Merge branch 'teleporter-tweaks'
[neverball] / ball / st_name.c
index 7b57d73..b454745 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "game.h"
 #include "text.h"
+#include "back.h"
 
 #include "st_name.h"
 #include "st_shared.h"
@@ -32,21 +33,23 @@ static char player[MAXNAM];
 /*---------------------------------------------------------------------------*/
 
 static struct state *ok_state, *cancel_state;
+static unsigned int draw_back;
 
-int goto_name(struct state *ok, struct state *cancel)
+int goto_name(struct state *ok, struct state *cancel, unsigned int back)
 {
     config_get_s(CONFIG_PLAYER, player, MAXNAM);
 
     ok_state     = ok;
     cancel_state = cancel;
+    draw_back    = back;
 
     return goto_state(&st_name);
 }
 
 /*---------------------------------------------------------------------------*/
 
-#define NAME_OK     1
-#define NAME_CANCEL 2
+#define NAME_OK     -1
+#define NAME_CANCEL -2
 
 static int name_id;
 
@@ -89,6 +92,12 @@ static int name_enter(void)
 {
     int id, jd;
 
+    if (draw_back)
+    {
+        game_free();
+        back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
+    }
+
     if ((id = gui_vstack(0)))
     {
         gui_label(id, _("Player Name"), GUI_MED, GUI_ALL, 0, 0);
@@ -99,10 +108,12 @@ static int name_enter(void)
 
         gui_space(id);
         gui_keyboard(id);
+        gui_space(id);
 
         if ((jd = gui_harray(id)))
         {
             enter_id = gui_start(jd, _("OK"), GUI_SML, NAME_OK, 0);
+            gui_space(jd);
             gui_state(jd, _("Cancel"), GUI_SML, NAME_CANCEL, 0);
         }
 
@@ -116,10 +127,29 @@ static int name_enter(void)
 
 static void name_leave(int id)
 {
+    if (draw_back)
+        back_free();
+
     SDL_EnableUNICODE(0);
     gui_delete(id);
 }
 
+static void name_paint(int id, float t)
+{
+    if (draw_back)
+    {
+        config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
+        {
+            back_draw(0);
+        }
+        config_pop_matrix();
+    }
+    else
+        game_draw(0, t);
+
+    gui_paint(id);
+}
+
 static int name_keybd(int c, int d)
 {
     if (d)
@@ -128,7 +158,7 @@ static int name_keybd(int c, int d)
 
         if (c == '\b' || c == 0x7F)
             return name_action(GUI_BS);
-        if (c > ' ')
+        if (c >= ' ')
             return name_action(c);
     }
     return 1;
@@ -142,9 +172,10 @@ static int name_buttn(int b, int d)
         {
             int c = gui_token(gui_click());
 
-            /* Ugh.  This is such a hack. */
-
-            return name_action(isupper(c) ? gui_keyboard_char(c) : c);
+            if (c >= 0 && !GUI_ISMSK(c))
+                return name_action(gui_keyboard_char(c));
+            else
+                return name_action(c);
         }
         if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
             name_action(NAME_CANCEL);
@@ -157,10 +188,11 @@ static int name_buttn(int b, int d)
 struct state st_name = {
     name_enter,
     name_leave,
-    shared_paint,
+    name_paint,
     shared_timer,
     shared_point,
     shared_stick,
+    shared_angle,
     shared_click,
     name_keybd,
     name_buttn,