2015-12-05 17:27:02 -08:00
|
|
|
#include "ViewManager.hpp"
|
2015-12-07 20:27:35 -08:00
|
|
|
#include "Specter/Control.hpp"
|
2015-12-11 16:37:32 -08:00
|
|
|
#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"
|
2015-12-05 17:27:02 -08:00
|
|
|
|
2015-12-10 18:37:54 -08:00
|
|
|
using YAMLNode = Athena::io::YAMLNode;
|
|
|
|
|
2015-12-05 17:27:02 -08:00
|
|
|
namespace RUDE
|
|
|
|
{
|
|
|
|
|
2015-12-11 16:37:32 -08:00
|
|
|
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);
|
2015-12-11 16:37:32 -08:00
|
|
|
sspace->setContentView(sview);
|
|
|
|
if (space->usesToolbar())
|
2016-01-03 21:31:02 -08:00
|
|
|
space->buildToolbarView(m_viewResources, sspace->toolbar());
|
2015-12-11 16:37:32 -08:00
|
|
|
return sspace;
|
|
|
|
}
|
|
|
|
|
2015-12-05 17:27:02 -08:00
|
|
|
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-05 17:27:02 -08:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-12-05 17:27:02 -08: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-12 18:27:34 -08:00
|
|
|
float pixelFactor = 1.0;
|
2015-12-05 17:27:02 -08:00
|
|
|
|
|
|
|
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());
|
2015-12-05 17:27:02 -08:00
|
|
|
SetupRootView();
|
2015-12-12 18:27:34 -08:00
|
|
|
SetupSplashView();
|
2015-12-05 17:27:02 -08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-12-05 17:27:02 -08:00
|
|
|
m_rootView->dispatchEvents();
|
2015-12-12 18:27:34 -08:00
|
|
|
if (m_showSplash)
|
|
|
|
m_splash->think();
|
2015-12-05 17:27:02 -08:00
|
|
|
m_rootView->draw(gfxQ);
|
|
|
|
gfxQ->execute();
|
|
|
|
m_mainWindow->waitForRetrace();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::stop()
|
|
|
|
{
|
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|