dsiver144

Dark's Custom Menu v1.1

Feb 16th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.96 KB | None | 0 0
  1. #===============================================================================
  2. # Script       : Dark's Custom Menu
  3. # Author       : Nhat Nguyen ( Dark Sky )
  4. # Release Date : Feb 16th 2016
  5. # Version      : 1.1                                                                          
  6. #===============================================================================
  7. module CustomMenu
  8.   #---------------------------------------------------------------------------
  9.   Background_Image  = "Background"
  10.   CommandList_Image = "Command List"
  11.   Gold_Image        = "Gold"
  12.   Main_Menu_Image   = "Main Menu"
  13.   Status_Image      = ""
  14.   Cursor_Image      = "Select Actor"
  15.   Actor_image_regex = /<custom_*face:\s*"(\w+)">/i
  16.   #---------------------------------------------------------------------------
  17. end
  18. #==============================================================================
  19. # ** Scene_Menu
  20. #------------------------------------------------------------------------------
  21. #  This class performs the menu screen processing.
  22. #==============================================================================
  23.  
  24. class Scene_Menu < Scene_MenuBase
  25.   #--------------------------------------------------------------------------
  26.   # * Start Processing
  27.   #--------------------------------------------------------------------------
  28.   def start
  29.     super
  30.     create_command_window
  31.     create_gold_window
  32.     create_status_window
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * Create Command Window
  36.   #--------------------------------------------------------------------------
  37.   alias dark_custom_menu create_command_window
  38.   def create_command_window
  39.     dark_custom_menu
  40.     @command_window_sprite = Sprite.new
  41.     @command_window_sprite.bitmap = Cache.picture(CustomMenu::CommandList_Image)
  42.     @command_window.width = 140
  43.     @command_window.x = 35
  44.     @command_window.y = 110
  45.     @command_window.opacity = 0
  46.     @command_window.back_opacity = 0
  47.     if @command_window.last_symbol != nil
  48.       @command_window.select_last
  49.     else
  50.       @command_window.select(0)
  51.     end
  52.     @command_window.contents_width
  53.     @command_window.create_contents
  54.     @command_window.refresh
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Create Gold Window
  58.   #--------------------------------------------------------------------------
  59.   alias dark_custom_menu_create_gold_window create_gold_window
  60.   def create_gold_window
  61.     dark_custom_menu_create_gold_window
  62.     @gold_window.x = 64
  63.     @gold_window.y += 3
  64.     @gold_window.opacity = 0
  65.     @gold_window.back_opacity = 0
  66.     @gold_window_sprite = Sprite.new
  67.     @gold_window_sprite.bitmap = Cache.picture(CustomMenu::Gold_Image)
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Create Background
  71.   #--------------------------------------------------------------------------
  72.   def create_background
  73.     @background_sprite = Sprite.new
  74.     @background_sprite.bitmap = Cache.picture(CustomMenu::Background_Image)
  75.     @main_menu_sprite  = Sprite.new
  76.     @main_menu_sprite.bitmap  = Cache.picture(CustomMenu::Main_Menu_Image)
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # * Create Status Window
  80.   #--------------------------------------------------------------------------
  81.   def create_status_window
  82.     @status_window = Window_MenuStatus.new(@command_window.width, 0)
  83.     @status_window.opacity = 0
  84.     @status_window.x = 182 - 32
  85.     @status_window.y = 62 - 12
  86.     @status_window.back_opacity = 0
  87.     @status_window_sprite = Sprite.new
  88.     @status_window_sprite.bitmap = Cache.picture(CustomMenu::Status_Image)
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Update
  92.   #--------------------------------------------------------------------------
  93.   alias dark_custom_menu_update update
  94.   def update
  95.     dark_custom_menu_update
  96.   end
  97. end
  98.  
  99. class Scene_ItemBase < Scene_MenuBase
  100.   #--------------------------------------------------------------------------
  101.   # * Start Processing
  102.   #--------------------------------------------------------------------------
  103.   def start
  104.     super
  105.     create_actor_window
  106.     create_background
  107.   end
  108. end
  109.  
  110. class Game_Actor < Game_Battler
  111.   attr_reader :note
  112.   #--------------------------------------------------------------------------
  113.   # * Object Initialization
  114.   #--------------------------------------------------------------------------
  115.   alias dark_custom_menu_initialize_game_actor initialize
  116.   def initialize(actor_id)
  117.     dark_custom_menu_initialize_game_actor(actor_id)
  118.     @note = actor.note
  119.   end
  120. end
  121.  
  122. #==============================================================================
  123. # ** Window_MenuStatus
  124. #------------------------------------------------------------------------------
  125. #  This window displays party member status on the menu screen.
  126. #==============================================================================
  127.  
  128. class Window_MenuStatus < Window_Selectable
  129.   #--------------------------------------------------------------------------
  130.   # * Public Instance Variables
  131.   #--------------------------------------------------------------------------
  132.   attr_reader   :pending_index            # Pending position (for formation)
  133.   #--------------------------------------------------------------------------
  134.   # * Object Initialization
  135.   #--------------------------------------------------------------------------
  136.   def initialize(x, y)
  137.     super(x, y, window_width, window_height)
  138.     self.windowskin = Cache.system("Custom_Menu_Windowskin")
  139.     @cursor_image = Sprite.new
  140.     @cursor_image.bitmap = Cache.picture(CustomMenu::Cursor_Image)
  141.     @cursor_image.x = Graphics.width - @cursor_image.width
  142.     @cursor_image.y = 65
  143.     @cursor_image.visible = false
  144.     @face_images = []
  145.     refresh
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # * Get Item Height
  149.   #--------------------------------------------------------------------------
  150.   def item_height
  151.     41
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Get Spacing for Items Arranged Side by Side
  155.   #--------------------------------------------------------------------------
  156.   def spacing
  157.     return 17
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # * Get Rectangle for Drawing Items
  161.   #--------------------------------------------------------------------------
  162.   def item_rect(index)
  163.     rect = Rect.new
  164.     rect.width = item_width
  165.     rect.height = item_height
  166.     rect.x = index % col_max * (item_width + spacing)
  167.     rect.y = index / col_max * (item_height+spacing+index-1.5)
  168.     rect
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Draw Item
  172.   #--------------------------------------------------------------------------
  173.   def draw_item(index)
  174.     actor = $game_party.members[index]
  175.     enabled = $game_party.battle_members.include?(actor)
  176.     rect = item_rect(index)
  177.     if actor.note =~ CustomMenu::Actor_image_regex
  178.       @face_images.push(Sprite.new)
  179.       @face_images[index].bitmap = Cache.picture($1.to_s)
  180.       @face_images[index].z = 0
  181.     end
  182.     draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  183.   end
  184.  
  185.   def draw_actor_simple_status(actor, x, y)
  186.     draw_actor_name(actor, x + 12, y)
  187.     draw_actor_icons(actor, x, y + line_height * 2)
  188.     draw_actor_hp(actor, x + 80 , y + 8, 80)
  189.     draw_actor_mp(actor, x + 170, y + 8, 80)
  190.     draw_actor_tp(actor, x, y + 21, 60)
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Draw TP
  194.   #--------------------------------------------------------------------------
  195.   def draw_actor_tp(actor, x, y, width = 124)
  196.     change_color(system_color)
  197.     draw_text(x, y, 30, line_height, Vocab::tp_a)
  198.     change_color(tp_color(actor))
  199.     draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # * Draw Name
  203.   #--------------------------------------------------------------------------
  204.   def draw_actor_name(actor, x, y, width = 112)
  205.     change_color(hp_color(actor))
  206.     contents.font.name = ["Chau Philomene One",Font.default_name]
  207.     contents.font.out_color = Color.new(162,0,255)
  208.     draw_text(x, y, width, line_height, actor.name)
  209.     contents.font.out_color = Font.default_out_color
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # * Processing When OK Button Is Pressed
  213.   #--------------------------------------------------------------------------
  214.   def process_ok
  215.     super
  216.     $game_party.menu_actor = $game_party.members[index]
  217.   end
  218.  
  219.   alias dark_custom_menu_dispose_menustatus dispose
  220.   def dispose
  221.     dark_custom_menu_dispose_menustatus
  222.     bitmap_dispose
  223.   end
  224.   def bitmap_dispose
  225.     @cursor_image.bitmap.dispose
  226.     @cursor_image.dispose
  227.     @face_images.each do |sprite|
  228.       sprite.bitmap.dispose
  229.       sprite.dispose
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # * Update Cursor Bitmap Position
  234.   #--------------------------------------------------------------------------  
  235.   def update_cursor_bitmap
  236.     @cursor_image.visible = self.active
  237.     if @index != -1
  238.       @cursor_image.visible = true
  239.       @cursor_image.y = 65 + @index*19*3
  240.       if @index == 2
  241.         @cursor_image.y += 4
  242.       end
  243.       if @index == 3
  244.         @cursor_image.y += 6
  245.       end
  246.     end
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Refresh
  250.   #--------------------------------------------------------------------------
  251.   alias dark_custom_menu_refresh refresh
  252.   def refresh
  253.     dark_custom_menu_refresh
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * Update
  257.   #--------------------------------------------------------------------------
  258.   alias dark_custom_menu_update_menustatus update
  259.   def update
  260.     dark_custom_menu_update_menustatus
  261.     update_cursor_bitmap if !@cursor_image.disposed?
  262.   end
  263. end
  264.  
  265. #==============================================================================
  266. # ** Window_MenuCommand
  267. #------------------------------------------------------------------------------
  268. #  This command window appears on the menu screen.
  269. #==============================================================================
  270.  
  271. class Window_MenuCommand < Window_Command
  272.   #--------------------------------------------------------------------------
  273.   # * Initialize Command Selection Position (Class Method)
  274.   #--------------------------------------------------------------------------
  275.   def self.init_command_position
  276.     @@last_command_symbol = nil
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # * Object Initialization
  280.   #--------------------------------------------------------------------------
  281.   def initialize
  282.     super(0, 0)
  283.     select_last
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # * Get Last Command Position
  287.   #--------------------------------------------------------------------------
  288.   def last_symbol
  289.     return @@last_command_symbol
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # * Draw Item
  293.   #--------------------------------------------------------------------------
  294.   def draw_item(index)
  295.     change_color(normal_color, command_enabled?(index))
  296.     draw_text(item_rect_for_text(index), command_name(index), 1)
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # * Make Command List
  300.   #--------------------------------------------------------------------------
  301.   def make_command_list
  302.     add_main_commands
  303.     add_original_commands
  304.     add_save_command
  305.     add_game_end_command
  306.   end
  307. end
Advertisement
Add Comment
Please, Sign In to add comment