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