3 * Andrew Sayman - 10/11/04
5 * Copyright (C) 2000 Daniel Nelson
6 * Copyright (C) 2004 Andrew Sayman
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Daniel Nelson - aluminumangel.org
34 #include "../Attack.h"
35 #include "callbacks.h"
36 #include "interface.h"
40 #include "modeparser.h"
42 static GtkWidget
*fraClient
, *fraSingle
, *fraServer
;
43 static GtkWindow
*window
= NULL
;
44 static int mode
= CM_SOLO
;
45 static gboolean MS_RUNNING
= FALSE
;
46 static pid_t running_process
= 0;
49 extern char **glut_argv
;
51 void turn_game_prefs_off () {
52 GAME_SINGLE
= GAME_SERVER
= GAME_CLIENT
= GAME_EXTREME
= FALSE
;
55 void lookup_widgets(GtkToggleButton
* gtb
) {
56 fraClient
= lookup_widget(GTK_WIDGET(gtb
), "fraClient");
57 fraSingle
= lookup_widget(GTK_WIDGET(gtb
), "fraSingle");
58 fraServer
= lookup_widget(GTK_WIDGET(gtb
), "fraServer");
61 void turn_sensitive_off() {
62 gtk_widget_set_sensitive (fraClient
, FALSE
);
63 gtk_widget_set_sensitive (fraSingle
, FALSE
);
64 gtk_widget_set_sensitive (fraServer
, FALSE
);
67 void toggle_sensitive (GtkToggleButton
* gtb
, gint selector
) {
68 gtk_widget_set_sensitive (fraClient
, FALSE
);
69 gtk_widget_set_sensitive (fraSingle
, FALSE
);
70 gtk_widget_set_sensitive (fraServer
, FALSE
);
72 case 1: gtk_widget_set_sensitive (fraClient
, TRUE
);
74 case 2: gtk_widget_set_sensitive (fraServer
, TRUE
);
79 void prepare_for_actions (GtkToggleButton
*gtb
) {
81 turn_game_prefs_off();
86 game_end (GPid pid
, gint status
, gpointer data
) {
88 g_print("game_end called!\n");
93 gtk_widget_show(GTK_WIDGET(window
));
95 g_spawn_close_pid (pid
);
99 ca_error_dialog (const char *message
)
101 GtkWidget
*dialog
= NULL
;
102 dialog
= gtk_message_dialog_new (window
,
103 GTK_DIALOG_DESTROY_WITH_PARENT
,
107 gtk_dialog_run (GTK_DIALOG (dialog
));
108 gtk_widget_destroy (dialog
);
112 on_btnStart_clicked (GtkButton
*button
,
116 GTK_WINDOW(lookup_widget(GTK_WIDGET(button
),"winCrackAttackSplash"));
118 //Game is running, display an error message to the user
119 ca_error_dialog("Error: crack-attack is already running");
123 // Save the gui data when the game starts.
124 gui_data_save(GTK_WIDGET(button
));
126 // Set the mode based on all the widget values...
127 mode
= generate_mode(GTK_WIDGET(button
));
130 g_print("Looking for location: %s\n", GC_BINARY_LOCATION
);
132 gtk_widget_hide(GTK_WIDGET(window
));
135 gtk_widget_hide(GTK_WIDGET(window
));
136 GSpawnFlags flags
= (GSpawnFlags
) (G_SPAWN_LEAVE_DESCRIPTORS_OPEN
|
137 G_SPAWN_DO_NOT_REAP_CHILD
);
140 generate_array(mode
, GC_BINARY_LOCATION
, GTK_WIDGET(button
));
143 g_spawn_async(NULL
, args
, NULL
, flags
, NULL
, NULL
, &pid
, &err
);
146 g_child_watch_add(pid
, (GChildWatchFunc
) game_end
, NULL
);
149 if (err
) ca_error_dialog(err
->message
);
154 on_winCrackAttackSplash_delete_event (GtkWindow
*window
,
161 on_cmbQuality_changed (GtkComboBox
*cmb
,
164 gint tmp
= gtk_combo_box_get_active(cmb
);
165 GtkImage
* imgLogo
= GTK_IMAGE(lookup_widget(GTK_WIDGET(cmb
), "imgLogo"));
166 gchar
*filename
= NULL
;
169 filename
= find_pixmap_file("preview_normal.tga");
173 filename
= find_pixmap_file("preview_reduced.tga");
177 filename
= find_pixmap_file("preview_extremely_reduced.tga");
181 filename
= find_pixmap_file("preview_normal.tga");
184 gtk_image_set_from_file(imgLogo
, filename
);