Re #641: Empties new player name when clicked
Empties new player name editbox when clicked, so it won't show 'Enter Name' Note however, that if leaved blank, it stores the new player with name '-- No One --' git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4921 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 755171f00988e601a2c85369b170fb68f7ec0e98 Former-commit-id: 31acab93bf8004029065d9d5d03ac4ff66966cf7
This commit is contained in:
parent
71c483f42d
commit
a3feefa02a
1 changed files with 27 additions and 4 deletions
|
@ -143,7 +143,7 @@ public:
|
||||||
{
|
{
|
||||||
if (_info.dispname)
|
if (_info.dispname)
|
||||||
delete[] _info.dispname;
|
delete[] _info.dispname;
|
||||||
if (!dispname || strlen(dispname) == 0)
|
if (!dispname)
|
||||||
dispname = NoPlayer;
|
dispname = NoPlayer;
|
||||||
_info.dispname = new char[strlen(dispname)+1];
|
_info.dispname = new char[strlen(dispname)+1];
|
||||||
strcpy(_info.dispname, dispname); // Can't use strdup : free crashes in destructor !?
|
strcpy(_info.dispname, dispname); // Can't use strdup : free crashes in destructor !?
|
||||||
|
@ -713,7 +713,30 @@ onChangeName(void * /* dummy */)
|
||||||
strIn.assign(NoPlayer); // If it was all whitespace, assign default
|
strIn.assign(NoPlayer); // If it was all whitespace, assign default
|
||||||
}
|
}
|
||||||
|
|
||||||
(*CurrPlayer)->setDispName(strIn == PlayerNamePrompt ? NoPlayer : strIn.c_str());
|
(*CurrPlayer)->setDispName((strIn == PlayerNamePrompt || strIn == NoPlayer) ? NoPlayer : strIn.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdtScrollList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#641 New player name should get empty when clicking on it
|
||||||
|
// In the Player Configuration menu, when you create
|
||||||
|
// a new player, his name is set to "-- Enter name --",
|
||||||
|
// as a prompt for changing it.
|
||||||
|
// But when you want to change it, you have to first erase
|
||||||
|
// this prompt string all.
|
||||||
|
// Would be great if the prompt string disappear when clicked.
|
||||||
|
// Note(kilo): this way if one clicks the player name editbox
|
||||||
|
// and leaves without entering anything, the new player will be called
|
||||||
|
// "--No Player--" and stored with that name.
|
||||||
|
static void
|
||||||
|
onActivateName(void * /* dummy */)
|
||||||
|
{
|
||||||
|
std::string strIn = GfuiEditboxGetString(ScrHandle, NameEditId);
|
||||||
|
if (strIn == PlayerNamePrompt) {
|
||||||
|
(*CurrPlayer)->setDispName("");
|
||||||
|
GfuiEditboxSetString(ScrHandle, NameEditId, (*CurrPlayer)->dispName());
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdtScrollList();
|
UpdtScrollList();
|
||||||
|
@ -872,7 +895,7 @@ PlayerConfigMenuInit(void *prevMenu)
|
||||||
GfuiMenuCreateButtonControl(ScrHandle, param, "controls", NULL, onConfControls);
|
GfuiMenuCreateButtonControl(ScrHandle, param, "controls", NULL, onConfControls);
|
||||||
|
|
||||||
/* Player name editbox */
|
/* Player name editbox */
|
||||||
NameEditId = GfuiMenuCreateEditControl(ScrHandle, param, "nameedit", NULL, NULL, onChangeName);
|
NameEditId = GfuiMenuCreateEditControl(ScrHandle, param, "nameedit", NULL, onActivateName, onChangeName);
|
||||||
|
|
||||||
/* Player skill level "combobox" (left arrow, label, right arrow) */
|
/* Player skill level "combobox" (left arrow, label, right arrow) */
|
||||||
GfuiMenuCreateButtonControl(ScrHandle, param, "skillleftarrow", (void*)0, onChangeLevel);
|
GfuiMenuCreateButtonControl(ScrHandle, param, "skillleftarrow", (void*)0, onChangeLevel);
|
||||||
|
|
Loading…
Reference in a new issue