Subversion Repositories eduke32

Rev

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