Advertisement
roninator2

Kid Friendly Basic Quest - Main Menu Functions

Dec 14th, 2024 (edited)
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.92 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Main Menu Functions     ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Menu Screens           ║    09 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  Set the Windows to look like FFMQ.                      ║
  13. # ║                                                          ║
  14. # ╚══════════════════════════════════════════════════════════╝
  15. # ╔══════════════════════════════════════════════════════════╗
  16. # ║ Terms of use:                                            ║
  17. # ║ Free for all uses in RPG Maker - Except nudity           ║
  18. # ╚══════════════════════════════════════════════════════════╝
  19.  
  20. #==============================================================================
  21. # * Window Menu Command
  22. #==============================================================================
  23. class Window_MenuCommand < Window_Command
  24.   #--------------------------------------------------------------------------
  25.   # initialize
  26.   #--------------------------------------------------------------------------
  27.   def initialize
  28.     x = Graphics.width - window_width
  29.     super(x, 0)
  30.     select_last
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Get Spacing for Items Arranged Side by Side
  34.   #--------------------------------------------------------------------------
  35.   def spacing
  36.     return 15
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # * Window Width
  40.   #--------------------------------------------------------------------------
  41.   def window_width
  42.     return Graphics.width / 2
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # * Get Window Height
  46.   #--------------------------------------------------------------------------
  47.   def window_height
  48.     fitting_height(visible_line_number)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Get Line Height
  52.   #--------------------------------------------------------------------------
  53.   def line_height
  54.     return 35
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Visible Line Number
  58.   #--------------------------------------------------------------------------
  59.   def visible_line_number
  60.     item_max
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Make Command List
  64.   #--------------------------------------------------------------------------
  65.   def make_command_list
  66.     add_main_commands
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Add Main Commands
  70.   #--------------------------------------------------------------------------
  71.   def add_main_commands
  72.     add_command("Items",   :item)
  73.     add_command("Spells",  :spell)
  74.     add_command("Armour",  :armour)
  75.     add_command("Weapons",  :weapon)
  76.     add_command("Status", :status)
  77.     add_command("Customize", :game_end)
  78.     add_command("Save", :save, save_enabled)
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * Get Rectangle for Drawing Items (for Text)
  82.   #--------------------------------------------------------------------------
  83.   def item_rect_for_text(index)
  84.     rect = item_rect(index)
  85.     rect.x += 40
  86.     rect.y -= 10
  87.     rect.width -= 8
  88.     rect.height += 15
  89.     rect
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # * Draw Item
  93.   #--------------------------------------------------------------------------
  94.   def draw_item(index)
  95.     make_font_bigger
  96.     change_color(normal_color, command_enabled?(index))
  97.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  98.     make_font_smaller
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Update Cursor
  102.   #--------------------------------------------------------------------------
  103.   def update_cursor
  104.     if @cursor_all
  105.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  106.       self.top_row = 0
  107.     elsif @index < 0
  108.       cursor_rect.empty
  109.     else
  110.       ensure_cursor_visible
  111.       cursor_rect.set(item_rect(@index))
  112.     end
  113.     name = command_name(index)
  114.     adj = name.size * 6
  115.     width = text_size(name).width + adj
  116.     cursor_rect.x += 30
  117.     cursor_rect.width = width
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Get Text Size
  121.   #--------------------------------------------------------------------------
  122.   def text_size(str)
  123.     contents.text_size(str)
  124.   end
  125. end
  126.  
  127. #==============================================================================
  128. # ** Scene_Menu
  129. #==============================================================================
  130. class Scene_Menu < Scene_MenuBase
  131.   #--------------------------------------------------------------------------
  132.   # * Start Processing
  133.   #--------------------------------------------------------------------------
  134.   def start
  135.     super
  136.     create_blank_window
  137.     create_spell_window
  138.     create_spell_window2
  139.     create_item_window
  140.     create_spell_count_window
  141.     create_command_window
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Create Command Window
  145.   #--------------------------------------------------------------------------
  146.   def create_command_window
  147.     @command_window = Window_MenuCommand.new
  148.     @command_window.z = 200
  149.     @command_window.set_handler(:item,      method(:command_item))
  150.     @command_window.set_handler(:spell,     method(:command_spell))
  151.     @command_window.set_handler(:armour,    method(:command_armour))
  152.     @command_window.set_handler(:weapon,    method(:command_weapons))
  153.     @command_window.set_handler(:status,    method(:command_status))
  154.     @command_window.set_handler(:save,      method(:command_save))
  155.     @command_window.set_handler(:game_end,  method(:command_game_end))
  156.     @command_window.set_handler(:cancel,    method(:return_scene))
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * command_item
  160.   #--------------------------------------------------------------------------
  161.   def command_item
  162.     SceneManager.call(Scene_Item)
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # * command_spell
  166.   #--------------------------------------------------------------------------
  167.   def command_spell
  168.     SceneManager.call(Scene_Spell)
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * command_armour
  172.   #--------------------------------------------------------------------------
  173.   def command_armour
  174.     SceneManager.call(Scene_Armour)
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * command_weapons
  178.   #--------------------------------------------------------------------------
  179.   def command_weapons
  180.     SceneManager.call(Scene_Weapons)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * command_status
  184.   #--------------------------------------------------------------------------
  185.   def command_status
  186.     SceneManager.call(Scene_Status)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * command_save
  190.   #--------------------------------------------------------------------------
  191.   def command_save
  192.     SceneManager.call(Scene_Save)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Create Spell Window1
  196.   #--------------------------------------------------------------------------
  197.   def create_spell_window
  198.     ww = Graphics.width / 2
  199.     wh = Graphics.height - 220
  200.     @spell_window = Window_SpellList.new(0, 60, ww, wh)
  201.     @spell_window.actor = $game_party.members[0]
  202.     @spell_window.viewport = @viewport
  203.     @spell_window.actor = $game_party.members[0]
  204.     @spell_window.z = 50
  205.     @spell_window.back_opacity = 0
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # * Create Spell Window2
  209.   #--------------------------------------------------------------------------
  210.   def create_spell_window2
  211.     ww = Graphics.width / 2
  212.     wh = Graphics.height - 220
  213.     @spell_window2 = Window_SpellList.new(ww, 60, ww, wh)
  214.     @spell_window2.actor = $game_party.members[1]
  215.     @spell_window2.viewport = @viewport
  216.     @spell_window2.actor = $game_party.members[1]
  217.     @spell_window2.z = 10
  218.     @spell_window2.back_opacity = 0
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # * Create Item Window
  222.   #--------------------------------------------------------------------------
  223.   def create_item_window
  224.     wh = Graphics.height - 258
  225.     @item_window = Window_ItemList.new(0, 48, Graphics.width / 2, wh)
  226.     @item_window.viewport = @viewport
  227.     @item_window.z = 100
  228.     @item_window.refresh
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Create Spell Count Window
  232.   #--------------------------------------------------------------------------
  233.   def create_spell_count_window
  234.     @spell_count_window = Window_KFBQSpellCount.new(0, Graphics.height - 160, Graphics.width, 60)
  235.     @spell_count_window.z = 60
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * Create Blank Window
  239.   #--------------------------------------------------------------------------
  240.   def create_blank_window
  241.     @help_window = Window_ItemHelp.new
  242.     @help_window.viewport = @viewport
  243.   end
  244. end
  245.  
  246. # ╔═════════════════════════════════════╦════════════════════╗
  247. # ║ Title: KFBQ Menu Background         ║  Version: 1.00     ║
  248. # ║ Author: Roninator2                  ║                    ║
  249. # ╠═════════════════════════════════════╬════════════════════╣
  250. # ║ Function:                           ║   Date Created     ║
  251. # ║                                     ╠════════════════════╣
  252. # ║   FFMQ Style Dark Background        ║    09 Mar 2023     ║
  253. # ╚═════════════════════════════════════╩════════════════════╝
  254. # ╔══════════════════════════════════════════════════════════╗
  255. # ║ Instructions:                                            ║
  256. # ║                                                          ║
  257. # ║  Configures the menubase to show a black background      ║
  258. # ║  for all menu scenes.                                    ║
  259. # ╚══════════════════════════════════════════════════════════╝
  260. # ╔══════════════════════════════════════════════════════════╗
  261. # ║ Terms of use:                                            ║
  262. # ║ Free for all uses in RPG Maker - Except nudity           ║
  263. # ╚══════════════════════════════════════════════════════════╝
  264.  
  265. class Scene_MenuBase < Scene_Base
  266.   #--------------------------------------------------------------------------
  267.   # * Termination Processing
  268.   #--------------------------------------------------------------------------
  269.   def terminate
  270.     super
  271.     dispose_background if @background_sprite
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # * Create Background
  275.   #--------------------------------------------------------------------------
  276.   def create_background
  277.     @background_sprite = Sprite.new
  278.     @background_sprite.bitmap = SceneManager.background_bitmap
  279.     @background_sprite.color.set(0, 0, 0, 255)
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # * Free Background
  283.   #--------------------------------------------------------------------------
  284.   def dispose_background
  285.     if @background_sprite
  286.       @background_sprite.bitmap.dispose
  287.       @background_sprite.dispose
  288.     end
  289.   end
  290. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement