Reset the cursor when opening new GUI pages. Patch by danger89, refs #539.

Remove duplicate cursor image and duplicate hardcoded default paths.

This was SVN commit r18933.
This commit is contained in:
elexis 2016-11-14 13:23:07 +00:00
parent 29e809f3e9
commit 34ce0f865d
13 changed files with 30 additions and 12 deletions

Binary file not shown.

View File

@ -24,6 +24,5 @@ function cancelOnError(msg)
});
}
// Reset cursor
Engine.SetCursor("arrow-default");
Engine.ResetCursor();
}

View File

@ -52,6 +52,7 @@
{"nick": "dan", "name": "Dan Strandberg"},
{"name": "Daniel Trevitz"},
{"nick": "DanCar", "name": "Daniel Cardenas"},
{"nick": "danger89", "name": "Melroy van den Berg"},
{"nick": "Dave", "name": "David Protasowski"},
{"nick": "dax", "name": "Dacian Fiordean"},
{"nick": "deebee", "name": "Deepak Anthony"},

View File

@ -103,6 +103,5 @@ function reallyStartGame()
// Switch GUI from loading screen to game session.
Engine.SwitchGuiPage("page_session.xml", g_Data);
// Restore default cursor.
Engine.SetCursor("arrow-default");
Engine.ResetCursor();
}

View File

@ -79,7 +79,8 @@ function updateCursorAndTooltip()
}
if (!cursorSet)
Engine.SetCursor("arrow-default");
Engine.ResetCursor();
if (!tooltipSet)
informationTooltip.hidden = true;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -26,6 +26,7 @@
#include "ps/CLogger.h"
#include "ps/Profile.h"
#include "ps/XML/Xeromyces.h"
#include "ps/GameSetup/Config.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRuntime.h"
@ -97,6 +98,8 @@ void CGUIManager::PushPage(const CStrW& pageName, shared_ptr<ScriptInterface::St
m_PageStack.back().name = pageName;
m_PageStack.back().initData = initData;
LoadPage(m_PageStack.back());
ResetCursor();
}
void CGUIManager::PopPage()
@ -299,6 +302,11 @@ Status CGUIManager::ReloadAllPages()
return INFO::OK;
}
void CGUIManager::ResetCursor()
{
g_CursorName = g_DefaultCursor;
}
std::string CGUIManager::GetSavedGameData()
{
shared_ptr<ScriptInterface> scriptInterface = top()->GetScriptInterface();

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -92,6 +92,11 @@ public:
*/
Status ReloadChangedFile(const VfsPath& path);
/**
* Sets the default mouse pointer.
*/
void ResetCursor();
/**
* Called when we should reload all pages (e.g. translation hotloading update).
*/

View File

@ -113,6 +113,11 @@ void PopGuiPageCB(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args)
g_GUI->PopPageCB(pCxPrivate->pScriptInterface->WriteStructuredClone(args));
}
void ResetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
{
g_GUI->ResetCursor();
}
JS::Value GuiInterfaceCall(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue data)
{
if (!g_Game)
@ -1016,6 +1021,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<void, &PopGuiPage>("PopGuiPage");
scriptInterface.RegisterFunction<void, JS::HandleValue, &PopGuiPageCB>("PopGuiPageCB");
scriptInterface.RegisterFunction<JS::Value, CStr, &GetGUIObjectByName>("GetGUIObjectByName");
scriptInterface.RegisterFunction<void, &ResetCursor>("ResetCursor");
// Simulation<->GUI interface functions:
scriptInterface.RegisterFunction<JS::Value, std::wstring, JS::HandleValue, &GuiInterfaceCall>("GuiInterfaceCall");

View File

@ -27,7 +27,9 @@
// (these variables are documented in the header.)
CStrW g_CursorName = L"test";
const wchar_t g_DefaultCursor[] = L"default-arrow";
CStrW g_CursorName = g_DefaultCursor;
bool g_NoGLS3TC = false;
bool g_NoGLAutoMipmap = false;

View File

@ -92,6 +92,7 @@ extern bool g_Quickstart;
extern bool g_DisableAudio;
extern CStrW g_CursorName;
extern const wchar_t g_DefaultCursor[];
class CmdLineArgs;
extern void CONFIG_Init(const CmdLineArgs& args);