diff options
author | Eric Anderson <ejona86@gmail.com> | 2009-05-02 11:17:18 -0500 |
---|---|---|
committer | Eric Anderson <ejona86@gmail.com> | 2009-05-02 11:17:18 -0500 |
commit | e9c0705d2ca8f9c718e0531953af96b58f58d8a3 (patch) | |
tree | aaba9a727055a269baa9cc47174878fdb1d5f65f | |
parent | 667f7811083b6f7e59f5ea65c78efd6b0adccbb4 (diff) | |
download | kpl-master.tar.gz kpl-master.zip |
-rw-r--r-- | KPLUnixStarter.c | 89 | ||||
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | gtk_kpl.glade | 187 |
3 files changed, 234 insertions, 56 deletions
diff --git a/KPLUnixStarter.c b/KPLUnixStarter.c index f4c5928..7f0dd4d 100644 --- a/KPLUnixStarter.c +++ b/KPLUnixStarter.c @@ -4,6 +4,11 @@ static GtkWidget *mainWindow; +static GtkWidget *spectateButton, *easyButton, *mediumButton, *hardButton, + *veryHardButton; + +static int gameTypeSelected = 0; + static void on_destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } @@ -30,8 +35,27 @@ static void quick_message (gchar *message) { gtk_widget_show_all (dialog); } -static void start_single_game(GtkButton *button, gpointer data) { - int ret = LaunchSpringExecutable(GPOINTER_TO_INT(data)); +void radio_toggled(GtkToggleButton *button, gpointer data) { + if (!gtk_toggle_button_get_active(button)) + return; + + GtkWidget *b = GTK_WIDGET(button); + if (b == spectateButton) + gameTypeSelected = 0; + else if (b == easyButton) + gameTypeSelected = 1; + else if (b == mediumButton) + gameTypeSelected = 2; + else if (b == hardButton) + gameTypeSelected = 3; + else if (b == veryHardButton) + gameTypeSelected = 4; + else + fprintf(stderr, "Error: unable to change radio_toggled - button unknown.\n"); +} + +void start_single_game(GtkButton *button, gpointer data) { + int ret = LaunchSpringExecutable(gameTypeSelected); if (ret != 0) { fprintf(stderr, "Error: %d\n", ret); quick_message("Error"); @@ -39,58 +63,21 @@ static void start_single_game(GtkButton *button, gpointer data) { } int main(int argc, char* argv[]) { - GtkWidget *container; - GtkWidget *button; - GtkWidget *image; - gtk_init(&argc, &argv); - mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(mainWindow), "Kernel Panic Launcher"); - gtk_window_set_default_icon_from_file("icons/KPL.ico", NULL); - - 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"); - image = gtk_image_new_from_file("icons/32x32LightBlueFlow.ico"); - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(image)); - gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(button)); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game), - GINT_TO_POINTER(0)); - - button = gtk_button_new_with_mnemonic("_Easy"); - image = gtk_image_new_from_file("icons/32x32GreenBit.ico"); - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(image)); - 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"); - image = gtk_image_new_from_file("icons/32x32YellowPointer.ico"); - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(image)); - 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"); - image = gtk_image_new_from_file("icons/32x32OrangeByte.ico"); - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(image)); - 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"); - image = gtk_image_new_from_file("icons/32x32RedConnection.ico"); - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(image)); - gtk_container_add(GTK_CONTAINER(container), button); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_single_game), - GINT_TO_POINTER(4)); - + GtkBuilder *builder; + builder = gtk_builder_new(); + gtk_builder_add_from_file(builder, "obj/gtk_kpl.ui", NULL); + gtk_builder_connect_signals(builder, NULL); + + mainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "window1")); + spectateButton = GTK_WIDGET(gtk_builder_get_object(builder, "spectateButton")); + easyButton = GTK_WIDGET(gtk_builder_get_object(builder, "easyButton")); + mediumButton = GTK_WIDGET(gtk_builder_get_object(builder, "mediumButton")); + hardButton = GTK_WIDGET(gtk_builder_get_object(builder, "hardButton")); + veryHardButton = GTK_WIDGET(gtk_builder_get_object(builder, "veryHardButton")); gtk_widget_show_all(mainWindow); + gtk_main(); //return StartEasy(0); @@ -4,19 +4,23 @@ REALCFLAGS = -Wall $(CFLAGS) -fPIC .SUFFIXES: .SUFFIXES: .cpp .o -all: obj/libKPL.so obj/KPLUnixStarter +all: obj/libKPL.so obj/KPLUnixStarter obj/gtk_kpl.ui -run: obj/libKPL.so obj/KPLUnixStarter +run: all LD_LIBRARY_PATH=obj ./obj/KPLUnixStarter +obj/gtk_kpl.ui: gtk_kpl.glade + gtk-builder-convert $< $@ + cp icons/*.ico obj/ + obj/libKPL.so: obj/GenerateScript.o obj/ColorSpacesConversions.o obj/KPLFillModSpecific.o obj/KPLTypes.o obj/WriteScript.o obj/KPL_Start.o g++ $(REALCFLAGS) -shared -o $@ $^ obj/KPLUnixStarter: obj/KPLUnixStarter.o obj/libKPL.so - gcc $(REALCFLAGS) -o $@ obj/KPLUnixStarter.o -L./obj -lKPL `pkg-config --libs gtk+-2.0` + gcc $(REALCFLAGS) -Wl,--export-dynamic -o $@ obj/KPLUnixStarter.o -L./obj -lKPL `pkg-config --libs gtk+-2.0` obj/KPLUnixStarter.o: KPLUnixStarter.c - gcc $(REALCFLAGS) `pkg-config --cflags gtk+-2.0` -c -o $@ $< + gcc $(REALCFLAGS) -Wl,--export-dynamic `pkg-config --cflags gtk+-2.0 gmodule-export-2.0` -c -o $@ $< obj/%.o: %.c gcc $(REALCFLAGS) -c -o $@ $< @@ -25,7 +29,7 @@ obj/%.o: %.cpp g++ $(REALCFLAGS) -c -o $@ $< clean: - rm -f obj/*.o obj/*.so + rm -f obj/*.o obj/*.so obj/*.ico obj/*.ui obj/KPLUnixStarter dist: obj/libKPL.so obj/KPLUnixStarter strip obj/libKPL.so diff --git a/gtk_kpl.glade b/gtk_kpl.glade new file mode 100644 index 0000000..7e2328c --- /dev/null +++ b/gtk_kpl.glade @@ -0,0 +1,187 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> +<!--Generated with glade3 3.4.5 on Sat May 2 11:14:13 2009 --> +<glade-interface> + <widget class="GtkWindow" id="window1"> + <property name="title" translatable="yes">Kernel Panic Launcher</property> + <property name="icon">KPL.ico</property> + <signal name="destroy" handler="gtk_main_quit"/> + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <child> + <widget class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <child> + <widget class="GtkRadioButton" id="spectateButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Spectate</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="radio_toggled"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="easyButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Easy</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">spectateButton</property> + <signal name="toggled" handler="radio_toggled"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="mediumButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Medium</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">spectateButton</property> + <signal name="toggled" handler="radio_toggled"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="hardButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Hard</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">spectateButton</property> + <signal name="toggled" handler="radio_toggled"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="veryHardButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Very Hard</property> + <property name="response_id">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">spectateButton</property> + <signal name="toggled" handler="radio_toggled"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="pixbuf">32x32LightBlueFlow.ico</property> + </widget> + </child> + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="pixbuf">32x32GreenBit.ico</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="pixbuf">32x32YellowPointer.ico</property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <widget class="GtkImage" id="image4"> + <property name="visible">True</property> + <property name="pixbuf">32x32OrangeByte.ico</property> + </widget> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <widget class="GtkImage" id="image5"> + <property name="visible">True</property> + <property name="pixbuf">32x32RedConnection.ico</property> + </widget> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + </widget> + </child> + <child> + <widget class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <child> + <widget class="GtkButton" id="button2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="label" translatable="yes">gtk-quit</property> + <property name="use_stock">True</property> + <property name="response_id">0</property> + <signal name="clicked" handler="gtk_main_quit"/> + </widget> + </child> + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="label" translatable="yes">Start Skirmish</property> + <property name="response_id">0</property> + <signal name="clicked" handler="start_single_game"/> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + </widget> +</glade-interface> |