# ============================================================================= # TheoAllen - Simple Variable HUD # Version : 1.0 # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com # (This script documentation is written in informal indonesian language) # ============================================================================= ($imported ||= {})[:Theo_VariableHUD] = true # ============================================================================= # CHANGE LOGS: # ----------------------------------------------------------------------------- # 2013.07.23 - Finished script # ============================================================================= =begin Perkenalan : Script ini berguna untuk menampilkan nilai dari sebuah variable Cara penggunaan : Pasang dibawah material namun diatas main Gunakan script call show_variable(id) >> nampilin nilai variable show_variable(id,icon_id) >> variable + gambar icon show_variable(id,icon_id,pos) >> variable + icon + posisi hide_variable >> untuk sembunyiin variable HUD Terms of Use : Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau dipake buat komersil, jangan lupa, gw dibagi gratisannya. Note : Karena ini simple, jadi jangan harap ada banyak kustomisasi bebas =end # ============================================================================= # Sedikit Konfigurasi # ============================================================================= VarHUD_DefaultPos = 1 # Posisi default HUD # ----------------------------------------------------------------------------- # 1 >> Kiri Atas # 2 >> Kanan Atas # 3 >> Kiri Bawah # 4 >> Kanan Bawah # ----------------------------------------------------------------------------- VarHUD_FontSize = 34 # Ukuran Font # ============================================================================= # Akhir dari konfig # ============================================================================= class Game_Temp attr_accessor :refresh_hud alias theo_varhud_init initialize def initialize theo_varhud_init @refresh_hud = false end end class Game_Variables alias theo_varhud_on_change on_change def on_change theo_varhud_on_change $game_temp.refresh_hud = true end end class Game_System class VarHUD attr_accessor :position attr_accessor :visible attr_accessor :icon attr_accessor :id def initialize @position = 0 @visible = false @icon = 0 @id = 0 end end attr_reader :varhud alias theo_varhud_init initialize def initialize theo_varhud_init @varhud = VarHUD.new end end class Game_Interpreter def show_variable(id,icon = 0,position = VarHUD_DefaultPos) hud = $game_system.varhud hud.visible = true hud.position = position hud.icon = icon hud.id = id $game_temp.refresh_hud = true end def hide_variable $game_system.varhud.visible = false end end class Window_VarHUD < Window_Base def initialize super(0,0,window_width,window_height) contents.font.size = VarHUD_FontSize update_hud_position self.opacity = 0 refresh end def window_width;Graphics.width;end; def window_height;fitting_height(1);end; def line_height;VarHUD_FontSize;end; def update super update_visibility refresh if $game_temp.refresh_hud end def update_visibility self.visible = $game_system.varhud.visible end def refresh contents.clear update_hud_position update_hud_contents $game_temp.refresh_hud = false end def update_hud_position pos = $game_system.varhud.position if pos == 1 || pos == 2 self.y = 0 else self.y = Graphics.height - self.height end end def update_hud_contents rect = contents.rect icon = $game_system.varhud.icon var_id = $game_system.varhud.id case $game_system.varhud.position when 1,3 if icon != 0 rect.x += 27 draw_icon(icon,0,icon_y_pos) end draw_text(rect,$game_variables[var_id]) else if icon != 0 rect.x -= 27 draw_icon(icon,contents.width-24,icon_y_pos) end draw_text(rect,$game_variables[var_id],2) end end def icon_y_pos return 0 if line_height <= 24 return contents.rect.height/2 - 12 end end class Scene_Map < Scene_Base alias theo_varhud_start start def start theo_varhud_start create_var_hud end def create_var_hud @var_hud = Window_VarHUD.new @var_hud.z -= 100 end end