diff --git a/polymer/build/Makefile b/polymer/build/Makefile index e144eb912..a2dcce32e 100644 --- a/polymer/build/Makefile +++ b/polymer/build/Makefile @@ -137,7 +137,7 @@ ifeq ($(RENDERTYPE),SDL) ifeq (1,$(HAVE_GTK2)) OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0) - ENGINEOBJS+= $(OBJ)gtkbits.$o + ENGINEOBJS+= $(OBJ)gtkbits.$o $(OBJ)dynamicgtk.$o EDITOROBJS+= $(OBJ)startgtk.editor.$o GAMEEXEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o EDITOREXEOBJS+= $(OBJ)editor_banner.$o diff --git a/polymer/build/Makefile.deps b/polymer/build/Makefile.deps index 75cf6eeb7..42c008ac9 100644 --- a/polymer/build/Makefile.deps +++ b/polymer/build/Makefile.deps @@ -27,7 +27,8 @@ $(OBJ)scriptfile.$o: $(SRC)scriptfile.c $(INC)scriptfile.h $(INC)cache1d.h $(INC $(OBJ)sdlayer.$o: $(SRC)sdlayer.c $(INC)compat.h $(INC)sdlayer.h $(INC)baselayer.h $(INC)cache1d.h $(INC)pragmas.h $(INC)a.h $(INC)build.h $(INC)osd.h $(INC)glbuild.h $(OBJ)sound.$o: $(SRC)sound.c $(INC)osd.h $(INC)compat.h $(INC)cache1d.h $(OBJ)winlayer.$o: $(SRC)winlayer.c $(INC)compat.h $(INC)winlayer.h $(INC)baselayer.h $(INC)pragmas.h $(INC)build.h $(INC)a.h $(INC)osd.h $(INC)dxdidf.h $(INC)glbuild.h -$(OBJ)gtkbits.$o: $(SRC)gtkbits.c $(INC)baselayer.h $(INC)build.h +$(OBJ)gtkbits.$o: $(SRC)gtkbits.c $(INC)baselayer.h $(INC)build.h $(INC)dynamicgtk.h +$(OBJ)dynamicgtk.$o: $(SRC)dynamicgtk.c $(INC)dynamicgtk.h $(OBJ)gameres.$(res): $(SRC)misc/gameres.rc $(SRC)startwin.game.h $(OBJ)buildres.$(res): $(SRC)misc/buildres.rc $(INC)startwin.editor.h diff --git a/polymer/build/Makefile.shared b/polymer/build/Makefile.shared index 3312fff0a..21391db12 100644 --- a/polymer/build/Makefile.shared +++ b/polymer/build/Makefile.shared @@ -52,7 +52,10 @@ ifeq ($(PLATFORM),LINUX) # on my 64bit Gentoo these are the 32bit emulation libs LIBS+= -m32 -L/emul/linux/x86/usr/lib BUILDCFLAGS+= -m32 - override WITHOUT_GTK=1 + #override WITHOUT_GTK=0 + GTKCOMPAT32=1 + else + GTKCOMPAT32=0 endif endif ifeq ($(PLATFORM),WINDOWS) @@ -108,7 +111,14 @@ ifeq ($(RENDERTYPE),SDL) else ifneq (No,$(shell pkg-config --exists gtk+-2.0 || echo No)) HAVE_GTK2=1 - LIBS+= $(shell pkg-config --libs gtk+-2.0) + # on my 64bit Gentoo box I have Cairo enabled which means the libs list includes + # -lpangocairo-1.0 and -lcairo, however the 32bit compatibility libraries don't + # include cairo, so we need to filter out those -l switches in order to link + ifeq ($(GTKCOMPAT32),1) + # LIBS+= $(shell pkg-config --libs gtk+-2.0 | sed 's/\s-l\(pango\)\{0,1\}cairo\S*\s/ /g') + else + # LIBS+= $(shell pkg-config --libs gtk+-2.0) + endif else HAVE_GTK2=0 endif diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index efd90267d..7d6fc1270 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -307,7 +307,7 @@ int app_main(int argc, char **argv) if ((i = ExtInit()) < 0) return -1; #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) if (i || forcesetup || cmdsetup) { - if (!startwin_run()) return -1; + if (quitevent || !startwin_run()) return -1; } #endif diff --git a/polymer/build/src/config.c b/polymer/build/src/config.c index b8a38de19..86fd055b4 100644 --- a/polymer/build/src/config.c +++ b/polymer/build/src/config.c @@ -140,7 +140,7 @@ if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); if (Batoi(val) != 0) glusetexcachecompression = 1; else glusetexcachecompression = 0; } - if(glusetexcache == -1 && glusetexcachecompression == -1) + if(glusetexcache == -1 || glusetexcachecompression == -1) { i=wm_ynbox("Texture caching", "Would you like to enable the on-disk texture cache? " diff --git a/polymer/build/src/dynamicgtk.c b/polymer/build/src/dynamicgtk.c new file mode 100755 index 000000000..6784fca4e --- /dev/null +++ b/polymer/build/src/dynamicgtk.c @@ -0,0 +1,146 @@ +#include +#include +#include + +#define __dynamicgtkfoo__ +#include "dynamicgtk.h" + +static void *handle = NULL; +struct _dynamicgtksyms dynamicgtksyms; + +#define GETDLSYM(x) { \ + dynamicgtksyms.x = dlsym(handle, (failsym = (const char *)#x)); \ + if (!dynamicgtksyms.x ) { err = 1; break; } \ +} + +int dynamicgtk_init(void) +{ + int err = 0; + const char *failsym = NULL; + + if (handle) return 1; + + handle = dlopen("libgtk-x11-2.0.so", RTLD_NOW|RTLD_GLOBAL); + if (!handle) return 0; + + memset(&dynamicgtksyms, 0, sizeof(dynamicgtksyms)); + + do { + GETDLSYM(g_object_get_data) + GETDLSYM(g_object_set_data) + GETDLSYM(g_object_set_data_full) + GETDLSYM(g_object_unref) + GETDLSYM(g_signal_connect_data) + GETDLSYM(g_signal_handlers_block_matched) + GETDLSYM(g_signal_handlers_unblock_matched) + GETDLSYM(g_type_check_instance_cast) + GETDLSYM(gdk_pixbuf_from_pixdata) + GETDLSYM(gdk_pixbuf_new_from_data) + GETDLSYM(gtk_accel_group_new) + GETDLSYM(gtk_alignment_new) + GETDLSYM(gtk_box_get_type) + GETDLSYM(gtk_box_pack_start) + GETDLSYM(gtk_button_box_get_type) + GETDLSYM(gtk_button_box_set_layout) + GETDLSYM(gtk_button_new) + GETDLSYM(gtk_cell_layout_get_type) + GETDLSYM(gtk_cell_layout_pack_start) + GETDLSYM(gtk_cell_layout_set_attributes) + GETDLSYM(gtk_cell_renderer_text_new) + GETDLSYM(gtk_check_button_new_with_mnemonic) + GETDLSYM(gtk_combo_box_get_active_iter) + GETDLSYM(gtk_combo_box_get_model) + GETDLSYM(gtk_combo_box_get_type) + GETDLSYM(gtk_combo_box_new_text) + GETDLSYM(gtk_combo_box_new_with_model) + GETDLSYM(gtk_combo_box_set_active_iter) + GETDLSYM(gtk_container_add) + GETDLSYM(gtk_container_foreach) + GETDLSYM(gtk_container_get_type) + GETDLSYM(gtk_container_set_border_width) + GETDLSYM(gtk_dialog_get_type) + GETDLSYM(gtk_dialog_run) + GETDLSYM(gtk_fixed_get_type) + GETDLSYM(gtk_fixed_new) + GETDLSYM(gtk_fixed_put) + GETDLSYM(gtk_hbox_new) + GETDLSYM(gtk_hbutton_box_new) + GETDLSYM(gtk_image_new_from_pixbuf) + GETDLSYM(gtk_image_new_from_stock) + GETDLSYM(gtk_init_check) + GETDLSYM(gtk_label_get_type) + GETDLSYM(gtk_label_new) + GETDLSYM(gtk_label_new_with_mnemonic) + GETDLSYM(gtk_label_set_mnemonic_widget) + GETDLSYM(gtk_list_store_append) + GETDLSYM(gtk_list_store_clear) + GETDLSYM(gtk_list_store_get_type) + GETDLSYM(gtk_list_store_new) + GETDLSYM(gtk_list_store_set) + GETDLSYM(gtk_main) + GETDLSYM(gtk_main_iteration_do) + GETDLSYM(gtk_main_quit) + GETDLSYM(gtk_message_dialog_new) + GETDLSYM(gtk_misc_get_type) + GETDLSYM(gtk_misc_set_alignment) + GETDLSYM(gtk_notebook_get_nth_page) + GETDLSYM(gtk_notebook_get_type) + GETDLSYM(gtk_notebook_new) + GETDLSYM(gtk_notebook_set_current_page) + GETDLSYM(gtk_notebook_set_tab_label) + GETDLSYM(gtk_object_get_type) + GETDLSYM(gtk_scrolled_window_get_type) + GETDLSYM(gtk_scrolled_window_new) + GETDLSYM(gtk_scrolled_window_set_policy) + GETDLSYM(gtk_text_buffer_backspace) + GETDLSYM(gtk_text_buffer_create_mark) + GETDLSYM(gtk_text_buffer_delete_mark) + GETDLSYM(gtk_text_buffer_get_end_iter) + GETDLSYM(gtk_text_buffer_insert) + GETDLSYM(gtk_text_view_get_buffer) + GETDLSYM(gtk_text_view_get_type) + GETDLSYM(gtk_text_view_new) + GETDLSYM(gtk_text_view_scroll_to_mark) + GETDLSYM(gtk_text_view_set_cursor_visible) + GETDLSYM(gtk_text_view_set_editable) + GETDLSYM(gtk_text_view_set_left_margin) + GETDLSYM(gtk_text_view_set_right_margin) + GETDLSYM(gtk_text_view_set_wrap_mode) + GETDLSYM(gtk_toggle_button_get_active) + GETDLSYM(gtk_toggle_button_get_type) + GETDLSYM(gtk_toggle_button_set_active) + GETDLSYM(gtk_tree_model_get) + GETDLSYM(gtk_tree_model_get_type) + GETDLSYM(gtk_vbox_new) + GETDLSYM(gtk_widget_add_accelerator) + GETDLSYM(gtk_widget_destroy) + GETDLSYM(gtk_widget_ref) + GETDLSYM(gtk_widget_set_sensitive) + GETDLSYM(gtk_widget_set_size_request) + GETDLSYM(gtk_widget_show) + GETDLSYM(gtk_widget_unref) + GETDLSYM(gtk_window_add_accel_group) + GETDLSYM(gtk_window_get_type) + GETDLSYM(gtk_window_new) + GETDLSYM(gtk_window_set_default_icon) + GETDLSYM(gtk_window_set_position) + GETDLSYM(gtk_window_set_resizable) + GETDLSYM(gtk_window_set_title) + GETDLSYM(gtk_window_set_type_hint) + } while (0); + + if (err) { + //printf("Failed fetching symbol %s from GTK lib\n", failsym); + dlclose(handle); + handle = NULL; + return -1; + } + return 0; +} + +void dynamicgtk_uninit(void) +{ + if (handle) dlclose(handle); + handle = NULL; + memset(&dynamicgtksyms, 0, sizeof(dynamicgtksyms)); +} diff --git a/polymer/build/src/game.c b/polymer/build/src/game.c index bca758180..531274157 100644 --- a/polymer/build/src/game.c +++ b/polymer/build/src/game.c @@ -434,7 +434,7 @@ long app_main(long argc, char *argv[]) #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) if (i || forcesetup || cmdsetup) { - if (!startwin_run()) return -1; + if (quitevent || !startwin_run()) return -1; } #endif writesetup("game.cfg"); diff --git a/polymer/build/src/gtkbits.c b/polymer/build/src/gtkbits.c index 810dbcef2..83d246bca 100644 --- a/polymer/build/src/gtkbits.c +++ b/polymer/build/src/gtkbits.c @@ -13,6 +13,10 @@ #include "baselayer.h" #include "build.h" +#ifndef LINKED_GTK +# include "dynamicgtk.h" +#endif + int gtkenabled = 0; static GdkPixbuf *appicon = NULL; @@ -61,6 +65,13 @@ extern struct sdlappicon sdlappicon; #endif void gtkbuild_init(int *argc, char ***argv) { +#ifndef LINKED_GTK + gtkenabled = dynamicgtk_init(); + if (gtkenabled < 0) { + gtkenabled = 0; + return; + } +#endif gtkenabled = gtk_init_check(argc, argv); if (!gtkenabled) return; #ifdef RENDERTYPESDL @@ -73,7 +84,10 @@ void gtkbuild_init(int *argc, char ***argv) void gtkbuild_exit(int r) { - if (!gtkenabled) return; - if (appicon) g_object_unref((gpointer)appicon); - //gtk_exit(r); + if (gtkenabled) { + if (appicon) g_object_unref((gpointer)appicon); + } +#ifndef LINKED_GTK + dynamicgtk_uninit(); +#endif } diff --git a/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade b/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade index ce1187f4d..79da5c0ae 100755 --- a/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade +++ b/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade @@ -295,6 +295,7 @@ True + @@ -367,6 +368,7 @@ True + diff --git a/polymer/build/src/startgtk.editor.c b/polymer/build/src/startgtk.editor.c index 2cddd44a8..cfa5575ef 100755 --- a/polymer/build/src/startgtk.editor.c +++ b/polymer/build/src/startgtk.editor.c @@ -15,6 +15,10 @@ #include #include +#ifndef LINKED_GTK +# include "dynamicgtk.h" +#endif + #include "baselayer.h" #include "compat.h" #include "build.h" @@ -33,7 +37,7 @@ static struct { extern int gtkenabled; static GtkWidget *startwin = NULL; -static int retval = -1, mode = 0; +static int retval = -1, mode = TAB_MESSAGES; // -- SUPPORT FUNCTIONS ------------------------------------------------------- @@ -56,17 +60,14 @@ static GdkPixbuf *load_banner(void) static void SetPage(int n) { if (!gtkenabled || !startwin) return; + mode = n; gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); -} -static void EnableConfig(int n) -{ - // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive - mode = n; - gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + // 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; + gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); } static void on_vmode2dcombo_changed(GtkComboBox *, gpointer); @@ -168,8 +169,8 @@ static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer u static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) { - retval = 0; - gtk_main_quit(); + if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } + else quitevent++; } static void on_startbutton_clicked(GtkButton *button, gpointer user_data) @@ -180,7 +181,8 @@ static void on_startbutton_clicked(GtkButton *button, gpointer user_data) static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { - //quitevent++; + 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 } @@ -373,6 +375,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group, GDK_C, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group, + GDK_Escape, 0, + GTK_ACCEL_VISIBLE); cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (cancelbuttonalign); @@ -398,6 +403,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group, GDK_S, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (startbutton, "clicked", accel_group, + GDK_Return, 0, + GTK_ACCEL_VISIBLE); startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (startbuttonalign); @@ -487,7 +495,6 @@ int startwin_open(void) startwin = create_window(); if (startwin) { SetPage(TAB_MESSAGES); - EnableConfig(FALSE); gtk_widget_show(startwin); gtk_main_iteration_do(FALSE); return 0; @@ -577,7 +584,6 @@ int startwin_run(void) if (!startwin) return 1; SetPage(TAB_CONFIG); - EnableConfig(TRUE); settings.fullscreen = fullscreen; settings.xdim2d = xdim2d; @@ -591,7 +597,6 @@ int startwin_run(void) gtk_main(); SetPage(TAB_MESSAGES); - EnableConfig(FALSE); if (retval) { fullscreen = settings.fullscreen; xdim2d = settings.xdim2d; diff --git a/polymer/build/src/startgtk.game.c b/polymer/build/src/startgtk.game.c index 4a4e1d222..c173f0c4f 100755 --- a/polymer/build/src/startgtk.game.c +++ b/polymer/build/src/startgtk.game.c @@ -15,6 +15,10 @@ #include #include +#ifndef LINKED_GTK +# include "dynamicgtk.h" +#endif + #include "baselayer.h" #include "compat.h" #include "build.h" @@ -31,7 +35,7 @@ static struct { extern int gtkenabled; static GtkWidget *startwin = NULL; -static int retval = -1, mode = 0; +static int retval = -1, mode = TAB_MESSAGES; // -- SUPPORT FUNCTIONS ------------------------------------------------------- @@ -54,17 +58,14 @@ static GdkPixbuf *load_banner(void) static void SetPage(int n) { if (!gtkenabled || !startwin) return; + mode = n; gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); -} -static void EnableConfig(int n) -{ - // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive - mode = n; - gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + // 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; + gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); } static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); @@ -137,8 +138,8 @@ static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer u static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) { - retval = 0; - gtk_main_quit(); + if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } + else quitevent++; } static void on_startbutton_clicked(GtkButton *button, gpointer user_data) @@ -149,7 +150,8 @@ static void on_startbutton_clicked(GtkButton *button, gpointer user_data) static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { - //quitevent++; + 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 } @@ -314,6 +316,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group, GDK_C, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group, + GDK_Escape, 0, + GTK_ACCEL_VISIBLE); cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (cancelbuttonalign); @@ -339,6 +344,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group, GDK_S, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (startbutton, "clicked", accel_group, + GDK_Return, 0, + GTK_ACCEL_VISIBLE); startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (startbuttonalign); @@ -422,7 +430,6 @@ int startwin_open(void) startwin = create_window(); if (startwin) { SetPage(TAB_MESSAGES); - EnableConfig(FALSE); gtk_widget_show(startwin); gtk_main_iteration_do(FALSE); return 0; @@ -514,7 +521,6 @@ int startwin_run(void) if (!startwin) return 1; SetPage(TAB_CONFIG); - EnableConfig(TRUE); settings.fullscreen = fullscreen; settings.xdim3d = xdimgame; @@ -526,7 +532,6 @@ int startwin_run(void) gtk_main(); SetPage(TAB_MESSAGES); - EnableConfig(FALSE); if (retval) { fullscreen = settings.fullscreen; xdimgame = settings.xdim3d; diff --git a/polymer/build/src/startwin.editor.c b/polymer/build/src/startwin.editor.c index 04fdfd319..2122a08e9 100755 --- a/polymer/build/src/startwin.editor.c +++ b/polymer/build/src/startwin.editor.c @@ -28,7 +28,7 @@ static struct { static HWND startupdlg = NULL; static HWND pages[2] = { NULL, NULL}; -static int done = -1; +static int done = -1, mode = TAB_CONFIG; static void PopulateForm(void) { @@ -131,13 +131,14 @@ static void SetPage(int n) ShowWindow(pages[cur],SW_HIDE); SendMessage(tab, TCM_SETCURSEL, n, 0); ShowWindow(pages[n],SW_SHOW); + mode = n; SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); } static void EnableConfig(int n) { - EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); + //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE), n); @@ -271,7 +272,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, } case WM_CLOSE: - done = 0; + if (mode == TAB_CONFIG) done = 0; + else quitevent++; return TRUE; case WM_DESTROY: @@ -290,7 +292,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { - case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_CANCEL: + if (mode == TAB_CONFIG) done = 0; + else quitevent++; + return TRUE; case WIN_STARTWIN_START: done = 1; return TRUE; } return FALSE; diff --git a/polymer/build/src/startwin.game.c b/polymer/build/src/startwin.game.c index a9e7df3dd..b8b2d200f 100755 --- a/polymer/build/src/startwin.game.c +++ b/polymer/build/src/startwin.game.c @@ -26,7 +26,7 @@ static struct { static HWND startupdlg = NULL; static HWND pages[2] = { NULL, NULL}; -static int done = -1; +static int done = -1, mode = TAB_CONFIG; static void PopulateForm(void) { @@ -107,13 +107,14 @@ static void SetPage(int n) ShowWindow(pages[cur],SW_HIDE); SendMessage(tab, TCM_SETCURSEL, n, 0); ShowWindow(pages[n],SW_SHOW); + mode = n; SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); } static void EnableConfig(int n) { - EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); + //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE), n); @@ -246,7 +247,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, } case WM_CLOSE: - done = 0; + if (mode == TAB_CONFIG) done = 0; + else quitevent++; return TRUE; case WM_DESTROY: @@ -265,7 +267,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { - case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_CANCEL: + if (mode == TAB_CONFIG) done = 0; + else quitevent++; + return TRUE; case WIN_STARTWIN_START: done = 1; return TRUE; } return FALSE; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 9b1ed1a6d..e8a3030ea 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -623,7 +623,7 @@ int32 CONFIG_ReadSetup( void ) glusetexcache = glusetexcachecompression = -1; SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); - if(glusetexcache == -1 && glusetexcachecompression == -1) + if(glusetexcache == -1 || glusetexcachecompression == -1) { i=wm_ynbox("Texture caching", "Would you like to enable the on-disk texture cache? " diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index d269bcecd..e5b3adaa3 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8535,8 +8535,8 @@ void Startup(void) } #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) - if (i < 0 || ForceSetup || CommandSetup) { - if (!startwin_run()) { + if (i < 0 || (netparamcount == 0 && ForceSetup) || CommandSetup) { + if (quitevent | !startwin_run()) { uninitengine(); freeconmem(); exit(0); diff --git a/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade index f0c32fa17..ae077376d 100755 --- a/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade +++ b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade @@ -396,6 +396,7 @@ True + @@ -468,6 +469,7 @@ True + diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index c89dbc9d9..07994682b 100755 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -15,6 +15,10 @@ #include #include +#ifndef LINKED_GTK +# include "dynamicgtk.h" +#endif + #include "duke3d.h" #include "build.h" #include "compat.h" @@ -33,7 +37,7 @@ static struct { extern int gtkenabled; static GtkWidget *startwin = NULL; -static int retval = -1, mode = 0; +static int retval = -1, mode = TAB_MESSAGES; // -- SUPPORT FUNCTIONS ------------------------------------------------------- @@ -56,17 +60,14 @@ static GdkPixbuf *load_banner(void) static void SetPage(int n) { if (!gtkenabled || !startwin) return; - gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); -} - -static void EnableConfig(int n) -{ - // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive mode = n; - gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); + + // 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; + gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); } static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); @@ -142,8 +143,8 @@ static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer u static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) { - retval = 0; - gtk_main_quit(); + if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } + else quitevent++; } static void on_startbutton_clicked(GtkButton *button, gpointer user_data) @@ -172,7 +173,8 @@ static void on_inputjoycheck_toggled(GtkToggleButton *togglebutton, gpointer use static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { - //quitevent++; + 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 } @@ -391,6 +393,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group, GDK_C, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group, + GDK_Escape, 0, + GTK_ACCEL_VISIBLE); cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (cancelbuttonalign); @@ -416,6 +421,9 @@ static GtkWidget *create_window(void) gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group, GDK_S, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (startbutton, "clicked", accel_group, + GDK_Return, 0, + GTK_ACCEL_VISIBLE); startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (startbuttonalign); @@ -520,7 +528,6 @@ int startwin_open(void) startwin = create_window(); if (startwin) { SetPage(TAB_MESSAGES); - EnableConfig(FALSE); gtk_widget_show(startwin); gtk_main_iteration_do(FALSE); return 0; @@ -612,7 +619,6 @@ int startwin_run(void) if (!startwin) return 1; SetPage(TAB_CONFIG); - EnableConfig(TRUE); settings.fullscreen = ScreenMode; settings.xdim3d = ScreenWidth; @@ -626,7 +632,6 @@ int startwin_run(void) gtk_main(); SetPage(TAB_MESSAGES); - EnableConfig(FALSE); if (retval) { ScreenMode = settings.fullscreen; ScreenWidth = settings.xdim3d; diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index 97fc4d5c5..dafeb0650 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -29,7 +29,7 @@ static struct { static HWND startupdlg = NULL; static HWND pages[2] = { NULL, NULL}; -static int done = -1; +static int done = -1, mode = TAB_CONFIG; static void PopulateForm(void) { @@ -119,13 +119,14 @@ static void SetPage(int n) ShowWindow(pages[cur],SW_HIDE); SendMessage(tab, TCM_SETCURSEL, n, 0); ShowWindow(pages[n],SW_SHOW); + mode = n; SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); } static void EnableConfig(int n) { - EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); + //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); @@ -260,7 +261,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, } case WM_CLOSE: - done = 0; + if (mode == TAB_CONFIG) done = 0; + else quitevent++; return TRUE; case WM_DESTROY: @@ -279,7 +281,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { - case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_CANCEL: + if (mode == TAB_CONFIG) done = 0; + else quitevent++; + return TRUE; case WIN_STARTWIN_START: done = 1; return TRUE; } return FALSE;