2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:47:42 +00:00

Simplify findCVar

This commit is contained in:
2015-11-22 00:01:51 -08:00
parent 9c053b53e8
commit b7fda5a620
3 changed files with 28 additions and 17 deletions

View File

@@ -3,33 +3,43 @@
#include <Specter/Specter.hpp>
#include <Runtime/CVarManager.hpp>
#include <Runtime/CGameAllocator.hpp>
#include <functional>
namespace RUDE
{
struct Application : boo::IApplicationCallback
{
Retro::CGameAllocator m_allocator;
HECL::Runtime::FileStoreManager m_fileMgr;
Specter::FontCache m_fontCache;
Specter::RootView m_rootView;
Retro::CVarManager m_cvarManager;
boo::IWindow* m_mainWindow;
Zeus::CColor m_clearColor;
bool m_running = true;
Application() : m_fileMgr(_S("rude")), m_fontCache(m_fileMgr), m_rootView(m_fontCache), m_cvarManager(m_fileMgr, true){}
void onCVarModified(Retro::CVar* cvar)
{
if (cvar == m_cvarManager.findCVar("r_clearColor"))
m_clearColor = cvar->toColor();
}
Application() : m_fileMgr(_S("rude")), m_fontCache(m_fileMgr), m_rootView(m_fontCache), m_cvarManager(m_fileMgr){}
int appMain(boo::IApplication* app)
{
m_allocator.Initialize();
m_mainWindow = app->newWindow(_S("RUDE"));
m_rootView.setWindow(m_mainWindow, 1.0f);
m_cvarManager.serialize();
Retro::CVar* tmp = m_cvarManager.findCVar("r_clearcolor");
Retro::CVar::ListenerFunc listen = std::bind(&Application::onCVarModified, this, std::placeholders::_1);
if (tmp)
tmp->addListener(listen);
while (m_running)
{
m_cvarManager.update();
m_mainWindow->waitForRetrace();
}