Advertisement
Guest User

Untitled

a guest
Nov 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 37.19 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. #           HERETIC'S ANIMATE TITLE SCREENS WITH EVENTS
  4. #           Version 1.02
  5. #           Tuesday, March 19th, 2013
  6. #
  7. #===============================================================================
  8. #
  9. # UPDATE NOTES
  10. #
  11. # Version 1.02
  12. # - Added Options to specify a Windowskin
  13. # - Added Align Option for Left, Center, and Right
  14. # - Added Shadowed Text Option for the Title Menu
  15. #
  16. # Version 1.01
  17. # - Script slightly updated to be compatible with a script by
  18. #   diagostimo which allows Scripted Keypresses by Faking User Input
  19. #
  20. #
  21. #
  22. # Introduction:  This script will allow you to Animate your Title Screen
  23. # using nothing but Events!  Not everyone is a scripter, but if you are
  24. # good at Eventing, then this is the script for you!
  25. #
  26. # How it Works:  The first thing you'll notice the Title Screen in this Demo
  27. # is an In-Game Map.  Using the Map as a Title Screen is what allows you to
  28. # use Events to Animate the Title Screen instead of complex Scripting.
  29. #
  30. # Game Map as a Title Screens allows you to do anything you want.  You can
  31. # show a Full Screen Picture as your Title Screen too!  What else this
  32. # allows you to do is to Animate any aspect of your Title Screen, so if
  33. # you wanted your Title Screen to have a Background Image then make your
  34. # Game Title fly in from the side, you can do that too!  You are only limited
  35. # by your Imagination and the limits of the RMXP engine to move stuff around!
  36. #
  37. # In this Demo, I just imported a couple of quickly made Pictures that were
  38. # slapped together in Photoshop, then used Events to show the Pictures to use
  39. # as the Game Title, then Animated them just a bit.  But if you wanted to put
  40. # in a Prelude to your Story, or if you have a nice custom Battle System that
  41. # you wanted to show off, you can do that too!  Even the Crapcom Logo is done
  42. # all by Events and Pictures!
  43. #
  44. # Technical Stuff:
  45. #
  46. # To bring up the Title Menu (New Game /  Continue / Shut Down), you need
  47. # to run a Script: "display_title_menu".  The Title Menu will NOT be displayed
  48. # UNTIL you call "display_title_menu" (without the quotes) from an Event
  49. # Script.  The Event should be an Autorun or a Parallel Event.  The Scripts
  50. # window is on Page 3 in the bottom right.
  51. #
  52. # If you run "hide_title_menu", this will prevent the Player from bringing
  53. # it back by hitting a Key.  I set up this script to fade out the Title Menu
  54. # after a period of inactivity, which you can customize.  If you want it to
  55. # stay, just set TITLE_MAP_INACTIVE_TIMEOUT to a really long time.
  56. #
  57. # The Player Graphic is set to None (optional) when starting up.  If you want
  58. # or need to change the Player to be Visible, you'll need to change the Player
  59. # Graphic.  Events -> Page 3 -> Bottom Left Corner is a button called
  60. # "Change Actor Graphic".  Use this to make the Player visible again.
  61. #
  62. # Another Feature is to only allow the Title Menu (New Game / Cont. etc) to
  63. # appear on certain Maps.  If the player hits a Key on ANY other map during
  64. # your Demo (before New Game or Continuing), everything will Reset and the
  65. # whole process will start all over.  The option is an Array, so you can
  66. # show the Title Menu on different Maps, not just one.
  67. #
  68. #
  69. # Non Scripters need to learn Global Variables!
  70. #
  71. # Global Variables - These are super easy.  $foo = "bar"  The Dollar Sign ($)
  72. # defines a Variable as a Global Variable.  You can check a Global Variable
  73. # from anywhere.  If you run a Script in one Map that says $foo = "bar", then
  74. # go into Battle, you can access $foo from Battle.  
  75. #
  76. # Global Variables are VERY IMPORTANT to using this Script.  They DO NOT RESET
  77. # when the Title Scene starts over.  All other Game Data WILL reset!  Switches,
  78. # Variables, anything you may have done to the Party, everything except
  79. # for Global Variables will be reset!  I am pointing out the importance of
  80. # using Global Variables to show you how to retain some data.  Global Variables
  81. # will even retain their values if you hit F12 to reset the game.  One other
  82. # thing about Global Variables is they are NOT saved if you Save a Game, then
  83. # close the program, open it up, and Load that Saved Game.  Once you close
  84. # the program, Global Variables lose their value.  Also, dont put numbers
  85. # as the first character in the Name of your Variable.  $1st_Scene will
  86. # cause a Crash!
  87. #
  88. #
  89. #
  90. #
  91. # -----   Eventing   ------
  92. #
  93. # I did some things that may seem "Screwy" in my events.  I didnt want the
  94. # Script to take control of anything away from Eventing.  In the Demo, if
  95. # the Player hits a Key, the "slower" animation is skipped and it brings up
  96. # the Title Menu (New Game / Cont. / etc) as quickly as possible.  What I
  97. # did there was to run a Parallel Event that checks to see if the Player
  98. # hit a Key with "title_escape_keys?", and if they did, run a much faster
  99. # version of the Title.
  100. #
  101. #
  102. #
  103. #
  104. # -----   Hacking   ------
  105. #
  106. # The original version of this script explained how to do some minor "hacks"
  107. # to various systems to get them to do things they werent supposed to do.
  108. #
  109. # I wasnt fond of the idea, and decided that Simulating User Input was a better
  110. # way and far more compatible.  But Simulating User Input turned into its own
  111. # standalone script that I bundled with this one.  Trust me, its a lot easier
  112. # to just use the Timed / Simulated User Input script than it is to try to get
  113. # the numerous scripts out there to do things they arent really supposed to do.
  114. #
  115. #
  116. #
  117. #
  118. #
  119. # -----   COMMANDS   -----
  120. #
  121. # - display_title_menu  
  122. # *   Use an Event Script to display the Title Menu
  123. # **  MUST BE RUN for Title Menu to be displayed at all!
  124. # **  Current MAP ID needs to be Allowed in Script Configuration
  125. #
  126. # - hide_title_menu      
  127. # *   Prevents the Title Menu from Displaying
  128. #
  129. # - restart_title_scene
  130. # *   Restarts the Title Scene
  131. # **  Same thing as calling $scene = Scene_Title.new
  132. #
  133. # - title_escape_keys?  
  134. # *   Pressing a Key will make this return True
  135. # **  Use in Events in a Conditional Branch -> Script to check
  136. #
  137. # - displaying_title_menu?
  138. # *   This returns True if the Title Menu (New Game) is even partially showing
  139. # **  Use in Events in a Conditional Branch -> Script to check
  140. #
  141. # Everything else is controlled by Events and some Global Variables, and you!
  142. #
  143. # *** Notes ***
  144. #
  145. # When the game is first fired up, the Player is transferred to a Map before
  146. # any Autorun Events have had a chance to do anything.  If the Map that the
  147. # player lands on is anything but EMPTY, you'll see what ever is there for a
  148. # split second.  To get around this, I set up the First Map that the Player
  149. # lands on to be All Black, then fade the Screen to Black, then transfer the
  150. # Player.  This prevents any visual artifacts from popping through and makes
  151. # it look "clean".  The 2nd Map is the one where I allow the Title Menu
  152. # to be displayed.  If you want to use a different Windowskin, you can do
  153. # it on the first map.
  154. #
  155. # This Script does not care where you put your Player Start.  It ignores it
  156. # so you can set up the Player Start and TITLE_MAP_ID to be different.
  157. #
  158. # The Style is up to you!
  159. #
  160. # Displaying an In Game Map as a Title Screen is a Style Choice that is totally
  161. # up to you.  You can use a Static Image if you want.  To do this, Import your
  162. # Static Image into Pictures, and use an Event to display that Picture as
  163. # your Title Screen.  The Map is loaded because it allows you to control
  164. # what goes on screen through Eventing, but it is not necessary to display
  165. # any sort of Game Map what so ever.  Some classic games show Game Maps instead
  166. # of Title Screens.  The first Super Mario Bros. on the 8-bit NES, Sonic the
  167. # Hedgehog on the Sega Genesis, and even games like God of War have fully
  168. # animated Title Scenes.  
  169. #
  170. # -----   LEGAL   ----
  171. #
  172. # This script is Free for Public and Commercial Use.  You can modify it to suit
  173. # your needs.  Distribution of this script just requires that you give me credit
  174. # as the Original Author.  You are also allowed to post it publicly on any
  175. # website you want.
  176.  
  177. #==============================================================================
  178. # ** Scene_Title
  179. #------------------------------------------------------------------------------
  180. #  This class performs title screen processing.
  181. #===============================================================================
  182.  
  183. class Scene_Map
  184.   #---------   SCRIPT CONFIGURATION   -------------#
  185.  
  186.   TITLE_SKIN = "Blank"                   # Skin for Title Menu
  187.   TITLE_MAP_ID = 4                       # Map ID to move Player to
  188.   TITLE_MAP_X = 7                         # X coordinate on Title Map
  189.   TITLE_MAP_Y = 7                         # Y coordinate on Title Map
  190.   TITLE_MAP_PLAYER_DIRECTION = 2          # Direction to start Player
  191.   MAP_IDS_TO_ALLOW_WINDOW = [5]          # Map ID's allowed to display Window
  192.   TITLE_HIDE_PLAYER = true                # Set Player Graphic to None if True
  193.   TITLE_FULLSCREEN = false                 # Start Game in Fullscreen
  194.  
  195.   TITLE_MENU_ALIGN = 1                    # 0 = Left, 1 = Center, 2 = Right
  196.   TITLE_MENU_SHADOW_TEXT = false           # Display Text with Text Shadows
  197.  
  198.   GAME_SWITCHES_TO_ENABLE = [1]           # Game Switches you want set to ON
  199.                                           # Set to [] if you dont want any
  200.                                           # Use commas to separate if you
  201.                                           # want Multiple Switches
  202.                                           # IE:  [1,2,4]
  203.  
  204.  
  205.   # WINDOW CONFIGURATION - New Game / Continue / Shutdown
  206.  
  207.   TITLE_MAP_WINDOW_OPACITY = 0          # Window Opacity of the New Game Window
  208.   TITLE_MAP_WINDOW_BACK_OPACITY = 0     # The Windows Background - Windowskin
  209.   TITLE_MAP_WINDOW_CONTENTS_OPACITY = 0 # The Windows Border from the Windowskin
  210.   TITLE_MAP_WINDOW_FADE_RATE = 10         # Fade Out Subtracts this from Opacity per Frame
  211.   TITLE_MAP_INACTIVE_TIMEOUT = 99999          # Timeout in Seconds
  212.  
  213.   # Windowskin Note -  You can change the Windowskin with an Autorun Event on
  214.   # your first map, or in the Database, System, Windowskin Graphic
  215.  
  216.   # Coordinates for special command window [x, y]
  217.   # These are pictures instead of the actual window
  218.   SPEC_COMMAND = [160,230]
  219.  
  220.   # Custom sound effect for selection
  221.   CUSTOM_SELECT_SOUND = "105-Heal01"
  222.  
  223. end
  224.  
  225. # If you want different Keys to Display the Menu, set them here.
  226. # This should be pretty easy to figure out, even for non scripters.
  227.  
  228. class Interpreter
  229.   # Pressing any of the Keys here will make this return true
  230.   def title_escape_keys?
  231.     # Only works if this is a Title Scene
  232.     if $title_scene
  233.       # If the Player hit any of the B, C, Up or Down Keys
  234.       if Input.trigger?(Input::B) or
  235.          Input.trigger?(Input::C) or    # The Confirm or Enter Key
  236.          Input.trigger?(Input::UP) or   # The UP Key
  237.          Input.trigger?(Input::DOWN) or # The DOWN Key
  238.          Input.trigger?(Input::LEFT) or # The LEFT Key
  239.          Input.trigger?(Input::RIGHT)   # The RIGHT Key - No 'OR' at the end
  240.         # Return True that one of the Above Keys had been pressed
  241.         return true
  242.       end
  243.       return false
  244.     end
  245.   end
  246.  
  247.   # If the New Game / Continue Window is showing, even partially
  248.   def displaying_title_menu?
  249.     return true if $title_scene and $scene.command_window and
  250.                    ($scene.command_window.active or
  251.                     $scene.command_window.opacity > 0 or
  252.                     $scene.command_window.back_opacity > 0 or
  253.                     $scene.command_window.contents_opacity > 0)
  254.   end
  255.  
  256.   # This displays the Title Menu - MUST BE CALLED TO MAKE TITLE MENU APPEAR!
  257.   def display_title_menu
  258.     if $title_scene
  259.       $scene.hide_title_menu = false      
  260.       $scene.display_title_menu = true
  261.     end
  262.     return
  263.   end
  264.  
  265.   # This prevents the Title Menu from being displayed on Key Press
  266.   def hide_title_menu
  267.     if $title_scene
  268.       $scene.hide_title_menu = true
  269.       $scene.display_title_menu = false
  270.     end
  271.     return
  272.   end  
  273.  
  274.   # Restarts the game, basically. Calling $scene = Scene_Title.new does the same
  275.   def restart_title_scene
  276.     # This Resets All Game Data, but not Global Variables like $foo
  277.     $scene = Scene_Title.new
  278.   end
  279.  
  280. end
  281.  
  282. #==============================================================================
  283. # ** Window_Command - Modified to allow Centering, Shadowing and Skinning
  284. #------------------------------------------------------------------------------
  285. #  This window deals with general command choices.
  286. #
  287. #  You can edit the Choices available in the Menu, but remember, you'll still
  288. #  have to set up other commands to make any additional Menu Options work.
  289. #
  290. #==============================================================================
  291.  
  292. class Window_Command_Center < Window_Selectable
  293.   #--------------------------------------------------------------------------
  294.   # * Object Initialization
  295.   #     width    : window width
  296.   #     commands : command text string array
  297.   #--------------------------------------------------------------------------
  298.   def initialize(width, commands)
  299.     # Compute window height from command quantity
  300.     super(0, 0, width, commands.size * 32 + 32)
  301.     @item_max = commands.size
  302.     @commands = commands
  303.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  304.     refresh
  305.     self.index = 0
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # * Refresh
  309.   #--------------------------------------------------------------------------
  310.   def refresh
  311.     self.contents.clear
  312.     for i in 0...@item_max
  313.       draw_item(i, normal_color)
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # * Draw Shadow Text
  318.   #--------------------------------------------------------------------------
  319.   def draw_shadow_text(x, y, width, height, string, align = 0)
  320.     # Duplicate the Font Color
  321.     color = self.contents.font.color.dup
  322.     # Set Current Font Color to Black
  323.     self.contents.font.color = Color.new(0, 0, 0)
  324.     self.contents.draw_text(x + 2, y + 2, width, height, string, align)
  325.     # Draw Text using Stored Color
  326.     self.contents.font.color = color
  327.     self.contents.draw_text(x, y, width, height, string, align)
  328.   end  
  329.   #--------------------------------------------------------------------------
  330.   # * Draw Item
  331.   #     index : item number
  332.   #     color : text color
  333.   #--------------------------------------------------------------------------
  334.   def draw_item(index, color)
  335.     self.contents.font.color = color
  336.     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
  337.     align = Scene_Map::TITLE_MENU_ALIGN
  338.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  339.     if Scene_Map::TITLE_MENU_SHADOW_TEXT
  340.       # Draws Shadowed Text Menu Options
  341.       draw_shadow_text(4, 32 * index, self.contents.width - 8, 32,
  342.                        @commands[index], align)
  343.     else
  344.       # Draws Text without Shadows
  345.       self.contents.draw_text(rect, @commands[index], align)
  346.     end
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # * Disable Item
  350.   #     index : item number
  351.   #--------------------------------------------------------------------------
  352.   def disable_item(index)
  353.     draw_item(index, disabled_color)
  354.     #make command for continue grey
  355.   end
  356. end
  357.  
  358. #==============================================================================
  359. # ** Scene_Title
  360. #------------------------------------------------------------------------------
  361. #  This class performs title screen processing.
  362. #===============================================================================
  363.  
  364. class Scene_Title
  365.   #--------------------------------------------------------------------------
  366.   # * Main Processing - Full Redefinition
  367.   #--------------------------------------------------------------------------
  368.   def main
  369.     # check for Battle Testing
  370.     if $BTEST
  371.       # This ONLY happens when you test a Battle from the Database => Troops
  372.       # and does NOT happen at all during gameplay, ever
  373.       #
  374.       # Set up variables for Test Battle
  375.       battle_test
  376.       # Quit Processing - Exits the Program
  377.       return
  378.     end
  379.     # Terminate Any Audio - needed after a restart
  380.     Audio.bgm_stop
  381.     Audio.bgs_stop
  382.     Audio.me_stop
  383.     # Load database
  384.     $data_actors        = load_data("Data/Actors.rxdata")
  385.     $data_classes       = load_data("Data/Classes.rxdata")
  386.     $data_skills        = load_data("Data/Skills.rxdata")
  387.     $data_items         = load_data("Data/Items.rxdata")
  388.     $data_weapons       = load_data("Data/Weapons.rxdata")
  389.     $data_armors        = load_data("Data/Armors.rxdata")
  390.     $data_enemies       = load_data("Data/Enemies.rxdata")
  391.     $data_troops        = load_data("Data/Troops.rxdata")
  392.     $data_states        = load_data("Data/States.rxdata")
  393.     $data_animations    = load_data("Data/Animations.rxdata")
  394.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  395.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  396.     $data_system        = load_data("Data/System.rxdata")
  397.     # If going Fullscreen
  398.     if not $fullscreen and
  399.        Scene_Map::TITLE_FULLSCREEN
  400.       # Alt Enter to go to Fullscreen
  401.       showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  402.       showm.call(18,0,0,0)  # Hold the Alt Keyboard key
  403.       showm.call(13,0,0,0)  # Hold the Enter Keyboard key
  404.       showm.call(13,0,2,0)  # Release the Enter Keyboard key
  405.       showm.call(18,0,2,0)  # Release the Alt Keyboard key
  406.       $fullscreen = true
  407.     end    
  408.     # Make each type of game object
  409.     $game_temp          = Game_Temp.new
  410.     $game_system        = Game_System.new
  411.     $game_switches      = Game_Switches.new
  412.     $game_variables     = Game_Variables.new
  413.     $game_self_switches = Game_SelfSwitches.new
  414.     $game_screen        = Game_Screen.new
  415.     $game_actors        = Game_Actors.new
  416.     $game_party         = Game_Party.new
  417.     $game_troop         = Game_Troop.new
  418.     $game_map           = Game_Map.new
  419.     $game_player        = Game_Player.new
  420.     # Disable Menu Access
  421.     $game_system.menu_disabled = true      
  422.     # Set up initial party
  423.     $game_party.setup_starting_members
  424.     # Set up initial map position
  425.     $game_map.setup(Scene_Map::TITLE_MAP_ID)
  426.     # Move player to initial position
  427.     $game_player.moveto(Scene_Map::TITLE_MAP_X, Scene_Map::TITLE_MAP_Y)
  428.     $game_player.direction = Scene_Map::TITLE_MAP_PLAYER_DIRECTION
  429.     # Refresh player
  430.     $game_player.refresh
  431.    
  432.     # If the option to Hide the Player is set, set Opacity to Zero
  433.     if Scene_Map::TITLE_HIDE_PLAYER
  434.       $game_party.actors[0].character_name = ''
  435.       $game_player.refresh
  436.     end
  437.    
  438.     # Run automatic change for BGM and BGS set with map
  439.     $game_map.autoplay
  440.     # Update map (run parallel process event)
  441.     $game_map.update
  442.  
  443.     # Enable Game Switches in Configuration
  444.     for i in Scene_Map::GAME_SWITCHES_TO_ENABLE
  445.       # Enable the Game Switch
  446.       $game_switches.data[i] = true
  447.     end
  448.    
  449.     # Refresh map, because of switches
  450.     $game_map.need_refresh = true
  451.    
  452.     # Command Window moved to Scene_Map
  453.  
  454.     # Declare that this is a Title Scene.  This variable is false during play
  455.     $title_scene = true
  456.      
  457.     # Sends Player to the map
  458.     $scene = Scene_Map.new
  459.    
  460.     $scene.display_title_menu = false
  461.     $scene.hide_title_menu = true
  462.    
  463.     # Resets Fake User Input Scripts
  464.     if Input.respond_to? :clear_auto
  465.       Input.clear_auto
  466.     end
  467.   end
  468. end
  469.  
  470. class Game_Actor
  471.   attr_accessor :character_name
  472. end
  473.  
  474. #==============================================================================
  475. # ** Scene_Map
  476. #------------------------------------------------------------------------------
  477. #  This class performs map screen processing.
  478. #==============================================================================
  479.  
  480. class Scene_Map
  481.   attr_reader   :command_window  # Window for New Game / Continue / etc
  482.   attr_accessor :message_window  # Allows Closing with 'terminate_message'
  483.   attr_accessor :display_title_menu
  484.   attr_accessor :fade_out_title_menu
  485.   attr_accessor :hide_title_menu
  486.  
  487.   alias map_title_update update
  488.   def update
  489.     # Run Original
  490.     map_title_update
  491.     # Map Update - Only makes Title Map available during Title
  492.     if $title_scene
  493.       if Scene_Map::MAP_IDS_TO_ALLOW_WINDOW.include?($game_map.map_id)
  494.         # If Player pressed Enter or Inactive Time
  495.         if @display_title_menu and
  496.            not @command_window and          
  497.            not @hide_title_menu  
  498.           # Prevent the window from disappearing
  499.           @display_title_menu = false
  500.           @fade_out_title_menu = false
  501.          
  502.           # Make command window
  503.           s1 = "New Game"
  504.           s2 = "Continue"
  505.           s3 = "Shutdown"
  506.           s4 = "Credits"
  507.           @command_window = Window_Command_Center.new(192, [s1, s2, s3, s4])
  508.           @command_window.x = 639
  509.           @command_window.y = 479
  510.           @command_window.opacity = TITLE_MAP_WINDOW_OPACITY
  511.           @command_window.contents_opacity = TITLE_MAP_WINDOW_CONTENTS_OPACITY
  512.           @command_window.back_opacity = TITLE_MAP_WINDOW_BACK_OPACITY
  513.  
  514.           # Make special command window
  515.           @com = Sprite.new
  516.           @com.z = 999
  517.           @com.x = SPEC_COMMAND[0]
  518.           @com.y = SPEC_COMMAND[1]
  519.          
  520.           # Make special command window
  521.           @com_glow = Sprite.new
  522.           @com_glow.z = 99999
  523.           @com_glow.x = SPEC_COMMAND[0]
  524.           @com_glow.y = SPEC_COMMAND[1]
  525.          
  526.           # Custom Title Skin
  527.           if TITLE_SKIN
  528.             @command_window.windowskin = RPG::Cache.windowskin(TITLE_SKIN)
  529.           end
  530.           @command_window.active = true
  531.           @command_window.visible = true
  532.           @com.visible = true
  533.           # Continue enabled determinant
  534.           # Check if at least one save file exists
  535.           # If enabled, make @continue_enabled true; if disabled, make it false
  536.           @continue_enabled = false
  537.           for i in 0..3
  538.             if FileTest.exist?("Save#{i+1}.rxdata")
  539.               @continue_enabled = true
  540.             end
  541.           end
  542.           # If continue is enabled, move cursor to "Continue"
  543.           # If disabled, display "Continue" text in gray
  544.           if @continue_enabled
  545.             @command_window.index = 1
  546.           else
  547.             @command_window.disable_item(1)
  548.           end
  549.           # Store the Frame Counter for when this window was Displayed
  550.           @title_frames = Graphics.frame_count
  551.         # Show Window called by Script... display_title_menu
  552.         elsif @command_window and
  553.               @display_title_menu and
  554.               not @hide_title_menu and
  555.               not @command_window.disposed? and
  556.               not @command_window.active
  557.           # Set Command Window as Active and Visible, dont recreate
  558.           @com.visible = true
  559.           @command_window.active = true
  560.           @command_window.visible = true
  561.           @command_window.opacity = TITLE_MAP_WINDOW_OPACITY
  562.           @command_window.contents_opacity = TITLE_MAP_WINDOW_CONTENTS_OPACITY
  563.           @command_window.back_opacity = TITLE_MAP_WINDOW_BACK_OPACITY
  564.           @com.opacity = TITLE_MAP_WINDOW_OPACITY
  565.           # Prevent Hiding
  566.           @display_title_menu = false
  567.           @fade_out_title_menu = false
  568.           # Prevents Triggering Inactive Timeout
  569.           @title_frames = Graphics.frame_count          
  570.         # If Command Window Inactive, and Player hits a Key
  571.         elsif @command_window and
  572.               not @command_window.disposed? and
  573.               not @command_window.active and
  574.               not @hide_title_menu and              
  575.               not @display_title_menu and
  576.               $game_system.map_interpreter.title_escape_keys?  
  577.           # Set Command Window as Active and Visible, dont recreate
  578.           @com.visible = true
  579.           @com.opacity = TITLE_MAP_WINDOW_OPACITY
  580.           @command_window.active = true
  581.           @command_window.visible = true
  582.           @command_window.opacity = TITLE_MAP_WINDOW_OPACITY
  583.           @command_window.contents_opacity = TITLE_MAP_WINDOW_CONTENTS_OPACITY
  584.           @command_window.back_opacity = TITLE_MAP_WINDOW_BACK_OPACITY
  585.           # Prevent Hiding
  586.           @display_title_menu = false
  587.           @fade_out_title_menu = false
  588.           # Prevents Triggering Inactive Timeout
  589.           @title_frames = Graphics.frame_count          
  590.         # Window not created, and Player hits a Key when allowed to display menu
  591.         elsif not @hide_title_menu and
  592.               not @command_window and not @display_title_menu and
  593.               $game_system.map_interpreter.title_escape_keys?
  594.           # Force Title Menu to be Created - Above
  595.           @display_title_menu = true
  596.           # Prevent Hiding        
  597.           @fade_out_title_menu = false
  598.           # Prevents Triggering Inactive Timeout
  599.           @title_frames = Graphics.frame_count
  600.         # If we need to Hide the Menu or Force it off the Screen
  601.         elsif @fade_out_title_menu or @hide_title_menu
  602.           # If the Command Window exists and has not been disposed
  603.           if @command_window and not @command_window.disposed?
  604.             # If Window is Visible
  605.             if @command_window.opacity > 0 or
  606.                @command_window.contents_opacity > 0 or
  607.                @command_window.back_opacity > 0 or
  608.                @com.opacity > 0
  609.               # Fade Out the Window
  610.               @command_window.opacity -= TITLE_MAP_WINDOW_FADE_RATE
  611.               @command_window.contents_opacity -= TITLE_MAP_WINDOW_FADE_RATE
  612.               @command_window.back_opacity -= TITLE_MAP_WINDOW_FADE_RATE              
  613.               @command_window.active = false
  614.               @com.opacity -= TITLE_MAP_WINDOW_FADE_RATE
  615.             else
  616.               # End the Hiding Procedure
  617.               @fade_out_title_menu = false
  618.             end
  619.           end
  620.         # Window is Active, Update for Player Input
  621.         elsif @command_window and
  622.               not @command_window.disposed? and
  623.               @command_window.active
  624.           # Update the Title Window
  625.           title_window_update
  626.         end
  627.       elsif $game_system.map_interpreter.title_escape_keys? and
  628.             $game_map.map_id != TITLE_MAP_ID
  629.         # Prepare for transition
  630.         Graphics.freeze
  631.         # If New Game / Continue Window exists...
  632.         if @command_window
  633.           # Dispose of command window
  634.           @command_window.dispose
  635.           @com.dispose
  636.         end
  637.         # Restart the whole thing
  638.         $scene = Scene_Title.new
  639.       end
  640.     end
  641.   end
  642.  
  643.   #--------------------------------------------------------------------------
  644.   # * Player Place Move
  645.   #--------------------------------------------------------------------------
  646.   alias title_transfer_player transfer_player
  647.   def transfer_player
  648.     # If this is a Title Scene, Hide Window when transferring maps
  649.     if $title_scene
  650.       # If Window has been created
  651.       if @command_window
  652.         # Set special commands to invisible
  653.         @com.opacity = 0
  654.         # Set Opacity to 0
  655.         @command_window.opacity = 0
  656.         @command_window.back_opacity = 0
  657.         @command_window.contents_opacity = 0
  658.         # Prevent Selection
  659.         @command_window.active = false
  660.       end
  661.     end
  662.     # Call Original
  663.     title_transfer_player
  664.   end  
  665.  
  666.   #--------------------------------------------------------------------------
  667.   # * Title Command Window Timeout
  668.   #--------------------------------------------------------------------------  
  669.  
  670.   def title_timeout
  671.     # 40 is used for the Framerate
  672.     if Graphics.frame_count > TITLE_MAP_INACTIVE_TIMEOUT * 60 + @title_frames
  673.       return true
  674.     end
  675.   end
  676.  
  677.   #--------------------------------------------------------------------------
  678.   # * Update Title Window
  679.   #--------------------------------------------------------------------------
  680.   def title_window_update
  681.     # If Command Window isnt being Hidden
  682.     if @command_window.active
  683.       # If Key was pressed, reset Inactivity Frame Counter
  684.       if $game_system.map_interpreter.title_escape_keys?
  685.         # Store the Frame Counter for when this window was Displayed
  686.         # This prevents the Window from Fading out from Inactivity
  687.         @title_frames = Graphics.frame_count
  688.       else
  689.         if title_timeout
  690.           # Hide the Title Menu
  691.           @fade_out_title_menu = true
  692.           # Reset Frame Inactivity Counter
  693.           @title_frames = Graphics.frame_count
  694.         end
  695.       end
  696.     end
  697.     # Update command window
  698.     @command_window.update
  699.     # Draw the title pictures
  700.     case @command_window.index
  701.     when 0 #Draw "new game"
  702.        @com.bitmap = RPG::Cache.title("Com_01")
  703.        @com_glow.bitmap = RPG::Cache.title("Com_01_G")
  704.        #Call glowing method
  705.        glowing_selection
  706.     when 1 #Draw "continue"
  707.     # Check if continue is disabled
  708.        unless @continue_enabled
  709.             #Draw faded out
  710.             @com.bitmap = RPG::Cache.title("Com_02_Disable")
  711.        else
  712.             # Draw regular
  713.             @com.bitmap = RPG::Cache.title("Com_02")
  714.             @com_glow.bitmap = RPG::Cache.title("Com_02_G")
  715.             #Call glowing method
  716.             glowing_selection
  717.        end
  718.     when 2 #Draw "end"
  719.        @com.bitmap = RPG::Cache.title("Com_03")
  720.        @com_glow.bitmap = RPG::Cache.title("Com_03_G")
  721.        #Call glowing method
  722.        glowing_selection
  723.     when 3 #Draw "credits"
  724.        @com.bitmap = RPG::Cache.title("Com_04")
  725.        @com_glow.bitmap = RPG::Cache.title("Com_04_G")
  726.        #Call glowing method
  727.        glowing_selection
  728.     end
  729.     # If C button was pressed
  730.     if Input.trigger?(Input::C)
  731.       # Branch by command window cursor position
  732.       case @command_window.index
  733.       when 0  # New game
  734.         title_new_game
  735.       when 1  # Continue
  736.         title_continue
  737.       when 2  # Shutdown
  738.         title_shutdown
  739.       when 3  # Credits
  740.         title_credits
  741.       end
  742.     end
  743.   end
  744.  
  745.   #Method for glowing selection
  746.   def glowing_selection
  747.     #Fade it in and out
  748.     #Check the direction variable exists
  749.     if @com_glow.opacity == 255
  750.         com_opacity_direction = -1
  751.     elsif @com_glow.opacity == 0 || com_opacity_direction == nil
  752.         com_opacity_direction = 1
  753.     end
  754.     #Fade the sprite in and out
  755.     @com_glow.opacity += (com_opacity_direction * 15)
  756.   end
  757.  
  758.  
  759.  
  760.   #--------------------------------------------------------------------------
  761.   # * Title: New Game
  762.   #--------------------------------------------------------------------------
  763.   def title_new_game
  764.     # Prepare for transition
  765.     Graphics.freeze
  766.     # Dispose of command window
  767.     @command_window.dispose
  768.     @com.dispose
  769.     @com_glow.dispose
  770.     # Declare that Gameplay is NOT a Title Scene
  771.     $title_scene = false  
  772.     # Play decision SE
  773.     $game_system.se_play(RPG::AudioFile.new(CUSTOM_SELECT_SOUND))
  774.     # Stop BGM
  775.     Audio.bgm_stop
  776.     # Stop BGS
  777.     Audio.bgs_stop    
  778.     # Reset frame count for measuring play time
  779.     Graphics.frame_count = 0
  780.     # Make each type of game object
  781.     $game_temp          = Game_Temp.new
  782.     $game_system        = Game_System.new
  783.     $game_switches      = Game_Switches.new
  784.     $game_variables     = Game_Variables.new
  785.     $game_self_switches = Game_SelfSwitches.new
  786.     $game_screen        = Game_Screen.new
  787.     $game_actors        = Game_Actors.new
  788.     $game_party         = Game_Party.new
  789.     $game_troop         = Game_Troop.new
  790.     $game_map           = Game_Map.new
  791.     $game_player        = Game_Player.new
  792.     # Set up initial party
  793.     $game_party.setup_starting_members
  794.     # Set up initial map position
  795.     $game_map.setup($data_system.start_map_id)
  796.     # Move player to initial position
  797.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  798.     # Refresh player
  799.     $game_player.refresh
  800.     # Set player's temporary items to 0
  801.     $recent_items = []
  802.     # Run automatic change for BGM and BGS set with map
  803.     $game_map.autoplay
  804.     # Update map (run parallel process event)
  805.     $game_map.update
  806.     # Switch to map screen
  807.     $scene = Scene_Map.new
  808.     # Re-enable Menu Access since it was Disabled for Demo Titles
  809.     $game_system.menu_disabled = false
  810.   end
  811.   #--------------------------------------------------------------------------
  812.   # * Command: Continue
  813.   #--------------------------------------------------------------------------
  814.   def title_continue
  815.     # If continue is disabled
  816.     unless @continue_enabled
  817.       # Play buzzer SE
  818.       $game_system.se_play($data_system.buzzer_se)
  819.       return
  820.     end
  821.     # Prepare for transition
  822.     Graphics.freeze
  823.     # Dispose of command window
  824.     @command_window.dispose
  825.     # Dispose special window
  826.     @com.dispose
  827.     @com_glow.dispose
  828.     # Play decision SE
  829.     $game_system.se_play($data_system.decision_se)
  830.     # Switch to load screen
  831.     $scene = Scene_Load.new
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # * Command: Shutdown
  835.   #--------------------------------------------------------------------------
  836.   def title_shutdown
  837.     # Dispose of command window
  838.     @command_window.dispose    
  839.     # Dispose special window
  840.     @com.dispose
  841.     @com_glow.dispose
  842.     # Play decision SE
  843.     $game_system.se_play(RPG::AudioFile.new(CUSTOM_SELECT_SOUND))
  844.     # Fade out BGM, BGS, and ME
  845.     Audio.bgm_fade(800)
  846.     Audio.bgs_fade(800)
  847.     Audio.me_fade(800)
  848.     # Shutdown
  849.     $scene = nil
  850.   end  
  851.   #--------------------------------------------------------------------------
  852.   # * Command: Credits
  853.   #--------------------------------------------------------------------------
  854.   def title_credits
  855.     # Dispose of command window
  856.     @command_window.dispose    
  857.     # Dispose special window
  858.     @com.dispose
  859.     @com_glow.dispose
  860.     # Play decision SE
  861.     $game_system.se_play($data_system.decision_se)
  862.     # Fade out BGM, BGS, and ME
  863.     Audio.bgm_fade(800)
  864.     Audio.bgs_fade(800)
  865.     Audio.me_fade(800)
  866.     # Load credits scene
  867.     $scene = Scene_Credits.new
  868.   end  
  869.  
  870.  
  871.   #--------------------------------------------------------------------------
  872.   # * Battle Call - Alias hides the Command Window
  873.   #--------------------------------------------------------------------------
  874.   alias title_scene_call_battle call_battle
  875.   def call_battle
  876.     # If in a Title Scene Demo Battle
  877.     if $title_scene
  878.       # Hide the Command Window
  879.       $scene.hide_title_menu = true
  880.     end
  881.     #Call Original
  882.     title_scene_call_battle
  883.   end
  884. end  
  885.  
  886. # ** Scene_Load
  887. #------------------------------------------------------------------------------
  888. #  This class performs load screen processing.
  889. #==============================================================================
  890.  
  891. class Scene_Load < Scene_File
  892.   #--------------------------------------------------------------------------
  893.   # * Decision Processing
  894.   #--------------------------------------------------------------------------
  895.   alias map_title_decision on_decision
  896.   def on_decision(filename)
  897.     # Prevent Title Menu from Displaying
  898.     $title_scene = false
  899.     # Stop BGS
  900.     Audio.bgs_stop    
  901.     # Call Original
  902.     map_title_decision(filename)
  903.   end
  904.   #--------------------------------------------------------------------------
  905.   # * Cancel Processing
  906.   #--------------------------------------------------------------------------
  907.   def on_cancel
  908.     # Play cancel SE
  909.     $game_system.se_play($data_system.cancel_se)
  910.     # If Map Displayed is the one we want the Title to be on...
  911.     if Scene_Map::MAP_IDS_TO_ALLOW_WINDOW.include?($game_map.map_id)
  912.       # Switch back to the Map
  913.       $scene = Scene_Map.new
  914.     else
  915.       # Start the Scene all over again
  916.       $scene = Scene_Title.new
  917.     end
  918.     # Make sure the Title Menu comes up
  919.     $scene.display_title_menu = true  
  920.   end  
  921. end
  922.  
  923. class Game_Switches
  924.   # Enables @data to be accessed and changed
  925.   attr_accessor :data
  926. end
  927.  
  928. class Game_Player < Game_Character
  929.   # Enable @direction to be accessed and changed
  930.   attr_accessor :direction
  931. end
  932.  
  933. #==============================================================================
  934. # ** Scene_Battle (part 1)
  935. #------------------------------------------------------------------------------
  936. #  This class performs battle screen processing.
  937. #==============================================================================
  938.  
  939. class Scene_Battle
  940.  
  941.   # This should allow ANY Battle or Combat System to have a Demonstration
  942.   # of the Combat System.  Pressing a Key during an Automated Battle Demo
  943.   # will exit the Battle Demo and return to the Title Screen
  944.  
  945.   alias battle_demo_during_title_update update
  946.   def update
  947.     # Only process this section if this is a Title Scene
  948.     if $title_scene
  949.       if $game_system.battle_interpreter.title_escape_keys?
  950.         # Clear in battle flag
  951.         $game_temp.in_battle = false
  952.         # Clear entire party actions flag
  953.         $game_party.clear_actions
  954.         # Remove battle states
  955.         for actor in $game_party.actors
  956.           actor.remove_states_battle
  957.         end
  958.         # Clear enemies
  959.         $game_troop.enemies.clear
  960.         # Call battle callback
  961.         if $game_temp.battle_proc != nil
  962.           $game_temp.battle_proc.call(1)
  963.           $game_temp.battle_proc = nil
  964.         end
  965.         # Restart Title Scene which exits battle
  966.         $scene = Scene_Title.new
  967.       end
  968.     end
  969.     # Call Original
  970.     battle_demo_during_title_update
  971.   end
  972. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement