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
|
#include <gtk/gtk.h>
#include "KPL_Start.h"
static GtkWidget *mainWindow;
static void on_destroy(GtkWidget *widget, gpointer data) {
gtk_main_quit();
}
/* Function to open a dialog box displaying the message provided. */
static void quick_message (gchar *message) {
GtkWidget *dialog, *label, *content_area;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons ("Message",
mainWindow,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK,
GTK_RESPONSE_NONE,
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
label = gtk_label_new (message);
/* Ensure that the dialog box is destroyed when the user responds. */
g_signal_connect_swapped (dialog,
"response",
G_CALLBACK (gtk_widget_destroy),
dialog);
/* Add the label, and show everything we've added to the dialog. */
gtk_container_add (GTK_CONTAINER (content_area), label);
gtk_widget_show_all (dialog);
}
static void start_single_game(GtkButton *button, gpointer data) {
int ret = LaunchSpringExecutable(GPOINTER_TO_INT(data));
if (ret != 0) {
fprintf(stderr, "Error: %d\n", ret);
quick_message("Error");
}
}
int main(int argc, char* argv[]) {
GtkWidget *container;
GtkWidget *button;
gtk_init(&argc, &argv);
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(mainWindow), "Kernel Panic Launcher");
g_signal_connect(G_OBJECT(mainWindow), "destroy", G_CALLBACK(on_destroy),
NULL);
container = gtk_vbutton_box_new();
gtk_container_add(GTK_CONTAINER(mainWindow), container);
button = gtk_button_new_with_mnemonic("_Spectate");
gtk_container_add(GTK_CONTAINER(container), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game),
GINT_TO_POINTER(0));
button = gtk_button_new_with_mnemonic("_Easy");
gtk_container_add(GTK_CONTAINER(container), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game),
GINT_TO_POINTER(1));
button = gtk_button_new_with_mnemonic("_Medium");
gtk_container_add(GTK_CONTAINER(container), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game),
GINT_TO_POINTER(2));
button = gtk_button_new_with_mnemonic("_Hard");
gtk_container_add(GTK_CONTAINER(container), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game),
GINT_TO_POINTER(3));
button = gtk_button_new_with_mnemonic("_Very Hard");
gtk_container_add(GTK_CONTAINER(container), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game),
GINT_TO_POINTER(4));
gtk_widget_show_all(mainWindow);
gtk_main();
//return StartEasy(0);
return 0;
}
|