2014-11-28 23:47:46 +00:00
|
|
|
|
|
|
|
#include "gtkpixdata.h"
|
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
#include "dynamicgtk.h"
|
2009-11-14 02:30:47 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "editor.h"
|
2010-06-23 04:20:46 +00:00
|
|
|
#include "baselayer.h"
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TAB_CONFIG,
|
|
|
|
TAB_MESSAGES,
|
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
|
|
|
|
{
|
|
|
|
GtkWidget *startwin;
|
|
|
|
GtkWidget *hlayout;
|
|
|
|
GtkWidget *banner;
|
|
|
|
GtkWidget *vlayout;
|
|
|
|
GtkWidget *tabs;
|
|
|
|
GtkWidget *configtlayout;
|
|
|
|
GtkWidget *vmode2dlabel;
|
|
|
|
GtkWidget *vmode3dlabel;
|
|
|
|
GtkWidget *vmode2dcombo;
|
|
|
|
GtkWidget *vmode3dcombo;
|
|
|
|
GtkWidget *fullscreencheck;
|
|
|
|
GtkWidget *emptyhlayout;
|
|
|
|
GtkWidget *alwaysshowcheck;
|
|
|
|
GtkWidget *configtab;
|
|
|
|
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;
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
} stwidgets;
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
static struct
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t fullscreen;
|
|
|
|
int32_t xdim2d, ydim2d;
|
|
|
|
int32_t xdim3d, ydim3d, bpp3d;
|
|
|
|
int32_t forcesetup;
|
2006-07-01 01:40:18 +00:00
|
|
|
} settings;
|
|
|
|
|
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-14 02:30:47 +00:00
|
|
|
static void PopulateForm(void);
|
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_vmode2dcombo_changed(GtkComboBox *combobox, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
int32_t val;
|
|
|
|
UNREFERENCED_PARAMETER(user_data);
|
|
|
|
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.xdim2d = validmode[val].xdim;
|
|
|
|
settings.ydim2d = validmode[val].ydim;
|
|
|
|
}
|
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);
|
|
|
|
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;
|
|
|
|
settings.bpp3d = validmode[val].bpp;
|
|
|
|
}
|
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) == TRUE);
|
|
|
|
PopulateForm();
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
|
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) == TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 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)
|
|
|
|
{
|
2016-01-12 10:30:48 +00:00
|
|
|
return gdk_pixbuf_from_pixdata((GdkPixdata const *)&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-11-13 23:12:47 +00:00
|
|
|
mode = n;
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(stwidgets.tabs), n);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
// each control in the config page vertical layout plus the start button should be made (in)sensitive
|
|
|
|
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),
|
2011-01-16 02:50:27 +00:00
|
|
|
(GtkCallback)gtk_widget_set_sensitive,
|
|
|
|
(gpointer)&n);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PopulateForm(void)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t mode2d, mode3d, i;
|
2006-07-01 01:40:18 +00:00
|
|
|
GtkListStore *modes2d, *modes3d;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkComboBox *box2d, *box3d;
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
|
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
|
|
|
|
if (mode2d < 0) mode2d = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (mode3d < 0)
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 };
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
|
|
|
|
for (; cd[i]; i++)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
|
|
|
|
if (mode3d < 0) continue;
|
|
|
|
settings.bpp3d = cd[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
box2d = GTK_COMBO_BOX(stwidgets.vmode2dcombo);
|
|
|
|
box3d = GTK_COMBO_BOX(stwidgets.vmode3dcombo);
|
2006-07-01 01:40:18 +00:00
|
|
|
modes2d = GTK_LIST_STORE(gtk_combo_box_get_model(box2d));
|
|
|
|
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
|
|
|
|
gtk_list_store_clear(modes2d);
|
|
|
|
gtk_list_store_clear(modes3d);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=0; i<validmodecnt; i++)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
if (validmode[i].fs != settings.fullscreen) continue;
|
|
|
|
|
|
|
|
// 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);
|
2006-07-01 01:40:18 +00:00
|
|
|
gtk_list_store_append(modes3d, &iter);
|
|
|
|
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i == mode3d)
|
|
|
|
{
|
2012-11-15 14:27:57 +00:00
|
|
|
g_signal_handlers_block_by_func(box3d, (gpointer)on_vmode3dcombo_changed, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
gtk_combo_box_set_active_iter(box3d, &iter);
|
2012-11-15 14:27:57 +00:00
|
|
|
g_signal_handlers_unblock_by_func(box3d, (gpointer)on_vmode3dcombo_changed, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// only 8-bit modes get used for 2D
|
2008-01-28 01:13:10 +00:00
|
|
|
if (validmode[i].bpp != 8 || validmode[i].xdim < 640 || validmode[i].ydim < 480) continue;
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf, "%d x %d", validmode[i].xdim, validmode[i].ydim);
|
2006-07-01 01:40:18 +00:00
|
|
|
gtk_list_store_append(modes2d, &iter);
|
|
|
|
gtk_list_store_set(modes2d, &iter, 0,buf, 1,i, -1);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i == mode2d)
|
|
|
|
{
|
2012-11-15 14:27:57 +00:00
|
|
|
g_signal_handlers_block_by_func(box2d, (gpointer)on_vmode2dcombo_changed, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
gtk_combo_box_set_active_iter(box2d, &iter);
|
2012-11-15 14:27:57 +00:00
|
|
|
g_signal_handlers_unblock_by_func(box2d, (gpointer)on_vmode2dcombo_changed, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *create_window(void)
|
|
|
|
{
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.accel_group = gtk_accel_group_new();
|
2006-07-01 01:40:18 +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-01 01:40:18 +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-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// banner
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf = load_banner();
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.banner = gtk_image_new_from_pixbuf(pixbuf);
|
2006-07-01 01:40:18 +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-01 01:40:18 +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-01 01:40:18 +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);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// layout table of config page
|
2011-01-16 02:50:27 +00:00
|
|
|
stwidgets.configtlayout = gtk_table_new(4, 3, FALSE);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// 2D video mode label
|
|
|
|
stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:");
|
2011-01-16 02:50:27 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode2dlabel), 0.3, 0);
|
2012-11-15 14:27:57 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dlabel, 0,1, 0,1, GTK_FILL, (GtkAttachOptions)0, 4, 6);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
// 2D video mode combo
|
|
|
|
{
|
|
|
|
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.vmode2dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
|
2006-07-01 01:40:18 +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.vmode2dcombo), cell, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, "text", 0, NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
2016-06-05 04:46:28 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dcombo, 1,2, 0,1,
|
2012-11-15 14:27:57 +00:00
|
|
|
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 6);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.vmode2dcombo, "grab_focus", stwidgets.accel_group,
|
2007-12-12 17:42:14 +00:00
|
|
|
GDK_2, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
|
|
|
// Fullscreen checkbox
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
|
2012-11-15 14:27:57 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.fullscreencheck, 2,3, 0,1, GTK_FILL, (GtkAttachOptions)0, 4, 6);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.fullscreencheck, "grab_focus", stwidgets.accel_group,
|
|
|
|
GDK_F, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
// 3D video mode label
|
|
|
|
stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:");
|
2011-01-16 02:50:27 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
|
2012-11-15 14:27:57 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 1,2, GTK_FILL, (GtkAttachOptions)0, 4, 6);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
// 3D video mode combo
|
|
|
|
{
|
|
|
|
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-01 01:40:18 +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-01 01:40:18 +00:00
|
|
|
}
|
2016-06-05 04:46:28 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 1,2,
|
2012-11-15 14:27:57 +00:00
|
|
|
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.vmode3dcombo, "grab_focus", stwidgets.accel_group,
|
2007-12-12 17:42:14 +00:00
|
|
|
GDK_3, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2011-01-16 02:50:27 +00:00
|
|
|
// Empty horizontal layout
|
|
|
|
stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0);
|
2016-06-05 04:46:28 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,1, 2,3, (GtkAttachOptions)0,
|
2012-11-15 14:27:57 +00:00
|
|
|
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
// Always show config checkbox
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
|
2012-11-15 14:27:57 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,2, 3,4, GTK_FILL, (GtkAttachOptions)0, 4, 6);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.alwaysshowcheck, "grab_focus", stwidgets.accel_group,
|
2007-12-12 17:42:14 +00:00
|
|
|
GDK_A, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2006-07-01 01:40:18 +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-01 01:40:18 +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-01 01:40:18 +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-01 01:40:18 +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), 1), stwidgets.messagestab);
|
2006-07-01 01:40:18 +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-01 01:40:18 +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);
|
|
|
|
gtk_widget_add_accelerator(stwidgets.cancelbutton, "grab_focus", stwidgets.accel_group,
|
2007-12-12 17:42:14 +00:00
|
|
|
GDK_C, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.cancelbutton, "clicked", stwidgets.accel_group,
|
2012-11-15 14:27:57 +00:00
|
|
|
GDK_Escape, (GdkModifierType)0,
|
2007-12-12 17:42:14 +00:00
|
|
|
GTK_ACCEL_VISIBLE);
|
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbutton), stwidgets.cancelbuttonalign);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbuttonalign), stwidgets.cancelbuttonlayout);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
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);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonlabel, FALSE, FALSE, 0);
|
2006-07-01 01:40:18 +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);
|
|
|
|
gtk_widget_add_accelerator(stwidgets.startbutton, "grab_focus", stwidgets.accel_group,
|
2007-12-12 17:42:14 +00:00
|
|
|
GDK_S, GDK_MOD1_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_add_accelerator(stwidgets.startbutton, "clicked", stwidgets.accel_group,
|
2012-11-15 14:27:57 +00:00
|
|
|
GDK_Return, (GdkModifierType)0,
|
2007-12-12 17:42:14 +00:00
|
|
|
GTK_ACCEL_VISIBLE);
|
|
|
|
|
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);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startbuttonlayout = gtk_hbox_new(FALSE, 2);
|
|
|
|
gtk_container_add(GTK_CONTAINER(stwidgets.startbuttonalign), stwidgets.startbuttonlayout);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
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);
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
|
|
|
|
gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
// Wire up the signals
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.startwin, "delete_event",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_startwin_delete_event),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.vmode2dcombo, "changed",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_vmode2dcombo_changed),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_vmode3dcombo_changed),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_fullscreencheck_toggled),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_alwaysshowcheck_toggled),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_cancelbutton_clicked),
|
|
|
|
NULL);
|
2009-11-14 02:30:47 +00:00
|
|
|
g_signal_connect((gpointer) stwidgets.startbutton, "clicked",
|
2007-12-12 17:42:14 +00:00
|
|
|
G_CALLBACK(on_startbutton_clicked),
|
|
|
|
NULL);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
// Associate labels with their controls
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode2dlabel), stwidgets.vmode2dcombo);
|
|
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode3dlabel), stwidgets.vmode3dcombo);
|
|
|
|
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(stwidgets.startwin), stwidgets.accel_group);
|
|
|
|
|
|
|
|
return stwidgets.startwin;
|
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
|
|
|
{
|
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
if (stwidgets.startwin) return 1;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2009-11-14 02:30:47 +00:00
|
|
|
stwidgets.startwin = create_window();
|
|
|
|
if (stwidgets.startwin)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
SetPage(TAB_MESSAGES);
|
2009-11-14 02:30:47 +00:00
|
|
|
gtk_widget_show_all(stwidgets.startwin);
|
2006-07-01 01:40:18 +00:00
|
|
|
gtk_main_iteration_do(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_close(void)
|
2006-07-01 01:40:18 +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-01 01:40:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_puts(const char *str)
|
2006-07-01 01:40:18 +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-01 01:40:18 +00:00
|
|
|
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
|
|
|
|
|
|
|
|
gtk_text_buffer_get_end_iter(textbuffer, &enditer);
|
2007-12-12 17:42:14 +00:00
|
|
|
for (aptr = bptr = str; *aptr != 0;)
|
|
|
|
{
|
|
|
|
switch (*bptr)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
case '\b':
|
|
|
|
if (bptr > aptr)
|
|
|
|
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
|
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
|
|
|
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_settitle(const char *title)
|
2006-07-01 01:40:18 +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-01 01:40:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t startwin_idle(void *s)
|
2006-07-01 01:40:18 +00:00
|
|
|
{
|
2008-03-23 00:06:42 +00:00
|
|
|
UNREFERENCED_PARAMETER(s);
|
2006-07-01 01:40:18 +00:00
|
|
|
if (!gtkenabled) return 0;
|
2009-11-14 02:30:47 +00:00
|
|
|
//if (!stwidgets.startwin) return 1;
|
2007-12-12 17:42:14 +00:00
|
|
|
gtk_main_iteration_do(FALSE);
|
2006-07-01 01:40:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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-01 01:40:18 +00:00
|
|
|
|
|
|
|
SetPage(TAB_CONFIG);
|
|
|
|
|
|
|
|
settings.fullscreen = fullscreen;
|
|
|
|
settings.xdim2d = xdim2d;
|
|
|
|
settings.ydim2d = ydim2d;
|
|
|
|
settings.xdim3d = xdimgame;
|
|
|
|
settings.ydim3d = ydimgame;
|
|
|
|
settings.bpp3d = bppgame;
|
|
|
|
settings.forcesetup = forcesetup;
|
|
|
|
PopulateForm();
|
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
|
|
|
|
SetPage(TAB_MESSAGES);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (retval)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
fullscreen = settings.fullscreen;
|
|
|
|
xdim2d = settings.xdim2d;
|
|
|
|
ydim2d = settings.ydim2d;
|
|
|
|
xdimgame = settings.xdim3d;
|
|
|
|
ydimgame = settings.ydim3d;
|
|
|
|
bppgame = settings.bpp3d;
|
|
|
|
forcesetup = settings.forcesetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|