Advertisement
Guest User

Untitled

a guest
Jun 18th, 2021
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.16 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_CreateChar
  3. #------------------------------------------------------------------------------
  4. # Esta classe lida com a janela de criação de personagem.
  5. #------------------------------------------------------------------------------
  6. # Autor: Valentine
  7. #==============================================================================
  8.  
  9. class Window_CreateChar < Window_Base2
  10.  
  11.  
  12. HAIRTYPES = [
  13. [279,280,281], #masculino
  14. [282,283,284] #feminino
  15. ]
  16.  
  17. HAIRARMORIDS = [70,76,82]
  18.  
  19.  
  20. def initialize
  21. # Quando a resolução é alterada, as coordenadas x e y
  22. #são reajustadas no adjust_windows_position da Scene_Map
  23. super(adjust_x, adjust_y,'Wcreate') #401, 288
  24. self.visible = false
  25. @dragable = false
  26. @hair_type = 0
  27. @hair_color = 0
  28. refresh_hair
  29. create_buttons
  30. end
  31.  
  32. def adjust_x
  33. Graphics.width / 2 - 300
  34. end
  35.  
  36. def adjust_y
  37. Graphics.height / 2 - 200
  38. end
  39.  
  40. def max_classes
  41. $network.vip? ? Configs::MAX_VIP_CLASSES : Configs::MAX_DEFAULT_CLASSES
  42. end
  43.  
  44. def class_names
  45. (1..max_classes).collect { |class_id| $data_classes[class_id].name }
  46. end
  47.  
  48.  
  49.  
  50. def create_buttons
  51. @name_box = Text_Box.new(self, 245, 45, 115, Configs::MAX_CHARACTERS) { enable_create_button }
  52. #@class_box = Combo_Box.new(self, 265, 20, 120, class_names) { change_class } if max_classes > 1
  53. @next_sex = Image_Button.new(self, 572, 280, 'Right') { change_sex(Enums::Sex::FEMALE) }
  54. @prev_sex = Image_Button.new(self, 460, 280, 'Left') { change_sex(Enums::Sex::MALE) }
  55. @next_char = Image_Button.new(self, 572, 220, 'Right') { next_character }
  56. @prev_char = Image_Button.new(self, 460, 220, 'Left') { prev_character }
  57. @create_button = Image_Button.new(self, 250, 257, 'criar') { create_actor}
  58. #classes buttons========================================#
  59. @class1 = Image_Button.new(self, 29, 50,'cl1') {protetor}
  60. @class2 = Image_Button.new(self, 29, 120,'cl2') {guardiao}
  61. #==cabelos============================#
  62. #==============posição,ideo do icones#
  63. @hair0 =Icon.new(self, 100,100, 279) { change_hair_type(0) }#cada tipo de cabelo
  64. @hair1 =Icon.new(self, 150,100, 280) { change_hair_type(1) }
  65. @hair2 =Icon.new(self, 200,100, 281) { change_hair_type(2) }
  66. #cor dos cabelos
  67. Icon.new(self, 200, 200, 252) { change_hair_color(0) }#black
  68. Icon.new(self, 250, 200, 253) { change_hair_color(1) }#brown
  69. Icon.new(self, 300, 200, 254) { change_hair_color(2) }#yellow
  70. Icon.new(self, 200, 250, 268) { change_hair_color(3) }#pink
  71. Icon.new(self, 250, 250, 269) { change_hair_color(4) }#blue
  72. Icon.new(self, 300, 250, 270) { change_hair_color(5) }#red
  73. #=======================================================#
  74. #@create_button = Button.new(self, 168, 254, Vocab::Create, 64) { create_actor }
  75. #@rem_hp = Button.new(self, 19, 147, '-', 26) { remove_param(0) }
  76. #@rem_mp = Button.new(self, 19, 171, '-', 26) { remove_param(1) }
  77. #@rem_atk = Button.new(self, 19, 195, '-', 26) { remove_param(2) }
  78. #@remo_agi = Button.new(self, 19, 219, '-', 26) { remove_param(3) }
  79. #@add_hp = Button.new(self, 166, 147, '+', 26) { add_param(0) }
  80. #@add_mp = Button.new(self, 166, 171, '+', 26) { add_param(1) }
  81. #@add_atk = Button.new(self, 166, 195, '+', 26) { add_param(2) }
  82. #@add_agi = Button.new(self, 166, 219, '+', 26) { add_param(3) }
  83. #@rem_def = Button.new(self, 211, 147, '-', 26) { remove_param(4) }
  84. #@remo_mat = Button.new(self, 211, 171, '-', 26) { remove_param(5) }
  85. #@rem_mdf = Button.new(self, 211, 195, '-', 26) { remove_param(6) }
  86. #@rem_luk = Button.new(self, 211, 219, '-', 26) { remove_param(7) }
  87. #@add_def = Button.new(self, 356, 147, '+', 26) { add_param(4) }
  88. #@add_mat = Button.new(self, 356, 171, '+', 26) { add_param(5) }
  89. # @add_mdf = Button.new(self, 356, 195, '+', 26) { add_param(6) }
  90. # @add_luk = Button.new(self, 356, 219, '+', 26) { add_param(7) }
  91. #@points_bar = Progress_Bar.new(self, 18, 121, 365, Configs::START_POINTS) if Configs::START_POINTS > 0
  92. end
  93.  
  94. def show(actor_id)
  95. bg
  96. @actor_id = actor_id
  97. @sex = Enums::Sex::MALE
  98. @points = Configs::START_POINTS
  99. @class_id = 1
  100. @sprite_index = 0
  101. refresh_character
  102. @params = Array.new(8, 0)
  103. @name_box.clear
  104. create_buttons
  105. #@class_box.index = 0 if max_classes > 1
  106. super()
  107. # Ativa a caixa de texto após a janela ficar visível
  108. @name_box.active = true
  109. enable_buttons
  110. end
  111.  
  112. def bg
  113. @bg1 = Sprite.new
  114. @bg1.bitmap = Cache.system("wprotetor")
  115. @bg1.x = Graphics.width / 2
  116. @bg1.y = Graphics.height / 2
  117. end
  118.  
  119. def hide
  120. super
  121. $windows[:alert].hide
  122. $windows[:use_char].show
  123. @bg1.bitmap.dispose
  124. @bg1.dispose
  125. end
  126.  
  127. def invalid_name?
  128. @name_box.text =~ /[^A-Za-z0-9 ]/
  129. end
  130.  
  131. def illegal_name?
  132. Configs::FORBIDDEN_NAMES.any? { |word| @name_box.text =~ /#{word}/i }
  133. end
  134.  
  135. def refresh
  136. contents.clear
  137. bitmap = Cache.system("wprotetor")
  138. contents.blt(0,0, bitmap, bitmap.rect)
  139. draw_shadow(274, 80)
  140. draw_character(@character_name, @character_index, 290, 135)
  141. draw_paperdoll(@hair_name , @hair_index, @sex, 290, 135)
  142. change_color(normal_color)
  143. #draw_text(4, 8, 45, line_height, "#{Vocab::Name}:")
  144. #draw_text(196, 8, 60, line_height, Vocab::Class)
  145. draw_text(260, 8, 150, line_height, $data_classes[@class_id].name) if max_classes == 1
  146. #draw_text(4, 35, 45, line_height, Vocab::Sex)
  147. draw_text(490, 255, 55, line_height, @sex == Enums::Sex::MALE ? Vocab::Male : Vocab::Female, 1)
  148. #draw_text(4, 62, 70, line_height, Vocab::Graphic)
  149. #draw_text(119, 130, 25, line_height, @params[0] * 10 + $data_classes[@class_id].params[0, 1], 2)
  150. #draw_text(119, 161, 25, line_height, @params[1] * 10 + $data_classes[@class_id].params[1, 1], 2)
  151. word_wrap($data_actors[@class_id].description.delete("\n"), 210).each_with_index do |text, i|
  152. draw_text(190, line_height * i +280, contents_width, line_height, text)
  153. end
  154. #(2...8).each do |param_id|
  155. # draw_text(param_id / 4 * 189 + 119, param_id % 4 * 24 + 137, 25, line_height, $data_classes[@class_id].params[param_id, 1] + @params[param_id], 2)
  156. #end
  157. #change_color(system_color)
  158. #(0...8).each do |param_id|
  159. # Largura suficiente para os termos não abreviados
  160. # draw_text(param_id / 4 * 193 + 47, param_id % 4 * 24 + 137, 100, line_height, "#{Vocab::param(param_id)}:")
  161. #end
  162. if @points_bar
  163. @points_bar.index = @points
  164. @points_bar.text = "#{@points}/#{Configs::START_POINTS}"
  165. end
  166. @next_char.visible = @prev_char.visible = $data_classes[@class_id].graphics[@sex].size > 1
  167. end
  168.  
  169. def refresh_character
  170. @character_name = $data_classes[@class_id].graphics[@sex][@sprite_index][0]
  171. @character_index = $data_classes[@class_id].graphics[@sex][@sprite_index][1]
  172. end
  173.  
  174. def create_actor
  175. #return unless @create_button.enable
  176. if illegal_name? && $network.standard_group?
  177. $windows[:alert].show(Vocab::InvalidName)
  178. elsif invalid_name?
  179. $windows[:alert].show(Vocab::ForbiddenCharacter)
  180. else
  181. $network.send_create_actor(@actor_id, @name_box.text, @sprite_index, @class_id, @sex, @params, @hair_type, @hair_color)
  182. end
  183. end
  184.  
  185. def change_sex(sex)
  186. @sex = sex
  187. @sprite_index = 0
  188. refresh_character
  189. refresh
  190. end
  191.  
  192. def change_class
  193. @class_id = @class_box.index + 1
  194. @sprite_index = 0
  195. refresh_character
  196. refresh
  197. end
  198.  
  199. def next_character
  200. @sprite_index = @sprite_index < $data_classes[@class_id].graphics[@sex].size - 1 ? @sprite_index + 1 : 0
  201. refresh_character
  202. refresh
  203. end
  204.  
  205. def prev_character
  206. @sprite_index = @sprite_index > 0 ? @sprite_index - 1 : @sprite_index = $data_classes[@class_id].graphics[@sex].size - 1
  207. refresh_character
  208. refresh
  209. end
  210.  
  211.  
  212. #def add_param(param_id)
  213. # @points -= 1
  214. # @params[param_id] += 1
  215. # refresh
  216. # enable_buttons
  217. # end
  218.  
  219. # def remove_param(param_id)
  220. # @points += 1
  221. # @params[param_id] -= 1
  222. # refresh
  223. # enable_buttons
  224. # end
  225.  
  226. def enable_buttons
  227. # @create_button.enable = enable
  228. #@rem_hp.enable = @params[0] > 0
  229. #@rem_mp.enable = @params[1] > 0
  230. #@rem_atk.enable = @params[2] > 0
  231. #@remo_agi.enable = @params[3] > 0
  232. #@rem_def.enable = @params[4] > 0
  233. #@remo_mat.enable = @params[5] > 0
  234. #@rem_mdf.enable = @params[6] > 0
  235. # @rem_luk.enable = @params[7] > 0
  236. #enable = @points > 0
  237. #@add_hp.enable = enable
  238. # @add_mp.enable = enable
  239. # @add_atk.enable = enable
  240. # @add_agi.enable = enable
  241. #@add_def.enable = enable
  242. # @add_mat.enable = enable
  243. #@add_mdf.enable = enable
  244. #@add_luk.enable = enable
  245. end
  246.  
  247. def enable_create_button
  248. @create_button.enable = @name_box.text.strip.size >= Configs::MIN_CHARACTERS
  249. end
  250.  
  251. def update
  252. super
  253. close_windows
  254. ok if Input.trigger?(:C)
  255. end
  256.  
  257. def close_windows
  258. return unless Input.trigger?(:B)
  259. if $windows[:alert].visible || $windows[:config].visible
  260. $windows[:alert].hide
  261. $windows[:config].hide
  262. else
  263. hide
  264. end
  265. end
  266.  
  267. def ok
  268. $windows[:alert].visible ? $windows[:alert].hide : create_actor
  269. end
  270.  
  271. #========def buttons classe==========#
  272.  
  273. def protetor
  274. bitmap = Cache.system("wprotetor")
  275. #@sprite_index = 0
  276. @class_id = 1
  277. refresh_character
  278. refresh
  279. end
  280.  
  281. def guardiao
  282. bitmap = Cache.system("wguardiao")
  283. # @sprite_index = 0
  284. @class_id = 2
  285. refresh_character
  286. refresh
  287. end
  288.  
  289. #=======================================#
  290. def change_hair_type(id)
  291. @hair_type = id
  292. refresh_hair
  293. refresh
  294.  
  295.  
  296. end
  297.  
  298. def change_hair_color(id)
  299. @hair_color = id
  300. refresh_hair
  301. refresh
  302. end
  303.  
  304. def refresh_hair
  305. @hair_name = $data_armors[ (HAIRARMORIDS[@hair_type] + @hair_color)].paperdoll_name
  306. @hair_index = $data_armors[ (HAIRARMORIDS[@hair_type] + @hair_color)].paperdoll_index
  307. end
  308.  
  309.  
  310. #====================================================#
  311. end
  312.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement