Advertisement
neutale

Custom Title Screen [XP]

Jan 19th, 2019
1,262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.14 KB | None | 0 0
  1. #==============================================================================
  2. # ++ Custom Title Screen [XP] ver. 1.11 ++
  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/Titles" folder)
  17.   #(When command is not selected, the format reset itself)
  18.  
  19.   # New Game
  20.   IMG_NEWGAME = ["newgame","newgame_active"]
  21.   IMG_NEWGAME_X = 450   # X coordinate
  22.   IMG_NEWGAME_Y = 320   # Y coordinate
  23.   # Continue
  24.   IMG_LOAD = ["continue","continue_active"]
  25.   IMG_LOAD_X = 450   # X coordinate
  26.   IMG_LOAD_Y = 360   # Y coordinate
  27.   # Shutdown
  28.   IMG_END = ["shutdown","shutdown_active"]
  29.   IMG_END_X = 450   # X coordinate
  30.   IMG_END_Y = 400   # 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_LOAD_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.   # Menu Commands Labels
  44.   MENU_NEWGAME = "New Game"  # New Game
  45.   MENU_LOAD = "Continue"   # Load
  46.   MENU_END = "Shutdown"    # Shutdown
  47.  
  48.   # Hide window pane (true / false)
  49.   WINDOW_TRANS = false
  50.   # Window transparency (specified when window pane is displayed)
  51.   WINDOW_OPACITY = 160
  52.  
  53.   # Horizontal window width
  54.   WINDOW_WIDTH = 192
  55.   # Horizontal window position ( 0:default / 1:left  / 2:center / 3:right )
  56.   WINDOW_ALIGN = 2
  57.   # Window X coordinate
  58.   WINDOW_POS_X = 0
  59.   # Vertical window position ( 0:default / 1:upper  / 2:center / 3:lower )
  60.   WINDOW_VALIGN = 0
  61.   # Window Y coordinate
  62.   WINDOW_POS_Y = 288
  63.  
  64. end
  65.  
  66. # ↑ Setting are here
  67. #------------------------------------------------------------------------------
  68.  
  69. #==============================================================================
  70. # ■ Scene_Title
  71. #==============================================================================
  72.  
  73. class Scene_Title
  74.   #--------------------------------------------------------------------------
  75.   # ● Main processing
  76.   #--------------------------------------------------------------------------
  77.   def main
  78.     # if battle test
  79.     if $BTEST
  80.       battle_test
  81.       return
  82.     end
  83.     # Load database
  84.     $data_actors        = load_data("Data/Actors.rxdata")
  85.     $data_classes       = load_data("Data/Classes.rxdata")
  86.     $data_skills        = load_data("Data/Skills.rxdata")
  87.     $data_items         = load_data("Data/Items.rxdata")
  88.     $data_weapons       = load_data("Data/Weapons.rxdata")
  89.     $data_armors        = load_data("Data/Armors.rxdata")
  90.     $data_enemies       = load_data("Data/Enemies.rxdata")
  91.     $data_troops        = load_data("Data/Troops.rxdata")
  92.     $data_states        = load_data("Data/States.rxdata")
  93.     $data_animations    = load_data("Data/Animations.rxdata")
  94.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  95.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  96.     $data_system        = load_data("Data/System.rxdata")
  97.     # Create game system
  98.     $game_system = Game_System.new
  99.     # Create title graphic
  100.     @sprite = Sprite.new
  101.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  102.     # Create command window
  103.     s1 = PARA_TITLE_CUSTOM::MENU_NEWGAME
  104.     s2 = PARA_TITLE_CUSTOM::MENU_LOAD
  105.     s3 = PARA_TITLE_CUSTOM::MENU_END
  106.     w = PARA_TITLE_CUSTOM::WINDOW_WIDTH
  107.     @command_window = Window_Command.new(w, [s1, s2, s3])
  108.     if PARA_TITLE_CUSTOM::WINDOW_TRANS
  109.       @command_window.opacity = 0
  110.     else
  111.       @command_window.back_opacity = PARA_TITLE_CUSTOM::WINDOW_OPACITY
  112.     end
  113.     # Command window position
  114.     case PARA_TITLE_CUSTOM::WINDOW_ALIGN
  115.       when 0
  116.         @command_window.x = PARA_TITLE_CUSTOM::WINDOW_POS_X
  117.       when 1
  118.         @command_window.x = 0
  119.       when 2
  120.         @command_window.x = ( 640 - @command_window.width ) / 2
  121.       when 3
  122.         @command_window.x = 640 - @command_window.width
  123.     end
  124.     case PARA_TITLE_CUSTOM::WINDOW_VALIGN
  125.       when 0
  126.         @command_window.y = PARA_TITLE_CUSTOM::WINDOW_POS_Y
  127.       when 1
  128.         @command_window.y = 0
  129.       when 2
  130.         @command_window.y = ( 480 - @command_window.height ) / 2
  131.       when 3
  132.         @command_window.y = 480 - @command_window.height
  133.     end
  134.     # Continue valid decision
  135.     # Check whether there is even one saved file
  136.     # If enabled, set @continue_enabled to true, false if it is invalid
  137.     @continue_enabled = false
  138.     for i in 0..3
  139.       if FileTest.exist?("Save#{i+1}.rxdata")
  140.         @continue_enabled = true
  141.       end
  142.     end
  143.     # Images for menu commands
  144.     if PARA_TITLE_CUSTOM::IMG_MENU
  145.       @command_window.visible = false
  146.       @command_img0 = Sprite.new
  147.       @command_img0.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  148.       @command_img0.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_NEWGAME[0])
  149.       @command_img0.x = PARA_TITLE_CUSTOM::IMG_NEWGAME_X
  150.       @command_img0.y = PARA_TITLE_CUSTOM::IMG_NEWGAME_Y
  151.       @command_img1 = Sprite.new
  152.       @command_img1.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  153.       @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD[0])
  154.       @command_img1.x = PARA_TITLE_CUSTOM::IMG_LOAD_X
  155.       @command_img1.y = PARA_TITLE_CUSTOM::IMG_LOAD_Y
  156.       @command_img2 = Sprite.new
  157.       @command_img2.blend_type = PARA_TITLE_CUSTOM::BLEND_TYPE
  158.       @command_img2.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_END[0])
  159.       @command_img2.x = PARA_TITLE_CUSTOM::IMG_END_X
  160.       @command_img2.y = PARA_TITLE_CUSTOM::IMG_END_Y
  161.       # When Continue is active, move the cursor to Continue
  162.       # If it is invalid, Continue text will be translucent
  163.       if @continue_enabled
  164.         select_img_item(1)
  165.       else
  166.         case PARA_TITLE_CUSTOM::LOAD_DISABLED_TYPE
  167.           when 0
  168.             @command_img1.opacity = 160
  169.           when 1
  170.             @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD_DISABLED[0])
  171.         end
  172.         select_img_item(0)
  173.       end
  174.     end
  175.     # Play title BGM
  176.     $game_system.bgm_play($data_system.title_bgm)
  177.     # ME、BGS stop playing
  178.     Audio.me_stop
  179.     Audio.bgs_stop
  180.     # Transition execution
  181.     Graphics.transition
  182.     # Main loop
  183.     loop do
  184.       # Update graphics
  185.       Graphics.update
  186.       # Update input
  187.       Input.update
  188.       # Update
  189.       update
  190.       # Interrupt the loop when if scene switch
  191.       if $scene != self
  192.         break
  193.       end
  194.     end
  195.     # Transition preparation
  196.     Graphics.freeze
  197.     # Dispose command window
  198.     @command_window.dispose
  199.     if PARA_TITLE_CUSTOM::IMG_MENU
  200.       @command_img0.dispose
  201.       @command_img1.dispose
  202.       @command_img2.dispose
  203.     end
  204.     # Dispose title image
  205.     @sprite.bitmap.dispose
  206.     @sprite.dispose
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● Update
  210.   #--------------------------------------------------------------------------
  211.   alias update_para_tcst update
  212.   def update
  213.     update_para_tcst
  214.     if PARA_TITLE_CUSTOM::IMG_MENU
  215.       if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
  216.         # Image select
  217.         select_img_item(@command_window.index)
  218.       end
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ○ Image on title screen
  223.   #--------------------------------------------------------------------------
  224.   def select_img_item(index)
  225.     @command_window.index = index
  226.     # Unselected
  227.     @command_img0.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_NEWGAME[0])
  228.     case PARA_TITLE_CUSTOM::LOAD_DISABLED_TYPE
  229.       when 0
  230.         @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD[0])
  231.       when 1
  232.         if @continue_enabled
  233.           @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD[0])
  234.         else
  235.           @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD_DISABLED[0])
  236.         end
  237.     end
  238.     @command_img2.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_END[0])
  239.     # Selected image
  240.     case @command_window.index
  241.       when 0  # New Game
  242.         @command_img0.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_NEWGAME[1])
  243.       when 1  # Continue
  244.         case PARA_TITLE_CUSTOM::LOAD_DISABLED_TYPE
  245.           when 0
  246.             @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD[1])
  247.           when 1
  248.             if @continue_enabled
  249.               @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD[1])
  250.             else
  251.               @command_img1.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_LOAD_DISABLED[1])
  252.             end
  253.           end
  254.       when 2  # Shutdown
  255.       @command_img2.bitmap = RPG::Cache.title(PARA_TITLE_CUSTOM::IMG_END[1])
  256.     end
  257.   end
  258. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement