projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moved variable from local to file scope
[rocksndiamonds.git]
/
src
/
screens.c
diff --git
a/src/screens.c
b/src/screens.c
index dcbac9163a4c5329b020f8398dda7cff395a65b4..e9be137bb2ccf9a6c4e340ef1a8ffd4406241cc6 100644
(file)
--- a/
src/screens.c
+++ b/
src/screens.c
@@
-4018,6
+4018,7
@@
void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
static TreeInfo *type_name_node = NULL;
static char type_name_last[MAX_PLAYER_NAME_LEN + 1] = { 0 };
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)
static void drawTypeNameText(char *name, struct TextPosInfo *pos,
boolean active)
@@
-4076,11
+4077,11
@@
static void getTypeNameValues(char *name, struct TextPosInfo *pos, int *xpos)
}
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
}
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
- boolean
success
)
+ boolean
changed
)
{
TreeInfo *node = type_name_node;
{
TreeInfo *node = type_name_node;
- if (!
success
)
+ if (!
changed
)
strcpy(name, type_name_last);
if (strEqual(name, ""))
strcpy(name, type_name_last);
if (strEqual(name, ""))
@@
-4091,15
+4092,13
@@
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
if (node == NULL) // should not happen
return;
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);
}
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;
if (strEqual(name, type_name_last))
return;
@@
-4107,10
+4106,10
@@
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
if (setup.multiple_users)
{
if (setup.multiple_users)
{
-
int edit_user
_nr = posTreeInfo(node);
+
type_name
_nr = posTreeInfo(node);
// change name of edited user in global list of user names
// change name of edited user in global list of user names
- setString(&global.user_names[
edit_user
_nr], name);
+ setString(&global.user_names[
type_name
_nr], name);
// change name of edited user in local menu tree structure
setString(&node->name, name);
// change name of edited user in local menu tree structure
setString(&node->name, name);
@@
-4120,7
+4119,7
@@
static void setTypeNameValues(char *name, struct TextPosInfo *pos,
SaveSetup();
// temporarily change active user to edited user
SaveSetup();
// temporarily change active user to edited user
- user.nr =
edit_user
_nr;
+ user.nr =
type_name
_nr;
// load setup of edited user
LoadSetup();
// load setup of edited user
LoadSetup();
@@
-4147,19
+4146,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;
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;
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));
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)
{
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)
StartTextInput(sx, sy, pos->width, pos->height);
}
else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
@@
-4179,22
+4177,25
@@
static void HandleTypeNameExt(boolean initialize, Key key)
{
setTypeNameValues(name, pos, TRUE);
{
setTypeNameValues(name, pos, TRUE);
-
is_
active = FALSE;
+ active = FALSE;
}
else if (key == KSYM_Escape)
{
setTypeNameValues(name, pos, 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);
{
StopTextInput();
SetGameStatus(game_status_last_screen);
+
+ if (game_status == GAME_MODE_MAIN)
+ InitializeMainControls();
}
}
}
}