shithub: choc

Download patch

ref: f03d7bd78f86dbe824c7048e19a031ac4f612ac9
parent: 8a357066f760771c1f5ca5fc3676b45c95a692d4
author: Simon Howard <[email protected]>
date: Fri Jun 2 15:32:48 EDT 2006

Add initial code for a setup utility.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 549

--- a/configure.in
+++ b/configure.in
@@ -53,6 +53,7 @@
 Makefile
 textscreen/Makefile
 textscreen/examples/Makefile
+setup/Makefile
 src/Makefile
 src/chocolate-doom-res.rc
 ])
--- /dev/null
+++ b/setup/Makefile.am
@@ -1,0 +1,9 @@
+AM_CFLAGS = @SDL_CFLAGS@ -I../textscreen -I../src
+
+gamesdir = $(prefix)/games
+
+games_PROGRAMS = chocolate-setup
+
+chocolate_setup_LDADD = @LDFLAGS@ @SDL_LIBS@ ../textscreen/libtextscreen.a
+chocolate_setup_SOURCES = mainmenu.c keyboard.c
+
--- /dev/null
+++ b/setup/keyboard.c
@@ -1,0 +1,23 @@
+#include "textscreen.h"
+
+int dummy;
+
+void ConfigKeyboard(void)
+{
+    txt_window_t *window;
+    txt_table_t *table;
+
+    window = TXT_NewWindow("Keyboard configuration");
+
+    table = TXT_NewTable(2);
+    TXT_AddWidget(window, table);
+
+    TXT_AddWidget(table, TXT_NewLabel("Move Forward"));
+    TXT_AddWidget(table, TXT_NewIntInputBox(&dummy, 7));
+    TXT_AddWidget(table, TXT_NewLabel("Move Backward"));
+    TXT_AddWidget(table, TXT_NewIntInputBox(&dummy, 7));
+    TXT_AddWidget(table, TXT_NewLabel("Turn Left"));
+    TXT_AddWidget(table, TXT_NewIntInputBox(&dummy, 7));
+    TXT_AddWidget(table, TXT_NewLabel("Turn Right"));
+}
+
--- /dev/null
+++ b/setup/mainmenu.c
@@ -1,0 +1,73 @@
+#include <stdlib.h>
+
+#include "config.h"
+#include "textscreen.h"
+
+void DoQuit(void *widget, void *dosave)
+{
+    if (dosave != NULL)
+    {
+        printf("Saving config\n");
+    }
+
+    exit(0);
+}
+
+void QuitConfirm(void *unused1, void *unused2)
+{
+    txt_window_t *window;
+    txt_label_t *label;
+    txt_button_t *button;
+
+    window = TXT_NewWindow(NULL);
+
+    label = TXT_NewLabel("Save settings and\n"
+                         "quit setup?");
+    TXT_AddWidget(window, label);
+    TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);
+
+    button = TXT_NewButton("  Yes  ");
+    TXT_SetWidgetAlign(button, TXT_HORIZ_CENTER);
+    TXT_AddWidget(window, button);
+    TXT_SignalConnect(button, "pressed", DoQuit, DoQuit);
+
+    button = TXT_NewButton("  No   ");
+    TXT_SetWidgetAlign(button, TXT_HORIZ_CENTER);
+    TXT_AddWidget(window, button);
+    TXT_SignalConnect(button, "pressed", DoQuit, NULL);
+}
+
+extern void ConfigKeyboard();
+
+void MainMenu(void)
+{
+    txt_window_t *window;
+    txt_window_action_t *quit_action;
+    txt_button_t *button;
+
+    window = TXT_NewWindow("Main Menu");
+    TXT_AddWidget(window, TXT_NewButton("Configure display"));
+    button = TXT_NewButton("Configure keyboard");
+    TXT_AddWidget(window, button);
+    TXT_SignalConnect(button, "pressed", ConfigKeyboard, NULL);
+    TXT_AddWidget(window, TXT_NewButton("Configure mouse"));
+    TXT_AddWidget(window, TXT_NewButton("Save parameters and launch DOOM"));
+    TXT_AddWidget(window, TXT_NewStrut(0, 1));
+    TXT_AddWidget(window, TXT_NewButton("Start a Network game"));
+    TXT_AddWidget(window, TXT_NewButton("Join a Network game"));
+
+    quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Abort");
+    TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
+    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
+}
+
+int main(int argc, char *argv[])
+{
+    TXT_Init();
+    TXT_SetDesktopTitle(PACKAGE_NAME " Setup ver " PACKAGE_VERSION);
+    
+    MainMenu();
+
+    TXT_GUIMainLoop();
+}
+