Moves game load progress update function from GameSetup to CGUIManager.
This was SVN commit r26150.
This commit is contained in:
parent
7b8c66ec9f
commit
8347c94e3a
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -32,11 +32,16 @@
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
#include "scriptinterface/StructuredClone.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const CStr EVENT_NAME_GAME_LOAD_PROGRESS = "GameLoadProgress";
|
||||
const CStr EVENT_NAME_WINDOW_RESIZED = "WindowResized";
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
CGUIManager* g_GUI = nullptr;
|
||||
|
||||
const CStr CGUIManager::EventNameWindowResized = "WindowResized";
|
||||
|
||||
|
||||
// General TODOs:
|
||||
//
|
||||
// A lot of the CGUI data could (and should) be shared between
|
||||
@ -383,7 +388,7 @@ void CGUIManager::UpdateResolution()
|
||||
for (const SGUIPage& p : pageStack)
|
||||
{
|
||||
p.gui->UpdateResolution();
|
||||
p.gui->SendEventToAll(EventNameWindowResized);
|
||||
p.gui->SendEventToAll(EVENT_NAME_WINDOW_RESIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,6 +406,22 @@ const CParamNode& CGUIManager::GetTemplate(const std::string& templateName)
|
||||
return templateRoot;
|
||||
}
|
||||
|
||||
void CGUIManager::DisplayLoadProgress(int percent, const wchar_t* pending_task)
|
||||
{
|
||||
const ScriptInterface& scriptInterface = *(GetActiveGUI()->GetScriptInterface());
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValueVector paramData(rq.cx);
|
||||
|
||||
ignore_result(paramData.append(JS::NumberValue(percent)));
|
||||
|
||||
JS::RootedValue valPendingTask(rq.cx);
|
||||
Script::ToJSVal(rq, &valPendingTask, pending_task);
|
||||
ignore_result(paramData.append(valPendingTask));
|
||||
|
||||
SendEventToAll(EVENT_NAME_GAME_LOAD_PROGRESS, paramData);
|
||||
}
|
||||
|
||||
// This returns a shared_ptr to make sure the CGUI doesn't get deallocated
|
||||
// while we're in the middle of calling a function on it (e.g. if a GUI script
|
||||
// calls SwitchPage)
|
||||
|
@ -123,6 +123,11 @@ public:
|
||||
*/
|
||||
const CParamNode& GetTemplate(const std::string& templateName);
|
||||
|
||||
/**
|
||||
* Display progress / description in loading screen.
|
||||
*/
|
||||
void DisplayLoadProgress(int percent, const wchar_t* pending_task);
|
||||
|
||||
private:
|
||||
struct SGUIPage
|
||||
{
|
||||
@ -161,8 +166,6 @@ private:
|
||||
std::shared_ptr<JS::PersistentRootedValue> callbackFunction;
|
||||
};
|
||||
|
||||
const static CStr EventNameWindowResized;
|
||||
|
||||
std::shared_ptr<CGUI> top() const;
|
||||
|
||||
std::shared_ptr<ScriptContext> m_ScriptContext;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -342,7 +342,7 @@ static int ProgressiveLoad()
|
||||
CancelLoad(CStr(e.what()).FromUTF8());
|
||||
}
|
||||
|
||||
GUI_DisplayLoadProgress(progress_percent, description);
|
||||
g_GUI->DisplayLoadProgress(progress_percent, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -117,8 +117,6 @@ thread_local std::shared_ptr<ScriptContext> g_ScriptContext;
|
||||
|
||||
static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code
|
||||
|
||||
static const CStr g_EventNameGameLoadProgress = "GameLoadProgress";
|
||||
|
||||
bool g_InDevelopmentCopy;
|
||||
bool g_CheckedIfInDevelopmentCopy = false;
|
||||
|
||||
@ -184,23 +182,6 @@ retry:
|
||||
// GUI integration
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// display progress / description in loading screen
|
||||
void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task)
|
||||
{
|
||||
const ScriptInterface& scriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface());
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValueVector paramData(rq.cx);
|
||||
|
||||
ignore_result(paramData.append(JS::NumberValue(percent)));
|
||||
|
||||
JS::RootedValue valPendingTask(rq.cx);
|
||||
Script::ToJSVal(rq, &valPendingTask, pending_task);
|
||||
ignore_result(paramData.append(valPendingTask));
|
||||
|
||||
g_GUI->SendEventToAll(g_EventNameGameLoadProgress, paramData);
|
||||
}
|
||||
|
||||
bool ShouldRender()
|
||||
{
|
||||
return !g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen());
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -29,9 +29,6 @@ class Paths;
|
||||
// GUI integration
|
||||
//
|
||||
|
||||
// display progress / description in loading screen
|
||||
extern void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task);
|
||||
|
||||
extern void Render();
|
||||
|
||||
extern bool ShouldRender();
|
||||
|
Loading…
Reference in New Issue
Block a user