IceDragon200

ICY-BitmapXtended V1.0

Jun 2nd, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 35.84 KB | None | 0 0
  1. #==============================================================================#
  2. # ** ICY-CORE - Bitmap Extended
  3. #------------------------------------------------------------------------------#
  4. # ** Created by    : IceDragon (http://www.rpgmakervx.net/)
  5. # ** Version       : 1.0
  6. # ** Date Modified : 04/21/2011
  7. #------------------------------------------------------------------------------#
  8. #  03/31/2011 Changed from WindowBase Extended to Bitmap Extended
  9. #==============================================================================#
  10. $imported = {} if $imported == nil
  11. $imported["ICY_WindowBase_Xtended"] = true
  12. $imported["ICY_Bitmap_Xtended"] = true
  13.  
  14. #==============================================================================#
  15. # BitmapXTended
  16. #==============================================================================#
  17. module BitmapXtended
  18. # // Redefine - This part is made to rewrite some of the core methods  
  19.   #--------------------------------------------------------------------------#
  20.   # * Constants
  21.   #--------------------------------------------------------------------------#
  22.   WLH       = Window_Base::WLH
  23.   CRISIS_HP = 15
  24.   CRISIS_MP = 15
  25.  
  26.   BMP_XTND_MODULE_INCL = %Q(
  27.   unless $imported["CoreFixesUpgradesMelody"]
  28.     # The following hash allows you to change the text colour values used for
  29.     # various common interface
  30.     S_COLORS ={
  31.     # Used For   => Colour ID
  32.       :normal    =>  0,  # Normal text colour.
  33.       :system    => 16,  # System use. Namely vocab.
  34.       :crisis    => 17,  # Low HP colour.
  35.       :lowmp     => 17,  # Low MP colour.
  36.       :knockout  => 18,  # Knocked out text colour.
  37.       :gaugeback => 19,  # Generic gauge back.
  38.       :exhaust   =>  7,  # Exhausted HP and MP bars.
  39.       :hp_back   => 19,  # HP gauge back.
  40.       :hp_gauge1 => 20,  # HP gradient no 1.
  41.       :hp_gauge2 => 21,  # HP gradient no 2.
  42.       :mp_back   => 19,  # MP gauge back.
  43.       :mp_gauge1 => 22,  # MP gradient no 1.
  44.       :mp_gauge2 => 23,  # MP gradient no 2.
  45.       :power_up  => 24,  # Boosted stat colour.
  46.       :power_dn  => 25,  # Nerfed stat colour.
  47.     } # Do not remove.
  48.   else
  49.     S_COLORS = YEM::UPGRADE::COLOURS
  50.   end  
  51.  
  52.   #--------------------------------------------------------------------------#
  53.   # * new method :drawing_bitmap
  54.   #--------------------------------------------------------------------------#    
  55.   def drawing_bitmap ; return Bitmap.new(32, 32)   end
  56.    
  57.   #--------------------------------------------------------------------------#
  58.   # * new method :pallete_bitmap
  59.   #--------------------------------------------------------------------------#    
  60.   def pallete_bitmap ; return Bitmap.new(128, 128) end
  61.    
  62.   #--------------------------------------------------------------------------#
  63.   # * Get Text Color
  64.   #     n : Text color number  (0-31)
  65.   #--------------------------------------------------------------------------#
  66.   def text_color(n)
  67.     x = 64 + (n % 8) * 8
  68.     y = 96 + (n / 8) * 8
  69.     return pallete_bitmap.get_pixel(x, y)
  70.   end
  71.  
  72.   #--------------------------------------------------------------------------#
  73.   # * overwrite methods :*_colors
  74.   #--------------------------------------------------------------------------#
  75.   def normal_color()    ; return text_color(S_COLORS[:normal]);    end
  76.   def system_color()    ; return text_color(S_COLORS[:system]);    end
  77.   def crisis_color()    ; return text_color(S_COLORS[:crisis]);    end
  78.   def lowmp_color()     ; return text_color(S_COLORS[:lowmp]);     end
  79.   def knockout_color()  ; return text_color(S_COLORS[:knockout]);  end
  80.   def gauge_back_color(); return text_color(S_COLORS[:gaugeback]); end
  81.   def exhaust_color()   ; return text_color(S_COLORS[:exhaust]);   end
  82.   def hp_back_color()   ; return text_color(S_COLORS[:hp_back]);   end
  83.   def hp_gauge_color1() ; return text_color(S_COLORS[:hp_gauge1]); end
  84.   def hp_gauge_color2() ; return text_color(S_COLORS[:hp_gauge2]); end
  85.   def mp_back_color()   ; return text_color(S_COLORS[:mp_back]);   end
  86.   def mp_gauge_color1() ; return text_color(S_COLORS[:mp_gauge1]); end
  87.   def mp_gauge_color2() ; return text_color(S_COLORS[:mp_gauge2]); end
  88.   def power_up_color()  ; return text_color(S_COLORS[:power_up]);  end
  89.   def power_down_color(); return text_color(S_COLORS[:power_dn]);  end
  90.    
  91.   #--------------------------------------------------------------------------#
  92.   # * overwrite method :hp_color
  93.   #--------------------------------------------------------------------------#
  94.   def hp_color( actor )
  95.     return knockout_color if actor.hp == 0
  96.     return crisis_color if actor.hp < ( actor.maxhp*CRISIS_HP/100 )
  97.     return normal_color
  98.   end
  99.  
  100.   #--------------------------------------------------------------------------#
  101.   # * overwrite method :mp_color
  102.   #--------------------------------------------------------------------------#
  103.   def mp_color( actor )
  104.     return lowmp_color if actor.mp < ( actor.maxmp*CRISIS_MP/100 )
  105.     return normal_color
  106.   end
  107.  
  108.   #--------------------------------------------------------------------------#
  109.   # * Draw Icon
  110.   #     icon_index : Icon number
  111.   #     x     : draw spot x-coordinate
  112.   #     y     : draw spot y-coordinate
  113.   #     enabled    : Enabled flag. When false, draw semi-transparently.
  114.   #--------------------------------------------------------------------------#
  115.   def draw_icon(icon_index, x, y, enabled = true)
  116.     bitmap = Cache.system("Iconset")
  117.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  118.     drawing_bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  119.   end
  120.  
  121. # // End Redefine  
  122.   #--------------------------------------------------------------------------#
  123.   # * Draw Actor Sprite = This a X, Y accurate version of the draw_actor_graphic
  124.   #   actor   : actor
  125.   #     x     : draw spot x-coordinate
  126.   #     y     : draw spot y-coordinate
  127.   #   enabled : half opacity?
  128.   #--------------------------------------------------------------------------#
  129.   def draw_actor_sprite(actor, x, y, enabled = true)
  130.     character_name = actor.character_name
  131.     character_index = actor.character_index
  132.     return if character_name == nil
  133.     bitmap = Cache.character(character_name)
  134.     sign = character_name[/^[\!\$]./]
  135.     if sign != nil and sign.include?('$')
  136.       cw = bitmap.width / 3
  137.       ch = bitmap.height / 4
  138.     else
  139.       cw = bitmap.width / 12
  140.       ch = bitmap.height / 8
  141.     end
  142.     n = character_index
  143.     trim_bitmap = Bitmap.new(cw, ch)
  144.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  145.     trim_bitmap.blt(0, 0, bitmap, src_rect)
  146.     dy = y - (ch - 32)
  147.     dx = x - (cw - 32)
  148.     drawing_bitmap.blt(dx, dy, trim_bitmap, trim_bitmap.rect, enabled ? 255 : 128)
  149.   end
  150.  
  151.   #--------------------------------------------------------------------------#
  152.   # * Draw Format Text
  153.   #     x     : draw spot x-coordinate
  154.   #     y     : draw spot y-coordinate
  155.   #    width  : draw_text width
  156.   #    height : draw_text height
  157.   #     text  : draw_text
  158.   #    align  : draw_text align
  159.   #    font   : font size
  160.   #    color  : text color
  161.   #   enabled : half opacity?
  162.   #--------------------------------------------------------------------------#
  163.   # x, y, width, height, text, align, font, color, enabled
  164.   # rect, text, align, font, color, enabled
  165.   #--------------------------------------------------------------------------#
  166.   def draw_format_text(*args)
  167.     # ------------------------------------------------------------------------ #
  168.     pos = 0
  169.     pasn = *args ; if pasn[pos].is_a?(Rect)
  170.       rect = pasn[pos]
  171.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  172.       pos = 1
  173.     else
  174.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  175.       pos = 4
  176.     end  
  177.     text    = pasn[pos] ; pos += 1 ; align = pasn[pos].nil? ? 0 : pasn[pos]
  178.     pos     += 1         ; df = Font.default_size
  179.     font    = pasn[pos].nil? ? df : pasn[pos] ; pos += 1  
  180.     color   = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  181.     enabled = pasn[pos].nil? ? true : pasn[pos]
  182.     # ------------------------------------------------------------------------ #
  183.     old_font_color = drawing_bitmap.font.color
  184.     old_font_size  = drawing_bitmap.font.size
  185.     drawing_bitmap.font.color = color
  186.     drawing_bitmap.font.color.alpha = enabled ? 255 : 128
  187.     drawing_bitmap.font.size = font
  188.     drawing_bitmap.draw_text(x, y, width, height, text, align)
  189.     drawing_bitmap.font.color = old_font_color
  190.     drawing_bitmap.font.size = old_font_size
  191.   end
  192.   #--------------------------------------------------------------------------#
  193.   # * Draw Icon Format Text
  194.   #     x     : draw spot x-coordinate
  195.   #     y     : draw spot y-coordinate
  196.   #    width  : draw_text width
  197.   #    height : draw_text height
  198.   #     text  : draw_text
  199.   #     icon  : draw_icon
  200.   #    align  : draw_text align
  201.   #    font   : font size
  202.   #    color  : text color
  203.   #   enabled : half opacity?
  204.   #--------------------------------------------------------------------------#    
  205.   # x, y, width, height, text, icon, align, font, color, enabled
  206.   # rect, text, icon, align, font, color, enabled
  207.   #--------------------------------------------------------------------------#
  208.   def draw_icon_format_text(*args)
  209.     # ------------------------------------------------------------------------ #
  210.     pos = 0
  211.     pasn = *args ; if pasn[pos].is_a?(Rect)
  212.       rect = pasn[pos]
  213.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  214.       pos = 1
  215.     else
  216.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  217.       pos = 4
  218.     end  
  219.     text    = pasn[pos] ; pos += 1 ; icon = pasn[pos] ; pos += 1
  220.     align   = pasn[pos].nil? ? 0 : pasn[pos]
  221.     pos     += 1         ; df = Font.default_size
  222.     font    = pasn[pos].nil? ? df : pasn[pos] ; pos += 1  
  223.     color   = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  224.     enabled = pasn[pos].nil? ? true : pasn[pos]
  225.     # ------------------------------------------------------------------------ #
  226.     off_set = 0
  227.     if icon != nil
  228.       draw_icon(icon, x, y) if outlined == false
  229.       draw_outlined_icon(icon, x, y, 32, 32, 4) if outlined
  230.       off_set = 32
  231.     end    
  232.     draw_format_text(x + off_set, y, width, height, text, align, font, color, enabled)
  233.   end
  234.  
  235.   #--------------------------------------------------------------------------#
  236.   # * Draw Filled Rect
  237.   #     x     : draw spot x-coordinate
  238.   #     y     : draw spot y-coordinate
  239.   #    width  : Rect width
  240.   #    height : Rect height
  241.   #    color  : Rect Color
  242.   #   enabled : half opacity?
  243.   #--------------------------------------------------------------------------#
  244.   # x, y, width, height, border, color, enabled
  245.   # rect, border, color, enabled
  246.   #--------------------------------------------------------------------------#
  247.   def draw_filled_rect(*args)
  248.     # ------------------------------------------------------------------------ #
  249.     pos = 0
  250.     pasn = *args ; if pasn[pos].is_a?(Rect)
  251.       rect = pasn[pos]
  252.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  253.       pos = 1
  254.     else
  255.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  256.       pos = 4
  257.     end  
  258.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  259.     enabled = pasn[pos].nil? ? true : pasn[pos]
  260.     # ------------------------------------------------------------------------ #
  261.     outline = Rect.new(0, 0, width, height)
  262.     outline_sprite = Bitmap.new(outline.width, outline.height)
  263.     outline_sprite.fill_rect(outline, color)
  264.     drawing_bitmap.blt(x, y, outline_sprite, outline, enabled ? 255 : 128)
  265.   end
  266.  
  267.   #--------------------------------------------------------------------------#
  268.   # * Draw Border Rect
  269.   #     x     : draw spot x-coordinate
  270.   #     y     : draw spot y-coordinate
  271.   #    width  : Rect width
  272.   #    height : Rect height
  273.   #    border : Border Size
  274.   #    color  : Rect Color
  275.   #   enabled : half opacity?
  276.   #--------------------------------------------------------------------------#  
  277.   # x, y, width, height, border, color, enabled
  278.   # rect, border, color, enabled
  279.   #--------------------------------------------------------------------------#
  280.   def draw_border_rect(*args)
  281.     # ------------------------------------------------------------------------ #
  282.     pos = 0
  283.     pasn = *args ; if pasn[pos].is_a?(Rect)
  284.       rect = pasn[pos]
  285.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  286.       pos = 1
  287.     else
  288.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  289.       pos = 4
  290.     end  
  291.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  292.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  293.     enabled = pasn[pos].nil? ? true : pasn[pos]
  294.     # ------------------------------------------------------------------------ #
  295.     outline = Rect.new(0, 0, width, height)
  296.     sub_rect = Rect.new((border / 2), (border / 2), (outline.width - border), (outline.height - border))
  297.     outline_sprite = Bitmap.new(outline.width, outline.height)
  298.     outline_sprite.fill_rect(outline, color)
  299.     outline_sprite.clear_rect(sub_rect)
  300.     drawing_bitmap.blt(x, y, outline_sprite, outline, enabled ? 255 : 128)
  301.   end
  302.  
  303.   #--------------------------------------------------------------------------
  304.   # * Draw Filled Border Rect
  305.   #     x     : draw spot x-coordinate
  306.   #     y     : draw spot y-coordinate
  307.   #    width  : Rect width
  308.   #    height : Rect height
  309.   #    border : Border Size
  310.   #    color1 : Fill Color
  311.   #    color2 : Border Color
  312.   #   enabled : half opacity?
  313.   #--------------------------------------------------------------------------
  314.   # x, y, width, height, border, color1, color2, enabled
  315.   # rect, border, color1, color2, enabled
  316.   #--------------------------------------------------------------------------
  317.   def draw_fill_border_rect(*args)
  318.     # ------------------------------------------------------------------------ #
  319.     pos = 0
  320.     pasn = *args ; if pasn[pos].is_a?(Rect)
  321.       rect = pasn[pos]
  322.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  323.       pos = 1
  324.     else
  325.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  326.       pos = 4
  327.     end  
  328.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  329.     color1  = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  330.     color2  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  331.     enabled = pasn[pos].nil? ? true : pasn[pos]
  332.     # ------------------------------------------------------------------------ #
  333.     border_halv = border / 2
  334.     draw_border_rect(x, y, width, height, border, color2, enabled)
  335.     draw_filled_rect(x + border_halv, y + border_halv, width - border, height - border, color1, enabled)
  336.   end
  337.  
  338.   #--------------------------------------------------------------------------
  339.   # * Draw Outlined Icon
  340.   # icon_index: Icon Index
  341.   #     x     : draw spot x-coordinate
  342.   #     y     : draw spot y-coordinate
  343.   #    width  : Rect width
  344.   #    height : Rect height
  345.   #    border : Border Size
  346.   #    color  : Rect Color
  347.   #   enabled : half opacity?
  348.   #--------------------------------------------------------------------------  
  349.   # icon_index, x, y, width, height, border, color, enabled
  350.   # icon_index, rect, border, color, enabled
  351.   #--------------------------------------------------------------------------
  352.   def draw_outlined_icon(*args)
  353.     # ------------------------------------------------------------------------ #
  354.     pos = 0
  355.     pasn = *args ; icon_index = pasn[pos] ; pos += 1
  356.     if pasn[pos].is_a?(Rect)
  357.       rect = pasn[pos]
  358.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  359.       pos += 1
  360.     else
  361.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  362.       pos += 4
  363.     end  
  364.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  365.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  366.     enabled = pasn[pos].nil? ? true : pasn[pos]
  367.     # ------------------------------------------------------------------------ #
  368.     draw_border_rect(x, y, width, height, border, color, enabled)
  369.     draw_icon(icon_index, x + ((width - 24) / 2), y + ((height - 24) / 2), enabled = true)
  370.   end
  371.  
  372.   #--------------------------------------------------------------------------
  373.   # * Draw Outlined Item
  374.   #    item   : Item
  375.   #     x     : draw spot x-coordinate
  376.   #     y     : draw spot y-coordinate
  377.   #    width  : Rect width
  378.   #    height : Rect height
  379.   #    border : Border Size
  380.   #    color  : Rect Color
  381.   #   enabled : half opacity?
  382.   #--------------------------------------------------------------------------  
  383.   # item, x, y, width, height, border, color, enabled
  384.   # item, rect, border, color, enabled
  385.   #--------------------------------------------------------------------------
  386.   def draw_outlined_item(*args)
  387.     # ------------------------------------------------------------------------ #
  388.     pos = 0
  389.     pasn = *args ; item = pasn[pos] ; pos += 1
  390.     if pasn[pos].is_a?(Rect)
  391.       rect = pasn[pos]
  392.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  393.       pos += 1
  394.     else
  395.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  396.       pos += 4
  397.     end  
  398.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  399.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  400.     enabled = pasn[pos].nil? ? true : pasn[pos]
  401.     # ------------------------------------------------------------------------ #
  402.     draw_outlined_icon(item.icon_index, x, y, width, height, border, color, enabled = true)
  403.   end
  404.  
  405.   #--------------------------------------------------------------------------
  406.   # * Draw Outlined Actor
  407.   #    actor  : actor
  408.   #     x     : draw spot x-coordinate
  409.   #     y     : draw spot y-coordinate
  410.   #    width  : Rect width
  411.   #    height : Rect height
  412.   #    border : Border Size
  413.   #    color  : Rect Color
  414.   #   enabled : half opacity?
  415.   #--------------------------------------------------------------------------  
  416.   # actor, x, y, width, height, border, color, enabled
  417.   # actor, rect, border, color, enabled
  418.   #--------------------------------------------------------------------------
  419.   def draw_outlined_actor(*args)
  420.     # ------------------------------------------------------------------------ #
  421.     pos = 0
  422.     pasn = *args ; actor = pasn[pos] ; pos += 1
  423.     if pasn[pos].is_a?(Rect)
  424.       rect = pasn[pos]
  425.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  426.       pos += 1
  427.     else
  428.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  429.       pos += 4
  430.     end  
  431.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  432.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  433.     enabled = pasn[pos].nil? ? true : pasn[pos]
  434.     # ------------------------------------------------------------------------ #
  435.     draw_border_rect(x, y, width, height, border, color)
  436.     draw_actor_sprite(actor, x + ((width - 32) / 2), y + ((height - 32) / 2), enabled = true)
  437.   end
  438.    
  439.   #--------------------------------------------------------------------------
  440.   # * Draw Horizontal Gradation Bar
  441.   #     x     : draw spot x-coordinate
  442.   #     y     : draw spot y-coordinate
  443.   #    width  : Rect width
  444.   #    height : Rect height
  445.   #    value  : Value of Bar - Always forced to positive
  446.   #    max    : Max value of Bar - Always forced to positive
  447.   #    color1 : Bar Color1
  448.   #    color2 : Bar Color2
  449.   #    color3 : Border Color
  450.   #    border : Border Size
  451.   #   enabled : half opacity?
  452.   #--------------------------------------------------------------------------
  453.   # x, y, width, height, value, max, color1, color2, color3, border, enabled
  454.   # rect, value, max, color1, color2, color3, border, enabled
  455.   #--------------------------------------------------------------------------
  456.   def draw_horizontal_grad_bar(*args) ; draw_grad_bar(*args) end
  457.   def draw_grad_bar(*args)
  458.     # ------------------------------------------------------------------------ #
  459.     pos = 0
  460.     pasn = *args ; if pasn[pos].is_a?(Rect)
  461.       rect = pasn[pos]
  462.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  463.       pos = 1
  464.     else
  465.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  466.       pos = 4
  467.     end  
  468.     grey = Color.new(20, 20, 20)
  469.     value   = pasn[pos].abs                        ; pos += 1
  470.     max     = pasn[pos].abs                        ; pos += 1
  471.     color1  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  472.     color2  = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  473.     color3  = pasn[pos].nil? ? grey         : pasn[pos] ; pos += 1
  474.     border  = pasn[pos].nil? ? 4            : pasn[pos] ; pos += 1
  475.     enabled = pasn[pos].nil? ? true         : pasn[pos]
  476.     # ------------------------------------------------------------------------ #
  477.     bb = border * 2 #4
  478.     hb = bb / 2
  479.     draw_border_rect(x, y, width, height, border, color3, enabled)
  480.     barwidth = (width - bb) * value / max
  481.     unless enabled
  482.       color1.alpha = 128
  483.       color2.alpha = 128
  484.     end  
  485.     drawing_bitmap.gradient_fill_rect(x+hb, y+hb, barwidth, height-bb, color1, color2)
  486.   end
  487.  
  488.   #--------------------------------------------------------------------------
  489.   # * Draw Vertical Gradation Bar
  490.   #     x     : draw spot x-coordinate
  491.   #     y     : draw spot y-coordinate
  492.   #    width  : Rect width
  493.   #    height : Rect height
  494.   #    value  : Value of Bar - Always forced to positive
  495.   #    max    : Max value of Bar - Always forced to positive
  496.   #    color1 : Bar Color1
  497.   #    color2 : Bar Color2
  498.   #    color3 : Border Color
  499.   #    border : Border Size
  500.   #    invert : Bar Drawn in reverse
  501.   #   enabled : half opacity?
  502.   #--------------------------------------------------------------------------
  503.   # x, y, width, height, value, max, color1, color2, color3, border, invert, enabled
  504.   # rect, value, max, color1, color2, color3, border, invert, enabled
  505.   #--------------------------------------------------------------------------
  506.   def draw_vertical_grad_bar(*args)
  507.     # ------------------------------------------------------------------------ #
  508.     pos = 0
  509.     pasn = *args ; if pasn[pos].is_a?(Rect)
  510.       rect = pasn[pos]
  511.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  512.       pos = 1
  513.     else
  514.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  515.       pos = 4
  516.     end  
  517.     grey = Color.new(20, 20, 20)
  518.     value   = pasn[pos]                             ; pos += 1
  519.     max     = pasn[pos]                             ; pos += 1
  520.     color1  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  521.     color2  = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  522.     color3  = pasn[pos].nil? ? grey         : pasn[pos] ; pos += 1
  523.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  524.     invert  = pasn[pos].nil? ? true : pasn[pos]         ; pos += 1
  525.     enabled = pasn[pos].nil? ? true : pasn[pos]
  526.     # ------------------------------------------------------------------------ #    
  527.     bb = border * 2 #4
  528.     hb = bb / 2
  529.     draw_border_rect(x, y, width, height, 2, color3, enabled)
  530.     barheight = (height - bb) * value / max
  531.     if invert
  532.       y += (height - bb) - barheight
  533.       colorx = color1.clone
  534.       color1 = color2.clone
  535.       color2 = colorx.clone
  536.       colorx = nil
  537.     end  
  538.     drawing_bitmap.gradient_fill_rect(x+hb, y+hb, width-bb, barheight, color1, color2, enabled)
  539.   end
  540.  
  541.   #--------------------------------------------------------------------------
  542.   # * Draw Vertical Gradation Bar 2 # (Solid Undercolor)
  543.   #     x     : draw spot x-coordinate
  544.   #     y     : draw spot y-coordinate
  545.   #    width  : Rect width
  546.   #    height : Rect height
  547.   #    value  : Value of Bar - Always forced to positive
  548.   #    max    : Max value of Bar - Always forced to positive
  549.   #    color1 : Bar Color1
  550.   #    color2 : Bar Color2
  551.   #    color3 : Border Color
  552.   #    border : Border Size
  553.   #    invert : Bar Drawn in reverse
  554.   #   enabled : half opacity?
  555.   #--------------------------------------------------------------------------
  556.   # x, y, width, height, value, max, color1, color2, color3, border, invert, enabled
  557.   # rect, value, max, color1, color2, color3, border, invert, enabled
  558.   #--------------------------------------------------------------------------
  559.   def draw_vertical_grad_bar2(*args)
  560.     # ------------------------------------------------------------------------ #
  561.     pos = 0
  562.     pasn = *args ; if pasn[pos].is_a?(Rect)
  563.       rect = pasn[pos]
  564.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  565.       pos = 1
  566.     else
  567.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  568.       pos = 4
  569.     end  
  570.     grey = Color.new(20, 20, 20)
  571.     value   = pasn[pos]                             ; pos += 1
  572.     max     = pasn[pos]                             ; pos += 1
  573.     color1  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  574.     color2  = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  575.     color3  = pasn[pos].nil? ? grey         : pasn[pos] ; pos += 1
  576.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  577.     invert  = pasn[pos].nil? ? true : pasn[pos]         ; pos += 1
  578.     enabled = pasn[pos].nil? ? true : pasn[pos]
  579.     # ------------------------------------------------------------------------ #
  580.     bb = border * 2 #4
  581.     hb = bb / 2
  582.     drawing_bitmap.fill_rect(x, y, width, height, color3)
  583.     barheight = (height - bb) * value / max
  584.     if invert
  585.       y += (height - bb) - barheight
  586.       colorx = color1.clone
  587.       color1 = color2.clone
  588.       color2 = colorx.clone
  589.       colorx = nil
  590.     end  
  591.     drawing_bitmap.gradient_fill_rect(x+hb, y+hb, width-bb, barheight, color1, color2, enabled)
  592.   end
  593.  
  594.   #--------------------------------------------------------------------------
  595.   # * Draw Round Gradation Bar
  596.   #     x     : draw spot x-coordinate
  597.   #     y     : draw spot y-coordinate
  598.   #    width  : Rect width
  599.   #    height : Rect height
  600.   #    value  : Value of Bar - Always forced to positive
  601.   #    max    : Max value of Bar - Always forced to positive
  602.   #    color1 : Bar Color1
  603.   #    color2 : Bar Color2
  604.   #    color3 : Border Color
  605.   #    border : Border Size
  606.   #   enabled : half opacity?
  607.   #--------------------------------------------------------------------------
  608.   # x, y, width, height, value, max, color1, color2, color3, border, enabled
  609.   # rect, value, max, color1, color2, color3, border, enabled
  610.   #--------------------------------------------------------------------------
  611.   def draw_round_grad_bar(*args)
  612.     # ------------------------------------------------------------------------ #
  613.     pos = 0
  614.     pasn = *args ; if pasn[pos].is_a?(Rect)
  615.       rect = pasn[pos]
  616.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  617.       pos = 1
  618.     else
  619.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  620.       pos = 4
  621.     end  
  622.     grey = Color.new(20, 20, 20)
  623.     value   = pasn[pos].abs                        ; pos += 1
  624.     max     = pasn[pos].abs                        ; pos += 1
  625.     color1  = pasn[pos].nil? ? grey         : pasn[pos] ; pos += 1
  626.     color2  = pasn[pos].nil? ? grey         : pasn[pos] ; pos += 1
  627.     color3  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  628.     border  = pasn[pos].nil? ? 4            : pasn[pos] ; pos += 1
  629.     enabled = pasn[pos].nil? ? true         : pasn[pos]
  630.     # ------------------------------------------------------------------------ #
  631.     bb = 2#border * 2 #4
  632.     hb = 1
  633.     #hb = bb / 2
  634.     draw_border_rect(x, y, width, height, border, color3, enabled)
  635.     barwidth = (width - bb) * value / max
  636.     unless enabled
  637.       color1.alpha = 128
  638.       color2.alpha = 128
  639.     end  
  640.     drawing_bitmap.gradient_fill_rect(x+hb, y+hb, barwidth, height-bb, color1, color2)
  641.     drawing_bitmap.clear_rect(x, y, 1, 1)
  642.     drawing_bitmap.clear_rect(x+width-1, y, 1, 1)
  643.     drawing_bitmap.clear_rect(x, y+height-1, 1, 1)
  644.     drawing_bitmap.clear_rect(x+width-1, y+height-1, 1, 1)
  645.   end
  646.  
  647.   # // ----------------------------------------------------------------------
  648.   #--------------------------------------------------------------------------
  649.   # * Draw Jagged Rect
  650.   #     x     : draw spot x-coordinate
  651.   #     y     : draw spot y-coordinate
  652.   #    width  : Rect width
  653.   #    height : Rect height
  654.   #     spac  : Spacing
  655.   #    border : Border Size
  656.   #    color  : Border Color
  657.   #    color2 : Jagged Color
  658.   #   enabled : half opacity?
  659.   #--------------------------------------------------------------------------
  660.   def draw_jagged_rect(*args)
  661.     # ------------------------------------------------------------------------ #
  662.     pos = 0
  663.     pasn = *args ; if pasn[pos].is_a?(Rect)
  664.       rect = pasn[pos]
  665.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  666.       pos = 1
  667.     else
  668.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  669.       pos = 4
  670.     end  
  671.     spac    = pasn[pos].nil? ? 2 : pasn[pos]            ; pos += 1
  672.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  673.     color   = pasn[pos].nil? ? system_color : pasn[pos] ; pos += 1
  674.     color2  = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  675.     enabled = pasn[pos].nil? ? true : pasn[pos]
  676.     # ------------------------------------------------------------------------ #
  677.     draw_border_rect(x, y, width, height, border, color, enabled = true)
  678.     draw_dotted_rect(x, y, width, height, spac, border, color2, enabled = true)
  679.     border_halv = border / 2
  680.     bitmap_bite_out(x + border_halv, y + border_halv, width - border, height - border)
  681.   end
  682.  
  683.   #--------------------------------------------------------------------------
  684.   # * Draw Dotted Rect
  685.   #     x     : draw spot x-coordinate
  686.   #     y     : draw spot y-coordinate
  687.   #    width  : Rect width
  688.   #    height : Rect height
  689.   #     spac  : Spacing
  690.   #    border : Border Size
  691.   #    color  : Jagged Color
  692.   #   enabled : half opacity?
  693.   #--------------------------------------------------------------------------
  694.   def draw_dotted_rect(*args)
  695.     # ------------------------------------------------------------------------ #
  696.     pos = 0
  697.     pasn = *args ; if pasn[pos].is_a?(Rect)
  698.       rect = pasn[pos]
  699.       x, y, width, height = rect.x, rect.y, rect.width, rect.height
  700.       pos = 1
  701.     else
  702.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  703.       pos = 4
  704.     end  
  705.     spac    = pasn[pos].nil? ? 2 : pasn[pos]            ; pos += 1
  706.     border  = pasn[pos].nil? ? 4 : pasn[pos]            ; pos += 1
  707.     color   = pasn[pos].nil? ? normal_color : pasn[pos] ; pos += 1
  708.     enabled = pasn[pos].nil? ? true : pasn[pos]
  709.     # ------------------------------------------------------------------------ #
  710.     color.alpha = enabled ? 255 : 128
  711.     border_hal = border / 2
  712.     restx = x - border_hal ; resty = y - border_hal
  713.     spotx = restx ; spoty = resty
  714.     coun = 0
  715.     max_spotter = (width / spac) + border_hal
  716.     aew = width + border_hal
  717.     aeh = height + border_hal
  718.     ae = aew * aeh
  719.     for i in 0..ae
  720.       drawing_bitmap.set_pixel(spotx, spoty, color)
  721.       spotx += spac
  722.       coun += 1
  723.       if coun == max_spotter
  724.         coun = 0
  725.         spotx = restx
  726.         spoty += spac
  727.       end
  728.       break if spoty > height
  729.     end  
  730.   end
  731.  
  732.   #--------------------------------------------------------------------------
  733.   # * Draw Jagged Rect
  734.   #     x     : draw spot x-coordinate
  735.   #     y     : draw spot y-coordinate
  736.   #    width  : Rect width
  737.   #    height : Rect height
  738.   #--------------------------------------------------------------------------
  739.   def bitmap_bite_out(*args)
  740.     pos = 0
  741.     pasn = *args
  742.     if pasn.is_a?(Rect)
  743.       x, y, width, height = pasn[pos].x, pasn[pos].y, pasn[pos].width, pasn[pos].height
  744.     else
  745.       x, y, width, height = pasn[pos], pasn[pos+1], pasn[pos+2], pasn[pos+3]
  746.     end  
  747.     bite = Rect.new(x, y, width, height)
  748.     drawing_bitmap.clear_rect(bite)
  749.   end
  750.  
  751.   def draw_short_hp(actor, x, y, width = 64, bar=true)
  752.     draw_actor_hp_gauge(actor, x, y, width) if bar
  753.     drawing_bitmap.draw_text(x, y, width, WLH, Vocab.hp, 0)
  754.     drawing_bitmap.draw_text(x, y, width, WLH, actor.hp, 2)
  755.   end
  756.    
  757.   def draw_short_mp(actor, x, y, width = 64, bar=true)
  758.     draw_actor_mp_gauge(actor, x, y, width) if bar
  759.     drawing_bitmap.draw_text(x, y, width, WLH, Vocab.mp, 0)
  760.     drawing_bitmap.draw_text(x, y, width, WLH, actor.mp, 2)
  761.   end
  762.    
  763.   def draw_command_icon_box(x, y, commandi, icon_index, boxsize = 32, border = 4, color = system_color, enabled = true)
  764.     draw_border_rect(x, y, boxsize, boxsize, border, color)
  765.     draw_icon(icon_index, x + ((boxsize - 24) / 2), y + ((boxsize - 24) / 3), enabled)
  766.     draw_format_text(x, y + (boxsize - 24), boxsize, 16, commandi, 1, 16)
  767.   end
  768.    
  769.   def draw_command_actor_box(x, y, commandi, actor, boxsize = 32, border = 4, color = system_color, enabled = true)
  770.     draw_border_rect(x, y, boxsize, boxsize, border, color)
  771.     draw_actor_sprite(actor, x + ((boxsize - 32) / 2), y + ((boxsize - 32) / 3), enabled)
  772.     draw_format_text(x, y + (boxsize - 24), boxsize, 16, commandi, 1, 16)
  773.   end
  774.    
  775.   def draw_text_fraction_style(x, y, text1, text2, enabled = true)
  776.     old_font_color = drawing_bitmap.font.color
  777.     old_font_size = drawing_bitmap.font.size
  778.     drawing_bitmap.font.color = normal_color
  779.     drawing_bitmap.font.color.alpha = enabled ? 255 : 128
  780.     drawing_bitmap.font.size = 14
  781.     drawing_bitmap.draw_text(x - 8, y - 4, 32, WLH, text1)
  782.     drawing_bitmap.font.size = 18
  783.     drawing_bitmap.draw_text(x + 8, y + 4, 32, WLH, "/")
  784.     drawing_bitmap.font.size = 14
  785.     drawing_bitmap.draw_text(x + 16, y + 8, 32, WLH, text2)
  786.     drawing_bitmap.font.color = old_font_color
  787.     drawing_bitmap.font.size = old_font_size
  788.   end
  789.  
  790.   #--------------------------------------------------------------------------
  791.   # * Draw Extended Parameter
  792.   #    actor  : actor
  793.   #     x     : draw spot x-coordinate
  794.   #     y     : draw spot y-coordinate
  795.   #    type   : type_of stat
  796.   #--------------------------------------------------------------------------
  797.   def draw_extended_actor_parameter(actor, x, y, type)
  798.     case type
  799.     when 0
  800.       icon = 1
  801.     when 1
  802.       icon = 53
  803.     when 2
  804.       icon = 20
  805.     when 3
  806.       icon = 137
  807.     end
  808.     draw_icon(icon, x, y)
  809.     draw_actor_parameter(actor, x + 32, y, type)
  810.   end
  811.  
  812.   def draw_all_actor_parameters(actor, x, y)
  813.     for i in 0..3
  814.       draw_extended_actor_parameter(actor, x, y, i)
  815.       y += 32
  816.     end
  817.   end
  818. )  
  819. end
  820.  
  821. #==============================================================================#
  822. # Bitmap
  823. #==============================================================================#
  824. class Bitmap
  825.  
  826.   include BitmapXtended
  827.   module_eval( BMP_XTND_MODULE_INCL )
  828.  
  829.   def drawing_bitmap ; return self                   end
  830.   def pallete_bitmap ; return Cache.system("Window") end
  831.    
  832. end
  833.  
  834. #==============================================================================#
  835. # Sprite
  836. #==============================================================================#
  837. class Sprite
  838.  
  839.   include BitmapXtended
  840.   module_eval( BMP_XTND_MODULE_INCL )
  841.  
  842.   def drawing_bitmap ; return self.bitmap            end
  843.   def pallete_bitmap ; return Cache.system("Window") end
  844.    
  845. end  
  846.  
  847. #==============================================================================#
  848. # Window_Base
  849. #==============================================================================#
  850. class Window_Base < Window
  851.  
  852.   include BitmapXtended
  853.   module_eval( BMP_XTND_MODULE_INCL )
  854.  
  855.   def drawing_bitmap ; return self.contents end
  856.   def pallete_bitmap ; return windowskin    end
  857.  
  858. end  
  859.  
  860. #=*==========================================================================*=#
  861. # ** END OF FILE
  862. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment