git-svn-id: https://svn.eduke32.com/eduke32@555 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2007-08-16 23:25:24 +00:00
parent 66538686e2
commit 9c6486025d
6 changed files with 319 additions and 67 deletions

View file

@ -12,14 +12,12 @@
# USE_OPENGL - enables OpenGL support in Polymost # USE_OPENGL - enables OpenGL support in Polymost
# NOASM - disables the use of inline assembly pragmas # NOASM - disables the use of inline assembly pragmas
# #
# SETSPRITEZ - set to 1 for Shadow Warrior
SUPERBUILD ?= 1 SUPERBUILD ?= 1
POLYMOST ?= 1 POLYMOST ?= 1
USE_OPENGL ?= 1 USE_OPENGL ?= 1
NOASM ?= 0 NOASM ?= 0
SETSPRITEZ ?= 0
# Debugging options # Debugging options
# RELEASE - 1 = no debugging # RELEASE - 1 = no debugging
# EFENCE - 1 = compile with Electric Fence for malloc() debugging # EFENCE - 1 = compile with Electric Fence for malloc() debugging

View file

@ -142,6 +142,4 @@ endif
ifneq (0,$(NOASM)) ifneq (0,$(NOASM))
BUILDCFLAGS+= -DNOASM BUILDCFLAGS+= -DNOASM
endif endif
ifneq (0,$(SETSPRITEZ))
BUILDCFLAGS+= -DSETSPRITEZ
endif

View file

