Merge branch 'template_train_replacement-sx' into jgrpp
# Conflicts: # src/window.cpp
This commit is contained in:
@@ -81,6 +81,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.
|
||||
*/
|
||||
@@ -254,7 +257,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 {
|
||||
@@ -1044,7 +1047,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 {
|
||||
@@ -1670,13 +1673,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
|
||||
@@ -1715,7 +1716,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)
|
||||
@@ -1769,7 +1770,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;
|
||||
@@ -1782,6 +1783,11 @@ struct MainToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPlaceObjectAbort()
|
||||
{
|
||||
_last_started_action = CBF_NONE;
|
||||
}
|
||||
|
||||
virtual void OnTick()
|
||||
{
|
||||
if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
|
||||
@@ -1994,13 +2000,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);
|
||||
@@ -2059,7 +2063,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)
|
||||
@@ -2068,7 +2072,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);
|
||||
}
|
||||
|
||||
@@ -2100,13 +2104,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;
|
||||
@@ -2119,6 +2123,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);
|
||||
|
Reference in New Issue
Block a user