Advertisement
Guest User

NC Menu Edit for Survival HUD

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