module Graphics
if !defined?(height)
class << self
def height; 480; end
end
end
if !defined?(width)
class << self
def width; 640; end
end
end
end
module BarWriter
def self.drawBar(bitmap,x,y,width,height,value,maxvalue,color)
bitmap.fill_rect(x,y+2,width,height,Color.new(0,0,0))
bitmap.fill_rect(x,y,width*value/maxvalue,height,color)
end
end
module CharlieLeeBarWriter
def self.drawBar(bitmap,x,y,width,height,value,maxvalue,color)
buffer=Bitmap.new(width,height)
bar=Bar.new(0,0,buffer.width,buffer.height,buffer)
bar.refresh(value,maxvalue)
bitmap.blt(x,y,buffer,buffer.rect)
buffer.dispose
end
end
class ActorStatus < Window_Base
###################
FONTNAME="Arial"
FONTSIZE=16
WAITCOUNT=15 # In frames (1/40 second)
HPBARCOLOR=Color.new(0,0,200)
SPBARCOLOR=Color.new(0,200,0)
BARWRITERMODULE=::BarWriter
###################
def initialize(id)
@unitsize=FONTSIZE+8
super(id*(Graphics.width/4),Graphics.height-((@unitsize*3)+32),
Graphics.width/4,(@unitsize*3)+32)
self.contents=Bitmap.new(self.width-32,self.height-32)
@id=id
@movecount=WAITCOUNT
self.z=5000
self.opacity=128
self.contents.font.name=[FONTNAME,"Arial","Times New Roman"]
self.contents.font.size=FONTSIZE
refresh
end
def update
super
if $game_player.moving? || $game_temp.message_window_showing ||
$game_player.move_route_forcing || $game_system.map_interpreter.running?
self.visible=false
@movecount=0
elsif @movecount<WAITCOUNT
self.visible=false
@movecount+=1
else
if @movecount==WAITCOUNT || Graphics.frame_count%10==0
refresh
end
end
end
def drawActorBar(x,y,word,width,color,value,maxvalue)
bitmap=self.contents
valuewidth=bitmap.text_size(value.to_s).width
maxvaluewidth=bitmap.text_size("/"+maxvalue.to_s).width
BARWRITERMODULE.drawBar(
bitmap,x+32,y+(@unitsize/2),width-32,(@unitsize*2/5),
value,maxvalue,color)
bitmap.font.color = system_color
bitmap.draw_text(x, y, bitmap.text_size(word).width, @unitsize, word)
self.contents.font.color = value == 0 ? knockout_color :
value <= maxvalue / 4 ? crisis_color : normal_color
bitmap.draw_text(x+width-maxvaluewidth-valuewidth,
y, valuewidth, @unitsize, value.to_s)
self.contents.font.color = normal_color
bitmap.draw_text(x+width-maxvaluewidth,
y, maxvaluewidth, @unitsize, "/"+maxvalue.to_s)
end
def refresh
self.contents.clear
if !$game_party || @id>=$game_party.actors.size ||
!$game_party.actors[@id]
self.visible=false
return
end
self.visible=true
actor=$game_party.actors[@id]
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, self.contents.width, @unitsize, actor.name)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
width=self.contents.text_size(text).width
self.contents.draw_text(self.contents.width-width, 0, width, @unitsize, text)
drawActorBar(0,@unitsize,$data_system.words.hp,self.contents.width,
HPBARCOLOR,actor.hp,actor.maxhp)
drawActorBar(0,@unitsize*2,$data_system.words.sp,self.contents.width,
SPBARCOLOR,actor.sp,actor.maxsp)
end
end
class Spriteset_Map
if !defined?(petero_actordisplays_Spriteset_Map_initialize)
alias petero_actordisplays_Spriteset_Map_initialize initialize
alias petero_actordisplays_Spriteset_Map_update update
alias petero_actordisplays_Spriteset_Map_dispose dispose
end
def initialize
@actordisplays=[
ActorStatus.new(0),
ActorStatus.new(1),
ActorStatus.new(2),
ActorStatus.new(3)
]
petero_actordisplays_Spriteset_Map_initialize
end
def update
for d in @actordisplays
d.update
end
petero_actordisplays_Spriteset_Map_update
end
def dispose
for d in @actordisplays
d.dispose
end
petero_actordisplays_Spriteset_Map_dispose
end
end