Rev 1544 | Rev 1593 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1540 | terminx | 1 | #if defined(LINKED_GTK) |
2 | #include <gtk/gtk.h> |
||
3 | #include <gdk-pixbuf/gdk-pixdata.h> |
||
4 | #else |
||
5 | #include "dynamicgtk.h" |
||
6 | #endif |
||
194 | terminx | 7 | |
8 | #include "duke3d.h" |
||
1540 | terminx | 9 | #include "grpscan.h" |
194 | terminx | 10 | #include "build.h" |
11 | |||
1544 | terminx | 12 | #define RDR_POLYMOST 3 // sould be defined elsewhere |
13 | #define RDR_POLYMER 4 // sould be defined elsewhere |
||
194 | terminx | 14 | |
1544 | terminx | 15 | enum { |
16 | NONE, |
||
17 | ALL, |
||
18 | POPULATE_VIDEO, |
||
19 | POPULATE_CONFIG, |
||
20 | POPULATE_GAME, |
||
21 | }; |
||
22 | |||
23 | enum { |
||
24 | TAB_CONFIG, |
||
25 | TAB_GAME, |
||
26 | TAB_MESSAGES, |
||
27 | }; |
||
28 | |||
29 | enum { |
||
30 | INPUT_KB, |
||
31 | INPUT_MOUSE, |
||
32 | INPUT_JOYSTICK, |
||
33 | INPUT_ALL, |
||
34 | }; |
||
35 | |||
335 | terminx | 36 | static struct |
37 | { |
||
1540 | terminx | 38 | GtkWidget *startwin; |
39 | GtkWidget *hlayout; |
||
40 | GtkWidget *banner; |
||
41 | GtkWidget *vlayout; |
||
1544 | terminx | 42 | GtkWidget *tabs; |
43 | GtkWidget *configtlayout; |
||
1540 | terminx | 44 | GtkWidget *displayvlayout; |
45 | GtkWidget *vmode3dlabel; |
||
46 | GtkWidget *vmode3dcombo; |
||
1544 | terminx | 47 | GtkWidget *fullscreencheck; |
1540 | terminx | 48 | GtkWidget *polymercheck; |
1544 | terminx | 49 | GtkWidget *inputdevlabel; |
50 | GtkWidget *inputdevcombo; |
||
51 | GtkWidget *custommodlabel; |
||
52 | GtkWidget *custommodcombo; |
||
1540 | terminx | 53 | GtkWidget *emptyhlayout; |
54 | GtkWidget *autoloadcheck; |
||
1544 | terminx | 55 | GtkWidget *alwaysshowcheck; |
56 | GtkWidget *configtab; |
||
57 | GtkWidget *gamevlayout; |
||
58 | GtkWidget *gamelabel; |
||
59 | GtkWidget *gamescroll; |
||
60 | GtkWidget *gamelist; |
||
61 | GtkWidget *gametab; |
||
62 | GtkWidget *messagesscroll; |
||
63 | GtkWidget *messagestext; |
||
64 | GtkWidget *messagestab; |
||
65 | GtkWidget *buttons; |
||
66 | GtkWidget *cancelbutton; |
||
67 | GtkWidget *cancelbuttonalign; |
||
68 | GtkWidget *cancelbuttonlayout; |
||
69 | GtkWidget *cancelbuttonicon; |
||
70 | GtkWidget *cancelbuttonlabel; |
||
71 | GtkWidget *startbutton; |
||
72 | GtkWidget *startbuttonalign; |
||
73 | GtkWidget *startbuttonlayout; |
||
74 | GtkWidget *startbuttonicon; |
||
75 | GtkWidget *startbuttonlabel; |
||
1540 | terminx | 76 | } stwidgets; |
77 | |||
78 | static struct |
||
79 | { |
||
1205 | terminx | 80 | int32_t fullscreen; |
1540 | terminx | 81 | int32_t polymer; |
1205 | terminx | 82 | int32_t xdim3d, ydim3d, bpp3d; |
83 | int32_t forcesetup; |
||
1540 | terminx | 84 | int32_t autoload; |
1205 | terminx | 85 | int32_t usemouse, usejoy; |
86 | int32_t game; |
||
87 | int32_t crcval; |
||
1544 | terminx | 88 | char *custommoddir; |
1457 | terminx | 89 | char selectedgrp[BMAX_PATH]; |
555 | terminx | 90 | } settings; |
194 | terminx | 91 | |
1540 | terminx | 92 | static int32_t retval = -1, mode = TAB_MESSAGES; |
1205 | terminx | 93 | extern int32_t gtkenabled; |
1544 | terminx | 94 | static void PopulateForm(unsigned char pgs); |
194 | terminx | 95 | |
96 | |||
1540 | terminx | 97 | // -- EVENT CALLBACKS AND CREATION STUFF -------------------------------------- |
194 | terminx | 98 | |
1540 | terminx | 99 | static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data) |
100 | { |
||
101 | GtkTreeModel *data; |
||
102 | GtkTreeIter iter; |
||
103 | int32_t val; |
||
104 | UNREFERENCED_PARAMETER(user_data); |
||
1544 | terminx | 105 | |
1540 | terminx | 106 | if (!gtk_combo_box_get_active_iter(combobox, &iter)) return; |
107 | if (!(data = gtk_combo_box_get_model(combobox))) return; |
||
108 | gtk_tree_model_get(data, &iter, 1, &val, -1); |
||
109 | settings.xdim3d = validmode[val].xdim; |
||
110 | settings.ydim3d = validmode[val].ydim; |
||
111 | } |
||
194 | terminx | 112 | |
1540 | terminx | 113 | static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) |
114 | { |
||
115 | UNREFERENCED_PARAMETER(user_data); |
||
116 | settings.fullscreen = gtk_toggle_button_get_active(togglebutton); |
||
1544 | terminx | 117 | PopulateForm(POPULATE_VIDEO); |
1540 | terminx | 118 | } |
194 | terminx | 119 | |
1540 | terminx | 120 | static void on_polymercheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) |
121 | { |
||
122 | UNREFERENCED_PARAMETER(user_data); |
||
123 | if (gtk_toggle_button_get_active(togglebutton)) |
||
124 | { |
||
1544 | terminx | 125 | glrendmode = RDR_POLYMER; |
1540 | terminx | 126 | settings.polymer = TRUE; |
127 | if (settings.bpp3d == 8) |
||
128 | { |
||
129 | settings.bpp3d = 32; |
||
1544 | terminx | 130 | PopulateForm(POPULATE_VIDEO); |
1540 | terminx | 131 | } |
132 | } |
||
133 | else |
||
134 | { |
||
1544 | terminx | 135 | glrendmode = RDR_POLYMOST; |
1540 | terminx | 136 | settings.polymer = FALSE; |
137 | } |
||
138 | } |
||
194 | terminx | 139 | |
1544 | terminx | 140 | static void on_inputdevcombo_changed(GtkComboBox *combobox, gpointer user_data) |
1540 | terminx | 141 | { |
142 | UNREFERENCED_PARAMETER(user_data); |
||
1544 | terminx | 143 | switch (gtk_combo_box_get_active(combobox)) |
144 | { |
||
145 | case 0: settings.usemouse = 0; settings.usejoy = 0; break; |
||
146 | case 1: settings.usemouse = 1; settings.usejoy = 0; break; |
||
147 | case 2: settings.usemouse = 0; settings.usejoy = 1; break; |
||
148 | case 3: settings.usemouse = 1; settings.usejoy = 1; break; |
||
149 | } |
||
1540 | terminx | 150 | } |
151 | |||
1544 | terminx | 152 | static void on_custommodcombo_changed(GtkComboBox *combobox, gpointer user_data) |
1540 | terminx | 153 | { |
1544 | terminx | 154 | GtkTreeIter iter; |
155 | GtkTreeModel *model; |
||
156 | GtkTreePath *path; |
||
157 | char *value; |
||
1540 | terminx | 158 | UNREFERENCED_PARAMETER(user_data); |
1544 | terminx | 159 | |
160 | if (gtk_combo_box_get_active_iter (combobox, &iter)) |
||
161 | { |
||
162 | model = gtk_combo_box_get_model (combobox); |
||
163 | gtk_tree_model_get( model, &iter, 0,&value, -1 ); |
||
164 | path = gtk_tree_model_get_path(model, &iter); |
||
165 | |||
166 | if (*gtk_tree_path_get_indices (path) == NONE) |
||
167 | settings.custommoddir = NULL; |
||
168 | else settings.custommoddir = value; |
||
169 | } |
||
1540 | terminx | 170 | } |
171 | |||
1544 | terminx | 172 | static void on_autoloadcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) |
1540 | terminx | 173 | { |
174 | UNREFERENCED_PARAMETER(user_data); |
||
1544 | terminx | 175 | settings.autoload = gtk_toggle_button_get_active(togglebutton); |
1540 | terminx | 176 | } |
177 | |||
178 | static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) |
||
179 | { |
||
180 | UNREFERENCED_PARAMETER(user_data); |
||
181 | settings.forcesetup = gtk_toggle_button_get_active(togglebutton); |
||
182 | } |
||
183 | |||
184 | static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) |
||
185 | { |
||
186 | UNREFERENCED_PARAMETER(button); |
||
187 | UNREFERENCED_PARAMETER(user_data); |
||
188 | if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } |
||
189 | else quitevent++; |
||
190 | } |
||
191 | |||
192 | static void on_startbutton_clicked(GtkButton *button, gpointer user_data) |
||
193 | { |
||
194 | UNREFERENCED_PARAMETER(button); |
||
195 | UNREFERENCED_PARAMETER(user_data); |
||
196 | retval = 1; |
||
197 | gtk_main_quit(); |
||
198 | } |
||
199 | |||
200 | static void on_gamelist_selection_changed(GtkTreeSelection *selection, gpointer user_data) |
||
201 | { |
||
202 | GtkTreeIter iter; |
||
203 | GtkTreeModel *model; |
||
204 | struct grpfile *fg; |
||
205 | UNREFERENCED_PARAMETER(user_data); |
||
1544 | terminx | 206 | |
1540 | terminx | 207 | if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
208 | { |
||
209 | gtk_tree_model_get(model, &iter, 2, (gpointer)&fg, -1); |
||
210 | strcpy(settings.selectedgrp, fg->name); |
||
211 | settings.game = fg->game; |
||
212 | settings.crcval = fg->crcval; |
||
213 | } |
||
214 | } |
||
215 | |||
216 | static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) |
||
217 | { |
||
218 | UNREFERENCED_PARAMETER(widget); |
||
219 | UNREFERENCED_PARAMETER(event); |
||
220 | UNREFERENCED_PARAMETER(user_data); |
||
221 | if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } |
||
222 | else quitevent++; |
||
223 | return TRUE; // FALSE would let the event go through. we want the game to decide when to close |
||
224 | } |
||
225 | |||
226 | |||
227 | // -- SUPPORT FUNCTIONS ------------------------------------------------------- |
||
228 | |||
194 | terminx | 229 | static GdkPixbuf *load_banner(void) |
230 | { |
||
214 | terminx | 231 | extern const GdkPixdata startbanner_pixdata; |
232 | return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); |
||
194 | terminx | 233 | } |
234 | |||
1205 | terminx | 235 | static void SetPage(int32_t n) |
194 | terminx | 236 | { |
1540 | terminx | 237 | if (!gtkenabled || !stwidgets.startwin) return; |
214 | terminx | 238 | mode = n; |
1540 | terminx | 239 | gtk_notebook_set_current_page(GTK_NOTEBOOK(stwidgets.tabs), n); |
194 | terminx | 240 | |
214 | terminx | 241 | // each control in the config page vertical layout plus the start button should be made (in)sensitive |
555 | terminx | 242 | if (n == TAB_CONFIG) n = TRUE; else n = FALSE; |
1540 | terminx | 243 | gtk_widget_set_sensitive(stwidgets.startbutton, n); |
1544 | terminx | 244 | gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout), |
1540 | terminx | 245 | (GtkCallback)gtk_widget_set_sensitive, |
246 | (gpointer)&n); |
||
194 | terminx | 247 | } |
248 | |||
1544 | terminx | 249 | static unsigned char GetModsDirNames(GtkListStore *list) |
194 | terminx | 250 | { |
1544 | terminx | 251 | char *homedir; |
252 | char pdir[BMAX_PATH]; |
||
253 | unsigned char iternumb = 0; |
||
254 | CACHE1D_FIND_REC *dirs = NULL; |
||
255 | GtkTreeIter iter; |
||
256 | |||
257 | pathsearchmode = 1; |
||
258 | |||
259 | if ((homedir = Bgethomedir())) |
||
260 | { |
||
261 | Bsnprintf(pdir, sizeof(pdir), "%s/" ".eduke32", homedir); |
||
262 | dirs = klistpath(pdir, "*", CACHE1D_FIND_DIR); |
||
263 | for (dirs=dirs; dirs != NULL; dirs=dirs->next) |
||
264 | { |
||
265 | if ((Bstrcmp(dirs->name, "autoload") == 0) || |
||
266 | (Bstrcmp(dirs->name, "..") == 0) || |
||
267 | (Bstrcmp(dirs->name, ".") == 0)) |
||
268 | continue; |
||
269 | else |
||
270 | { |
||
271 | gtk_list_store_append(list, &iter); |
||
272 | gtk_list_store_set(list, &iter, 0,dirs->name, -1); |
||
273 | iternumb++; |
||
274 | } |
||
275 | } |
||
276 | } |
||
277 | |||
278 | klistfree(dirs); |
||
279 | dirs = NULL; |
||
280 | |||
281 | return iternumb; |
||
282 | } |
||
283 | |||
284 | static void PopulateForm(unsigned char pgs) |
||
285 | { |
||
286 | if ((pgs == ALL) || (pgs == POPULATE_VIDEO)) |
||
555 | terminx | 287 | { |
1205 | terminx | 288 | int32_t mode3d, i; |
555 | terminx | 289 | GtkListStore *modes3d; |
290 | GtkTreeIter iter; |
||
291 | char buf[64]; |
||
1544 | terminx | 292 | |
555 | terminx | 293 | mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); |
294 | if (mode3d < 0) |
||
335 | terminx | 295 | { |
1205 | terminx | 296 | int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 }; |
1544 | terminx | 297 | |
555 | terminx | 298 | for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } |
299 | for (; cd[i]; i++) |
||
300 | { |
||
301 | mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); |
||
302 | if (mode3d < 0) continue; |
||
303 | settings.bpp3d = cd[i]; |
||
304 | break; |
||
305 | } |
||
335 | terminx | 306 | } |
1544 | terminx | 307 | |
308 | modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.vmode3dcombo))); |
||
555 | terminx | 309 | gtk_list_store_clear(modes3d); |
310 | |||
311 | for (i=0; i<validmodecnt; i++) |
||
335 | terminx | 312 | { |
555 | terminx | 313 | if (validmode[i].fs != settings.fullscreen) continue; |
314 | |||
315 | // all modes get added to the 3D mode list |
||
584 | terminx | 316 | Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); |
555 | terminx | 317 | gtk_list_store_append(modes3d, &iter); |
318 | gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1); |
||
319 | if (i == mode3d) |
||
320 | { |
||
1544 | terminx | 321 | g_signal_handlers_block_by_func(stwidgets.vmode3dcombo, on_vmode3dcombo_changed, NULL); |
322 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.vmode3dcombo), &iter); |
||
323 | g_signal_handlers_unblock_by_func(stwidgets.vmode3dcombo, on_vmode3dcombo_changed, NULL); |
||
555 | terminx | 324 | } |
214 | terminx | 325 | } |
1544 | terminx | 326 | } |
1540 | terminx | 327 | |
1544 | terminx | 328 | if ((pgs == ALL) || (pgs == POPULATE_CONFIG)) |
329 | { |
||
330 | GtkListStore *devlist, *modsdir; |
||
331 | GtkTreeIter iter; |
||
332 | GtkTreePath *path; |
||
333 | char *value; |
||
334 | unsigned char i, r = 0; |
||
335 | const char *availabledev[] = { |
||
336 | "Keyboard only", |
||
337 | "Keyboard and mouse", |
||
338 | "Keyboard and joystick", |
||
339 | "All supported devices" |
||
340 | }; |
||
341 | |||
342 | // populate input devices combo |
||
343 | devlist = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.inputdevcombo))); |
||
344 | gtk_list_store_clear(devlist); |
||
345 | |||
346 | for (i=0; i<(int32_t)G_N_ELEMENTS(availabledev); i++) |
||
347 | { |
||
348 | gtk_list_store_append(devlist, &iter); |
||
349 | gtk_list_store_set(devlist, &iter, 0,availabledev[i], -1); |
||
350 | } |
||
351 | switch (settings.usemouse) |
||
352 | { |
||
353 | case 0: if (settings.usejoy) |
||
354 | gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_JOYSTICK); |
||
355 | else |
||
356 | gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_KB); |
||
357 | break; |
||
358 | case 1: if (settings.usejoy) |
||
359 | gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_ALL); |
||
360 | else |
||
361 | gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_MOUSE); |
||
362 | break; |
||
363 | } |
||
364 | |||
365 | // populate custom mod combo |
||
366 | modsdir = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.custommodcombo))); |
||
367 | gtk_list_store_clear(modsdir); |
||
368 | |||
369 | gtk_list_store_append(modsdir, &iter); |
||
370 | gtk_list_store_set(modsdir, &iter, 0,"None", -1); |
||
371 | r = GetModsDirNames(modsdir); |
||
372 | |||
373 | for(i=0; i<=r; i++) |
||
374 | { |
||
375 | path = gtk_tree_path_new_from_indices( i, -1 ); |
||
376 | gtk_tree_model_get_iter( GTK_TREE_MODEL(modsdir), &iter, path ); |
||
377 | gtk_tree_model_get( GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1 ); |
||
378 | |||
379 | if (Bstrcmp(settings.custommoddir, "/") == 0) |
||
380 | { |
||
381 | gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.custommodcombo), NONE); |
||
382 | settings.custommoddir = NULL; |
||
383 | |||
384 | break; |
||
385 | } |
||
386 | if (Bstrcmp(settings.custommoddir, value) == 0) |
||
387 | { |
||
388 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (stwidgets.custommodcombo), |
||
389 | &iter); |
||
390 | |||
391 | break; |
||
392 | } |
||
393 | } |
||
394 | |||
395 | // populate check buttons |
||
1540 | terminx | 396 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen); |
397 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer); |
||
398 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), settings.autoload); |
||
399 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup); |
||
1544 | terminx | 400 | } |
194 | terminx | 401 | |
1544 | terminx | 402 | if ((pgs == ALL) || (pgs == POPULATE_GAME)) |
555 | terminx | 403 | { |
404 | struct grpfile *fg; |
||
1205 | terminx | 405 | int32_t i; |
555 | terminx | 406 | GtkListStore *list; |
407 | GtkTreeIter iter; |
||
408 | GtkTreeView *gamelist; |
||
194 | terminx | 409 | |
1540 | terminx | 410 | gamelist = GTK_TREE_VIEW(stwidgets.gamelist); |
555 | terminx | 411 | list = GTK_LIST_STORE(gtk_tree_view_get_model(gamelist)); |
412 | gtk_list_store_clear(list); |
||
194 | terminx | 413 | |
555 | terminx | 414 | for (fg = foundgrps; fg; fg=fg->next) |
415 | { |
||
416 | for (i = 0; i<numgrpfiles; i++) |
||
417 | if (fg->crcval == grpfiles[i].crcval) break; |
||
418 | if (i == numgrpfiles) continue; // unrecognised grp file |
||
194 | terminx | 419 | |
555 | terminx | 420 | gtk_list_store_append(list, &iter); |
421 | gtk_list_store_set(list, &iter, 0, grpfiles[i].name, 1, fg->name, 2, (gpointer)fg, -1); |
||
422 | if (!Bstrcasecmp(fg->name, settings.selectedgrp)) |
||
423 | { |
||
424 | GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist); |
||
425 | g_signal_handlers_block_by_func(sel, on_gamelist_selection_changed, NULL); |
||
426 | gtk_tree_selection_select_iter(sel, &iter); |
||
427 | g_signal_handlers_unblock_by_func(sel, on_gamelist_selection_changed, NULL); |
||
428 | } |
||
214 | terminx | 429 | } |
430 | } |
||
194 | terminx | 431 | } |
432 | |||
555 | terminx | 433 | static gint name_sorter(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) |
434 | { |
||
435 | gchar *as, *bs; |
||
436 | gint r; |
||
654 | terminx | 437 | UNREFERENCED_PARAMETER(user_data); |
555 | terminx | 438 | gtk_tree_model_get(model, a, 0, &as, -1); |
439 | gtk_tree_model_get(model, b, 0, &bs, -1); |
||
440 | |||
441 | r = g_utf8_collate(as,bs); |
||
442 | |||
443 | g_free(as); |
||
444 | g_free(bs); |
||
445 | |||
446 | return r; |
||
447 | } |
||
448 | |||
194 | terminx | 449 | static GtkWidget *create_window(void) |
450 | { |
||
214 | terminx | 451 | // Basic window |
1540 | terminx | 452 | stwidgets.startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
453 | gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), apptitle); // NOTE: use global app title |
||
454 | gtk_window_set_position(GTK_WINDOW(stwidgets.startwin), GTK_WIN_POS_CENTER); |
||
455 | gtk_window_set_resizable(GTK_WINDOW(stwidgets.startwin), FALSE); |
||
456 | gtk_window_set_type_hint(GTK_WINDOW(stwidgets.startwin), GDK_WINDOW_TYPE_HINT_DIALOG); |
||
194 | terminx | 457 | |
214 | terminx | 458 | // Horizontal layout of banner and controls |
1540 | terminx | 459 | stwidgets.hlayout = gtk_hbox_new(FALSE, 0); |
460 | gtk_container_add(GTK_CONTAINER(stwidgets.startwin), stwidgets.hlayout); |
||
194 | terminx | 461 | |
1540 | terminx | 462 | // banner |
214 | terminx | 463 | { |
464 | GdkPixbuf *pixbuf = load_banner(); |
||
1540 | terminx | 465 | stwidgets.banner = gtk_image_new_from_pixbuf(pixbuf); |
214 | terminx | 466 | g_object_unref((gpointer)pixbuf); |
467 | } |
||
1540 | terminx | 468 | gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.banner, FALSE, FALSE, 0); |
469 | gtk_misc_set_alignment(GTK_MISC(stwidgets.banner), 0.5, 0); |
||
194 | terminx | 470 | |
214 | terminx | 471 | // Vertical layout of tab control and start+cancel buttons |
1540 | terminx | 472 | stwidgets.vlayout = gtk_vbox_new(FALSE, 0); |
473 | gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.vlayout, TRUE, TRUE, 0); |
||
194 | terminx | 474 | |
214 | terminx | 475 | // Tab control |
1540 | terminx | 476 | stwidgets.tabs = gtk_notebook_new(); |
477 | gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.tabs, TRUE, TRUE, 0); |
||
478 | gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4); |
||
479 | |||
480 | // layout table of config page |
||
1544 | terminx | 481 | stwidgets.configtlayout = gtk_table_new(6, 3, FALSE); |
482 | gtk_container_add (GTK_CONTAINER (stwidgets.tabs), stwidgets.configtlayout); |
||
1540 | terminx | 483 | |
484 | // 3D video mode LabelText |
||
485 | stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:"); |
||
486 | gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0); |
||
1544 | terminx | 487 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 0); |
1540 | terminx | 488 | |
489 | // 3D video mode combo |
||
214 | terminx | 490 | { |
491 | GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); |
||
492 | GtkCellRenderer *cell; |
||
194 | terminx | 493 | |
1540 | terminx | 494 | stwidgets.vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list)); |
214 | terminx | 495 | g_object_unref(G_OBJECT(list)); |
194 | terminx | 496 | |
214 | terminx | 497 | cell = gtk_cell_renderer_text_new(); |
1540 | terminx | 498 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE); |
499 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL); |
||
214 | terminx | 500 | } |
1544 | terminx | 501 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0); |
194 | terminx | 502 | |
1540 | terminx | 503 | // Fullscreen checkbox |
504 | stwidgets.displayvlayout = gtk_vbox_new(TRUE, 0); |
||
1544 | terminx | 505 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 0); |
1540 | terminx | 506 | stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen"); |
507 | gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.fullscreencheck, FALSE, FALSE, 0); |
||
508 | |||
509 | // Polymer checkbox |
||
510 | stwidgets.polymercheck = gtk_check_button_new_with_mnemonic("_Polymer"); |
||
511 | gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.polymercheck, FALSE, FALSE, 0); |
||
194 | terminx | 512 | |
1540 | terminx | 513 | // Input devices LabelText |
1544 | terminx | 514 | stwidgets.inputdevlabel = gtk_label_new_with_mnemonic("_Input devices:"); |
1540 | terminx | 515 | gtk_misc_set_alignment(GTK_MISC(stwidgets.inputdevlabel), 0.3, 0); |
1544 | terminx | 516 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevlabel, 0,1, 1,2, GTK_FILL, 0, 4, 0); |
1540 | terminx | 517 | |
1544 | terminx | 518 | // Input devices combo |
519 | { |
||
520 | GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING); |
||
521 | GtkCellRenderer *cell; |
||
522 | |||
523 | stwidgets.inputdevcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list)); |
||
524 | g_object_unref(G_OBJECT(list)); |
||
525 | |||
526 | cell = gtk_cell_renderer_text_new(); |
||
527 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, FALSE); |
||
528 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, "text", 0, NULL); |
||
529 | } |
||
530 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0); |
||
1540 | terminx | 531 | |
1544 | terminx | 532 | // Custom mod LabelText |
533 | stwidgets.custommodlabel = gtk_label_new_with_mnemonic("Custom _Mod:"); |
||
534 | gtk_misc_set_alignment(GTK_MISC(stwidgets.custommodlabel), 0.3, 0); |
||
535 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodlabel, 0,1, 2,3, GTK_FILL, 0, 4, 7); |
||
1540 | terminx | 536 | |
1544 | terminx | 537 | // Custom mod combo |
538 | { |
||
539 | GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING); |
||
540 | GtkCellRenderer *cell; |
||
1540 | terminx | 541 | |
1544 | terminx | 542 | stwidgets.custommodcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list)); |
543 | g_object_unref(G_OBJECT(list)); |
||
544 | |||
545 | cell = gtk_cell_renderer_text_new(); |
||
546 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, FALSE); |
||
547 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, "text", 0, NULL); |
||
548 | } |
||
549 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodcombo, 1,2, 2,3, GTK_EXPAND | GTK_FILL, 0, 4, 7); |
||
550 | |||
551 | // Empty horizontal layout |
||
552 | stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0); |
||
553 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,3, 3,4, 0, GTK_EXPAND | GTK_FILL, 4, 0); |
||
554 | |||
1540 | terminx | 555 | // Autoload checkbox |
556 | stwidgets.autoloadcheck = gtk_check_button_new_with_mnemonic("_Enable \"autoload\" folder"); |
||
1544 | terminx | 557 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.autoloadcheck, 0,3, 4,5, GTK_FILL, 0, 2, 2); |
1540 | terminx | 558 | |
559 | // Always show config checkbox |
||
1544 | terminx | 560 | stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show this window at startup"); |
561 | gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,3, 5,6, GTK_FILL, 0, 2, 2); |
||
1540 | terminx | 562 | |
214 | terminx | 563 | // Configuration tab |
1540 | terminx | 564 | stwidgets.configtab = gtk_label_new("Configuration"); |
565 | gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 0), stwidgets.configtab); |
||
194 | terminx | 566 | |
555 | terminx | 567 | // Game data layout |
1540 | terminx | 568 | stwidgets.gamevlayout = gtk_vbox_new(FALSE, 0); |
569 | gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.gamevlayout); |
||
570 | gtk_container_set_border_width(GTK_CONTAINER(stwidgets.gamevlayout), 4); |
||
555 | terminx | 571 | |
1143 | terminx | 572 | // Game data field LabelText |
1540 | terminx | 573 | stwidgets.gamelabel = gtk_label_new_with_mnemonic("_Game or addon:"); |
574 | gtk_box_pack_start(GTK_BOX(stwidgets.gamevlayout), stwidgets.gamelabel, FALSE, FALSE, 0); |
||
575 | gtk_misc_set_alignment(GTK_MISC(stwidgets.gamelabel), 0, 0.5); |
||
555 | terminx | 576 | |
577 | // Game data scrollable area |
||
1540 | terminx | 578 | stwidgets.gamescroll = gtk_scrolled_window_new(NULL, NULL); |
579 | gtk_box_pack_start(GTK_BOX(stwidgets.gamevlayout), stwidgets.gamescroll, TRUE, TRUE, 0); |
||
580 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.gamescroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
||
581 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(stwidgets.gamescroll), GTK_SHADOW_IN); |
||
555 | terminx | 582 | |
583 | // Game data list |
||
584 | { |
||
585 | GtkListStore *list = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
||
586 | GtkCellRenderer *cell; |
||
587 | GtkTreeViewColumn *col; |
||
588 | |||
589 | gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list), 0, name_sorter, NULL, NULL); |
||
590 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list), 0, GTK_SORT_ASCENDING); |
||
591 | |||
1540 | terminx | 592 | stwidgets.gamelist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list)); |
555 | terminx | 593 | g_object_unref(G_OBJECT(list)); |
594 | |||
595 | cell = gtk_cell_renderer_text_new(); |
||
596 | col = gtk_tree_view_column_new_with_attributes("Game", cell, "text", 0, NULL); |
||
597 | gtk_tree_view_column_set_expand(col, TRUE); |
||
1540 | terminx | 598 | gtk_tree_view_append_column(GTK_TREE_VIEW(stwidgets.gamelist), col); |
555 | terminx | 599 | col = gtk_tree_view_column_new_with_attributes("GRP file", cell, "text", 1, NULL); |
600 | gtk_tree_view_column_set_min_width(col, 64); |
||
1540 | terminx | 601 | gtk_tree_view_append_column(GTK_TREE_VIEW(stwidgets.gamelist), col); |
555 | terminx | 602 | } |
1540 | terminx | 603 | gtk_container_add(GTK_CONTAINER(stwidgets.gamescroll), stwidgets.gamelist); |
604 | |||
605 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(stwidgets.gamelist), FALSE); |
||
606 | gtk_tree_view_set_enable_search(GTK_TREE_VIEW(stwidgets.gamelist), FALSE); |
||
555 | terminx | 607 | |
608 | // Game tab |
||
1540 | terminx | 609 | stwidgets.gametab = gtk_label_new("Game"); |
610 | gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 1), stwidgets.gametab); |
||
555 | terminx | 611 | |
214 | terminx | 612 | // Messages scrollable area |
1540 | terminx | 613 | stwidgets.messagesscroll = gtk_scrolled_window_new(NULL, NULL); |
614 | gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.messagesscroll); |
||
615 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
||
194 | terminx | 616 | |
214 | terminx | 617 | // Messages text area |
1540 | terminx | 618 | stwidgets.messagestext = gtk_text_view_new(); |
619 | gtk_container_add(GTK_CONTAINER(stwidgets.messagesscroll), stwidgets.messagestext); |
||
620 | gtk_text_view_set_editable(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE); |
||
621 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(stwidgets.messagestext), GTK_WRAP_WORD); |
||
622 | gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE); |
||
623 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2); |
||
624 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2); |
||
194 | terminx | 625 | |
214 | terminx | 626 | // Messages tab |
1540 | terminx | 627 | stwidgets.messagestab = gtk_label_new("Messages"); |
628 | gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 2), stwidgets.messagestab); |
||
194 | terminx | 629 | |
214 | terminx | 630 | // Dialogue box buttons layout |
1540 | terminx | 631 | stwidgets.buttons = gtk_hbutton_box_new(); |
632 | gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.buttons, FALSE, TRUE, 0); |
||
633 | gtk_container_set_border_width(GTK_CONTAINER(stwidgets.buttons), 3); |
||
634 | gtk_button_box_set_layout(GTK_BUTTON_BOX(stwidgets.buttons), GTK_BUTTONBOX_END); |
||
194 | terminx | 635 | |
214 | terminx | 636 | // Cancel button |
1540 | terminx | 637 | stwidgets.cancelbutton = gtk_button_new(); |
638 | gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.cancelbutton); |
||
639 | GTK_WIDGET_SET_FLAGS(stwidgets.cancelbutton, GTK_CAN_DEFAULT); |
||
194 | terminx | 640 | |
1540 | terminx | 641 | stwidgets.cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0); |
642 | gtk_container_add(GTK_CONTAINER(stwidgets.cancelbutton), stwidgets.cancelbuttonalign); |
||
194 | terminx | 643 | |
1540 | terminx | 644 | stwidgets.cancelbuttonlayout = gtk_hbox_new(FALSE, 2); |
645 | gtk_container_add(GTK_CONTAINER(stwidgets.cancelbuttonalign), stwidgets.cancelbuttonlayout); |
||
194 | terminx | 646 | |
1540 | terminx | 647 | stwidgets.cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON); |
648 | gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonicon, FALSE, FALSE, 0); |
||
194 | terminx | 649 | |
1540 | terminx | 650 | stwidgets.cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel"); |
651 | gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonlabel, FALSE, FALSE, 0); |
||
194 | terminx | 652 | |
214 | terminx | 653 | // Start button |
1540 | terminx | 654 | stwidgets.startbutton = gtk_button_new(); |
655 | gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.startbutton); |
||
656 | GTK_WIDGET_SET_FLAGS(stwidgets.startbutton, GTK_CAN_DEFAULT); |
||
194 | terminx | 657 | |
1540 | terminx | 658 | stwidgets.startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0); |
659 | gtk_container_add(GTK_CONTAINER(stwidgets.startbutton), stwidgets.startbuttonalign); |
||
194 | terminx | 660 | |
1540 | terminx | 661 | stwidgets.startbuttonlayout = gtk_hbox_new(FALSE, 2); |
662 | gtk_container_add(GTK_CONTAINER(stwidgets.startbuttonalign), stwidgets.startbuttonlayout); |
||
194 | terminx | 663 | |
1540 | terminx | 664 | stwidgets.startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON); |
665 | gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonicon, FALSE, FALSE, 0); |
||
194 | terminx | 666 | |
1540 | terminx | 667 | stwidgets.startbuttonlabel = gtk_label_new_with_mnemonic("_Start"); |
668 | gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0); |
||
194 | terminx | 669 | |
214 | terminx | 670 | // Wire up the signals |
1544 | terminx | 671 | g_signal_connect((gpointer) stwidgets.startwin, "delete_event", |
333 | terminx | 672 | G_CALLBACK(on_startwin_delete_event), |
673 | NULL); |
||
1544 | terminx | 674 | g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed", |
675 | G_CALLBACK(on_vmode3dcombo_changed), |
||
676 | NULL); |
||
677 | g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled", |
||
333 | terminx | 678 | G_CALLBACK(on_fullscreencheck_toggled), |
679 | NULL); |
||
1544 | terminx | 680 | g_signal_connect((gpointer) stwidgets.polymercheck, "toggled", |
1540 | terminx | 681 | G_CALLBACK(on_polymercheck_toggled), |
682 | NULL); |
||
1544 | terminx | 683 | g_signal_connect((gpointer) stwidgets.inputdevcombo, "changed", |
684 | G_CALLBACK(on_inputdevcombo_changed), |
||
1540 | terminx | 685 | NULL); |
1544 | terminx | 686 | g_signal_connect((gpointer) stwidgets.custommodcombo, "changed", |
687 | G_CALLBACK(on_custommodcombo_changed), |
||
333 | terminx | 688 | NULL); |
1544 | terminx | 689 | g_signal_connect((gpointer) stwidgets.autoloadcheck, "toggled", |
690 | G_CALLBACK(on_autoloadcheck_toggled), |
||
333 | terminx | 691 | NULL); |
1544 | terminx | 692 | g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled", |
333 | terminx | 693 | G_CALLBACK(on_alwaysshowcheck_toggled), |
694 | NULL); |
||
1544 | terminx | 695 | g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked", |
333 | terminx | 696 | G_CALLBACK(on_cancelbutton_clicked), |
697 | NULL); |
||
1544 | terminx | 698 | g_signal_connect((gpointer) stwidgets.startbutton, "clicked", |
333 | terminx | 699 | G_CALLBACK(on_startbutton_clicked), |
700 | NULL); |
||
555 | terminx | 701 | { |
1540 | terminx | 702 | GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(stwidgets.gamelist)); |
555 | terminx | 703 | gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
704 | g_signal_connect((gpointer) sel, "changed", |
||
705 | G_CALLBACK(on_gamelist_selection_changed), |
||
706 | NULL); |
||
707 | } |
||
194 | terminx | 708 | |
214 | terminx | 709 | // Associate labels with their controls |
1540 | terminx | 710 | gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode3dlabel), stwidgets.vmode3dcombo); |
1544 | terminx | 711 | gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.inputdevlabel), stwidgets.inputdevcombo); |
712 | gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.custommodlabel), stwidgets.custommodcombo); |
||
1540 | terminx | 713 | gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.gamelabel), stwidgets.gamelist); |
194 | terminx | 714 | |
1540 | terminx | 715 | return stwidgets.startwin; |
716 | } |
||
194 | terminx | 717 | |
718 | |||
719 | // -- BUILD ENTRY POINTS ------------------------------------------------------ |
||
720 | |||
1205 | terminx | 721 | int32_t startwin_open(void) |
194 | terminx | 722 | { |
214 | terminx | 723 | if (!gtkenabled) return 0; |
1540 | terminx | 724 | if (stwidgets.startwin) return 1; |
194 | terminx | 725 | |
1540 | terminx | 726 | stwidgets.startwin = create_window(); |
727 | if (stwidgets.startwin) |
||
335 | terminx | 728 | { |
214 | terminx | 729 | SetPage(TAB_MESSAGES); |
1540 | terminx | 730 | gtk_widget_show_all(stwidgets.startwin); |
214 | terminx | 731 | gtk_main_iteration_do(FALSE); |
732 | return 0; |
||
733 | } |
||
734 | return -1; |
||
194 | terminx | 735 | } |
736 | |||
1205 | terminx | 737 | int32_t startwin_close(void) |
194 | terminx | 738 | { |
214 | terminx | 739 | if (!gtkenabled) return 0; |
1540 | terminx | 740 | if (!stwidgets.startwin) return 1; |
741 | gtk_widget_destroy(stwidgets.startwin); |
||
742 | stwidgets.startwin = NULL; |
||
214 | terminx | 743 | return 0; |
194 | terminx | 744 | } |
745 | |||
1205 | terminx | 746 | int32_t startwin_puts(const char *str) |
194 | terminx | 747 | { |
214 | terminx | 748 | GtkWidget *textview; |
749 | GtkTextBuffer *textbuffer; |
||
750 | GtkTextIter enditer; |
||
751 | GtkTextMark *mark; |
||
752 | const char *aptr, *bptr; |
||
194 | terminx | 753 | |
214 | terminx | 754 | if (!gtkenabled || !str) return 0; |
1540 | terminx | 755 | if (!stwidgets.startwin) return 1; |
756 | if (!(textview = stwidgets.messagestext)) return -1; |
||
214 | terminx | 757 | textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); |
194 | terminx | 758 | |
214 | terminx | 759 | gtk_text_buffer_get_end_iter(textbuffer, &enditer); |
335 | terminx | 760 | for (aptr = bptr = str; *aptr != 0;) |
761 | { |
||
762 | switch (*bptr) |
||
763 | { |
||
337 | terminx | 764 | case '\b': |
765 | if (bptr > aptr) |
||
766 | gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); |
||
194 | terminx | 767 | #if GTK_CHECK_VERSION(2,6,0) |
337 | terminx | 768 | gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); |
194 | terminx | 769 | #else |
337 | terminx | 770 | { |
771 | GtkTextIter iter2 = enditer; |
||
772 | gtk_text_iter_backward_cursor_position(&iter2); |
||
773 | //FIXME: this seems be deleting one too many chars somewhere! |
||
774 | if (!gtk_text_iter_equal(&iter2, &enditer)) |
||
775 | gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); |
||
776 | } |
||
194 | terminx | 777 | #endif |
337 | terminx | 778 | aptr = ++bptr; |
779 | break; |
||
780 | case 0: |
||
781 | if (bptr > aptr) |
||
782 | gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); |
||
783 | aptr = bptr; |
||
784 | break; |
||
785 | case '\r': // FIXME |
||
786 | default: |
||
787 | bptr++; |
||
788 | break; |
||
214 | terminx | 789 | } |
790 | } |
||
194 | terminx | 791 | |
214 | terminx | 792 | mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); |
793 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); |
||
794 | gtk_text_buffer_delete_mark(textbuffer, mark); |
||
194 | terminx | 795 | |
214 | terminx | 796 | return 0; |
194 | terminx | 797 | } |
798 | |||
1205 | terminx | 799 | int32_t startwin_settitle(const char *title) |
194 | terminx | 800 | { |
214 | terminx | 801 | if (!gtkenabled) return 0; |
1540 | terminx | 802 | if (!stwidgets.startwin) return 1; |
803 | gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), title); |
||
214 | terminx | 804 | return 0; |
194 | terminx | 805 | } |
806 | |||
1205 | terminx | 807 | int32_t startwin_idle(void *s) |
194 | terminx | 808 | { |
654 | terminx | 809 | UNREFERENCED_PARAMETER(s); |
214 | terminx | 810 | if (!gtkenabled) return 0; |
1540 | terminx | 811 | //if (!stwidgets.startwin) return 1; |
333 | terminx | 812 | gtk_main_iteration_do(FALSE); |
214 | terminx | 813 | return 0; |
194 | terminx | 814 | } |
815 | |||
1205 | terminx | 816 | int32_t startwin_run(void) |
194 | terminx | 817 | { |
622 | terminx | 818 | if (!gtkenabled) return 1; |
1540 | terminx | 819 | if (!stwidgets.startwin) return 1; |
194 | terminx | 820 | |
214 | terminx | 821 | SetPage(TAB_CONFIG); |
194 | terminx | 822 | |
563 | terminx | 823 | settings.xdim3d = ud.config.ScreenWidth; |
824 | settings.ydim3d = ud.config.ScreenHeight; |
||
825 | settings.bpp3d = ud.config.ScreenBPP; |
||
1544 | terminx | 826 | settings.fullscreen = ud.config.ScreenMode; |
563 | terminx | 827 | settings.usemouse = ud.config.UseMouse; |
828 | settings.usejoy = ud.config.UseJoystick; |
||
1587 | terminx | 829 | settings.custommoddir = g_modDir; |
1544 | terminx | 830 | settings.forcesetup = ud.config.ForceSetup; |
1143 | terminx | 831 | settings.game = g_gameType; |
1587 | terminx | 832 | Bstrncpy(settings.selectedgrp, g_grpNamePtr, BMAX_PATH); |
1540 | terminx | 833 | if (ud.config.NoAutoLoad) settings.autoload = FALSE; |
834 | else settings.autoload = TRUE; |
||
1544 | terminx | 835 | if (glrendmode == RDR_POLYMER) |
1540 | terminx | 836 | { |
837 | if (settings.bpp3d == 8) settings.bpp3d = 32; |
||
838 | settings.polymer = TRUE; |
||
839 | } |
||
1544 | terminx | 840 | PopulateForm(ALL); |
194 | terminx | 841 | |
214 | terminx | 842 | gtk_main(); |
843 | |||
844 | SetPage(TAB_MESSAGES); |
||
1540 | terminx | 845 | if (retval) // launch the game with these parameters |
335 | terminx | 846 | { |
1205 | terminx | 847 | int32_t i; |
1544 | terminx | 848 | |
563 | terminx | 849 | ud.config.ScreenWidth = settings.xdim3d; |
850 | ud.config.ScreenHeight = settings.ydim3d; |
||
851 | ud.config.ScreenBPP = settings.bpp3d; |
||
1544 | terminx | 852 | ud.config.ScreenMode = settings.fullscreen; |
563 | terminx | 853 | ud.config.UseMouse = settings.usemouse; |
854 | ud.config.UseJoystick = settings.usejoy; |
||
1544 | terminx | 855 | ud.config.ForceSetup = settings.forcesetup; |
1587 | terminx | 856 | g_grpNamePtr = settings.selectedgrp; |
1143 | terminx | 857 | g_gameType = settings.game; |
1544 | terminx | 858 | if (settings.custommoddir != NULL) |
1587 | terminx | 859 | Bstrcpy(g_modDir, settings.custommoddir); |
860 | else Bsprintf(g_modDir, "/"); |
||
1544 | terminx | 861 | |
1540 | terminx | 862 | if (settings.autoload) ud.config.NoAutoLoad = FALSE; |
863 | else ud.config.NoAutoLoad = TRUE; |
||
886 | terminx | 864 | |
865 | for (i = 0; i<numgrpfiles; i++) if (settings.crcval == grpfiles[i].crcval) break; |
||
866 | if (i != numgrpfiles) |
||
1587 | terminx | 867 | g_gameNamePtr = (char *)grpfiles[i].name; |
214 | terminx | 868 | } |
869 | |||
870 | return retval; |
||
194 | terminx | 871 | } |