DEADSOFTWARE

menu: add video settings
[flatwaifu.git] / src / menu.c
index ab0e5735fb24006d2465f7f94ba53ad83752c23a..f7ba78fe63d4fdf0eb09b48de01419aef82f105a 100644 (file)
@@ -64,7 +64,7 @@ static int stack_p = -1;
 char ibuf[GM_MAX_INPUT];
 byte input;
 int icur;
-static int imax;
+int imax;
 static byte cbuf[32];
 short lastkey;
 
@@ -94,7 +94,7 @@ static void GM_say (const char nm[8]) {
   }
 }
 
-static int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
+int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
   assert(msg != NULL);
   assert(a <= b);
   assert(s >= 0);
@@ -105,7 +105,7 @@ static int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
   return 1;
 }
 
-static int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
+int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
   assert(msg != NULL);
   assert(str != NULL);
   assert(maxlen >= 0);
@@ -201,7 +201,11 @@ static int GM_save_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
   intptr_t i = (intptr_t)data;
   switch (msg->type) {
     case GM_ENTER:
-      F_getsavnames();
+      if (g_st == GS_GAME) {
+        F_getsavnames();
+      } else {
+        GM_pop();
+      }
       return 1;
     case GM_GETSTR:
       F_getsavnames();
@@ -217,6 +221,13 @@ static int GM_save_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
   return 0;
 }
 
+static int GM_options_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
+  switch (msg->type) {
+    case GM_SELECT: GM_push(R_menu()); return 1;
+  }
+  return 0;
+}
+
 static int GM_exit_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
   switch (msg->type) {
     case GM_ENTER:
@@ -279,13 +290,13 @@ static const new_menu_t newgame_menu = {
   GM_BIG, "Music", NULL, NULL,
   {
     { GM_SCROLLER, "Volume", &mus_vol, &GM_var_handler, NULL },
-    { GM_BUTTON, "Music:", g_music, &GM_var_handler, NULL },
+    { GM_BUTTON, "Music: ", g_music, &GM_var_handler, NULL },
     { 0, NULL, NULL, NULL, NULL } // end
   }
 }, options_menu = {
   GM_BIG, "Options", NULL, NULL,
   {
-    //{ GM_BUTTON, "Video", NULL, NULL, NULL },
+    { GM_BUTTON, "Video", NULL, &GM_options_handler, NULL },
     { GM_BUTTON, "Sound", NULL, NULL, &sound_menu },
     { GM_BUTTON, "Music", NULL, NULL, &music_menu },
     { 0, NULL, NULL, NULL, NULL } // end
@@ -563,10 +574,16 @@ void GM_key (int key, int down) {
   if (down) {
     lastkey = key;
     if (!_2pl || cheat) {
-      for (i = 0; i < 31; ++i) {
+      for (i = 0; i < 31; i++) {
         cbuf[i] = cbuf[i + 1];
       }
-      //cbuf[31] = get_keychar(key);
+      if (key >= KEY_0 && key <= KEY_9) {
+        cbuf[31] = key - KEY_0 + '0';
+      } else if (key >= KEY_A && key <= KEY_Z) {
+        cbuf[31] = key - KEY_A + 'A';
+      } else {
+        cbuf[31] = 0;
+      }
     }
   }
 }