DaxSoft

Variables Popup 1.0

Feb 2nd, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.97 KB | None | 0 0
  1. #==============================================================================
  2. # • Variable Popup
  3. #==============================================================================
  4. # Autor: Dax
  5. # Versão: 1.0
  6. # Requerimento: Dax Core
  7. #==============================================================================
  8. # • Descrição:
  9. #------------------------------------------------------------------------------
  10. # [Mostra o valor duma variável em cima do player ou de um evento.]
  11. #==============================================================================
  12. # • Como usar : NO COMANDO 'CHAMAR SCRIPT'
  13. #------------------------------------------------------------------------------
  14. # var_player(variable_id, type) | Para usar no jogador;
  15. # * variable_id : ID da variável, que irá mostrar o dano.
  16. # * type : Cor do dano. Por padrão e branco, em tal não precisa espeficar.
  17. # :normal : Cor normal(Pode mudar)
  18. # :critical : Cor vermelho(Pode mudar)
  19. # :recover : Cor verde(Pode mudar)
  20. # :special : Cor azul(Pode mudar)
  21. # var_event(id, variable_id, type) | Para usar no evento;
  22. # * id : ID do Evento no mapa.
  23. # * variable_id : ID da variável, que irá mostrar o dano.
  24. # * type : Cor do dano. Por padrão e branco, em tal não precisa espeficar.
  25. # :normal : Cor normal(Pode mudar)
  26. # :critical : Cor vermelho(Pode mudar)
  27. # :recover : Cor verde(Pode mudar)
  28. # :special : Cor azul(Pode mudar)
  29. #==============================================================================
  30. Dax.register(:variable_popup)
  31. #==============================================================================
  32. # • Variable Popup
  33. #==============================================================================
  34. module Rpg::Variable_Popup
  35. #----------------------------------------------------------------------------
  36. # • Função do módulo.
  37. #----------------------------------------------------------------------------
  38. module_function
  39. @variable_popup = []
  40. #----------------------------------------------------------------------------
  41. # • Configuração.
  42. #----------------------------------------------------------------------------
  43. def configure
  44. return {
  45. # Configuração da propriedade no mapa.
  46. z: 200,
  47. # Cor normal do texto.;
  48. normal: ColorBasic.hex("ffffff"),
  49. # Cor critical do texto.
  50. critical: ColorBasic.hex("c51414"),
  51. # Cor recover do texto.
  52. recover: ColorBasic.hex("31d329"),
  53. # Cor special do texto.
  54. special: ColorBasic.hex("63b8df"),
  55. # Nome da fonte do texto.
  56. name: "Bell MT",
  57. # Tamanho da fonte do texto.
  58. size: 20,
  59. # Usar negrito na fonte do texto.
  60. bold: true,
  61. # Usar borda na fonte do texto.
  62. outline: false,
  63. # Usar sombra da fonte do texto.
  64. shadow: true,
  65. # Cor da borda da fonte do texto.
  66. out_color: ColorBasic.hex("000000"),
  67. # Posição adicional.
  68. x_add: 0,
  69. # Posição adicional.
  70. y_add: 0,
  71. # Velocidade para sumir do mapa.
  72. opacity: 3,
  73. }
  74. end
  75. #----------------------------------------------------------------------------
  76. # • Popup da variável no personagem.
  77. #----------------------------------------------------------------------------
  78. def player(id, type=:normal)
  79. @variable_popup << Variable_Popup_Player.new(id, type)
  80. end
  81. #----------------------------------------------------------------------------
  82. # • Popup da variável no evento.
  83. #----------------------------------------------------------------------------
  84. def event(id, vid, type=:normal)
  85. @variable_popup << Variable_Popup_Event.new(id, vid, type)
  86. end
  87. #----------------------------------------------------------------------------
  88. # • Atualização.
  89. #----------------------------------------------------------------------------
  90. def update
  91. return if @variable_popup.nil?
  92. @variable_popup.each_with_index do |var, index|
  93. unless var.nil?
  94. var.update
  95. unless var.visible
  96. var.dispose
  97. @variable_popup.delete_at(index)
  98. end
  99. end
  100. end
  101. end
  102. #----------------------------------------------------------------------------
  103. # • Limpar todas.
  104. #----------------------------------------------------------------------------
  105. def clear
  106. @variable_popup.clear
  107. end
  108. end
  109. #==============================================================================
  110. # • Rpg::Variable_Popup::Player
  111. #==============================================================================
  112. class Variable_Popup_Player < Sprite
  113. #----------------------------------------------------------------------------
  114. # • Inicialização dos objetos.
  115. #----------------------------------------------------------------------------
  116. def initialize(id, type=:normal)
  117. super([64, Rpg::Variable_Popup.configure[:size]+2])
  118. self.x = ($game_player.screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
  119. self.y = ($game_player.screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
  120. ["name", "size", "bold", "outline", "shadow", "out_color"].each { |i|
  121. eval("self.bitmap.font.#{i} = Rpg::Variable_Popup.configure[:#{i}]")
  122. }
  123. self.bitmap.font.color = Rpg::Variable_Popup.configure[type]
  124. @opacity = Rpg::Variable_Popup.configure[:opacity]
  125. self.bitmap.draw_text_rect($game_variables[id].to_s, 1)
  126. end
  127. #----------------------------------------------------------------------------
  128. # • Renovação dos objetos.
  129. #----------------------------------------------------------------------------
  130. def dispose
  131. self.bitmap.dispose
  132. super
  133. end
  134. #----------------------------------------------------------------------------
  135. # • Atualização dos objetos.
  136. #----------------------------------------------------------------------------
  137. def update
  138. super
  139. self.x = ($game_player.screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
  140. self.y = ($game_player.screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
  141. self.opacity -= @opacity
  142. self.visible = false if self.opacity <= 0
  143. end
  144. end
  145. #==============================================================================
  146. # • Rpg::Variable_Popup::Event
  147. #==============================================================================
  148. class Variable_Popup_Event < Sprite
  149. #----------------------------------------------------------------------------
  150. # • Inicialização dos objetos.
  151. #----------------------------------------------------------------------------
  152. def initialize(id, vid, type=:normal)
  153. super([64, Rpg::Variable_Popup.configure[:size]+2])
  154. self.x = ($game_map.events[id].screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
  155. self.y = ($game_map.events[id].screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
  156. ["name", "size", "bold", "outline", "shadow", "out_color"].each { |i|
  157. eval("self.bitmap.font.#{i} = Rpg::Variable_Popup.configure[:#{i}]")
  158. }
  159. self.bitmap.font.color = Rpg::Variable_Popup.configure[type]
  160. @opacity = Rpg::Variable_Popup.configure[:opacity]
  161. self.bitmap.draw_text_rect($game_variables[vid].to_s, 1)
  162. @id = id
  163. end
  164. #----------------------------------------------------------------------------
  165. # • Renovação dos objetos.
  166. #----------------------------------------------------------------------------
  167. def dispose
  168. self.bitmap.dispose
  169. super
  170. end
  171. #----------------------------------------------------------------------------
  172. # • Atualização dos objetos.
  173. #----------------------------------------------------------------------------
  174. def update
  175. super
  176. self.x = ($game_map.events[@id].screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
  177. self.y = ($game_map.events[@id].screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
  178. self.opacity -= @opacity
  179. self.visible = false if self.opacity <= 0
  180. end
  181. end
  182. #==============================================================================
  183. # • Spriteset_Map
  184. #==============================================================================
  185. class Spriteset_Map
  186. alias :variable_popup_update :update
  187. def update
  188. variable_popup_update
  189. Rpg::Variable_Popup.update
  190. end
  191. end
  192. #==============================================================================
  193. # • Interpretador;
  194. #==============================================================================
  195. class Game_Interpreter
  196. #----------------------------------------------------------------------------
  197. # • No Jogador.
  198. #----------------------------------------------------------------------------
  199. def var_player(*args)
  200. Rpg::Variable_Popup.player(*args)
  201. end
  202. #----------------------------------------------------------------------------
  203. # • No Evento.
  204. #----------------------------------------------------------------------------
  205. def var_event(*args)
  206. Rpg::Variable_Popup.event(*args)
  207. end
  208. end
Advertisement
Add Comment
Please, Sign In to add comment