1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/* $Header: /fridge/cvs/xscorch/sgtk/soptions-gtk.c,v 1.17 2009-04-26 17:39:49 jacob Exp $ */
/*
xscorch - soptions-gtk.c Copyright(c) 2000-2003 Justin David Smith
justins(at)chaos2.org http://chaos2.org/
Generic options configuration dialogue
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2 of the License ONLY.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <sgtk.h>
#include <sdialog.h>
#include <slabel.h>
#include <slinkcheck.h>
#include <slinkcombo.h>
#include <slinkspin.h>
#include <sdialog-gtk.h>
#include <ssetup-gtk.h>
#include <sgame/sconfig.h>
#include <snet/snet.h>
typedef struct _sc_options_setup_data_gtk {
sc_config *c;
sc_config_options *co;
int modeidx;
int teamidx;
int orderidx;
int talkidx;
int talkprob;
bool extstatus;
bool tooltips;
bool interleave;
} sc_options_setup_data_gtk;
static void _sc_options_setup_apply_gtk(__libj_unused ScDialog *dlg, sc_options_setup_data_gtk *setup) {
sc_config_options *co = setup->co;
sc_window_gtk *w = (sc_window_gtk *)setup->c->window;
bool oldextstatus;
bool oldtooltips;
oldextstatus = co->extstatus;
oldtooltips = co->tooltips;
co->mode = sc_config_mode_types()[setup->modeidx];
co->team = sc_config_team_types()[setup->teamidx];
co->order = sc_config_order_types()[setup->orderidx];
co->talk = sc_config_talk_types()[setup->talkidx];
co->talkprob = setup->talkprob;
co->extstatus= setup->extstatus;
co->tooltips = setup->tooltips;
co->interleave=setup->interleave;
/* Reconfigure the statusbar */
if(oldextstatus != co->extstatus) sc_status_setup(setup->c->window);
if(oldtooltips != co->tooltips) {
/* TEMP - 99.44% likely this does not work. */
if(co->tooltips) gtk_tooltips_enable(w);
else gtk_tooltips_disable(w);
}
#if USE_NETWORK
if(SC_NETWORK_SERVER(setup->c)) sc_net_server_send_config(setup->c, setup->c->server);
#endif
}
void sc_options_setup_gtk(sc_window_gtk *w) {
sc_config_options *co = &w->c->options;
sc_options_setup_data_gtk setup;
ScDialog *dialog;
int confirm = (SC_NETWORK_AUTH(w->c) ? SC_DIALOG_OK : 0);
int row = 0;
setup.c = w->c;
setup.co = co;
setup.modeidx = 0;
setup.teamidx = 0;
setup.orderidx = 0;
setup.talkidx = 0;
setup.talkprob = co->talkprob;
setup.extstatus= co->extstatus;
setup.tooltips = co->tooltips;
setup.interleave=co->interleave;
while(sc_config_mode_types()[setup.modeidx] != co->mode) ++setup.modeidx;
while(sc_config_team_types()[setup.teamidx] != co->team) ++setup.teamidx;
while(sc_config_order_types()[setup.orderidx]!=co->order)++setup.orderidx;
while(sc_config_talk_types()[setup.talkidx] != co->talk) ++setup.talkidx;
dialog = SC_DIALOG(sc_dialog_new("Options Setup", NULL, confirm | SC_DIALOG_CANCEL));
g_signal_connect(G_OBJECT(dialog), "apply",
(GCallback)_sc_options_setup_apply_gtk, &setup);
attach_option(dialog, w, "Mode", sc_link_combo_new(&setup.modeidx, sc_config_mode_names()), &row);
attach_option(dialog, w, "N/A: Teams", sc_link_combo_new(&setup.teamidx, sc_config_team_names()), &row);
attach_option(dialog, w, "Order", sc_link_combo_new(&setup.orderidx, sc_config_order_names()), &row);
attach_option(dialog, w, "Talk Mode", sc_link_combo_new(&setup.talkidx, sc_config_talk_names()), &row);
attach_option(dialog, w, "Talk Probability", sc_link_spin_new(&setup.talkprob, 0, 100, 1), &row);
attach_option(dialog, w, "Extended Status", sc_link_check_new(&setup.extstatus), &row);
attach_option(dialog, w, "Tooltips", sc_link_check_new(&setup.tooltips), &row);
attach_option(dialog, w, "Interleaved Tracking", sc_link_check_new(&setup.interleave), &row);
sc_dialog_run(dialog);
}
|