Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #-------------------------------------------------------------------------------
  2. # Non-Combat Menu v1.04a
  3. #-- Fully customizable menu geared toward less battle-oriented games.
  4. #-- By mjshi
  5. #-------------------------------------------------------------------------------
  6. # Installation: Put above Main, preferably also above other custom scripts.
  7. #-------------------------------------------------------------------------------
  8. # Update notes:
  9. #- Added support for most quest log scripts.
  10. #- Added support for separators.
  11. # Bugfixes:
  12. #- Fixed the gold window bug
  13. #- Forced the ingame menu command to call the Non-Combat Menu rather than the
  14. # regular one.
  15. #-------------------------------------------------------------------------------
  16.  
  17. $imported = {} if $imported.nil?
  18. $imported["NonCombatMenu"] = true
  19.  
  20. module NonCombatMenu
  21. MENU = [
  22. #-----------------------------------------------------------------------------
  23. # **CONFIGURATION**
  24. #-----------------------------------------------------------------------------
  25. # What should the actual menu show?
  26. # Put a # in front of the ones you don't want to show, and you can reorder
  27. # this list to change the order in the menu.
  28. # **Don't remove the comma after each []!**
  29. #
  30. ['Items', :item],
  31. ['Status', :status],
  32. ['Quest Log', :quests],
  33. ['Save', :save],
  34. ['Load', :load],
  35. ['Exit', :shutdown],
  36.  
  37. # Other possible commands:
  38. #['Equipment', :nequip],
  39. #['Quest Log', :quests],
  40. #['Formation', :nform],
  41. #['Load', :load],
  42. #['Cancel', :cancel],
  43. #[' ', :none],
  44. # :none does nothing, so it's ideal for spacers or separators.
  45. ]
  46. #-----------------------------------------------------------------------------
  47. # Should the gold window be shown in the item menu?
  48. #
  49. SHOW_GOLD_WINDOW = true
  50. #
  51. # Where should it be shown (to the left? set to false. right? set to true)
  52. GOLD_WINDOW_ALIGN_RIGHT = false
  53. #
  54. # How wide should the window be (in pixels)? 160 is the default.
  55. GOLD_WINDOW_WIDTH = 160
  56. #
  57. #-----------------------------------------------------------------------------
  58. # How many tabs are you showing? (add up the # of true values below)
  59. #
  60. TABS_SHOWN = 2
  61. #
  62. # What should the item menu show?
  63. SHOW_CONSUMABLES = true # i.e. normal items
  64. SHOW_KEY_ITEMS = true
  65. SHOW_WEAPONS = true
  66. SHOW_ARMORS = false
  67. #
  68. # Where should the item description window be?
  69. # 0 = top
  70. # 1 = between the tabs and the item selection
  71. # 2 = at the bottom
  72. DESCR_PLACEMENT = 2
  73. #
  74. #-----------------------------------------------------------------------------
  75.  
  76. end
  77.  
  78. #--------------------------------------------------------------------#
  79. # !!! Beware of crashes and errors if you edit beyond this point !!! #
  80. #--------------------------------------------------------------------#
  81.  
  82. # Overwrites the old, boring menu to use the cooler-looking Game End menu
  83. class Scene_Map
  84. def call_menu
  85. Sound.play_ok
  86. SceneManager.call(Scene_End)
  87. end
  88. end
  89.  
  90. # Overwrites how the tabs are shown in the Items Menu
  91. class Window_ItemCategory
  92.  
  93. # Changes width to allow placement of gold window.
  94. # If gold window doesn't exist, revert to default width.
  95. def window_width
  96. NonCombatMenu::SHOW_GOLD_WINDOW ? Graphics.width - NonCombatMenu::GOLD_WINDOW_WIDTH : Graphics.width
  97. end
  98.  
  99. # Changes columns to fit tabs shown
  100. def col_max
  101. return NonCombatMenu::TABS_SHOWN
  102. end
  103.  
  104. # Makes a list of commands that will be shown/hidden depending on config
  105. def make_command_list
  106. add_command(Vocab::item, :item) if NonCombatMenu::SHOW_CONSUMABLES
  107. add_command(Vocab::key_item, :key_item) if NonCombatMenu::SHOW_KEY_ITEMS
  108. add_command(Vocab::weapon, :weapon) if NonCombatMenu::SHOW_WEAPONS
  109. add_command(Vocab::armor, :armor) if NonCombatMenu::SHOW_ARMORS
  110. end
  111.  
  112. end
  113.  
  114. #Makes it so the user can change the gold window width
  115. class Window_Gold
  116. def window_width
  117. return NonCombatMenu::GOLD_WINDOW_WIDTH
  118. end
  119. end
  120.  
  121. # Adds a gold window to the item menu & determines placement
  122. class Scene_Item
  123. def start
  124. super
  125. create_help_window
  126.  
  127. # Checks if the gold menu should be shown
  128. create_gold_window if NonCombatMenu::SHOW_GOLD_WINDOW
  129.  
  130. create_category_window
  131. create_item_window
  132. end
  133.  
  134. def create_category_window
  135. @category_window = Window_ItemCategory.new
  136. @category_window.viewport = @viewport
  137. @category_window.help_window = @help_window
  138.  
  139. # Set Tab Menu's X depending on Gold existing or not
  140. if NonCombatMenu::SHOW_GOLD_WINDOW
  141. @category_window.x = NonCombatMenu::GOLD_WINDOW_WIDTH unless NonCombatMenu::GOLD_WINDOW_ALIGN_RIGHT
  142. end
  143.  
  144. # Set description, tab menu, gold Y
  145. if NonCombatMenu::DESCR_PLACEMENT == 1
  146. @help_window.y = @category_window.height
  147. elsif NonCombatMenu::DESCR_PLACEMENT == 2
  148. @help_window.y = Graphics.height - @help_window.height
  149. else
  150. @gold_window.y = @help_window.height if NonCombatMenu::SHOW_GOLD_WINDOW
  151. @category_window.y = @help_window.height
  152. end
  153.  
  154. @category_window.set_handler(:ok, method(:on_category_ok))
  155. @category_window.set_handler(:cancel, method(:return_scene))
  156. end
  157.  
  158. def create_item_window
  159.  
  160. # Changes where the item window is displayed
  161. if NonCombatMenu::DESCR_PLACEMENT == 1
  162. wy = @category_window.y + @category_window.height + @help_window.height
  163. elsif NonCombatMenu::DESCR_PLACEMENT == 2
  164. wy = @category_window.height + @help_window.height
  165. else
  166. wy = @category_window.y + @category_window.height
  167. end
  168.  
  169. wh = Graphics.height - wy
  170. @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
  171. @item_window.y = @category_window.height if NonCombatMenu::DESCR_PLACEMENT == 2
  172. @item_window.viewport = @viewport
  173. @item_window.help_window = @help_window
  174. @item_window.set_handler(:ok, method(:on_item_ok))
  175. @item_window.set_handler(:cancel, method(:on_item_cancel))
  176. @category_window.item_window = @item_window
  177. end
  178.  
  179. def create_gold_window
  180. @gold_window = Window_Gold.new
  181. # Makes the gold window (if aligned right) be under any new windows
  182. @gold_window.viewport = @viewport
  183. @gold_window.x = Graphics.width - NonCombatMenu::GOLD_WINDOW_WIDTH if NonCombatMenu::GOLD_WINDOW_ALIGN_RIGHT
  184. end
  185. end
  186.  
  187. # Strips down the status menu to the very basics
  188. class Window_Status
  189. def initialize(actor)
  190. super((Graphics.width - 300)/2, (Graphics.height - 120)/2, 300, 120)
  191. @actor = actor
  192. refresh
  193. activate
  194. end
  195. def refresh
  196. contents.clear
  197. draw_block2(line_height * 0)
  198. end
  199. def draw_basic_info(x, y)
  200. draw_actor_name(@actor, x, y + line_height * 0.5)
  201. draw_actor_hp(@actor, x, y + line_height * 1.5)
  202. draw_actor_mp(@actor, x, y + line_height * 2.5)
  203. end
  204. end
  205.  
  206. # Dims the Status window's background as well~
  207. class Scene_Status
  208. def create_background
  209. super
  210. @background_sprite.tone.set(0, 0, 0, 128)
  211. end
  212. end
  213.  
  214. # Overwrites Scene_End to use Save/Load/Items
  215. class Scene_End
  216.  
  217. def start
  218. super
  219. create_command_window
  220. create_invisible_formation_window
  221. end
  222.  
  223. def create_command_window
  224. @command_window = Window_GameEnd.new
  225.  
  226. NonCombatMenu::MENU.each do |i|
  227. next if i[1].to_s == "cancel"
  228. @command_window.set_handler(i[1], method(("command_" + i[1].to_s).to_sym))
  229. end
  230.  
  231. @command_window.set_handler(:cancel, method(:return_scene))
  232. end
  233.  
  234. def create_invisible_formation_window
  235. @status_window = Window_MenuStatus.new(@command_window.width, 0)
  236. @status_window.x = (Graphics.width - @status_window.width)/2
  237. @status_window.hide.deactivate
  238. end
  239.  
  240. def command_item
  241. SceneManager.call(Scene_Item)
  242. end
  243. def command_status
  244. SceneManager.call(Scene_Status)
  245. end
  246. def command_save
  247. SceneManager.call(Scene_Save)
  248. end
  249. # Defines the load command
  250. def command_load
  251. SceneManager.call(Scene_Load)
  252. end
  253. def command_nequip
  254. SceneManager.call(Scene_Equip)
  255. end
  256. def command_quests
  257. SceneManager.call(Scene_Quest)
  258. end
  259. def command_none
  260. SceneManager.call(Scene_End)
  261. end
  262.  
  263. def command_nform
  264. @command_window.hide.deactivate
  265. @status_window.select_last
  266. @status_window.show.activate
  267. @status_window.set_handler(:ok, method(:on_formation_ok))
  268. @status_window.set_handler(:cancel, method(:on_formation_cancel))
  269. end
  270.  
  271. def on_formation_ok
  272. if @status_window.pending_index >= 0
  273. $game_party.swap_order(@status_window.index,
  274. @status_window.pending_index)
  275. @status_window.pending_index = -1
  276. @status_window.redraw_item(@status_window.index)
  277. else
  278. @status_window.pending_index = @status_window.index
  279. end
  280. @status_window.activate
  281. end
  282.  
  283. def on_formation_cancel
  284. if @status_window.pending_index >= 0
  285. @status_window.pending_index = -1
  286. @status_window.activate
  287. else
  288. @status_window.unselect
  289. @status_window.hide.deactivate
  290. @command_window.show.activate
  291. end
  292. end
  293. end
  294.  
  295. # Overwrites Window_End to show tabs depending on configured values
  296. class Window_GameEnd
  297. def make_command_list
  298. NonCombatMenu::MENU.each do |i|
  299. i[1].to_s == "none" ? add_command(i[0], i[1], enabled = false) : add_command(i[0], i[1])
  300. end
  301. end
  302. end
  303.  
  304. #Call the Non-Combat Menu with event commands
  305. class Game_Interpreter
  306. def command_351
  307. return if $game_party.in_battle
  308. SceneManager.call(Scene_End)
  309. Window_MenuCommand::init_command_position
  310. Fiber.yield
  311. end
  312. end