Rev 4541 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4541 | Rev 5062 | ||
---|---|---|---|
1 | //-------------------------------------------------------------------------
|
1 | //-------------------------------------------------------------------------
|
2 | /*
|
2 | /*
|
3 | Copyright (C) 2010 EDuke32 developers and contributors
|
3 | Copyright (C) 2010 EDuke32 developers and contributors
|
4 | 4 | ||
5 | This file is part of EDuke32.
|
5 | This file is part of EDuke32.
|
6 | 6 | ||
7 | EDuke32 is free software; you can redistribute it and/or
|
7 | EDuke32 is free software; you can redistribute it and/or
|
8 | modify it under the terms of the GNU General Public License version 2
|
8 | modify it under the terms of the GNU General Public License version 2
|
9 | as published by the Free Software Foundation.
|
9 | as published by the Free Software Foundation.
|
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful,
|
11 | This program is distributed in the hope that it will be useful,
|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
14 | 14 | ||
15 | See the GNU General Public License for more details.
|
15 | See the GNU General Public License for more details.
|
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License
|
17 | You should have received a copy of the GNU General Public License
|
18 | along with this program; if not, write to the Free Software
|
18 | along with this program; if not, write to the Free Software
|
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20 | */
|
20 | */
|
21 | //-------------------------------------------------------------------------
|
21 | //-------------------------------------------------------------------------
|
22 | 22 | ||
23 | #ifndef _WIN32
|
23 | #ifndef _WIN32
|
24 | #error Only for Windows
|
24 | #error Only for Windows
|
25 | #endif
|
25 | #endif
|
26 | 26 | ||
27 | #include "duke3d.h"
|
27 | #include "duke3d.h"
|
28 | #include "sounds.h"
|
28 | #include "sounds.h"
|
29 | 29 | ||
30 | #include "build.h"
|
30 | #include "build.h"
|
31 | #include "renderlayer.h"
|
31 | #include "renderlayer.h"
|
32 | #include "compat.h"
|
32 | #include "compat.h"
|
33 | 33 | ||
34 | #include "grpscan.h"
|
34 | #include "grpscan.h"
|
35 | 35 | ||
36 | #define WIN32_LEAN_AND_MEAN
|
36 | #define WIN32_LEAN_AND_MEAN
|
37 | #include <windows.h>
|
37 | #include <windows.h>
|
38 | #include <windowsx.h>
|
38 | #include <windowsx.h>
|
39 | #ifndef _WIN32_IE
|
39 | #ifndef _WIN32_IE
|
40 | #define _WIN32_IE 0x0300
|
40 | #define _WIN32_IE 0x0300
|
41 | #endif
|
41 | #endif
|
42 | #include <commctrl.h>
|
42 | #include <commctrl.h>
|
43 | #include <stdio.h>
|
43 | #include <stdio.h>
|
44 | 44 | ||
45 | #include "startwin.game.h"
|
45 | #include "startwin.game.h"
|
46 | 46 | ||
47 | #include "game.h"
|
47 | #include "game.h"
|
48 | #include "common.h"
|
48 | #include "common.h"
|
49 | #include "common_game.h"
|
49 | #include "common_game.h"
|
50 | 50 | ||
51 | #define TAB_CONFIG 0
|
51 | #define TAB_CONFIG 0
|
52 | // #define TAB_GAME 1
|
52 | // #define TAB_GAME 1
|
53 | #define TAB_MESSAGES 1
|
53 | #define TAB_MESSAGES 1
|
54 | 54 | ||
55 | static struct audioenumdrv *wavedevs = NULL; |
55 | static struct audioenumdrv *wavedevs = NULL; |
56 | 56 | ||
57 | static struct |
57 | static struct |
58 | {
|
58 | {
|
59 | int32_t flags; // bitfield |
59 | int32_t flags; // bitfield |
60 | int32_t xdim, ydim, bpp; |
60 | int32_t xdim, ydim, bpp; |
61 | int32_t forcesetup; |
61 | int32_t forcesetup; |
62 | int32_t usemouse, usejoy; |
62 | int32_t usemouse, usejoy; |
63 | int32_t game; |
63 | int32_t game; |
64 | int32_t crcval; // for finding the grp in the list again |
64 | int32_t crcval; // for finding the grp in the list again |
65 | char *gamedir; |
65 | char *gamedir; |
66 | char selectedgrp[BMAX_PATH]; |
66 | char selectedgrp[BMAX_PATH]; |
67 | }
|
67 | }
|
68 | settings;
|
68 | settings;
|
69 | 69 | ||
70 | static HWND startupdlg = NULL; |
70 | static HWND startupdlg = NULL; |
71 | static HWND pages[3] = |
71 | static HWND pages[3] = |
72 | {
|
72 | {
|
73 | NULL, NULL, NULL |
73 | NULL, NULL, NULL |
74 | }; |
74 | }; |
75 | static int32_t done = -1, mode = TAB_CONFIG; |
75 | static int32_t done = -1, mode = TAB_CONFIG; |
76 | 76 | ||
77 | static CACHE1D_FIND_REC *finddirs=NULL; |
77 | static CACHE1D_FIND_REC *finddirs=NULL; |
78 | static int32_t numdirs=0; |
78 | static int32_t numdirs=0; |
79 | 79 | ||
80 | static inline void clearfilenames(void) |
80 | static inline void clearfilenames(void) |
81 | {
|
81 | {
|
82 | klistfree(finddirs); |
82 | klistfree(finddirs); |
83 | finddirs = NULL; |
83 | finddirs = NULL; |
84 | numdirs = 0; |
84 | numdirs = 0; |
85 | }
|
85 | }
|
86 | 86 | ||
87 | static inline int32_t getfilenames(char *path) |
87 | static inline int32_t getfilenames(char *path) |
88 | {
|
88 | {
|
89 | CACHE1D_FIND_REC *r; |
89 | CACHE1D_FIND_REC *r; |
90 | 90 | ||
91 | clearfilenames(); |
91 | clearfilenames(); |
92 | finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); |
92 | finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); |
93 | for (r = finddirs; r; r=r->next) numdirs++; |
93 | for (r = finddirs; r; r=r->next) numdirs++; |
94 | return(0); |
94 | return(0); |
95 | }
|
95 | }
|
96 | 96 | ||
97 | #define POPULATE_VIDEO 1
|
97 | #define POPULATE_VIDEO 1
|
98 | #define POPULATE_CONFIG 2
|
98 | #define POPULATE_CONFIG 2
|
99 | #define POPULATE_GAME 4
|
99 | #define POPULATE_GAME 4
|
100 | #define POPULATE_GAMEDIRS 8
|
100 | #define POPULATE_GAMEDIRS 8
|
101 | 101 | ||
102 | extern int32_t g_noSetup; |
102 | extern int32_t g_noSetup; |
103 | 103 | ||
104 | #ifdef INPUT_MOUSE
|
104 | #ifdef INPUT_MOUSE
|
105 | #undef INPUT_MOUSE
|
105 | #undef INPUT_MOUSE
|
106 | #endif
|
106 | #endif
|
107 | 107 | ||
108 | #define INPUT_KB 0
|
108 | #define INPUT_KB 0
|
109 | #define INPUT_MOUSE 1
|
109 | #define INPUT_MOUSE 1
|
110 | #define INPUT_JOYSTICK 2
|
110 | #define INPUT_JOYSTICK 2
|
111 | #define INPUT_ALL 3
|
111 | #define INPUT_ALL 3
|
112 | 112 | ||
113 | const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboard and joystick", "All supported devices" }; |
113 | const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboard and joystick", "All supported devices" }; |
114 | 114 | ||
115 | static void PopulateForm(int32_t pgs) |
115 | static void PopulateForm(int32_t pgs) |
116 | {
|
116 | {
|
117 | HWND hwnd;
|
117 | HWND hwnd;
|
118 | char buf[512]; |
118 | char buf[512]; |
119 | int32_t i,j; |
119 | int32_t i,j; |
120 | 120 | ||
121 | if (pgs & POPULATE_GAMEDIRS) |
121 | if (pgs & POPULATE_GAMEDIRS) |
122 | {
|
122 | {
|
123 | CACHE1D_FIND_REC *dirs = NULL; |
123 | CACHE1D_FIND_REC *dirs = NULL; |
124 | 124 | ||
125 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR); |
125 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR); |
126 | 126 | ||
127 | getfilenames("/"); |
127 | getfilenames("/"); |
128 | (void)ComboBox_ResetContent(hwnd); |
128 | (void)ComboBox_ResetContent(hwnd); |
129 | j = ComboBox_AddString(hwnd, "None"); |
129 | j = ComboBox_AddString(hwnd, "None"); |
130 | (void)ComboBox_SetItemData(hwnd, j, 0); |
130 | (void)ComboBox_SetItemData(hwnd, j, 0); |
131 | (void)ComboBox_SetCurSel(hwnd, j); |
131 | (void)ComboBox_SetCurSel(hwnd, j); |
132 | for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++) |
132 | for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++) |
133 | {
|
133 | {
|
134 | (void)ComboBox_AddString(hwnd, dirs->name); |
134 | (void)ComboBox_AddString(hwnd, dirs->name); |
135 | (void)ComboBox_SetItemData(hwnd, i, i); |
135 | (void)ComboBox_SetItemData(hwnd, i, i); |
136 | if (Bstrcasecmp(dirs->name,settings.gamedir) == 0) |
136 | if (Bstrcasecmp(dirs->name,settings.gamedir) == 0) |
137 | (void)ComboBox_SetCurSel(hwnd, i); |
137 | (void)ComboBox_SetCurSel(hwnd, i); |
138 | }
|
138 | }
|
139 | }
|
139 | }
|
140 | 140 | ||
141 | if (pgs & POPULATE_VIDEO) |
141 | if (pgs & POPULATE_VIDEO) |
142 | {
|
142 | {
|
143 | int32_t mode; |
143 | int32_t mode; |
144 | 144 | ||
145 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); |
145 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); |
146 | 146 | ||
147 | mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.flags&1, 1); |
147 | mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.flags&1, 1); |
148 | if (mode < 0 || (settings.bpp < 15 && (settings.flags & 2))) |
148 | if (mode < 0 || (settings.bpp < 15 && (settings.flags & 2))) |
149 | {
|
149 | {
|
150 | int32_t cd[] = { 32, 24, 16, 15, 8, 0 }; |
150 | int32_t cd[] = { 32, 24, 16, 15, 8, 0 }; |
151 | for (i=0; cd[i];) |
151 | for (i=0; cd[i];) |
152 | {
|
152 | {
|
153 | if (cd[i] >= settings.bpp) i++; |
153 | if (cd[i] >= settings.bpp) i++; |
154 | else break; |
154 | else break; |
155 | }
|
155 | }
|
156 | for (; cd[i]; i++) |
156 | for (; cd[i]; i++) |
157 | {
|
157 | {
|
158 | mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.flags&1, 1); |
158 | mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.flags&1, 1); |
159 | if (mode < 0) continue; |
159 | if (mode < 0) continue; |
160 | settings.bpp = cd[i]; |
160 | settings.bpp = cd[i]; |
161 | break; |
161 | break; |
162 | }
|
162 | }
|
163 | }
|
163 | }
|
164 | 164 | ||
165 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.flags&1) ? BST_CHECKED : BST_UNCHECKED)); |
165 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.flags&1) ? BST_CHECKED : BST_UNCHECKED)); |
166 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.flags&2) ? BST_CHECKED : BST_UNCHECKED)); |
166 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.flags&2) ? BST_CHECKED : BST_UNCHECKED)); |
167 | 167 | ||
168 | (void)ComboBox_ResetContent(hwnd); |
168 | (void)ComboBox_ResetContent(hwnd); |
169 | 169 | ||
170 | for (i=0; i<validmodecnt; i++) |
170 | for (i=0; i<validmodecnt; i++) |
171 | {
|
171 | {
|
172 | if (validmode[i].fs != (settings.flags & 1)) continue; |
172 | if (validmode[i].fs != (settings.flags & 1)) continue; |
173 | if ((validmode[i].bpp < 15) && (settings.flags & 2)) continue; |
173 | if ((validmode[i].bpp < 15) && (settings.flags & 2)) continue; |
174 | 174 | ||
175 | // all modes get added to the 3D mode list
|
175 | // all modes get added to the 3D mode list
|
176 | Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); |
176 | Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); |
177 | j = ComboBox_AddString(hwnd, buf); |
177 | j = ComboBox_AddString(hwnd, buf); |
178 | (void)ComboBox_SetItemData(hwnd, j, i); |
178 | (void)ComboBox_SetItemData(hwnd, j, i); |
179 | if (i == mode)(void)ComboBox_SetCurSel(hwnd, j); |
179 | if (i == mode)(void)ComboBox_SetCurSel(hwnd, j); |
180 | }
|
180 | }
|
181 | }
|
181 | }
|
182 | 182 | ||
183 | if (pgs & POPULATE_CONFIG) |
183 | if (pgs & POPULATE_CONFIG) |
184 | {
|
184 | {
|
185 | #if 0
|
185 | #if 0
|
186 | struct audioenumdev *d; |
186 | struct audioenumdev *d; |
187 | char *n; |
187 | char *n; |
188 | 188 | ||
189 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV); |
189 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV); |
190 | (void)ComboBox_ResetContent(hwnd); |
190 | (void)ComboBox_ResetContent(hwnd); |
191 | if (wavedevs) |
191 | if (wavedevs) |
192 | {
|
192 | {
|
193 | d = wavedevs->devs; |
193 | d = wavedevs->devs; |
194 | for (i=0; wavedevs->drvs[i]; i++) |
194 | for (i=0; wavedevs->drvs[i]; i++) |
195 | {
|
195 | {
|
196 | strcpy(buf, wavedevs->drvs[i]); |
196 | strcpy(buf, wavedevs->drvs[i]); |
197 | if (d->devs) |
197 | if (d->devs) |
198 | {
|
198 | {
|
199 | strcat(buf, ":"); |
199 | strcat(buf, ":"); |
200 | n = buf + strlen(buf); |
200 | n = buf + strlen(buf); |
201 | for (j=0; d->devs[j]; j++) |
201 | for (j=0; d->devs[j]; j++) |
202 | {
|
202 | {
|
203 | strcpy(n, d->devs[j]); |
203 | strcpy(n, d->devs[j]); |
204 | (void)ComboBox_AddString(hwnd, buf); |
204 | (void)ComboBox_AddString(hwnd, buf); |
205 | }
|
205 | }
|
206 | }
|
206 | }
|
207 | else
|
207 | else
|
208 | {
|
208 | {
|
209 | (void)ComboBox_AddString(hwnd, buf); |
209 | (void)ComboBox_AddString(hwnd, buf); |
210 | }
|
210 | }
|
211 | d = d->next; |
211 | d = d->next; |
212 | }
|
212 | }
|
213 | }
|
213 | }
|
214 | #endif
|
214 | #endif
|
215 | 215 | ||
216 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); |
216 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); |
217 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.flags & 4) ? BST_CHECKED : BST_UNCHECKED)); |
217 | Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.flags & 4) ? BST_CHECKED : BST_UNCHECKED)); |
218 | 218 | ||
219 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT); |
219 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT); |
220 | 220 | ||
221 | (void)ComboBox_ResetContent(hwnd); |
221 | (void)ComboBox_ResetContent(hwnd); |
222 | (void)ComboBox_SetCurSel(hwnd, 0); |
222 | (void)ComboBox_SetCurSel(hwnd, 0); |
223 | 223 | ||
224 | j = 4; |
224 | j = 4; |
225 | 225 | ||
226 | #ifdef RENDERTYPEWIN
|
226 | #ifdef RENDERTYPEWIN
|
227 | if (di_disabled) j = 2; |
227 | if (di_disabled) j = 2; |
228 | #endif
|
228 | #endif
|
229 | 229 | ||
230 | for (i=0; i<j; i++) |
230 | for (i=0; i<j; i++) |
231 | {
|
231 | {
|
232 | (void)ComboBox_InsertString(hwnd, i, controlstrings[i]); |
232 | (void)ComboBox_InsertString(hwnd, i, controlstrings[i]); |
233 | (void)ComboBox_SetItemData(hwnd, i, i); |
233 | (void)ComboBox_SetItemData(hwnd, i, i); |
234 | 234 | ||
235 | switch (i) |
235 | switch (i) |
236 | {
|
236 | {
|
237 | case INPUT_MOUSE: |
237 | case INPUT_MOUSE: |
238 | if (settings.usemouse && !settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
238 | if (settings.usemouse && !settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
239 | break; |
239 | break; |
240 | case INPUT_JOYSTICK: |
240 | case INPUT_JOYSTICK: |
241 | if (!settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
241 | if (!settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
242 | break; |
242 | break; |
243 | case INPUT_ALL: |
243 | case INPUT_ALL: |
244 | if (settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
244 | if (settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); |
245 | break; |
245 | break; |
246 | }
|
246 | }
|
247 | }
|
247 | }
|
248 | }
|
248 | }
|
249 | 249 | ||
250 | if (pgs & POPULATE_GAME) |
250 | if (pgs & POPULATE_GAME) |
251 | {
|
251 | {
|
252 | struct grpfile *fg; |
252 | struct grpfile *fg; |
253 | int32_t j; |
253 | int32_t j; |
254 | char buf[1024]; |
254 | char buf[1024]; |
255 | 255 | ||
256 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA); |
256 | hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA); |
257 | 257 | ||
258 | for (fg = foundgrps; fg; fg=fg->next) |
258 | for (fg = foundgrps; fg; fg=fg->next) |
259 | {
|
259 | {
|
260 | struct grpfile *grp; |
260 | struct grpfile *grp; |
261 | for (grp = listgrps; grp; grp=grp->next) |
261 | for (grp = listgrps; grp; grp=grp->next) |
262 | if (fg->crcval == grp->crcval) break; |
262 | if (fg->crcval == grp->crcval) break; |
263 | 263 | ||
264 | if (grp == NULL) |
264 | if (grp == NULL) |
265 | continue; |
265 | continue; |
266 | 266 | ||
267 | Bsprintf(buf, "%s\t%s", grp->name, fg->name); |
267 | Bsprintf(buf, "%s\t%s", grp->name, fg->name); |
268 | j = ListBox_AddString(hwnd, buf); |
268 | j = ListBox_AddString(hwnd, buf); |
269 | (void)ListBox_SetItemData(hwnd, j, (LPARAM)fg); |
269 | (void)ListBox_SetItemData(hwnd, j, (LPARAM)fg); |
270 | if (!Bstrcasecmp(fg->name, settings.selectedgrp)) |
270 | if (!Bstrcasecmp(fg->name, settings.selectedgrp)) |
271 | {
|
271 | {
|
272 | (void)ListBox_SetCurSel(hwnd, j); |
272 | (void)ListBox_SetCurSel(hwnd, j); |
273 | settings.game = fg->game; |
273 | settings.game = fg->game; |
274 | settings.crcval = fg->crcval; |
274 | settings.crcval = fg->crcval; |
275 | }
|
275 | }
|
276 | }
|
276 | }
|
277 | }
|
277 | }
|
278 | }
|
278 | }
|
279 | 279 | ||
280 | static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
280 | static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
281 | {
|
281 | {
|
282 | switch (uMsg) |
282 | switch (uMsg) |
283 | {
|
283 | {
|
284 | case WM_COMMAND: |
284 | case WM_COMMAND: |
285 | switch (LOWORD(wParam)) |
285 | switch (LOWORD(wParam)) |
286 | {
|
286 | {
|
287 | case IDCFULLSCREEN: |
287 | case IDCFULLSCREEN: |
288 | if (settings.flags & 1) settings.flags &= ~1; |
288 | if (settings.flags & 1) settings.flags &= ~1; |
289 | else settings.flags |= 1; |
289 | else settings.flags |= 1; |
290 | PopulateForm(POPULATE_VIDEO); |
290 | PopulateForm(POPULATE_VIDEO); |
291 | return TRUE; |
291 | return TRUE; |
292 | case IDCPOLYMER: |
292 | case IDCPOLYMER: |
293 | if (settings.flags & 2) settings.flags &= ~2; |
293 | if (settings.flags & 2) settings.flags &= ~2; |
294 | else settings.flags |= 2; |
294 | else settings.flags |= 2; |
295 | if (settings.bpp == 8) settings.bpp = 32; |
295 | if (settings.bpp == 8) settings.bpp = 32; |
296 | PopulateForm(POPULATE_VIDEO); |
296 | PopulateForm(POPULATE_VIDEO); |
297 | return TRUE; |
297 | return TRUE; |
298 | case IDCVMODE: |
298 | case IDCVMODE: |
299 | if (HIWORD(wParam) == CBN_SELCHANGE) |
299 | if (HIWORD(wParam) == CBN_SELCHANGE) |
300 | {
|
300 | {
|
301 | int32_t i; |
301 | int32_t i; |
302 | i = ComboBox_GetCurSel((HWND)lParam); |
302 | i = ComboBox_GetCurSel((HWND)lParam); |
303 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
303 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
304 | if (i != CB_ERR) |
304 | if (i != CB_ERR) |
305 | {
|
305 | {
|
306 | settings.xdim = validmode[i].xdim; |
306 | settings.xdim = validmode[i].xdim; |
307 | settings.ydim = validmode[i].ydim; |
307 | settings.ydim = validmode[i].ydim; |
308 | settings.bpp = validmode[i].bpp; |
308 | settings.bpp = validmode[i].bpp; |
309 | }
|
309 | }
|
310 | }
|
310 | }
|
311 | return TRUE; |
311 | return TRUE; |
312 | case IDCALWAYSSHOW: |
312 | case IDCALWAYSSHOW: |
313 | settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; |
313 | settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; |
314 | return TRUE; |
314 | return TRUE; |
315 | case IDCAUTOLOAD: |
315 | case IDCAUTOLOAD: |
316 | if (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) == BST_CHECKED) |
316 | if (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) == BST_CHECKED) |
317 | settings.flags &= ~4; |
317 | settings.flags &= ~4; |
318 | else settings.flags |= 4; |
318 | else settings.flags |= 4; |
319 | return TRUE; |
319 | return TRUE; |
320 | case IDCINPUT: |
320 | case IDCINPUT: |
321 | if (HIWORD(wParam) == CBN_SELCHANGE) |
321 | if (HIWORD(wParam) == CBN_SELCHANGE) |
322 | {
|
322 | {
|
323 | int32_t i; |
323 | int32_t i; |
324 | i = ComboBox_GetCurSel((HWND)lParam); |
324 | i = ComboBox_GetCurSel((HWND)lParam); |
325 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
325 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
326 | if (i != CB_ERR) |
326 | if (i != CB_ERR) |
327 | {
|
327 | {
|
328 | switch (i) |
328 | switch (i) |
329 | {
|
329 | {
|
330 | case 0: |
330 | case 0: |
331 | settings.usemouse = settings.usejoy = 0; |
331 | settings.usemouse = settings.usejoy = 0; |
332 | break; |
332 | break; |
333 | case 1: |
333 | case 1: |
334 | settings.usemouse = 1; |
334 | settings.usemouse = 1; |
335 | settings.usejoy = 0; |
335 | settings.usejoy = 0; |
336 | break; |
336 | break; |
337 | case 2: |
337 | case 2: |
338 | settings.usemouse = 0; |
338 | settings.usemouse = 0; |
339 | settings.usejoy = 1; |
339 | settings.usejoy = 1; |
340 | break; |
340 | break; |
341 | case 3: |
341 | case 3: |
342 | settings.usemouse = settings.usejoy = 1; |
342 | settings.usemouse = settings.usejoy = 1; |
343 | break; |
343 | break; |
344 | }
|
344 | }
|
345 | }
|
345 | }
|
346 | }
|
346 | }
|
347 | return TRUE; |
347 | return TRUE; |
348 | 348 | ||
349 | case IDCGAMEDIR: |
349 | case IDCGAMEDIR: |
350 | if (HIWORD(wParam) == CBN_SELCHANGE) |
350 | if (HIWORD(wParam) == CBN_SELCHANGE) |
351 | {
|
351 | {
|
352 | int32_t i,j; |
352 | int32_t i,j; |
353 | CACHE1D_FIND_REC *dir = NULL; |
353 | CACHE1D_FIND_REC *dir = NULL; |
354 | i = ComboBox_GetCurSel((HWND)lParam); |
354 | i = ComboBox_GetCurSel((HWND)lParam); |
355 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
355 | if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); |
356 | if (i != CB_ERR) |
356 | if (i != CB_ERR) |
357 | {
|
357 | {
|
358 | if (i==0) |
358 | if (i==0) |
359 | settings.gamedir = NULL; |
359 | settings.gamedir = NULL; |
360 | else
|
360 | else
|
361 | {
|
361 | {
|
362 | for (j=1,dir=finddirs; dir != NULL; dir=dir->next,j++) |
362 | for (j=1,dir=finddirs; dir != NULL; dir=dir->next,j++) |
363 | if (j == i) |
363 | if (j == i) |
364 | {
|
364 | {
|
365 | settings.gamedir = dir->name; |
365 | settings.gamedir = dir->name; |
366 | break; |
366 | break; |
367 | }
|
367 | }
|
368 | }
|
368 | }
|
369 | }
|
369 | }
|
370 | }
|
370 | }
|
371 | return TRUE; |
371 | return TRUE; |
372 | case IDCDATA: |
372 | case IDCDATA: |
373 | {
|
373 | {
|
374 | intptr_t i; |
374 | intptr_t i; |
375 | if (HIWORD(wParam) != LBN_SELCHANGE) break; |
375 | if (HIWORD(wParam) != LBN_SELCHANGE) break; |
376 | i = ListBox_GetCurSel((HWND)lParam); |
376 | i = ListBox_GetCurSel((HWND)lParam); |
377 | if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); |
377 | if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); |
378 | if (i != CB_ERR) |
378 | if (i != CB_ERR) |
379 | {
|
379 | {
|
380 | strcpy(settings.selectedgrp, ((struct grpfile *)i)->name); |
380 | strcpy(settings.selectedgrp, ((struct grpfile *)i)->name); |
381 | settings.game = ((struct grpfile *)i)->game; |
381 | settings.game = ((struct grpfile *)i)->game; |
382 | settings.crcval = ((struct grpfile *)i)->crcval; |
382 | settings.crcval = ((struct grpfile *)i)->crcval; |
383 | }
|
383 | }
|
384 | return TRUE; |
384 | return TRUE; |
385 | }
|
385 | }
|
386 | default: |
386 | default: |
387 | break; |
387 | break; |
388 | }
|
388 | }
|
389 | break; |
389 | break; |
390 | default: |
390 | default: |
391 | break; |
391 | break; |
392 | }
|
392 | }
|
393 | return FALSE; |
393 | return FALSE; |
394 | }
|
394 | }
|
395 | 395 | ||
396 | 396 | ||
397 | static void SetPage(int32_t n) |
397 | static void SetPage(int32_t n) |
398 | {
|
398 | {
|
399 | HWND tab;
|
399 | HWND tab;
|
400 | int32_t cur; |
400 | int32_t cur; |
401 | tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
401 | tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
402 | cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0); |
402 | cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0); |
403 | ShowWindow(pages[cur],SW_HIDE); |
403 | ShowWindow(pages[cur],SW_HIDE); |
404 | SendMessage(tab, TCM_SETCURSEL, n, 0); |
404 | SendMessage(tab, TCM_SETCURSEL, n, 0); |
405 | ShowWindow(pages[n],SW_SHOW); |
405 | ShowWindow(pages[n],SW_SHOW); |
406 | mode = n; |
406 | mode = n; |
407 | 407 | ||
408 | SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); |
408 | SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); |
409 | }
|
409 | }
|
410 | 410 | ||
411 | static void EnableConfig(int32_t n) |
411 | static void EnableConfig(int32_t n) |
412 | {
|
412 | {
|
413 | //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
|
413 | //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
|
414 | EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); |
414 | EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); |
415 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); |
415 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); |
416 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n); |
416 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n); |
417 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); |
417 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); |
418 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n); |
418 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n); |
419 | 419 | ||
420 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n); |
420 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n); |
421 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n); |
421 | EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n); |
422 | }
|
422 | }
|
423 | 423 | ||
424 | static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
424 | static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
425 | {
|
425 | {
|
426 | static HBITMAP hbmp = NULL; |
426 | static HBITMAP hbmp = NULL; |
427 | HDC hdc;
|
427 | HDC hdc;
|
428 | 428 | ||
429 | switch (uMsg) |
429 | switch (uMsg) |
430 | {
|
430 | {
|
431 | case WM_INITDIALOG: |
431 | case WM_INITDIALOG: |
432 | {
|
432 | {
|
433 | HWND hwnd;
|
433 | HWND hwnd;
|
434 | RECT r, rdlg, chrome, rtab, rcancel, rstart; |
434 | RECT r, rdlg, chrome, rtab, rcancel, rstart; |
435 | int32_t xoffset = 0, yoffset = 0; |
435 | int32_t xoffset = 0, yoffset = 0; |
436 | 436 | ||
437 | // Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
437 | // Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
438 | ZeroMemory(&chrome, sizeof(chrome)); |
438 | ZeroMemory(&chrome, sizeof(chrome)); |
439 | AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); |
439 | AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); |
440 | GetWindowRect(hwndDlg, &rdlg); |
440 | GetWindowRect(hwndDlg, &rdlg); |
441 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); |
441 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); |
442 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); |
442 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); |
443 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); |
443 | GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); |
444 | 444 | ||
445 | // Knock off the non-client area of the main dialogue to give just the client area
|
445 | // Knock off the non-client area of the main dialogue to give just the client area
|
446 | rdlg.left -= chrome.left; |
446 | rdlg.left -= chrome.left; |
447 | rdlg.top -= chrome.top; |
447 | rdlg.top -= chrome.top; |
448 | rdlg.right -= chrome.right; |
448 | rdlg.right -= chrome.right; |
449 | rdlg.bottom -= chrome.bottom; |
449 | rdlg.bottom -= chrome.bottom; |
450 | 450 | ||
451 | // Translate them to client-relative coordinates wrt the main dialogue window
|
451 | // Translate them to client-relative coordinates wrt the main dialogue window
|
452 | rtab.right -= rtab.left - 1; |
452 | rtab.right -= rtab.left - 1; |
453 | rtab.bottom -= rtab.top - 1; |
453 | rtab.bottom -= rtab.top - 1; |
454 | rtab.left -= rdlg.left; |
454 | rtab.left -= rdlg.left; |
455 | rtab.top -= rdlg.top; |
455 | rtab.top -= rdlg.top; |
456 | 456 | ||
457 | rcancel.right -= rcancel.left - 1; |
457 | rcancel.right -= rcancel.left - 1; |
458 | rcancel.bottom -= rcancel.top - 1; |
458 | rcancel.bottom -= rcancel.top - 1; |
459 | rcancel.left -= rdlg.left; |
459 | rcancel.left -= rdlg.left; |
460 | rcancel.top -= rdlg.top; |
460 | rcancel.top -= rdlg.top; |
461 | 461 | ||
462 | rstart.right -= rstart.left - 1; |
462 | rstart.right -= rstart.left - 1; |
463 | rstart.bottom -= rstart.top - 1; |
463 | rstart.bottom -= rstart.top - 1; |
464 | rstart.left -= rdlg.left; |
464 | rstart.left -= rdlg.left; |
465 | rstart.top -= rdlg.top; |
465 | rstart.top -= rdlg.top; |
466 | 466 | ||
467 | // And then convert the main dialogue coordinates to just width/length
|
467 | // And then convert the main dialogue coordinates to just width/length
|
468 | rdlg.right -= rdlg.left - 1; |
468 | rdlg.right -= rdlg.left - 1; |
469 | rdlg.bottom -= rdlg.top - 1; |
469 | rdlg.bottom -= rdlg.top - 1; |
470 | rdlg.left = 0; |
470 | rdlg.left = 0; |
471 | rdlg.top = 0; |
471 | rdlg.top = 0; |
472 | 472 | ||
473 | // Load the bitmap into the bitmap control and fetch its dimensions
|
473 | // Load the bitmap into the bitmap control and fetch its dimensions
|
474 | hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); |
474 | hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); |
475 | hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); |
475 | hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); |
476 | SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); |
476 | SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); |
477 | GetClientRect(hwnd, &r); |
477 | GetClientRect(hwnd, &r); |
478 | xoffset = r.right; |
478 | xoffset = r.right; |
479 | yoffset = r.bottom - rdlg.bottom; |
479 | yoffset = r.bottom - rdlg.bottom; |
480 | 480 | ||
481 | // Shift and resize the controls that require it
|
481 | // Shift and resize the controls that require it
|
482 | rtab.left += xoffset; |
482 | rtab.left += xoffset; |
483 | rtab.bottom += yoffset; |
483 | rtab.bottom += yoffset; |
484 | rcancel.left += xoffset; |
484 | rcancel.left += xoffset; |
485 | rcancel.top += yoffset; |
485 | rcancel.top += yoffset; |
486 | rstart.left += xoffset; |
486 | rstart.left += xoffset; |
487 | rstart.top += yoffset; |
487 | rstart.top += yoffset; |
488 | rdlg.right += xoffset; |
488 | rdlg.right += xoffset; |
489 | rdlg.bottom += yoffset; |
489 | rdlg.bottom += yoffset; |
490 | 490 | ||
491 | // Move the controls to their new positions
|
491 | // Move the controls to their new positions
|
492 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); |
492 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); |
493 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); |
493 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); |
494 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); |
494 | MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); |
495 | 495 | ||
496 | // Move the main dialogue to the centre of the screen
|
496 | // Move the main dialogue to the centre of the screen
|
497 | hdc = GetDC(NULL); |
497 | hdc = GetDC(NULL); |
498 | rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; |
498 | rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; |
499 | rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; |
499 | rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; |
500 | ReleaseDC(NULL, hdc); |
500 | ReleaseDC(NULL, hdc); |
501 | MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, |
501 | MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, |
502 | rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); |
502 | rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); |
503 | 503 | ||
504 | // Add tabs to the tab control
|
504 | // Add tabs to the tab control
|
505 | {
|
505 | {
|
506 | TCITEM tab;
|
506 | TCITEM tab;
|
507 | 507 | ||
508 | hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); |
508 | hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); |
509 | 509 | ||
510 | ZeroMemory(&tab, sizeof(tab)); |
510 | ZeroMemory(&tab, sizeof(tab)); |
511 | tab.mask = TCIF_TEXT; |
511 | tab.mask = TCIF_TEXT; |
512 | tab.pszText = TEXT("Setup"); |
512 | tab.pszText = TEXT("Setup"); |
513 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); |
513 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); |
514 | tab.mask = TCIF_TEXT; |
514 | tab.mask = TCIF_TEXT; |
515 | tab.pszText = TEXT("Message Log"); |
515 | tab.pszText = TEXT("Message Log"); |
516 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); |
516 | SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); |
517 | 517 | ||
518 | // Work out the position and size of the area inside the tab control for the pages
|
518 | // Work out the position and size of the area inside the tab control for the pages
|
519 | ZeroMemory(&r, sizeof(r)); |
519 | ZeroMemory(&r, sizeof(r)); |
520 | GetClientRect(hwnd, &r); |
520 | GetClientRect(hwnd, &r); |
521 | SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); |
521 | SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); |
522 | r.right -= r.left-1; |
522 | r.right -= r.left-1; |
523 | r.bottom -= r.top-1; |
523 | r.bottom -= r.top-1; |
524 | r.top += rtab.top; |
524 | r.top += rtab.top; |
525 | r.left += rtab.left; |
525 | r.left += rtab.left; |
526 | 526 | ||
527 | // Create the pages and position them in the tab control, but hide them
|
527 | // Create the pages and position them in the tab control, but hide them
|
528 | pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), |
528 | pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), |
529 | MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); |
529 | MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); |
530 | pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); |
530 | pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); |
531 | SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
531 | SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
532 | SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
532 | SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); |
533 | 533 | ||
534 | // Tell the editfield acting as the console to exclude the width of the scrollbar
|
534 | // Tell the editfield acting as the console to exclude the width of the scrollbar
|
535 | GetClientRect(pages[TAB_MESSAGES],&r); |
535 | GetClientRect(pages[TAB_MESSAGES],&r); |
536 | r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; |
536 | r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; |
537 | r.left = r.top = 0; |
537 | r.left = r.top = 0; |
538 | SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); |
538 | SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); |
539 | 539 | ||
540 | // Set a tab stop in the game data listbox
|
540 | // Set a tab stop in the game data listbox
|
541 | {
|
541 | {
|
542 | DWORD tabs[1] = { 150 }; |
542 | DWORD tabs[1] = { 150 }; |
543 | (void)ListBox_SetTabStops(GetDlgItem(pages[TAB_CONFIG], IDCDATA), 1, tabs); |
543 | (void)ListBox_SetTabStops(GetDlgItem(pages[TAB_CONFIG], IDCDATA), 1, tabs); |
544 | }
|
544 | }
|
545 | 545 | ||
546 | SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); |
546 | SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); |
547 | SetWindowText(hwndDlg, apptitle); |
547 | SetWindowText(hwndDlg, apptitle); |
548 | }
|
548 | }
|
549 | return FALSE; |
549 | return FALSE; |
550 | }
|
550 | }
|
551 | 551 | ||
552 | case WM_NOTIFY: |
552 | case WM_NOTIFY: |
553 | {
|
553 | {
|
554 | LPNMHDR nmhdr = (LPNMHDR)lParam; |
554 | LPNMHDR nmhdr = (LPNMHDR)lParam; |
555 | int32_t cur; |
555 | int32_t cur; |
556 | if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; |
556 | if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; |
557 | cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); |
557 | cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); |
558 | switch (nmhdr->code) |
558 | switch (nmhdr->code) |
559 | {
|
559 | {
|
560 | case TCN_SELCHANGING: |
560 | case TCN_SELCHANGING: |
561 | {
|
561 | {
|
562 | if (cur < 0 || !pages[cur]) break; |
562 | if (cur < 0 || !pages[cur]) break; |
563 | ShowWindow(pages[cur],SW_HIDE); |
563 | ShowWindow(pages[cur],SW_HIDE); |
564 | return TRUE; |
564 | return TRUE; |
565 | }
|
565 | }
|
566 | case TCN_SELCHANGE: |
566 | case TCN_SELCHANGE: |
567 | {
|
567 | {
|
568 | if (cur < 0 || !pages[cur]) break; |
568 | if (cur < 0 || !pages[cur]) break; |
569 | ShowWindow(pages[cur],SW_SHOW); |
569 | ShowWindow(pages[cur],SW_SHOW); |
570 | return TRUE; |
570 | return TRUE; |
571 | }
|
571 | }
|
572 | }
|
572 | }
|
573 | break; |
573 | break; |
574 | }
|
574 | }
|
575 | 575 | ||
576 | case WM_CLOSE: |
576 | case WM_CLOSE: |
577 | if (mode == TAB_CONFIG) done = 0; |
577 | if (mode == TAB_CONFIG) done = 0; |
578 | else quitevent++; |
578 | else quitevent++; |
579 | return TRUE; |
579 | return TRUE; |
580 | 580 | ||
581 | case WM_DESTROY: |
581 | case WM_DESTROY: |
582 | if (hbmp) |
582 | if (hbmp) |
583 | {
|
583 | {
|
584 | DeleteObject(hbmp); |
584 | DeleteObject(hbmp); |
585 | hbmp = NULL; |
585 | hbmp = NULL; |
586 | }
|
586 | }
|
587 | 587 | ||
588 | if (pages[TAB_CONFIG]) |
588 | if (pages[TAB_CONFIG]) |
589 | {
|
589 | {
|
590 | DestroyWindow(pages[TAB_CONFIG]); |
590 | DestroyWindow(pages[TAB_CONFIG]); |
591 | pages[TAB_CONFIG] = NULL; |
591 | pages[TAB_CONFIG] = NULL; |
592 | }
|
592 | }
|
593 | 593 | ||
594 | startupdlg = NULL; |
594 | startupdlg = NULL; |
595 | return TRUE; |
595 | return TRUE; |
596 | 596 | ||
597 | case WM_COMMAND: |
597 | case WM_COMMAND: |
598 | switch (LOWORD(wParam)) |
598 | switch (LOWORD(wParam)) |
599 | {
|
599 | {
|
600 | case WIN_STARTWIN_CANCEL: |
600 | case WIN_STARTWIN_CANCEL: |
601 | if (mode == TAB_CONFIG) done = 0; |
601 | if (mode == TAB_CONFIG) done = 0; |
602 | else quitevent++; |
602 | else quitevent++; |
603 | return TRUE; |
603 | return TRUE; |
604 | case WIN_STARTWIN_START: |
604 | case WIN_STARTWIN_START: |
605 | done = 1; |
605 | done = 1; |
606 | return TRUE; |
606 | return TRUE; |
607 | }
|
607 | }
|
608 | return FALSE; |
608 | return FALSE; |
609 | 609 | ||
610 | case WM_CTLCOLORSTATIC: |
610 | case WM_CTLCOLORSTATIC: |
611 | if ((HWND)lParam == pages[TAB_MESSAGES]) |
611 | if ((HWND)lParam == pages[TAB_MESSAGES]) |
612 | return (BOOL)(intptr_t)GetSysColorBrush(COLOR_WINDOW); |
612 | return (BOOL)(intptr_t)GetSysColorBrush(COLOR_WINDOW); |
613 | break; |
613 | break; |
614 | 614 | ||
615 | default: |
615 | default: |
616 | break; |
616 | break; |
617 | }
|
617 | }
|
618 | 618 | ||
619 | return FALSE; |
619 | return FALSE; |
620 | }
|
620 | }
|
621 | 621 | ||
622 | 622 | ||
623 | int32_t startwin_open(void) |
623 | int32_t startwin_open(void) |
624 | {
|
624 | {
|
625 | INITCOMMONCONTROLSEX icc;
|
625 | INITCOMMONCONTROLSEX icc;
|
626 | if (startupdlg) return 1; |
626 | if (startupdlg) return 1; |
627 | icc.dwSize = sizeof(icc); |
627 | icc.dwSize = sizeof(icc); |
628 | icc.dwICC = ICC_TAB_CLASSES; |
628 | icc.dwICC = ICC_TAB_CLASSES; |
629 | InitCommonControlsEx(&icc); |
629 | InitCommonControlsEx(&icc); |
630 | startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); |
630 | startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); |
631 | if (startupdlg) |
631 | if (startupdlg) |
632 | {
|
632 | {
|
633 | SetPage(TAB_MESSAGES); |
633 | SetPage(TAB_MESSAGES); |
634 | EnableConfig(0); |
634 | EnableConfig(0); |
635 | return 0; |
635 | return 0; |
636 | }
|
636 | }
|
637 | return -1; |
637 | return -1; |
638 | }
|
638 | }
|
639 | 639 | ||
640 | int32_t startwin_close(void) |
640 | int32_t startwin_close(void) |
641 | {
|
641 | {
|
642 | if (!startupdlg) return 1; |
642 | if (!startupdlg) return 1; |
643 | DestroyWindow(startupdlg); |
643 | DestroyWindow(startupdlg); |
644 | startupdlg = NULL; |
644 | startupdlg = NULL; |
645 | return 0; |
645 | return 0; |
646 | }
|
646 | }
|
647 | 647 | ||
648 | int32_t startwin_puts(const char *buf) |
648 | int32_t startwin_puts(const char *buf) |
649 | {
|
649 | {
|
650 | const char *p = NULL, *q = NULL; |
650 | const char *p = NULL, *q = NULL; |
651 | static char workbuf[1024]; |
651 | static char workbuf[1024]; |
652 | static int32_t newline = 0; |
652 | static int32_t newline = 0; |
653 | int32_t curlen, linesbefore, linesafter; |
653 | int32_t curlen, linesbefore, linesafter; |
654 | HWND edctl;
|
654 | HWND edctl;
|
655 | int32_t vis; |
655 | int32_t vis; |
656 | static HWND dactrl = NULL; |
656 | static HWND dactrl = NULL; |
657 | 657 | ||
658 | if (!startupdlg) return 1; |
658 | if (!startupdlg) return 1; |
659 | 659 | ||
660 | edctl = pages[TAB_MESSAGES]; |
660 | edctl = pages[TAB_MESSAGES]; |
661 | if (!edctl) return -1; |
661 | if (!edctl) return -1; |
662 | 662 | ||
663 | if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
663 | if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); |
664 | 664 | ||
665 | vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES); |
665 | vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES); |
666 | 666 | ||
667 | if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); |
667 | if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); |
668 | curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); |
668 | curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); |
669 | SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); |
669 | SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); |
670 | linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
670 | linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
671 | p = buf; |
671 | p = buf; |
672 | while (*p) |
672 | while (*p) |
673 | {
|
673 | {
|
674 | if (newline) |
674 | if (newline) |
675 | {
|
675 | {
|
676 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); |
676 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); |
677 | newline = 0; |
677 | newline = 0; |
678 | }
|
678 | }
|
679 | q = p; |
679 | q = p; |
680 | while (*q && *q != '\n') q++; |
680 | while (*q && *q != '\n') q++; |
681 | Bmemcpy(workbuf, p, q-p); |
681 | Bmemcpy(workbuf, p, q-p); |
682 | if (*q == '\n') |
682 | if (*q == '\n') |
683 | {
|
683 | {
|
684 | if (!q[1]) |
684 | if (!q[1]) |
685 | {
|
685 | {
|
686 | newline = 1; |
686 | newline = 1; |
687 | workbuf[q-p] = 0; |
687 | workbuf[q-p] = 0; |
688 | }
|
688 | }
|
689 | else
|
689 | else
|
690 | {
|
690 | {
|
691 | workbuf[q-p] = '\r'; |
691 | workbuf[q-p] = '\r'; |
692 | workbuf[q-p+1] = '\n'; |
692 | workbuf[q-p+1] = '\n'; |
693 | workbuf[q-p+2] = 0; |
693 | workbuf[q-p+2] = 0; |
694 | }
|
694 | }
|
695 | p = q+1; |
695 | p = q+1; |
696 | }
|
696 | }
|
697 | else
|
697 | else
|
698 | {
|
698 | {
|
699 | workbuf[q-p] = 0; |
699 | workbuf[q-p] = 0; |
700 | p = q; |
700 | p = q; |
701 | }
|
701 | }
|
702 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); |
702 | SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); |
703 | }
|
703 | }
|
704 | linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
704 | linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); |
705 | SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); |
705 | SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); |
706 | if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); |
706 | if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); |
707 | return 0; |
707 | return 0; |
708 | }
|
708 | }
|
709 | 709 | ||
710 | int32_t startwin_settitle(const char *str) |
710 | int32_t startwin_settitle(const char *str) |
711 | {
|
711 | {
|
712 | if (!startupdlg) return 1; |
712 | if (!startupdlg) return 1; |
713 | SetWindowText(startupdlg, str); |
713 | SetWindowText(startupdlg, str); |
714 | return 0; |
714 | return 0; |
715 | }
|
715 | }
|
716 | 716 | ||
717 | int32_t startwin_idle(void *v) |
717 | int32_t startwin_idle(void *v) |
718 | {
|
718 | {
|
719 | if (!startupdlg || !IsWindow(startupdlg)) return 0; |
719 | if (!startupdlg || !IsWindow(startupdlg)) return 0; |
720 | if (IsDialogMessage(startupdlg, (MSG *)v)) return 1; |
720 | if (IsDialogMessage(startupdlg, (MSG *)v)) return 1; |
721 | return 0; |
721 | return 0; |
722 | }
|
722 | }
|
723 | 723 | ||
724 | int32_t startwin_run(void) |
724 | int32_t startwin_run(void) |
725 | {
|
725 | {
|
726 | MSG msg;
|
726 | MSG msg;
|
727 | if (!startupdlg) return 1; |
727 | if (!startupdlg) return 1; |
728 | 728 | ||
729 | done = -1; |
729 | done = -1; |
730 | 730 | ||
731 | #ifdef JFAUD
|
731 | #ifdef JFAUD
|
732 | EnumAudioDevs(&wavedevs, NULL, NULL); |
732 | EnumAudioDevs(&wavedevs, NULL, NULL); |
733 | #endif
|
733 | #endif
|
734 | SetPage(TAB_CONFIG); |
734 | SetPage(TAB_CONFIG); |
735 | EnableConfig(1); |
735 | EnableConfig(1); |
736 | 736 | ||
737 | settings.flags = 0; |
737 | settings.flags = 0; |
738 | if (ud.config.ScreenMode) settings.flags |= 1; |
738 | if (ud.config.ScreenMode) settings.flags |= 1; |
739 | #ifdef POLYMER
|
739 | #ifdef POLYMER
|
740 | if (glrendmode == REND_POLYMER) settings.flags |= 2; |
740 | if (glrendmode == REND_POLYMER) settings.flags |= 2; |
741 | #endif
|
741 | #endif
|
742 | if (ud.config.NoAutoLoad) settings.flags |= 4; |
742 | if (ud.config.NoAutoLoad) settings.flags |= 4; |
743 | settings.xdim = ud.config.ScreenWidth; |
743 | settings.xdim = ud.config.ScreenWidth; |
744 | settings.ydim = ud.config.ScreenHeight; |
744 | settings.ydim = ud.config.ScreenHeight; |
745 | settings.bpp = ud.config.ScreenBPP; |
745 | settings.bpp = ud.config.ScreenBPP; |
746 | settings.forcesetup = ud.config.ForceSetup; |
746 | settings.forcesetup = ud.config.ForceSetup; |
747 | settings.usemouse = ud.config.UseMouse; |
747 | settings.usemouse = ud.config.UseMouse; |
748 | settings.usejoy = ud.config.UseJoystick; |
748 | settings.usejoy = ud.config.UseJoystick; |
749 | settings.game = g_gameType; |
749 | settings.game = g_gameType; |
750 | // settings.crcval = 0;
|
750 | // settings.crcval = 0;
|
751 | Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH); |
751 | Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH); |
752 | settings.gamedir = g_modDir; |
752 | settings.gamedir = g_modDir; |
753 | PopulateForm(-1); |
753 | PopulateForm(-1); |
754 | 754 | ||
755 | while (done < 0) |
755 | while (done < 0) |
756 | {
|
756 | {
|
757 | switch (GetMessage(&msg, NULL, 0,0)) |
757 | switch (GetMessage(&msg, NULL, 0,0)) |
758 | {
|
758 | {
|
759 | case 0: |
759 | case 0: |
760 | done = 1; |
760 | done = 1; |
761 | break; |
761 | break; |
762 | case -1: |
762 | case -1: |
763 | return -1; |
763 | return -1; |
764 | default: |
764 | default: |
765 | if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; |
765 | if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; |
766 | TranslateMessage(&msg); |
766 | TranslateMessage(&msg); |
767 | DispatchMessage(&msg); |
767 | DispatchMessage(&msg); |
768 | break; |
768 | break; |
769 | }
|
769 | }
|
770 | }
|
770 | }
|
771 | 771 | ||
772 | SetPage(TAB_MESSAGES); |
772 | SetPage(TAB_MESSAGES); |
773 | EnableConfig(0); |
773 | EnableConfig(0); |
774 | if (done) |
774 | if (done) |
775 | {
|
775 | {
|
776 | ud.config.ScreenMode = (settings.flags&1); |
776 | ud.config.ScreenMode = (settings.flags&1); |
777 | #ifdef POLYMER
|
777 | #ifdef POLYMER
|
778 | if (settings.flags & 2) glrendmode = REND_POLYMER; |
778 | if (settings.flags & 2) glrendmode = REND_POLYMER; |
779 | else glrendmode = REND_POLYMOST; |
779 | else glrendmode = REND_POLYMOST; |
780 | #endif
|
780 | #endif
|
781 | if (settings.flags & 4) ud.config.NoAutoLoad = 1; |
781 | if (settings.flags & 4) ud.config.NoAutoLoad = 1; |
782 | else ud.config.NoAutoLoad = 0; |
782 | else ud.config.NoAutoLoad = 0; |
783 | ud.config.ScreenWidth = settings.xdim; |
783 | ud.config.ScreenWidth = settings.xdim; |
784 | ud.config.ScreenHeight = settings.ydim; |
784 | ud.config.ScreenHeight = settings.ydim; |
785 | ud.config.ScreenBPP = settings.bpp; |
785 | ud.config.ScreenBPP = settings.bpp; |
786 | ud.config.ForceSetup = settings.forcesetup; |
786 | ud.config.ForceSetup = settings.forcesetup; |
787 | ud.config.UseMouse = settings.usemouse; |
787 | ud.config.UseMouse = settings.usemouse; |
788 | ud.config.UseJoystick = settings.usejoy; |
788 | ud.config.UseJoystick = settings.usejoy; |
789 | 789 | ||
790 | clearGrpNamePtr(); |
790 | clearGrpNamePtr(); |
791 | g_grpNamePtr = dup_filename(settings.selectedgrp); |
791 | g_grpNamePtr = dup_filename(settings.selectedgrp); |
792 | 792 | ||
793 | g_gameType = settings.game; |
793 | g_gameType = settings.game; |
794 | 794 | ||
795 | if (g_noSetup == 0 && settings.gamedir != NULL) |
795 | if (g_noSetup == 0 && settings.gamedir != NULL) |
796 | Bstrcpy(g_modDir,settings.gamedir); |
796 | Bstrcpy(g_modDir,settings.gamedir); |
797 | else Bsprintf(g_modDir,"/"); |
797 | else Bsprintf(g_modDir,"/"); |
798 | 798 | ||
799 | {
|
799 | {
|
800 | struct grpfile *grp; |
800 | struct grpfile *grp; |
801 | for (grp = listgrps; grp; grp=grp->next) |
801 | for (grp = listgrps; grp; grp=grp->next) |
802 | if (settings.crcval == grp->crcval) break; |
802 | if (settings.crcval == grp->crcval) break; |
803 | 803 | ||
804 | if (grp) |
804 | if (grp) |
805 | {
|
805 | {
|
806 | g_gameNamePtr = grp->name; |
806 | g_gameNamePtr = grp->name; |
807 | g_dependencyCRC = grp->dependency; |
807 | g_dependencyCRC = grp->dependency; |
- | 808 | g_postprocessing = grp->postprocessing; |
|
808 | 809 | ||
809 | if (grp->scriptname && g_scriptNamePtr == NULL) |
810 | if (grp->scriptname && g_scriptNamePtr == NULL) |
810 | g_scriptNamePtr = dup_filename(grp->scriptname); |
811 | g_scriptNamePtr = dup_filename(grp->scriptname); |
811 | 812 | ||
812 | if (grp->defname && g_defNamePtr == NULL) |
813 | if (grp->defname && g_defNamePtr == NULL) |
813 | g_defNamePtr = dup_filename(grp->defname); |
814 | g_defNamePtr = dup_filename(grp->defname); |
814 | }
|
815 | }
|
815 | }
|
816 | }
|
816 | }
|
817 | }
|
817 | 818 | ||
818 | if (wavedevs) |
819 | if (wavedevs) |
819 | {
|
820 | {
|
820 | struct audioenumdev *d, *e; |
821 | struct audioenumdev *d, *e; |
821 | Bfree(wavedevs->drvs); |
822 | Bfree(wavedevs->drvs); |
822 | for (e=wavedevs->devs; e; e=d) |
823 | for (e=wavedevs->devs; e; e=d) |
823 | {
|
824 | {
|
824 | d = e->next; |
825 | d = e->next; |
825 | if (e->devs) Bfree(e->devs); |
826 | if (e->devs) Bfree(e->devs); |
826 | Bfree(e); |
827 | Bfree(e); |
827 | }
|
828 | }
|
828 | Bfree(wavedevs); |
829 | Bfree(wavedevs); |
829 | }
|
830 | }
|
830 | 831 | ||
831 | return done; |
832 | return done; |
832 | }
|
833 | }
|
833 | 834 | ||
834 | 835 |