Subversion Repositories eduke32

Rev

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