2015-12-06 01:27:02 +00:00
|
|
|
#include "ViewManager.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "specter/Control.hpp"
|
|
|
|
#include "specter/Space.hpp"
|
|
|
|
#include "specter/Menu.hpp"
|
2015-12-24 03:32:21 +00:00
|
|
|
#include "SplashScreen.hpp"
|
2015-12-31 03:20:52 +00:00
|
|
|
#include "locale/locale.hpp"
|
2016-01-07 00:40:27 +00:00
|
|
|
#include "ResourceBrowser.hpp"
|
2016-01-18 23:33:23 +00:00
|
|
|
#include "icons/icons.hpp"
|
2016-07-16 19:21:12 +00:00
|
|
|
#include "badging/Badging.hpp"
|
2016-02-17 05:20:34 +00:00
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CElectricDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
2016-04-09 23:19:17 +00:00
|
|
|
#include "Runtime/Character/CSkinRules.hpp"
|
2016-08-03 21:53:03 +00:00
|
|
|
#include "Graphics/CMetroidModelInstance.hpp"
|
2016-08-17 04:59:05 +00:00
|
|
|
#include "World/CWorldTransManager.hpp"
|
2016-08-17 06:18:18 +00:00
|
|
|
#include "Graphics/Shaders/CColoredQuadFilter.hpp"
|
|
|
|
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
|
2017-01-17 01:23:19 +00:00
|
|
|
#include "Audio/CStreamAudioManager.hpp"
|
2018-05-10 02:56:54 +00:00
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
2016-01-16 03:58:11 +00:00
|
|
|
#include <cstdio>
|
2015-12-06 01:27:02 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
using YAMLNode = athena::io::YAMLNode;
|
2015-12-11 02:37:54 +00:00
|
|
|
|
2018-01-02 01:04:23 +00:00
|
|
|
extern hecl::SystemString ExeDir;
|
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
namespace urde
|
2015-12-06 01:27:02 +00:00
|
|
|
{
|
|
|
|
|
2017-10-22 06:11:22 +00:00
|
|
|
void ViewManager::InitMP1(MP1::CMain& main)
|
2016-02-18 02:42:32 +00:00
|
|
|
{
|
2018-01-15 16:00:20 +00:00
|
|
|
main.Init(m_fileStoreManager, &m_cvarManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
|
2017-11-12 05:14:57 +00:00
|
|
|
if (!m_noShaderWarmup)
|
|
|
|
main.WarmupShaders();
|
2017-10-22 06:11:22 +00:00
|
|
|
|
2017-09-14 12:42:20 +00:00
|
|
|
m_testGameView.reset(new TestGameView(*this, m_viewResources, *m_rootView));
|
2016-03-28 21:38:48 +00:00
|
|
|
|
2017-01-22 06:28:55 +00:00
|
|
|
m_rootView->accessContentViews().clear();
|
2017-01-22 21:26:58 +00:00
|
|
|
m_rootView->accessContentViews().push_back(m_testGameView.get());
|
2016-02-18 02:42:32 +00:00
|
|
|
m_rootView->updateSize();
|
|
|
|
}
|
|
|
|
|
2017-01-22 21:26:58 +00:00
|
|
|
void ViewManager::TestGameView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
2016-02-18 02:42:32 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::View::resized(root, sub);
|
|
|
|
urde::CGraphics::SetViewportResolution({sub.size[0], sub.size[1]});
|
2018-05-10 02:56:54 +00:00
|
|
|
if (m_debugText)
|
2018-05-14 03:38:36 +00:00
|
|
|
{
|
|
|
|
boo::SWindowRect newSub = sub;
|
|
|
|
newSub.location[1] = 5 * m_vm.m_viewResources.pixelFactor();
|
|
|
|
m_debugText->resized(root, newSub);
|
|
|
|
}
|
2016-02-18 02:42:32 +00:00
|
|
|
}
|
|
|
|
|
2017-03-17 23:33:02 +00:00
|
|
|
void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
2016-02-18 02:42:32 +00:00
|
|
|
{
|
2017-03-18 05:12:27 +00:00
|
|
|
m_vm.m_projManager.mainDraw();
|
2018-05-10 02:56:54 +00:00
|
|
|
if (m_debugText && g_StateManager && g_StateManager->Player())
|
|
|
|
m_debugText->draw(gfxQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::TestGameView::think()
|
|
|
|
{
|
|
|
|
if (!m_debugText)
|
2018-05-14 03:38:36 +00:00
|
|
|
{
|
|
|
|
m_debugText.reset(
|
2018-06-04 19:15:35 +00:00
|
|
|
new specter::MultiLineTextView(m_vm.m_viewResources, *this, m_vm.m_viewResources.m_monoFont18));
|
2018-05-14 03:38:36 +00:00
|
|
|
boo::SWindowRect sub = subRect();
|
|
|
|
sub.location[1] = 5 * m_vm.m_viewResources.pixelFactor();
|
|
|
|
m_debugText->resized(rootView().subRect(), sub);
|
|
|
|
}
|
2018-05-10 02:56:54 +00:00
|
|
|
|
2018-06-04 19:15:35 +00:00
|
|
|
if (m_debugText && g_StateManager)
|
2018-05-10 02:56:54 +00:00
|
|
|
{
|
2018-06-04 19:15:35 +00:00
|
|
|
std::string overlayText;
|
|
|
|
const hecl::CVar* showFrameIdx = hecl::CVarManager::instance()->findCVar("debugOverlay.showFrameCounter");
|
|
|
|
const hecl::CVar* playerInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.playerInfo");
|
|
|
|
const hecl::CVar* worldInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.worldInfo");
|
|
|
|
const hecl::CVar* areaInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.areaInfo");
|
|
|
|
if (showFrameIdx && showFrameIdx->toBoolean())
|
|
|
|
overlayText += hecl::Format("Frame: %d\n",
|
|
|
|
g_StateManager->GetUpdateFrameIndex());
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-06-04 19:15:35 +00:00
|
|
|
if (g_StateManager->Player() && playerInfo && playerInfo->toBoolean())
|
|
|
|
{
|
|
|
|
const CPlayer& pl = g_StateManager->GetPlayer();
|
|
|
|
zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f());
|
2018-06-28 01:17:01 +00:00
|
|
|
zeus::CTransform camXf = g_StateManager->GetCameraManager()->GetCurrentCameraTransform(*g_StateManager);
|
|
|
|
zeus::CQuaternion camQ = zeus::CQuaternion(camXf.getRotation().buildMatrix3f());
|
2018-06-04 19:15:35 +00:00
|
|
|
overlayText += hecl::Format("Player Position: x %f, y %f, z %f\n"
|
2018-06-28 01:17:01 +00:00
|
|
|
" Quaternion: w %f, x %f, y %f, z %f\n"
|
|
|
|
"Camera Position: x %f, y %f, z %f\n"
|
2018-06-04 19:15:35 +00:00
|
|
|
" Quaternion: w %f, x %f, y %f, z %f\n",
|
2018-06-28 01:17:01 +00:00
|
|
|
pl.GetTranslation().x, pl.GetTranslation().y, pl.GetTranslation().z,
|
|
|
|
plQ.w, plQ.x, plQ.y, plQ.z,
|
|
|
|
camXf.origin.x, camXf.origin.y, camXf.origin.z,
|
|
|
|
camQ.w, camQ.x, camQ.y, camQ.z);
|
2018-06-04 19:15:35 +00:00
|
|
|
}
|
|
|
|
if (worldInfo && worldInfo->toBoolean())
|
|
|
|
{
|
|
|
|
TLockedToken<CStringTable> tbl =
|
|
|
|
g_SimplePool->GetObj({FOURCC('STRG'), g_StateManager->GetWorld()->IGetStringTableAssetId()});
|
|
|
|
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
|
|
|
|
overlayText += hecl::Format("World: 0x%08X%s, Area: %i\n",
|
|
|
|
u32(g_GameState->CurrentWorldAssetId().Value()),
|
|
|
|
(tbl.IsLoaded() ? (" " + hecl::Char16ToUTF8(tbl->GetString(0))).c_str() : ""), aId);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-06-04 19:15:35 +00:00
|
|
|
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
|
|
|
|
if (areaInfo && areaInfo->toBoolean() && g_StateManager->WorldNC() && g_StateManager->WorldNC()->DoesAreaExist(aId))
|
2018-05-14 03:38:36 +00:00
|
|
|
{
|
2018-06-04 19:15:35 +00:00
|
|
|
const auto& layerStates = g_GameState->CurrentWorldState().GetLayerState();
|
|
|
|
std::string layerBits;
|
|
|
|
u32 totalActive = 0;
|
|
|
|
for (u32 i = 0; i < layerStates->GetAreaLayerCount(aId); ++i)
|
2018-05-14 03:38:36 +00:00
|
|
|
{
|
2018-06-04 19:15:35 +00:00
|
|
|
if (layerStates->IsLayerActive(aId, i))
|
|
|
|
{
|
|
|
|
++totalActive;
|
|
|
|
layerBits += "1";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
layerBits += "0";
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-06-04 19:15:35 +00:00
|
|
|
overlayText += hecl::Format("Area AssetId: 0x%08X, Total Objects: %i, Total Layers: %i, Total Active Layers: %i\n"
|
|
|
|
"Active Layer bits: %s\n",
|
2018-06-12 01:16:27 +00:00
|
|
|
(unsigned int)g_StateManager->WorldNC()->GetArea(aId)->GetAreaAssetId().Value(),
|
2018-06-04 19:15:35 +00:00
|
|
|
g_StateManager->GetAllObjectList().size(), layerStates->GetAreaLayerCount(aId),
|
|
|
|
totalActive, layerBits.c_str());
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-06-04 19:15:35 +00:00
|
|
|
if (!overlayText.empty())
|
|
|
|
m_debugText->typesetGlyphs(overlayText);
|
2018-05-10 02:56:54 +00:00
|
|
|
}
|
2016-02-18 02:42:32 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::View* ViewManager::BuildSpaceViews()
|
2015-12-12 00:37:32 +00:00
|
|
|
{
|
2016-01-11 02:17:08 +00:00
|
|
|
m_rootSpaceView = m_rootSpace->buildSpaceView(m_viewResources);
|
2016-01-05 00:01:02 +00:00
|
|
|
return m_rootSpaceView;
|
2015-12-12 00:37:32 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::RootView* ViewManager::SetupRootView()
|
2015-12-06 01:27:02 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
m_rootView.reset(new specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
|
|
|
m_rootView->setBackground(zeus::CColor::skBlack);
|
2016-01-05 00:01:02 +00:00
|
|
|
return m_rootView.get();
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 00:01:02 +00:00
|
|
|
SplashScreen* ViewManager::SetupSplashView()
|
2015-12-13 02:27:34 +00:00
|
|
|
{
|
|
|
|
m_splash.reset(new SplashScreen(*this, m_viewResources));
|
2016-01-05 00:01:02 +00:00
|
|
|
if (!m_showSplash)
|
|
|
|
m_splash->close(true);
|
|
|
|
return m_splash.get();
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-05-14 03:38:36 +00:00
|
|
|
void ViewManager::RootSpaceViewBuilt(specter::View* view)
|
2016-01-11 02:17:08 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
std::vector<specter::View*>& cViews = m_rootView->accessContentViews();
|
2016-01-11 02:17:08 +00:00
|
|
|
cViews.clear();
|
|
|
|
cViews.push_back(view);
|
|
|
|
cViews.push_back(m_splash.get());
|
|
|
|
m_rootView->updateSize();
|
|
|
|
}
|
|
|
|
|
2016-03-07 03:12:32 +00:00
|
|
|
void ViewManager::ProjectChanged(hecl::Database::Project& proj)
|
|
|
|
{
|
|
|
|
CDvdFile::Shutdown();
|
2018-03-28 08:09:41 +00:00
|
|
|
CDvdFile::Initialize(hecl::ProjectPath(proj.getProjectWorkingPath(), _S("out/files")));
|
2016-03-07 03:12:32 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 02:27:34 +00:00
|
|
|
void ViewManager::SetupEditorView()
|
|
|
|
{
|
2016-01-10 06:42:58 +00:00
|
|
|
m_rootSpace.reset(new RootSpace(*this));
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
SplitSpace* split = new SplitSpace(*this, nullptr, specter::SplitView::Axis::Horizontal);
|
2016-01-10 06:42:58 +00:00
|
|
|
m_rootSpace->setChild(std::unique_ptr<Space>(split));
|
|
|
|
split->setChildSlot(0, std::make_unique<ResourceBrowser>(*this, split));
|
|
|
|
split->setChildSlot(1, std::make_unique<ResourceBrowser>(*this, split));
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2016-01-11 02:17:08 +00:00
|
|
|
BuildSpaceViews();
|
2016-01-04 05:31:02 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 00:01:02 +00:00
|
|
|
void ViewManager::SetupEditorView(ConfigReader& r)
|
2016-01-04 05:31:02 +00:00
|
|
|
{
|
2016-01-10 06:42:58 +00:00
|
|
|
m_rootSpace.reset(Space::NewRootSpaceFromConfigStream(*this, r));
|
2016-01-11 02:17:08 +00:00
|
|
|
BuildSpaceViews();
|
2016-01-05 00:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::SaveEditorView(ConfigWriter& w)
|
|
|
|
{
|
|
|
|
if (!m_rootSpace)
|
|
|
|
return;
|
|
|
|
m_rootSpace->saveState(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::DismissSplash()
|
|
|
|
{
|
|
|
|
if (!m_showSplash)
|
|
|
|
return;
|
2016-01-04 05:31:02 +00:00
|
|
|
m_showSplash = false;
|
2016-01-05 00:01:02 +00:00
|
|
|
m_splash->close();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr)
|
2018-05-14 03:38:36 +00:00
|
|
|
: m_fileStoreManager(fileMgr)
|
|
|
|
, m_cvarManager(cvarMgr)
|
|
|
|
, m_projManager(*this)
|
|
|
|
, m_fontCache(fileMgr)
|
|
|
|
, m_translator(urde::SystemLocaleOrEnglish())
|
|
|
|
, m_recentProjectsPath(hecl::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().data()))
|
|
|
|
, m_recentFilesPath(hecl::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().data()))
|
2016-01-16 03:58:11 +00:00
|
|
|
{
|
2016-02-01 20:04:55 +00:00
|
|
|
Space::SpaceMenuNode::InitializeStrings(*this);
|
2016-01-16 03:58:11 +00:00
|
|
|
char path[2048];
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::Sstat theStat;
|
2016-01-16 03:58:11 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
FILE* fp = hecl::Fopen(m_recentProjectsPath.c_str(), _S("r"), hecl::FileLockType::Read);
|
2016-01-16 03:58:11 +00:00
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
while (fgets(path, 2048, fp))
|
|
|
|
{
|
|
|
|
std::string pathStr(path);
|
|
|
|
pathStr.pop_back();
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv pathStrView(pathStr);
|
2016-03-04 23:04:53 +00:00
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
2017-11-13 06:19:18 +00:00
|
|
|
m_recentProjects.emplace_back(pathStrView.sys_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
fp = hecl::Fopen(m_recentFilesPath.c_str(), _S("r"), hecl::FileLockType::Read);
|
2016-01-16 03:58:11 +00:00
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
while (fgets(path, 2048, fp))
|
|
|
|
{
|
|
|
|
std::string pathStr(path);
|
|
|
|
pathStr.pop_back();
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv pathStrView(pathStr);
|
2016-03-04 23:04:53 +00:00
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
2017-11-13 06:19:18 +00:00
|
|
|
m_recentFiles.emplace_back(pathStrView.sys_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
|
|
|
|
ViewManager::~ViewManager() {}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void ViewManager::pushRecentProject(hecl::SystemStringView path)
|
2016-01-02 02:27:46 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
for (hecl::SystemString& testPath : m_recentProjects)
|
2016-01-16 03:58:11 +00:00
|
|
|
{
|
|
|
|
if (path == testPath)
|
|
|
|
return;
|
|
|
|
}
|
2017-11-13 06:19:18 +00:00
|
|
|
m_recentProjects.emplace_back(path);
|
2016-03-04 23:04:53 +00:00
|
|
|
FILE* fp = hecl::Fopen(m_recentProjectsPath.c_str(), _S("w"), hecl::FileLockType::Write);
|
2016-01-16 03:58:11 +00:00
|
|
|
if (fp)
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
for (hecl::SystemString& pPath : m_recentProjects)
|
2017-11-13 06:19:18 +00:00
|
|
|
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void ViewManager::pushRecentFile(hecl::SystemStringView path)
|
2016-01-02 02:27:46 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
for (hecl::SystemString& testPath : m_recentFiles)
|
2016-01-16 03:58:11 +00:00
|
|
|
{
|
|
|
|
if (path == testPath)
|
|
|
|
return;
|
|
|
|
}
|
2017-11-13 06:19:18 +00:00
|
|
|
m_recentFiles.emplace_back(path);
|
2016-03-04 23:04:53 +00:00
|
|
|
FILE* fp = hecl::Fopen(m_recentFilesPath.c_str(), _S("w"), hecl::FileLockType::Write);
|
2016-01-16 03:58:11 +00:00
|
|
|
if (fp)
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
for (hecl::SystemString& pPath : m_recentFiles)
|
2017-11-13 06:19:18 +00:00
|
|
|
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
fclose(fp);
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
void ViewManager::init(boo::IApplication* app)
|
|
|
|
{
|
2018-01-07 05:19:49 +00:00
|
|
|
m_mainWindow = app->newWindow(_S("URDE"));
|
2015-12-06 01:27:02 +00:00
|
|
|
m_mainWindow->showWindow();
|
|
|
|
m_mainWindow->setWaitCursor(true);
|
|
|
|
|
2016-12-10 02:35:09 +00:00
|
|
|
float pixelFactor = m_mainWindow->getVirtualPixelFactor();
|
2015-12-06 01:27:02 +00:00
|
|
|
|
2016-04-15 20:42:40 +00:00
|
|
|
m_mainBooFactory = m_mainWindow->getMainContextDataFactory();
|
2016-08-05 03:21:19 +00:00
|
|
|
m_mainPlatformName = m_mainBooFactory->platformName();
|
|
|
|
m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]"));
|
2016-04-15 20:42:40 +00:00
|
|
|
m_mainCommandQueue = m_mainWindow->getCommandQueue();
|
|
|
|
m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor);
|
2017-11-05 06:17:12 +00:00
|
|
|
InitializeIcons(m_viewResources);
|
|
|
|
InitializeBadging(m_viewResources);
|
2015-12-13 02:27:34 +00:00
|
|
|
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::RootView* root = SetupRootView();
|
2016-01-05 00:01:02 +00:00
|
|
|
m_showSplash = true;
|
|
|
|
root->accessContentViews().push_back(SetupSplashView());
|
|
|
|
root->updateSize();
|
2016-04-15 20:42:40 +00:00
|
|
|
m_renderTex = root->renderTex();
|
2015-12-06 01:27:02 +00:00
|
|
|
m_mainWindow->setWaitCursor(false);
|
2016-03-24 00:05:56 +00:00
|
|
|
m_voiceEngine = boo::NewAudioVoiceEngine();
|
2017-12-21 03:19:54 +00:00
|
|
|
m_voiceEngine->setVolume(0.7f);
|
2016-09-14 05:54:09 +00:00
|
|
|
m_amuseAllocWrapper.emplace(*m_voiceEngine);
|
2017-01-22 06:28:55 +00:00
|
|
|
|
|
|
|
for (const auto& arg : app->getArgs())
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
if (m_deferedProject.empty() && hecl::SearchForProject(arg))
|
2017-01-22 06:28:55 +00:00
|
|
|
m_deferedProject = arg;
|
2017-11-12 05:14:57 +00:00
|
|
|
if (arg == _S("--no-shader-warmup"))
|
|
|
|
m_noShaderWarmup = true;
|
2017-12-21 03:19:54 +00:00
|
|
|
else if (arg == _S("--no-sound"))
|
|
|
|
m_voiceEngine->setVolume(0.f);
|
2017-01-22 06:28:55 +00:00
|
|
|
}
|
2018-01-02 01:04:23 +00:00
|
|
|
|
|
|
|
if (m_deferedProject.empty())
|
|
|
|
{
|
|
|
|
/* Default behavior - search upwards for packaged project containing the program */
|
|
|
|
if (hecl::ProjectRootPath root = hecl::SearchForProject(ExeDir))
|
|
|
|
{
|
|
|
|
hecl::SystemString rootPath(root.getAbsolutePath());
|
|
|
|
hecl::Sstat theStat;
|
2018-05-14 03:38:36 +00:00
|
|
|
if (!hecl::Stat((rootPath + _S("/out/files/Metroid1.upak")).c_str(), &theStat) && S_ISREG(theStat.st_mode))
|
2018-01-02 01:04:23 +00:00
|
|
|
m_deferedProject = rootPath + _S("/out");
|
|
|
|
}
|
|
|
|
}
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ViewManager::proc()
|
|
|
|
{
|
2017-01-22 06:28:55 +00:00
|
|
|
if (!m_deferedProject.empty() && m_viewResources.fontCacheReady())
|
|
|
|
{
|
|
|
|
m_projManager.openProject(m_deferedProject);
|
|
|
|
m_deferedProject.clear();
|
|
|
|
}
|
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
|
|
|
if (m_rootView->isDestroyed())
|
|
|
|
return false;
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2015-12-09 01:04:50 +00:00
|
|
|
if (m_updatePf)
|
|
|
|
{
|
|
|
|
m_viewResources.resetPixelFactor(m_reqPf);
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::RootView* root = SetupRootView();
|
2016-01-05 00:01:02 +00:00
|
|
|
if (m_rootSpace)
|
2016-01-11 02:17:08 +00:00
|
|
|
BuildSpaceViews();
|
|
|
|
else
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
std::vector<specter::View*>& cViews = m_rootView->accessContentViews();
|
2016-01-11 02:17:08 +00:00
|
|
|
cViews.push_back(SetupSplashView());
|
|
|
|
}
|
2016-01-05 00:01:02 +00:00
|
|
|
root->updateSize();
|
2015-12-09 01:04:50 +00:00
|
|
|
m_updatePf = false;
|
|
|
|
}
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->dispatchEvents();
|
2016-01-31 01:08:31 +00:00
|
|
|
m_rootView->internalThink();
|
2016-01-05 00:01:02 +00:00
|
|
|
if (m_rootSpace)
|
|
|
|
m_rootSpace->think();
|
|
|
|
if (m_splash)
|
2015-12-13 02:27:34 +00:00
|
|
|
m_splash->think();
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2016-01-11 02:17:08 +00:00
|
|
|
if (m_deferSplit)
|
|
|
|
{
|
2016-01-12 00:46:27 +00:00
|
|
|
SplitSpace* ss = static_cast<SplitSpace*>(m_deferSplit->spaceSplit(m_deferSplitAxis, m_deferSplitThisSlot));
|
|
|
|
m_rootView->startSplitDrag(ss->splitView(), m_deferSplitCoord);
|
2016-01-11 02:17:08 +00:00
|
|
|
m_deferSplit = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-05 00:01:02 +00:00
|
|
|
++m_editorFrames;
|
|
|
|
if (m_rootSpaceView && m_editorFrames <= 30)
|
2018-05-14 03:38:36 +00:00
|
|
|
m_rootSpaceView->setMultiplyColor(zeus::CColor::lerp({1, 1, 1, 0}, {1, 1, 1, 1}, m_editorFrames / 30.0));
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2017-03-18 05:12:27 +00:00
|
|
|
m_projManager.mainUpdate();
|
2016-04-15 20:42:40 +00:00
|
|
|
|
2018-06-01 06:38:01 +00:00
|
|
|
if (m_testGameView)
|
|
|
|
m_testGameView->think();
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
if (g_Renderer)
|
|
|
|
g_Renderer->BeginScene();
|
2015-12-06 01:27:02 +00:00
|
|
|
m_rootView->draw(gfxQ);
|
2017-03-14 07:03:58 +00:00
|
|
|
if (g_Renderer)
|
|
|
|
g_Renderer->EndScene();
|
2015-12-06 01:27:02 +00:00
|
|
|
gfxQ->execute();
|
2017-10-26 10:09:51 +00:00
|
|
|
if (g_ResFactory)
|
|
|
|
g_ResFactory->AsyncIdle();
|
2018-08-28 05:44:16 +00:00
|
|
|
m_voiceEngine->pumpAndMixVoices();
|
2018-05-08 05:10:24 +00:00
|
|
|
if (!m_skipWait || !hecl::com_developer->toBoolean())
|
2018-08-28 05:44:16 +00:00
|
|
|
m_mainWindow->waitForRetrace();
|
2016-09-09 04:19:19 +00:00
|
|
|
CBooModel::ClearModelUniformCounters();
|
2016-07-08 06:53:06 +00:00
|
|
|
CGraphics::TickRenderTimings();
|
2017-12-12 02:06:19 +00:00
|
|
|
++logvisor::FrameIndex;
|
2015-12-06 01:27:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewManager::stop()
|
|
|
|
{
|
2016-03-08 07:10:52 +00:00
|
|
|
m_videoVoice.reset();
|
2016-03-28 04:36:55 +00:00
|
|
|
m_projManager.shutdown();
|
2016-03-07 22:48:54 +00:00
|
|
|
CDvdFile::Shutdown();
|
2017-11-05 06:17:12 +00:00
|
|
|
DestroyIcons();
|
|
|
|
DestroyBadging();
|
2016-02-24 21:21:09 +00:00
|
|
|
m_viewResources.destroyResData();
|
|
|
|
m_fontCache.destroyAtlases();
|
2015-12-06 01:27:02 +00:00
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
|
|
|
}
|
|
|
|
|
2018-05-14 03:38:36 +00:00
|
|
|
} // namespace urde
|