-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMano_SaveFileInfo.js
More file actions
1496 lines (1444 loc) · 38.9 KB
/
Mano_SaveFileInfo.js
File metadata and controls
1496 lines (1444 loc) · 38.9 KB
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
//@ts-check
//=============================================================================
// Mano_SaveFileInfo.js
// ----------------------------------------------------------------------------
// Copyright (c) 2022-2022 Sigureya
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.0.0 2022/04/14 初版
// ----------------------------------------------------------------------------
// [Twitter]: https://twitter.com/Sigureya/
//=============================================================================
/*:
* @plugindesc セーブ画面に追加情報を表示します。
* @author しぐれん
*
* @target MZ
* @orderAfter NUUN_SaveScreen
* @orderAfter AltSaveScreen
*
* @command SetText
* @desc 指定した変数に文字列を書き込みます。
* 改行にも対応します。
* @arg variableId
* @type variable
* @default 0
*
* @arg text
* @text 書き込む文章
* @type multiline_string
*
* @param listWindow
* @text ファイルリストの配置
* @type struct<Rect>
* @default {"x":"270","y":"112","width":"616","height":"340"}
*
* @param numVisibleRows
* @text 表示するファイル数(縦)
* @desc 他のプラグインで設定した値を使う場合、99を指定します。
* @type number
* @min 1
* @default 3
*
* @param maxCols
* @text 表示するファイル数(横)
* @type number
* @min 1
* @default 2
*
* @param leftWindow
* @text 左側のウィンドウ
* @type struct<Rect>
* @default {"x":"0","y":"112","width":"270","height":"340"}
*
* @param leftSpriteList
* @text 画像設定(左側)
* @type struct<SpriteV2>[]
* @parent leftWindow
* @default ["{\"table\":\"[]\",\"variableId\":\"1\",\"bitmap\":\"\",\"x\":\"0\",\"y\":\"0\",\"width\":\"200\",\"height\":\"200\",\"anthorX\":\"0\",\"anthorY\":\"0\",\"isUpper\":\"false\"}"]
*
* @param leftTextList
* @text 文章設定(左側)
* @type struct<TextFormat>[]
* @parent leftWindow
* @default ["{\"symbol\":\"variable\",\"variableId\":\"1\",\"nameFormat\":\"立ち絵変数:\",\"valueFormat\":\"%1\",\"valueColor\":\"\",\"indentLevel\":\"32\",\"numLines\":\"1\"}","{\"symbol\":\"playtime\",\"variableId\":\"0\",\"nameFormat\":\"プレイ時間\",\"valueFormat\":\"%1\",\"valueColor\":\"\",\"indentLevel\":\"0\",\"numLines\":\"1\"}","{\"symbol\":\"timestamp\",\"variableId\":\"0\",\"nameFormat\":\"%1\",\"valueFormat\":\"\",\"valueColor\":\"\",\"indentLevel\":\"0\",\"numLines\":\"1\"}","{\"symbol\":\"mapname\",\"variableId\":\"0\",\"nameFormat\":\"\",\"valueFormat\":\"%1\",\"valueColor\":\"\",\"indentLevel\":\"0\",\"numLines\":\"1\"}","{\"symbol\":\"mapinfo\",\"variableId\":\"0\",\"nameFormat\":\"\",\"valueFormat\":\"%1\",\"valueColor\":\"\",\"indentLevel\":\"0\",\"numLines\":\"1\"}"]
*
* @param leftTextPosition
* @text 文章の配置
* @parent leftWindow
* @type struct<Rect>
* @default {"x":"0","y":"140","width":"270","height":"340"}
*
* @param bottomWindow
* @type struct<Rect>
* @default {"x":"0","y":"452","width":"808","height":"180"}
*
* @param bottomSpriteList
* @text 画像設定(下側)
* @type struct<SpriteV2>[]
* @parent bottomWindow
* @default []
*
* @param bottomTextList
* @text 文章設定(下側)
* @type struct<TextFormat>[]
* @parent bottomWindow
* @default ["{\"symbol\":\"lastmsg\",\"variableId\":\"0\",\"nameFormat\":\"%1\",\"valueFormat\":\"\",\"valueColor\":\"\",\"indentLevel\":\"0\",\"numLines\":\"4\"}"]
*
* @param bottomTextPosition
* @text 文章の配置
* @parent bottomWindow
* @type struct<Rect>
* @default {"x":"0","y":"0","width":"808","height":"130"}
*
* @param lastMessageSwitch
* @text 最後の文章記録フラグ
* @desc ONの場合のみ、最後の文章を記録します。
* ゲーム開始時に自動でONになります。
* @type switch
* @default 0
*
* @help
* プラグインを有効にするためには、
* プラグイン導入後に1回以上セーブを行う必要があります。
* 無効状態でもエラーにはなりません。
*
* ファイル一覧の左・下の2か所に情報ウィンドウを追加します。
* 情報ウィンドウには以下の情報が表示可能です。
* これらの設定はプラグインパラメータで行います。
* ・プレイ時間
* ・地名(ゲーム中表示)
* ・地名(編集用表示)
* ・セーブ日時
* ・変数
* ・最後に表示した文章
* ・画像(変数との対応表が必要)
*
* ■他のプラグインとの対応
* ・NUUN_SaveScreen
* 同時使用可能です。
*
* ■AltSaveScreen
* 画面配置に異常が出るため同時使用できません。
* 技術的には解決可能ですが、仕様が未定です。
*
* ■利用規約
* MIT Licenseです。
* ご自由にお使いください。
*/
/*~struct~Rect:
* @param x
* @type number
* @default 0
*
* @param y
* @type number
* @default 0
*
* @param width
* @text width/ウィンドウの幅
* @type number
* @default 200
*
* @param height
* @text height/ウィンドウの高さ
* @type number
* @default 200
*/
/*~struct~ActorImage:
* @param dataType
* @type select
* @param memberIndex
* @type number
* @default 0
*/
/*~struct~TextTableItem:
* @param value
* @type number
* @default 1
*
* @param item
* @type multiline_string
* @text 表示する文章
* @desc 制御文字は使用できません。
*
*/
/*~struct~TextV2:
* @param table
* @text 文字列リスト
* @desc 指定した変数の値を使い、
* ここのテーブルから画像を取り出します。
* @type struct<TextTableItem>[]
* @default []
*
* @param variableid
* @text 対応する変数
* @type variable
* @desc 指定した変数の値によって表示画像を切り換えます。
* 完全一致のみ対応です。
* @default 0
*
* @param numLines
* @type number
* @default 1
* @min 1
*/
/*~struct~TextFormat:
* @param symbol
* @text 描画する文字の種類
* @type select
* @option 無し
* @value
* @option プレイ時間
* @value playtime
* @option 地名(ゲーム中表示)
* @value mapname
* @option 地名(編集用表示)
* @value mapinfo
* @option セーブ日時
* @value timestamp
* @option 変数
* @value variable
* @option 最後に表示した文章
* @value lastmsg
* @default
*
* @param variableId
* @text 変数番号
* @type variable
* @desc 描画する文字の種類で
* 変数を指定した場合に使用する変数です。
* @default 0
*
* @param nameFormat
* @text 【左】項目表示フォーマット
* @desc %1などでパラメータを取得して、書式を決めます。
* 制御文字が使用可能です。
* @type string
* @default 項目名
*
* @param valueFormat
* @text 【右】データ表示フォーマット
* @desc %1などでパラメータを取得して、書式を決めます。
* 制御文字・改行は無効です。
* @type string
* @default %1
*
* @param valueColor
* @text 【右】データ文章カラー
* @type string
* @desd #FF00FF表記
* @default
*
* @param indentLevel
* @text インデント(項目名を右へ移動)
* @desc 左側の文字が右側へ移動します。
* 数値によっては、右側の文字と重なる場合があります。
* @type number
* @default 0
*
* @param numLines
* @text 行数
* @desc 表示する行数を指定します。
* 画像と重ならないようにする場合にも使います。
* @type number
* @default 1
*
*/
/*~struct~SpriteTableItem:
* @param value
* @text 対応数値
* @desc 指定した変数がこの値と同じ場合に画像を表示します。
* @type number
* @default 1
*
* @param item
* @text 画像
* @type file
* @dir img/pictures/
* @desc 指定画像は枠に収まるよう縮小されます。
*
*/
/*~struct~SpriteV2:
* @param table
* @text 画像リスト
* @desc 指定した変数の値を使い、
* ここのテーブルから画像を取り出します。
* @type struct<SpriteTableItem>[]
* @default []
*
* @param variableId
* @text 対応する変数
* @type variable
* @desc 指定した変数の値によって表示画像を切り換えます。
* 完全一致のみ対応です。
* @default 0
*
* @param bitmap
* @desc 設定処理で画像が見つからなかった場合の画像。
* ※固定で画像を出したい場合にも使えます。
* @type file
* @dir img/picutures/
*
* @param x
* @type number
* @default 0
*
* @param y
* @type number
* @default 0
*
* @param width
* @text 幅
* @desc 画像がこれより大きい場合、
* 枠の中に納まるように縮小します。
* @type number
* @default 200
*
* @param height
* @text 高さ
* @desc 画像がこれより大きい場合、
* 枠の中に納まるように縮小します。
* @type number
* @default 200
*
* @param anthorX
* @text 画像中心位置X
* @desc 0:左が原点・0.5:中央が原点・1:右が原点
* @type number
* @default 0
* @min -1
* @max 1
* @decimals 2
*
* @param anthorY
* @text 画像中心位置Y
* @desc 0:上が原点・0.5:中央が原点・1:下が原点
* @type number
* @default 0
* @min -1
* @max 1
* @decimals 2
*
* @param isUpper
* @type boolean
* @on 文章の上
* @off 文章の下
* @default false
*/
/*~struct~Sprite:
* @param symbol
* @type select
* @option BattlerImage
* @default BattlerImage
* @text 【シンボル】
* @desc 表示画像の種類
*
* @param bitmap
* @desc 設定処理で画像が見つからなかった場合の画像。
* ※固定で画像を出したい場合にも使えます。
* @type file
* @dir img/
*
* @param x
* @type number
* @default 0
*
* @param y
* @type number
* @default 0
*
* @param width
* @text 幅
* @desc 画像がこれより大きい場合、
* 枠の中に納まるように縮小します。
* @type number
* @default 200
*
* @param height
* @text 高さ
* @desc 画像がこれより大きい場合、
* 枠の中に納まるように縮小します。
* @type number
* @default 200
*
* @param anthorX
* @text 画像中心位置X
* @desc 0:左が原点・0.5:中央が原点・1:右が原点
* @type number
* @default 0.5
* @max 1
* @decimals 2
*
* @param anthorY
* @text 画像中心位置Y
* @desc 0:上が原点・0.5:中央が原点・1:下が原点
* @type number
* @default 0.5
* @max 1
* @decimals 2
*
* @param isUpper
* @type boolean
* @on 文章の上
* @off 文章の下
* @default true
*/
(function(){
'use strict';
/**
* @param {string} objText
*/
function parseRect(objText){
const obj = JSON.parse(objText);
return new Rectangle(
Number(obj.x),Number(obj.y),Number(obj.width),Number(obj.height)
);
}
/**
* @typedef {PIXI.Rectangle} RectangleP
*/
/**
* @type {String}
*/
const PLUGIN_NAME= ('Mano_SaveFileInfo');
function getParam(){ return PluginManager.parameters(PLUGIN_NAME); }
/**
* @typedef {Object} SaveFileInfo
* @property {string} playtime
* @property {Number} timestamp
* @property {string} title
* @property {Array<[string,Number]>} faces
* @property {Array<[string,Number]>} characters
* @property {Record< string,(string|number)>} [uzssrecord=null]
*/
//専用のレコードへ保存するためのやつ
class KVP_Base{
/**
*
* @returns {string}
*/
key(){
return null;
}
/**
*
* @returns {string|number}
*/
value(){
return 0;
}
/**
* @param {SaveFileInfo} info
*/
read(info){
if(info.uzssrecord){
const key =this.key();
if(key){
return info.uzssrecord[key];
}
}
return null;
}
/**
* @param {SaveFileInfo} info
*/
readToText(info){
const t= this.read(info);
if(t){
return String(t);
}
return "";
}
}
class RecordTemporay{
constructor(){
/**
* @type {Record<(string),(Number|string)>}
*/
this._record={};
}
/**
* @param {KVP_Base} kvp
*/
writeV2(kvp){
const key = kvp.key();
//キーが有効なら書き込み
if(key){
const value =kvp.value();
this._record[key] =value;
}
}
get(){
return this._record;
}
}
class KVP_Variable extends KVP_Base{
/**
* @param {number} variableId
*/
constructor(variableId){
super();
this._variableId =variableId;
}
value(){
return $gameVariables.value(this._variableId);
}
key(){
return `V${this._variableId}`;
}
}
class KVP_Mapname extends KVP_Base{
key(){
return "mapname";
}
value(){
return $gameMap.displayName();
}
}
class KVP_Mapinfo extends KVP_Base{
key(){
return "mapinfo";
}
value(){
const mapId = $gameMap.mapId();
const mapInfo =$dataMapInfos[mapId];
if(mapInfo){
return mapInfo.name;
}
return "";
}
}
class KVP_Playtime extends KVP_Base{
/**
* @param {SaveFileInfo} info
*/
read(info){
return info.playtime;
}
}
class KVP_Timestamp extends KVP_Base{
/**
* @param {SaveFileInfo} info
*/
read(info){
const d= new Date(info.timestamp);
return `${d.toLocaleDateString()} ${d.toLocaleTimeString()} `
}
}
class KVP_LastMessage extends KVP_Base{
key(){
return "lastmsg";
}
value(){
return SavaDataManager_V2.getLastMessage();
}
}
class TextItemDictionary_T{
constructor(){
/**
* @type {Map<string,KVP_Base>}
*/
this._table=new Map();
this._table.set("timestamp",new KVP_Timestamp());
this._table.set("mapname",new KVP_Mapname());
this._table.set("playtime",new KVP_Playtime());
this._table.set("mapinfo",new KVP_Mapinfo());
this._table.set("lastmsg",new KVP_LastMessage());
}
/**
* @private
* @param {string} symbol
* @param {number} variableId
*/
createKVP(symbol,variableId){
if(symbol ==="variable"){
return new KVP_Variable(variableId);
}
const t = this._table.get(symbol);
if(t){
return t;
}
return null;
}
/**
*
* @param {string} text
*/
createByText(text){
const obj =JSON.parse(text);
const param =(
{
indentLevel:Number(obj.indentLevel||0),
valueColor:String(obj.valueColor),
valueFormat:String(obj.valueFormat),
symbol:String(obj.symbol),
nameFormat:String(obj.nameFormat),
numLines:Number(obj.numLines||1),
}
);
const vid =Number(obj.variableId);
const kvp = this.createKVP(param.symbol,vid);
return new TextContents(kvp,param);
}
}
const TextItemDictionary=( ()=>{
return new TextItemDictionary_T();
})();
class I_BitmapSelector{
/**
* @returns {Bitmap}
* @param {SaveFileInfo} info
*/
getBitmap(info){
return null;
}
/**
* @returns {KVP_Base}
*/
kvp(){
return null;
}
}
class KVPXXX_BitmapTable extends I_BitmapSelector{
/**
* @param {number} variableId
* @param { Map<number,string> } table
*/
constructor(variableId,table){
super();
this._kvp = new KVP_Variable(variableId);
this._table=table;
}
kvp(){
return this._kvp;
}
/**
* @param {SaveFileInfo} info
*/
getBitmap(info){
const value = Number( this._kvp.read(info));
if(!isNaN(value)){
const filename = this._table.get(value);
if(filename){
return ImageManager.loadPicture(filename);
}
}
return null;
}
}
/**
* @typedef {Object} TextParamator
* @property {String} symbol
* @property {Number} indentLevel
* @property {String} valueFormat
* @property {String} nameFormat
* @property {String} valueColor
* @property {number} numLines
*/
class TextContents{
/**
* @param {KVP_Base} kvp
* @param {TextParamator} param
*/
constructor(kvp,param){
this._kvp =kvp;
this._param =param;
}
kvp(){
return this._kvp;
}
/**
* @param {SaveFileInfo} data
*/
kvpText(data){
if(data){
if(this._kvp){
return [this._kvp.readToText(data)]
}
}
return null;
}
/**
* @param {SaveFileInfo} data
*/
getTextXXX(data){
const textArray = this.kvpText(data);
return {
left:this.createParamText(this._param.nameFormat,textArray),
right :this.createParamText(this._param.valueFormat,textArray),
}
}
/**
* @param {String} format
* @param {String[]|null} param
*/
createParamText(format,param){
const reg =/%([0-9]+)/g;
return format.replace(reg,(s,n)=>{
if(!param){
return "";
}
const text = param[Number(n)-1];
return text ||"";
});
}
indentLevel(){
return this._param.indentLevel;
}
valueTextColor(){
return this._param.valueColor;
}
numLines(){
return this._param.numLines;
}
}
/**
* @typedef {Object} AreaObject
* @property {RectangleP} rect
* @property {TextContents[]} textList
*/
// class FaceBitmapSelector extends I_BitmapSelector{
// /**
// * @param {Number} index
// */
// constructor(index){
// super();
// this._index=index;
// }
// /**
// * @param {SaveFileInfo} info
// */
// getBitmap(info){
// const face=(info.faces[this._index]);
// if(face){
// return ImageManager.loadFace(face[0]);
// }
// return null;
// }
// /**
// * @param {SaveFileInfo} info
// */
// frameRect(info){
// const face = (info.faces[this._index]);
// if(face){
// const index = face[1];
// return this.faceRect(index);
// }
// return null;
// }
// /**
// * @param {Number} index
// */
// faceRect(index){
// const pw =ImageManager.faceWidth
// const ph =ImageManager.faceHeight;
// const sx =Math.floor((index % 4) * pw + (0) / 2);
// const sy = Math.floor(Math.floor(index / 4) * ph + (0) / 2);
// return new Rectangle(
// sx,sy,
// pw,
// ph
// );
// }
// }
/**
* @typedef {Object} SpriteRecipe
* @property {RectangleP} positionRect
* @property {number} anthorX
* @property {Number} anthorY
* @property {boolean} isUpper
*/
class SpriteContents{
/**
* @param {I_BitmapSelector} xxx
* @param {SpriteRecipe} recipe
*/
constructor(xxx,recipe){
this._xxx =xxx;
this._recipe =recipe;
}
/**
* @returns {KVP_Base}
*/
kvp(){
return this._xxx.kvp();
}
hue(data){
return 0;
}
anthorX(){
return this._recipe.anthorX;
}
anthorY(){
return this._recipe.anthorY;
}
positionRect(){
return this._recipe.positionRect.clone();
}
alpha(){
return 1;
}
/**
* @param {SaveFileInfo} info
*/
getBitmap(info){
if(info){
return this._xxx.getBitmap(info);
}
return null;
}
/**
* @param {SaveFileInfo} info
*/
frameRect(info){
return null;
//return this._xxx.frameRect(info);
}
isUpper(){
return this._recipe.isUpper;
}
}
/**
* @template T_DataType
* @typedef {Object} SuperView_SpriteContentsConcept
* @property {()=>RectangleP} positionRect
* @property {()=>number} anthorX
* @property {()=>number} anthorY
* @property {(data:T_DataType)=>RectangleP} frameRect
* @property {(data:T_DataType)=>number} hue
* @property {(data:T_DataType)=>Bitmap} getBitmap
* @property {(data:T_DataType)=>number} alpha
*/
/**
* @template {SaveFileInfo} T_DataType
*/
class Sprite_SuperView extends Sprite{
constructor(){
super();
this._data=null;
this.visible =false;
this.setContents(null);
}
clear(){
this.visible=false;
this._elment=null;
}
/**
* @param {SuperView_SpriteContentsConcept<T_DataType>} contents
*/
setContents(contents){
this._elment =(contents ||null);
this.refresh();
}
updateVisible(){
//this.visible=true;
this.visible = !!this._elment;
}
updatePosition(){
if(this._elment){
const rect =this._elment.positionRect()
this.x = rect.x;
this.y = rect.y;
this.anchor.x = this._elment.anthorX();
this.anchor.y = this._elment.anthorY();
}
}
updateFrame(){
const rect = this._elment.frameRect(this._data);
if(rect){
this.setFrame(rect.x,rect.y,rect.width,rect.height);
return;
}
const orig=this.bitmap.rect;
this.setFrame(orig.x,orig.y,orig.width,orig.height);
this;
}
refresh(){
this.updateVisible();
this.loadBitmap();
this.updatePosition();
this.updateOpacity();
this.updateHue();
}
updateHue(){
if(this._elment){
this.setHue(this._elment.hue(this._data));
}
}
updateOpacity(){
if(this._elment){
this.alpha =this._elment.alpha(this._data);
}
}
loadBitmap(){
if(!this._elment ){
this.bitmap=null;
return;
}
//フォールバック画像を返す可能性があるので、nullでも渡す
const bitmap =this._elment.getBitmap(this._data||null);
this.bitmap = bitmap;
if(bitmap){
//TODO:hueがMV/MZで設定方法が違う
//MZはspriteが持っているので、何らかの対応を行う
bitmap.addLoadListener(this.onBitmapLoadead.bind(this));
}
}
onBitmapLoadead(){
this.updateFrame();
this.resetScale();
}
resetScale(){
const s=this.calcScale();
this.scale.set(s,s);
}
calcScale(){
const bitmap =this.bitmap;
if(bitmap && bitmap.isReady()){
const posRect =this._elment.positionRect();
const scaleA =posRect.width / this._frame.width ;
const scaleB =posRect.height / this._frame.height;
return Math.min(1,scaleA,scaleB);
}
return 0;
}
/**
* @param {T_DataType} data
*/
setData(data){
const dd= data||null;
if(dd!==this._data){
this._data=dd;
this.refresh();
}
}
}
/**
* @template {SaveFileInfo} T_DataType
*/
class Spriteset_SuperView extends PIXI.Container{
/**
*
* @param {SpriteContents[]} constents
*/
constructor(constents){
super();
/**
* @type {Sprite_SuperView<T_DataType>[]}
*/
this._list =[];
this.setContents(constents);
}
/**
* @param {Number} num
*/
reserveSprite(num){
const alocate= num - this._list.length;
if(alocate >0){
for (let i = 0; i < alocate; i++) {
/**
* @type {Sprite_SuperView<T_DataType>}
*/
const sprite = new Sprite_SuperView();
this._list.push(sprite);
this.addChild(sprite);
}
}
}
/**
* @param {SpriteContents[]} contentsList
*/
setContents(contentsList){
this.reserveSprite(contentsList.length);
this._list.forEach((sprite,index)=>{
const contents =contentsList[index];
sprite.setContents(contents||null);
});
}
/**
* @param {T_DataType} data
*/
setData(data){
for (const iterator of this._list) {
iterator.setData(data);
}
}
}
class DataWindowLayout_V2{
/**
*
* @param {SpriteContents[]} casset
* @param {AreaObject[]} area
* @param {RectangleP} rect
*/