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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
| //==================================
/*:
* @target MZ
* @plugindesc v1.2 Keyboard Rebind Options
* @author Nowis-337
* @url https://nowis-337.itch.io/
*
* @help Nowis337_KeyboardRebind.js
*
* - This plugin adds the option to rebind keyboard keys.
* - Features:
* * Movement presets: Arrow Keys, WASD, ZQSD, Customise your own!
* * Rebind to most keys on the keyboard (except for F1 - F12).
* * Make your own custom keynames to use (eg via scriptcalls).
* * Probably not compatible with other plugins that assign common events
* to certain keys.
* * Limitions: Cannot set more than one keys to the same function like default RPG Maker.
*
* Parameters:
* - Using Default Options Menu - disable if you are using plugins that modify
* the options menu. It just relates to functions to remember where your
* cursor in the options window was when exiting the controller rebind
* menu.
* You can call the menu with:
*
* SceneManager.push(Scene_KeyboardRebind);
*
* - Window Width - adjusts the width of the window.
*
* - Enable Movement Presets - enables the option to pick movement key presets
* as the first element in the menu.
*
* - Movement Preset List
* - Movement Preset Name - the name of the preset.
* - Preset - Put in your directional keys here. These are set as
* 'Critical' as default so they cannot be overridden.
*
* - Keybind List
* - Keybind Name - the name of the keybind displayed in the menu.
* - Key Preset - sets the keyname associated with RPG Maker default.
* - set to "Custom" to set your own keyname (see below).
* - Custom Keyname - set a custom keyname for the keybind.
* - can be used with script calls.
* - Default Input (Special) - sets the default key from the dropdown list.
* Select 'Other' to type your own (see below).
* - Default Input - type in the key here. The above option needs to be set as "Other"
* - Critical - flags the keybind to be critical. The key assigned
* to a critical keybind cannot be assigned to a different
* keybind.
* - I set this on the "Ok" button so you cannot assign this
* button to another keybind and thus erasing the "Ok"
* keybind and get stuck in the menu.
*
*
* - Text - customise menu names and messages.
*
* ============================================================================
* Free to use in non-commercial and commercial projects!
* Please credit Nowis-337
* ============================================================================
* 5/12/2022 - Fixed dispay error of movement presets when cancelling out of the menu and re-entering
* 30/9/2022 - Fixed error from copy and pasting from my other plugin.
* 5/9/2022 - Finished plugin!
*
* @param defaultOptions
* @desc Using Default Options Menu.
* @text Default Options Menu
* @type boolean
* @default true
*
* @param windowWidth
* @text Window Width
* @desc Width of of the rebind menu.
* @type number
* @default 500
*
* @param usingMovementPresets
* @desc Enable option to set movement presets.
* @text Enable Movement Presets
* @type boolean
* @default true
*
* @param MovementKeyBindList
* @text Movement Keys Preset List
* @desc The first preset will be the default.
* @type struct<MovementPresets>[]
* @default ["{\"movementPresetName\":\"Arrow Keys\",\"movementPresetStruct\":\"[\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Up\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Up\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Down\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Down\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Left\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Left\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Right\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Right\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\"]\"}","{\"movementPresetName\":\"WASD\",\"movementPresetStruct\":\"[\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Up\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"W\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Down\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"S\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Left\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"A\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Right\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"D\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\"]\"}","{\"movementPresetName\":\"ZQSD\",\"movementPresetStruct\":\"[\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Up\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"Z\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Down\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"S\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Left\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"Q\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\",\\\"{\\\\\\\"keyPreset\\\\\\\":\\\\\\\"Right\\\\\\\",\\\\\\\"defaultother\\\\\\\":\\\\\\\"Other\\\\\\\",\\\\\\\"default\\\\\\\":\\\\\\\"D\\\\\\\",\\\\\\\"critical\\\\\\\":\\\\\\\"true\\\\\\\"}\\\"]\"}"]
*
*
* @param KeybindList
* @text Keybind List
* @type struct<KeyBind>[]
* @default ["{\"keyName\":\"Select\",\"keyPreset\":\"Ok\",\"inputKey\":\"\",\"defaultother\":\"Other\",\"default\":\"Z\",\"critical\":\"true\"}","{\"keyName\":\"Cancel/Menu\",\"keyPreset\":\"Escape\",\"inputKey\":\"\",\"defaultother\":\"Other\",\"default\":\"X\",\"critical\":\"false\"}","{\"keyName\":\"Sprint\",\"keyPreset\":\"Sprint\",\"inputKey\":\"\",\"defaultother\":\"Shift\",\"default\":\"\",\"critical\":\"false\"}"]
*
*
*
*
*
* @param Text
* @param OptionLabel
* @parent Text
* @text Option Label
* @desc Name that appears in the options menu and the title of the menu.
* @type text
* @default Keyboard Config
*
* @param MovementLabel
* @parent Text
* @text Movement Preset Label
* @desc Label for Movement Presets.
* @type text
* @default Movement Preset
*
*
* @param SelectButton
* @parent Text
* @text Select Button
* @desc Instructions that appear at the bottom by default.
* @default Select key to rebind.
*
* @param PendingInput
* @parent Text
* @text Pending Input
* @default Press new key to rebind.
*
* @param ButtonUnavailable
* @parent Text
* @text Button Unavailable
* @desc Warning that appear when trying to assign a critical keybind button to another keybind.
* @default This key is already in use. Please pick another key.
*
* @param ButtonInvalid
* @parent Text
* @text Button Invalid
* @desc Warning that appear when key pressed is invalid.
* @default This key is invalid. Please pick another key.
*
*
* @param UnassignedButton
* @parent Text
* @text Unassigned Button
* @desc Warning that appear when there are unassigned keybinds.
* @default Please assign a key to all keybinds.
*
*
*/
/*~struct~MovementPresets:
* @param movementPresetName
* @text Movement Preset Name
* @desc Name of Movement Preset
* @type text
*
* @param movementPresetStruct
* @text Preset
* @type struct<MovementKeyBind>[]
*
*/
/*~struct~KeyBind:
* @param keyName
* @text Keybind Name
* @desc Name of the Keybind.
* @type text
*
* @param keyPreset
* @text Key Preset
* @desc Preset default keybind options. Select 'Custom' to customise your own.
* @type select
* @option Ok
* @option Escape
* @option Cancel
* @option Menu
* @option Sprint
* @option Up
* @option Down
* @option Left
* @option Right
* @option Custom
*
*
* @param inputKey
* @text Custom Keyname
* @desc Custom keyname for a custom keybind. Requires "Custom" under Key Preset.
* @type text
*
*
* @param defaultother
* @text Default Input (Special Keys)
* @desc Bind to default special key. Select 'Other' for other keyboard inputs below.
* @type select
* @option Other
* @option Space
* @option Enter
* @option Backspace
* @option Shift
* @option Ctrl
* @option Alt
* @option Esc
* @option Tab
* @option Del
* @option Ins
* @option Home
* @option End
* @option PgUp
* @option PgDn
* @option Capslock
* @option NumLock
* @option Up
* @option Down
* @option Left
* @option Right
* @option Num0
* @option Num1
* @option Num2
* @option Num3
* @option Num4
* @option Num5
* @option Num6
* @option Num7
* @option Num8
* @option Num9
* @option NumPeriod
* @option NumDivide
*
*
*
* @param default
* @text Default Input
* @desc Bind to default keyboard input. Select 'Other' above to use this.
* @type text
*
*
* @param critical
* @text Critical
* @desc Is this keybind critical?
* @type boolean
* @default false
*
*/
/*~struct~MovementKeyBind:
* @param keyPreset
* @text Key Preset
* @desc Preset default keybind options. Select 'Custom' to customise your own.
* @type select
* @option Up
* @option Down
* @option Left
* @option Right
*
*
* @param defaultother
* @text Default Input (Special Keys)
* @desc Bind to default special key. Select 'Other' for other keyboard inputs below.
* @type select
* @option Other
* @option Space
* @option Enter
* @option Backspace
* @option Shift
* @option Ctrl
* @option Alt
* @option Esc
* @option Tab
* @option Del
* @option Ins
* @option Home
* @option End
* @option PgUp
* @option PgDn
* @option Capslock
* @option NumLock
* @option Up
* @option Down
* @option Left
* @option Right
* @option Num0
* @option Num1
* @option Num2
* @option Num3
* @option Num4
* @option Num5
* @option Num6
* @option Num7
* @option Num8
* @option Num9
* @option NumPeriod
* @option NumDivide
*
* @param default
* @text Default Input
* @desc Bind to default keyboard input. Select 'Other' above to use this.
* @type text
*
*
* @param critical
* @text Critical
* @desc Is this keybind critical?
* @type boolean
* @default true
*
*/
var Nowis337_KeyboardRebind = {
usingDefaultOption: Boolean(JSON.parse(PluginManager.parameters("Nowis337_KeyboardRebind")["defaultOptions"])),
windowWidth: Number(PluginManager.parameters("Nowis337_KeyboardRebind")["windowWidth"]),
usingMovementPreset: Boolean(JSON.parse(PluginManager.parameters("Nowis337_KeyboardRebind")["usingMovementPresets"])),
_movementPresets: [],
_movementPresetIndex: 0,
savedCurrentKeyboardInput: null,
pendingCurrentKeyboardInput: null,
buffervalue: 10,
textTitle: PluginManager.parameters("Nowis337_KeyboardRebind")["OptionLabel"],
textMovement: PluginManager.parameters("Nowis337_KeyboardRebind")["MovementLabel"],
text1: PluginManager.parameters("Nowis337_KeyboardRebind")["SelectButton"],
text2: PluginManager.parameters("Nowis337_KeyboardRebind")["PendingInput"],
text3: PluginManager.parameters("Nowis337_KeyboardRebind")["ButtonUnavailable"],
text4: PluginManager.parameters("Nowis337_KeyboardRebind")["UnassignedButton"],
text5: PluginManager.parameters("Nowis337_KeyboardRebind")["ButtonInvalid"]
};
Nowis337_KeyboardRebind.addGamePadDelay = function(){
//if(Nowis337_ControllerRebind.gamepadRepeatFix){
// Input._gamePadDelay = 15;
//};
};
Nowis337_KeyboardRebind.createMovementPresets = function(){
let parse1 = JSON.parse(PluginManager.parameters("Nowis337_KeyboardRebind")["MovementKeyBindList"]);
let parse2 = [];
parse1.forEach(struct => parse2.push(JSON.parse(struct)));
parse2.forEach(object => object.movementPresetStruct = JSON.parse(object.movementPresetStruct));
parse2.forEach(myFunction1);
function myFunction1(object){
let array = []
object.movementPresetStruct.forEach(struct => array.push(JSON.parse(struct)));
object.movementPresetStruct = array;
};
this._movementPresets = parse2;
};
Nowis337_KeyboardRebind.currentMovementPresetData = function(){
this.createMovementPresets();
const index = this._movementPresetIndex;
let group = this._movementPresets[index].movementPresetStruct;
let array = [];
group.forEach(processingFunction);
function processingFunction(struct){
let object = {};
switch(struct["keyPreset"]){
case "Up"span style="color:#7cc4f5;"> : object.inputKey = "up"; break;
case "Down"span style="color:#7cc4f5;"> : object.inputKey = "down"; break;
case "Left"span style="color:#7cc4f5;"> : object.inputKey = "left"; break;
case "Right"span style="color:#7cc4f5;"> : object.inputKey = "right"; break;
default: object.inputKey = null;
};
let keycode;
if(struct["defaultother"] !== "Other"){
keycode = Nowis337_KeyboardRebind.findKeyCode(struct["defaultother"]);
} else {
let keycodeinput = struct["default"].toUpperCase();
keycode = Nowis337_KeyboardRebind.findKeyCode(keycodeinput);
};
object.default = keycode;
object.critical = JSON.parse(struct["critical"]);
array.push(object);
};
return array;
};
Nowis337_KeyboardRebind.createData = function(){
let rawData = JSON.parse(PluginManager.parameters("Nowis337_KeyboardRebind")["KeybindList"]);
let array = [];
rawData.forEach(processData);
function processData(struct0){
let struct = JSON.parse(struct0);
let object = {};
object.keyName = struct["keyName"];
if(struct["keyPreset"] == "Custom"){
object.inputKey = struct["inputKey"];
} else {
switch(struct["keyPreset"]){
case "Ok"span style="color:#7cc4f5;"> : object.inputKey = "ok"; break;
case "Cancel"span style="color:#7cc4f5;"> : object.inputKey = "cancel"; break;
case "Menu"span style="color:#7cc4f5;"> : object.inputKey = "menu"; break;
case "Escape"span style="color:#7cc4f5;"> : object.inputKey = "escape"; break;
case "Sprint"span style="color:#7cc4f5;"> : object.inputKey = "shift"; break;
default: object.inputKey = null;
};
};
let keycode;
if(struct["defaultother"] !== "Other"){
keycode = Nowis337_KeyboardRebind.findKeyCode(struct["defaultother"]);
} else {
let keycodeinput = struct["default"].toUpperCase();
keycode = Nowis337_KeyboardRebind.findKeyCode(keycodeinput);
};
object.default = keycode;
object.critical = JSON.parse(struct["critical"]);
object.specialfunction = "";
array.push(object);
};
this.finalData = array;
if(Nowis337_KeyboardRebind.usingMovementPreset){
this.finalData.unshift({specialfunction:"movementpreset"});
};
};
Nowis337_KeyboardRebind.findKeyCode = function(inputkeyname){
let object = Nowis337_KeyboardRebind.keyLookUp.find(object => object.name == inputkeyname);
if(object){
return object.code;
} else {
return undefined;
};
};
Nowis337_KeyboardRebind.criticalKeySymbols = function(){
let data = this.finalData;
let array = [];
data.forEach(myFunction);
function myFunction(object){
if(object.critical) array.push(object.inputKey);
};
if(this.usingMovementPreset){
let data2 = this.currentMovementPresetData();
data2.forEach(myFunction2);
function myFunction2(object){
if(object.critical) array.push(object.inputKey);
};
};
return array;
};
Nowis337_KeyboardRebind.findKeyDisplay = function(keycode){
let number = 1*keycode;
let object = Nowis337_KeyboardRebind.keyLookUp.find(object => object.code == number);
if(object){
return object.name;
} else {
return "-"
};
};
Nowis337_KeyboardRebind.currentBindedKey = function(keysymbol){
let arrayofallkeys = Object.keys(Input.keyMapper);
let currentkeycode = arrayofallkeys.find(myFunction);
function myFunction(value){
return Input.keyMapper[value] === keysymbol;
};
return currentkeycode;
};
Nowis337_KeyboardRebind.saveCurrentKeyboardInput = function(){
this.savedCurrentKeyboardInput = JSON.parse(JSON.stringify(Input.keyMapper));
};
Nowis337_KeyboardRebind.updatePendingKeyboardInput = function(){
this.pendingCurrentKeyboardInput = JSON.parse(JSON.stringify(Input.keyMapper));
};
Nowis337_KeyboardRebind.restorePendingKeyboardInput = function(){
Input.keyMapper = JSON.parse(JSON.stringify(this.pendingCurrentKeyboardInput));
};
Nowis337_KeyboardRebind.restoreSavedKeyboardInput = function(){
Input.keyMapper = JSON.parse(JSON.stringify(this.savedCurrentKeyboardInput));
};
Nowis337_KeyboardRebind.prepareKeys = function(){
};
Nowis337_KeyboardRebind.clearKeys = function(){
this.keyLookUp.forEach(clearFunction);
function clearFunction(object){
Input.keyMapper[object.code] = "";
};
};
Nowis337_KeyboardRebind.applyDefaultKeys = function(){
this.clearKeys();
if(this.usingMovementPreset){
this._movementPresetIndex = 0;
let data1 = this.currentMovementPresetData();
data1.forEach(object => Input.keyMapper[object.default] = object.inputKey);
};
let data2 = this.finalData;
data2.forEach(applyDefaultFunction);
function applyDefaultFunction(object){
if(object.specialfunction !== "") return;
if(object.default )
Input.keyMapper[object.default] = object.inputKey;
};
};
Nowis337_KeyboardRebind.checkKeyUnassigned = function(){
if(this.usingMovementPreset){
let data1 = this.currentMovementPresetData();
if(data1.some(object => this.currentBindedKey(object.inputKey))){
} else {
return true;
};
};
let data = Nowis337_KeyboardRebind.finalData;
return data.some(notAssigned);
function notAssigned(object){
if(!object.inputKey) return false;
let inputkeyname = object.inputKey;
let result = Nowis337_KeyboardRebind.currentBindedKey(inputkeyname);
if(!result) return true;
return false;
};
};
Nowis337_KeyboardRebind.listenFunction = function(event){
if(SceneManager._scene._inputBuffer > 0) return;
SceneManager._scene._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
SceneManager._scene.processInput(event.keyCode);
};
Nowis337_KeyboardRebind.addListenEvent = function(){
document.addEventListener("keydown", Nowis337_KeyboardRebind.listenFunction);
};
Nowis337_KeyboardRebind.removeListenEvent = function(){
document.removeEventListener("keydown", Nowis337_KeyboardRebind.listenFunction);
}
//========== Scene_KeyboardRebind =================
function Scene_KeyboardRebind() {
this.initialize(...arguments);
}
Scene_KeyboardRebind.prototype = Object.create(Scene_MenuBase.prototype);
Scene_KeyboardRebind.prototype.constructor = Scene_KeyboardRebind;
Scene_KeyboardRebind.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
Nowis337_KeyboardRebind.saveCurrentKeyboardInput();
Nowis337_KeyboardRebind._oldMovementPresetIndex = Nowis337_KeyboardRebind._movementPresetIndex;
this._inputBuffer = 0;
this._listeningMode = false;
this._currentPendingKey = "";
this._criticalKeySymbols = Nowis337_KeyboardRebind.criticalKeySymbols(); // array of symbols
};
Scene_KeyboardRebind.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createKeyList();
this.createConfirmWindow();
this.createHeader();
this.createMovementList();
this.createRebindPopup();
};
Scene_KeyboardRebind.prototype.update = function() {
if(this._inputBuffer > 0){
this._inputBuffer--;
};
Scene_MenuBase.prototype.update.call(this);
//if(this._listeningMode) this.listenForKeyInput();
};
Scene_KeyboardRebind.prototype.createKeyList = function(){
let datalength = Nowis337_KeyboardRebind.finalData.length;
const ww = Nowis337_KeyboardRebind.windowWidth;
const wh = this.calcWindowHeight(datalength, true);
const wx = (Graphics.boxWidth - ww)/2;
const wy = (Graphics.boxHeight - this.calcWindowHeight(1,false) - this.calcWindowHeight(1,false) - this.calcWindowHeight(3,true) - wh)/2 + this.calcWindowHeight(1,false);
const rect = new Rectangle(wx, wy, ww, wh);
this._keyList = new Window_KeyList2(rect);
this._keyList.setHandler("ok", this.keyConfirmOk.bind(this));
this._keyList.setHandler("cancel", this.keyConfirmCancel.bind(this));
this.addWindow(this._keyList);
this._keyList.refresh();
this._keyList.activate();
this._keyList.select(0);
};
Scene_KeyboardRebind.prototype.createConfirmWindow = function(){
const ww = this._keyList.width;
const wh = this.calcWindowHeight(3, true);
const wx = this._keyList.x;
const wy = this._keyList.y + this._keyList.height;
const rect = new Rectangle(wx, wy, ww, wh);
this._rebindConfirmWindow = new Window_KeyRebindConfirm2(rect);
this._rebindConfirmWindow.setHandler("ok", this.rebindConfirmOk.bind(this));
this._rebindConfirmWindow.setHandler("cancel", this.rebindConfirmCancel.bind(this));
this.addWindow(this._rebindConfirmWindow);
this._rebindConfirmWindow.deselect();
this._rebindConfirmWindow.deactivate();
this._keyList._rebindConfirmWindow = this._rebindConfirmWindow;
this._rebindConfirmWindow._keyList = this._keyList;
};
Scene_KeyboardRebind.prototype.createHeader = function(){
const text = Nowis337_KeyboardRebind.textTitle;
const ww = this._keyList.width;
const wh = this.calcWindowHeight(1, false);
const wx = this._keyList.x;
const wy = this._keyList.y - wh;
const rect = new Rectangle(wx, wy, ww, wh);
this._headerWindow = new Window_Base(rect);
this.addWindow(this._headerWindow);
const textrect = this._headerWindow.baseTextRect();
this._headerWindow.contents.clear();
this._headerWindow.drawText(text, textrect.x, textrect.y, textrect.width, "center");
};
Scene_KeyboardRebind.prototype.createMovementList = function(){
let datalength = Nowis337_KeyboardRebind._movementPresets.length;
const ww = 230;
const wh = this.calcWindowHeight(datalength, true);
const wx = this._keyList.x + this._keyList.width - 50;
const wy = this._keyList.y;
const rect = new Rectangle(wx, wy, ww, wh);
this._movementList = new Window_MovementList(rect);
this._movementList.setHandler("ok", this.movementListOk.bind(this));
this._movementList.setHandler("cancel", this.movementListCancel.bind(this));
this._movementList.openness = 0;
this.addWindow(this._movementList);
this._movementList.refresh();
this._movementList.deactivate();
this._movementList.select(-1);
};
Scene_KeyboardRebind.prototype.createRebindPopup = function(){
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(1, false);
const wx = (Graphics.boxWidth - ww)/2;
const wy = Graphics.boxHeight - wh;
const rect = new Rectangle(wx, wy, ww, wh);
this._rebindPopUp = new Window_Base(rect);
this.updateText(Nowis337_KeyboardRebind.text1);
//this._rebindPopUp.openness = 0;
this.addWindow(this._rebindPopUp);
};
Scene_KeyboardRebind.prototype.rebindConfirmOk = function(){
if(this._inputBuffer > 0) return;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
Nowis337_KeyboardRebind.addGamePadDelay();
if(this._rebindConfirmWindow.currentSymbol() == "rebinddefault"){
Nowis337_KeyboardRebind.clearKeys();
Input.gamepadMapper = Nowis337_KeyboardRebind.applyDefaultKeys();
this._keyList.refresh();
SoundManager.playSave();
Input.clear();
this._rebindConfirmWindow.activate();
};
if(this._rebindConfirmWindow.currentSymbol() == "rebindconfirm"){
if(Nowis337_KeyboardRebind.checkKeyUnassigned()){
SoundManager.playBuzzer();
this.updateText(Nowis337_KeyboardRebind.text4);
Input.clear();
this._rebindConfirmWindow.activate();
} else {
SoundManager.playSave();
this.popScene();
};
};
if(this._rebindConfirmWindow.currentSymbol() == "rebindcancel"){
SoundManager.playCancel();
Nowis337_KeyboardRebind.restoreSavedKeyboardInput();
Nowis337_KeyboardRebind._movementPresetIndex = Nowis337_KeyboardRebind._oldMovementPresetIndex;
//console.log(Nowis337_KeyboardRebind._oldMovementPresetIndex);
this.popScene();
};
}
Scene_KeyboardRebind.prototype.rebindConfirmCancel = function(){
if(this._inputBuffer > 0) return;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
Nowis337_KeyboardRebind.addGamePadDelay();
if(this._rebindConfirmWindow.index() !== 2){
this._rebindConfirmWindow.smoothSelect(2);
this._rebindConfirmWindow.activate();
Input.clear();
} else {
Nowis337_KeyboardRebind.restoreSavedKeyboardInput();
Nowis337_KeyboardRebind._movementPresetIndex = Nowis337_KeyboardRebind._oldMovementPresetIndex;
this.popScene();
}
};
Scene_KeyboardRebind.prototype.keyConfirmOk = function(){
if(this._inputBuffer > 0) return;
SoundManager.playOk();
Nowis337_KeyboardRebind.addGamePadDelay();
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
if(this._keyList._data[this._keyList.index()].specialfunction == "movementpreset"){
this._keyList.deactivate();
this._movementList.open();
this._movementList.activate();
this._movementList.select(0);
} else {
this._keyList.deactivate();
this._currentPendingKey = this._keyList._data[this._keyList.index()].inputKey;
Nowis337_KeyboardRebind.updatePendingKeyboardInput();
//this._listeningMode = true;
Nowis337_KeyboardRebind.addListenEvent();
this.updateText(Nowis337_KeyboardRebind.text2);
Input.clear();
};
};
Scene_KeyboardRebind.prototype.keyConfirmCancel = function(){
if(this._inputBuffer > 0) return;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
Nowis337_KeyboardRebind.addGamePadDelay();
this._keyList.deselect();
this._keyList.deactivate();
this._rebindConfirmWindow.activate();
this._rebindConfirmWindow.select(2);
Input.clear();
};
Scene_KeyboardRebind.prototype.movementListOk = function(){
if(this._inputBuffer > 0) return;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
Nowis337_KeyboardRebind.addGamePadDelay();
SoundManager.playSave();
let listindex = this._movementList.index();
const thisscene = this;
var flagtorebindok = false;
let previousokkeycode = Nowis337_KeyboardRebind.currentBindedKey("ok");
Nowis337_KeyboardRebind.updatePendingKeyboardInput();
//==========================================//
Nowis337_KeyboardRebind._movementPresetIndex = listindex;
let newdata = Nowis337_KeyboardRebind.currentMovementPresetData();
newdata.forEach(myFunction1);
function myFunction1(object){
let newkeycode = object.default;
let inputKey = object.inputKey;
thisscene.erasePreviousKey(inputKey);
Input.keyMapper[newkeycode] = inputKey;
if(newkeycode == previousokkeycode) flagtorebindok = true;
}
if(flagtorebindok){
//rebind ok to enter
Input.keyMapper["13"] = "ok";
};
this._movementList.deselect();
this._movementList.deactivate();
this._movementList.close();
this._keyList.refresh();
this._keyList.activate();
Input.clear();
};
Scene_KeyboardRebind.prototype.movementListCancel = function(){
if(this._inputBuffer > 0) return;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
Nowis337_KeyboardRebind.addGamePadDelay();
SoundManager.playCancel();
this._movementList.deselect();
this._movementList.deactivate();
this._movementList.close();
this._keyList.activate();
Input.clear();
};
Scene_KeyboardRebind.prototype.listenForKeyInput = function(){
//defunct
};
Scene_KeyboardRebind.prototype.keyListeningFunction = function(event){
//this.processInput(event.keyCode);
};
Scene_KeyboardRebind.prototype.isNewKeyCritical = function (keycode){
// console.log(keycode);
// console.log(this._currentPendingKey);
// console.log(this._criticalKeySymbols);
if(Nowis337_KeyboardRebind.pendingCurrentKeyboardInput[keycode] === this._currentPendingKey) return false;
if(this._criticalKeySymbols.includes(Nowis337_KeyboardRebind.pendingCurrentKeyboardInput[keycode])){
return true;
};
return false;
};
Scene_KeyboardRebind.prototype.processInput = function(keycode){
if(this.notValidInput(keycode)){
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
SoundManager.playBuzzer();
this.updateText(Nowis337_KeyboardRebind.text5);
Input.clear();
return;
};
if(this.isNewKeyCritical(keycode)){
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
SoundManager.playBuzzer();
this.updateText(Nowis337_KeyboardRebind.text3);
Input.clear();
//this._keyList.activate();
} else {
SoundManager.playOk();
Nowis337_KeyboardRebind.removeListenEvent();
let alreadyboundedkey = Nowis337_KeyboardRebind.currentBindedKey(this._currentPendingKey);
if(alreadyboundedkey !== keycode){
// erase previous
this.erasePreviousKey(this._currentPendingKey);
// apply new button
Input.keyMapper[keycode] = this._currentPendingKey;
};
//this._rebindPopUp.deactivate();
//this._listeningMode = false;
this._inputBuffer = Nowis337_KeyboardRebind.buffervalue;
this._keyList.refresh();
this._keyList.activate();
Input.clear();
this.updateText(Nowis337_KeyboardRebind.text1);
};
};
Scene_KeyboardRebind.prototype.erasePreviousKey = function(keysymbol){
let arrayofallkeys = Object.keys(Nowis337_KeyboardRebind.pendingCurrentKeyboardInput);
let currentkeycode = arrayofallkeys.find(myFunction);
function myFunction(value){
return Nowis337_KeyboardRebind.pendingCurrentKeyboardInput[value] === keysymbol;
};
Input.keyMapper[currentkeycode] = "";
};
Scene_KeyboardRebind.prototype.updateText = function(text){
const textrect = this._rebindPopUp.baseTextRect();
this._rebindPopUp.contents.clear();
this._rebindPopUp.drawText(text, textrect.x, textrect.y, textrect.width, "center");
};
Scene_KeyboardRebind.prototype.notValidInput = function(keycode){
if(Nowis337_KeyboardRebind.keyLookUp.some(object => object.code == keycode)) return false;
return true;
};
//=================== Window_KeyList2 =============================
function Window_KeyList2() {
this.initialize(...arguments);
this._rebindConfirmWindow = null;
}
Window_KeyList2.prototype = Object.create(Window_Selectable.prototype);
Window_KeyList2.prototype.constructor = Window_KeyList2;
Window_KeyList2.prototype.initialize = function(rect) {
Window_Selectable.prototype.initialize.call(this, rect);
};
Window_KeyList2.prototype.maxItems = function() {
return Nowis337_KeyboardRebind.finalData.length;
};
Window_KeyList2.prototype.drawItem = function(index) {
const rect = this.itemRect(index);
let data = this._data;
let name;
let label;
if(data[index].specialfunction == "movementpreset" && Nowis337_KeyboardRebind.usingMovementPreset){
name = Nowis337_KeyboardRebind.textMovement;
label = Nowis337_KeyboardRebind._movementPresets[Nowis337_KeyboardRebind._movementPresetIndex].movementPresetName;
} else {
name = this._data[index].keyName;
let currentbindedkey = Nowis337_KeyboardRebind.currentBindedKey(data[index].inputKey);
label = Nowis337_KeyboardRebind.findKeyDisplay(currentbindedkey);
};
this.drawText(name + ": ", rect.x - rect.width, rect.y, rect.width, "right");
this.drawText(label, rect.x, rect.y, rect.width, "center");
};
Window_KeyList2.prototype.refresh = function() {
this.updateData();
this.paint();
};
Window_KeyList2.prototype.updateData = function() {
this._data = Nowis337_KeyboardRebind.finalData;
};
Window_KeyList2.prototype.itemWidth = function() {
return Math.floor(this.innerWidth / 2);
};
Window_KeyList2.prototype.itemRect = function(index) {
const maxCols = this.maxCols();
const itemWidth = this.itemWidth();
const itemHeight = this.itemHeight();
const colSpacing = this.colSpacing();
const rowSpacing = this.rowSpacing();
const col = index % maxCols;
const row = Math.floor(index / maxCols);
const x = (col+1) * itemWidth + colSpacing / 2 - this.scrollBaseX();
const y = row * itemHeight + rowSpacing / 2 - this.scrollBaseY();
const width = itemWidth - colSpacing;
const height = itemHeight - rowSpacing;
return new Rectangle(x, y, width, height);
};
Window_KeyList2.prototype.cursorDown = function(wrap) {
const index = this.index();
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if(index < maxItems-1){
this.smoothSelect((index + maxCols) % maxItems);
} else {
this.deselect();
this.deactivate();
this._rebindConfirmWindow.activate();
this._rebindConfirmWindow.select(-1);
};
};
Window_KeyList2.prototype.cursorUp = function(wrap) {
const index = Math.max(0, this.index());
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if (index > 0) {
this.smoothSelect((index - maxCols + maxItems) % maxItems);
} else {
this.deselect();
this.deactivate();
this._rebindConfirmWindow.select(this._rebindConfirmWindow.maxItems()); //Why does it do this???
this._rebindConfirmWindow.activate();
};
};
Window_KeyRebindConfirm2.prototype.playOkSound = function() {
//SoundManager.playOk();
};
//=================== Window_KeyRebindConfirm2 =============================
function Window_KeyRebindConfirm2() {
this.initialize(...arguments);
}
Window_KeyRebindConfirm2.prototype = Object.create(Window_Command.prototype);
Window_KeyRebindConfirm2.prototype.constructor = Window_KeyRebindConfirm2;
Window_KeyRebindConfirm2.prototype.initialize = function(rect) {
Window_Command.prototype.initialize.call(this, rect);
this._keyList = null;
};
Window_KeyRebindConfirm2.prototype.makeCommandList = function() {
this.addCommand("Default", "rebinddefault");
this.addCommand("Confirm", "rebindconfirm");
this.addCommand("Cancel", "rebindcancel");
};
Window_KeyRebindConfirm2.prototype.maxItems = function() {
return 3;
};
Window_KeyRebindConfirm2.prototype.cursorDown = function(wrap) {
const index = this.index();
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if(index < maxItems-1){
this.smoothSelect((index + maxCols) % maxItems);
} else {
this.deselect();
this.deactivate();
this._keyList.activate();
this._keyList.smoothSelect(0);
};
};
Window_KeyRebindConfirm2.prototype.cursorUp = function(wrap) {
const index = Math.max(0, this.index());
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if (index > 0) {
this.smoothSelect((index - maxCols + maxItems) % maxItems);
} else {
this.deselect();
this.deactivate();
this._keyList.activate();
this._keyList.smoothSelect(this._keyList.maxItems()-1);
};
};
Window_KeyRebindConfirm2.prototype.playOkSound = function() {
//SoundManager.playOk();
};
//=================== Window_MovementList =============================
function Window_MovementList() {
this.initialize(...arguments);
}
Window_MovementList.prototype = Object.create(Window_Selectable.prototype);
Window_MovementList.prototype.constructor = Window_MovementList;
Window_MovementList.prototype.initialize = function(rect) {
Window_Selectable.prototype.initialize.call(this, rect);
};
Window_MovementList.prototype.maxItems = function() {
return Nowis337_KeyboardRebind._movementPresets.length;
};
Window_MovementList.prototype.drawItem = function(index) {
const rect = this.itemRect(index);
this.drawText(this._data[index].movementPresetName, rect.x, rect.y, rect.width, "center");
};
Window_MovementList.prototype.refresh = function() {
this.updateData();
this.paint();
};
Window_MovementList.prototype.updateData = function() {
this._data = Nowis337_KeyboardRebind._movementPresets;
};
Window_MovementList.prototype.itemWidth = function() {
return Math.floor(this.innerWidth);
};
Window_MovementList.prototype.playOkSound = function() {
//SoundManager.playOk();
};
// Saving and Loading Data
//===============================
// ConfigManager
//====================================================
const Nowis337_KeyboardRebind_ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
let config1 = Nowis337_KeyboardRebind_ConfigManager_makeData.call(this);
config1.savedKeyboardMapper = Input.keyMapper;
config1.savedMovementPresetIndex = Nowis337_KeyboardRebind._movementPresetIndex;
return config1;
};
const Nowis337_KeyboardRebind_ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
Nowis337_KeyboardRebind_ConfigManager_applyData.call(this, config);
if("savedKeyboardMapper" in config){
this.savedKeyboardMapper = config.savedKeyboardMapper;
Input.keyMapper = config.savedKeyboardMapper;
};
if("savedMovementPresetIndex" in config){
Nowis337_KeyboardRebind._movementPresetIndex = config.savedMovementPresetIndex;
};
};
const Nowis337_KeyboardRebind_ConfigManager_load = ConfigManager.load;
ConfigManager.load = function() {
Nowis337_KeyboardRebind.createData();
Nowis337_KeyboardRebind.applyDefaultKeys();
//Nowis337_KeyboardRebind._movementPresetIndex = 0;
Nowis337_KeyboardRebind_ConfigManager_load.call(this);
};
// Scene_Options
//=====================================================
const Nowis337_KeyboardRebind_Scene_Options_prototype_maxCommands = Scene_Options.prototype.maxCommands
Scene_Options.prototype.maxCommands = function() {
return Nowis337_KeyboardRebind_Scene_Options_prototype_maxCommands.call(this)+1;
};
// Window_Options
const Nowis337_KeyboardRebind_Window_Option_prototype_addGeneralOptions = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
this.addCommand(Nowis337_KeyboardRebind.textTitle, "keyboardRebind");
Nowis337_KeyboardRebind_Window_Option_prototype_addGeneralOptions.call(this);
};
const Nowis337_KeyboardRebind_Window_Option_prototype_changeValue = Window_Options.prototype.changeValue;
Window_Options.prototype.changeValue = function(symbol, value) {
Nowis337_KeyboardRebind_Window_Option_prototype_changeValue.call(this, symbol, value);
if(symbol == "keyboardRebind"){
//SoundManager.playOk();
Input.clear();
if(Nowis337_KeyboardRebind.usingDefaultOption){
Nowis337_KeyboardRebind._lastIndex = this.index();
};
SceneManager.push(Scene_KeyboardRebind);
};
};
const Nowis337_KeyboardRebind_Window_Options_prototype_statusText = Window_Options.prototype.statusText;
Window_Options.prototype.statusText = function(index) {
const symbol = this.commandSymbol(index);
if(symbol == "keyboardRebind") return "";
return Nowis337_KeyboardRebind_Window_Options_prototype_statusText.call(this, index);
};
const Nowis337_KeyboardRebind_Window_Options_prototype_initialize = Window_Options.prototype.initialize;
Window_Options.prototype.initialize = function(rect) {
Nowis337_KeyboardRebind_Window_Options_prototype_initialize.call(this,rect);
};
const Nowis337_KeyboardRebind_Scene_Options_prototype_popScene = Scene_Options.prototype.popScene;
Scene_Options.prototype.popScene = function() {
if(Nowis337_KeyboardRebind.usingDefaultOption){
Nowis337_KeyboardRebind._lastIndex = -1;
};
Nowis337_KeyboardRebind_Scene_Options_prototype_popScene.call(this);
};
const Nowis_337_KeyboardRebind_Scene_Options_createOptionsWindow = Scene_Options.prototype.createOptionsWindow;
Scene_Options.prototype.createOptionsWindow = function() {
Nowis_337_KeyboardRebind_Scene_Options_createOptionsWindow.call(this);
if(Nowis337_KeyboardRebind.usingDefaultOption){
if(Nowis337_KeyboardRebind._lastIndex!== undefined && Nowis337_KeyboardRebind._lastIndex > -1){
this._optionsWindow.select(Nowis337_KeyboardRebind._lastIndex);
Nowis337_KeyboardRebind._lastIndex = -1;
};
};
};
// APPENDIX
//================================
Nowis337_KeyboardRebind.keyLookUp =
[
{name:"Space", code: 32},
{name:"Enter", code: 13},
{name:"Backspace", code: 8},
{name:"Shift", code: 16},
{name:"Ctrl", code: 17},
{name:"Alt", code: 18},
{name:"Esc", code: 27},
{name:"Tab", code: 9},
{name:"Del", code: 46},
{name:"Ins", code: 45},
{name:"Home", code: 36},
{name:"End", code: 35},
{name:"PgUp", code: 33},
{name:"PgDn", code: 34},
{name:"Capslock", code: 20},
{name:"NumLock", code: 144},
{name:"Up", code: 38},
{name:"Down", code: 40},
{name:"Left", code: 37},
{name:"Right", code: 39},
{name:"Num1", code: 97},
{name:"Num2", code: 98},
{name:"Num3", code: 99},
{name:"Num4", code: 100},
{name:"Num5", code: 101},
{name:"Num6", code: 102},
{name:"Num7", code: 103},
{name:"Num8", code: 104},
{name:"Num9", code: 105},
{name:"Num0", code: 96},
{name:"NumPeriod", code: 110},
{name:"NumDivide", code: 111},
{name:"`", code: 192},
{name:"1", code: 49},
{name:"2", code: 50},
{name:"3", code: 51},
{name:"4", code: 52},
{name:"5", code: 53},
{name:"6", code: 54},
{name:"7", code: 55},
{name:"8", code: 56},
{name:"9", code: 57},
{name:"0", code: 48},
{name:"-", code: 189},
{name:"=", code: 187},
{name:"*", code: 106},
{name:"-", code: 109},
{name:"+", code: 107},
{name:"Q", code: 81},
{name:"W", code: 87},
{name:"E", code: 69},
{name:"R", code: 82},
{name:"T", code: 84},
{name:"Y", code: 89},
{name:"U", code: 85},
{name:"I", code: 73},
{name:"O", code: 79},
{name:"P", code: 80},
{name:"[", code: 219},
{name:"]", code: 221},
{name:"\\", code: 220},
{name:"A", code: 65},
{name:"S", code: 83},
{name:"D", code: 68},
{name:"F", code: 70},
{name:"G", code: 71},
{name:"H", code: 72},
{name:"J", code: 74},
{name:"K", code: 75},
{name:"L", code: 76},
{name:";", code: 186},
{name:"'", code: 222},
{name:"Z", code: 90},
{name:"X", code: 88},
{name:"C", code: 67},
{name:"V", code: 86},
{name:"B", code: 66},
{name:"N", code: 78},
{name:"M", code: 77},
{name:",", code: 188},
{name:".", code: 190},
{name:"/", code: 191}
];
|