Advertisement
Dark_Paladin

DKP Single Player Menu v1.2

Jul 20th, 2013
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.21 KB | None | 0 0
  1. ###############################################################################
  2. # Dark Paladin Single Character Menu v1.2
  3. #     Platform: VX Ace
  4. #       Author: Dark Paladin
  5. #  Description: A menu system for a single Character.
  6. # Terms of use: You MAY use this script for your Non-commercial Projects.
  7. #    You MAY use this script for Commercial projects without my permission.
  8. #    Credit is appreciated but not needed.
  9. # This script requires: N/A Cachext Included
  10. ###############################################################################
  11. #==============================================================================  
  12. # CONFIG AREA  
  13. #==============================================================================
  14.  
  15. module DKP_Menu_Config
  16.     Enable_Background = true           # true/false Use Background?
  17.       Menu_Background = "Background2"  # Set the name of the background pic
  18.                                        # Place Image in "Graphics/DPmenu/Main/" Or change it in the cachext module.
  19.        Status_Opacity = 0              # Status Window Opacity
  20.          Help_Opacity = 0              # Item Help Window Opacity
  21.          Item_Opacity = 0              # Item Window Opacity
  22.       Command_Opacity = 0              # Command Window Opacity
  23.     CategoryW_Opacity = 0              # Category Window Opacity
  24.   end
  25.  
  26.   module Cachext
  27.   #--------------------------------------------------------------------------
  28.   # DKP Cachext
  29.   # Do not edit unless you really know what your doing!
  30.   # Platform: VX Ace
  31.   # Author: Dark paladin
  32.   # Description: Module for menu background.
  33.   # -------------------------------------------------------------------------
  34.   #--------------------------------------------------------------------------
  35.   # *Graphics
  36.   #--------------------------------------------------------------------------  
  37.   #You can edit the stuff in purple between the "" to change folder location.  
  38.   #--------------------------------------------------------------------------
  39.   # *Menu Graphics Folder
  40.   #--------------------------------------------------------------------------
  41.   def self.dpmenu(filename)# You can change the Folder names here for background image.
  42.     load_bitmap("Graphics/DPmenu/Main/", filename)
  43.   end
  44. #==============================================================================  
  45. # END CONFIG AREA  
  46. #==============================================================================  
  47.   #--------------------------------------------------------------------------
  48.   # * Load Bitmap
  49.   #--------------------------------------------------------------------------
  50.   def self.load_bitmap(folder_name, filename, hue = 0)
  51.     @cachext ||= {}
  52.     if filename.empty?
  53.       empty_bitmap
  54.     elsif hue == 0
  55.       normal_bitmap(folder_name + filename)
  56.     else
  57.       hue_changed_bitmap(folder_name + filename, hue)
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Create Empty Bitmap
  62.   #--------------------------------------------------------------------------
  63.   def self.empty_bitmap
  64.     Bitmap.new(32, 32)
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * Create/Get Normal Bitmap
  68.   #--------------------------------------------------------------------------
  69.   def self.normal_bitmap(path)
  70.     @cachext[path] = Bitmap.new(path) unless include?(path)
  71.     @cachext[path]
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # * Create/Get Hue-Changed Bitmap
  75.   #--------------------------------------------------------------------------
  76.   def self.hue_changed_bitmap(path, hue)
  77.     key = [path, hue]
  78.     unless include?(key)
  79.       @cachext[key] = normal_bitmap(path).clone
  80.       @cachext[key].hue_change(hue)
  81.     end
  82.     @cachext[key]
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Check Cache Existence
  86.   #--------------------------------------------------------------------------
  87.   def self.include?(key)
  88.     @cachext[key] && !@cachext[key].disposed?
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Clear Cache
  92.   #--------------------------------------------------------------------------
  93.   def self.clear
  94.     @cachext ||= {}
  95.     @cachext.clear
  96.     GC.start
  97.   end
  98. end
  99.  
  100. #==============================================================================
  101. # ** Window_ItemCategory
  102. #------------------------------------------------------------------------------
  103. #  This window is for selecting a category of normal items and equipment
  104. # on the item screen or shop screen.
  105. #==============================================================================
  106. class Window_ItemCategory < Window_HorzCommand
  107.   include DKP_Menu_Config
  108.   #--------------------------------------------------------------------------
  109.   # * Public Instance Variables
  110.   #--------------------------------------------------------------------------
  111.   attr_reader   :item_window
  112.   #--------------------------------------------------------------------------
  113.   # * Object Initialization
  114.   #--------------------------------------------------------------------------
  115.   def initialize
  116.     super(0, 0)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Get Window Width
  120.   #--------------------------------------------------------------------------
  121.   def window_width
  122.     244
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # * Get Digit Count
  126.   #--------------------------------------------------------------------------
  127.   def col_max
  128.     return 2
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Frame Update
  132.   #--------------------------------------------------------------------------
  133.   def update
  134.     super
  135.     @item_window.category = current_symbol if @item_window
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Create Command List
  139.   #--------------------------------------------------------------------------
  140.   def make_command_list
  141.     add_command(Vocab::item,     :item)
  142.     add_command(Vocab::key_item, :key_item)
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # * Set Item Window
  146.   #--------------------------------------------------------------------------
  147.   def item_window=(item_window)
  148.     @item_window = item_window
  149.     update
  150.   end
  151. end
  152.  
  153. #==============================================================================
  154. # ** Window_MenuStatus
  155. #------------------------------------------------------------------------------
  156. #  This window displays party member status on the menu screen.
  157. #==============================================================================
  158.  
  159. class Window_MenuStatus < Window_Selectable
  160.   include DKP_Menu_Config
  161.   #--------------------------------------------------------------------------
  162.   # * Public Instance Variables
  163.   #--------------------------------------------------------------------------
  164.   attr_reader   :pending_index            # Pending position (for formation)
  165.   #--------------------------------------------------------------------------
  166.   # * Object Initialization
  167.   #--------------------------------------------------------------------------
  168.   def initialize(x, y)
  169.     super(x, y, window_width, window_height)
  170.     @pending_index = -1
  171.     self.opacity = Status_Opacity
  172.     refresh
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Get Window Width
  176.   #--------------------------------------------------------------------------
  177.   def window_width
  178.     return 300
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * Get Window Height
  182.   #--------------------------------------------------------------------------
  183.   def window_height
  184.     return 370
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * Get Number of Items
  188.   #--------------------------------------------------------------------------
  189.   def item_max
  190.    return 1
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Get Item Height
  194.   #--------------------------------------------------------------------------
  195.   def item_height
  196.     (height - standard_padding * 2) / 4
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # Simple Status
  200.   #--------------------------------------------------------------------------
  201.   def draw_actor_hp(actor, x, y, width = 200)
  202.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  203.     change_color(system_color)
  204.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  205.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  206.     hp_color(actor), normal_color)
  207.   end  
  208.   def draw_actor_name(actor, x, y, width = 112)
  209.     change_color(hp_color(actor))
  210.     draw_text(x, y, width / 2, line_height, actor.name)
  211.   end
  212.     def draw_actor_simple_status(actor, x, y)
  213.     draw_actor_name(actor, 187, 25)
  214.     draw_actor_icons(actor, 0, y + line_height * 8)
  215.     draw_actor_hp(actor, 40, 100 + line_height * 1)
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Draw Item
  219.   #--------------------------------------------------------------------------
  220.   def draw_item(index)
  221.     actor = $game_party.members[0]
  222.     enabled = $game_party.battle_members.include?(actor)
  223.     rect = item_rect(index)
  224.     draw_item_background(index)
  225.     draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
  226.     draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # * Draw Background for Item
  230.   #--------------------------------------------------------------------------
  231.   def draw_item_background(index)
  232.     if index == @pending_index
  233.       contents.fill_rect(item_rect(index), pending_color)
  234.     end
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Processing When OK Button Is Pressed
  238.   #--------------------------------------------------------------------------
  239.   def process_ok
  240.     super
  241.     $game_party.menu_actor = $game_party.members[index]
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Restore Previous Selection Position
  245.   #--------------------------------------------------------------------------
  246.   def select_last
  247.     select($game_party.menu_actor.index || 0)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * Set Pending Position (for Formation)
  251.   #--------------------------------------------------------------------------
  252.   def pending_index=(index)
  253.     last_pending_index = @pending_index
  254.     @pending_index = index
  255.     redraw_item(@pending_index)
  256.     redraw_item(last_pending_index)
  257.   end
  258. end
  259.  
  260. #==============================================================================
  261. # ** Window_Help
  262. #------------------------------------------------------------------------------
  263. #  This window shows skill and item explanations along with actor status.
  264. #==============================================================================
  265.  
  266. class DKPWindow_Help < Window_Base
  267.   include DKP_Menu_Config
  268.   #--------------------------------------------------------------------------
  269.   # * Object Initialization
  270.   #--------------------------------------------------------------------------
  271.   def initialize(line_number = 4)
  272.     super(0, 0, 244, fitting_height(line_number))
  273.     self.opacity = Help_Opacity
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # * Set Text
  277.   #--------------------------------------------------------------------------
  278.   def set_text(text)
  279.     if text != @text
  280.       @text = text
  281.       refresh
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # * Clear
  286.   #--------------------------------------------------------------------------
  287.   def clear
  288.     set_text("")
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Set Item
  292.   #     item : Skills and items etc.
  293.   #--------------------------------------------------------------------------
  294.   def set_item(item)
  295.     set_text(item ? item.description : "")
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * Refresh
  299.   #--------------------------------------------------------------------------
  300.   def refresh
  301.     contents.clear
  302.     draw_text_ex(0, 0, word_wrapping(@text))
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # * Word Wrap
  306.   #--------------------------------------------------------------------------
  307.   def word_wrapping(text, pos = 0)
  308.     current_text_position = 0    
  309.     for i in 0..(text.length - 1)
  310.       if text[i] == "\n"
  311.         current_text_position = 0
  312.         next
  313.       end
  314.       current_text_position += contents.text_size(text[i]).width
  315.       if (pos + current_text_position) >= (contents.width)
  316.         current_element = i
  317.         while(text[current_element] != " ")
  318.           break if current_element == 0
  319.           current_element -= 1
  320.         end
  321.         temp_text = ""
  322.         for j in 0..(text.length - 1)
  323.           temp_text += text[j]
  324.           temp_text += "\n" if j == current_element
  325.         end
  326.         text = temp_text
  327.         i = current_element
  328.         current_text_position = 0
  329.       end
  330.     end
  331.     return text
  332.   end
  333. end
  334. #==============================================================================
  335. # ** Window_Gold
  336. #------------------------------------------------------------------------------
  337. #  This window displays the party's gold.
  338. #==============================================================================
  339.  
  340. class Window_Gold < Window_Base
  341.   include DKP_Menu_Config
  342.   #--------------------------------------------------------------------------
  343.   # * Object Initialization
  344.   #--------------------------------------------------------------------------
  345.   def initialize
  346.     super(0, 0, window_width, fitting_height(1))
  347.     self.opacity = 0
  348.     self.z = 1000
  349.     refresh
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # * Get Window Width
  353.   #--------------------------------------------------------------------------
  354.   def window_width
  355.     return 160
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # * Refresh
  359.   #--------------------------------------------------------------------------
  360.   def refresh
  361.     contents.clear
  362.     draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # * Get Party Gold
  366.   #--------------------------------------------------------------------------
  367.   def value
  368.     $game_party.gold
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # Get Currency Unit
  372.   #--------------------------------------------------------------------------
  373.   def currency_unit
  374.     Vocab::currency_unit
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # * Open Window
  378.   #--------------------------------------------------------------------------
  379.   def open
  380.     refresh
  381.     super
  382.   end
  383. end
  384. class Window_ItemList < Window_Selectable
  385.   include DKP_Menu_Config
  386.   #--------------------------------------------------------------------------
  387.   # * Object Initialization
  388.   #--------------------------------------------------------------------------
  389.   def initialize(x, y, width, height)
  390.     super
  391.     @category = :none
  392.     @data = []
  393.     self.opacity = Item_Opacity
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # * Set Category
  397.   #--------------------------------------------------------------------------
  398.   def category=(category)
  399.     return if @category == category
  400.     @category = category
  401.     refresh
  402.     self.oy = 0
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # * Get Digit Count
  406.   #--------------------------------------------------------------------------
  407.   def col_max
  408.     return 1
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # * Get Number of Items
  412.   #--------------------------------------------------------------------------
  413.   def item_max
  414.     @data ? @data.size : 1
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # * Get Item
  418.   #--------------------------------------------------------------------------
  419.   def item
  420.     @data && index >= 0 ? @data[index] : nil
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # * Get Activation State of Selection Item
  424.   #--------------------------------------------------------------------------
  425.   def current_item_enabled?
  426.     enable?(@data[index])
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # * Include in Item List?
  430.   #--------------------------------------------------------------------------
  431.   def include?(item)
  432.     case @category
  433.     when :item
  434.       item.is_a?(RPG::Item) && !item.key_item?
  435.     when :key_item
  436.       item.is_a?(RPG::Item) && item.key_item?
  437.     else
  438.       false
  439.     end
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # * Display in Enabled State?
  443.   #--------------------------------------------------------------------------
  444.   def enable?(item)
  445.     $game_party.usable?(item)
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # * Create Item List
  449.   #--------------------------------------------------------------------------
  450.   def make_item_list
  451.     @data = $game_party.all_items.select {|item| include?(item) }
  452.     @data.push(nil) if include?(nil)
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # * Restore Previous Selection Position
  456.   #--------------------------------------------------------------------------
  457.   def select_last
  458.     select(@data.index($game_party.last_item.object) || 0)
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # * Draw Item
  462.   #--------------------------------------------------------------------------
  463.   def draw_item(index)
  464.     item = @data[index]
  465.     if item
  466.       rect = item_rect(index)
  467.       rect.width -= 4
  468.       draw_item_name(item, rect.x, rect.y, enable?(item))
  469.       draw_item_number(rect, item)
  470.     end
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # * Draw Number of Items
  474.   #--------------------------------------------------------------------------
  475.   def draw_item_number(rect, item)
  476.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # * Update Help Text
  480.   #--------------------------------------------------------------------------
  481.   def update_help
  482.     @help_window.set_item(item)
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # * Refresh
  486.   #--------------------------------------------------------------------------
  487.   def refresh
  488.     make_item_list
  489.     create_contents
  490.     draw_all_items
  491.   end
  492. end
  493. #==============================================================================
  494. # ** Window_MenuCommand
  495. #------------------------------------------------------------------------------
  496. #  This command window appears on the menu screen.
  497. #==============================================================================
  498.  
  499. class Window_MenuCommand < Window_Command
  500.   include DKP_Menu_Config
  501.   #--------------------------------------------------------------------------
  502.   # * Initialize Command Selection Position (Class Method)
  503.   #--------------------------------------------------------------------------
  504.   def self.init_command_position
  505.     @@last_command_symbol = nil
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # * Get Digit Count
  509.   #--------------------------------------------------------------------------
  510.   def col_max
  511.     return 3
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # * Get Spacing for Items Arranged Side by Side
  515.   #--------------------------------------------------------------------------
  516.   def spacing
  517.     return 100
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # * Object Initialization
  521.   #--------------------------------------------------------------------------
  522.   def initialize
  523.     super(0, Graphics.height- 47)
  524.     activate
  525.     select_last
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # * Get Window Width
  529.   #--------------------------------------------------------------------------
  530.   def window_width
  531.     return 544
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # * Get Number of Lines to Show
  535.   #--------------------------------------------------------------------------
  536.   def visible_line_number
  537.     return 1
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * Create Command List
  541.   #--------------------------------------------------------------------------
  542.   def make_command_list
  543.     add_main_commands
  544.     add_save_command
  545.     add_game_end_command
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * Add Main Commands to List
  549.   #--------------------------------------------------------------------------
  550.   def add_main_commands
  551.     add_command(Vocab::item,   :item,   main_commands_enabled)
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # * Add Save to Command List
  555.   #--------------------------------------------------------------------------
  556.   def add_save_command
  557.     add_command(Vocab::save, :save, save_enabled)
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # * Add Exit Game to Command List
  561.   #--------------------------------------------------------------------------
  562.   def add_game_end_command
  563.     add_command(Vocab::game_end, :game_end)
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # * Get Activation State of Main Commands
  567.   #--------------------------------------------------------------------------
  568.   def main_commands_enabled
  569.     $game_party.exists
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # * Get Activation State of Save
  573.   #--------------------------------------------------------------------------
  574.   def save_enabled
  575.     !$game_system.save_disabled
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # * Processing When OK Button Is Pressed
  579.   #--------------------------------------------------------------------------
  580.   def process_ok
  581.     @@last_command_symbol = current_symbol
  582.     super
  583.   end
  584.   #--------------------------------------------------------------------------
  585.   # * Restore Previous Selection Position
  586.   #--------------------------------------------------------------------------
  587.   def select_last
  588.     select_symbol(@@last_command_symbol)
  589.   end
  590. end
  591.  
  592.  
  593. class Game_Interpreter
  594.   def command_351
  595.     return if $game_party.in_battle
  596.     SceneManager.call(Scene_Item)
  597.     Window_MenuCommand::init_command_position
  598.     Fiber.yield
  599.   end
  600. end
  601. class Scene_Map < Scene_Base
  602.   def call_menu
  603.     SceneManager.call(Scene_Item)
  604.     Window_MenuCommand::init_command_position
  605.   end
  606. end
  607.  
  608.  
  609. #==============================================================================
  610. # ** Scene_Item
  611. #------------------------------------------------------------------------------
  612. #  This class performs the item screen processing.
  613. #==============================================================================
  614.  
  615. class Scene_Item < Scene_ItemBase
  616.   include DKP_Menu_Config
  617.   #--------------------------------------------------------------------------
  618.   # * Start Processing
  619.   #--------------------------------------------------------------------------
  620.   def start
  621.     super
  622.     create_help_window
  623.     create_status_window
  624.     if Enable_Background != false then create_Image_Background end
  625.     create_gold_window
  626.     create_command_window
  627.     create_category_window
  628.     create_item_window
  629.     #@category_window.deactivate
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # * Create Category Window
  633.   #--------------------------------------------------------------------------
  634.   def create_category_window
  635.     @category_window = Window_ItemCategory.new
  636.     @category_window.viewport = @viewport
  637.     @category_window.help_window = @help_window
  638.     @category_window.y = 120
  639.     @category_window.opacity = CategoryW_Opacity
  640.     @category_window.set_handler(:ok,     method(:on_category_ok))
  641.     @category_window.set_handler(:cancel, method(:return_item))
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # * Create Item Window
  645.   #--------------------------------------------------------------------------
  646.   def create_item_window
  647.     @item_window = Window_ItemList.new(0, 170, 244, 200)
  648.     @item_window.viewport = @viewport
  649.     @item_window.help_window = @help_window
  650.     @item_window.set_handler(:ok,     method(:on_item_ok))
  651.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  652.     @category_window.item_window = @item_window
  653.   end
  654.   #--------------------------------------------------------------------------
  655.   # * Create Command Window
  656.   #--------------------------------------------------------------------------
  657.   def create_command_window
  658.     @command_window = Window_MenuCommand.new
  659.     @command_window.opacity = Command_Opacity
  660.     @command_window.set_handler(:item,      method(:command_item))
  661.     @command_window.set_handler(:save,      method(:command_save))
  662.     @command_window.set_handler(:game_end,  method(:command_game_end))
  663.     @command_window.set_handler(:cancel,    method(:return_scene))
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # * Deactivate category
  667.   #--------------------------------------------------------------------------
  668.   def return_item
  669.     @category_window.deactivate
  670.     @command_window.activate
  671.     @command_window.select_last
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # * [Save] Command
  675.   #--------------------------------------------------------------------------
  676.   def command_save
  677.     SceneManager.call(Scene_Save)
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # * [Exit Game] Command
  681.   #--------------------------------------------------------------------------
  682.   def command_game_end
  683.     SceneManager.call(Scene_End)
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # * [Item] Command
  687.   #--------------------------------------------------------------------------
  688.   def command_item
  689.     @category_window.activate
  690.     @command_window.deactivate
  691.   end
  692.   #--------------------------------------------------------------------------
  693.   # * Create Gold Window
  694.   #--------------------------------------------------------------------------
  695.   def create_gold_window
  696.     @gold_window = Window_Gold.new
  697.     @gold_window.x = Graphics.width - @gold_window.width
  698.     @gold_window.y = Graphics.height - 100
  699.   end
  700.   #--------------------------------------------------------------------------
  701.   # * Create Background Image
  702.   #--------------------------------------------------------------------------
  703.   def create_Image_Background
  704.         bitmap = Cachext.dpmenu(Menu_Background)
  705.         @background_sprite.bitmap = bitmap
  706.     end
  707.   #--------------------------------------------------------------------------
  708.   # * Create Status Window
  709.   #--------------------------------------------------------------------------
  710.   def create_status_window
  711.     @status_window = Window_MenuStatus.new(244, 0)
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # * Create Help Window
  715.   #--------------------------------------------------------------------------
  716.   def create_help_window
  717.     @help_window = DKPWindow_Help.new
  718.     @help_window.viewport = @viewport
  719.   end  
  720.   #--------------------------------------------------------------------------
  721.   # * Category [OK]
  722.   #--------------------------------------------------------------------------
  723.   def on_category_ok
  724.     @item_window.activate
  725.     @item_window.select_last
  726.   end
  727.   #--------------------------------------------------------------------------
  728.   # * Item [OK]
  729.   #--------------------------------------------------------------------------
  730.   def on_item_ok
  731.     $game_party.last_item.object = item
  732.     determine_item
  733.   end
  734.     def determine_item
  735.     if item.for_friend?
  736.       show_sub_window(@actor_window)
  737.       @actor_window.select_for_item(item)
  738.     else
  739.       use_item
  740.       activate_item_window
  741.     end
  742.   end
  743.     def cursor_left?
  744.     @item_window.index % 1 == 0
  745.   end
  746.     def show_sub_window(window)
  747.     width_remain = Graphics.width - window.width
  748.     window.x = cursor_left? ? width_remain : 0
  749.     @viewport.rect.x = @viewport.ox = cursor_left? ? 0 : window.width
  750.     @viewport.rect.width = width_remain
  751.     window.show.activate
  752.   end
  753.   #--------------------------------------------------------------------------
  754.   # * Item [Cancel]
  755.   #--------------------------------------------------------------------------
  756.   def on_item_cancel
  757.     @item_window.unselect
  758.     @category_window.activate
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # * Play SE When Using Item
  762.   #--------------------------------------------------------------------------
  763.   def play_se_for_item
  764.     Sound.play_use_item
  765.   end
  766.   #--------------------------------------------------------------------------
  767.   # * Use Item
  768.   #--------------------------------------------------------------------------
  769.   def use_item
  770.     super
  771.     @item_window.redraw_current_item
  772.   end
  773. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement