Permalink
Browse files

fix #6086

  • Loading branch information...
rt
rt committed Nov 21, 2018
1 parent 89b4773 commit 2b68b17dcf8973cded077a33e0d55a6574b6ad0d
Showing with 25 additions and 14 deletions.
  1. +8 −7 rts/Game/UI/MouseHandler.cpp
  2. +7 −3 rts/Game/UI/MouseHandler.h
  3. +9 −3 rts/Menu/LuaMenuController.cpp
  4. +1 −1 rts/Menu/LuaMenuController.h
@@ -145,6 +145,8 @@ void CMouseHandler::ReloadCursors()
cursorCommandMap.reserve(32);
cursorFileMap.clear();
cursorFileMap.reserve(32);
activeCursorName.clear();
queuedCursorName.clear();
cursorCommandMap["none"] = loadedCursors.size() - 1;
cursorFileMap["null"] = loadedCursors.size() - 1;
@@ -612,7 +614,7 @@ std::string CMouseHandler::GetCurrentTooltip() const
void CMouseHandler::Update()
{
SetCursor(newCursor);
SetCursor(queuedCursorName);
if (!hideCursor)
return;
@@ -717,26 +719,25 @@ void CMouseHandler::ToggleHwCursor(bool enable)
}
// force hardware cursor rebinding, otherwise we get a standard b&w cursor
cursorText = "none";
activeCursorName = "none";
}
/******************************************************************************/
void CMouseHandler::ChangeCursor(const std::string& cmdName, const float scale)
{
newCursor = cmdName;
queuedCursorName = cmdName;
cursorScale = scale;
}
void CMouseHandler::SetCursor(const std::string& cmdName, const bool forceRebind)
{
if ((cursorText == cmdName) && !forceRebind)
if ((activeCursorName == cmdName) && !forceRebind)
return;
cursorText = cmdName;
const auto it = cursorCommandMap.find(cmdName);
const auto it = cursorCommandMap.find(activeCursorName = cmdName);
if (it != cursorCommandMap.end()) {
activeCursorIdx = it->second;
@@ -973,7 +974,7 @@ bool CMouseHandler::ReplaceMouseCursor(
// update current cursor if necessary
if (activeCursorIdx == fileIt->second)
SetCursor(cursorText, true);
SetCursor(activeCursorName, true);
return true;
}
@@ -28,6 +28,10 @@ class CMouseHandler
void ChangeCursor(const std::string& cmdName, const float scale = 1.0f);
void ReloadCursors();
void ResetCursor() {
ChangeCursor("");
Update();
}
void Update();
void UpdateCursors();
@@ -67,7 +71,7 @@ class CMouseHandler
std::string GetCurrentTooltip() const;
const std::string& GetCurrentCursor() const { return newCursor; }
const std::string& GetCurrentCursor() const { return queuedCursorName; }
float GetCurrentCursorScale() const { return cursorScale; }
void ToggleHwCursor(bool enable);
@@ -143,8 +147,8 @@ class CMouseHandler
float3 dir;
private:
std::string newCursor; /// cursor changes are delayed
std::string cursorText; /// current cursor name
std::string queuedCursorName; /// cursor changes are delayed until Update
std::string activeCursorName; /// current cursor name
std::vector<CMouseCursor> loadedCursors;
spring::unordered_map<std::string, size_t> cursorFileMap;
@@ -39,14 +39,20 @@ CLuaMenuController::~CLuaMenuController()
}
void CLuaMenuController::Reset()
bool CLuaMenuController::Reset()
{
if (!Valid())
return;
if (!Valid()) {
// if no LuaMenu, cursor will not be updated (again) until game exists so force a reset
// calling ReloadCursors here is not possible since no archives are loaded at this point
mouse->ResetCursor();
return false;
}
LOG("[LuaMenuController::%s] using menu archive \"%s\"", __func__, menuArchive.c_str());
vfsHandler->AddArchiveWithDeps(menuArchive, false);
mouse->ReloadCursors();
return true;
}
bool CLuaMenuController::Activate(const std::string& msg)
@@ -13,7 +13,7 @@ class CLuaMenuController : public CGameController
~CLuaMenuController();
// Reloads the archives but not LuaMenu
void Reset();
bool Reset();
bool Activate(const std::string& msg);
static bool ActivateInstance(const std::string& msg);

0 comments on commit 2b68b17

Please sign in to comment.