-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathRS_Window_KoreanNameInput.js
1242 lines (1158 loc) · 42 KB
/
RS_Window_KoreanNameInput.js
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
//================================================================
// RS_Window_KoreanNameInput.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2018 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @plugindesc <RS_Window_KoreanNameInput>
* @author biud436
*
* @param Font Size
* @desc Specify the font size in name processing.
* @default 28
*
* @param Line Height
* @desc Specify the line height for window.
* @default 36
*
* @param Window Width
* @desc Calculate the window width.
* @default 480
*
* @param Window Height
* @desc Calculate the window height.
* @default this.fittingHeight(6);
*
* @param Default Button Width
* @desc Specify the default button width.
* @default Math.floor(this.width/this.maxCols());
*
* @param Center Spacing
* @desc Specify the spacing value in the middle space.
* @default 0
*
* @param Button Type
* @type boolean
* @desc Sets the button width how to calculate the width.
* @default false
* @on Crop
* @off Expand
*
* @param Help Message
*
* @param messageForTouching
* @parent Help Message
* @desc
* @default The input mode has been switched to touch mode.
*
* @param messageForDirectMode
* @parent Help Message
* @desc
* @default The input mode has been switched to direct input mode.
*
* @param messageForPc
* @parent Help Message
* @desc
* @default Enter your own name directly on the keyboard.
*
* @param messageForMobile
* @parent Help Message
* @desc
* @default Use your finger to touch the desired letter.
*
* @help
* =============================================================================
* Pliugin Commands
* =============================================================================
* OpenKoreanNameInput actorId digits
*
* actorId : if this value is to 'leader', it will automatically set up by the name of the player.
* digits : The maximum length of the name string. the default value is to 6.
*
* =============================================================================
* Description
* =============================================================================
* This plugin provides a Korean character input system for RPG Maker MV,
* allowing proper Hangul composition that follows Korean language rules.
*
* The system supports both direct keyboard input and touch-based input methods,
* with automatic detection for PC and mobile platforms.
*
* It includes a complete set of Korean consonants and vowels (jamo),
* allowing users to create any possible Korean syllable.
*
* =============================================================================
* Features
* =============================================================================
* 1. Dual Input Methods:
* - Direct keyboard input for PC users
* - Touch-based input for mobile users
*
* 2. Korean/English Toggle:
* - Switch between Korean and English character sets using the 한/영 key
*
* 3. Help System:
* - Contextual tips displayed in a help window
* - Different messages for different platforms and input modes
*
* 4. Full Hangul Support:
* - Complete character composition following Korean language rules
* - Support for all consonants, vowels, and combined syllables
*
* 5. Customization:
* - Adjustable window sizes and positions
* - Customizable button sizing and layout
* - Editable help messages
*
* =============================================================================
* Usage Tips
* =============================================================================
* - For PC users: You can type directly with your keyboard. The plugin will
* automatically compose Hangul characters according to Korean typing rules.
*
* - For mobile users: Touch the on-screen keyboard to select characters.
*
* - To switch between Korean and English, use the 한/영 button.
*
* - The numeric keypad on the right side of the keyboard can be used for
* entering numbers.
*
* - Spacing, backspace, and confirmation buttons are available at the
* bottom of the input window.
*
* =============================================================================
* Technical Notes
* =============================================================================
* This plugin utilizes the Hangul.js library for Korean character processing.
* The library handles the complex rules of jamo combination to form complete
* Korean syllables.
*
* Window_KoreanNameInput extends the default Window_NameInput class.
* Window_KoreanNameEdit extends the default Window_NameEdit class.
* Scene_KoreanName extends the default Scene_Name class.
* =============================================================================
* Change Log
* =============================================================================
* 2018.03.13 (v1.0.0) - First Release.
* 2018.10.26 (v1.0.1) :
* - Added the help window.
* - You can switch the name input mode between direct mode and touch mode, and indicate corresponding message to help window.
* 2018.11.28 (v1.0.2) :
* - 한/영 키 추가.
* - The help text would always be displayed up to top.
* - 오른쪽 숫자 패드로 숫자 입력 가능.
* 2019.05.30 (v1.0.3) :
* - 마지막 글자가 입력되지 않는 문제를 수정하였습니다.
* - 이름이 허용 글자 수보다 더 큰 경우 발생하는 문제를 수정하였습니다.
*/
/*:ko
* @plugindesc <RS_Window_KoreanNameInput>
* @author biud436
*
* @param Font Size
* @text 폰트 크기
* @desc Specify the font size in name processing.
* @default 28
*
* @param Line Height
* @text 라인 크기
* @desc Specify the line height for window.
* @default 36
*
* @param Window Width
* @text 창 폭
* @desc Calculate the window width.
* @default 480
*
* @param Window Height
* @text 창 높이
* @desc Calculate the window height.
* @default this.fittingHeight(6);
*
* @param Default Button Width
* @text 기본 버튼 폭
* @desc Specify the default button width.
* @default Math.floor(this.width/this.maxCols());
*
* @param Center Spacing
* @text 중간 간격
* @desc Specify the spacing value in the middle space.
* @default 0
*
* @param Button Type
* @text 버튼 형식
* @type boolean
* @desc Sets the button width how to calculate the width.
* @default false
* @on 자르기(Crop)
* @off 확장(Expand)
*
* @param Help Message
* @text 도움말 / 툴팁 설정
*
* @param messageForTouching
* @text 터치 모드
* @parent Help Message
* @desc
* @default 터치 방식으로 전환되었습니다.
*
* @param messageForDirectMode
* @text 직접 입력 모드
* @parent Help Message
* @desc
* @default 직접 입력 모드로 전환되었습니다.
*
* @param messageForPc
* @text 직접 타이핑
* @parent Help Message
* @desc
* @default 키보드로 직접 원하는 이름을 입력 하세요.
*
* @param messageForMobile
* @text 직접 터치
* @parent Help Message
* @desc
* @default 손가락으로 원하는 자/모음을 터치하세요.
*
* @help
* =============================================================================
* 플러그인 명령
* =============================================================================
* OpenKoreanNameInput actorId digits
*
* actorId : leader면 자동으로 게임 플레이어의 이름으로 설정됩니다.
* digits : 지정할 이름의 최대 길이로 기본값은 6입니다.
*
* =============================================================================
* 설명
* =============================================================================
* 이 플러그인은 RPG Maker MV를 위한 한글 문자 입력 시스템을 제공하여
* 한글 규칙에 따라 적절한 한글 작성이 가능하도록 합니다.
*
* 직접 키보드 입력과 터치 기반 입력 방식을 모두 지원하며,
* PC와 모바일 플랫폼을 자동으로 감지합니다.
*
* 모든 한글 자음과 모음(자모)의 전체 세트를 포함하여
* 사용자가 가능한 모든 한글 음절을 만들 수 있습니다.
*
* =============================================================================
* 특징
* =============================================================================
* 1. 이중 입력 방식:
* - PC 사용자를 위한 직접 키보드 입력
* - 모바일 사용자를 위한 터치 기반 입력
*
* 2. 한/영 전환:
* - 한/영 키를 사용하여 한글과 영문 문자 세트 간 전환
*
* 3. 도움말 시스템:
* - 도움말 창에 표시되는 상황별 팁
* - 다양한 플랫폼 및 입력 모드에 대한 다양한 메시지
*
* 4. 완전한 한글 지원:
* - 한국어 언어 규칙에 따른 완전한 문자 구성
* - 모든 자음, 모음 및 조합된 음절 지원
*
* 5. 커스터마이징:
* - 조정 가능한 창 크기 및 위치
* - 맞춤 가능한 버튼 크기 및 레이아웃
* - 편집 가능한 도움말 메시지
*
* =============================================================================
* 사용 팁
* =============================================================================
* - PC 사용자: 키보드로 직접 입력할 수 있습니다. 플러그인은 한글 타이핑 규칙에 따라
* 자동으로 한글 문자를 구성합니다.
*
* - 모바일 사용자: 화면의 키보드를 터치하여 문자를 선택합니다.
*
* - 한글과 영어 간 전환하려면 한/영 버튼을 사용하세요.
*
* - 키보드 오른쪽에 있는 숫자 키패드를 사용하여 숫자를 입력할 수 있습니다.
*
* - 띄어쓰기, 백스페이스 및 확인 버튼은 입력 창 하단에서 사용할 수 있습니다.
*
* =============================================================================
* 기술적 참고사항
* =============================================================================
* 이 플러그인은 한글 문자 처리를 위해 Hangul.js라는 검증된 라이브러리를 포함합니다.
* 이 라이브러리는 완전한 한글 음절을 형성하기 위한 자모 결합의 복잡한 규칙을 처리합니다.
*
* Window_KoreanNameInput은 기본 Window_NameInput 클래스를 확장합니다.
* Window_KoreanNameEdit은 기본 Window_NameEdit 클래스를 확장합니다.
* Scene_KoreanName은 기본 Scene_Name 클래스를 확장합니다.
*
* =============================================================================
* Change Log
* =============================================================================
* 2018.03.13 (v1.0.0) - First Release.
* 2018.10.26 (v1.0.1) :
* - 툴팁을 표시하는 창을 추가했습니다.
* - 직접 입력과 터치 모드를 전환할 수 있으며 툴팁에 표시됩니다.
* 2018.11.28 (v1.0.2) :
* - 한/영 전환 기능이 추가되었습니다.
* - 도움말 텍스트가 항상 위로 올라오게 됩니다.
* - 오른쪽 숫자 패드로 숫자 입력 가능.
* 2019.05.30 (v1.0.3) :
* - 마지막 글자가 입력되지 않는 문제를 수정하였습니다.
* - 이름이 허용 글자 수보다 더 큰 경우 발생하는 문제를 수정하였습니다.
*/
var Imported = Imported || {};
Imported.RS_Window_KoreanNameInput = true;
var RS = RS || {};
RS.Window_KoreanNameInput = RS.Window_KoreanNameInput || {};
RS.Window_KoreanNameInput.Params = RS.Window_KoreanNameInput.Params || {};
(function () {
var parameters = $plugins.filter(function (i) {
return i.description.contains('<RS_Window_KoreanNameInput>');
});
parameters = parameters.length > 0 && parameters[0].parameters;
RS.Window_KoreanNameInput.Params.fontSize = parseInt(
parameters['Font Size'] || 28
);
RS.Window_KoreanNameInput.Params.windowWidthEval =
parameters['Window Width'] || '480';
RS.Window_KoreanNameInput.Params.windowHeightEval =
parameters['Window Height'] || 'this.fittingHeight(6);';
RS.Window_KoreanNameInput.Params.lineHeight = parseInt(
parameters['Line Height'] || 36
);
RS.Window_KoreanNameInput.Params.buttonWidth =
parameters['Default Button Width'] || '42';
RS.Window_KoreanNameInput.Params.isCropped = Boolean(
parameters['Button Type'] === 'true'
);
RS.Window_KoreanNameInput.Params.centerSpacing = parseInt(
parameters['Center Spacing'] || 0
);
RS.Window_KoreanNameInput.Params.fillLife = 3;
RS.Window_KoreanNameInput.Params.messageForTouching =
parameters['messageForTouching'] || '터치 방식으로 전환되었습니다.';
RS.Window_KoreanNameInput.Params.messageForDirectMode =
parameters['messageForDirectMode'] || '직접 입력 모드로 전환되었습니다.';
RS.Window_KoreanNameInput.Params.messageForPc =
parameters['messageForPc'] || '키보드로 직접 원하는 이름을 입력 하세요.';
RS.Window_KoreanNameInput.Params.messageForMobile =
parameters['messageForMobile'] || '손가락으로 원하는 자/모음을 터치하세요.';
function Window_KoreanNameInput() {
this.initialize.apply(this, arguments);
}
Window_KoreanNameInput.prototype = Object.create(Window_NameInput.prototype);
Window_KoreanNameInput.prototype.constructor = Window_KoreanNameInput;
Window_KoreanNameInput.KOREAN = [
'ㅂ',
'ㅈ',
'ㄷ',
'ㄱ',
'ㅅ',
'ㅛ',
'ㅕ',
'ㅑ',
'ㅐ',
'ㅔ',
'ㅃ',
'ㅉ',
'ㄸ',
'ㄲ',
'ㅆ',
'',
'',
'',
'ㅒ',
'ㅖ',
'ㅁ',
'ㄴ',
'ㅇ',
'ㄹ',
'ㅎ',
'ㅗ',
'ㅓ',
'ㅏ',
'ㅣ',
'',
'ㅋ',
'ㅌ',
'ㅊ',
'ㅍ',
'ㅠ',
'ㅜ',
'ㅡ',
'',
'',
'',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
'',
'한/영',
'',
'',
'',
'',
'',
'띄어쓰기',
'백스페이스',
'확인',
];
Window_KoreanNameInput.KOREAN2 = [
'A',
'B',
'C',
'D',
'E',
'a',
'b',
'c',
'd',
'e',
'F',
'G',
'H',
'I',
'J',
'f',
'g',
'h',
'i',
'j',
'K',
'L',
'M',
'N',
'O',
'k',
'l',
'm',
'n',
'o',
'P',
'Q',
'R',
'S',
'T',
'p',
'q',
'r',
's',
't',
'U',
'V',
'W',
'X',
'Y',
'u',
'v',
'w',
'x',
'y',
'Z',
'[',
']',
'^',
'_',
'z',
'{',
'}',
'|',
'~',
'0',
'1',
'2',
'3',
'4',
'!',
'#',
'$',
'%',
'&',
'5',
'6',
'7',
'8',
'9',
'(',
')',
'*',
'+',
'-',
'',
'한/영',
'',
'',
'',
'',
'',
'띄어쓰기',
'백스페이스',
'확인',
];
Window_KoreanNameInput.prototype.initialize = function (editWindow) {
var self = this;
this._dataFromTable = {};
this._dataFromTable.maxItems = Window_KoreanNameInput.KOREAN.length;
this._dataFromTable.okIndex = Window_KoreanNameInput.KOREAN.indexOf('확인');
this._dataFromTable.backIndex =
Window_KoreanNameInput.KOREAN.indexOf('백스페이스');
this._dataFromTable.spaceIndex =
Window_KoreanNameInput.KOREAN.indexOf('띄어쓰기');
this._dataFromTable.specificIndex =
Window_KoreanNameInput.KOREAN.indexOf('한/영');
Window_NameInput.prototype.initialize.call(this, editWindow);
};
Window_KoreanNameInput.prototype.standardFontSize = function () {
return RS.Window_KoreanNameInput.Params.fontSize;
};
Window_KoreanNameInput.prototype.lineHeight = function () {
return RS.Window_KoreanNameInput.Params.lineHeight;
};
Window_KoreanNameInput.prototype.windowHeight = function () {
return this._page === 0 ? this.fittingHeight(6) : this.fittingHeight(9);
};
Window_KoreanNameInput.prototype.table = function () {
return [Window_KoreanNameInput.KOREAN, Window_KoreanNameInput.KOREAN2];
};
Window_KoreanNameInput.prototype.maxCols = function () {
return 10;
};
Window_KoreanNameInput.prototype.maxItems = function () {
return this.table().length;
};
Window_KoreanNameInput.prototype.cursorPagedown = function () {
this._page = (this._page + 1) % this.table().length;
this.refresh();
};
Window_KoreanNameInput.prototype.character = function (index) {
index = index || this._index;
var c = this.table()[this._page][index];
var exclude = ['띄어쓰기', '백스페이스', '확인', '한/영'];
var isCharacter = exclude.indexOf(c) === -1;
if (isCharacter) {
return c;
} else {
return '';
}
};
Window_KoreanNameInput.prototype.isPageChange = function () {
return false;
};
Window_KoreanNameInput.prototype.processCursorMove = function () {
var lastPage = this._page;
Window_Selectable.prototype.processCursorMove.call(this);
this.updateCursor();
if (this._page !== lastPage) {
SoundManager.playCursor();
}
};
Window_KoreanNameInput.prototype.updateCursor = function () {
var rect = this.itemRect(this._index);
this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
};
Window_KoreanNameInput.prototype.cursorPagedown = function () {};
Window_KoreanNameInput.prototype.cursorPageup = function () {};
Window_KoreanNameInput.prototype.cursorDown = function (wrap) {
var max = this._dataFromTable.maxItems;
var done = false;
var temp = this._index;
var depth = 0;
while (!done) {
if (temp < max - 10 || wrap) {
if (temp > max - 20) {
if (temp % 10 < 7) {
temp = this._dataFromTable.spaceIndex;
} else {
temp = (temp + 10) % max;
}
} else {
temp = (temp + 10) % max;
}
}
var c = this.table()[this._page][temp];
if (c !== '') {
this._index = temp;
done = true;
depth = 0;
}
depth++;
if (depth > 10) break;
}
};
Window_KoreanNameInput.prototype.cursorUp = function (wrap) {
var max = this._dataFromTable.maxItems;
var done = false;
var temp = this._index;
var depth = 0;
while (!done) {
if (temp >= 10 || wrap) {
temp = (temp + max - 10) % max;
}
var c = this.table()[this._page][temp];
if (c !== '') {
this._index = temp;
done = true;
depth = 0;
}
depth++;
if (depth > 10) break;
}
};
Window_KoreanNameInput.prototype.cursorRight = function (wrap) {
var temp = this._index;
var done = false;
var depth = 0;
while (!done) {
if (temp % 10 < 9) {
temp++;
} else if (wrap) {
temp -= 9;
}
var c = this.table()[this._page][temp];
if (c !== '') {
this._index = temp;
done = true;
depth = 0;
}
depth++;
if (depth > 10) break;
}
};
Window_KoreanNameInput.prototype.cursorLeft = function (wrap) {
var temp = this._index;
var done = false;
var depth = 0;
while (!done) {
if (temp % 10 > 0) {
temp--;
} else if (wrap) {
temp += 9;
}
var c = this.table()[this._page][temp];
if (c !== '') {
this._index = temp;
done = true;
}
depth++;
if (depth > 10) break;
}
};
Window_KoreanNameInput.prototype.processHandling = function () {
if (this.isOpen() && this.active) {
if (Input.isRepeated('cancel')) {
this.processBack();
}
if (Input.isRepeated('ok')) {
this.processOk();
}
}
};
Window_KoreanNameInput.prototype.hitTest = function (x, y) {
var maxItems = this._dataFromTable.maxItems;
if (this.isContentsArea(x, y)) {
var cx = x - this.padding;
var cy = y - this.padding;
var topIndex = this.topIndex();
for (var i = 0; i < this.maxPageItems(); i++) {
var index = topIndex + i;
if (index < maxItems) {
var rect = this.itemRect(index);
var right = rect.x + rect.width;
var bottom = rect.y + rect.height;
if (cx >= rect.x && cy >= rect.y && cx < right && cy < bottom) {
var c = this.table()[this._page][index];
if (c !== '') {
return index;
}
}
}
}
}
return -1;
};
Window_KoreanNameInput.prototype.itemRect = function (index) {
var w = eval(RS.Window_KoreanNameInput.Params.buttonWidth);
var c = RS.Window_KoreanNameInput.Params.centerSpacing;
var lineHeight = this.lineHeight();
if (!RS.Window_KoreanNameInput.Params.isCropped) {
if (
index === this._dataFromTable.spaceIndex ||
index === this._dataFromTable.backIndex ||
index === this._dataFromTable.okIndex
) {
w = this.contentsWidth() / 6;
return {
x: this.contentsWidth() / 2 + (index % 3) * w,
y: Math.floor(index / 10) * lineHeight,
width: w,
height: lineHeight,
};
}
}
return {
x: (index % 10) * w + Math.floor((index % 10) / 5) * c,
y: Math.floor(index / 10) * lineHeight,
width: w,
height: lineHeight,
};
};
Window_KoreanNameInput.prototype.refresh = function () {
var table = this.table();
this.contents.clear();
this.resetTextColor();
if (!this._dataFromTable) {
this._dataFromTable = {};
}
this._dataFromTable.maxItems = table[this._page].length;
this._dataFromTable.okIndex = table[this._page].indexOf('확인');
this._dataFromTable.backIndex = table[this._page].indexOf('백스페이스');
this._dataFromTable.spaceIndex = table[this._page].indexOf('띄어쓰기');
this._dataFromTable.specificIndex = table[this._page].indexOf('한/영');
for (var i = 0; i < this._dataFromTable.maxItems; i++) {
var rect = this.itemRect(i);
rect.x += 3;
rect.width -= 6;
this.drawText(table[this._page][i], rect.x, rect.y, rect.width, 'center');
}
};
Window_KoreanNameInput.prototype.isHan = function () {
return this._index === this._dataFromTable.specificIndex;
};
Window_KoreanNameInput.prototype.isOk = function () {
return this._index === this._dataFromTable.okIndex;
};
Window_KoreanNameInput.prototype.isBack = function () {
return this._index === this._dataFromTable.backIndex;
};
Window_KoreanNameInput.prototype.isSpace = function () {
return this._index === this._dataFromTable.spaceIndex;
};
Window_KoreanNameInput.prototype.processOk = function () {
if (this.character()) {
this.onNameAdd();
} else if (this.isOk()) {
this.onNameOk();
} else if (this.isHan()) {
this._editWindow._isHan = !this._editWindow._isHan;
this._page = this._editWindow._isHan ? 0 : 1;
this.refresh();
this._index = this._dataFromTable.specificIndex;
} else if (this.isSpace()) {
this._editWindow.add(' ');
} else if (this.isBack()) {
this.processBack();
}
};
//============================================================================
// Window_NameEdit
//============================================================================
function Window_KoreanNameEdit() {
this.initialize.apply(this, arguments);
}
Window_KoreanNameEdit.prototype = Object.create(Window_NameEdit.prototype);
Window_KoreanNameEdit.prototype.constructor = Window_KoreanNameEdit;
Window_KoreanNameEdit.prototype.initialize = function (actor, maxLength) {
Window_NameEdit.prototype.initialize.call(this, actor, maxLength);
this._name = actor.name().slice(0, this._maxLength);
this._index = this._name.length;
this._traceBackCallback = [];
this._alertFunc = function () {};
this._isHan = true;
this._isOnAlertWindowWhenTyping = 'none';
this.on('removed', this.removeEventListener, this);
this.addEventListener();
};
Window_KoreanNameEdit.prototype.windowWidth = function () {
return eval(RS.Window_KoreanNameInput.Params.windowWidthEval);
};
Window_KoreanNameEdit.prototype.faceWidth = function () {
return 0;
};
Window_KoreanNameEdit.prototype.refresh = function () {
this.contents.clear();
for (var i = 0; i < this._maxLength; i++) {
this.drawUnderline(i);
}
for (var j = 0; j < this._name.length; j++) {
this.drawChar(j);
}
var rect = this.itemRect(this._index);
this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
};
Window_KoreanNameEdit.prototype.add = function (ch) {
var index = Window_KoreanNameInput.KOREAN.indexOf(ch);
var inputWindow;
if (index >= 0) {
if ((inputWindow = this.isValidInputWindow())) {
inputWindow._index =
ch === ' ' ? inputWindow._dataFromTable.spaceIndex : index;
}
}
if (this._index <= this._maxLength) {
var ret = (this._name.slice(0) + ch).split(''); // 배열로 변환
this._name = Hangul.assemble(Hangul.disassemble(ret));
this._name = this._name.slice(0, this._maxLength);
this._index = this._name.length;
this.refresh();
return true;
} else {
return false;
}
};
Window_KoreanNameEdit.prototype.back = function () {
var inputWindow;
if ((inputWindow = this.isValidInputWindow())) {
inputWindow._index = inputWindow._dataFromTable.backIndex;
}
if (this._name.length > 0) {
this._index--;
var nameToArr = this._name.split('');
var ret = Hangul.disassemble(nameToArr);
ret = ret.slice(0, ret.join('').length - 1);
ret = Hangul.assemble(ret);
this._name = ret;
this._index = this._name.length;
this.refresh();
return true;
} else {
return false;
}
};
Window_KoreanNameEdit.prototype.charWidth = function () {
var text = '\uAC00';
return this.textWidth(text);
};
Window_KoreanNameEdit.prototype.refresh = function () {
this.contents.clear();
var rect = this.itemRect(Math.max(this._index - 1, 0));
for (var i = 0; i < this._maxLength; i++) {
this.drawUnderline(i);
}
for (var j = 0; j < this._name.length; j++) {
this.drawChar(j);
}
if (this._index === 0) {
this.setCursorRect(rect.x, rect.y, 1, rect.height);
} else {
this.setCursorRect(rect.x + (rect.width - 1), rect.y, 1, rect.height);
}
};
Window_KoreanNameEdit.BACK_SPACE = 8;
Window_KoreanNameEdit.ENTER = 13;
Window_KoreanNameEdit.IS_NOT_CHAR = 32;
Window_KoreanNameEdit.KEYS_ARRAY = 255;
Window_KoreanNameEdit.prototype.addEventListener = function () {
window.addEventListener('keydown', this.onKeyDown.bind(this), false);
window.addEventListener('mousemove', this.onMouseMove.bind(this), false);
};
Window_KoreanNameEdit.prototype.removeEventListener = function () {
window.removeEventListener('keydown', this.onKeyDown.bind(this));
window.removeEventListener('mousemove', this.onMouseMove.bind(this));
};
Window_KoreanNameEdit.prototype.update = function () {
Window_NameEdit.prototype.update.call(this);
this.processBackCallback();
};
Window_KoreanNameEdit.prototype.processBackCallback = function () {
var back = this._traceBackCallback.pop();
if (back && typeof back === 'string') {
this.back();
}
};
Window_KoreanNameEdit.HANGUL_KEYS = {
32: [' '],
49: ['1', '!'],
50: ['2', '@'],
51: ['3', '#'],
52: ['4', '$'],
53: ['5', '%'],
54: ['6', '^'],
55: ['7', '&'],
56: ['8', '*'],
57: ['9', '('],
48: ['0', ')'],
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: ['ㅋ'],
96: ['0'],
97: ['1'],
98: ['2'],
99: ['3'],
100: ['4'],
101: ['5'],
102: ['6'],
103: ['7'],
104: ['8'],
105: ['9'],
188: [',', '<'],
190: ['.', '>'],
191: ['/', '?'],
};
Window_KoreanNameEdit.ENGLISH_KEYS = {
32: [' '],
49: ['1', '!'],
50: ['2', '@'],
51: ['3', '#'],
52: ['4', '$'],
53: ['5', '%'],
54: ['6', '^'],
55: ['7', '&'],
56: ['8', '*'],
57: ['9', '('],
48: ['0', ')'],
65: ['a', 'A'],
66: ['b', 'B'],
67: ['c', 'C'],
68: ['d', 'D'],
69: ['e', 'E'],
70: ['f', 'F'],