PHP код:
class Window_EquipLeft < Window_Base
# --------------------------------
attr_accessor :mode
attr_accessor :changes
# --------------------------------
def initialize(actor)
super(0, 64, 272, 192)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 100
@actor = actor
@mode = 0
@changes = [0, 0, 0, 0, 0, 0, 0, 0]
@elem_text = ""
@stat_text = ""
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 180, 0)
draw_actor_parameter(@actor, 4, 32, 0)
draw_actor_parameter(@actor, 4, 64, 1)
draw_actor_parameter(@actor, 4, 96, 2)
draw_actor_parameter(@actor, 4, 128, 3)
draw_actor_parameter(@actor, 4, 160, 4)
draw_actor_parameter(@actor, 4, 192, 5)
draw_actor_parameter(@actor, 4, 224, 6)
self.contents.font.color = system_color
if @mode == 0
self.contents.draw_text(4, 256, 200, 32, $str_el_attack)
self.contents.draw_text(4, 320, 200, 32, $str_st_attack)
end
if @mode == 1
self.contents.draw_text(4, 256, 200, 32, $str_el_defense)
self.contents.draw_text(4, 320, 200, 32, $str_st_defense)
end
self.contents.font.color = normal_color
if @elem_text == ""
@elem_text = $str_none
end
self.contents.draw_text(16, 288, 220, 32, @elem_text)
if @stat_text == ""
@stat_text = $str_none
end
self.contents.draw_text(16, 352, 220, 32, @stat_text)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 32, 40, 32, "→", 1)
if @changes[0] == 0
self.contents.font.color = normal_color
elsif @changes[0] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 32, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 64, 40, 32, "→", 1)
if @changes[1] == 0
self.contents.font.color = normal_color
elsif @changes[1] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 64, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 96, 40, 32, "→", 1)
if @changes[2] == 0
self.contents.font.color = normal_color
elsif @changes[2] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 96, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 128, 40, 32, "→", 1)
if @changes[3] == 0
self.contents.font.color = normal_color
elsif @changes[3] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 128, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 160, 40, 32, "→", 1)
if @changes[4] == 0
self.contents.font.color = normal_color
elsif @changes[4] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 160, 36, 32, @new_dex.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 192, 40, 32, "→", 1)
if @changes[5] == 0
self.contents.font.color = normal_color
elsif @changes[5] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 192, 36, 32, @new_agi.to_s, 2)
end
if @new_int != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 224, 40, 32, "→", 1)
if @changes[6] == 0
self.contents.font.color = normal_color
elsif @changes[6] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(200, 224, 36, 32, @new_int.to_s, 2)
end
end
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
new_agi, new_int, new_eva, elem_text, stat_text)
flag = false
if new_atk != @new_atk || new_pdef != @new_pdef || new_mdef != @new_mdef
flag = true
end
if new_str != @new_str || new_dex != @new_dex || new_agi != @new_agi
flag = true
end
if new_eva != @new_eva || elem_text != @elem_text || stat_text != @stat_text
flag = true
end
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
@new_eva = new_eva
@elem_text = elem_text
@stat_text = stat_text
if flag
refresh
end
end
end
а вот Window_EquipItem
PHP код:
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 256, 640, 224)
@actor = actor
@equip_type = equip_type
@column_max = 1
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
@data.push(nil)
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max-1
draw_item(i)
end
s = @data.size-1
self.contents.draw_text(4, s*32, 100, 32, $str_remove)
end
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4
y = index * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 288, y, 16, 32, ":", 1)
self.contents.draw_text(x + 304, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
всё легко и понятно
Социальные закладки