2015-12-06 01:27:02 +00:00
|
|
|
#include "ViewManager.hpp"
|
2015-12-08 04:27:35 +00:00
|
|
|
#include "Specter/Control.hpp"
|
2015-12-12 00:37:32 +00:00
|
|
|
#include "Specter/Space.hpp"
|
2015-12-24 03:32:21 +00:00
|
|
|
#include "SplashScreen.hpp"
|
2015-12-06 01:27:02 +00:00
|
|
|
|
2015-12-11 02:37:54 +00:00
|
|
|
using YAMLNode = Athena::io::YAMLNode;
|
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
namespace RUDE
|
|
|
|
{
|
|
|
|
|
2015-12-12 00:37:32 +00:00
|
|
|
Specter::View* ViewManager::BuildSpaceViews(RUDE::Space* space)
|
|
|
|
{
|
|
|
|
Specter::Space* sspace = space->buildSpace(m_viewResources);
|
|
|
|
Specter::View* sview = space->buildContent(m_viewResources);
|
|
|
|
sspace->setContentView(sview);
|
|
|
|
if (space->usesToolbar())
|
|
|
|
space->buildToolbar(m_viewResources, sspace->toolbar());
|
|
|
|
return sspace;
|
|
|
|
}
|
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
void ViewManager::SetupRootView()
|
|
|
|
{
|
|
|
|
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
2015-12-13 02:27:34 +00:00
|
|
|
m_rootView->setBackground(Zeus::CColor::skBlack);
|
|
|
|
m_rootView->updateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::SetupSplashView()
|
|
|
|
{
|
|
|
|
m_splash.reset(new SplashScreen(*this, m_viewResources));
|
|
|
|
m_rootView->setContentView(m_splash.get());
|
|
|
|
m_rootView->updateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::SetupEditorView()
|
|
|
|
{
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->setBackground(Zeus::CColor::skGrey);
|
2015-12-12 00:37:32 +00:00
|
|
|
m_rootView->setContentView(m_split.buildContent(m_viewResources));
|
|
|
|
m_split.m_splitView->setContentView(0, BuildSpaceViews(&m_space1));
|
|
|
|
m_split.m_splitView->setContentView(1, BuildSpaceViews(&m_space2));
|
2015-12-09 01:04:50 +00:00
|
|
|
m_rootView->updateSize();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 02:27:34 +00:00
|
|
|
ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
|
|
|
|
: m_cvarManager(cvarMgr), m_fontCache(fileMgr),
|
|
|
|
m_setTo1(*this), m_setTo2(*this),
|
|
|
|
m_split(*this),
|
|
|
|
m_space1(*this, "Hello, World!\n\n", "Hello Button", &m_setTo1),
|
|
|
|
m_space2(*this, "こんにちは世界!\n\n", "こんにちはボタン", &m_setTo2)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ViewManager::~ViewManager() {}
|
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
void ViewManager::init(boo::IApplication* app)
|
|
|
|
{
|
|
|
|
m_mainWindow = std::unique_ptr<boo::IWindow>(app->newWindow(_S("RUDE")));
|
|
|
|
m_mainWindow->showWindow();
|
|
|
|
m_mainWindow->setWaitCursor(true);
|
|
|
|
|
2015-12-13 02:27:34 +00:00
|
|
|
float pixelFactor = 1.0;
|
2015-12-08 01:49:54 +00:00
|
|
|
m_cvPixelFactor = m_cvarManager.newCVar("ed_pixelfactor", "User-selected UI Scale",
|
|
|
|
pixelFactor, HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive);
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
|
2015-12-08 01:49:54 +00:00
|
|
|
m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor);
|
2015-12-13 02:27:34 +00:00
|
|
|
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
|
2015-12-06 01:27:02 +00:00
|
|
|
SetupRootView();
|
2015-12-13 02:27:34 +00:00
|
|
|
SetupSplashView();
|
|
|
|
m_showSplash = true;
|
2015-12-06 01:27:02 +00:00
|
|
|
|
|
|
|
m_mainWindow->setWaitCursor(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ViewManager::proc()
|
|
|
|
{
|
|
|
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
|
|
|
if (m_rootView->isDestroyed())
|
|
|
|
return false;
|
2015-12-09 01:04:50 +00:00
|
|
|
if (m_updatePf)
|
|
|
|
{
|
|
|
|
m_viewResources.resetPixelFactor(m_reqPf);
|
|
|
|
SetupRootView();
|
|
|
|
m_updatePf = false;
|
|
|
|
}
|
2015-12-08 01:49:54 +00:00
|
|
|
#if 0
|
|
|
|
if (m_cvPixelFactor->isModified())
|
2015-12-06 01:27:02 +00:00
|
|
|
{
|
2015-12-08 01:49:54 +00:00
|
|
|
float pixelFactor = m_cvPixelFactor->toFloat();
|
|
|
|
m_viewResources.resetPixelFactor(pixelFactor);
|
|
|
|
m_cvPixelFactor->clearModified();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
2015-12-08 01:49:54 +00:00
|
|
|
#endif
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->dispatchEvents();
|
2015-12-13 02:27:34 +00:00
|
|
|
if (m_showSplash)
|
|
|
|
m_splash->think();
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->draw(gfxQ);
|
|
|
|
gfxQ->execute();
|
|
|
|
m_mainWindow->waitForRetrace();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::stop()
|
|
|
|
{
|
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|