summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anderson <ejona86@gmail.com>2009-05-01 17:18:21 -0500
committerEric Anderson <ejona86@gmail.com>2009-05-01 17:18:21 -0500
commitae8bd57cad0273c04e89fc2c267c655c4cb349c3 (patch)
tree9a1c9d70aea0f1d5f4fd464af9327c05038f39d5
parent663d9336324110648ffdea7c7092a004353419b5 (diff)
downloadkpl-ae8bd57cad0273c04e89fc2c267c655c4cb349c3.tar.gz
kpl-ae8bd57cad0273c04e89fc2c267c655c4cb349c3.zip
Get existing KPL code to compile and run under Linux. Start work on GTK+
KPL GUI.
-rw-r--r--KPLUnixStarter.c87
-rw-r--r--Makefile32
2 files changed, 119 insertions, 0 deletions
diff --git a/KPLUnixStarter.c b/KPLUnixStarter.c
new file mode 100644
index 0000000..39821df
--- /dev/null
+++ b/KPLUnixStarter.c
@@ -0,0 +1,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;
+}
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..320179f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
+srcdir = .
+REALCFLAGS = $(CFLAGS) -fPIC
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o
+
+all: obj/libKPL.so obj/KPLUnixStarter
+
+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`
+
+obj/KPLUnixStarter.o: KPLUnixStarter.c
+ gcc $(REALCFLAGS) `pkg-config --cflags gtk+-2.0` -c -o $@ $<
+
+obj/%.o: %.c
+ gcc $(REALCFLAGS) -c -o $@ $<
+
+obj/%.o: %.cpp
+ g++ $(REALCFLAGS) -c -o $@ $<
+
+clean:
+ rm -f obj/*.o obj/*.so
+
+dist: obj/libKPL.so obj/KPLUnixStarter
+ strip obj/libKPL.so
+ strip obj/KPLUnixStarter
+
+.PHONEY: clean
+