Rev 1062 | Rev 1097 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
194 | terminx | 1 | #ifndef RENDERTYPEWIN |
2 | #error Only for Windows |
||
3 | #endif |
||
4 | |||
5 | #include "duke3d.h" |
||
219 | terminx | 6 | #include "sounds.h" |
194 | terminx | 7 | |
8 | #include "build.h" |
||
9 | #include "winlayer.h" |
||
10 | #include "compat.h" |
||
11 | |||
241 | terminx | 12 | #include "grpscan.h" |
214 | terminx | 13 | |
194 | terminx | 14 | #define WIN32_LEAN_AND_MEAN |
15 | #include <windows.h> |
||
16 | #include <windowsx.h> |
||
17 | #define _WIN32_IE 0x0300 |
||
18 | #include <commctrl.h> |
||
19 | #include <stdio.h> |
||
20 | |||
21 | #include "startwin.game.h" |
||
22 | |||
23 | #define TAB_CONFIG 0 |
||
991 | terminx | 24 | // #define TAB_GAME 1 |
25 | #define TAB_MESSAGES 1 |
||
194 | terminx | 26 | |
219 | terminx | 27 | static struct audioenumdrv *wavedevs = NULL; |
28 | |||
335 | terminx | 29 | static struct |
30 | { |
||
222 | terminx | 31 | int fullscreen; |
32 | int xdim, ydim, bpp; |
||
33 | int forcesetup; |
||
34 | int usemouse, usejoy; |
||
35 | char selectedgrp[BMAX_PATH+1]; |
||
241 | terminx | 36 | int game; |
886 | terminx | 37 | int crcval; // for finding the grp in the list again |
984 | terminx | 38 | char *gamedir; |
335 | terminx | 39 | } |
40 | settings; |
||
194 | terminx | 41 | |
42 | static HWND startupdlg = NULL; |
||
335 | terminx | 43 | static HWND pages[3] = |
559 | terminx | 44 | { |
45 | NULL, NULL, NULL |
||
46 | }; |
||
197 | terminx | 47 | static int done = -1, mode = TAB_CONFIG; |
194 | terminx | 48 | |
984 | terminx | 49 | static CACHE1D_FIND_REC *finddirs=NULL; |
50 | static int numdirs=0; |
||
51 | |||
987 | terminx | 52 | static void clearfilenames(void) |
984 | terminx | 53 | { |
54 | klistfree(finddirs); |
||
55 | finddirs = NULL; |
||
56 | numdirs = 0; |
||
57 | } |
||
58 | |||
987 | terminx | 59 | static int getfilenames(char *path) |
984 | terminx | 60 | { |
61 | CACHE1D_FIND_REC *r; |
||
62 | |||
63 | clearfilenames(); |
||
64 | finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); |
||
65 | for (r = finddirs; r; r=r->next) numdirs++; |
||
66 | return(0); |
||
67 | } |
||
68 | |||
219 | terminx | 69 | #define POPULATE_VIDEO 1 |
70 | #define POPULATE_CONFIG 2 |
||
71 | #define POPULATE_GAME 4 |
||
985 | terminx | 72 | #define POPULATE_GAMEDIRS 8 |
219 | terminx | 73 | |
1064 | terminx | 74 | #if defined(POLYMOST) |
988 | terminx | 75 | extern char TEXCACHEDIR[]; |
1064 | terminx | 76 | #endif |
988 | terminx | 77 | |
214 | terminx | 78 | static void PopulateForm(int pgs) |
194 | terminx | 79 | { |
222 | terminx | 80 | HWND hwnd; |
81 | char buf[256]; |
||
82 | int i,j; |
||
219 | terminx | 83 | |
335 | terminx | 84 | if (pgs & POPULATE_VIDEO) |
85 | { |
||
222 | terminx | 86 | int mode; |
194 | terminx | 87 | |
222 | terminx | 88 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); |
194 | terminx | 89 | |
222 | terminx | 90 | mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1); |
335 | terminx | 91 | if (mode < 0) |
92 | { |
||
222 | terminx | 93 | int cd[] = { 32, 24, 16, 15, 8, 0 }; |
335 | terminx | 94 | for (i=0; cd[i];) |
95 | { |
||
96 | if (cd[i] >= settings.bpp) i++; |
||
97 | else break; |
||
98 | } |
||
99 | for (; cd[i]; i++) |
||
100 | { |
||
222 | terminx | 101 | mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); |
102 | if (mode < 0) continue; |
||
103 | settings.bpp = cd[i]; |
||
104 | break; |
||
105 | } |
||
106 | } |
||
214 | terminx | 107 | |
222 | terminx | 108 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); |
649 | terminx | 109 | (void)ComboBox_ResetContent(hwnd); |
335 | terminx | 110 | for (i=0; i<validmodecnt; i++) |
111 | { |
||
222 | terminx | 112 | if (validmode[i].fs != settings.fullscreen) continue; |
214 | terminx | 113 | |
222 | terminx | 114 | // all modes get added to the 3D mode list |
584 | terminx | 115 | Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); |
222 | terminx | 116 | j = ComboBox_AddString(hwnd, buf); |
649 | terminx | 117 | (void)ComboBox_SetItemData(hwnd, j, i); |
723 | terminx | 118 | if (i == mode)(void)ComboBox_SetCurSel(hwnd, j); |
222 | terminx | 119 | } |
120 | } |
||
214 | terminx | 121 | |
335 | terminx | 122 | if (pgs & POPULATE_CONFIG) |
123 | { |
||
222 | terminx | 124 | struct audioenumdev *d; |
125 | char *n; |
||
219 | terminx | 126 | |
222 | terminx | 127 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV); |
649 | terminx | 128 | (void)ComboBox_ResetContent(hwnd); |
335 | terminx | 129 | if (wavedevs) |
130 | { |
||
222 | terminx | 131 | d = wavedevs->devs; |
335 | terminx | 132 | for (i=0; wavedevs->drvs[i]; i++) |
133 | { |
||
222 | terminx | 134 | strcpy(buf, wavedevs->drvs[i]); |
335 | terminx | 135 | if (d->devs) |
136 | { |
||
222 | terminx | 137 | strcat(buf, ":"); |
138 | n = buf + strlen(buf); |
||
335 | terminx | 139 | for (j=0; d->devs[j]; j++) |
140 | { |
||
222 | terminx | 141 | strcpy(n, d->devs[j]); |
649 | terminx | 142 | (void)ComboBox_AddString(hwnd, buf); |
222 | terminx | 143 | } |
335 | terminx | 144 | } |
145 | else |
||
146 | { |
||
649 | terminx | 147 | (void)ComboBox_AddString(hwnd, buf); |
222 | terminx | 148 | } |
149 | d = d->next; |
||
150 | } |
||
151 | } |
||
219 | terminx | 152 | |
222 | terminx | 153 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); |
219 | terminx | 154 | |
222 | terminx | 155 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED)); |
156 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED)); |
||
157 | } |
||
194 | terminx | 158 | |
335 | terminx | 159 | if (pgs & POPULATE_GAME) |
160 | { |
||
222 | terminx | 161 | struct grpfile *fg; |
162 | int i, j; |
||
163 | char buf[128+BMAX_PATH]; |
||
194 | terminx | 164 | |
991 | terminx | 165 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA); |
194 | terminx | 166 | |
335 | terminx | 167 | for (fg = foundgrps; fg; fg=fg->next) |
168 | { |
||
241 | terminx | 169 | for (i = 0; i<numgrpfiles; i++) if (fg->crcval == grpfiles[i].crcval) break; |
222 | terminx | 170 | if (i == numgrpfiles) continue; // unrecognised grp file |
171 | Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name); |
||
172 | j = ListBox_AddString(hwnd, buf); |
||
649 | terminx | 173 | (void)ListBox_SetItemData(hwnd, j, (LPARAM)fg); |
723 | terminx | 174 | if (!Bstrcasecmp(fg->name, settings.selectedgrp))(void)ListBox_SetCurSel(hwnd, j); |
222 | terminx | 175 | } |
176 | } |
||
984 | terminx | 177 | |
985 | terminx | 178 | if (pgs & POPULATE_GAMEDIRS) |
984 | terminx | 179 | { |
180 | CACHE1D_FIND_REC *dirs = NULL; |
||
181 | |||
991 | terminx | 182 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR); |
984 | terminx | 183 | |
184 | getfilenames("/"); |
||
185 | (void)ComboBox_ResetContent(hwnd); |
||
186 | j = ComboBox_AddString(hwnd, "None"); |
||
187 | (void)ComboBox_SetItemData(hwnd, j, 0); |
||
985 | terminx | 188 | (void)ComboBox_SetCurSel(hwnd, j); |
984 | terminx | 189 | for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++) |
190 | { |
||
1064 | terminx | 191 | #if defined(POLYMOST) && defined(USE_OPENGL) |
990 | terminx | 192 | if (Bstrcasecmp(TEXCACHEDIR,dirs->name) == 0) continue; |
1064 | terminx | 193 | #endif |
989 | terminx | 194 | j = ComboBox_AddString(hwnd, dirs->name); |
984 | terminx | 195 | (void)ComboBox_SetItemData(hwnd, j, i); |
990 | terminx | 196 | if (Bstrcasecmp(dirs->name,settings.gamedir) == 0) |
985 | terminx | 197 | (void)ComboBox_SetCurSel(hwnd, j); |
984 | terminx | 198 | } |
199 | } |
||
194 | terminx | 200 | } |
201 | |||
202 | static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
||
203 | { |
||
335 | terminx | 204 | switch (uMsg) |
205 | { |
||
337 | terminx | 206 | case WM_COMMAND: |
207 | switch (LOWORD(wParam)) |
||
208 | { |
||
209 | case IDCFULLSCREEN: |
||
210 | settings.fullscreen = !settings.fullscreen; |
||
211 | PopulateForm(POPULATE_VIDEO); |
||
212 | return TRUE; |
||
213 | case IDCVMODE: |
||
214 | if (HIWORD(wParam) == CBN_SELCHANGE) |
||
335 | terminx | 215 | { |
337 | terminx | 216 | int i; |
217 | i = ComboBox_GetCurSel((HWND)lParam); |
||
218 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
||
219 | if (i != CB_ERR) |
||
220 | { |
||
221 | settings.xdim = validmode[i].xdim; |
||
222 | settings.ydim = validmode[i].ydim; |
||
223 | settings.bpp = validmode[i].bpp; |
||
224 | } |
||
222 | terminx | 225 | } |
337 | terminx | 226 | return TRUE; |
227 | case IDCALWAYSSHOW: |
||
228 | settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; |
||
229 | return TRUE; |
||
230 | case IDCINPUTMOUSE: |
||
231 | settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED; |
||
232 | return TRUE; |
||
233 | case IDCINPUTJOY: |
||
234 | settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED; |
||
235 | return TRUE; |
||
991 | terminx | 236 | case IDCGAMEDIR: |
984 | terminx | 237 | if (HIWORD(wParam) == CBN_SELCHANGE) |
238 | { |
||
239 | int i,j; |
||
240 | CACHE1D_FIND_REC *dir = NULL; |
||
241 | i = ComboBox_GetCurSel((HWND)lParam); |
||
242 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
||
243 | if (i != CB_ERR) |
||
244 | { |
||
1062 | terminx | 245 | if (i==0) |
246 | settings.gamedir = NULL; |
||
247 | else |
||
248 | { |
||
249 | for (j=1,dir=finddirs;dir != NULL;dir=dir->next,j++) |
||
250 | if (j == i) |
||
251 | { |
||
252 | settings.gamedir = dir->name; |
||
253 | break; |
||
254 | } |
||
255 | } |
||
984 | terminx | 256 | } |
257 | } |
||
258 | return TRUE; |
||
991 | terminx | 259 | case IDCDATA: |
260 | { |
||
261 | int i; |
||
262 | if (HIWORD(wParam) != LBN_SELCHANGE) break; |
||
263 | i = ListBox_GetCurSel((HWND)lParam); |
||
264 | if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); |
||
265 | if (i != CB_ERR) |
||
266 | { |
||
267 | strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); |
||
268 | settings.game = ((struct grpfile*)i)->game; |
||
269 | settings.crcval = ((struct grpfile*)i)->crcval; |
||
270 | } |
||
271 | return TRUE; |
||
272 | } |
||
331 | terminx | 273 | default: |
274 | break; |
||
337 | terminx | 275 | } |
276 | break; |
||
277 | default: |
||
278 | break; |
||
222 | terminx | 279 | } |
280 | return FALSE; |
||
214 | terminx | 281 | } |
194 | terminx | 282 | |
283 | |||
284 | static void SetPage(int n) |
||
285 | { |
||
222 | terminx | 286 | HWND tab; |
287 | int cur; |
||
288 | tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
||
289 | cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0); |
||
290 | ShowWindow(pages[cur],SW_HIDE); |
||
291 | SendMessage(tab, TCM_SETCURSEL, n, 0); |
||
292 | ShowWindow(pages[n],SW_SHOW); |
||
293 | mode = n; |
||
196 | terminx | 294 | |
222 | terminx | 295 | SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); |
194 | terminx | 296 | } |
297 | |||
298 | static void EnableConfig(int n) |
||
299 | { |
||
222 | terminx | 300 | //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); |
301 | EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); |
||
302 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); |
||
303 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); |
||
304 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n); |
||
305 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n); |
||
214 | terminx | 306 | |
991 | terminx | 307 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n); |
308 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n); |
||
194 | terminx | 309 | } |
310 | |||
311 | static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
||
312 | { |
||
222 | terminx | 313 | static HBITMAP hbmp = NULL; |
314 | HDC hdc; |
||
194 | terminx | 315 | |
335 | terminx | 316 | switch (uMsg) |
317 | { |
||
337 | terminx | 318 | case WM_INITDIALOG: |
319 | { |
||
320 | HWND hwnd; |
||
321 | RECT r, rdlg, chrome, rtab, rcancel, rstart; |
||
322 | int xoffset = 0, yoffset = 0; |
||
194 | terminx | 323 | |
337 | terminx | 324 | // Fetch the positions (in screen coordinates) of all the windows we need to tweak |
325 | ZeroMemory(&chrome, sizeof(chrome)); |
||
326 | AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); |
||
327 | GetWindowRect(hwndDlg, &rdlg); |
||
328 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); |
||
329 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); |
||
330 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); |
||
194 | terminx | 331 | |
337 | terminx | 332 | // Knock off the non-client area of the main dialogue to give just the client area |
333 | rdlg.left -= chrome.left; |
||
334 | rdlg.top -= chrome.top; |
||
335 | rdlg.right -= chrome.right; |
||
336 | rdlg.bottom -= chrome.bottom; |
||
194 | terminx | 337 | |
337 | terminx | 338 | // Translate them to client-relative coordinates wrt the main dialogue window |
339 | rtab.right -= rtab.left - 1; |
||
340 | rtab.bottom -= rtab.top - 1; |
||
341 | rtab.left -= rdlg.left; |
||
342 | rtab.top -= rdlg.top; |
||
194 | terminx | 343 | |
337 | terminx | 344 | rcancel.right -= rcancel.left - 1; |
345 | rcancel.bottom -= rcancel.top - 1; |
||
346 | rcancel.left -= rdlg.left; |
||
347 | rcancel.top -= rdlg.top; |
||
194 | terminx | 348 | |
337 | terminx | 349 | rstart.right -= rstart.left - 1; |
350 | rstart.bottom -= rstart.top - 1; |
||
351 | rstart.left -= rdlg.left; |
||
352 | rstart.top -= rdlg.top; |
||
194 | terminx | 353 | |
337 | terminx | 354 | // And then convert the main dialogue coordinates to just width/length |
355 | rdlg.right -= rdlg.left - 1; |
||
356 | rdlg.bottom -= rdlg.top - 1; |
||
357 | rdlg.left = 0; |
||
358 | rdlg.top = 0; |
||
194 | terminx | 359 | |
337 | terminx | 360 | // Load the bitmap into the bitmap control and fetch its dimensions |
361 | hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); |
||
362 | hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); |
||
363 | SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); |
||
364 | GetClientRect(hwnd, &r); |
||
365 | xoffset = r.right; |
||
366 | yoffset = r.bottom - rdlg.bottom; |
||
194 | terminx | 367 | |
337 | terminx | 368 | // Shift and resize the controls that require it |
369 | rtab.left += xoffset; |
||
370 | rtab.bottom += yoffset; |
||
371 | rcancel.left += xoffset; |
||
372 | rcancel.top += yoffset; |
||
373 | rstart.left += xoffset; |
||
374 | rstart.top += yoffset; |
||
375 | rdlg.right += xoffset; |
||
376 | rdlg.bottom += yoffset; |
||
194 | terminx | 377 | |
337 | terminx | 378 | // Move the controls to their new positions |
379 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); |
||
380 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); |
||
381 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); |
||
194 | terminx | 382 | |
337 | terminx | 383 | // Move the main dialogue to the centre of the screen |
384 | hdc = GetDC(NULL); |
||
385 | rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; |
||
386 | rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; |
||
387 | ReleaseDC(NULL, hdc); |
||
388 | MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, |
||
389 | rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); |
||
194 | terminx | 390 | |
337 | terminx | 391 | // Add tabs to the tab control |
392 | { |
||
393 | TCITEM tab; |
||
194 | terminx | 394 | |
337 | terminx | 395 | hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); |
194 | terminx | 396 | |
337 | terminx | 397 | ZeroMemory(&tab, sizeof(tab)); |
398 | tab.mask = TCIF_TEXT; |
||
399 | tab.pszText = TEXT("Configuration"); |
||
400 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); |
||
401 | tab.mask = TCIF_TEXT; |
||
402 | tab.pszText = TEXT("Messages"); |
||
403 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); |
||
194 | terminx | 404 | |
337 | terminx | 405 | // Work out the position and size of the area inside the tab control for the pages |
406 | ZeroMemory(&r, sizeof(r)); |
||
407 | GetClientRect(hwnd, &r); |
||
408 | SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); |
||
409 | r.right -= r.left-1; |
||
410 | r.bottom -= r.top-1; |
||
411 | r.top += rtab.top; |
||
412 | r.left += rtab.left; |
||
194 | terminx | 413 | |
337 | terminx | 414 | // Create the pages and position them in the tab control, but hide them |
415 | pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), |
||
416 | MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); |
||
417 | pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); |
||
418 | SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
||
419 | SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
||
194 | terminx | 420 | |
337 | terminx | 421 | // Tell the editfield acting as the console to exclude the width of the scrollbar |
422 | GetClientRect(pages[TAB_MESSAGES],&r); |
||
423 | r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; |
||
424 | r.left = r.top = 0; |
||
425 | SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); |
||
194 | terminx | 426 | |
337 | terminx | 427 | // Set a tab stop in the game data listbox |
428 | { |
||
429 | DWORD tabs[1] = { 150 }; |
||
991 | terminx | 430 | (void)ListBox_SetTabStops(GetDlgItem(pages[TAB_CONFIG], IDCDATA), 1, tabs); |
337 | terminx | 431 | } |
335 | terminx | 432 | |
337 | terminx | 433 | SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); |
434 | SetWindowText(hwndDlg, apptitle); |
||
335 | terminx | 435 | } |
337 | terminx | 436 | return FALSE; |
437 | } |
||
335 | terminx | 438 | |
337 | terminx | 439 | case WM_NOTIFY: |
440 | { |
||
441 | LPNMHDR nmhdr = (LPNMHDR)lParam; |
||
442 | int cur; |
||
443 | if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; |
||
444 | cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); |
||
445 | switch (nmhdr->code) |
||
335 | terminx | 446 | { |
337 | terminx | 447 | case TCN_SELCHANGING: |
448 | { |
||
449 | if (cur < 0 || !pages[cur]) break; |
||
450 | ShowWindow(pages[cur],SW_HIDE); |
||
451 | return TRUE; |
||
222 | terminx | 452 | } |
337 | terminx | 453 | case TCN_SELCHANGE: |
454 | { |
||
455 | if (cur < 0 || !pages[cur]) break; |
||
456 | ShowWindow(pages[cur],SW_SHOW); |
||
331 | terminx | 457 | return TRUE; |
337 | terminx | 458 | } |
459 | } |
||
460 | break; |
||
461 | } |
||
194 | terminx | 462 | |
337 | terminx | 463 | case WM_CLOSE: |
464 | if (mode == TAB_CONFIG) done = 0; |
||
465 | else quitevent++; |
||
466 | return TRUE; |
||
194 | terminx | 467 | |
337 | terminx | 468 | case WM_DESTROY: |
469 | if (hbmp) |
||
470 | { |
||
471 | DeleteObject(hbmp); |
||
472 | hbmp = NULL; |
||
473 | } |
||
194 | terminx | 474 | |
337 | terminx | 475 | if (pages[TAB_CONFIG]) |
476 | { |
||
477 | DestroyWindow(pages[TAB_CONFIG]); |
||
478 | pages[TAB_CONFIG] = NULL; |
||
479 | } |
||
480 | |||
481 | startupdlg = NULL; |
||
482 | return TRUE; |
||
483 | |||
484 | case WM_COMMAND: |
||
485 | switch (LOWORD(wParam)) |
||
486 | { |
||
487 | case WIN_STARTWIN_CANCEL: |
||
488 | if (mode == TAB_CONFIG) done = 0; |
||
489 | else quitevent++; |
||
335 | terminx | 490 | return TRUE; |
337 | terminx | 491 | case WIN_STARTWIN_START: |
492 | done = 1; |
||
493 | return TRUE; |
||
494 | } |
||
495 | return FALSE; |
||
194 | terminx | 496 | |
337 | terminx | 497 | case WM_CTLCOLORSTATIC: |
498 | if ((HWND)lParam == pages[TAB_MESSAGES]) |
||
499 | return (BOOL)GetSysColorBrush(COLOR_WINDOW); |
||
500 | break; |
||
194 | terminx | 501 | |
337 | terminx | 502 | default: |
503 | break; |
||
222 | terminx | 504 | } |
505 | |||
506 | return FALSE; |
||
194 | terminx | 507 | } |
508 | |||
509 | |||
510 | int startwin_open(void) |
||
511 | { |
||
222 | terminx | 512 | INITCOMMONCONTROLSEX icc; |
513 | if (startupdlg) return 1; |
||
514 | icc.dwSize = sizeof(icc); |
||
515 | icc.dwICC = ICC_TAB_CLASSES; |
||
516 | InitCommonControlsEx(&icc); |
||
517 | startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); |
||
335 | terminx | 518 | if (startupdlg) |
519 | { |
||
222 | terminx | 520 | SetPage(TAB_MESSAGES); |
521 | EnableConfig(0); |
||
522 | return 0; |
||
523 | } |
||
524 | return -1; |
||
194 | terminx | 525 | } |
526 | |||
527 | int startwin_close(void) |
||
528 | { |
||
222 | terminx | 529 | if (!startupdlg) return 1; |
530 | DestroyWindow(startupdlg); |
||
531 | startupdlg = NULL; |
||
532 | return 0; |
||
194 | terminx | 533 | } |
534 | |||
535 | int startwin_puts(const char *buf) |
||
536 | { |
||
222 | terminx | 537 | const char *p = NULL, *q = NULL; |
851 | terminx | 538 | static char workbuf[1024]; |
222 | terminx | 539 | static int newline = 0; |
540 | int curlen, linesbefore, linesafter; |
||
541 | HWND edctl; |
||
542 | int vis; |
||
851 | terminx | 543 | static HWND dactrl = NULL; |
194 | terminx | 544 | |
222 | terminx | 545 | if (!startupdlg) return 1; |
194 | terminx | 546 | |
222 | terminx | 547 | edctl = pages[TAB_MESSAGES]; |
548 | if (!edctl) return -1; |
||
194 | terminx | 549 | |
851 | terminx | 550 | if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
222 | terminx | 551 | |
851 | terminx | 552 | vis = ((int)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES); |
553 | |||
222 | terminx | 554 | if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); |
555 | curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); |
||
556 | SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); |
||
557 | linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
||
558 | p = buf; |
||
335 | terminx | 559 | while (*p) |
560 | { |
||
561 | if (newline) |
||
562 | { |
||
222 | terminx | 563 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); |
564 | newline = 0; |
||
565 | } |
||
566 | q = p; |
||
567 | while (*q && *q != '\n') q++; |
||
568 | memcpy(workbuf, p, q-p); |
||
335 | terminx | 569 | if (*q == '\n') |
570 | { |
||
571 | if (!q[1]) |
||
572 | { |
||
222 | terminx | 573 | newline = 1; |
574 | workbuf[q-p] = 0; |
||
335 | terminx | 575 | } |
576 | else |
||
577 | { |
||
222 | terminx | 578 | workbuf[q-p] = '\r'; |
579 | workbuf[q-p+1] = '\n'; |
||
580 | workbuf[q-p+2] = 0; |
||
581 | } |
||
582 | p = q+1; |
||
335 | terminx | 583 | } |
584 | else |
||
585 | { |
||
222 | terminx | 586 | workbuf[q-p] = 0; |
587 | p = q; |
||
588 | } |
||
589 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); |
||
590 | } |
||
591 | linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
||
592 | SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); |
||
593 | if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); |
||
594 | return 0; |
||
194 | terminx | 595 | } |
596 | |||
597 | int startwin_settitle(const char *str) |
||
598 | { |
||
222 | terminx | 599 | if (!startupdlg) return 1; |
600 | SetWindowText(startupdlg, str); |
||
601 | return 0; |
||
194 | terminx | 602 | } |
603 | |||
604 | int startwin_idle(void *v) |
||
605 | { |
||
222 | terminx | 606 | if (!startupdlg || !IsWindow(startupdlg)) return 0; |
607 | if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; |
||
608 | return 0; |
||
194 | terminx | 609 | } |
610 | |||
611 | int startwin_run(void) |
||
612 | { |
||
222 | terminx | 613 | MSG msg; |
614 | if (!startupdlg) return 1; |
||
194 | terminx | 615 | |
222 | terminx | 616 | done = -1; |
194 | terminx | 617 | |
219 | terminx | 618 | #ifdef JFAUD |
222 | terminx | 619 | EnumAudioDevs(&wavedevs, NULL, NULL); |
219 | terminx | 620 | #endif |
222 | terminx | 621 | SetPage(TAB_CONFIG); |
622 | EnableConfig(1); |
||
194 | terminx | 623 | |
563 | terminx | 624 | settings.fullscreen = ud.config.ScreenMode; |
625 | settings.xdim = ud.config.ScreenWidth; |
||
626 | settings.ydim = ud.config.ScreenHeight; |
||
627 | settings.bpp = ud.config.ScreenBPP; |
||
628 | settings.forcesetup = ud.config.ForceSetup; |
||
629 | settings.usemouse = ud.config.UseMouse; |
||
630 | settings.usejoy = ud.config.UseJoystick; |
||
561 | terminx | 631 | settings.game = g_GameType; |
886 | terminx | 632 | // settings.crcval = 0; |
222 | terminx | 633 | strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); |
984 | terminx | 634 | settings.gamedir = mod_dir; |
222 | terminx | 635 | PopulateForm(-1); |
194 | terminx | 636 | |
335 | terminx | 637 | while (done < 0) |
638 | { |
||
639 | switch (GetMessage(&msg, NULL, 0,0)) |
||
640 | { |
||
337 | terminx | 641 | case 0: |
642 | done = 1; |
||
643 | break; |
||
644 | case -1: |
||
645 | return -1; |
||
646 | default: |
||
647 | if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; |
||
648 | TranslateMessage(&msg); |
||
649 | DispatchMessage(&msg); |
||
650 | break; |
||
222 | terminx | 651 | } |
652 | } |
||
194 | terminx | 653 | |
222 | terminx | 654 | SetPage(TAB_MESSAGES); |
655 | EnableConfig(0); |
||
335 | terminx | 656 | if (done) |
657 | { |
||
886 | terminx | 658 | int i; |
659 | |||
563 | terminx | 660 | ud.config.ScreenMode = settings.fullscreen; |
661 | ud.config.ScreenWidth = settings.xdim; |
||
662 | ud.config.ScreenHeight = settings.ydim; |
||
663 | ud.config.ScreenBPP = settings.bpp; |
||
664 | ud.config.ForceSetup = settings.forcesetup; |
||
665 | ud.config.UseMouse = settings.usemouse; |
||
666 | ud.config.UseJoystick = settings.usejoy; |
||
222 | terminx | 667 | duke3dgrp = settings.selectedgrp; |
561 | terminx | 668 | g_GameType = settings.game; |
990 | terminx | 669 | |
985 | terminx | 670 | if (settings.gamedir != NULL) |
984 | terminx | 671 | Bstrcpy(mod_dir,settings.gamedir); |
989 | terminx | 672 | else Bsprintf(mod_dir,"/"); |
886 | terminx | 673 | |
674 | for (i = 0; i<numgrpfiles; i++) if (settings.crcval == grpfiles[i].crcval) break; |
||
675 | if (i != numgrpfiles) |
||
676 | duke3dgrpstring = (char *)grpfiles[i].name; |
||
222 | terminx | 677 | } |
194 | terminx | 678 | |
335 | terminx | 679 | if (wavedevs) |
680 | { |
||
222 | terminx | 681 | struct audioenumdev *d, *e; |
682 | free(wavedevs->drvs); |
||
335 | terminx | 683 | for (e=wavedevs->devs; e; e=d) |
684 | { |
||
222 | terminx | 685 | d = e->next; |
686 | if (e->devs) free(e->devs); |
||
687 | free(e); |
||
688 | } |
||
689 | free(wavedevs); |
||
690 | } |
||
219 | terminx | 691 | |
222 | terminx | 692 | return done; |
194 | terminx | 693 | } |
694 |