1. #==============================================================================
  2. #
  3. # -- NerdiGaming - Title Menu
  4. # -- Last Updated: November 9, 2012
  5. #
  6. #==============================================================================
  7. # - Introduction
  8. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  9. # This is a very simple script that allows you to use images for your title
  10. # menu.
  11. #
  12. #==============================================================================
  13. # - Instructions
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # To install this script, open up your script editor and copy/paste this script
  16. # to an open slot below Materials but above Main. Remember to save.
  17. #
  18. #==============================================================================
  19. # - Terms of Use
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # - You MUST credit me: NerdiGaming
  22. # - You MAY NOT re-distribute this script or any attached material to any
  23. # location without my permission.
  24. # - You MAY use this script or any attached material for non-commercial
  25. # projects.
  26. # - You MUST contact me before using this script or any attached material for
  27. # commercial projects.
  28. #
  29. #==============================================================================
  30. # - Updates
  31. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. # Version 1.2 - Fixed a Bug: If players held down an input button the menu
  33. # would not update.
  34. # - Removed unecessary overwrites; improving compatability
  35. # slightly.
  36. # - Removed some unecessary code.
  37. # Version 1.1 - Fixed a Bug: If a save file was present, New Game would be
  38. # selected instead of Continue.
  39. # Version 1 - Script Completed.
  40. #==============================================================================
  41. module TitleMenu
  42. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  43. # - Padding -
  44. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  45. # Padding increases the distance between the New Game and Exit Game images
  46. # from the Continue Game image.
  47. #
  48. # New Game
  49. # -> <- This Space
  50. # Continue Game
  51. # -> <- This Space
  52. # Exit Game
  53. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  54. PADDING = -3 # Default: 5
  55. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  56. # - Offset -
  57. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58. # Offset moves the menu images in different directions.
  59. #
  60. # Positive Y = Moves the Menu Up Example: 50
  61. # Negative Y = Moves the Menu Down Example: -50
  62. #
  63. # Positive X = Moves the Menu Left Example: 50
  64. # Negative X = Moves the Menu Right Example: -50
  65. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  66. Y_OFFSET = -90 # Default: 0
  67. X_OFFSET = 0 # Default: 0
  68. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  69. # - Image Names -
  70. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  71. # This is where you specify what you want your images to be called.
  72. #
  73. # The images need to be placed in your Project\Graphics\System\ Folder.
  74. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  75. NEW_IMAGE = "NewGameR"
  76. NEW_SELECTED_IMAGE = "NewGameSelectedR"
  77. CONTINUE_IMAGE = "ContinueGameR"
  78. CONTINUE_SELECTED_IMAGE = "ContinueGameSelectedR"
  79. EXIT_IMAGE = "ExitGameR"
  80. EXIT_SELECTED_IMAGE = "ExitGameSelectedR"
  81. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  82. # - Continue Opacity -
  83. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84. # Continue Opacity is how transparent the continue image will be when there
  85. # are no save files present or if the continue option is disabled for some
  86. # reason.
  87. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  88. CONTINUE_DISABLED_OPACITY = 100 # Default: 100
  89. end # TitleMenu
  90. class Scene_Title < Scene_Base
  91. #--------------------------------------------------------------------------
  92. # * Start processing
  93. #--------------------------------------------------------------------------
  94. def start
  95. super
  96. SceneManager.clear
  97. Graphics.freeze
  98. check_continue
  99. create_background
  100. create_command_window
  101. play_title_music
  102. end
  103. #--------------------------------------------------------------------------
  104. # * Termination Processing
  105. #--------------------------------------------------------------------------
  106. def terminate
  107. super
  108. SceneManager.snapshot_for_background
  109. dispose_background
  110. end
  111. #--------------------------------------------------------------------------
  112. # * Check User Input
  113. #--------------------------------------------------------------------------
  114. def check_input
  115. case @command_window.index
  116. when 0 # New Game Is Selected
  117. @spriteNewGameSelected.z = 15
  118. @spriteNewGame.z = -2
  119. @spriteContinueGameSelected.z = -2
  120. @spriteContinueGame.z = 10
  121. @spriteExitGameSelected.z = -2
  122. @spriteExitGame.z = 10
  123. when 1 # Continue Game Is Selected
  124. @spriteNewGameSelected.z = -2
  125. @spriteNewGame.z = 10
  126. @spriteContinueGameSelected.z = 15
  127. @spriteContinueGame.z = -2
  128. @spriteExitGameSelected.z = -2
  129. @spriteExitGame.z = 10
  130. when 2 # Exit Game Is Selected
  131. @spriteNewGameSelected.z = -2
  132. @spriteNewGame.z = 10
  133. @spriteContinueGameSelected.z = -2
  134. @spriteContinueGame.z = 10
  135. @spriteExitGameSelected.z = 15
  136. @spriteExitGame.z = -2
  137. end
  138. end
  139. #--------------------------------------------------------------------------
  140. # * Frame Update
  141. #--------------------------------------------------------------------------
  142. def update
  143. super
  144. if Input.trigger?(:DOWN)
  145. check_input
  146. end
  147. if Input.repeat?(:DOWN)
  148. check_input
  149. end
  150. if Input.trigger?(:UP)
  151. check_input
  152. end
  153. if Input.repeat?(:UP)
  154. check_input
  155. end
  156. end
  157. #--------------------------------------------------------------------------
  158. # * Determine if Continue is Enabled
  159. #--------------------------------------------------------------------------
  160. def check_continue
  161. @continue_enabled = (Dir.glob('Save*.rvdata2').size > 0)
  162. end
  163. #--------------------------------------------------------------------------
  164. # * Create Background
  165. #--------------------------------------------------------------------------
  166. def create_background
  167. @sprite1 = Sprite.new
  168. @sprite1.bitmap = Cache.title1( $data_system.title1_name )
  169. @sprite2 = Sprite.new
  170. @sprite2.bitmap = Cache.title2( $data_system.title2_name )
  171. center_sprite( @sprite1 )
  172. center_sprite( @sprite2 )
  173. # Creates The Continue Game Image
  174. @spriteContinueGame = Sprite.new
  175. @spriteContinueGame.bitmap = Cache.system( TitleMenu::CONTINUE_IMAGE )
  176. @spriteContinueGame.x = ( ( Graphics.width / 2 ) - (@spriteContinueGame.bitmap.width / 2 ) )
  177. @spriteContinueGame.y = ( ( Graphics.height / 2 ) - (@spriteContinueGame.bitmap.height / 2 ) )
  178. @spriteContinueGame.z = 10
  179. # Creates The Continue Game Selected Image
  180. @spriteContinueGameSelected = Sprite.new
  181. @spriteContinueGameSelected.bitmap = Cache.system( TitleMenu::CONTINUE_SELECTED_IMAGE )
  182. @spriteContinueGameSelected.x = ( ( Graphics.width / 2 ) - ( @spriteContinueGameSelected.bitmap.width / 2 ) )
  183. @spriteContinueGameSelected.y = ( ( Graphics.height / 2 ) - ( @spriteContinueGameSelected.bitmap.height / 2 ) )
  184. @spriteContinueGameSelected.z = -2
  185. # Applies The Opacity If Continue Is Disabled
  186. if !@continue_enabled
  187. @spriteContinueGame.opacity = TitleMenu::CONTINUE_DISABLED_OPACITY
  188. @spriteContinueGameSelected.opacity = TitleMenu::CONTINUE_DISABLED_OPACITY
  189. end
  190. # Creates The New Game Image
  191. @spriteNewGame = Sprite.new
  192. @spriteNewGame.bitmap = Cache.system( TitleMenu::NEW_IMAGE )
  193. @spriteNewGame.x = ( ( Graphics.width / 2 ) - ( @spriteNewGame.bitmap.width / 2 ) )
  194. @spriteNewGame.y = ( ( Graphics.height / 2 ) - ( @spriteNewGame.bitmap.height / 2 ) ) - ( @spriteContinueGame.bitmap.height + TitleMenu::PADDING )
  195. @spriteNewGame.z = -2
  196. # Creates The New Game Selected Image
  197. @spriteNewGameSelected = Sprite.new
  198. @spriteNewGameSelected.bitmap = Cache.system( TitleMenu::NEW_SELECTED_IMAGE )
  199. @spriteNewGameSelected.x = ( ( Graphics.width / 2 ) - ( @spriteNewGameSelected.bitmap.width / 2 ) )
  200. @spriteNewGameSelected.y = ( ( Graphics.height / 2 ) - ( @spriteNewGameSelected.bitmap.height / 2 ) ) - ( @spriteContinueGame.bitmap.height + TitleMenu::PADDING )
  201. @spriteNewGameSelected.z = -2
  202. # Creates The Exit Game Image
  203. @spriteExitGame = Sprite.new
  204. @spriteExitGame.bitmap = Cache.system( TitleMenu::EXIT_IMAGE )
  205. @spriteExitGame.x = ( ( Graphics.width / 2 ) - ( @spriteExitGame.bitmap.width / 2 ) )
  206. @spriteExitGame.y = ( ( Graphics.height / 2 ) - ( @spriteExitGame.bitmap.height / 2 ) ) + ( @spriteContinueGame.bitmap.height + TitleMenu::PADDING )
  207. @spriteExitGame.z = 10
  208. # Creates The Exit Game Selected Image
  209. @spriteExitGameSelected = Sprite.new
  210. @spriteExitGameSelected.bitmap = Cache.system( TitleMenu::EXIT_SELECTED_IMAGE )
  211. @spriteExitGameSelected.x = ( ( Graphics.width / 2 ) - ( @spriteExitGameSelected.bitmap.width / 2 ) )
  212. @spriteExitGameSelected.y = ( ( Graphics.height / 2 ) - ( @spriteExitGameSelected.bitmap.height / 2 ) ) + ( @spriteContinueGame.bitmap.height + TitleMenu::PADDING )
  213. @spriteExitGameSelected.z = -2
  214. # Applies The Offset To The Continue Game Images
  215. @spriteContinueGame.x -= TitleMenu::X_OFFSET
  216. @spriteContinueGame.y -= TitleMenu::Y_OFFSET
  217. @spriteContinueGameSelected.x -= TitleMenu::X_OFFSET
  218. @spriteContinueGameSelected.y -= TitleMenu::Y_OFFSET
  219. # Applies The Offset To The New Game Images
  220. @spriteNewGame.x -= TitleMenu::X_OFFSET
  221. @spriteNewGame.y -= TitleMenu::Y_OFFSET
  222. @spriteNewGameSelected.x -= TitleMenu::X_OFFSET
  223. @spriteNewGameSelected.y -= TitleMenu::Y_OFFSET
  224. # Applies The Offset To The Exit Game Images
  225. @spriteExitGame.x -= TitleMenu::X_OFFSET
  226. @spriteExitGame.y -= TitleMenu::Y_OFFSET
  227. @spriteExitGameSelected.x -= TitleMenu::X_OFFSET
  228. @spriteExitGameSelected.y -= TitleMenu::Y_OFFSET
  229. end
  230. #--------------------------------------------------------------------------
  231. # * Dispose Background
  232. #--------------------------------------------------------------------------
  233. def dispose_background
  234. @sprite1.bitmap.dispose
  235. @sprite1.dispose
  236. @sprite2.bitmap.dispose
  237. @sprite2.dispose
  238. @spriteNewGame.bitmap.dispose
  239. @spriteNewGame.dispose
  240. @spriteNewGameSelected.bitmap.dispose
  241. @spriteNewGameSelected.dispose
  242. @spriteContinueGame.bitmap.dispose
  243. @spriteContinueGame.dispose
  244. @spriteContinueGameSelected.bitmap.dispose
  245. @spriteContinueGameSelected.dispose
  246. @spriteExitGame.bitmap.dispose
  247. @spriteExitGame.dispose
  248. @spriteExitGameSelected.bitmap.dispose
  249. @spriteExitGameSelected.dispose
  250. end
  251. #--------------------------------------------------------------------------
  252. # * Create Command Window
  253. #--------------------------------------------------------------------------
  254. def create_command_window
  255. @command_window = Window_TitleCommand.new
  256. @command_window.set_handler(:new_game, method(:command_new_game))
  257. @command_window.set_handler(:continue, method(:command_continue))
  258. @command_window.set_handler(:shutdown, method(:command_shutdown))
  259. @command_window.z = -2
  260. case @command_window.index
  261. when 0 # New Game Is Selected
  262. @spriteNewGameSelected.z = 15
  263. @spriteNewGame.z = -2
  264. @spriteContinueGameSelected.z = -2
  265. @spriteContinueGame.z = 10
  266. @spriteExitGameSelected.z = -2
  267. @spriteExitGame.z = 10
  268. when 1 # Continue Game Is Selected
  269. @spriteNewGameSelected.z = -2
  270. @spriteNewGame.z = 10
  271. @spriteContinueGameSelected.z = 15
  272. @spriteContinueGame.z = -2
  273. @spriteExitGameSelected.z = -2
  274. @spriteExitGame.z = 10
  275. when 2 # Exit Game Is Selected
  276. @spriteNewGameSelected.z = -2
  277. @spriteNewGame.z = 10
  278. @spriteContinueGameSelected.z = -2
  279. @spriteContinueGame.z = 10
  280. @spriteExitGameSelected.z = 15
  281. @spriteExitGame.z = -2
  282. end
  283. end
  284. #--------------------------------------------------------------------------
  285. # * [Continue] Command
  286. #--------------------------------------------------------------------------
  287. def command_continue
  288. if @continue_enabled
  289. close_command_window
  290. SceneManager.call(Scene_Load)
  291. end
  292. end
  293. end # Scene_Title
Comments powered by Disqus