2010-05-25 10:56:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
#if defined(LINKED_GTK)
|
2010-01-23 22:12:02 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk-pixbuf/gdk-pixdata.h>
|
2009-11-14 02:30:47 +00:00
|
|
|
#else
|
2010-01-23 22:12:02 +00:00
|
|
|
#include "dynamicgtk.h"
|
2009-11-14 02:30:47 +00:00
|
|
|
#endif
|
2006-07-01 12:00:26 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#include "duke3d.h"
|
2007-08-16 23:25:24 +00:00
|
|
|
#include "grpscan.h"
|
2009-11-14 02:30:47 +00:00
|
|
|
#include "build.h"
|
2007-08-16 23:25:24 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
#define RDR_POLYMOST 3 // sould be defined elsewhere
|
|
|
|
#define RDR_POLYMER 4 // sould be defined elsewhere
|
|
|
|
|
2010-01-23 22:12:02 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
ALL,
|
|
|
|
POPULATE_VIDEO,
|
|
|
|
POPULATE_CONFIG,
|
|
|
|
POPULATE_GAME,
|
2009-11-18 01:17:56 +00:00
|
|
|
};
|
|
|
|
|
2010-01-23 22:12:02 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TAB_CONFIG,
|
|
|
|
TAB_GAME,
|
|
|
|
TAB_MESSAGES,
|
2009-11-18 01:17:56 +00:00
|
|
|
};
|
|
|
|
|
2010-01-23 22:12:02 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
INPUT_KB,
|
|
|
|
INPUT_MOUSE,
|
|
|
|
INPUT_JOYSTICK,
|
|
|
|
INPUT_ALL,
|
2009-11-18 01:17:56 +00:00
|
|
|
};
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
static struct
|
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
GtkWidget *startwin;
|
|
|
|
GtkWidget *hlayout;
|
|
|
|
GtkWidget *banner;
|
|
|
|
GtkWidget *vlayout;
|
|
|
|
GtkWidget *tabs;
|
|
|
|
GtkWidget *configtlayout;
|
|
|
|
GtkWidget *displayvlayout;
|
|
|
|
GtkWidget *vmode3dlabel;
|
|
|
|
GtkWidget *vmode3dcombo;
|
|
|
|
GtkWidget *fullscreencheck;
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
GtkWidget *polymercheck;
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2010-01-23 22:12:02 +00:00
|
|
|
GtkWidget *inputdevlabel;
|
|
|
|
GtkWidget *inputdevcombo;
|
|
|
|
GtkWidget *custommodlabel;
|
|
|
|
GtkWidget *custommodcombo;
|
|
|
|
GtkWidget *emptyhlayout;
|
|
|
|
GtkWidget *autoloadcheck;
|
|
|
|
GtkWidget *alwaysshowcheck;
|
|
|
|
GtkWidget *configtab;
|
|
|
|
GtkWidget *gamevlayout;
|
|
|
|
GtkWidget *gamelabel;
|
|
|
|
GtkWidget *gamescroll;
|
|
|
|
GtkWidget *gamelist;
|
|
|
|
GtkWidget *gametab;
|
|
|
|
GtkWidget *messagesscroll;
|
|
|
|
GtkWidget *messagestext;
|
|
|
|
GtkWidget *messagestab;
|
|
|
|
GtkWidget *buttons;
|
|
|
|
GtkWidget *cancelbutton;
|
|
|
|
GtkWidget *cancelbuttonalign;
|
|
|
|
GtkWidget *cancelbuttonlayout;
|
|
|
|
GtkWidget *cancelbuttonicon;
|
|
|
|
GtkWidget *cancelbuttonlabel;
|
|
|
|
GtkWidget *startbutton;
|
|
|
|
GtkWidget *startbuttonalign;
|
|
|
|
GtkWidget *startbuttonlayout;
|
|
|
|
GtkWidget *startbuttonicon;
|
|
|
|
GtkWidget *startbuttonlabel;
|
2009-11-14 02:30:47 +00:00
|
|
|
} stwidgets;
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
static struct
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t fullscreen;
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2009-11-14 02:30:47 +00:00
|
|
|
int32_t polymer;
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t xdim3d, ydim3d, bpp3d;
|
|
|
|
int32_t forcesetup;
|
2010-01-23 22:12:02 +00:00
|
|
|
int32_t autoload;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t usemouse, usejoy;
|
|
|
|
int32_t game;
|
|
|
|
int32_t crcval;
|
2009-11-18 01:17:56 +00:00
|
|
|
char *custommoddir;
|
2009-07-12 01:55:34 +00:00
|
|
|
char selectedgrp[BMAX_PATH];
|
2007-08-16 23:25:24 +00:00
|
|
|
} settings;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
static int32_t retval = -1, mode = TAB_MESSAGES;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t gtkenabled;
|
2009-11-18 01:17:56 +00:00
|
|
|
static void PopulateForm(unsigned char pgs);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
int32_t val;
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
|
|
|
|
if (!(data = gtk_combo_box_get_model(combobox))) return;
|
|
|
|
gtk_tree_model_get(data, &iter, 1, &val, -1);
|
|
|
|
settings.xdim3d = validmode[val].xdim;
|
|
|
|
settings.ydim3d = validmode[val].ydim;
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
settings.fullscreen = gtk_toggle_button_get_active(togglebutton);
|
2009-11-18 01:17:56 +00:00
|
|
|
PopulateForm(POPULATE_VIDEO);
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2009-11-14 02:30:47 +00:00
|
|
|
static void on_polymercheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
if (gtk_toggle_button_get_active(togglebutton))
|
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
glrendmode = RDR_POLYMER;
|
|
|
|
settings.polymer = TRUE;
|
|
|
|
if (settings.bpp3d == 8)
|
|
|
|
{
|
|
|
|
settings.bpp3d = 32;
|
|
|
|
PopulateForm(POPULATE_VIDEO);
|
|
|
|
}
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
glrendmode = RDR_POLYMOST;
|
|
|
|
settings.polymer = FALSE;
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2009-11-14 02:30:47 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
static void on_inputdevcombo_changed(GtkComboBox *combobox, gpointer user_data)
|
2009-11-14 02:30:47 +00:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2009-11-18 01:17:56 +00:00
|
|
|
switch (gtk_combo_box_get_active(combobox))
|
2010-01-23 22:12:02 +00:00
|
|
|
{
|
|
|
|
case 0: settings.usemouse = 0; settings.usejoy = 0; break;
|
|
|
|
case 1: settings.usemouse = 1; settings.usejoy = 0; break;
|
|
|
|
case 2: settings.usemouse = 0; settings.usejoy = 1; break;
|
|
|
|
case 3: settings.usemouse = 1; settings.usejoy = 1; break;
|
|
|
|
}
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
static void on_custommodcombo_changed(GtkComboBox *combobox, gpointer user_data)
|
2009-11-14 02:30:47 +00:00
|
|
|
{
|
2009-11-18 01:17:56 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
|
|
|
char *value;
|
2009-11-14 02:30:47 +00:00
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter(combobox, &iter))
|
2009-11-18 01:17:56 +00:00
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
model = gtk_combo_box_get_model(combobox);
|
|
|
|
gtk_tree_model_get(model, &iter, 0,&value, -1);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
if (*gtk_tree_path_get_indices(path) == NONE)
|
|
|
|
settings.custommoddir = NULL;
|
|
|
|
else settings.custommoddir = value;
|
|
|
|
}
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
static void on_autoloadcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
|
2009-11-14 02:30:47 +00:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2009-11-18 01:17:56 +00:00
|
|
|
settings.autoload = gtk_toggle_button_get_active(togglebutton);
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
settings.forcesetup = gtk_toggle_button_get_active(togglebutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(button);
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
|
|
|
|
else quitevent++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(button);
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
retval = 1;
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_gamelist_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
struct grpfile *fg;
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get(model, &iter, 2, (gpointer)&fg, -1);
|
|
|
|
strcpy(settings.selectedgrp, fg->name);
|
|
|
|
settings.game = fg->game;
|
|
|
|
settings.crcval = fg->crcval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(widget);
|
|
|
|
UNREFERENCED_PARAMETER(event);
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
|
|
|
|
else quitevent++;
|
|
|
|
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- SUPPORT FUNCTIONS -------------------------------------------------------
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
static GdkPixbuf *load_banner(void)
|
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
extern const GdkPixdata startbanner_pixdata;
|
|
|
|
return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void SetPage(int32_t n)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!gtkenabled || !stwidgets.startwin) return;
|
2006-07-07 18:41:05 +00:00
|
|
|
mode = n;
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(stwidgets.tabs), n);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// each control in the config page vertical layout plus the start button should be made (in)sensitive
|
2007-08-16 23:25:24 +00:00
|
|
|
if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_set_sensitive(stwidgets.startbutton, n);
|
2009-11-18 01:17:56 +00:00
|
|
|
gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout),
|
2010-01-23 22:12:02 +00:00
|
|
|
(GtkCallback)gtk_widget_set_sensitive,
|
|
|
|
(gpointer)&n);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
static unsigned char GetModsDirNames(GtkListStore *list)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
char *homedir;
|
|
|
|
char pdir[BMAX_PATH];
|
|
|
|
unsigned char iternumb = 0;
|
|
|
|
CACHE1D_FIND_REC *dirs = NULL;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
pathsearchmode = 1;
|
|
|
|
|
|
|
|
if ((homedir = Bgethomedir()))
|
|
|
|
{
|
|
|
|
Bsnprintf(pdir, sizeof(pdir), "%s/" ".eduke32", homedir);
|
|
|
|
dirs = klistpath(pdir, "*", CACHE1D_FIND_DIR);
|
|
|
|
for (dirs=dirs; dirs != NULL; dirs=dirs->next)
|
|
|
|
{
|
|
|
|
if ((Bstrcmp(dirs->name, "autoload") == 0) ||
|
|
|
|
(Bstrcmp(dirs->name, "..") == 0) ||
|
|
|
|
(Bstrcmp(dirs->name, ".") == 0))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_list_store_append(list, &iter);
|
|
|
|
gtk_list_store_set(list, &iter, 0,dirs->name, -1);
|
|
|
|
iternumb++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
klistfree(dirs);
|
|
|
|
dirs = NULL;
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
return iternumb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PopulateForm(unsigned char pgs)
|
|
|
|
{
|
|
|
|
if ((pgs == ALL) || (pgs == POPULATE_VIDEO))
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mode3d, i;
|
2007-08-16 23:25:24 +00:00
|
|
|
GtkListStore *modes3d;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
char buf[64];
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2007-08-16 23:25:24 +00:00
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
|
|
|
|
if (mode3d < 0)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 };
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2007-08-16 23:25:24 +00:00
|
|
|
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
|
|
|
|
for (; cd[i]; i++)
|
|
|
|
{
|
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
|
|
|
|
if (mode3d < 0) continue;
|
|
|
|
settings.bpp3d = cd[i];
|
|
|
|
break;
|
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.vmode3dcombo)));
|
2007-08-16 23:25:24 +00:00
|
|
|
gtk_list_store_clear(modes3d);
|
|
|
|
|
|
|
|
for (i=0; i<validmodecnt; i++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2007-08-16 23:25:24 +00:00
|
|
|
if (validmode[i].fs != settings.fullscreen) continue;
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2007-08-16 23:25:24 +00:00
|
|
|
// all modes get added to the 3D mode list
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
|
2007-08-16 23:25:24 +00:00
|
|
|
gtk_list_store_append(modes3d, &iter);
|
|
|
|
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
|
|
|
|
if (i == mode3d)
|
|
|
|
{
|
2009-11-18 01:17:56 +00:00
|
|
|
g_signal_handlers_block_by_func(stwidgets.vmode3dcombo, on_vmode3dcombo_changed, NULL);
|
|
|
|
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.vmode3dcombo), &iter);
|
|
|
|
g_signal_handlers_unblock_by_func(stwidgets.vmode3dcombo, on_vmode3dcombo_changed, NULL);
|
2007-08-16 23:25:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-23 22:12:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
if ((pgs == ALL) || (pgs == POPULATE_CONFIG))
|
2010-01-23 22:12:02 +00:00
|
|
|
{
|
2009-11-18 01:17:56 +00:00
|
|
|
GtkListStore *devlist, *modsdir;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
char *value;
|
|
|
|
unsigned char i, r = 0;
|
2010-01-23 22:12:02 +00:00
|
|
|
const char *availabledev[] =
|
|
|
|
{
|
|
|
|
"Keyboard only",
|
|
|
|
"Keyboard and mouse",
|
|
|
|
"Keyboard and joystick",
|
|
|
|
"All supported devices"
|
|
|
|
};
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
// populate input devices combo
|
2010-01-23 22:12:02 +00:00
|
|
|
devlist = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.inputdevcombo)));
|
|
|
|
gtk_list_store_clear(devlist);
|
|
|
|
|
|
|
|
for (i=0; i<(int32_t)G_N_ELEMENTS(availabledev); i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(devlist, &iter);
|
2009-11-18 01:17:56 +00:00
|
|
|
gtk_list_store_set(devlist, &iter, 0,availabledev[i], -1);
|
|
|
|
}
|
2010-01-23 22:12:02 +00:00
|
|
|
switch (settings.usemouse)
|
|
|
|
{
|
|
|
|
case 0: if (settings.usejoy)
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_JOYSTICK);
|
|
|
|
else
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_KB);
|
|
|
|
break;
|
|
|
|
case 1: if (settings.usejoy)
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_ALL);
|
|
|
|
else
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_MOUSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// populate custom mod combo
|
|
|
|
modsdir = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.custommodcombo)));
|
|
|
|
gtk_list_store_clear(modsdir);
|
|
|
|
|
|
|
|
gtk_list_store_append(modsdir, &iter);
|
2009-11-18 01:17:56 +00:00
|
|
|
gtk_list_store_set(modsdir, &iter, 0,"None", -1);
|
2010-01-23 22:12:02 +00:00
|
|
|
r = GetModsDirNames(modsdir);
|
|
|
|
|
|
|
|
for (i=0; i<=r; i++)
|
|
|
|
{
|
|
|
|
path = gtk_tree_path_new_from_indices(i, -1);
|
|
|
|
gtk_tree_model_get_iter(GTK_TREE_MODEL(modsdir), &iter, path);
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1);
|
|
|
|
|
|
|
|
if (Bstrcmp(settings.custommoddir, "/") == 0)
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.custommodcombo), NONE);
|
|
|
|
settings.custommoddir = NULL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Bstrcmp(settings.custommoddir, value) == 0)
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.custommodcombo),
|
|
|
|
&iter);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
// populate check buttons
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen);
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer);
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), settings.autoload);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup);
|
2010-01-23 22:12:02 +00:00
|
|
|
}
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
if ((pgs == ALL) || (pgs == POPULATE_GAME))
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2007-08-16 23:25:24 +00:00
|
|
|
struct grpfile *fg;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2007-08-16 23:25:24 +00:00
|
|
|
GtkListStore *list;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeView *gamelist;
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
gamelist = GTK_TREE_VIEW(stwidgets.gamelist);
|
2007-08-16 23:25:24 +00:00
|
|
|
list = GTK_LIST_STORE(gtk_tree_view_get_model(gamelist));
|
|
|
|
gtk_list_store_clear(list);
|
|
|
|
|
|
|
|
for (fg = foundgrps; fg; fg=fg->next)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2007-08-16 23:25:24 +00:00
|
|
|
for (i = 0; i<numgrpfiles; i++)
|
|
|
|
if (fg->crcval == grpfiles[i].crcval) break;
|
|
|
|
if (i == numgrpfiles) continue; // unrecognised grp file
|
|
|
|
|
|
|
|
gtk_list_store_append(list, &iter);
|
|
|
|
gtk_list_store_set(list, &iter, 0, grpfiles[i].name, 1, fg->name, 2, (gpointer)fg, -1);
|
|
|
|
if (!Bstrcasecmp(fg->name, settings.selectedgrp))
|
|
|
|
{
|
|
|
|
GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist);
|
|
|
|
g_signal_handlers_block_by_func(sel, on_gamelist_selection_changed, NULL);
|
|
|
|
gtk_tree_selection_select_iter(sel, &iter);
|
|
|
|
g_signal_handlers_unblock_by_func(sel, on_gamelist_selection_changed, NULL);
|
|
|
|
}
|
2006-07-07 18:41:05 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 23:25:24 +00:00
|
|
|
static gint name_sorter(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar *as, *bs;
|
|
|
|
gint r;
|
2008-03-22 10:23:57 +00:00
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
2007-08-16 23:25:24 +00:00
|
|
|
gtk_tree_model_get(model, a, 0, &as, -1);
|
|
|
|
gtk_tree_model_get(model, b, 0, &bs, -1);
|
|
|
|
|
|
|
|
r = g_utf8_collate(as,bs);
|
|
|
|
|
|
|
|
g_free(as);
|
|
|
|
g_free(bs);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
static GtkWidget *create_window(void)
|
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
// Basic window
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), apptitle); // NOTE: use global app title
|
|
|
|
gtk_window_set_position(GTK_WINDOW(stwidgets.startwin), GTK_WIN_POS_CENTER);
|
|
|
|
gtk_window_set_resizable(GTK_WINDOW(stwidgets.startwin), FALSE);
|
|
|
|
gtk_window_set_type_hint(GTK_WINDOW(stwidgets.startwin), GDK_WINDOW_TYPE_HINT_DIALOG);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Horizontal layout of banner and controls
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.hlayout = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.startwin), stwidgets.hlayout);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// banner
|
2006-07-07 18:41:05 +00:00
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf = load_banner();
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.banner = gtk_image_new_from_pixbuf(pixbuf);
|
2006-07-07 18:41:05 +00:00
|
|
|
g_object_unref((gpointer)pixbuf);
|
|
|
|
}
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.banner, FALSE, FALSE, 0);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.banner), 0.5, 0);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Vertical layout of tab control and start+cancel buttons
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.vlayout = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.vlayout, TRUE, TRUE, 0);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Tab control
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.tabs = gtk_notebook_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.tabs, TRUE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// layout table of config page
|
2010-01-23 22:12:02 +00:00
|
|
|
stwidgets.configtlayout = gtk_table_new(6, 3, FALSE);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout);
|
|
|
|
|
|
|
|
// 3D video mode LabelText
|
|
|
|
stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
|
2011-01-31 04:13:53 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 0);
|
2011-01-31 04:13:53 +00:00
|
|
|
#else
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 7);
|
|
|
|
#endif
|
2010-01-23 22:12:02 +00:00
|
|
|
|
|
|
|
// 3D video mode combo
|
2006-07-07 18:41:05 +00:00
|
|
|
{
|
|
|
|
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
|
2006-07-07 18:41:05 +00:00
|
|
|
g_object_unref(G_OBJECT(list));
|
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new();
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL);
|
2006-07-07 18:41:05 +00:00
|
|
|
}
|
2011-01-31 18:16:11 +00:00
|
|
|
|
|
|
|
#ifdef POLYMER
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0);
|
|
|
|
#else
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 7);
|
|
|
|
#endif
|
2009-11-14 02:30:47 +00:00
|
|
|
|
|
|
|
// Fullscreen checkbox
|
2010-01-23 22:12:02 +00:00
|
|
|
stwidgets.displayvlayout = gtk_vbox_new(TRUE, 0);
|
2011-01-31 04:13:53 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 0);
|
2011-01-31 04:13:53 +00:00
|
|
|
#else
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 7);
|
|
|
|
#endif
|
|
|
|
|
2010-01-23 22:12:02 +00:00
|
|
|
stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.fullscreencheck, FALSE, FALSE, 0);
|
|
|
|
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
// Polymer checkbox
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.polymercheck = gtk_check_button_new_with_mnemonic("_Polymer");
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.polymercheck, FALSE, FALSE, 0);
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2009-11-14 02:30:47 +00:00
|
|
|
|
2010-01-23 22:12:02 +00:00
|
|
|
// Input devices LabelText
|
2009-11-18 01:17:56 +00:00
|
|
|
stwidgets.inputdevlabel = gtk_label_new_with_mnemonic("_Input devices:");
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.inputdevlabel), 0.3, 0);
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevlabel, 0,1, 1,2, GTK_FILL, 0, 4, 0);
|
|
|
|
|
|
|
|
// Input devices combo
|
|
|
|
{
|
2009-11-18 01:17:56 +00:00
|
|
|
GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING);
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
|
|
|
stwidgets.inputdevcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
|
|
|
|
g_object_unref(G_OBJECT(list));
|
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new();
|
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, "text", 0, NULL);
|
|
|
|
}
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0);
|
|
|
|
|
|
|
|
// Custom mod LabelText
|
2010-06-23 04:20:46 +00:00
|
|
|
stwidgets.custommodlabel = gtk_label_new_with_mnemonic("Custom _game:");
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.custommodlabel), 0.3, 0);
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodlabel, 0,1, 2,3, GTK_FILL, 0, 4, 7);
|
|
|
|
|
|
|
|
// Custom mod combo
|
|
|
|
{
|
2009-11-18 01:17:56 +00:00
|
|
|
GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING);
|
|
|
|
GtkCellRenderer *cell;
|
2009-11-14 02:30:47 +00:00
|
|
|
|
2009-11-18 01:17:56 +00:00
|
|
|
stwidgets.custommodcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
|
|
|
|
g_object_unref(G_OBJECT(list));
|
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new();
|
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, "text", 0, NULL);
|
|
|
|
}
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodcombo, 1,2, 2,3, GTK_EXPAND | GTK_FILL, 0, 4, 7);
|
|
|
|
|
|
|
|
// Empty horizontal layout
|
|
|
|
stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0);
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,3, 3,4, 0, GTK_EXPAND | GTK_FILL, 4, 0);
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// Autoload checkbox
|
2010-01-23 22:12:02 +00:00
|
|
|
stwidgets.autoloadcheck = gtk_check_button_new_with_mnemonic("_Enable \"autoload\" folder");
|
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.autoloadcheck, 0,3, 4,5, GTK_FILL, 0, 2, 2);
|
|
|
|
|
|
|
|
// Always show config checkbox
|
2009-11-18 01:17:56 +00:00
|
|
|
stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show this window at startup");
|
2010-01-23 22:12:02 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,3, 5,6, GTK_FILL, 0, 2, 2);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Configuration tab
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.configtab = gtk_label_new("Configuration");
|
|
|
|
gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 0), stwidgets.configtab);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2007-08-16 23:25:24 +00:00
|
|
|
// Game data layout
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.gamevlayout = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.gamevlayout);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.gamevlayout), 4);
|
2007-08-16 23:25:24 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
// Game data field LabelText
|
2010-06-23 04:20:46 +00:00
|
|
|
stwidgets.gamelabel = gtk_label_new_with_mnemonic("_Game:");
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.gamevlayout), stwidgets.gamelabel, FALSE, FALSE, 0);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.gamelabel), 0, 0.5);
|
2007-08-16 23:25:24 +00:00
|
|
|
|
|
|
|
// Game data scrollable area
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.gamescroll = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.gamevlayout), stwidgets.gamescroll, TRUE, TRUE, 0);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.gamescroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(stwidgets.gamescroll), GTK_SHADOW_IN);
|
2007-08-16 23:25:24 +00:00
|
|
|
|
|
|
|
// Game data list
|
|
|
|
{
|
|
|
|
GtkListStore *list = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list), 0, name_sorter, NULL, NULL);
|
|
|
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list), 0, GTK_SORT_ASCENDING);
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.gamelist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
|
2007-08-16 23:25:24 +00:00
|
|
|
g_object_unref(G_OBJECT(list));
|
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new();
|
|
|
|
col = gtk_tree_view_column_new_with_attributes("Game", cell, "text", 0, NULL);
|
|
|
|
gtk_tree_view_column_set_expand(col, TRUE);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(stwidgets.gamelist), col);
|
2007-08-16 23:25:24 +00:00
|
|
|
col = gtk_tree_view_column_new_with_attributes("GRP file", cell, "text", 1, NULL);
|
|
|
|
gtk_tree_view_column_set_min_width(col, 64);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(stwidgets.gamelist), col);
|
2007-08-16 23:25:24 +00:00
|
|
|
}
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.gamescroll), stwidgets.gamelist);
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(stwidgets.gamelist), FALSE);
|
|
|
|
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(stwidgets.gamelist), FALSE);
|
2007-08-16 23:25:24 +00:00
|
|
|
|
|
|
|
// Game tab
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.gametab = gtk_label_new("Game");
|
|
|
|
gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 1), stwidgets.gametab);
|
2007-08-16 23:25:24 +00:00
|
|
|
|
2006-07-07 18:41:05 +00:00
|
|
|
// Messages scrollable area
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.messagesscroll = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.messagesscroll);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Messages text area
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.messagestext = gtk_text_view_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.messagesscroll), stwidgets.messagestext);
|
|
|
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
|
|
|
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(stwidgets.messagestext), GTK_WRAP_WORD);
|
|
|
|
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
|
|
|
|
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);
|
|
|
|
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Messages tab
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.messagestab = gtk_label_new("Messages");
|
|
|
|
gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 2), stwidgets.messagestab);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Dialogue box buttons layout
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.buttons = gtk_hbutton_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.buttons, FALSE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.buttons), 3);
|
|
|
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(stwidgets.buttons), GTK_BUTTONBOX_END);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Cancel button
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.cancelbutton = gtk_button_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.cancelbutton);
|
|
|
|
GTK_WIDGET_SET_FLAGS(stwidgets.cancelbutton, GTK_CAN_DEFAULT);
|
|
|
|
|
|
|
|
stwidgets.cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbutton), stwidgets.cancelbuttonalign);
|
|
|
|
|
|
|
|
stwidgets.cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbuttonalign), stwidgets.cancelbuttonlayout);
|
|
|
|
|
|
|
|
stwidgets.cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonicon, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
stwidgets.cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonlabel, FALSE, FALSE, 0);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Start button
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startbutton = gtk_button_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.startbutton);
|
|
|
|
GTK_WIDGET_SET_FLAGS(stwidgets.startbutton, GTK_CAN_DEFAULT);
|
|
|
|
|
2010-07-02 01:26:56 +00:00
|
|
|
gtk_window_set_default(GTK_WINDOW(stwidgets.startwin), stwidgets.startbutton);
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.startbutton), stwidgets.startbuttonalign);
|
|
|
|
|
|
|
|
stwidgets.startbuttonlayout = gtk_hbox_new(FALSE, 2);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.startbuttonalign), stwidgets.startbuttonlayout);
|
|
|
|
|
|
|
|
stwidgets.startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonicon, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
stwidgets.startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Wire up the signals
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.startwin, "delete_event",
|
2006-11-14 21:35:50 +00:00
|
|
|
G_CALLBACK(on_startwin_delete_event),
|
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed",
|
2009-11-18 01:17:56 +00:00
|
|
|
G_CALLBACK(on_vmode3dcombo_changed),
|
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled",
|
2006-11-14 21:35:50 +00:00
|
|
|
G_CALLBACK(on_fullscreencheck_toggled),
|
|
|
|
NULL);
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.polymercheck, "toggled",
|
2009-11-14 02:30:47 +00:00
|
|
|
G_CALLBACK(on_polymercheck_toggled),
|
|
|
|
NULL);
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.inputdevcombo, "changed",
|
2009-11-18 01:17:56 +00:00
|
|
|
G_CALLBACK(on_inputdevcombo_changed),
|
2006-11-14 21:35:50 +00:00
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.custommodcombo, "changed",
|
2009-11-18 01:17:56 +00:00
|
|
|
G_CALLBACK(on_custommodcombo_changed),
|
2006-11-14 21:35:50 +00:00
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.autoloadcheck, "toggled",
|
2009-11-18 01:17:56 +00:00
|
|
|
G_CALLBACK(on_autoloadcheck_toggled),
|
2006-11-14 21:35:50 +00:00
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled",
|
2006-11-14 21:35:50 +00:00
|
|
|
G_CALLBACK(on_alwaysshowcheck_toggled),
|
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked",
|
2006-11-14 21:35:50 +00:00
|
|
|
G_CALLBACK(on_cancelbutton_clicked),
|
|
|
|
NULL);
|
2010-01-23 22:12:02 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.startbutton, "clicked",
|
2006-11-14 21:35:50 +00:00
|
|
|
G_CALLBACK(on_startbutton_clicked),
|
|
|
|
NULL);
|
2007-08-16 23:25:24 +00:00
|
|
|
{
|
2009-11-14 02:30:47 +00:00
|
|
|
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(stwidgets.gamelist));
|
2007-08-16 23:25:24 +00:00
|
|
|
gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
|
|
|
|
g_signal_connect((gpointer) sel, "changed",
|
|
|
|
G_CALLBACK(on_gamelist_selection_changed),
|
|
|
|
NULL);
|
|
|
|
}
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
// Associate labels with their controls
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode3dlabel), stwidgets.vmode3dcombo);
|
2009-11-18 01:17:56 +00:00
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.inputdevlabel), stwidgets.inputdevcombo);
|
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.custommodlabel), stwidgets.custommodcombo);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.gamelabel), stwidgets.gamelist);
|
|
|
|
|
|
|
|
return stwidgets.startwin;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
// -- BUILD ENTRY POINTS ------------------------------------------------------
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_open(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (stwidgets.startwin) return 1;
|
2006-07-07 18:41:05 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startwin = create_window();
|
|
|
|
if (stwidgets.startwin)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
SetPage(TAB_MESSAGES);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_show_all(stwidgets.startwin);
|
2006-07-07 18:41:05 +00:00
|
|
|
gtk_main_iteration_do(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_close(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!stwidgets.startwin) return 1;
|
|
|
|
gtk_widget_destroy(stwidgets.startwin);
|
|
|
|
stwidgets.startwin = NULL;
|
2006-07-07 18:41:05 +00:00
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_puts(const char *str)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
GtkWidget *textview;
|
|
|
|
GtkTextBuffer *textbuffer;
|
|
|
|
GtkTextIter enditer;
|
|
|
|
GtkTextMark *mark;
|
|
|
|
const char *aptr, *bptr;
|
|
|
|
|
|
|
|
if (!gtkenabled || !str) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!stwidgets.startwin) return 1;
|
|
|
|
if (!(textview = stwidgets.messagestext)) return -1;
|
2006-07-07 18:41:05 +00:00
|
|
|
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
|
|
|
|
|
|
|
gtk_text_buffer_get_end_iter(textbuffer, &enditer);
|
2006-11-15 01:16:55 +00:00
|
|
|
for (aptr = bptr = str; *aptr != 0;)
|
|
|
|
{
|
|
|
|
switch (*bptr)
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case '\b':
|
|
|
|
if (bptr > aptr)
|
|
|
|
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
|
2006-07-01 01:40:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2006-11-16 03:02:42 +00:00
|
|
|
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
|
2006-07-01 01:40:18 +00:00
|
|
|
#else
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
|
|
|
GtkTextIter iter2 = enditer;
|
|
|
|
gtk_text_iter_backward_cursor_position(&iter2);
|
|
|
|
//FIXME: this seems be deleting one too many chars somewhere!
|
|
|
|
if (!gtk_text_iter_equal(&iter2, &enditer))
|
|
|
|
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
#endif
|
2006-11-16 03:02:42 +00:00
|
|
|
aptr = ++bptr;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
if (bptr > aptr)
|
|
|
|
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
|
|
|
|
aptr = bptr;
|
|
|
|
break;
|
|
|
|
case '\r': // FIXME
|
|
|
|
default:
|
|
|
|
bptr++;
|
|
|
|
break;
|
2006-07-07 18:41:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
|
|
|
|
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
|
|
|
|
gtk_text_buffer_delete_mark(textbuffer, mark);
|
|
|
|
|
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_settitle(const char *title)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2006-07-07 18:41:05 +00:00
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!stwidgets.startwin) return 1;
|
|
|
|
gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), title);
|
2006-07-07 18:41:05 +00:00
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_idle(void *s)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2008-03-22 10:23:57 +00:00
|
|
|
UNREFERENCED_PARAMETER(s);
|
2006-07-07 18:41:05 +00:00
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
//if (!stwidgets.startwin) return 1;
|
2006-11-14 21:35:50 +00:00
|
|
|
gtk_main_iteration_do(FALSE);
|
2006-07-07 18:41:05 +00:00
|
|
|
return 0;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_run(void)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2008-02-18 08:10:54 +00:00
|
|
|
if (!gtkenabled) return 1;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (!stwidgets.startwin) return 1;
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
SetPage(TAB_CONFIG);
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
settings.xdim3d = ud.config.ScreenWidth;
|
|
|
|
settings.ydim3d = ud.config.ScreenHeight;
|
|
|
|
settings.bpp3d = ud.config.ScreenBPP;
|
2009-11-18 01:17:56 +00:00
|
|
|
settings.fullscreen = ud.config.ScreenMode;
|
2007-08-27 00:20:15 +00:00
|
|
|
settings.usemouse = ud.config.UseMouse;
|
|
|
|
settings.usejoy = ud.config.UseJoystick;
|
2010-01-16 23:08:17 +00:00
|
|
|
settings.custommoddir = g_modDir;
|
2009-11-18 01:17:56 +00:00
|
|
|
settings.forcesetup = ud.config.ForceSetup;
|
2008-11-20 14:06:36 +00:00
|
|
|
settings.game = g_gameType;
|
2010-01-16 23:08:17 +00:00
|
|
|
Bstrncpy(settings.selectedgrp, g_grpNamePtr, BMAX_PATH);
|
2009-11-14 02:30:47 +00:00
|
|
|
if (ud.config.NoAutoLoad) settings.autoload = FALSE;
|
|
|
|
else settings.autoload = TRUE;
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2009-11-18 01:17:56 +00:00
|
|
|
if (glrendmode == RDR_POLYMER)
|
2009-11-14 02:30:47 +00:00
|
|
|
{
|
2010-01-23 22:12:02 +00:00
|
|
|
if (settings.bpp3d == 8) settings.bpp3d = 32;
|
|
|
|
settings.polymer = TRUE;
|
2009-11-14 02:30:47 +00:00
|
|
|
}
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2009-11-18 01:17:56 +00:00
|
|
|
PopulateForm(ALL);
|
2006-07-07 18:41:05 +00:00
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
|
|
|
|
SetPage(TAB_MESSAGES);
|
2009-11-14 02:30:47 +00:00
|
|
|
if (retval) // launch the game with these parameters
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.ScreenWidth = settings.xdim3d;
|
|
|
|
ud.config.ScreenHeight = settings.ydim3d;
|
|
|
|
ud.config.ScreenBPP = settings.bpp3d;
|
2009-11-18 01:17:56 +00:00
|
|
|
ud.config.ScreenMode = settings.fullscreen;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.UseMouse = settings.usemouse;
|
|
|
|
ud.config.UseJoystick = settings.usejoy;
|
2009-11-18 01:17:56 +00:00
|
|
|
ud.config.ForceSetup = settings.forcesetup;
|
2010-01-16 23:08:17 +00:00
|
|
|
g_grpNamePtr = settings.selectedgrp;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_gameType = settings.game;
|
2009-11-18 01:17:56 +00:00
|
|
|
if (settings.custommoddir != NULL)
|
2010-01-16 23:08:17 +00:00
|
|
|
Bstrcpy(g_modDir, settings.custommoddir);
|
|
|
|
else Bsprintf(g_modDir, "/");
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
if (settings.autoload) ud.config.NoAutoLoad = FALSE;
|
|
|
|
else ud.config.NoAutoLoad = TRUE;
|
2008-07-22 09:05:34 +00:00
|
|
|
|
|
|
|
for (i = 0; i<numgrpfiles; i++) if (settings.crcval == grpfiles[i].crcval) break;
|
|
|
|
if (i != numgrpfiles)
|
2010-01-16 23:08:17 +00:00
|
|
|
g_gameNamePtr = (char *)grpfiles[i].name;
|
2006-07-07 18:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|