Auto-select last used tool when user cancels build action, only for roads now

This commit is contained in:
pelya
2014-11-12 03:25:09 +02:00
parent 5934a69f67
commit fdddd873dd
6 changed files with 32 additions and 1 deletions

View File

@@ -2943,6 +2943,9 @@ void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Wind
#include "table/animcursors.h"
static WindowClass _last_selected_window_class;
static WindowNumber _last_selected_window_number;
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
{
if (_thd.window_class != WC_INVALID) {
@@ -2989,9 +2992,20 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
void ResetObjectToPlace()
{
if (_thd.window_class != WC_INVALID) {
_last_selected_window_class = _thd.window_class;
_last_selected_window_number = _thd.window_number;
}
SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
}
void ToolbarSelectLastTool()
{
Window *w = FindWindowById(_last_selected_window_class, _last_selected_window_number);
if (w != NULL) w->SelectLastTool();
_last_selected_window_class = WC_INVALID;
}
Point GetViewportStationMiddle(const ViewPort *vp, const Station *st)
{
int x = TileX(st->xy) * TILE_SIZE;