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
|
/** (c) Nullsoft, Inc. C O N F I D E N T I A L
** Filename:
** Project:
** Description:
** Author:
** Created:
**/
#include "main.h"
static LRESULT WINAPI jumpDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
static LRESULT WINAPI jumpFileDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
HWND jump_hwnd, jump_hwnd2;
int jump_dialog(HWND hwnd)
{
if (IsWindow(jump_hwnd)) { SetForegroundWindow(jump_hwnd); return -1; }
LPCreateDialogW(IDD_JUMPDLG,DIALOG_PARENT(hwnd), jumpDlgProc);
return 0;
}
int jump_file_dialog(HWND hwnd)
{
if (IsWindow(jump_hwnd2)) { SetForegroundWindow(jump_hwnd2); return -1; }
LPCreateDialogW(IDD_JUMPFILEDLG,DIALOG_PARENT(hwnd),jumpFileDlgProc);
return 0;
}
static LRESULT WINAPI jumpDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
ShowWindow(jump_hwnd=hwndDlg,SW_SHOW);
{
char text[128] = {0};
int len=0;
if (in_mod) len=in_mod->GetLength()/1000;
StringCchPrintfA(text,128,"%d:%02d",len/60,len%60);
if (in_mod) len = in_mod->GetOutputTime()/1000;
else len=0;
SetDlgItemTextA(hwndDlg,IDC_TRACKLEN,text);
StringCchPrintfA(text,128,"%d:%02d",len/60,len%60);
SetDlgItemTextA(hwndDlg,IDC_MINUTES,text);
// show jump to time window and restore last position as applicable
POINT pt = {time_rect.left, time_rect.top};
if (!windowOffScreen(hwndDlg, pt))
SetWindowPos(hwndDlg, HWND_TOP, time_rect.left, time_rect.top, 0, 0, SWP_NOSIZE | SWP_NOSENDCHANGING);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
char text[129] = {0};
int m=0,s=0,bt=0;
char *p=text;
GetDlgItemTextA(hwndDlg,IDC_MINUTES,text,sizeof(text));
while (p && *p == ' ') p++;
while (p && *p >= '0' && *p <= '9') {bt=1;s=s*10+*p++-'0';}
if (p && *p++ == ':')
{
m=s;s=0;
while (p && *p >= '0' && *p <= '9') {bt=1;s=s*10+*p++-'0';}
}
if (bt)
{
int time=m*60000+s*1000;
if (time >= 0 && !PlayList_ishidden(PlayList_getPosition()))
{
if (in_seek(time) < 0)
SendMessageW(hMainWindow,WM_WA_MPEG_EOF,0,0);
else
{
ui_drawtime(in_getouttime()/1000,0);
}
}
Sleep(100);
while (1)
{
MSG msg = {0};
if (!PeekMessage(&msg,hMainWindow,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE))
break;
}
}
}
case IDCANCEL:
GetWindowRect(hwndDlg, &time_rect);
DestroyWindow(hwndDlg);
return FALSE;
}
return FALSE;
case WM_DESTROY:
jump_hwnd=0;
return 0;
}
return 0;
}
static void parselist(char *out, const char *in)
{
int inquotes=0, neednull=0;
while (in && *in)
{
char c=*in++;
if (c >= 'A' && c <= 'Z') c+='a'-'A';
if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
{
neednull=1;
*out++=c;
}
else if (c == '\"')
{
inquotes=!inquotes;
if (!inquotes)
{
*out++=0;
neednull=0;
}
}
else
{
if (inquotes) *out++=c;
else if (neednull)
{
*out++=0;
neednull=0;
}
}
}
*out++=0;
*out++=0;
}
extern "C"
{
static int __cdecl substr_search(const char *bigtext, const char *littletext)
{
char littletext_list[128] = {0}, *plist = 0;
char bigtext_list[MAX_PATH*8] = {0};
parselist(littletext_list, littletext);
StringCchCopyA(bigtext_list, MAX_PATH*8, bigtext);
plist = bigtext_list;
while (plist && *plist)
{
if (*plist >= 'A' && *plist <= 'Z') *plist += 'a'-'A';
plist++;
}
plist = littletext_list;
while (plist && *plist)
{
if (!strstr(bigtext_list, plist)) return 0;
plist += lstrlenA(plist) + 1;
}
return 1;
}
static int (__cdecl *jtf_comparator)(const char *, const char *) = substr_search;
static int (__cdecl *jtf_comparatorW)(const wchar_t *, const wchar_t *) = 0;
}
void SetJumpComparator(void *functionPtr)
{
if (functionPtr)
jtf_comparator = (int (__cdecl *)(const char *, const char *))(functionPtr);
else
jtf_comparator = substr_search;
}
void SetJumpComparatorW(void *functionPtr)
{
if (functionPtr)
jtf_comparatorW = (int (__cdecl *)(const wchar_t *, const wchar_t *))(functionPtr);
else
jtf_comparatorW = 0;
}
static WNDPROC oldWndProc;
static LRESULT WINAPI newWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
if ((uMsg == WM_KEYDOWN || uMsg == WM_KEYUP) &&
(wParam == VK_UP || wParam == VK_DOWN || wParam == VK_PRIOR || wParam == VK_NEXT))
{
SendMessageW(GetDlgItem(GetParent(hwndDlg),IDC_SELBOX),uMsg,wParam,lParam);
return 0;
}
return CallWindowProc(oldWndProc,hwndDlg,uMsg,wParam,lParam);
}
static LRESULT WINAPI jumpFileDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
ShowWindow(jump_hwnd2=hwndDlg,SW_SHOW);
{
int x = 0;
HWND hw = GetDlgItem(hwndDlg,IDC_SELBOX);
// prevents showing the full playlist contents on loading as needed
if (!config_jtf_check)
{
int t = PlayList_getPosition();
int v = PlayList_getlength();
SendMessageW(hw,WM_SETREDRAW,FALSE,0);
for (x = 0; x < v; x ++)
{
wchar_t ft[FILETITLE_SIZE] = {0};
PlayList_getitem2W(x, 0, ft);
SendMessageW(hw,LB_SETITEMDATA,SendMessageW(hw,LB_ADDSTRING,0,(LPARAM) ft),x);
}
for (x = 0; x < v; x ++)
{
if (SendMessageW(hw,LB_GETITEMDATA,x,0)==t)
break;
}
SendMessageW(hw,WM_SETREDRAW,TRUE,0);
}
SendMessageW(hw, LB_SETCURSEL, x, 0);
oldWndProc = (WNDPROC) SetWindowLongPtrW(GetDlgItem(hwndDlg, IDC_EDIT1), GWLP_WNDPROC, (LONG_PTR)newWndProc);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
LRESULT x=SendDlgItemMessage(hwndDlg,IDC_SELBOX,LB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SELBOX,LB_GETCURSEL,0,0),0);
if (x >= 0 && x != PlayList_getPosition())
{
PlayList_setposition(x);
PlayList_getcurrent(FileName,FileTitle,FileTitleNum);
StartPlaying();
}
Sleep(100);
while (1)
{
MSG msg = {0};
if (!PeekMessage(&msg,hMainWindow,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE))
break;
}
}
case IDCANCEL:
DestroyWindow(hwndDlg);
return FALSE;
case IDC_SELBOX:
if (HIWORD(wParam) == LBN_DBLCLK)
{
SendMessageW(hwndDlg,WM_COMMAND,IDOK,0);
}
return FALSE;
case IDC_EDIT1:
if (HIWORD(wParam) == EN_CHANGE)
{
wchar_t s[64] = {0};
if(jtf_comparatorW) GetDlgItemTextW(hwndDlg,IDC_EDIT1,s,64);
else GetDlgItemTextA(hwndDlg,IDC_EDIT1,(char*)s,64);
int v = PlayList_getlength();
HWND hw = GetDlgItem(hwndDlg,IDC_SELBOX);
SendMessageW(hw,WM_SETREDRAW,FALSE,0);
SendMessageW(hw,LB_RESETCONTENT,0,0);
// prevents showing the full playlist contents on searching as needed
if (!config_jtf_check || s[0] && config_jtf_check)
{
int x = 0;
for (; x < v; x++)
{
int addtolist = 1;
if (jtf_comparatorW)
{
wchar_t buf[FILENAME_SIZE+FILETITLE_SIZE+1] = {0};
PlayList_getitem_jtfW(x, buf);
addtolist = jtf_comparatorW(buf, s);
}
else
{
char buf[FILENAME_SIZE+FILETITLE_SIZE+1] = {0}, b2[FILETITLE_SIZE] = {0};
PlayList_getitem2(x,buf,b2);
StringCchCatA(buf,FILENAME_SIZE+FILETITLE_SIZE+1," ");
StringCchCatA(buf,FILENAME_SIZE+FILETITLE_SIZE+1,b2);
addtolist = jtf_comparator(buf,(char*)s);
}
if (!s[0] || addtolist)
{
wchar_t b2[FILETITLE_SIZE] = {0};
PlayList_getitem2W(x, 0, b2);
SendMessageW(hw,LB_SETITEMDATA,SendMessageW(hw,LB_ADDSTRING,0,(LPARAM) b2),x);
}
}
SendMessageW(hw,LB_SETCURSEL,0,x);
}
SendMessageW(hw,WM_SETREDRAW,TRUE,0);
}
return FALSE;
}
return FALSE;
case WM_DESTROY:
jump_hwnd2=0;
return 0;
}
return 0;
}
|