class Window_SimpleStatus < Window_Base #-------------------------------------------------------------------------- # ● initialize 外窗口初始化 # 变量 :@old_party_data 保存上一刻的队伍(所有队友?)信息 # @inside_windows 保存信息显示窗口 # @outside_windows_changed 第一次创建外窗口 或 # 外窗口需要更新的标示 #-------------------------------------------------------------------------- def initialize @x = 0 @y = Graphics.height - line_height*($game_party.all_members.size-1) - 48 width = Graphics.width height = 48 + line_height*($game_party.all_members.size-1) super(@x, @y, width, height) @old_party_data = [] @inside_windows = [] old_party_data_initialize inside_windows_initialize @outside_windows_changed = true end #-------------------------------------------------------------------------- # ● old_party_data 数组初始化 # @old_party_data :保存上一刻的队伍(所有队友?)信息,包括: # name 姓名 # level 等级 # hp 生命值 # mhp 最大生命值 # mp 魔法值 # mmp 最大魔法值 #-------------------------------------------------------------------------- def old_party_data_initialize for i in 0..$game_party.all_members.size-1 actor = $game_party.all_members[i] @old_party_data.push([actor.name, actor.level, actor.hp, actor.mhp, actor.mp, actor.mmp]) end end #-------------------------------------------------------------------------- # ● inside_windows 数组初始化 # @inside_windows :显示角色信息的窗口(边框透明度为 0 的窗口) # 变量 :height 窗口高度 # width 窗口宽度 # x 窗口左上角 x 坐标 # y 窗口左上角 y 坐标 #-------------------------------------------------------------------------- def inside_windows_initialize for i in 0..$game_party.all_members.size-1 height = 96 if height != 96 width = Graphics.width/4+48 @inside_windows.push(Array.new([Window_Base.new(0,0,width-24,height),Window_Base.new(0,0,width,height),Window_Base.new(0,0,width,height),Window_Base.new(0,0,width,height)])) end for i in 0..$game_party.all_members.size-1 @inside_windows[i].each do |window| window.opacity = 0 window.back_opacity = 0 window.contents_opacity = 0 window.padding = 0 end end for i in 0..@inside_windows.size-1 actor = $game_party.all_members x = y = standard_padding width = Graphics.width/4 @inside_windows[i][0].draw_actor_name(actor[i], x, y, width) @inside_windows[i][1].draw_actor_level(actor[i], x, y) @inside_windows[i][2].draw_actor_hp(actor[i], x, y, width) @inside_windows[i][3].draw_actor_mp(actor[i], x, y, width) end end #-------------------------------------------------------------------------- # ● update : 更新 #-------------------------------------------------------------------------- def update super outside_windows_update inside_windows_update old_party_data_update end #-------------------------------------------------------------------------- # ● outside_windows_update : 外窗口更新(就是那个边框) # @inside_windows :显示角色信息的窗口 # 变量 :height 窗口高度 # width 窗口宽度 # @x 外窗口左上角 x 坐标 # @y 外窗口左上角 y 坐标 #-------------------------------------------------------------------------- def outside_windows_update return if @outside_windows_changed == false for i in 0..@inside_windows.size-1 x = @x y = @y height = i width = Graphics.width/4 padding = i==0?0:24 @inside_windows[i][0].move(x+width*0, y+line_height*height, width, line_height+standard_padding*4) @inside_windows[i][1].move(x+width*1-12, y+line_height*height, width+24, line_height+standard_padding*4) @inside_windows[i][2].move(x+width*2-36, y+line_height*height, width+24, line_height+standard_padding*4) @inside_windows[i][3].move(x+width*3-24, y+line_height*height, width+24, line_height+standard_padding*4) end @outside_windows_changed = false end #-------------------------------------------------------------------------- # ● inside_windows_update : 内窗口更新,仅当窗口内容发生变化时更新 #-------------------------------------------------------------------------- def inside_windows_update for i in 0..@inside_windows.size-1 actor = $game_party.all_members x = y = standard_padding width = Graphics.width/4 if name_change(i,actor[i]) @inside_windows[i][0].contents.clear @inside_windows[i][0].draw_actor_name(actor[i], x, y, width) end if level_change(i,actor[i]) @inside_windows[i][1].contents.clear @inside_windows[i][1].draw_actor_level(actor[i], x, y) end if hp_change(i,actor[i]) @inside_windows[i][2].contents.clear @inside_windows[i][2].draw_actor_hp(actor[i], x, y, width) end if mp_change(i,actor[i]) @inside_windows[i][3].contents.clear @inside_windows[i][3].draw_actor_mp(actor[i], x, y, width) end @inside_windows.each do |window| window.each do |obj| obj.contents_opacity = 255 end end end end #-------------------------------------------------------------------------- # ● old_party_data_update : @old_party_data更新,仅当所有窗口更新完毕后更新 #-------------------------------------------------------------------------- def old_party_data_update for i in 0..@old_party_data.size-1 actor = $game_party.all_members[i] @old_party_data[i][0] = actor.name if name_change(i,actor) @old_party_data[i][1] = actor.level if level_change(i,actor) @old_party_data[i][2] = actor.hp if hp_change(i,actor) @old_party_data[i][3] = actor.mp if mp_change(i,actor) end end #-------------------------------------------------------------------------- # ● *_change : 检查需要显示的队伍数据是否发生变化 #-------------------------------------------------------------------------- def name_change(index = 0,actor) return @old_party_data[index][0]!=actor.name end def level_change(index = 0,actor) return @old_party_data[index][1]!=actor.level end def hp_change(index = 0,actor) return @old_party_data[index][2]!=actor.hp || @old_party_data[index][3]!=actor.mhp end def mp_change(index = 0,actor) return @old_party_data[index][4]!=actor.mp || @old_party_data[index][5]!=actor.mmp end #-------------------------------------------------------------------------- # ● old_party_data #-------------------------------------------------------------------------- def old_party_data @old_party_data end #-------------------------------------------------------------------------- # ● need_dispose :检查是否需要销毁窗口,在必要时(卡顿等)返回撤销命令 #-------------------------------------------------------------------------- def need_dispose return true if @old_party_data.size != $game_party.all_members.size actor = $game_party.all_members for i in 0..@old_party_data.size-1 return true if @old_party_data[i][0] != actor[i].name return true if @old_party_data[i][1] != actor[i].level return true if @old_party_data[i][3] != actor[i].mhp return true if @old_party_data[i][5] != actor[i].mmp end return false end #-------------------------------------------------------------------------- # ● dispose :销毁窗口 #-------------------------------------------------------------------------- def dispose super @inside_windows.each do |window| window.each do |obj| obj.dispose end end end end class Scene_Map alias old_start start def start old_start @Window_SimpleStatus = Window_SimpleStatus.new end alias old_pre_terminate pre_terminate def pre_terminate old_pre_terminate @Window_SimpleStatus.dispose end alias old_update update def update old_update if @Window_SimpleStatus.need_dispose @Window_SimpleStatus.dispose @Window_SimpleStatus = Window_SimpleStatus.new end end end
temp.PNG (113.91 KB, 下载次数: 33)
附图
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |