Advertisement
neutale

Custom Title Screen [VX]

Jan 18th, 2019
2,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.93 KB | None | 0 0
  1. #==============================================================================
  2. # ++ Custom Title Screen [VX] ver. 1.00 ++
  3. #  Script by paradog
  4. #  http://2d6.parasite.jp/
  5. #------------------------------------------------------------------------------
  6. # Use images in the title menu, or change the appearance of the menu window.
  7. #==============================================================================
  8.  
  9. module PARA_TITLE_CUSTOM
  10.  
  11.   # images for menu commands ( true / false )
  12.   IMG_MENU = true
  13.  
  14. #↓---Setting for using images in menu commands---
  15.  
  16.   # Image file name used for menu command (imported from "Graphics / System")
  17.   #(When command is not selected, the format reset itself)
  18.  
  19.   # New Game
  20.   IMG_NEWGAME = ["newgame","newgame_active"]
  21.   IMG_NEWGAME_X = 200   # X coordinate
  22.   IMG_NEWGAME_Y = 300   # Y coordinate
  23.   # Continue
  24.   IMG_CONTINUE = ["continue","continue_active"]
  25.   IMG_CONTINUE_X = 200   # X coordinate
  26.   IMG_CONTINUE_Y = 332   # Y coordinate
  27.   # Shutdown
  28.   IMG_SHUTDOWN = ["shutdown","shutdown_active"]
  29.   IMG_SHUTDOWN_X = 200   # X coordinate
  30.   IMG_SHUTDOWN_Y = 364   # Y coordinate
  31.  
  32.   # Continue disabled (0: translucent / 1: designates image)
  33.   LOAD_DISABLED_TYPE = 0
  34.  
  35.   # Image when Continue is disabled
  36.   IMG_CONTINUE_DISABLED = ["continue_disabled","continue_disabled_active"]
  37.  
  38.   # Image blend type ( 0:default / 1:add  / 2:subtract )
  39.   BLEND_TYPE = 0
  40.  
  41. #↓---Setting if menu isn't using an image---
  42.  
  43.   # Hide window pane (true / false)
  44.   WINDOW_TRANS = false
  45.   # Window transparency (specified when window pane is displayed)
  46.   WINDOW_OPACITY = 160
  47.  
  48.   # Horizontal window width
  49.   WINDOW_WIDTH = 172
  50.   # Horizontal window position ( 0:default / 1:left  / 2:center / 3:right )
  51.   WINDOW_ALIGN = 2
  52.   # Window X coordinate
  53.   WINDOW_POS_X = 0
  54.   # Vertical window position ( 0:default / 1:upper  / 2:center / 3:lower )
  55.   WINDOW_VALIGN = 0
  56.   # Window Y coordinate
  57.   WINDOW_POS_Y = 288
  58.  
  59. end
  60.  
  61. # ↑ Setting are here
  62. #------------------------------------------------------------------------------
  63.  
  64. #==============================================================================
  65. # ■ Scene_Title
  66. #==============================================================================
  67.  
  68. class Scene_Title < Scene_Base
  69.   #--------------------------------------------------------------------------
  70.   # ● Create command window
  71.   #--------------------------------------------------------------------------
  72.   def create_command_window
  73.     s1 = Vocab::new_game
  74.     s2 = Vocab::continue
  75.     s3 = Vocab::shutdown
  76.     w = PARA_TITLE_CUSTOM::WINDOW_WIDTH
  77.     @command_window = Window_Command.new(w, [s1, s2, s3])
  78.     @command_window.x = (544 - @command_window.width) / 2
  79.     @command_window.y = 288
  80.     if @continue_enabled                    # if continue enabled
  81.       @command_window.index = 1             # cursor movement
  82.     else                                    # invalid case
  83.       @command_window.draw_item(1, false)   # set command window translucent
  84.     end
  85.     @command_window.openness = 0
  86.     # command window image usage
  87.     if PARA_TITLE_CUSTOM::IMG_MENU
  88.       # hide command window
  89.       @command_window.opacity = 0
  90.       @command_window.contents_opacity = 0
  91.       create_img_command_window
  92.     else
  93.       change_window_visual
  94.     end
  95.     @command_window.open
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ○ Command window visual setting
  99.   #--------------------------------------------------------------------------
  100.   def change_window_visual
  101.     # Window transparency
  102.     if PARA_TITLE_CUSTOM::WINDOW_TRANS
  103.       @command_window.opacity = 0
  104.     else
  105.       @command_window.back_opacity = PARA_TITLE_CUSTOM::WINDOW_OPACITY
  106.     end
  107.     # Command window position
  108.     case PARA_TITLE_CUSTOM::WINDOW_ALIGN
  109.       when 0
  110.         @command_window.x = PARA_TITLE_CUSTOM::WINDOW_POS_X
  111.       when 1
  112.         @command_window.x = 0
  113.       when 2
  114.         @command_window.x = ( 544 - @command_window.width ) / 2
  115.       when 3
  116.         @command_window.x = 544 - @command_window.width
  117.     end
  118.     case PARA_TITLE_CUSTOM::WINDOW_VALIGN
  119.       when 0
  120.         @command_window.y = PARA_TITLE_CUSTOM::WINDOW_POS_Y
  121.       when 1
  122.         @command_window.y = 0
  123.       when 2
  124.         @command_window.y = ( 416 - @command_window.height ) / 2
  125.       when 3
  126.         @command_window.y = 416 - @command_window.height
  127.     end
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ○ Create image command window
  131.   #--------------------------------------------------------------------------
  132.   def create_img_command_window
  133.     # Create sprite
  134.     sprite1 = Sprite.new
  135.     sprite1.x = PARA_TITLE_CUSTOM::IMG_NEWGAME_X
  136.     sprite1.y = PARA_TITLE_CUSTOM::IMG_NEWGAME_Y
  137.     sprite1.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  138.     sprite2 = Sprite.new
  139.     sprite2.x = PARA_TITLE_CUSTOM::IMG_CONTINUE_X
  140.     sprite2.y = PARA_TITLE_CUSTOM::IMG_CONTINUE_Y
  141.     sprite2.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  142.     sprite3 = Sprite.new
  143.     sprite3.x = PARA_TITLE_CUSTOM::IMG_SHUTDOWN_X
  144.     sprite3.y = PARA_TITLE_CUSTOM::IMG_SHUTDOWN_Y
  145.     sprite3.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  146.     # Manage by spriteset
  147.     @command_sprites = [sprite1, sprite2, sprite3]
  148.     # Manage bitmap filenames as array
  149.     @command_bitmaps = [PARA_TITLE_CUSTOM::IMG_NEWGAME, PARA_TITLE_CUSTOM::IMG_CONTINUE, PARA_TITLE_CUSTOM::IMG_SHUTDOWN]
  150.     if @continue_enabled                    # When continue enabled
  151.       select_img_item(1)                    # Cursor movement
  152.     else                                    # Invalid case
  153.       case PARA_TITLE_CUSTOM::LOAD_DISABLED_TYPE
  154.         when 0  # semi-transparent image
  155.           @command_sprites[1].opacity = 160
  156.         when 1  # disabled image only
  157.           @command_bitmaps[1] = PARA_TITLE_CUSTOM::IMG_CONTINUE_DISABLED
  158.       end
  159.       select_img_item(0)                    # Cursor movement
  160.     end
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● Update
  164.   #--------------------------------------------------------------------------
  165.   def update
  166.     super
  167.     @command_window.update
  168.     if PARA_TITLE_CUSTOM::IMG_MENU
  169.       if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
  170.         # select image
  171.         select_img_item(@command_window.index)
  172.       end
  173.     end
  174.     if Input.trigger?(Input::C)
  175.       case @command_window.index
  176.       when 0    # new game
  177.         command_new_game
  178.       when 1    # continue
  179.         command_continue
  180.       when 2    # shutdown
  181.         command_shutdown
  182.       end
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ○ Image set during menu selection
  187.   #--------------------------------------------------------------------------
  188.   def select_img_item(index)
  189.     case index
  190.       when 0
  191.         @command_sprites[0].bitmap = Cache.system(@command_bitmaps[0][1])
  192.         @command_sprites[1].bitmap = Cache.system(@command_bitmaps[1][0])
  193.         @command_sprites[2].bitmap = Cache.system(@command_bitmaps[2][0])
  194.       when 1
  195.         @command_sprites[0].bitmap = Cache.system(@command_bitmaps[0][0])
  196.         @command_sprites[1].bitmap = Cache.system(@command_bitmaps[1][1])
  197.         @command_sprites[2].bitmap = Cache.system(@command_bitmaps[2][0])
  198.       when 2
  199.         @command_sprites[0].bitmap = Cache.system(@command_bitmaps[0][0])
  200.         @command_sprites[1].bitmap = Cache.system(@command_bitmaps[1][0])
  201.         @command_sprites[2].bitmap = Cache.system(@command_bitmaps[2][1])
  202.     end
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● Dispose command window
  206.   #--------------------------------------------------------------------------
  207.   def dispose_command_window
  208.     @command_window.dispose
  209.     if @command_sprites != nil
  210.       @command_sprites[0].dispose
  211.       @command_sprites[1].dispose
  212.       @command_sprites[2].dispose
  213.     end
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● Open command window
  217.   #--------------------------------------------------------------------------
  218.   def open_command_window
  219.     # Display when window background is hidden
  220.     if PARA_TITLE_CUSTOM::WINDOW_TRANS
  221.       @command_window.openness = 255
  222.     end
  223.     @command_window.open
  224.     begin
  225.       @command_window.update
  226.       Graphics.update
  227.     end until @command_window.openness == 255
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● Close command window
  231.   #--------------------------------------------------------------------------
  232.   def close_command_window
  233.     # Don't close when window background is hidden
  234.     if not(PARA_TITLE_CUSTOM::WINDOW_TRANS)
  235.       @command_window.close
  236.       begin
  237.         @command_window.update
  238.         Graphics.update
  239.       end until @command_window.openness == 0
  240.     end
  241.   end
  242. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement