Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================
- # http://thiagodd.blogspot.com.br
- #
- # [TSDA] Custom HUD
- # --> Version 1.0
- # ----Credits
- # thiago_d_d
- # Blizzard - for the mouse system
- #
- #--------------------------------------------------------------
- # * Features
- #--------------------------------------------------------------
- # + A custom HUD that shows value when mouse is above.
- #
- #--------------------------------------------------------------
- # * Install
- #--------------------------------------------------------------
- # Put this script above Main.
- #
- #--------------------------------------------------------------
- # * Configuration
- #--------------------------------------------------------------
- # Configure text color below.
- #==============================================================
- module TSDA
- COR_R=0
- COR_G=0
- COR_B=0
- end
- #--------------------------------------------------------------
- class Scene_Map
- alias old_main main
- alias old_update update
- def main
- @window_digimon = Window_Digimon_Hud.new
- @window_text = Window_MouseOver.new
- old_main
- @window_digimon.dispose
- @window_text.dispose
- end
- #------------------------------------------------------------
- def update
- @window_digimon.update
- @window_text.update
- old_update
- @window_digimon.refresh
- x = $mouse.x
- y = $mouse.y
- if x >= 328 && x <= 629 && y >= 465 && y <= 476
- actor = $game_party.actors[0]
- st = "#{actor.exp_now}/#{actor.exp_next}"
- @window_text.refresh(st)
- @window_text.visible = true
- elsif x >= 532 && x <= 630
- if y >= 429 && y <= 440
- actor = $game_party.actors[0]
- st = "#{actor.hp}/#{actor.maxhp}"
- @window_text.refresh(st)
- @window_text.visible = true
- elsif y >= 448 && y <= 459
- actor = $game_party.actors[0]
- st = "#{actor.sp}/#{actor.maxsp}"
- @window_text.refresh(st)
- @window_text.visible = true
- end
- else
- @window_text.visible = false
- end
- end
- end
- #----------------------------------------------
- class Game_Actor
- def exp_now
- return @exp_list[@level+1] > 0 ? self.exp_next -
- (@exp_list[@level+1] - @exp) : 0
- end
- #------------------------------------------------------------
- def exp_next
- @exp_list[@level+1] > 0 ? @exp_list[@level+1] -
- @exp_list[@level] : 0
- end
- end
- #--------------------------------------------------------------
- class Window_Digimon_Hud < Window_Base
- def initialize
- super(262,383,394,113)
- self.contents = Bitmap.new(width - 32,height - 32)
- self.contents.font.size = 16
- self.opacity = 0
- self.back_opacity = 0
- self.contents_opacity = 210
- refresh
- end
- #------------------------------------------------------------
- def refresh
- self.contents.clear
- actor = $game_party.actors[0]
- self.contents.font.color = Color.new(TSDA::COR_R,
- TSDA::COR_G,TSDA::COR_B)
- bitmap = RPG::Cache.picture("HUD1")
- bitmap2 = RPG::Cache.picture("HUD2")
- bitmap3 = RPG::Cache.picture("HUD3")
- bitmap4 = RPG::Cache.picture("HUD4")
- src_rect = Rect.new(0, 0, 362, 81)
- src_rect2 = Rect.new(0, 0,
- actor.exp_now * 302 / actor.exp_next, 12)
- src_rect3 = Rect.new(0, 0, actor.hp * 99 / actor.maxhp, 12)
- src_rect4 = Rect.new(0, 0, actor.sp * 99 / actor.maxsp, 12)
- self.contents.blt(0, 0, bitmap, src_rect)
- self.contents.blt(50, 66, bitmap2, src_rect2)
- self.contents.blt(254, 30, bitmap3, src_rect3)
- self.contents.blt(254, 49, bitmap4, src_rect4)
- self.contents.draw_text(231,8,39,16,actor.level.to_s)
- end
- end
- #--------------------------------------------------------------
- class Window_MouseOver < Window_Base
- def initialize
- super(0, 0, 160, 64)
- self.contents = Bitmap.new(width - 32,height - 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- self.opacity = 210
- self.back_opacity = 210
- self.z = 9999
- self.visible = false
- end
- #------------------------------------------------------------
- def refresh(text)
- self.width = self.contents.text_size(text).width + 32
- self.contents.dispose
- self.contents = Bitmap.new(width - 32,height - 32)
- self.contents.font.color = Color.new(TSDA::COR_R,
- TSDA::COR_G,TSDA::COR_B)
- self.x = $mouse.x - 64
- self.y = $mouse.y - 64
- self.contents.draw_text(0,0,128,32,text)
- end
- end
- #--------------------------------------------------------------
- class Mouse
- MOUSE_ICON = 'cursor'
- AUTO_CONFIGURE = true
- SCREEN_TO_CLIENT = Win32API.new('user32',
- 'ScreenToClient', %w(l p), 'i')
- CLIENT_RECT = Win32API.new('user32',
- 'GetClientRect', %w(l p), 'i')
- READ_INI = Win32API.new('kernel32',
- 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
- FIND_WINDOW = Win32API.new('user32',
- 'FindWindowA', %w(p p), 'l')
- CURSOR_POSITION = Win32API.new('user32',
- 'GetCursorPos', 'p', 'i')
- #------------------------------------------------------------
- def initialize
- @cursor = Sprite.new
- @cursor.z = 1000000
- update
- end
- #------------------------------------------------------------
- def update
- @cursor.x, @cursor.y = self.position
- end
- #------------------------------------------------------------
- def x
- return @cursor.x
- end
- #------------------------------------------------------------
- def y
- return @cursor.y
- end
- #------------------------------------------------------------
- def global_position
- pos = [0, 0].pack('ll')
- return (CURSOR_POSITION.call(pos) != 0 ?
- pos.unpack('ll') : nil)
- end
- #------------------------------------------------------------
- def position
- width, height = self.client_size
- x, y = self.screen_to_client(*self.global_position)
- return x, y
- end
- #------------------------------------------------------------
- def screen_to_client(x, y)
- return nil if x == nil || y == nil
- pos = [x, y].pack('ll')
- return (SCREEN_TO_CLIENT.call(WINDOW, pos) != 0 ?
- pos.unpack('ll') : nil)
- end
- #------------------------------------------------------------
- def client_size
- rect = [0, 0, 0, 0].pack('l4')
- CLIENT_RECT.call(WINDOW, rect)
- right, bottom = rect.unpack('l4')[2, 2]
- return right, bottom
- end
- #------------------------------------------------------------
- def self.find_window
- game_name = "\0" * 256
- READ_INI.call('Game', 'Title', '', game_name, 255,
- '.\\Game.ini')
- game_name.delete!("\0")
- return FIND_WINDOW.call('RGSS Player', game_name)
- end
- #------------------------------------------------------------
- WINDOW = self.find_window
- end
- $mouse = Mouse.new
- #--------------------------------------------------------------
- module Input
- class << Input
- alias update_mousecontroller_later update
- end
- #------------------------------------------------------------
- def self.update
- $mouse.update
- update_mousecontroller_later
- end
- #------------------------------------------------------------
- if Mouse::AUTO_CONFIGURE
- if $BlizzABS
- C.push(Input::Key['Mouse Left']) if
- !C.include?(Input::Key['Mouse Left'])
- if !Attack.include?(Input::Key['Mouse Right'])
- Attack.push(Input::Key['Mouse Right'])
- end
- elsif $tons_version != nil && $tons_version >= 6.4 &&
- TONS_OF_ADDONS::CUSTOM_CONTROLS || defined?(RMXOS)
- C.push(Input::Key['Mouse Left']) if !C.include?(
- Input::Key['Mouse Left'])
- end
- end
- end
- #--------------------------------------------------------------
- class Rect
- def covers?(x, y)
- return !(x < self.x || x >= self.x + self.width ||
- y < self.y || y >= self.y + self.height)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement