added setup option for upcoming new name selection screen
[rocksndiamonds.git] / src / screens.c
index 421238bebf31da5c0e423d6764cb15d1efe4b75d..040a45c56a47dbdadc2d61af9d8d63be172c2889 100644 (file)
@@ -252,6 +252,7 @@ static void DrawChooseLevelSet(void);
 static void DrawChooseLevelNr(void);
 static void DrawInfoScreen(void);
 static void DrawSetupScreen(void);
+static void DrawTypeName(void);
 
 static void DrawInfoScreen_NotAvailable(char *, char *);
 static void DrawInfoScreen_HelpAnim(int, int, boolean);
@@ -540,7 +541,9 @@ static int align_yoffset = 0;
 #define DRAW_MODE(s)           ((s) >= GAME_MODE_MAIN &&               \
                                 (s) <= GAME_MODE_SETUP ? (s) :         \
                                 (s) == GAME_MODE_PSEUDO_TYPENAME ?     \
-                                GAME_MODE_MAIN : GAME_MODE_DEFAULT)
+                                GAME_MODE_MAIN :                       \
+                                (s) == GAME_MODE_PSEUDO_TYPENAMES ?    \
+                                GAME_MODE_NAMES : GAME_MODE_DEFAULT)
 
 // (there are no draw offset definitions needed for INFO_MODE_TITLE)
 #define DRAW_MODE_INFO(i)      ((i) >= INFO_MODE_TITLE &&              \
@@ -680,6 +683,8 @@ static char *main_text_title_1                      = NULL;
 static char *main_text_title_2                 = NULL;
 static char *main_text_title_3                 = NULL;
 
+extern char debug_xsn_mode[];
+
 struct MainControlInfo
 {
   int nr;
@@ -2078,7 +2083,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        {
          SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
 
-         HandleTypeName(strlen(setup.player_name), 0);
+         DrawTypeName();
        }
       }
       else if (pos == MAIN_CONTROL_LEVELS)
@@ -3692,6 +3697,10 @@ static void DrawInfoScreen_Version(void)
 
   DrawTextF(xstart1, ystart, font_head, "Source date");
   DrawTextF(xstart2, ystart, font_text, getSourceDateString());
+  ystart += ystep_line;
+
+  DrawTextF(xstart1, ystart, font_head, "Commit hash");
+  DrawTextF(xstart2, ystart, font_text, getSourceHashString());
   ystart += ystep_para;
 
   DrawTextF(xstart1, ystart, font_head, "Library");
@@ -3954,7 +3963,7 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
 // type name functions
 // ============================================================================
 
-void HandleTypeName(int newxpos, Key key)
+static void HandleTypeNameExt(boolean initialize, Key key)
 {
   static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
   struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
@@ -3971,11 +3980,11 @@ void HandleTypeName(int newxpos, Key key)
 
   DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
 
-  if (newxpos)
+  if (initialize)
   {
     strcpy(last_player_name, setup.player_name);
 
-    xpos = newxpos;
+    xpos = strlen(setup.player_name);
 
     StartTextInput(startx, starty, pos->width, pos->height);
   }
@@ -4028,6 +4037,16 @@ void HandleTypeName(int newxpos, Key key)
   }
 }
 
+static void DrawTypeName(void)
+{
+  HandleTypeNameExt(TRUE, 0);
+}
+
+void HandleTypeName(Key key)
+{
+  HandleTypeNameExt(FALSE, key);
+}
+
 
 // ============================================================================
 // tree menu functions
@@ -6290,6 +6309,7 @@ static struct TokenInfo setup_info_game[] =
   { TYPE_PLAYER,       &setup.network_player_nr,"Preferred Network Player:" },
   { TYPE_TEXT_INPUT,   execGadgetNetworkServer, "Network Server Hostname:" },
   { TYPE_STRING,       &network_server_text,   ""                      },
+  { TYPE_SWITCH,       &setup.multiple_users,  "Multiple Users/Teams:" },
   { TYPE_YES_NO,       &setup.input_on_focus,  "Only Move Focussed Player:" },
   { TYPE_SWITCH,       &setup.time_limit,      "Time Limit:"           },
   { TYPE_SWITCH,       &setup.handicap,        "Handicap:"             },
@@ -6387,6 +6407,7 @@ static struct TokenInfo setup_info_graphics[] =
   { TYPE_SWITCH,       &setup.show_titlescreen,"Show Title Screens:"   },
   { TYPE_SWITCH,       &setup.toons,           "Show Menu Animations:" },
   { TYPE_SWITCH,       &setup.small_game_graphics, "Small Game Graphics:" },
+  { TYPE_YES_NO_AUTO,  &setup.debug.xsn_mode,  debug_xsn_mode          },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -6757,6 +6778,10 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
 
     if (startx + font_xoffset < text_startx + text_width + text_font_xoffset)
     {
+      // when using narrow font, left-shifting text "auto" not needed
+      if (type & TYPE_YES_NO_AUTO)
+       xpos += 1;
+
       xpos += 1;
       startx = mSX + xpos * 32;
 
@@ -7543,7 +7568,7 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
   Event event;
   int alpha = 200, alpha_step = -1;
   int alpha_ticks = 0;
-  char mapping[4096], temp[4096];
+  char mapping[4096], temp[256];
   int font_name = MENU_SETUP_FONT_TITLE;
   int font_info = MENU_SETUP_FONT_TEXT;
   int spacing_name = menu.line_spacing_setup[SETUP_MODE_INPUT];
@@ -8714,7 +8739,7 @@ static void CreateScreenMenubuttons(void)
                      GDI_END);
 
     if (gi == NULL)
-      Error(ERR_EXIT, "cannot create gadget");
+      Fail("cannot create gadget");
 
     screen_gadget[id] = gi;
   }
@@ -8782,7 +8807,7 @@ static void CreateScreenScrollbuttons(void)
                      GDI_END);
 
     if (gi == NULL)
-      Error(ERR_EXIT, "cannot create gadget");
+      Fail("cannot create gadget");
 
     screen_gadget[id] = gi;
   }
@@ -8863,7 +8888,7 @@ static void CreateScreenScrollbars(void)
                      GDI_END);
 
     if (gi == NULL)
-      Error(ERR_EXIT, "cannot create gadget");
+      Fail("cannot create gadget");
 
     screen_gadget[id] = gi;
   }
@@ -8909,7 +8934,7 @@ static void CreateScreenTextInputGadgets(void)
                      GDI_END);
 
     if (gi == NULL)
-      Error(ERR_EXIT, "cannot create gadget");
+      Fail("cannot create gadget");
 
     screen_gadget[id] = gi;
   }