metaforce/Editor/ViewManager.cpp

119 lines
3.1 KiB
C++
Raw Normal View History

#include "ViewManager.hpp"
2015-12-07 20:27:35 -08:00
#include "Specter/Control.hpp"
#include "Specter/Space.hpp"
2015-12-23 19:32:21 -08:00
#include "SplashScreen.hpp"
2015-12-30 19:20:52 -08:00
#include "locale/locale.hpp"
using YAMLNode = Athena::io::YAMLNode;
namespace RUDE
{
Specter::View* ViewManager::BuildSpaceViews(RUDE::Space* space)
{
2016-01-03 21:31:02 -08:00
Specter::Space* sspace = space->buildSpaceView(m_viewResources);
Specter::View* sview = space->buildContentView(m_viewResources);
sspace->setContentView(sview);
if (space->usesToolbar())
2016-01-03 21:31:02 -08:00
space->buildToolbarView(m_viewResources, sspace->toolbar());
return sspace;
}
void ViewManager::SetupRootView()
{
m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get()));
2015-12-12 18:27:34 -08: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();
2016-01-03 21:31:02 -08:00
m_showSplash = true;
2015-12-12 18:27:34 -08:00
}
void ViewManager::SetupEditorView()
{
2016-01-03 21:31:02 -08:00
m_rootSpace.reset(new SplitSpace(*this));
m_rootView->setContentView(BuildSpaceViews(m_rootSpace.get()));
m_rootView->updateSize();
m_showSplash = false;
}
void ViewManager::SetupEditorView(Athena::io::YAMLDocReader& r)
{
m_rootSpace.reset(Space::NewSpaceFromYAMLStream(*this, r));
m_rootView->setContentView(BuildSpaceViews(m_rootSpace.get()));
2015-12-08 17:04:50 -08:00
m_rootView->updateSize();
2016-01-03 21:31:02 -08:00
m_showSplash = false;
}
2015-12-12 18:27:34 -08:00
ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
2016-01-03 21:31:02 -08:00
: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this),
m_fontCache(fileMgr), m_translator(RUDE::SystemLocaleOrEnglish())
2015-12-12 18:27:34 -08:00
{}
ViewManager::~ViewManager() {}
2016-01-01 18:27:46 -08:00
void ViewManager::pushRecentProject(const HECL::SystemString& path)
{
m_recentProjects.push_back(path);
}
void ViewManager::pushRecentFile(const HECL::SystemString& path)
{
m_recentFiles.push_back(path);
}
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-12 18:27:34 -08:00
float pixelFactor = 1.0;
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
2015-12-07 17:49:54 -08:00
m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor);
2015-12-12 18:27:34 -08:00
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
SetupRootView();
2015-12-12 18:27:34 -08:00
SetupSplashView();
m_mainWindow->setWaitCursor(false);
}
bool ViewManager::proc()
{
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
if (m_rootView->isDestroyed())
return false;
2015-12-08 17:04:50 -08:00
if (m_updatePf)
{
m_viewResources.resetPixelFactor(m_reqPf);
SetupRootView();
2016-01-03 21:31:02 -08:00
if (m_showSplash)
SetupSplashView();
else
SetupEditorView();
2015-12-08 17:04:50 -08:00
m_updatePf = false;
}
m_rootView->dispatchEvents();
2015-12-12 18:27:34 -08:00
if (m_showSplash)
m_splash->think();
m_rootView->draw(gfxQ);
gfxQ->execute();
m_mainWindow->waitForRetrace();
return true;
}
void ViewManager::stop()
{
m_mainWindow->getCommandQueue()->stopRenderer();
}
}