Guest User

Untitled

a guest
Apr 6th, 2013
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 12.87 KB | None | 0 0
  1. #===============================================================================
  2. # * Main Menu Evo II
  3. # * Successor to Main Menu EVO
  4. # * By Crazyninjaguy
  5. # * http://www.planetdev.co.uk
  6. # * Part of CNG Engine Evolution
  7. #===============================================================================
  8.  
  9. $imported = {} if $imported == nil
  10. $imported["CEE-MainMenuEvoII"] = true
  11.  
  12. module CngEvo
  13.   module Menu
  14.     #===========================================================================
  15.     # * Load System data to prevent errors when loading Vocab terms
  16.     #===========================================================================
  17.     $data_system = load_data("Data/System.rvdata")
  18.     #===========================================================================
  19.     # * Menu Commands, seperate each value with a comma.
  20.     # * To add new commands, either use a Vocab entry (See the Vocab Module),
  21.     #   Or use a text string in quotes, example: "Quests"
  22.     #===========================================================================
  23.     COMMANDS = [
  24.     Vocab::item,
  25.     Vocab::skill,
  26.     Vocab::equip,
  27.     Vocab::status,
  28.     Vocab::save,
  29.     Vocab::game_end]
  30.     #===========================================================================
  31.     # * These are the icons that display next to the command option in the menu.
  32.     # * The best way to find the number of the icon is to use Yanfly's
  33.     #   YEM IconView Melody, and look for the ID number.
  34.     # * Seperate each number with a comma.
  35.     #===========================================================================
  36.     ICONS = [
  37.     144,
  38.     128,
  39.     32,
  40.     106,
  41.     141,
  42.     142]
  43.     #===========================================================================
  44.     # * These are the scenes to call for each menu command.
  45.     # * Copy the existing examples to add new ones.
  46.     # * The last value (True/False) is whether or not you need to select an
  47.     #   an actor to continue onto that scene.
  48.     # * True = Select an Actor.
  49.     # * False = Don't select one.
  50.     #===========================================================================
  51.     SCENES = [
  52.     [Scene_Item, false],
  53.     [Scene_Skill, true],
  54.     [Scene_Equip, true],
  55.     [Scene_Status, true],
  56.     [Scene_File, false],
  57.     [Scene_End, false]]
  58.     #===========================================================================
  59.     # * These are the Playtime, Steps, Map Name and Gold icons.
  60.     # * As with the others, seperate with a comma
  61.     #===========================================================================
  62.     INFO_ICONS = [
  63.     188,
  64.     48,
  65.     153,
  66.     205]
  67.   end # Menu
  68. end # CngEvo
  69.  
  70. #===============================================================================
  71. # * Scene_Menu Class, Processes the main menu.
  72. #===============================================================================
  73. class Scene_Menu < Scene_Base
  74.   #=============================================================================
  75.   # * Include the Menu module and initialize the command_window index
  76.   #=============================================================================
  77.   include CngEvo::Menu
  78.   def initialize(menu_index = 0)
  79.     @menu_index = menu_index
  80.   end # initialize
  81.   #=============================================================================
  82.   # * Start the scene by creating windows etc
  83.   #=============================================================================
  84.   def start
  85.     super
  86.     create_menu_background
  87.     create_command_window
  88.     @status_window = Window_MenuEvoStatus.new
  89.     @menuinfo = Window_MenuInfo.new
  90.   end # start
  91.   #=============================================================================
  92.   # * End the scene and dispose windows etc
  93.   #=============================================================================
  94.   def terminate
  95.     super
  96.     dispose_menu_background
  97.     @menudummy.dispose
  98.     @command_window.dispose
  99.     @status_window.dispose
  100.     @menuinfo.dispose
  101.   end # terminate
  102.   #=============================================================================
  103.   # * Update the scene's windows
  104.   #=============================================================================
  105.   def update
  106.     super
  107.     @menuinfo.update
  108.     if @command_window.active
  109.       @command_window.update
  110.       update_command
  111.     elsif @status_window.active
  112.       @status_window.update
  113.       update_actor_selection
  114.     end
  115.   end # update
  116.   #=============================================================================
  117.   # * Create the main command window
  118.   #=============================================================================
  119.   def create_command_window
  120.     @menudummy = Window_MenuDummy.new
  121.     @command_window = Window_Command.new(140, COMMANDS)
  122.     @command_window.index = @menu_index
  123.     @command_window.x = 24
  124.     @command_window.opacity = 0
  125.   end # create_command_window
  126.   #=============================================================================
  127.   # * Update the command window, and process choices
  128.   #=============================================================================
  129.   def update_command
  130.     if Input.trigger?(Input::C)
  131.       Sound.play_decision
  132.       if SCENES[@command_window.index][1] == false
  133.         $scene = SCENES[@command_window.index][0].new
  134.       else
  135.         start_actor_selection
  136.       end
  137.     elsif Input.trigger?(Input::B)
  138.       Sound.play_cancel
  139.       $scene = Scene_Map.new
  140.     end
  141.   end # update_command
  142. end # Scene_Menu
  143.  
  144. #===============================================================================
  145. # * Window_MenuDummy, this window draws the menu icons.
  146. #===============================================================================
  147. class Window_MenuDummy < Window_Base
  148.   #=============================================================================
  149.   # * Include the Menu module, and setup window size
  150.   #=============================================================================
  151.   include CngEvo::Menu
  152.   def initialize
  153.     super(0, 0, 164, ((24 * COMMANDS.size) + 32))
  154.     refresh
  155.   end # initialize
  156.   #=============================================================================
  157.   # * Draw the icons
  158.   #=============================================================================
  159.   def refresh
  160.     for i in 0...ICONS.size
  161.       draw_icon(ICONS[i], -2, (i * 24)) # Items
  162.     end
  163.   end # refresh
  164. end # Window_MenuDummy
  165.  
  166. #===============================================================================
  167. # * Window_MenuEvoStatus, this window is a Window_MenuStatus Replacement
  168. #===============================================================================
  169. class Window_MenuEvoStatus < Window_Selectable
  170.   #=============================================================================
  171.   # * Initialize the window, ans setup values
  172.   #=============================================================================
  173.   def initialize
  174.     super(0, (416 - 192), 544, 192)
  175.     refresh
  176.     self.active = false
  177.     self.index = -1
  178.   end # initialize
  179.   #=============================================================================
  180.   # * Draw window contents
  181.   #=============================================================================
  182.   def refresh
  183.     self.contents.clear
  184.     @item_max = $game_party.members.size
  185.     @facesprites = []
  186.     for actor in $game_party.members
  187.       x = actor.index * 128 + 16
  188.       draw_actor_evoface(actor, x, 64)
  189.       draw_actor_graphic(actor, x + 14, 158)
  190.       draw_actor_name(actor, x, 0)
  191.       draw_actor_level(actor, x, 32)
  192.       draw_actor_state(actor, x + 80, 0)
  193.       draw_actor_hp(actor, x - 12, 64)
  194.       draw_actor_mp(actor, x - 12, 96)
  195.     end
  196.   end # refresh
  197.   #=============================================================================
  198.   # * Update cursor
  199.   #=============================================================================
  200.   def update_cursor
  201.     if @index < 0               # No cursor
  202.       self.cursor_rect.empty
  203.     elsif @index < @item_max    # Normal
  204.       self.cursor_rect.set((@index * 128), 0, 128, 160)
  205.     elsif @index >= 100         # Self
  206.       self.cursor_rect.set((@index * 128), 0, 128, 160)
  207.     else                        # All
  208.       self.cursor_rect.set(0, 0, contents.width, 160)
  209.     end
  210.   end # update_cursor
  211.   #=============================================================================
  212.   # * Add support for horizontal scrolling
  213.   #=============================================================================
  214.   def update
  215.     super
  216.     if cursor_movable?
  217.       last_index = @index
  218.       if Input.repeat?(Input::RIGHT)
  219.         if @index == 0
  220.           if $game_party.members.size > 1
  221.             @index = 1
  222.           end
  223.         elsif @index == 1
  224.           if $game_party.members.size > 2
  225.             @index = 2
  226.           end
  227.         elsif @index == 2
  228.           if $game_party.members.size > 3
  229.             @index = 3
  230.           end
  231.         elsif @index == 3
  232.           if $game_party.members.size >= 4
  233.             @index = 0
  234.           end
  235.         end
  236.       elsif Input.repeat?(Input::LEFT)
  237.         if @index == 0
  238.           if $game_party.members.size >= 4
  239.             @index = 3
  240.           end
  241.         elsif @index == 1
  242.           @index = 0
  243.         elsif @index == 2
  244.           @index = 1
  245.         elsif @index == 3
  246.           @index = 2
  247.         end
  248.       end
  249.       if @index != last_index
  250.         Sound.play_cursor
  251.       end
  252.     end
  253.     update_cursor
  254.     call_update_help
  255.   end # update
  256. end # Window_MenuEvoStatus
  257.  
  258. #===============================================================================
  259. # * Window_MenuInfo class, this window draws Playtime, Steps etc.
  260. #===============================================================================
  261. class Window_MenuInfo < Window_Base
  262.   #=============================================================================
  263.   # * Include the Menu module and setup window size
  264.   #=============================================================================
  265.   include CngEvo::Menu
  266.   def initialize
  267.     super((544 - 260), 0, 260, 128)
  268.     refresh
  269.   end # initialize
  270.   #=============================================================================
  271.   # * Draw Window contents
  272.   #=============================================================================
  273.   def refresh
  274.     self.contents.clear
  275.     draw_icon(INFO_ICONS[1], 0, 24) # Steps
  276.     draw_icon(INFO_ICONS[2], 0, 48) # Map Name
  277.     draw_icon(INFO_ICONS[3], 0, 72) # Area
  278.     draw_time
  279.     self.contents.draw_text(0, 24, width - 32, WLH, $game_party.steps, 2)
  280.     @map_name = load_data("Data/MapInfos.rvdata")[$game_map.map_id].name
  281.     self.contents.draw_text(0, 48, width - 32, WLH, @map_name, 2)
  282.     self.contents.draw_text(0, 72, width - 32, WLH, $game_party.gold, 2)
  283.   end # refresh
  284.   #=============================================================================
  285.   # * Check if Playtime is different from last check
  286.   #=============================================================================
  287.   def update
  288.     if @text != (Graphics.frame_count / Graphics.frame_rate)
  289.       draw_time
  290.     end
  291.     super
  292.   end # update
  293.   #=============================================================================
  294.   # * Draw playtime info
  295.   #=============================================================================
  296.   def draw_time
  297.     self.contents.clear_rect(Rect.new(0, 0, (260 - 32), 24))
  298.     draw_icon(INFO_ICONS[0], 0, 0) # Playtime
  299.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  300.     @hour = @total_sec / 60 / 60
  301.     @min = @total_sec / 60 % 60
  302.     @sec = @total_sec % 60
  303.     @text = sprintf("%02d:%02d:%02d", @hour, @min, @sec)
  304.     self.contents.draw_text(0, 0, width - 32, WLH, @text, 2)
  305.   end # draw_time
  306. end # Window_MenuInfo
  307.  
  308. #===============================================================================
  309. # * Window_Base Edits to allow for face opacity changing
  310. #===============================================================================
  311. class Window_Base < Window
  312.   #=============================================================================
  313.   # * Draw the character's face graphic
  314.   #=============================================================================
  315.   def draw_evoface(face_name, face_index, x, y, size = 96)
  316.     opacity = 100
  317.     bitmap = Cache.face(face_name)
  318.     rect = Rect.new(0, 0, 0, 0)
  319.     rect.x = face_index % 4 * 96 + (96 - size) / 2
  320.     rect.y = face_index / 4 * 96 + (96 - size) / 2
  321.     rect.width = size
  322.     rect.height = size
  323.     self.contents.blt(x, y, bitmap, rect, opacity)
  324.     bitmap.dispose
  325.   end # draw_evoface
  326.   #=============================================================================
  327.   # * Call the draw_evoface method with the relevant arguments
  328.   #=============================================================================
  329.   def draw_actor_evoface(actor, x, y, size = 96)
  330.     draw_evoface(actor.face_name, actor.face_index, x, y, size)
  331.   end # draw_actor_evoface
  332. end # Window_Base
Advertisement
Add Comment
Please, Sign In to add comment