1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

change hardware cursor to software cursor when joystick available

This commit is contained in:
kdmcser
2024-04-21 11:40:24 +08:00
parent 876bae0b73
commit 60c4ddb515
11 changed files with 80 additions and 2 deletions

View File

@ -57,6 +57,7 @@ CursorHandler::CursorHandler()
cursor->preload();
set(Cursor::Map::POINTER);
showType = dynamic_cast<CursorSoftware *>(cursor.get()) ? Cursor::ShowType::SOFTWARE : Cursor::ShowType::HARDWARE;
}
CursorHandler::~CursorHandler() = default;
@ -290,3 +291,32 @@ void CursorHandler::show()
cursor->setVisible(true);
}
Cursor::ShowType CursorHandler::getShowType()
{
return showType;
}
void CursorHandler::ChangeCursor(Cursor::ShowType showType)
{
if(this->showType == showType)
return;
switch(showType)
{
case Cursor::ShowType::SOFTWARE:
cursor.reset(new CursorSoftware());
showType = Cursor::ShowType::SOFTWARE;
cursor->setImage(getCurrentImage(), getPivotOffset());
break;
case Cursor::ShowType::HARDWARE:
cursor.reset(new CursorHardware());
showType = Cursor::ShowType::HARDWARE;
cursor->setImage(getCurrentImage(), getPivotOffset());
break;
}
}
const Point & CursorHandler::getCursorPosition()
{
return cursor->getCursorPosition();
}