1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
| #Window Config
#Script créé par Zeus81
#Pour ouvrir cette fenêtre de configuration faire insérer un script et écrire : Window_Config.new
if FileTest.exist?("Config.rxdata")
file = File.open("Config.rxdata", "rb")
$game_config = Marshal.load(file)
file.close
else
$game_config = [0, 256, 256, 256, 256, 256, 256, 256, 256]
end
class Window_Config < Window_Selectable
def initialize
super(0, 0, 640, 480)
@column_max = 4
@item_max = 3
@index = 0
@config = $game_config[0]
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
main
end
def main
refresh
while(@index != -1)
update
Graphics.update
Input.update
end
dispose
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 32, 608, 1, normal_color)
self.contents.fill_rect(0, 104, 608, 1, normal_color)
self.contents.fill_rect(0, 280, 608, 1, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, 0, 608, 32, "Configuration des touches", 1)
self.contents.font.size = 20
self.contents.font.color = system_color
self.contents.font.italic = true
self.contents.draw_text(0, 32, 192, 32, "Configuration actuelle :")
self.contents.draw_text(0, 288, 192, 32, "Rappel des commandes :")
self.contents.font.italic = false
self.contents.font.color = crisis_color
self.contents.draw_text(0, 64, 200, 32, "Changer de configuration", 1)
self.contents.draw_text(204, 64, 200, 32, "Sauvegarder les modifications", 1)
self.contents.draw_text(408, 64, 200, 32, "Quitter sans sauvegarder", 1)
self.contents.draw_text(12, 112, 128, 32, "Type Standard", 1)
self.contents.draw_text(164, 112, 128, 32, "Type A", 1)
self.contents.draw_text(316, 112, 128, 32, "Type B", 1)
self.contents.draw_text(468, 112, 128, 32, "Type Perso", 1)
self.contents.font.color = normal_color
case $game_config[0]
when 0
self.contents.draw_text(192, 32, 416, 32, "Type Standard")
when 1
self.contents.draw_text(192, 32, 416, 32, "Type A")
when 2
self.contents.draw_text(192, 32, 416, 32, "Type B")
when 3
self.contents.draw_text(192, 32, 416, 32, "Type Perso")
end
self.contents.draw_text(4, 144, 92, 32, "Touche A = ")
self.contents.draw_text(4, 176, 92, 32, "Touche B = ")
self.contents.draw_text(4, 208, 92, 32, "Touche C = ")
self.contents.draw_text(4, 240, 92, 32, "Touche L = ")
self.contents.draw_text(308, 144, 92, 32, "Touche X = ")
self.contents.draw_text(308, 176, 92, 32, "Touche Y = ")
self.contents.draw_text(308, 208, 92, 32, "Touche Z = ")
self.contents.draw_text(308, 240, 92, 32, "Touche R = ")
self.contents.draw_text(96, 144, 208, 32, Input.input_name(Input::A, @config))
self.contents.draw_text(96, 176, 208, 32, Input.input_name(Input::B, @config))
self.contents.draw_text(96, 208, 208, 32, Input.input_name(Input::C, @config))
self.contents.draw_text(96, 240, 208, 32, Input.input_name(Input::L, @config))
self.contents.draw_text(404, 144, 208, 32, Input.input_name(Input::X, @config))
self.contents.draw_text(404, 176, 208, 32, Input.input_name(Input::Y, @config))
self.contents.draw_text(404, 208, 208, 32, Input.input_name(Input::Z, @config))
self.contents.draw_text(404, 240, 208, 32, Input.input_name(Input::R, @config))
self.contents.draw_text(4, 320, 300, 32, "Touche A : Rien")
self.contents.draw_text(4, 352, 300, 32, "Touche B : Ouvrir le menu / Annuler")
self.contents.draw_text(4, 384, 300, 32, "Touche C : Action / Valider")
self.contents.draw_text(4, 416, 300, 32, "Touche L : Précédent")
self.contents.draw_text(308, 320, 300, 32, "Touche X : Rien")
self.contents.draw_text(308, 352, 300, 32, "Touche Y : Rien")
self.contents.draw_text(308, 384, 300, 32, "Touche Z : Rien")
self.contents.draw_text(308, 416, 300, 32, "Touche R : Suivant")
end
def update
if @item_max == 3
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@index = 2
elsif Input.trigger?(Input::C)
case @index
when 0
$game_system.se_play($data_system.decision_se)
@item_max = 4
@index = @config
when 1
$game_system.se_play($data_system.save_se)
@index = -1
file = File.open("Config.rxdata", "wb")
Marshal.dump($game_config, file)
file.close
when 2
$game_system.se_play($data_system.cancel_se)
@index = -1
file = File.open("Config.rxdata", "rb")
$game_config = Marshal.load(file)
file.close
end
end
else
if @config != @index
@config = @index
refresh
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@item_max = 3
@index = 0
@config = $game_config[0]
refresh
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @index == 3
update_config_perso
end
$game_config[0] = @config
refresh
end
end
super
end
def update_config_perso
exceptions = [37,38,39,40,112,113,114,115,116,117,118,119,120,121,122,123]
input = nil
for i in 0..7
if i < 6
self.cursor_rect.set(i/3*304, 128+16+i%3*32, 300, 32)
else
self.cursor_rect.set(i/7*304, 224+16, 300, 32)
end
10.times do
Graphics.update
end
loop do
Graphics.update
input = Input.check
if exceptions.include?(input)
$game_system.se_play($data_system.buzzer_se)
10.times do
Graphics.update
end
elsif input != nil
break
end
end
$game_system.se_play($data_system.decision_se)
$game_config[i+1] = input
exceptions.push(input)
refresh
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
if @item_max == 3
x = @index*204
y = 64
w = 200
else
x = @index*152+12
y = 112
w = 128
end
self.cursor_rect.set(x, y, w, 32)
end
end
module Input
Touches = []
for i in 0...256
Touches[i] = "key_" + i.to_s
end
Touches[1] = "Click_Gauche"
Touches[2] = "Click_Droit"
Touches[4] = "Click_Milieu"
Touches[5] = "Click_4"
Touches[6] = "Click_5"
Touches[8] = "Retour"
Touches[9] = "Tab"
Touches[13] = "Entrée_et_Num_Entrée"
Touches[16] = "Maj_Gauche_et_Droit"
Touches[17] = "Ctrl_Gauche_et_Droit"
Touches[18] = "Alt_et_Alt_Gr"
Touches[19] = "Pause"
Touches[20] = "Verr_Maj"
Touches[27] = "Echap"
Touches[32] = "Espace"
Touches[33] = "Page_Précédente"
Touches[34] = "Page_Suivante"
Touches[35] = "Fin"
Touches[36] = "Origine"
Touches[37] = "Flèche_Gauche"
Touches[38] = "Flèche_Haut"
Touches[39] = "Flèche_Droite"
Touches[40] = "Flèche_Bas"
Touches[44] = "Impression_Ecran"
Touches[45] = "Inser"
Touches[46] = "Suppr"
Touches[48] = "0"
Touches[49] = "1"
Touches[50] = "2"
Touches[51] = "3"
Touches[52] = "4"
Touches[53] = "5"
Touches[54] = "6"
Touches[55] = "7"
Touches[56] = "8"
Touches[57] = "9"
Touches[65] = "A"
Touches[66] = "B"
Touches[67] = "C"
Touches[68] = "D"
Touches[69] = "E"
Touches[70] = "F"
Touches[71] = "G"
Touches[72] = "H"
Touches[73] = "I"
Touches[74] = "J"
Touches[75] = "K"
Touches[76] = "L"
Touches[77] = "M"
Touches[78] = "N"
Touches[79] = "O"
Touches[80] = "P"
Touches[81] = "Q"
Touches[82] = "R"
Touches[83] = "S"
Touches[84] = "T"
Touches[85] = "U"
Touches[86] = "V"
Touches[87] = "W"
Touches[88] = "X"
Touches[89] = "Y"
Touches[90] = "Z"
Touches[91] = "Windows_Gauche"
Touches[92] = "Windows_Droit"
Touches[93] = "Applications"
Touches[96] = "Num_0"
Touches[97] = "Num_1"
Touches[98] = "Num_2"
Touches[99] = "Num_3"
Touches[100] = "Num_4"
Touches[101] = "Num_5"
Touches[102] = "Num_6"
Touches[103] = "Num_7"
Touches[104] = "Num_8"
Touches[105] = "Num_9"
Touches[106] = "Num_*"
Touches[107] = "Num_+"
Touches[109] = "Num_-"
Touches[110] = "Num_."
Touches[111] = "Num_/"
Touches[112] = "F1"
Touches[113] = "F2"
Touches[114] = "F3"
Touches[115] = "F4"
Touches[116] = "F5"
Touches[117] = "F6"
Touches[118] = "F7"
Touches[119] = "F8"
Touches[120] = "F9"
Touches[121] = "F10"
Touches[122] = "F11"
Touches[123] = "F12"
Touches[144] = "Verr_Num"
Touches[145] = "Arrêt_Défil"
Touches[160] = "Maj_Gauche"
Touches[161] = "Maj_Droit"
Touches[162] = "Ctrl_Gauche"
Touches[163] = "Ctrl_Droit"
Touches[164] = "Alt"
Touches[165] = "Alt_Gr"
Touches[186] = "£"
Touches[187] = "+"
Touches[188] = "?"
Touches[190] = "."
Touches[191] = "/"
Touches[192] = "%"
Touches[219] = "°"
Touches[220] = "µ"
Touches[221] = "¨"
Touches[222] = "²"
Touches[223] = "§"
Touches[226] = ">"
AsyncKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
@last_dir = 0
@state = []
@last_state = []
@repeat_state = []
for i in 0..32
@state[i] = 0
@last_state[i] = 0
@repeat_state[i] = 0
end
module_function
def check
exceptions = [16, 17, 18]
for i in 0...256
if exceptions.include?(i) == false and AsyncKeyState.call(i) != 0
if i == 162 and AsyncKeyState.call(165) != 0
return 165
end
return i
end
end
return nil
end
def key_name(i)
return Touches[i] == nil ? "..." : Touches[i]
end
def input_name(input, i)
case input
when A
inputs = input_A(i)
when B
inputs = input_B(i)
when C
inputs = input_C(i)
when X
inputs = input_X(i)
when Y
inputs = input_Y(i)
when Z
inputs = input_Z(i)
when L
inputs = input_L(i)
when R
inputs = input_R(i)
end
name = key_name(inputs[0])
for i in 1...inputs.size
name += " / " + key_name(inputs[i])
end
return name
end
def input_A(i)
case i
when 0
return [90, 16]
when 1
return [107]
when 2
return [87]
when 3
return [$game_config[1]]
end
end
def input_B(i)
case i
when 0
return [88, 96, 27]
when 1
return [96]
when 2
return [88]
when 3
return [$game_config[2]]
end
end
def input_C(i)
case i
when 0
return [67, 13, 32]
when 1
return [13]
when 2
return [67]
when 3
return [$game_config[3]]
end
end
def input_X(i)
case i
when 0
return [65]
when 1
return [97]
when 2
return [81]
when 3
return [$game_config[4]]
end
end
def input_Y(i)
case i
when 0
return [83]
when 1
return [98]
when 2
return [83]
when 3
return [$game_config[5]]
end
end
def input_Z(i)
case i
when 0
return [68]
when 1
return [99]
when 2
return [68]
when 3
return [$game_config[6]]
end
end
def input_L(i)
case i
when 0
return [81, 33]
when 1
return [100]
when 2
return [65]
when 3
return [$game_config[7]]
end
end
def input_R(i)
case i
when 0
return [87, 34]
when 1
return [101]
when 2
return [90]
when 3
return [$game_config[8]]
end
end
def input?(input)
result = 0
case input
when SHIFT
result = AsyncKeyState.call(16)
when CTRL
result = AsyncKeyState.call(17)
when ALT
result = AsyncKeyState.call(18)
when F5
result = AsyncKeyState.call(116)
when F6
result = AsyncKeyState.call(117)
when F7
result = AsyncKeyState.call(118)
when F8
result = AsyncKeyState.call(119)
when F9
result = AsyncKeyState.call(120)
when DOWN
result = AsyncKeyState.call(40)
when LEFT
result = AsyncKeyState.call(37)
when RIGHT
result = AsyncKeyState.call(39)
when UP
result = AsyncKeyState.call(38)
when A
inputs = input_A($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when B
inputs = input_B($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when C
inputs = input_C($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when X
inputs = input_X($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when Y
inputs = input_Y($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when Z
inputs = input_Z($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when L
inputs = input_L($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
when R
inputs = input_R($game_config[0])
for i in 0...inputs.size
result += AsyncKeyState.call(inputs[i])
end
end
return result
end
def update
for input in 0..32
@repeat_state[input] += 1
@last_state[input] = @state[input]
@state[input] = 0
case input
when 1
@state[input] = 1 if (input?(DOWN)!=0 and input?(LEFT)!=0)
when 3
@state[input] = 1 if (input?(DOWN)!=0 and input?(RIGHT)!=0)
when 7
@state[input] = 1 if (input?(UP)!=0 and input?(LEFT)!=0)
when 9
@state[input] = 1 if (input?(UP)!=0 and input?(RIGHT)!=0)
else
@state[input] = input?(input)
end
end
end
def trigger?(input)
return (@state[input] != 0 and @last_state[input] == 0)
end
def repeat?(input)
if @state[input] != 0
if @repeat_state[input] == 1
return true
elsif @repeat_state[input] > 15
return ((@repeat_state[input]-16)%4 == 0)
end
else
@repeat_state[input] = 0
end
return false
end
def press?(input)
return @state[input] != 0
end
def dir4
if press?(DOWN) and press?(LEFT)
if @last_dir == DOWN
return @last_state[DOWN] != 0 ? 4 : 2
else
return @last_state[DOWN] != 0 ? 2 : 4
end
elsif press?(DOWN) and press?(RIGHT)
if @last_dir == DOWN
return @last_state[DOWN] != 0 ? 6 : 2
else
return @last_state[DOWN] != 0 ? 2 : 6
end
elsif press?(UP) and press?(LEFT)
if @last_dir == UP
return @last_state[UP] != 0 ? 4 : 8
else
return @last_state[UP] != 0 ? 8 : 4
end
elsif press?(UP) and press?(RIGHT)
if @last_dir == UP
return @last_state[UP] != 0 ? 6 : 8
else
return @last_state[UP] != 0 ? 8 : 6
end
elsif press?(DOWN) and press?(UP)
return 0
elsif press?(LEFT) and press?(RIGHT)
return 0
elsif press?(DOWN)
@last_dir = DOWN
return 2
elsif press?(LEFT)
@last_dir = LEFT
return 4
elsif press?(RIGHT)
@last_dir = RIGHT
return 6
elsif press?(UP)
@last_dir = UP
return 8
else
return 0
end
end
def dir8
if press?(DOWN) and press?(LEFT)
return 1
elsif press?(DOWN) and press?(RIGHT)
return 3
elsif press?(UP) and press?(LEFT)
return 7
elsif press?(UP) and press?(RIGHT)
return 9
elsif press?(DOWN) and press?(UP)
return 0
elsif press?(LEFT) and press?(RIGHT)
return 0
elsif press?(DOWN)
return 2
elsif press?(LEFT)
return 4
elsif press?(RIGHT)
return 6
elsif press?(UP)
return 8
else
return 0
end
end
end |