Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. #===============================================================================
  2. # * Simple HUD - by FL, fixed by SunakazeKun (Credits will be apreciated)
  3. #===============================================================================
  4. #
  5. # This script is for Pokémon Essentials. It displays a simple HUD with the
  6. # party icons and some small text.
  7. #
  8. # To manually refresh the HUD use the line '$hud_need_refresh = true'
  9. #
  10. #===============================================================================
  11. # * Settings
  12. #===============================================================================
  13. skin_val="Graphics\Pictures\HUDBar\HUD.txt"
  14. array = IO.readlines(skin_val)
  15. skin = array[0]
  16. BGPATH="Graphics\Pictures\HUDBar\"+skin
  17. # Put the image path between the two ". I recommend a 512x64 picture.
  18.  
  19. USEBAR=false
  20. # Make as 'true' to show a coded blue bar. Make sure to remove "BGPATH".
  21.  
  22. DRAWATBOTTOM=true
  23. # Make as 'true' to draw the HUD at bottom.
  24.  
  25. UPDATESPERSECONDS=1.00
  26. # More updates = more lag.
  27.  
  28. HUDTEXT=true
  29. # Make as 'false' to disable the HUD text.
  30. #===============================================================================
  31. # * Main
  32. #===============================================================================
  33. class Spriteset_Map
  34.  
  35. alias :initializeOldFL :initialize
  36. alias :disposeOldFL :dispose
  37. alias :updateOldFL :update
  38.  
  39. def initialize(map=nil)
  40. @hud = []
  41. initializeOldFL(map)
  42. $hud_need_refresh = true
  43. end
  44.  
  45. def dispose
  46. disposeOldFL
  47. disposeHud
  48. end
  49.  
  50. def update
  51. updateOldFL
  52. updateHud
  53. end
  54.  
  55. #===============================================================================
  56. # * HUD Data
  57. #===============================================================================
  58.  
  59. def createHud
  60. return if !$Trainer # Don't draw the hud if the player wasn't defined
  61. yposition = DRAWATBOTTOM ? Graphics.height-64 : 0
  62. @hud = []
  63. #===============================================================================
  64. # * Coded Blue Bar
  65. #===============================================================================
  66. if USEBAR
  67. bar=IconSprite.new(0,yposition,@viewport1)
  68. bar.bitmap=Bitmap.new(Graphics.width,64)
  69. bar.bitmap.fill_rect(Rect.new(0,0,bar.bitmap.width,bar.bitmap.height),
  70. Color.new(128,128,192))
  71. @hud.push(bar)
  72. end
  73. #===============================================================================
  74. # * Image
  75. #===============================================================================
  76. if BGPATH != "" # Make sure that there is nothing between the two ".
  77. bgbar=IconSprite.new(0,yposition,@viewport1)
  78. bgbar.setBitmap(BGPATH)
  79. @hud.push(bgbar)
  80. end
  81. #===============================================================================
  82. # * Text
  83. #===============================================================================
  84. if HUDTEXT
  85. baseColor=Color.new(72,72,72)
  86. shadowColor=Color.new(160,160,160)
  87. @hud.push(BitmapSprite.new(Graphics.width,Graphics.height,@viewport1))
  88. text1=_INTL("{1}",$Trainer.name)
  89. text2=_INTL("${1}",$Trainer.money)
  90. textPosition=[
  91. [text1,Graphics.width-64,yposition,2,baseColor,shadowColor],
  92. [text2,Graphics.width-64,yposition+32,2,baseColor,shadowColor]
  93. ]
  94. pbSetSystemFont(@hud[-1].bitmap)
  95. pbDrawTextPositions(@hud[-1].bitmap,textPosition)
  96. end
  97. #===============================================================================
  98. # * Pokémon Icons
  99. #===============================================================================
  100. for i in 0...$Trainer.party.size
  101. pokeicon=IconSprite.new(16+64*i,yposition-0,@viewport1)
  102. pokeicon.setBitmap(pbPokemonIconFile($Trainer.party[i]))
  103. pokeicon.src_rect=Rect.new(0,0,64,64)
  104. @hud.push(pokeicon)
  105. end
  106. for sprite in @hud
  107. sprite.z+=600
  108. end
  109. end
  110.  
  111. #===============================================================================
  112.  
  113. def updateHud
  114. for sprite in @hud
  115. sprite.update
  116. end
  117. end
  118.  
  119. def disposeHud
  120. for sprite in @hud
  121. sprite.dispose
  122. end
  123. @hud.clear
  124. end
  125. end
  126.  
  127. #===============================================================================
  128.  
  129. class Scene_Map
  130. alias :updateOldFL :update
  131. alias :miniupdateOldFL :miniupdate
  132. alias :createSpritesetsOldFL :createSpritesets
  133.  
  134. UPDATERATE = (Spriteset_Map::UPDATESPERSECONDS>0) ?
  135. (Graphics.frame_rate/Spriteset_Map::UPDATESPERSECONDS).floor : 0x3FFF
  136.  
  137. def update
  138. updateOldFL
  139. checkAndUpdateHud
  140. end
  141.  
  142. def miniupdate
  143. miniupdateOldFL
  144. checkAndUpdateHud
  145. end
  146.  
  147. def createSpritesets
  148. createSpritesetsOldFL
  149. checkAndUpdateHud
  150. end
  151.  
  152. def checkAndUpdateHud
  153. $hud_need_refresh = (Graphics.frame_count%UPDATERATE==0 ||
  154. $hud_need_refresh)
  155. if $hud_need_refresh
  156. for s in @spritesets.values
  157. s.disposeHud
  158. s.createHud
  159. end
  160. $hud_need_refresh = false
  161. end
  162. end
  163. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement