Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module HUDConfig
- AUTO_HIDE = false #vuoi che l'HUD si nasconda automaticamente dopo un po'?
- # ATTENZIONE: NECESSITA DELLO SCRITP SMOOTH MOVE
- HIDE_TIME = 5 #dopo quanti secondi vuoi che si nasconda?
- SPEED = 3 #velocità di scomparsa dell'HUD
- end
- class Window_H87Hud1 < Window_Base
- def initialize(x, y)
- super(x, y, Graphics.width, 96 + 16 + line_height*2)
- self.opacity = 0
- refresh
- end
- def refresh
- self.contents.clear
- @actor = $game_party.members[0]
- return if @actor.nil?
- draw_actor_face(actor, 0, 0)
- draw_actor_status
- draw_actor_equip
- draw_actor_exp
- end
- def actor
- return @actor
- end
- def draw_actor_status
- draw_hp(95, 0)
- draw_mp(95, line_height)
- draw_states(95, line_height*2)
- draw_name(0,0,95)
- end
- def draw_hp(x, y)
- mwidth = [actor.mhp/10,contents.width-x].min
- contents.fill_rect(x+2, y+2, mwidth+2, line_height - 4, Color.new(0,0,0))
- contents.fill_rect(x+3, y+3, mwidth, line_height - 6, gauge_back_color)
- hpwidth = actor.hp.to_f*mwidth/actor.mhp
- contents.gradient_fill_rect(x+3, y+3, hpwidth, line_height-6,hp_gauge_color1, hp_gauge_color2)
- change_color(system_color)
- #draw_text(x, y, 30, line_height, Vocab::hp_a)
- #draw_current_and_max_values(x, y, mwidth, actor.hp, actor.mhp,
- # hp_color(actor), normal_color)
- end
- def draw_mp(x, y)
- mwidth = [actor.mmp/2,contents.width-x].min
- contents.fill_rect(x+2, y+2, mwidth+2, line_height - 4, Color.new(0,0,0))
- contents.fill_rect(x+3, y+3, mwidth, line_height - 6, gauge_back_color)
- mpwidth = actor.mp.to_f*mwidth/actor.mmp
- contents.gradient_fill_rect(x+3, y+3, mwidth, line_height-6,mp_gauge_color1, mp_gauge_color2)
- change_color(system_color)
- #draw_text(x, y, 30, line_height, Vocab::mp_a)
- #draw_current_and_max_values(x+30, y, mwidth, actor.mp, actor.mhp,
- # mp_color(actor), normal_color)
- end
- def draw_states(x, y)
- draw_actor_icons(actor, x, y)
- end
- def draw_name(x, y, width)
- change_color(normal_color)
- old_size = contents.font.size
- contents.font.size = 15
- height = contents.text_size(actor.name).height
- #contents.fill_rect(x, y, width, height, Color.new(0,0,0,128))
- draw_text(x, y, width, height, actor.name)
- contents.font.size = old_size
- end
- def draw_actor_equip
- return if actor.weapons.size == 0
- for i in 0..actor.weapons.size-1
- weapon = actor.weapons[i]
- draw_icon(weapon.icon_index, 0, 95 + (line_height * i))
- draw_text(x+24, 95 + (line_height * i), contents.width, line_height, weapon.name)
- end
- end
- def draw_actor_exp
- unless actor.max_level?
- zero = actor.current_level_exp
- nlev = actor.next_level_exp - zero
- exp = actor.exp - zero
- contents.fill_rect(0, 94, 95, 2, gauge_back_color)
- width = exp*95/nlev
- contents.fill_rect(0,94,width, 2, power_up_color)
- end
- draw_actor_level(actor, 0, 96 - line_height)
- #~ exp = actor.
- #~ contents.fill_rect(0, 91,
- end
- def draw_exp_info(x, y)
- s1 = @actor.max_level? ? "-------" : @actor.exp
- s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
- s_next = sprintf(Vocab::ExpNext, Vocab::level)
- change_color(system_color)
- draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
- draw_text(x, y + line_height * 2, 180, line_height, s_next)
- change_color(normal_color)
- draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
- draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
- end
- end
- class Spriteset_Map
- alias h87hud1_create_pictures create_pictures unless $@
- def create_pictures
- h87hud1_create_pictures
- create_hud
- end
- def create_hud
- y = $game_system.hud_active ? 0 : - 160
- @actor_hud = Window_H87Hud1.new(0, y)
- @actor_hud.viewport = @viewport3
- end
- alias h87hud1_update update unless $@
- def update
- h87hud1_update
- @actor_hud.update
- end
- alias h87hud1_dispose dispose unless $@
- def dispose
- h87hud1_dispose
- @actor_hud.dispose
- end
- def refresh_hud
- @actor_hud.refresh
- end
- def hide_hud
- @actor_hud.smooth_move(0,0-@actor_hud.height, HUDConfig::SPEED)
- end
- def show_hud
- @actor_hud.smooth_move(0,0, HUDConfig::SPEED)
- end
- end
- class Scene_Map < Scene_Base
- alias h87hud_update update unless $@
- def update
- h87hud_update
- update_hud_autohide
- end
- def update_hud_autohide
- return unless HUDConfig::AUTO_HIDE
- if $game_system.hud_time > 0
- $game_system.hud_time -= 1
- hide_hud if $game_system.hud_time <= 0
- end
- end
- def refresh_hud
- @spriteset.refresh_hud
- if HUDConfig::AUTO_HIDE
- show_hud
- end
- end
- def hide_hud
- $game_system.hud_active = false
- @spriteset.hide_hud
- end
- def show_hud
- $game_system.hud_active = true
- @spriteset.show_hud
- $game_system.reset_hud_time
- end
- alias h87_hud1_update_scene update_scene unless $@
- def update_scene
- h87_hud1_update_scene
- update_hide_hud unless scene_changing?
- end
- def update_hide_hud
- if Input.trigger?(:X)
- Sound.play_cursor
- $game_system.hud_active ? hide_hud : show_hud
- end
- end
- end
- class Game_BattlerBase
- alias h87hud1_refresh refresh unless $@
- def refresh
- h87hud1_refresh
- refresh_hud
- end
- def refresh_hud
- return unless actor?
- SceneManager.scene.refresh_hud if SceneManager.scene_is?(Scene_Map)
- end
- end
- class Game_System
- def hud_active
- @hud_active = true if @hud_active.nil?
- return @hud_active
- end
- def hud_active=(value)
- @hud_active = value
- end
- def hud_time
- reset_hud_time if @hud_time.nil?
- return @hud_time
- end
- def hud_time=(value)
- @hud_time = 0 if @hud_time.nil?
- @hud_time = value
- end
- def reset_hud_time
- @hud_time = HUDConfig::HIDE_TIME*Graphics.frame_rate
- end
- end
- class Game_Interpreter
- def hide_hud
- $game_system.hud_active = false
- SceneManager.scene.hide_hud if SceneManager.scene_is?(Scene_Map)
- end
- def show_hud
- $game_system.hud_active = true
- SceneManager.scene.show_hud if SceneManager.scene_is?(Scene_Map)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement