if (leveldir_current->node_parent->node_group->cl_first == -1)
{
int num_leveldirs = numTreeInfoInGroup(leveldir_current);
- int leveldir_pos = posTreeInfo(leveldir_current);
+ int leveldir_pos = getPosFromTreeInfo(leveldir_current);
int num_page_entries = MIN(num_leveldirs, NUM_MENU_ENTRIES_ON_SCREEN);
int cl_first, cl_cursor;
static TreeInfo *type_name_node = NULL;
static char type_name_last[MAX_PLAYER_NAME_LEN + 1] = { 0 };
+static int type_name_nr = 0;
static void drawTypeNameText(char *name, struct TextPosInfo *pos,
boolean active)
int font_width = getFontWidth(pos->font);
type_name_node = getTreeInfoFromPos(node_first, entry_pos);
+ type_name_nr = entry_pos;
strcpy(name, type_name_node->name);
}
else
{
+ type_name_nr = user.nr;
+
strcpy(name, setup.player_name);
}
}
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
- boolean success)
+ boolean changed)
{
TreeInfo *node = type_name_node;
- if (!success)
+ if (!changed)
strcpy(name, type_name_last);
if (strEqual(name, ""))
if (node == NULL) // should not happen
return;
- if (success)
+ if (changed)
node->color = (strEqual(name, EMPTY_PLAYER_NAME) ? FC_BLUE : FC_RED);
pos->font = (node->color == FC_RED ? FONT_INPUT_1 : FONT_VALUE_OLD);
}
- if (!success)
- return;
-
+ // if player name not changed, no further action required
if (strEqual(name, type_name_last))
return;
int last_user_nr = user.nr;
+ // change name of edited user in global list of user names
+ setString(&global.user_names[type_name_nr], name);
+
if (setup.multiple_users)
{
- int edit_user_nr = posTreeInfo(node);
-
- // change name of edited user in global list of user names
- setString(&global.user_names[edit_user_nr], name);
-
// change name of edited user in local menu tree structure
setString(&node->name, name);
setString(&node->name_sorting, name);
SaveSetup();
// temporarily change active user to edited user
- user.nr = edit_user_nr;
+ user.nr = type_name_nr;
// load setup of edited user
LoadSetup();
struct TextPosInfo *pos = &pos_name;
char key_char = getValidConfigValueChar(getCharFromKey(key));
boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
- boolean is_active = TRUE;
+ boolean active = TRUE;
if (initialize)
{
{
setTypeNameValues(name, pos, TRUE);
- is_active = FALSE;
+ active = FALSE;
}
else if (key == KSYM_Escape)
{
setTypeNameValues(name, pos, FALSE);
- is_active = FALSE;
+ active = FALSE;
}
- drawTypeNameText(name, pos, is_active);
+ drawTypeNameText(name, pos, active);
- if (!is_active)
+ if (!active)
{
StopTextInput();
SetGameStatus(game_status_last_screen);
+
+ if (game_status == GAME_MODE_MAIN)
+ InitializeMainControls();
}
}
if (button == MB_MENU_INITIALIZE)
{
int num_entries = numTreeInfoInGroup(ti);
- int entry_pos = posTreeInfo(ti);
+ int entry_pos = getPosFromTreeInfo(ti);
align_xoffset = getAlignXOffsetFromTreeInfo(ti);
align_yoffset = getAlignYOffsetFromTreeInfo(ti);