summaryrefslogtreecommitdiff
path: root/main_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-12-30 01:17:53 +0000
committerDarkvater <darkvater@openttd.org>2006-12-30 01:17:53 +0000
commitc87fcab77216fa2a3c8a5a334c32099665b1241d (patch)
tree4ef6719359384448b5674c8f954ba1a88987d16d /main_gui.c
parented2c8ecef5f2a6d62273ebccf0f82bad1f73ea4a (diff)
downloadopenttd-c87fcab77216fa2a3c8a5a334c32099665b1241d.tar.xz
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
query has no parent (eg give money, rename waypoint), the global function HandleOnEditText is used.
Diffstat (limited to 'main_gui.c')
-rw-r--r--main_gui.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/main_gui.c b/main_gui.c
index ad28e506b..bf991e88f 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -54,27 +54,23 @@ extern void GenerateIndustries(void);
extern bool GenerateTowns(void);
-void HandleOnEditText(WindowEvent *e)
+void HandleOnEditText(const char *str)
{
- const char *b = e->we.edittext.str;
- int id;
-
- _cmd_text = b;
-
- id = _rename_id;
+ int id = _rename_id;
+ _cmd_text = str;
switch (_rename_what) {
case 0: /* Rename a s sign, if string is empty, delete sign */
DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME));
break;
case 1: /* Rename a waypoint */
- if (*b == '\0') return;
+ if (*str == '\0') return;
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
break;
#ifdef ENABLE_NETWORK
case 3: { /* Give money, you can only give money in excess of loan */
const Player *p = GetPlayer(_current_player);
- int32 money = min(p->money64 - p->current_loan, atoi(e->we.edittext.str) / _currency->rate);
+ int32 money = min(p->money64 - p->current_loan, atoi(str) / _currency->rate);
char msg[20];
money = clamp(money, 0, 20000000); // Clamp between 20 million and 0
@@ -311,7 +307,7 @@ void ShowNetworkGiveMoneyWindow(PlayerID player)
{
_rename_id = player;
_rename_what = 3;
- ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0, CS_NUMERAL);
+ ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL);
}
#endif /* ENABLE_NETWORK */
@@ -319,7 +315,7 @@ void ShowRenameSignWindow(const Sign *si)
{
_rename_id = si->index;
_rename_what = 0;
- ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, 1, 0, CS_ALPHANUMERAL);
+ ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, NULL, CS_ALPHANUMERAL);
}
void ShowRenameWaypointWindow(const Waypoint *wp)
@@ -336,7 +332,7 @@ void ShowRenameWaypointWindow(const Waypoint *wp)
_rename_id = id;
_rename_what = 1;
SetDParam(0, id);
- ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, 1, 0, CS_ALPHANUMERAL);
+ ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL);
}
static void SelectSignTool(void)
@@ -1837,8 +1833,6 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w);
} break;
- case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
-
case WE_MOUSELOOP:
if (IsWindowWidgetLowered(w, 0) != !!_pause) {
ToggleWidgetLoweredState(w, 0);
@@ -2038,8 +2032,6 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w);
} break;
- case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
-
case WE_MOUSELOOP:
if (IsWindowWidgetLowered(w, 0) != !!_pause) {
ToggleWidgetLoweredState(w, 0);