Subversion Repositories eduke32

Rev

Rev 1593 | Rev 1660 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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