diff options
author | frosch <frosch@openttd.org> | 2016-08-15 18:32:48 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2016-08-15 18:32:48 +0000 |
commit | 4d1843a95e26a64ff3ff0b967d721794dbf0fe46 (patch) | |
tree | 45cc7785faf095e617ca096deb1d9d7ff0cfbde6 /src | |
parent | ca6493f2e638fe528107eb88d8be83815b5110b3 (diff) | |
download | openttd-4d1843a95e26a64ff3ff0b967d721794dbf0fe46.tar.xz |
(svn r27627) -Codechange: Deduplicate some cursor magic into SetMouseCursorBusy.
Diffstat (limited to 'src')
-rw-r--r-- | src/genworld.cpp | 2 | ||||
-rw-r--r-- | src/genworld_gui.cpp | 2 | ||||
-rw-r--r-- | src/gfx.cpp | 13 | ||||
-rw-r--r-- | src/gfx_func.h | 1 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 4 |
5 files changed, 18 insertions, 4 deletions
diff --git a/src/genworld.cpp b/src/genworld.cpp index 88e1b84a5..2b2dfb5fd 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -77,7 +77,7 @@ static void CleanupGeneration() { _generating_world = false; - if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE); + SetMouseCursorBusy(false); /* Show all vital windows again, because we have hidden them */ if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows(); SetModalProgress(false); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index ad64ae802..741fd75d1 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -1190,7 +1190,7 @@ struct GenerateProgressWindow : public Window { { switch (widget) { case WID_GP_ABORT: - if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE); + SetMouseCursorBusy(false); ShowQuery( STR_GENERATION_ABORT_CAPTION, STR_GENERATION_ABORT_MESSAGE, diff --git a/src/gfx.cpp b/src/gfx.cpp index f3a98461d..909f6729e 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1573,6 +1573,19 @@ void CursorTick() } /** + * Set or unset the ZZZ cursor. + * @param busy Whether to show the ZZZ cursor. + */ +void SetMouseCursorBusy(bool busy) +{ + if (busy) { + if (_cursor.sprite == SPR_CURSOR_MOUSE) SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE); + } else { + if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE); + } +} + +/** * Assign a single non-animated sprite to the cursor. * @param sprite Sprite to draw for the cursor. * @param pal Palette to use for recolouring. diff --git a/src/gfx_func.h b/src/gfx_func.h index 6576dee4f..973e15f2b 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -145,6 +145,7 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int heigh /* window.cpp */ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); +void SetMouseCursorBusy(bool busy); void SetMouseCursor(CursorID cursor, PaletteID pal); void SetAnimatedMouseCursor(const AnimCursor *table); void CursorTick(); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 724bc649b..3d6f3c494 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2460,7 +2460,7 @@ static void SaveFileStart() { _sl.ff_state = _fast_forward; _fast_forward = 0; - if (_cursor.sprite == SPR_CURSOR_MOUSE) SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE); + SetMouseCursorBusy(true); InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START); _sl.saveinprogress = true; @@ -2470,7 +2470,7 @@ static void SaveFileStart() static void SaveFileDone() { if (_game_mode != GM_MENU) _fast_forward = _sl.ff_state; - if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE); + SetMouseCursorBusy(false); InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH); _sl.saveinprogress = false; |