summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-08-15 18:32:25 +0000
committerfrosch <frosch@openttd.org>2016-08-15 18:32:25 +0000
commitca6493f2e638fe528107eb88d8be83815b5110b3 (patch)
tree937cc5d114065f9da068647ec6d9b2fb9b3e1691 /src
parentf7a0ee9a158d4fad242e87b19f036908b43e9f30 (diff)
downloadopenttd-ca6493f2e638fe528107eb88d8be83815b5110b3.tar.xz
(svn r27626) -Codechange: Do not use the cursor sprite as PlaceObject status in the main toolbar.
Diffstat (limited to 'src')
-rw-r--r--src/toolbar_gui.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 45d751dc5..40c75ad71 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -79,6 +79,9 @@ enum CallBackFunction {
CBF_PLACE_LANDINFO,
};
+static CallBackFunction _last_started_action = CBF_NONE; ///< Last started user action.
+
+
/**
* Drop down list entry for showing a checked/unchecked toggle item.
*/
@@ -247,7 +250,7 @@ static ToolbarMode _toolbar_mode;
static CallBackFunction SelectSignTool()
{
- if (_cursor.sprite == SPR_CURSOR_SIGN) {
+ if (_last_started_action == CBF_PLACE_SIGN) {
ResetObjectToPlace();
return CBF_NONE;
} else {
@@ -1031,7 +1034,7 @@ static CallBackFunction MenuClickNewspaper(int index)
static CallBackFunction PlaceLandBlockInfo()
{
- if (_cursor.sprite == SPR_CURSOR_QUERY) {
+ if (_last_started_action == CBF_PLACE_LANDINFO) {
ResetObjectToPlace();
return CBF_NONE;
} else {
@@ -1656,13 +1659,11 @@ enum MainToolbarHotkeys {
/** Main toolbar. */
struct MainToolbarWindow : Window {
- CallBackFunction last_started_action; ///< Last started user action.
-
MainToolbarWindow(WindowDesc *desc) : Window(desc)
{
this->InitNested(0);
- this->last_started_action = CBF_NONE;
+ _last_started_action = CBF_NONE;
CLRBITS(this->flags, WF_WHITE_BORDER);
this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
@@ -1701,7 +1702,7 @@ struct MainToolbarWindow : Window {
virtual void OnDropdownSelect(int widget, int index)
{
CallBackFunction cbf = _menu_clicked_procs[widget](index);
- if (cbf != CBF_NONE) this->last_started_action = cbf;
+ if (cbf != CBF_NONE) _last_started_action = cbf;
}
virtual EventState OnHotkey(int hotkey)
@@ -1754,7 +1755,7 @@ struct MainToolbarWindow : Window {
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
- switch (this->last_started_action) {
+ switch (_last_started_action) {
case CBF_PLACE_SIGN:
PlaceProc_Sign(tile);
break;
@@ -1767,6 +1768,11 @@ struct MainToolbarWindow : Window {
}
}
+ virtual void OnPlaceObjectAbort()
+ {
+ _last_started_action = CBF_NONE;
+ }
+
virtual void OnTick()
{
if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
@@ -1978,13 +1984,11 @@ enum MainToolbarEditorHotkeys {
};
struct ScenarioEditorToolbarWindow : Window {
- CallBackFunction last_started_action; ///< Last started user action.
-
ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc)
{
this->InitNested(0);
- this->last_started_action = CBF_NONE;
+ _last_started_action = CBF_NONE;
CLRBITS(this->flags, WF_WHITE_BORDER);
PositionMainToolbar(this);
DoZoomInOutWindow(ZOOM_NONE, this);
@@ -2043,7 +2047,7 @@ struct ScenarioEditorToolbarWindow : Window {
{
if (_game_mode == GM_MENU) return;
CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
- if (cbf != CBF_NONE) this->last_started_action = cbf;
+ if (cbf != CBF_NONE) _last_started_action = cbf;
}
virtual void OnDropdownSelect(int widget, int index)
@@ -2052,7 +2056,7 @@ struct ScenarioEditorToolbarWindow : Window {
* editor toolbar, so we need to adjust for it. */
if (widget == WID_TE_SMALL_MAP) widget = WID_TN_SMALL_MAP;
CallBackFunction cbf = _menu_clicked_procs[widget](index);
- if (cbf != CBF_NONE) this->last_started_action = cbf;
+ if (cbf != CBF_NONE) _last_started_action = cbf;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
}
@@ -2084,13 +2088,13 @@ struct ScenarioEditorToolbarWindow : Window {
case MTEHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
default: return ES_NOT_HANDLED;
}
- if (cbf != CBF_NONE) this->last_started_action = cbf;
+ if (cbf != CBF_NONE) _last_started_action = cbf;
return ES_HANDLED;
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
- switch (this->last_started_action) {
+ switch (_last_started_action) {
case CBF_PLACE_SIGN:
PlaceProc_Sign(tile);
break;
@@ -2103,6 +2107,11 @@ struct ScenarioEditorToolbarWindow : Window {
}
}
+ virtual void OnPlaceObjectAbort()
+ {
+ _last_started_action = CBF_NONE;
+ }
+
virtual void OnTimeout()
{
this->SetWidgetsLoweredState(false, WID_TE_DATE_BACKWARD, WID_TE_DATE_FORWARD, WIDGET_LIST_END);