Advertisement
Guest User

[RGSS 2]Three actor menu

a guest
Mar 10th, 2012
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.92 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # DT's Three actor menu
  4. # Author: DoctorTodd
  5. # Date (02/19/2012)
  6. # Type: (Menu)
  7. # Version: (1.0.0)
  8. # Level: (Simple)
  9. # Email: BeaconGames2011@gmail.com
  10. #
  11. #===============================================================================
  12. #
  13. # Description: A menu that is modified to work as if you are only using three
  14. # actors.
  15. #
  16. # Credits: Me (DoctorTodd), Sykval for location window.
  17. #
  18. #===============================================================================
  19. #
  20. # Instructions
  21. # Paste above main.
  22. #
  23. #===============================================================================
  24. #
  25. # This script requires no editing.
  26. #
  27. #===============================================================================
  28.  
  29. class Scene_Menu < Scene_Base
  30.   #--------------------------------------------------------------------------
  31.   # * Object Initialization
  32.   #     menu_index : command cursor's initial position
  33.   #--------------------------------------------------------------------------
  34.   def initialize(menu_index = 0)
  35.     @menu_index = menu_index
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # * Start processing
  39.   #--------------------------------------------------------------------------
  40.   def start
  41.     super
  42.     create_menu_background
  43.     create_command_window
  44.     @gold_window = Window_Gold.new(0, 360)
  45.     @status_window = Window_MenuStatus.new(0, 55)
  46.     @win_loc = Scene_Menu::Window_location.new(272, 360)
  47.     @title = Window_MenuTitle.new(0, 0)
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # * Termination Processing
  51.   #--------------------------------------------------------------------------
  52.   def terminate
  53.     super
  54.     dispose_menu_background
  55.     @command_window.dispose
  56.     @gold_window.dispose
  57.     @status_window.dispose
  58.     @win_loc.dispose
  59.     @title.dispose
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Frame Update
  63.   #--------------------------------------------------------------------------
  64.   def update
  65.     super
  66.     update_menu_background
  67.     @command_window.update
  68.     @gold_window.update
  69.     @status_window.update
  70.     if @command_window.active
  71.     update_command_selection
  72.     elsif @status_window.active
  73.       update_actor_selection
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # * Create Command Window
  78.   #--------------------------------------------------------------------------
  79.   def create_command_window
  80.     s1 = Vocab::item
  81.     s2 = Vocab::skill
  82.     s3 = Vocab::equip
  83.     s4 = Vocab::status
  84.     s5 = Vocab::save
  85.     s6 = Vocab::game_end
  86.     @command_window = Window_Command.new(165, [s1, s2, s3, s4, s5, s6])
  87.     @command_window.index = @menu_index
  88.     @command_window.x = 381
  89.     @command_window.y = 55
  90.     if $game_party.members.size == 0          # If number of party members is 0
  91.       @command_window.draw_item(0, false)     # Disable item
  92.       @command_window.draw_item(1, false)     # Disable skill
  93.       @command_window.draw_item(2, false)     # Disable equipment
  94.       @command_window.draw_item(3, false)     # Disable status
  95.     end
  96.     if $game_system.save_disabled             # If save is forbidden
  97.       @command_window.draw_item(4, false)     # Disable save
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Update Command Selection
  102.   #--------------------------------------------------------------------------
  103.   def update_command_selection
  104.     if Input.trigger?(Input::B)
  105.       Sound.play_cancel
  106.       $scene = Scene_Map.new
  107.     elsif Input.trigger?(Input::C)
  108.       if $game_party.members.size == 0 and @command_window.index < 4
  109.         Sound.play_buzzer
  110.         return
  111.       elsif $game_system.save_disabled and @command_window.index == 4
  112.         Sound.play_buzzer
  113.         return
  114.       end
  115.       Sound.play_decision
  116.       case @command_window.index
  117.       when 0      # Item
  118.         $scene = Scene_Item.new
  119.       when 1,2,3  # Skill, equipment, status
  120.         start_actor_selection
  121.       when 4      # Save
  122.         $scene = Scene_File.new(true, false, false)
  123.       when 5      # End Game
  124.         $scene = Scene_End.new
  125.       end
  126.     end
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * Start Actor Selection
  130.   #--------------------------------------------------------------------------
  131.   def start_actor_selection
  132.     @command_window.active = false
  133.     @status_window.active = true
  134.     if $game_party.last_actor_index < @status_window.item_max
  135.       @status_window.index = $game_party.last_actor_index
  136.     else
  137.       @status_window.index = 0
  138.     end
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * End Actor Selection
  142.   #--------------------------------------------------------------------------
  143.   def end_actor_selection
  144.     @command_window.active = true
  145.     @status_window.active = false
  146.     @status_window.index = -1
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * Update Actor Selection
  150.   #--------------------------------------------------------------------------
  151.   def update_actor_selection
  152.     if Input.trigger?(Input::B)
  153.       Sound.play_cancel
  154.       end_actor_selection
  155.     elsif Input.trigger?(Input::C)
  156.       $game_party.last_actor_index = @status_window.index
  157.       Sound.play_decision
  158.       case @command_window.index
  159.       when 1  # skill
  160.         $scene = Scene_Skill.new(@status_window.index)
  161.       when 2  # equipment
  162.         $scene = Scene_Equip.new(@status_window.index)
  163.       when 3  # status
  164.         $scene = Scene_Status.new(@status_window.index)
  165.       end
  166.     end
  167.   end
  168. end
  169. #==============================================================================
  170. # ** Window_MenuStatus
  171. #------------------------------------------------------------------------------
  172. #  This window displays party member status on the menu screen.
  173. #==============================================================================
  174.  
  175. class Window_MenuStatus < Window_Selectable
  176.   #--------------------------------------------------------------------------
  177.   # * Object Initialization
  178.   #     x : window X coordinate
  179.   #     y : window Y coordinate
  180.   #--------------------------------------------------------------------------
  181.   def initialize(x, y)
  182.     super(x, y, 384, 305)
  183.     refresh
  184.      self.active = false
  185.     self.index = -1
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Refresh
  189.   #--------------------------------------------------------------------------
  190.   def refresh
  191.     self.contents.clear
  192.     @item_max = 3
  193.     for actor in $game_party.members
  194.       draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
  195.       x = 104
  196.       y = actor.index * 96 + WLH / 2
  197.       draw_actor_name(actor, x, y)
  198.       draw_actor_class(actor, x + 120, y)
  199.       draw_actor_level(actor, x, y + WLH * 1)
  200.       draw_actor_state(actor, x, y + WLH * 2)
  201.       draw_actor_hp(actor, x + 120, y + WLH * 1)
  202.       draw_actor_mp(actor, x + 120, y + WLH * 2)
  203.     end
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # * Update cursor
  207.   #--------------------------------------------------------------------------
  208.   def update_cursor
  209.     if @index < 0               # No cursor
  210.       self.cursor_rect.empty
  211.     elsif @index < @item_max    # Normal
  212.       self.cursor_rect.set(0, @index * 96, contents.width, 96)
  213.     elsif @index >= 100         # Self
  214.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  215.     else                        # All
  216.       self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  217.     end
  218.   end
  219. end
  220.  
  221. #==============================================================================
  222. # ** Window_Gold
  223. #------------------------------------------------------------------------------
  224. #  This window displays the amount of gold.
  225. #==============================================================================
  226.  
  227. class Window_Gold < Window_Base
  228.   #--------------------------------------------------------------------------
  229.   # * Object Initialization
  230.   #     x : window X coordinate
  231.   #     y : window Y coordinate
  232.   #--------------------------------------------------------------------------
  233.   def initialize(x, y)
  234.     super(x, y, 272, WLH + 32)
  235.     refresh
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * Refresh
  239.   #--------------------------------------------------------------------------
  240.   def refresh
  241.     self.contents.clear
  242.     draw_currency_value($game_party.gold, 4, 0, 230)
  243.   end
  244. end
  245. #==============================================================================
  246. # ** Window_Location
  247. #------------------------------------------------------------------------------
  248. #  This class shows the current map name.
  249. #==============================================================================
  250.  
  251. class Window_location < Window_Base
  252.   #--------------------------------------------------------------------------
  253.   # * Object Initialization
  254.   #--------------------------------------------------------------------------
  255.   def initialize(x, y)
  256.     super(x, y, 272, WLH + 32)
  257.     self.contents = Bitmap.new(width - 32, height - 32)
  258.     refresh
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * Refresh
  262.   #--------------------------------------------------------------------------
  263.   def refresh
  264.     self.contents.clear
  265.     $maps = load_data("Data/MapInfos.rvdata")
  266.     @map_id = $game_map.map_id
  267.     @currmap = $maps[@map_id].name
  268.     self.contents.font.color = system_color
  269.     self.contents.draw_text(0, -4, 128, 35, "Location:")
  270.     self.contents.font.color = normal_color
  271.     self.contents.draw_text(0, -4, 230, 35, @currmap, 1)
  272.   end
  273. end
  274. #==============================================================================
  275. # ** Window_MenuTitle
  276. #------------------------------------------------------------------------------
  277. #  This window is almost pointless, it just draws a window saying Main Menu.
  278. #==============================================================================
  279.  
  280. class Window_MenuTitle < Window_Base
  281.   #--------------------------------------------------------------------------
  282.   # * Object Initialization
  283.   #     x : window X coordinate
  284.   #     y : window Y coordinate
  285.   #--------------------------------------------------------------------------
  286.   def initialize(x, y)
  287.     super(x, y, 544, WLH + 32)
  288.     refresh
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Refresh
  292.   #--------------------------------------------------------------------------
  293.   def refresh
  294.     self.contents.clear
  295.     self.contents.font.color = system_color
  296.     self.contents.draw_text(0, -4, 128, 35, "Main Menu")
  297.   end
  298. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement