-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerText.js
More file actions
144 lines (137 loc) · 3.89 KB
/
TimerText.js
File metadata and controls
144 lines (137 loc) · 3.89 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
//=============================================================================
// RPG Maker MZ - Change timer display
//=============================================================================
/*:
* @target MZ
* @plugindesc Change timer display
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/TimerText.js
*
* @help TimerText.js
*
* This plugin changes how to display the timer.
*
* It does not provide plugin commands.
*
* Changelog
* 25 Sept 2020: Boolean options were not applied.
* 23 Sept 2020: First edition.
*
* @param bitmapWidth
* @text Width of display area
* @desc Changes width of display area. Set 0 for default.
* @default 96
* @type number
* @min 0
*
* @param bitmapHeight
* @text Height of display area
* @desc Changes height of display area. Set 0 for default.
* @default 48
* @type number
* @min 0
*
* @param forceFixedPitch
* @text Fixed pitch
* @desc Forces fixed pitch.
* @default false
* @type boolean
*
* @param blinkColon
* @text Blink ":"
* @desc Blink ":".
* @default false
* @type boolean
*
*/
/*:ja
* @target MZ
* @plugindesc タイマーの表示を変更
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/TimerText.js
*
* @help TimerText.js
*
* このプラグインは、タイマーの表示方法を変更します。
*
* プラグインコマンドはありません。
*
* 更新履歴
* 令和2年9月25日 booleanオプションが反映されていないのを修正
* 令和2年9月23日 初版
*
* @param bitmapWidth
* @text 表示領域の幅
* @desc 表示領域の幅を変更します。0の時はデフォルト値になります。
* @default 96
* @type number
* @min 0
*
* @param bitmapHeight
* @text 表示領域の高さ
* @desc 表示領域の高さを変更します。0の時はデフォルト値になります。
* @default 48
* @type number
* @min 0
*
* @param forceFixedPitch
* @text 固定ピッチにする
* @desc 数字の幅を強制的に揃えます。
* @default false
* @type boolean
*
* @param blinkColon
* @text 「:」を点滅させる
* @desc 「:」を点滅させます。
* @default false
* @type boolean
*
*/
(() => {
const pluginName = "TimerText";
const param = PluginManager.parameters(pluginName);
// rmmz_sprites.js
Sprite_Timer.prototype.createBitmap = function() {
//this.bitmap = new Bitmap(96, 48);
// ↓ Added by MihailJP
this.bitmap = new Bitmap(param.bitmapWidth || 96, param.bitmapHeight || 48);
// ↑ Added by MihailJP
this.bitmap.fontFace = this.fontFace();
this.bitmap.fontSize = this.fontSize();
this.bitmap.outlineColor = ColorManager.outlineColor();
};
Sprite_Timer.prototype.redraw = function() {
const text = this.timerText();
//const width = this.bitmap.width;
// ↓ Added by MihailJP
const width = this.bitmap.width / (JSON.parse(param.forceFixedPitch) ? text.length : 1);
// ↑ Added by MihailJP
const height = this.bitmap.height;
this.text = text;
this.bitmap.clear();
// ↓ Added by MihailJP
if (JSON.parse(param.forceFixedPitch)) {
for (let i = 0; i < text.length; ++i) {
this.bitmap.drawText(text.substr(i, 1), width * i, 0, width, height, "center");
}
} else {
// ↑ Added by MihailJP
this.bitmap.drawText(text, 0, 0, width, height, "center");
// ↓ Added by MihailJP
}
// ↑ Added by MihailJP
};
const orig_Sprite_Timer_updateBitmap = Sprite_Timer.prototype.updateBitmap;
Sprite_Timer.prototype.updateBitmap = function() {
orig_Sprite_Timer_updateBitmap.call(this);
if (this.text !== this.timerText()) {
this.redraw();
}
};
const orig_Sprite_Timer_timerText = Sprite_Timer.prototype.timerText;
Sprite_Timer.prototype.timerText = function() {
return orig_Sprite_Timer_timerText.call(this).replace(/:/,
((!JSON.parse(param.blinkColon)) || ($gameTimer._frames < 1) || ($gameTimer._frames % 60 >= 30))
? ":" : " ");
};
})();