Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Window_Base
- #==============================================================================
- class Window_Base2 < Window
- def initialize(x, y, width, height)
- super()
- self.x = x
- self.y = y
- self.width = width
- self.height = height
- self.z = 100
- end
- def dispose
- if self.contents != nil
- self.contents.dispose
- end
- super
- end
- def update
- super
- end
- end
- #===============================================================================
- # HUD
- # Thanks to Ngọa Hổ
- # Re-Scripted by MrShir
- #===============================================================================
- class GUI < Window_Base2
- def initialize
- super(-16, -16, 640+32, 480+32)
- self.z = 10
- self.contents = Bitmap.new(640,480)
- self.contents.font.name = ".VnArial"
- self.contents.font.size = 14
- @window_pos = Sprite.new
- @window_pos.bitmap = Bitmap.new(200, 80)
- # @window_pos.bitmap.font.name = [".VnArial"]
- @window_pos.bitmap.font.size = 14
- @window_pos.bitmap.font.color = ColorLib.white
- @window_pos.x = 487
- @window_pos.y = -2
- @window_pos.z = 13
- @exp_list = []
- actor = $data_actors[1]
- @exp_list[1] = 0
- pow_i = 2.4 + actor.exp_inflation / 100.0
- for i in 2..100
- if i > actor.final_level
- @exp_list[i] = 0
- else
- n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
- @exp_list[i] = @exp_list[i-1] + Integer(n)
- end
- end
- refresh_pos
- refresh
- end
- alias old_dispose dispose
- def dispose
- old_dispose
- @window_pos.dispose
- end
- #-----------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @old_hp = $game_party.actors[0].hp
- @old_mp = $game_party.actors[0].sp
- @old_exp = $game_party.actors[0].exp_s.to_i
- @next_exp = $game_party.actors[0].next_exp_s.to_i
- @level = $game_party.actors[0].level
- @next_exp -= @exp_list[@level]
- @old_exp -= @exp_list[@level]
- @maxhp = $game_party.actors[0].maxhp
- @maxmp = $game_party.actors[0].maxsp
- self.contents.blt(0, 0, Bitmap.new("Graphics/Sprite/top_hud"), Rect.new(0, 0, 640, 200))
- draw_gradient_bar(55,19, @old_hp, @maxhp, "hp", 87, 8)
- self.contents.font.color = Color.new(255, 255, 255)
- draw_gradient_bar(55,29, @old_mp, @maxmp, "mp", 87,8)
- self.contents.font.color = Color.new(255, 255, 255)
- self.contents.draw_text(60, 1, 65, 15,"tªn NV",1)
- # self.contents.draw_text(105, 1, 10, 15,$game_party.actors[0].level.to_s,1)
- if @old_exp != 0
- # thuật toán tạo % hiện ở dạng xx.xxx%, tác giả : Ngọa Hổ
- kn_hien_co = (@old_exp.to_f*100).to_i
- kn_can_co = @next_exp
- phantram_begin=(kn_hien_co.to_f/kn_can_co).to_f
- phantram_ok = (phantram_begin*100).to_i
- phantram = (phantram_ok.to_f/100).to_f
- else
- phantram=0
- end
- draw_gradient_bar(30, 463, phantram.abs, 100, "exp", 339, 15)
- self.contents.blt(0, 415, Bitmap.new("Graphics/Sprite/bot_hud"), Rect.new(0, 0, 640, 64))
- self.contents.font.color = Color.new(255, 255, 255)
- self.contents.draw_text(33, 460, 40, 22, phantram.to_s+"%")
- self.contents.draw_text(83, 460, 640, 22, "Kinh NghiÖm : "+@old_exp.to_s+" / "+@next_exp.to_s+" (CÊp : "+@level.to_s+")")
- end
- def refresh_pos
- @x = $game_player.x
- @y = $game_player.y
- @id = $game_map.map_id
- map_name = load_data("Data/MapInfos.rxdata")[@id].name
- @window_pos.bitmap.clear
- @window_pos.bitmap.draw_text(0, 0, 149, 20, map_name,2)
- @window_pos.bitmap.draw_text(0, 14, 145, 20, @x.to_s,2)
- @window_pos.bitmap.draw_text(0, 25, 145, 20, @y.to_s,2)
- end
- def need_update_pos
- return true if @x != $game_player.x
- return true if @y != $game_player.y
- return true if @id != $game_map.map_id
- return false
- end
- def need_update
- return true if @old_hp != $game_party.actors[0].hp
- return true if @old_mp != $game_party.actors[0].sp
- return true if @old_exp != $game_party.actors[0].exp_s
- return true if @level != $game_party.actors[0].level
- return false
- end
- #------------------------------------------------------------------------------
- def draw_gradient_bar(x, y, min, max, file, width = nil, height = nil, back = "")
- bar = Bitmap.new("Graphics/Sprite/"+file) rescue Bitmap.new("Graphics/Sprite/hp")
- back = Bitmap.new("Graphics/Sprite/"+back) rescue Bitmap.new("Graphics/Sprite/back")
- cx = 1
- cy = 1
- dx = 1
- dy = 1
- zoom_x = width != nil ? width : back.width
- zoom_y = height != nil ? height : back.height
- percent = min / max.to_f if max != 0
- percent = 0 if max == 0
- back_dest_rect = Rect.new(x,y,zoom_x,zoom_y)
- bar_dest_rect = Rect.new(x+cx,y+cy,zoom_x * percent-cx*2,zoom_y-cy*2) rescue print("x:"+x.to_s+" y:"+y.to_s+" min:"+min.to_s+" max:"+max.to_s)
- back_source_rect = Rect.new(0,0,back.width,back.height)
- bar_source_rect = Rect.new(0,0,bar.width* percent,bar.height)
- self.contents.stretch_blt(back_dest_rect, back, back_source_rect)
- self.contents.stretch_blt(bar_dest_rect, bar, bar_source_rect)
- end
- def hide
- self.z = -10
- @window_pos.z = -1
- end
- def show
- self.z = 10
- @window_pos.z = 13
- end
- end
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- class Scene_Map
- alias old_main main
- def main
- $gui = GUI.new
- old_main
- $gui.dispose
- end
- alias world_update update
- def update
- $gui.refresh if $gui.need_update
- $gui.refresh_pos if $gui.need_update_pos
- world_update
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement