mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-31 08:04:36 +01:00
Codechange: Allow to set cursor directly.
This commit is contained in:
committed by
rubidium42
parent
2de2c5d31d
commit
d17f662490
15
src/gfx.cpp
15
src/gfx.cpp
@@ -25,6 +25,7 @@
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "viewport_func.h"
|
||||
|
||||
#include "table/animcursors.h"
|
||||
#include "table/string_colours.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/control_codes.h"
|
||||
@@ -1725,6 +1726,20 @@ void SetAnimatedMouseCursor(std::span<const AnimCursor> table)
|
||||
SwitchAnimatedCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign an animation or a non-animated sprite to the cursor.
|
||||
* @param icon New shape of the mouse cursor.
|
||||
* @param pal Palette to use.
|
||||
*/
|
||||
void SetCursor(CursorID icon, PaletteID pal)
|
||||
{
|
||||
if ((icon & ANIMCURSOR_FLAG) != 0) {
|
||||
SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]);
|
||||
} else {
|
||||
SetMouseCursor(icon, pal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cursor position based on a relative change.
|
||||
*
|
||||
|
||||
@@ -170,6 +170,7 @@ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
|
||||
void SetMouseCursorBusy(bool busy);
|
||||
void SetMouseCursor(CursorID cursor, PaletteID pal);
|
||||
void SetAnimatedMouseCursor(std::span<const AnimCursor> table);
|
||||
void SetCursor(CursorID cursor, PaletteID pal);
|
||||
void CursorTick();
|
||||
void UpdateCursorSize();
|
||||
bool ChangeResInGame(int w, int h);
|
||||
|
||||
@@ -3567,12 +3567,7 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
|
||||
VpStartPreSizing();
|
||||
}
|
||||
|
||||
if ((icon & ANIMCURSOR_FLAG) != 0) {
|
||||
SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]);
|
||||
} else {
|
||||
SetMouseCursor(icon, pal);
|
||||
}
|
||||
|
||||
SetCursor(icon, pal);
|
||||
}
|
||||
|
||||
/** Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows). */
|
||||
|
||||
Reference in New Issue
Block a user