-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaint.js
More file actions
157 lines (145 loc) · 7.58 KB
/
paint.js
File metadata and controls
157 lines (145 loc) · 7.58 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
class Paint {
constructor() {
this.headerColors = [RGB(215, 0, 58), RGB(0, 123, 187), RGB(240, 131, 0), RGB(195, 216, 37), RGB(116, 50, 92)];
this.leftMargin = 15;
this.headerH = 0;
this.totalHeight = 0;
}
// デフォルトの形式(上寄せ)でパネルのメイン部分の行を描画する
// @param gr GdiGraphics
// @param display 表示する部分の内容
// @param i 何ブロック目か(int)
main(gr, display, i) {
this.totalHeight += 5;
let startXloc = this.totalHeight;
if (display.subline != undefined) {
var subfnt = fntToSub(display.font, display.subline.font);
var subclr = RGB(subfnt.color[0], subfnt.color[1], subfnt.color[2]);
var ms = gr.MeasureString(fb.TitleFormat(display.subline.format).Eval(), fnt(subfnt), this.leftMargin, this.totalHeight, window.Width - this.leftMargin, 10000, 0);
gr.DrawString(fb.TitleFormat(display.subline.format).Eval(), fnt(subfnt), subclr, this.leftMargin, this.totalHeight, window.Width - this.leftMargin, ms.Height + 1, 0);
this.totalHeight += ms.Height + 1;
}
var mainHeight = gr.MeasureString(fb.TitleFormat(display.format).Eval(), fnt(display.font), this.leftMargin, this.totalHeight, window.Width - this.leftMargin, 10000, 0).Height;
gr.DrawString(fb.TitleFormat(display.format).Eval(), fnt(display.font), fntclr(display.font), this.leftMargin, this.totalHeight, window.Width - this.leftMargin, mainHeight + 1, 0);
let h = (ms == undefined) ? mainHeight - 8 : ms.Height + mainHeight - 8;
gr.FillSolidRect(5, startXloc + 4, 3, h, this.headerColors[i % 5]);
this.totalHeight += mainHeight;
}
// ヘッダを描画する
// @param gr GdiGraphics
// @param focus boolean
header(gr, focus) {
var tText = paint.makeTopText();
var headerMeasure = gr.MeasureString(tText, fnt(jsonData.header.font), 0, 0, window.Width, 10000, 0);
this.headerH = headerMeasure.Height + 2;
if (this.headerH < 3) this.headerH = gr.MeasureString("Shiina", fnt(jsonData.header.font), 0, 0, window.Width, 10000, 0).Height + 2;
var hcolor = jsonData.header.color;
let backcolor = RGB(hcolor[0], hcolor[1], hcolor[2]);
if (!focus) backcolor = RGB(Math.round((hcolor[0] + 255 * 2) / 3), Math.round((hcolor[1] + 255 * 2) / 3), Math.round((hcolor[2] + 255 * 2) / 3));
gr.FillSolidRect(0, 0, window.Width, this.headerH - 2, backcolor);
gr.DrawString(tText, fnt(jsonData.header.font), fntclr(jsonData.header.font), 0, 0, window.Width, this.headerH, 0);
this.totalHeight += this.headerH;
}
// アートワークを描画する
// @param gr GdiGraphics
artwork(gr) {
try {
var img = utils.GetAlbumArtV2(fb.GetNowPlaying());
if (img != null) {
var w_per_h = img.Width / img.Height;
var drawing_height = window.Height - this.headerH;
var h = drawing_height * 0.7;
var w = h * w_per_h;
var x = window.Width - window.Width * 0.05 - w;
var y = this.headerH + drawing_height * 0.05;
var src_x = 0;
var src_y = 0;
var src_w = img.Width;
var src_h = img.Height;
var alpha = 150;
gr.DrawImage(img, x, y, w, h, src_x, src_y, src_w, src_h, 0, alpha);
img.RotateFlip(6);
gr.DrawImage(img, x, y + h + 5, w, h, src_x, src_y, src_w, src_h, 0, alpha * 0.3);
}
}
catch {
consoleWrite("Album Artwork is not found");
}
}
// ヘッダに表示する内容を生成する
// @return ヘッダに表示する内容(string)
makeTopText() {
// プレイリスト名&何曲目か/プレイリスト総曲数
var playing_item_location = plman.GetPlayingItemLocation();
var topText = plman.GetPlaylistName(playing_item_location.PlaylistIndex); // Playlist Name
if (is_ultimate) {
let adaptive_text = "";
if (is_adaptive) {
let status = " - ";
if (adaptive_this_q_result == 1) {
status = " O ";
} else if (adaptive_this_q_result == -1) {
status = " X ";
}
let mode_mark = "";
if (adaptive_loop) mode_mark += "L";
if (adaptive_order_random) mode_mark += "R";
adaptive_text = `${(mode_mark != "") ? "[" + mode_mark + "] " : ""} ${adaptive_now[1]}pt(${(adaptive_now[0] == adaptive_list_numbers.length - 1 && !adaptive_loop) ? 'Last' : "Rank" + (adaptive_now[0] + 1)}/${adaptive_list_numbers.length})${status} // `
}
if (ultimateAutoStop == 0) {
let min = Math.floor(ultimate_timer / 60);
let sec = ultimate_timer % 60;
return adaptive_text + "Elapsed -> " + min + ":" + ((sec < 10) ? "0" : "") + sec + " // " + topText + " " + this.getModeText();
} else {
// Ultimate-modeのときは残り時間を表示
if (ultimate_timer <= 0) return adaptive_text + "Additional time";
let min = Math.floor(ultimate_timer / 60);
let sec = ultimate_timer % 60;
return adaptive_text + "Remain -> " + min + ":" + ((sec < 10) ? "0" : "") + sec + " // " + topText + " " + this.getModeText();
}
}
if (fb.IsPlaying) topText += ' [' + (playing_item_location.PlaylistItemIndex + 1) + "/" + plman.PlaylistItemCount(plman.PlayingPlaylist) + ']';
// Rantro, Mix, Outroの場合は記載
topText += " // " + this.getModeText()
// RECORD_TIMEまわり
var rec = (isSpotify) ? spotRecordTime : fb.TitleFormat("[%RECORD_TIME%]").Eval();
if (rec == "") return topText;
topText += ' // REC:' + rec.replace(/-1/g, "-");
return topText;
}
getModeText() {
let mtext = (all_memorize) ? "[M]" : "";
switch (mode) {
case 1: // Rantro
mtext += "Rantro>>" + minPercent + "%~" + maxPercent + "% ";
break;
case 2: // Mix
mtext += "Mix>>I:R(" + minPercent + "%~" + maxPercent + "%)=" + mixIntroRatio + ":" + mixRantroRatio + " ";
break;
case 3: // Outro
mtext += "Outro>>" + outroLocation + "sec before the end ";
break;
}
return mtext;
}
// 任意のメッセージを中央に表示するパネルを出現させる
// Ultimate-modeで主に使用
// @param gr GdiGraphics
// @param msg 表示する文字列(string)
message(gr, msg) {
var messageMeasure = gr.MeasureString(msg, fnt(jsonData.ultimate.font), 0, 0, window.Width, 10000, 0);
let w = messageMeasure.Width * 2;
let h = messageMeasure.Height * 2;
if (w < h) w = h;
let left = window.Width / 2 - w / 2;
let up = window.Height / 2 - h / 2;
gr.FillEllipse(left + w / 10, up + h / 10, w, h, RGB(200, 200, 200));
gr.FillEllipse(left, up, w, h, RGB(255, 255, 255));
gr.DrawEllipse(left, up, w, h, 2, RGB(0, 0, 0));
gr.DrawString(msg, fnt(jsonData.ultimate.font), fntclr(jsonData.ultimate.font), (window.Width - messageMeasure.Width) / 2, (window.Height - messageMeasure.Height) / 2, w, h, 0);
}
lamp(gr, x, y, w, h, clr) {
gr.FillEllipse(x, y, w, h, RGB(clr[0], clr[1], clr[2]));
gr.DrawEllipse(x, y, w, h, 5, RGB(128, 128, 128));
}
}