@ -6,6 +6,9 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
struct _dynamicgtksyms { struct _dynamicgtksyms {
// glib.h
void (*g_free) (gpointer mem);
// gobject.h // gobject.h
gpointer (*g_object_get_data) (GObject *object, gpointer (*g_object_get_data) (GObject *object,
const gchar *key); const gchar *key);
@ -205,6 +208,8 @@ GtkWidget* (*gtk_scrolled_window_new) (GtkAdjustment *hadj
void (*gtk_scrolled_window_set_policy) (GtkScrolledWindow *scrolled_window, void (*gtk_scrolled_window_set_policy) (GtkScrolledWindow *scrolled_window,
GtkPolicyType hscrollbar_policy, GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy); GtkPolicyType vscrollbar_policy);
void (*gtk_scrolled_window_set_shadow_type) (GtkScrolledWindow *scrolled_window,
GtkShadowType type);
// gtktextbuffer.h // gtktextbuffer.h
gboolean (*gtk_text_buffer_backspace) (GtkTextBuffer *buffer, gboolean (*gtk_text_buffer_backspace) (GtkTextBuffer *buffer,
@ -257,6 +262,53 @@ void (*gtk_tree_model_get) (GtkTreeModel *tree_model,
...); ...);
GType (*gtk_tree_model_get_type) (void) G_GNUC_CONST; GType (*gtk_tree_model_get_type) (void) G_GNUC_CONST;
// gtktreeselection.h
gboolean (*gtk_tree_selection_get_selected) (GtkTreeSelection *selection,
GtkTreeModel **model,
GtkTreeIter *iter);
void (*gtk_tree_selection_select_iter) (GtkTreeSelection *selection,
GtkTreeIter *iter);
GType (*gtk_tree_selection_get_type) (void) G_GNUC_CONST;
void (*gtk_tree_selection_set_mode) (GtkTreeSelection *selection,
GtkSelectionMode type);
// gtktreesortable.h
GType (*gtk_tree_sortable_get_type) (void) G_GNUC_CONST;
void (*gtk_tree_sortable_set_sort_column_id) (GtkTreeSortable *sortable,
gint sort_column_id,
GtkSortType order);
void (*gtk_tree_sortable_set_sort_func) (GtkTreeSortable *sortable,
gint sort_column_id,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GtkDestroyNotify destroy);
// gtktreeview.h
GType (*gtk_tree_view_get_type) (void) G_GNUC_CONST;
GtkWidget *(*gtk_tree_view_new_with_model) (GtkTreeModel *model);
GtkTreeModel *(*gtk_tree_view_get_model) (GtkTreeView *tree_view);
GtkTreeSelection *(*gtk_tree_view_get_selection) (GtkTreeView *tree_view);
gint (*gtk_tree_view_append_column) (GtkTreeView *tree_view,
GtkTreeViewColumn *column);
void (*gtk_tree_view_set_enable_search) (GtkTreeView *tree_view,
gboolean enable_search);
void (*gtk_tree_view_set_headers_visible) (GtkTreeView *tree_view,
gboolean headers_visible);
// gtktreeviewcolumn.h
GtkTreeViewColumn *(*gtk_tree_view_column_new_with_attributes) (const gchar *title,
GtkCellRenderer *cell,
...) G_GNUC_NULL_TERMINATED;
void (*gtk_tree_view_column_set_expand) (GtkTreeViewColumn *tree_column,
gboolean expand);
void (*gtk_tree_view_column_set_min_width) (GtkTreeViewColumn *tree_column,
gint min_width);
// gtkvbox.h // gtkvbox.h
GtkWidget* (*gtk_vbox_new) (gboolean homogeneous, GtkWidget* (*gtk_vbox_new) (gboolean homogeneous,
gint spacing); gint spacing);
@ -293,6 +345,10 @@ void (*gtk_window_set_title) (GtkWindow *window,
void (*gtk_window_set_type_hint) (GtkWindow *window, void (*gtk_window_set_type_hint) (GtkWindow *window,
GdkWindowTypeHint hint); GdkWindowTypeHint hint);
// gunicode.h
gint (*g_utf8_collate) (const gchar *str1,
const gchar *str2);
}; };
extern struct _dynamicgtksyms dynamicgtksyms; extern struct _dynamicgtksyms dynamicgtksyms;
@ -301,6 +357,9 @@ void dynamicgtk_uninit(void);
#ifndef __dynamicgtkfoo__ #ifndef __dynamicgtkfoo__
// glib.h
#define g_free dynamicgtksyms.g_free
// gobject.h // gobject.h
#define g_object_get_data dynamicgtksyms.g_object_get_data #define g_object_get_data dynamicgtksyms.g_object_get_data
#define g_object_set_data dynamicgtksyms.g_object_set_data #define g_object_set_data dynamicgtksyms.g_object_set_data
@ -424,6 +483,7 @@ void dynamicgtk_uninit(void);
#define gtk_scrolled_window_get_type dynamicgtksyms.gtk_scrolled_window_get_type #define gtk_scrolled_window_get_type dynamicgtksyms.gtk_scrolled_window_get_type
#define gtk_scrolled_window_new dynamicgtksyms.gtk_scrolled_window_new #define gtk_scrolled_window_new dynamicgtksyms.gtk_scrolled_window_new
#define gtk_scrolled_window_set_policy dynamicgtksyms.gtk_scrolled_window_set_policy #define gtk_scrolled_window_set_policy dynamicgtksyms.gtk_scrolled_window_set_policy
#define gtk_scrolled_window_set_shadow_type dynamicgtksyms.gtk_scrolled_window_set_shadow_type
// gtktextbuffer.h // gtktextbuffer.h
#define gtk_text_buffer_backspace dynamicgtksyms.gtk_text_buffer_backspace #define gtk_text_buffer_backspace dynamicgtksyms.gtk_text_buffer_backspace
@ -452,6 +512,31 @@ void dynamicgtk_uninit(void);
#define gtk_tree_model_get dynamicgtksyms.gtk_tree_model_get #define gtk_tree_model_get dynamicgtksyms.gtk_tree_model_get
#define gtk_tree_model_get_type dynamicgtksyms.gtk_tree_model_get_type #define gtk_tree_model_get_type dynamicgtksyms.gtk_tree_model_get_type
// gtktreeselection.h
#define gtk_tree_selection_get_selected dynamicgtksyms.gtk_tree_selection_get_selected
#define gtk_tree_selection_select_iter dynamicgtksyms.gtk_tree_selection_select_iter
#define gtk_tree_selection_set_mode dynamicgtksyms.gtk_tree_selection_set_mode
// gtktreesortable.h
#define gtk_tree_sortable_get_type dynamicgtksyms.gtk_tree_sortable_get_type
#define gtk_tree_sortable_set_sort_column_id dynamicgtksyms.gtk_tree_sortable_set_sort_column_id
#define gtk_tree_sortable_set_sort_func dynamicgtksyms.gtk_tree_sortable_set_sort_func
// gtktreeview.h
#define gtk_tree_view_append_column dynamicgtksyms.gtk_tree_view_append_column
#define gtk_tree_view_get_model dynamicgtksyms.gtk_tree_view_get_model
#define gtk_tree_view_get_selection dynamicgtksyms.gtk_tree_view_get_selection
#define gtk_tree_view_get_type dynamicgtksyms.gtk_tree_view_get_type
#define gtk_tree_view_new_with_model dynamicgtksyms.gtk_tree_view_new_with_model
#define gtk_tree_view_set_enable_search dynamicgtksyms.gtk_tree_view_set_enable_search
#define gtk_tree_view_set_headers_visible dynamicgtksyms.gtk_tree_view_set_headers_visible
// gtktreeviewcolumn.h
#define gtk_tree_view_column_new_with_attributes dynamicgtksyms.gtk_tree_view_column_new_with_attributes
#define gtk_tree_view_column_set_expand dynamicgtksyms.gtk_tree_view_column_set_expand
#define gtk_tree_view_column_set_min_width dynamicgtksyms.gtk_tree_view_column_set_min_width
// gtkvbox.h // gtkvbox.h
#define gtk_vbox_new dynamicgtksyms.gtk_vbox_new #define gtk_vbox_new dynamicgtksyms.gtk_vbox_new
@ -474,6 +559,9 @@ void dynamicgtk_uninit(void);
#define gtk_window_set_title dynamicgtksyms.gtk_window_set_title #define gtk_window_set_title dynamicgtksyms.gtk_window_set_title
#define gtk_window_set_type_hint dynamicgtksyms.gtk_window_set_type_hint #define gtk_window_set_type_hint dynamicgtksyms.gtk_window_set_type_hint
// gunicode.h
#define g_utf8_collate dynamicgtksyms.g_utf8_collate
#endif #endif
#endif #endif

View file

@ -26,6 +26,7 @@ int dynamicgtk_init(void)
memset(&dynamicgtksyms, 0, sizeof(dynamicgtksyms)); memset(&dynamicgtksyms, 0, sizeof(dynamicgtksyms));
do { do {
GETDLSYM(g_free)
GETDLSYM(g_object_get_data) GETDLSYM(g_object_get_data)
GETDLSYM(g_object_set_data) GETDLSYM(g_object_set_data)
GETDLSYM(g_object_set_data_full) GETDLSYM(g_object_set_data_full)
@ -92,6 +93,7 @@ int dynamicgtk_init(void)
GETDLSYM(gtk_scrolled_window_get_type) GETDLSYM(gtk_scrolled_window_get_type)
GETDLSYM(gtk_scrolled_window_new) GETDLSYM(gtk_scrolled_window_new)
GETDLSYM(gtk_scrolled_window_set_policy) GETDLSYM(gtk_scrolled_window_set_policy)
GETDLSYM(gtk_scrolled_window_set_shadow_type)
GETDLSYM(gtk_text_buffer_backspace) GETDLSYM(gtk_text_buffer_backspace)
GETDLSYM(gtk_text_buffer_create_mark) GETDLSYM(gtk_text_buffer_create_mark)
GETDLSYM(gtk_text_buffer_delete_mark) GETDLSYM(gtk_text_buffer_delete_mark)
@ -111,6 +113,22 @@ int dynamicgtk_init(void)
GETDLSYM(gtk_toggle_button_set_active) GETDLSYM(gtk_toggle_button_set_active)
GETDLSYM(gtk_tree_model_get) GETDLSYM(gtk_tree_model_get)
GETDLSYM(gtk_tree_model_get_type) GETDLSYM(gtk_tree_model_get_type)
GETDLSYM(gtk_tree_selection_get_selected)
GETDLSYM(gtk_tree_selection_select_iter)
GETDLSYM(gtk_tree_selection_set_mode)
GETDLSYM(gtk_tree_sortable_get_type)
GETDLSYM(gtk_tree_sortable_set_sort_column_id)
GETDLSYM(gtk_tree_sortable_set_sort_func)
GETDLSYM(gtk_tree_view_append_column)
GETDLSYM(gtk_tree_view_column_new_with_attributes)
GETDLSYM(gtk_tree_view_column_set_expand)
GETDLSYM(gtk_tree_view_column_set_min_width)
GETDLSYM(gtk_tree_view_get_model)
GETDLSYM(gtk_tree_view_get_selection)
GETDLSYM(gtk_tree_view_get_type)
GETDLSYM(gtk_tree_view_new_with_model)
GETDLSYM(gtk_tree_view_set_enable_search)
GETDLSYM(gtk_tree_view_set_headers_visible)
GETDLSYM(gtk_vbox_new) GETDLSYM(gtk_vbox_new)
GETDLSYM(gtk_widget_add_accelerator) GETDLSYM(gtk_widget_add_accelerator)
GETDLSYM(gtk_widget_destroy) GETDLSYM(gtk_widget_destroy)
@ -127,6 +145,7 @@ int dynamicgtk_init(void)
GETDLSYM(gtk_window_set_resizable) GETDLSYM(gtk_window_set_resizable)
GETDLSYM(gtk_window_set_title) GETDLSYM(gtk_window_set_title)
GETDLSYM(gtk_window_set_type_hint) GETDLSYM(gtk_window_set_type_hint)
GETDLSYM(g_utf8_collate)
} while (0); } while (0);
if (err) { if (err) {

View file

@ -1875,6 +1875,8 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon
long y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy; long y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy;
char bad; char bad;
if (x2 >= xdim) x2 = xdim-1;
tsizx = tilesizx[globalpicnum]; tsizx = tilesizx[globalpicnum];
tsizy = tilesizy[globalpicnum]; tsizy = tilesizy[globalpicnum];
setgotpic(globalpicnum); setgotpic(globalpicnum);
@ -7940,11 +7942,8 @@ long setsprite(short spritenum, long newx, long newy, long newz)
sprite[spritenum].z = newz; sprite[spritenum].z = newz;
tempsectnum = sprite[spritenum].sectnum; tempsectnum = sprite[spritenum].sectnum;
#ifdef SETSPRITEZ
updatesectorz(newx,newy,newz,&tempsectnum);
#else
updatesector(newx,newy,&tempsectnum); updatesector(newx,newy,&tempsectnum);
#endif
if (tempsectnum < 0) if (tempsectnum < 0)
return(-1); return(-1);
if (tempsectnum != sprite[spritenum].sectnum) if (tempsectnum != sprite[spritenum].sectnum)
@ -7953,6 +7952,24 @@ long setsprite(short spritenum, long newx, long newy, long newz)
return(0); return(0);
} }
long setspritez(short spritenum, long newx, long newy, long newz)
{
short tempsectnum;
sprite[spritenum].x = newx;
sprite[spritenum].y = newy;
sprite[spritenum].z = newz;
tempsectnum = sprite[spritenum].sectnum;
updatesectorz(newx,newy,newz,&tempsectnum);
if (tempsectnum < 0)
return(-1);
if (tempsectnum != sprite[spritenum].sectnum)
changespritesect(spritenum,tempsectnum);
return(0);
}
// //
// insertsprite // insertsprite

View file

@ -24,8 +24,11 @@
#include "compat.h" #include "compat.h"
#include "baselayer.h" #include "baselayer.h"
#include "grpscan.h"
#define TAB_CONFIG 0 #define TAB_CONFIG 0
#define TAB_MESSAGES 1 #define TAB_GAME 1
#define TAB_MESSAGES 2
static struct static struct
{ {
@ -33,8 +36,9 @@ static struct
int xdim3d, ydim3d, bpp3d; int xdim3d, ydim3d, bpp3d;
int forcesetup; int forcesetup;
int usemouse, usejoy; int usemouse, usejoy;
} char selectedgrp[BMAX_PATH+1];
settings; int game;
} settings;
extern int gtkenabled; extern int gtkenabled;
@ -66,65 +70,94 @@ static void SetPage(int n)
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); 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 // each control in the config page vertical layout plus the start button should be made (in)sensitive
if (n == TAB_CONFIG) n = TRUE; if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
else n = FALSE;
gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n); (GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
} }
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
static void PopulateForm(void) static void on_gamelist_selection_changed(GtkTreeSelection *, gpointer);
static void PopulateForm(int pgs)
{ {
int mode3d, i; if (pgs & (1<<TAB_CONFIG))
GtkListStore *modes3d;
GtkTreeIter iter;
GtkComboBox *box3d;
char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0)
{ {
int i, cd[] = { 32, 24, 16, 15, 8, 0 }; int mode3d, i;
for (i=0; cd[i];) GtkListStore *modes3d;
GtkTreeIter iter;
GtkComboBox *box3d;
char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0)
{ {
if (cd[i] >= settings.bpp3d) i++; int i, cd[] = { 32, 24, 16, 15, 8, 0 };
else break; 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;
}
} }
for (; cd[i]; i++)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup);
box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo"));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++)
{ {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); if (validmode[i].fs != settings.fullscreen) continue;
if (mode3d < 0) continue;
settings.bpp3d = cd[i]; // all modes get added to the 3D mode list
break; Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d)
{
g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box3d, &iter);
g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL);
}
} }
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputmousecheck")), settings.usemouse);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputjoycheck")), settings.usejoy);
} }
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); if (pgs & (1<<TAB_GAME))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup);
box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo"));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++)
{ {
if (validmode[i].fs != settings.fullscreen) continue; struct grpfile *fg;
int i;
GtkListStore *list;
GtkTreeIter iter;
GtkTreeView *gamelist;
// all modes get added to the 3D mode list gamelist = GTK_TREE_VIEW(lookup_widget(startwin,"gamelist"));
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); list = GTK_LIST_STORE(gtk_tree_view_get_model(gamelist));
gtk_list_store_append(modes3d, &iter); gtk_list_store_clear(list);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d) for (fg = foundgrps; fg; fg=fg->next)
{ {
g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL); for (i = 0; i<numgrpfiles; i++)
gtk_combo_box_set_active_iter(box3d, &iter); if (fg->crcval == grpfiles[i].crcval) break;
g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL); 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);
}
} }
} }
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputmousecheck")), settings.usemouse);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputjoycheck")), settings.usejoy);
} }
// -- EVENT CALLBACKS AND CREATION STUFF -------------------------------------- // -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
@ -144,7 +177,7 @@ static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE); settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE);
PopulateForm(); PopulateForm(1<<TAB_CONFIG);
} }
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
@ -154,11 +187,7 @@ static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer u
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{ {
if (mode == TAB_CONFIG) if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
{
retval = 0;
gtk_main_quit();
}
else quitevent++; else quitevent++;
} }
@ -169,7 +198,8 @@ static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
} }
static void on_sounddrvcombo_changed(GtkComboBox *combobox, gpointer user_data) static void on_sounddrvcombo_changed(GtkComboBox *combobox, gpointer user_data)
{} {
}
static void on_inputmousecheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_inputmousecheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
@ -181,18 +211,44 @@ static void on_inputjoycheck_toggled(GtkToggleButton *togglebutton, gpointer use
settings.usejoy = (gtk_toggle_button_get_active(togglebutton) == TRUE); settings.usejoy = (gtk_toggle_button_get_active(togglebutton) == TRUE);
} }
static void on_gamelist_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
GtkTreeIter iter;
GtkTreeModel *model;
struct grpfile *fg;
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;
}
}
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{ {
if (mode == TAB_CONFIG) if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
{
retval = 0;
gtk_main_quit();
}
else quitevent++; else quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close return TRUE; // FALSE would let the event go through. we want the game to decide when to close
} }
static gint name_sorter(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
{
gchar *as, *bs;
gint r;
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;
}
static GtkWidget *create_window(void) static GtkWidget *create_window(void)
{ {
GtkWidget *startwin; GtkWidget *startwin;
@ -212,6 +268,11 @@ static GtkWidget *create_window(void)
GtkWidget *vmode3dcombo; GtkWidget *vmode3dcombo;
GtkWidget *alwaysshowcheck; GtkWidget *alwaysshowcheck;
GtkWidget *configtab; GtkWidget *configtab;
GtkWidget *gamevlayout;
GtkWidget *gamelabel;
GtkWidget *gamescroll;
GtkWidget *gamelist;
GtkWidget *gametab;
GtkWidget *messagesscroll; GtkWidget *messagesscroll;
GtkWidget *messagestext; GtkWidget *messagestext;
GtkWidget *messagestab; GtkWidget *messagestab;
@ -358,6 +419,58 @@ static GtkWidget *create_window(void)
gtk_widget_show(configtab); gtk_widget_show(configtab);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab);
// Game data layout
gamevlayout = gtk_vbox_new(FALSE, 0);
gtk_widget_show(gamevlayout);
gtk_container_add(GTK_CONTAINER(tabs), gamevlayout);
gtk_container_set_border_width(GTK_CONTAINER(gamevlayout), 4);
// Game data field label
gamelabel = gtk_label_new_with_mnemonic("_Game or addon:");
gtk_widget_show(gamelabel);
gtk_box_pack_start(GTK_BOX(gamevlayout), gamelabel, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(gamelabel), 0, 0.5);
// Game data scrollable area
gamescroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(gamescroll);
gtk_box_pack_start(GTK_BOX(gamevlayout), gamescroll, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gamescroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gamescroll), GTK_SHADOW_IN);
// 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);
gamelist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
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);
gtk_tree_view_append_column(GTK_TREE_VIEW(gamelist), col);
col = gtk_tree_view_column_new_with_attributes("GRP file", cell, "text", 1, NULL);
gtk_tree_view_column_set_min_width(col, 64);
gtk_tree_view_append_column(GTK_TREE_VIEW(gamelist), col);
}
gtk_widget_show(gamelist);
gtk_container_add(GTK_CONTAINER(gamescroll), gamelist);
gtk_widget_add_accelerator(gamelist, "grab_focus", accel_group,
GDK_G, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gamelist), FALSE);
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(gamelist), FALSE);
// Game tab
gametab = gtk_label_new("Game");
gtk_widget_show(gametab);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), gametab);
// Messages scrollable area // Messages scrollable area
messagesscroll = gtk_scrolled_window_new(NULL, NULL); messagesscroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(messagesscroll); gtk_widget_show(messagesscroll);
@ -377,7 +490,7 @@ static GtkWidget *create_window(void)
// Messages tab // Messages tab
messagestab = gtk_label_new("Messages"); messagestab = gtk_label_new("Messages");
gtk_widget_show(messagestab); gtk_widget_show(messagestab);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), messagestab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 2), messagestab);
// Dialogue box buttons layout // Dialogue box buttons layout
buttons = gtk_hbutton_box_new(); buttons = gtk_hbutton_box_new();
@ -470,10 +583,18 @@ static GtkWidget *create_window(void)
g_signal_connect((gpointer) startbutton, "clicked", g_signal_connect((gpointer) startbutton, "clicked",
G_CALLBACK(on_startbutton_clicked), G_CALLBACK(on_startbutton_clicked),
NULL); NULL);
{
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gamelist));
gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
g_signal_connect((gpointer) sel, "changed",
G_CALLBACK(on_gamelist_selection_changed),
NULL);
}
// Associate labels with their controls // Associate labels with their controls
gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo); gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo);
gtk_label_set_mnemonic_widget(GTK_LABEL(sounddrvlabel), sounddrvcombo); gtk_label_set_mnemonic_widget(GTK_LABEL(sounddrvlabel), sounddrvcombo);
gtk_label_set_mnemonic_widget(GTK_LABEL(gamelabel), gamelist);
/* Store pointers to all widgets, for use by lookup_widget(). */ /* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin"); GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin");
@ -493,6 +614,11 @@ static GtkWidget *create_window(void)
GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo"); GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo");
GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck"); GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck");
GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab"); GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab");
GLADE_HOOKUP_OBJECT(startwin, gamevlayout, "gamevlayout");
GLADE_HOOKUP_OBJECT(startwin, gamelabel, "gamelabel");
GLADE_HOOKUP_OBJECT(startwin, gamescroll, "gamescroll");
GLADE_HOOKUP_OBJECT(startwin, gamelist, "gamelist");
GLADE_HOOKUP_OBJECT(startwin, gametab, "gametab");
GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll"); GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll");
GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext"); GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext");
GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab"); GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab");
@ -609,6 +735,8 @@ int startwin_idle(void *s)
return 0; return 0;
} }
extern char *duke3dgrp;
int startwin_run(void) int startwin_run(void)
{ {
if (!gtkenabled) return 0; if (!gtkenabled) return 0;
@ -623,7 +751,9 @@ int startwin_run(void)
settings.forcesetup = ForceSetup; settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse; settings.usemouse = UseMouse;
settings.usejoy = UseJoystick; settings.usejoy = UseJoystick;
PopulateForm(); settings.game = gametype;
strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
PopulateForm(-1);
gtk_main(); gtk_main();
@ -637,6 +767,8 @@ int startwin_run(void)
ForceSetup = settings.forcesetup; ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse; UseMouse = settings.usemouse;
UseJoystick = settings.usejoy; UseJoystick = settings.usejoy;
duke3dgrp = settings.selectedgrp;
gametype = settings.game;
} }
return retval; return retval;