Advertisement
mjshi

Non-Combat Menu 1.04a

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