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
|
#include "about.h"
#include <windowsx.h>
#include <stdbool.h>
#include <wchar.h>
#include <stdlib.h>
#include "version.h"
enum {
ID_OK = 0x10
};
extern HWND g_currentdlg;
static struct {
HINSTANCE hinst;
void (*closecb)(void *ptr);
void *cbptr;
HWND about;
ATOM about_class;
HFONT font, font_large;
HWND static_main, static_icon, static_help, static_info, button_ok;
wchar_t *soundapiname;
bool adpcm_rom, font_rom;
} g;
static void on_destroy(HWND hwnd) {
DestroyWindow(g.static_main);
DestroyWindow(g.static_info);
DestroyWindow(g.static_help);
DestroyWindow(g.static_icon);
DestroyWindow(g.button_ok);
if (g.closecb) {
g.closecb(g.cbptr);
}
g.about = 0;
}
static void update_status(void) {
static wchar_t buf[1024];
swprintf(buf, sizeof(buf)/sizeof(buf[0]),
L"Audio API: %ls\r\n"
"ym2608_adpcm_rom.bin: %lsavailable\r\n"
"font.rom: %ls\r\n"
"SSE2 (for SIMD SSG resampling): %lsavailable\r\n"
"SSSE3 (for SIMD FMDSP palette lookup): %lsavailable",
g.soundapiname ? g.soundapiname : L"",
g.adpcm_rom ? L"" : L"un",
g.font_rom ? L"available" : L"unavailable, using MS Gothic",
__builtin_cpu_supports("sse2") ? L"" : L"un",
__builtin_cpu_supports("ssse3") ? L"" : L"un");
SetWindowText(g.static_info, buf);
}
static bool on_create(HWND hwnd, const CREATESTRUCT *cs) {
RECT wr = {
.left = 0,
.top = 0,
.right = 480,
.bottom = 300
};
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
DWORD exstyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
AdjustWindowRectEx(&wr, style, 0, exstyle);
SetWindowPos(hwnd, HWND_TOP, 0, 0, wr.right-wr.left, wr.bottom-wr.top,
SWP_NOZORDER | SWP_NOMOVE);
if (!g.font) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
LONG height = ncm.lfMessageFont.lfHeight;
ncm.lfMessageFont.lfHeight = height * 1.2;
ncm.lfMessageFont.lfWidth = 0;
g.font = CreateFontIndirect(&ncm.lfMessageFont);
ncm.lfMessageFont.lfHeight = height * 1.5;
ncm.lfMessageFont.lfWidth = 0;
g.font_large = CreateFontIndirect(&ncm.lfMessageFont);
}
g.static_icon = CreateWindowEx(0, L"static",
MAKEINTRESOURCE(1),
WS_CHILD | WS_VISIBLE | SS_ICON,
100, 10, 32, 32,
hwnd, 0, g.hinst, 0);
#ifdef _WIN64
#define ABOUT_ARCH "(amd64)"
#else
#define ABOUT_ARCH "(i586)"
#endif
g.static_info = CreateWindowEx(0, L"static",
L"",
WS_CHILD | WS_VISIBLE,
75, 50, 400, 90,
hwnd, 0, g.hinst, 0);
SetWindowFont(g.static_info, g.font, TRUE);
update_status();
g.static_help = CreateWindowEx(0, L"static",
L"F11: toggle track display page\r\n"
"F12: display FMDSP at 2x\r\n"
"Ctrl+F1-F10: FMDSP color palette\r\n\r\n"
"1-9,0,-: toggle track mask (Ctrl: PPZ8)\r\n"
"Shift+1-9,0,-: track solo\r\n"
"=: invert all mask\r\n"
"\\: all tracks on",
WS_CHILD | WS_VISIBLE,
75, 140, 400, 400,
hwnd, 0, g.hinst, 0);
SetWindowFont(g.static_help, g.font, TRUE);
g.static_main = CreateWindowEx(0, L"static",
L"FMPlayer/Win32 " ABOUT_ARCH " v" FMPLAYER_VERSION_STR,
WS_CHILD | WS_VISIBLE,
150, 10, 400, 40,
hwnd, 0, g.hinst, 0);
SetWindowFont(g.static_main, g.font_large, TRUE);
g.button_ok = CreateWindowEx(0, L"button",
L"&OK",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON,
200, 270, 80, 25,
hwnd, (HMENU)ID_OK, g.hinst, 0);
SetWindowFont(g.button_ok, g.font, TRUE);
ShowWindow(hwnd, SW_SHOW);
return true;
}
static void on_activate(HWND hwnd, bool activate, HWND targetwnd, WINBOOL state) {
if (activate) g_currentdlg = hwnd;
else g_currentdlg = 0;
}
static void on_command(HWND hwnd, int id, HWND hwnd_c, UINT code) {
if (code == BN_CLICKED && (id == ID_OK)) {
DestroyWindow(hwnd);
}
}
static LRESULT CALLBACK wndproc(
HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
) {
switch (msg) {
HANDLE_MSG(hwnd, WM_DESTROY, on_destroy);
HANDLE_MSG(hwnd, WM_CREATE, on_create);
HANDLE_MSG(hwnd, WM_ACTIVATE, on_activate);
HANDLE_MSG(hwnd, WM_COMMAND, on_command);
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
void about_open(HINSTANCE hinst, HWND parent, void (*closecb)(void *ptr), void *cbptr) {
g.closecb = closecb;
g.cbptr = cbptr;
g.hinst = hinst;
if (!g.about) {
if (!g.about_class) {
WNDCLASS wc = {0};
wc.lpfnWndProc = wndproc;
wc.hInstance = g.hinst;
wc.hIcon = LoadIcon(g.hinst, MAKEINTRESOURCE(1));
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wc.lpszClassName = L"myon_fmplayer_ym2608_about";
g.about_class = RegisterClass(&wc);
}
if (!g.about_class) {
MessageBox(parent, L"Cannot register class", L"Error", MB_ICONSTOP);
return;
}
g.about = CreateWindowEx(0,
MAKEINTATOM(g.about_class),
L"About",
WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
parent, 0, g.hinst, 0);
} else {
SetForegroundWindow(g.about);
}
}
void about_setsoundapiname(const wchar_t *apiname) {
free(g.soundapiname);
g.soundapiname = wcsdup(apiname);
if (g.about) update_status();
}
void about_set_fontrom_loaded(bool loaded) {
g.font_rom = loaded;
if (g.about) update_status();
}
void about_set_adpcmrom_loaded(bool loaded) {
g.adpcm_rom = loaded;
if (g.about) update_status();
}
void about_close(void) {
if (g.about) {
g.closecb = 0;
DestroyWindow(g.about);
}
}
|