X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=f9815ee33678683db95065ffcd5aeae30be29df8;hb=44da8ca05994d2dcbaea2ad2e1d945bfa0005575;hp=dcbac9163a4c5329b020f8398dda7cff395a65b4;hpb=636b164453fcb8011d360427e0ae486bf692743d;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index dcbac916..f9815ee3 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4076,11 +4076,11 @@ static void getTypeNameValues(char *name, struct TextPosInfo *pos, int *xpos) } 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, "")) @@ -4091,15 +4091,13 @@ static void setTypeNameValues(char *name, struct TextPosInfo *pos, 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; @@ -4147,19 +4145,18 @@ static void HandleTypeNameExt(boolean initialize, Key key) static struct TextPosInfo pos_name = { 0 }; static char name[MAX_PLAYER_NAME_LEN + 1] = { 0 }; static int xpos = 0; - - if (initialize) - getTypeNameValues(name, &pos_name, &xpos); - struct TextPosInfo *pos = &pos_name; - int sx = mSX + ALIGNED_TEXT_XPOS(pos); - int sy = mSY + ALIGNED_TEXT_YPOS(pos); 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) { + getTypeNameValues(name, pos, &xpos); + + int sx = mSX + ALIGNED_TEXT_XPOS(pos); + int sy = mSY + ALIGNED_TEXT_YPOS(pos); + StartTextInput(sx, sy, pos->width, pos->height); } else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN) @@ -4179,22 +4176,25 @@ static void HandleTypeNameExt(boolean initialize, Key key) { 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(); } }