Advertisement
Zetu

Leaf Style Menu v1.02

Jun 8th, 2011
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.79 KB | None | 0 0
  1. #==============================================================================#
  2. #                             Leaf Style Menu v1.02                            #
  3. #  NEEDED IMAGES                                                               #
  4. #    charset                                                                   #
  5. #    large_shd_charsheet                                                       #
  6. #    large_shd_charsheet_g                                                     #
  7. #    colorbar                                                                  #
  8. #    graybar                                                                   #
  9. #    hud_leaf                                                                  #
  10. #    hud_leafexp                                                               #
  11. #    imgbar_hp                                                                 #
  12. #    imgbar_mp                                                                 #
  13. #    imgbar_exp                                                                #
  14. #                                                                              #
  15. #  NEEDED SCRIPTS                                                              #
  16. #    Neo Menu System LITE by Zetu                                              #
  17. #    Text to Image by Zetu                                                     #
  18. #      *Fonts: "Default" (6-8 px)                                              #
  19. #              "24pxReq" (24 px)   THESE TWO NEED TO BE ADDED TO T2I's MODULE  #
  20. #              "ReqGS"   (24 px) Gray Version of 24pxReq.                      #
  21. #==============================================================================#
  22.  
  23. class Scene_Menu < Scene_Base
  24.  
  25.   alias nms_start start
  26.   def start
  27.     nms_start
  28.     @status_window.x += 32
  29.     @command_window.opacity = 0
  30.   end
  31.  
  32.   def create_command_window
  33.     @command_window = Window_CommandNMS.new(160, Z_Systems::NeoMenu::MENU_ITEMS, 1, 0)####
  34.     @command_window.index = @menu_index
  35.     zs_nms_disable
  36.   end
  37.  
  38.   def cmd_index
  39.     return @command_window.nil? ? 0 : @command_window.index
  40.   end
  41.  
  42. end
  43.  
  44. class Window_Base
  45.  
  46.   def draw_pic(filename, x, y, size = -1, allign = 0)
  47.     bitmap = Cache.picture(filename)
  48.     if size == -1
  49.       size = bitmap.width
  50.     end
  51.     size = [[size, 0].max, bitmap.width].min
  52.     rect = Rect.new(0, 0, 0, 0)
  53.     if allign == 1
  54.       rect.x = bitmap.width - size
  55.     end
  56.     rect.width = size
  57.     rect.height = bitmap.height
  58.     self.contents.blt(x, y, bitmap, rect)
  59.     bitmap.dispose
  60.   end
  61.  
  62. end
  63.  
  64. class Game_Actor < Game_Battler
  65.   def exp_til
  66.     return (@exp - @exp_list[@level])
  67.   end
  68.   def exp_max
  69.     return 0 if @level == 99
  70.     return @exp_list[@level+1] - @exp_list[@level]
  71.   end
  72. end
  73.  
  74. class Window_CommandNMS < Window_Selectable
  75.   include Z_Systems::NeoMenu
  76.   alias nms_initialize initialize
  77.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  78.     if row_max == 0
  79.       row_max = (commands.size + column_max - 1) / column_max
  80.     end
  81.     super(-16, -16, 224, row_max * WLH + 80, spacing)
  82.     @commands = commands
  83.     @item_max = commands.size
  84.     @column_max = column_max
  85.     @index = 0
  86.     refresh
  87.   end
  88.  
  89.   def draw_item(index, enabled = true)
  90.     type = MENU_ITEMS[$scene.cmd_index]
  91.     enabled = !DISABLES[type] unless DISABLES[type].nil?
  92.     rect = item_rect(index)
  93.     self.contents.clear_rect(rect)
  94.     bg_img = (enabled and index == $scene.cmd_index) ? "ColorBar" : "GrayBar"
  95.     tx = index == $scene.cmd_index ? 0 : -16
  96.     font = (enabled and index == $scene.cmd_index) ? "24pxReq" : "ReqGS"
  97.     draw_pic(bg_img, tx, rect.y)
  98.     draw_img_text(@commands[index], tx + 16, rect.y + 4, 0, 0, font)
  99.     draw_icon(ICONS[@commands[index]], tx + 168, rect.y+4)
  100.   end
  101.  
  102.   def item_rect(index)
  103.     rect = Rect.new(0, 0, 0, 0)
  104.     rect.width = 192
  105.     rect.height = 32
  106.     rect.x = 0
  107.     rect.y = index * 32
  108.     return rect
  109.   end
  110.  
  111.   alias nms_update update
  112.   def update
  113.     nms_update
  114.     refresh if @last_index != @index
  115.   end
  116.  
  117.   def refresh
  118.     @last_index = self.index
  119.     self.contents.clear
  120.     @index = @last_index
  121.     for i in 0...@item_max
  122.       draw_item(i)
  123.     end
  124.   end
  125.  
  126.   def update_cursor
  127.     self.cursor_rect.empty
  128.   end
  129.  
  130. end
  131.  
  132. class Window_MenuStatus < Window_Selectable
  133.  
  134.   def initialize(x, y)
  135.     super(x, y, 352, 416)
  136.     refresh
  137.     self.active = false
  138.     self.index = -1
  139.   end
  140.  
  141.   def refresh
  142.     self.contents.clear
  143.     @item_max = $game_party.members.size
  144.     for actor in $game_party.members
  145.       draw_actor_face(actor, 226, actor.index * 96 + 2, 92)
  146.       y = actor.index * 96 + WLH / 2
  147.       draw_actor_name(actor, 0, y)
  148.       draw_actor_class(actor, 100, y)
  149.       draw_actor_level(actor, 0, y + WLH * 1)
  150.       draw_actor_state(actor, 100, y + WLH * 1)
  151.       draw_actor_imgexp(actor, 4, y + WLH * 2 + 6)
  152.       draw_actor_imghpmp(actor, 100, y + WLH * 2)
  153.     end
  154.   end
  155.  
  156.   def draw_actor_imgexp(actor, x, y)
  157.     draw_pic("hud_leafexp", x, y)
  158.     if actor.exp_max != 0
  159.       draw_pic("imgbar_exp", x + 3, y + 3, 101 * actor.exp_til / actor.exp_max)
  160.     else
  161.       draw_pic("imgbar_exp", x + 3, y + 3, 101) if actor.level == 99
  162.     end
  163.   end
  164.  
  165.   def draw_actor_imghpmp(actor, x, y)
  166.     draw_pic("hud_leaf", x, y)
  167.     draw_pic("imgbar_hp", x + 3, y + 3, 101 * actor.hp / actor.maxhp)
  168.     draw_pic("imgbar_mp", x + 3, y +15, 101 * actor.mp / actor.maxmp)
  169.     draw_img_text(actor.maxhp, x + 104, y + 3, spacing = 1, allign = 1)
  170.     draw_img_text("/", x + 60, y + 3)
  171.     draw_img_text(actor.hp, x + 59, y + 3, spacing = 1, allign = 1)
  172.     draw_img_text(actor.maxmp, x + 104, y + 15, spacing = 1, allign = 1)
  173.     draw_img_text("/", x + 60, y + 15)
  174.     draw_img_text(actor.mp, x + 59, y + 15, spacing = 1, allign = 1)
  175.   end
  176.  
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement