2015-12-06 01:27:02 +00:00
|
|
|
#include "ViewManager.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#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-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"
|
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"
|
2018-10-07 02:59:17 +00:00
|
|
|
#include "hecl/Pipeline.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;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2015-12-06 01:27:02 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::InitMP1(MP1::CMain& main) {
|
|
|
|
main.Init(m_fileStoreManager, &m_cvarManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
|
|
|
|
if (!m_noShaderWarmup)
|
|
|
|
main.WarmupShaders();
|
2017-10-22 06:11:22 +00:00
|
|
|
|
2020-04-14 19:20:51 +00:00
|
|
|
m_testGameView.reset(new TestGameView(*this, m_viewResources, *m_rootView, m_cvarManager));
|
2016-03-28 21:38:48 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m_rootView->accessContentViews().clear();
|
|
|
|
m_rootView->accessContentViews().push_back(m_testGameView.get());
|
|
|
|
m_rootView->updateSize();
|
2016-02-18 02:42:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::TestGameView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
|
|
|
specter::View::resized(root, sub);
|
|
|
|
urde::CGraphics::SetViewportResolution({sub.size[0], sub.size[1]});
|
|
|
|
if (m_debugText) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue* gfxQ) {
|
|
|
|
m_vm.m_projManager.mainDraw();
|
2019-12-14 23:50:29 +00:00
|
|
|
if (m_debugText)
|
2018-12-08 05:30:43 +00:00
|
|
|
m_debugText->draw(gfxQ);
|
2018-05-10 02:56:54 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::TestGameView::think() {
|
|
|
|
if (!m_debugText) {
|
|
|
|
m_debugText.reset(new specter::MultiLineTextView(m_vm.m_viewResources, *this, m_vm.m_viewResources.m_monoFont18));
|
|
|
|
boo::SWindowRect sub = subRect();
|
|
|
|
sub.location[1] = 5 * m_vm.m_viewResources.pixelFactor();
|
|
|
|
m_debugText->resized(rootView().subRect(), sub);
|
|
|
|
}
|
|
|
|
|
2019-12-14 23:50:29 +00:00
|
|
|
if (m_debugText) {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::string overlayText;
|
2019-12-14 23:50:29 +00:00
|
|
|
if (g_StateManager) {
|
2020-04-14 19:20:51 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayShowFrameCounter->toBoolean())
|
2020-04-11 22:51:39 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("Frame: {}\n"), g_StateManager->GetUpdateFrameIndex());
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2021-01-03 19:00:32 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayShowFramerate->toBoolean())
|
2021-01-24 00:28:22 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("FPS: {}\n"), urde::CGraphics::GetFPS());
|
2021-01-03 19:00:32 +00:00
|
|
|
|
2020-04-14 19:20:51 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayShowInGameTime->toBoolean()) {
|
2019-12-14 23:50:29 +00:00
|
|
|
double igt = g_GameState->GetTotalPlayTime();
|
|
|
|
u32 ms = u64(igt * 1000) % 1000;
|
|
|
|
auto pt = std::div(igt, 3600);
|
|
|
|
overlayText +=
|
2020-04-11 22:51:39 +00:00
|
|
|
fmt::format(FMT_STRING("PlayTime: {:02d}:{:02d}:{:02d}.{:03d}\n"), pt.quot, pt.rem / 60, pt.rem % 60, ms);
|
2021-01-17 03:33:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_StateManager->GetCurrentArea() != nullptr && m_cvarCommons.m_debugOverlayShowRoomTimer->toBoolean()) {
|
|
|
|
double igt = g_GameState->GetTotalPlayTime();
|
|
|
|
if (m_currentRoom != g_StateManager->GetCurrentArea()) {
|
|
|
|
m_currentRoom = static_cast<const void*>(g_StateManager->GetCurrentArea());
|
|
|
|
m_lastRoomTime = igt - m_currentRoomStart;
|
|
|
|
m_currentRoomStart = igt;
|
2020-12-31 22:00:10 +00:00
|
|
|
}
|
2021-01-17 03:33:03 +00:00
|
|
|
double currentRoomTime = igt - m_currentRoomStart;
|
|
|
|
u32 curFrames = std::round(u32(currentRoomTime * 60));
|
|
|
|
u32 lastFrames = std::round(u32(m_lastRoomTime * 60));
|
2021-01-24 00:28:22 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("Room Time:{:8.3f}/{:6d}| Last Room:{:8.3f}/{:6d}\n"), currentRoomTime,
|
|
|
|
curFrames, m_lastRoomTime, lastFrames);
|
2019-12-14 23:50:29 +00:00
|
|
|
}
|
2018-05-10 02:56:54 +00:00
|
|
|
|
2020-04-14 19:20:51 +00:00
|
|
|
if (g_StateManager->Player() && m_cvarCommons.m_debugOverlayPlayerInfo->toBoolean()) {
|
2019-12-14 23:50:29 +00:00
|
|
|
const CPlayer& pl = g_StateManager->GetPlayer();
|
|
|
|
const zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f());
|
|
|
|
const zeus::CTransform camXf = g_StateManager->GetCameraManager()->GetCurrentCameraTransform(*g_StateManager);
|
|
|
|
const zeus::CQuaternion camQ = zeus::CQuaternion(camXf.getRotation().buildMatrix3f());
|
2020-04-11 22:51:39 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("Player Position: x {}, y {}, z {}\n"
|
2021-01-24 00:28:22 +00:00
|
|
|
" Roll: {}, Pitch: {}, Yaw: {}\n"
|
|
|
|
" Momentum: x {}, y: {}, z: {}\n"
|
|
|
|
" Velocity: x {}, y: {}, z: {}\n"
|
|
|
|
"Camera Position: x {}, y {}, z {}\n"
|
|
|
|
" Roll: {}, Pitch: {}, Yaw: {}\n"),
|
2019-12-14 23:50:29 +00:00
|
|
|
pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(),
|
|
|
|
zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()),
|
|
|
|
pl.GetMomentum().x(), pl.GetMomentum().y(), pl.GetMomentum().z(),
|
|
|
|
pl.GetVelocity().x(), pl.GetVelocity().y(), pl.GetVelocity().z(), camXf.origin.x(),
|
|
|
|
camXf.origin.y(), camXf.origin.z(), zeus::radToDeg(camQ.roll()),
|
|
|
|
zeus::radToDeg(camQ.pitch()), zeus::radToDeg(camQ.yaw()));
|
|
|
|
}
|
2020-04-14 19:20:51 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayWorldInfo->toBoolean()) {
|
2019-12-14 23:50:29 +00:00
|
|
|
TLockedToken<CStringTable> tbl =
|
|
|
|
g_SimplePool->GetObj({FOURCC('STRG'), g_StateManager->GetWorld()->IGetStringTableAssetId()});
|
|
|
|
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
|
2020-04-11 22:51:39 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("World: 0x{}{}, Area: {}\n"), g_GameState->CurrentWorldAssetId(),
|
2019-12-14 23:50:29 +00:00
|
|
|
(tbl.IsLoaded() ? (" " + hecl::Char16ToUTF8(tbl->GetString(0))).c_str() : ""), aId);
|
|
|
|
}
|
|
|
|
|
|
|
|
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
|
2020-04-14 19:20:51 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayAreaInfo->toBoolean() && g_StateManager->GetWorld() &&
|
2019-12-14 23:50:29 +00:00
|
|
|
g_StateManager->GetWorld()->DoesAreaExist(aId)) {
|
|
|
|
const auto& layerStates = g_GameState->CurrentWorldState().GetLayerState();
|
|
|
|
std::string layerBits;
|
|
|
|
u32 totalActive = 0;
|
|
|
|
for (u32 i = 0; i < layerStates->GetAreaLayerCount(aId); ++i) {
|
|
|
|
if (layerStates->IsLayerActive(aId, i)) {
|
|
|
|
++totalActive;
|
|
|
|
layerBits += "1";
|
|
|
|
} else
|
|
|
|
layerBits += "0";
|
|
|
|
}
|
2020-04-11 22:51:39 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("Area AssetId: 0x{}, Total Objects: {}\n"
|
2021-01-24 00:28:22 +00:00
|
|
|
"Active Layer bits: {}\n"),
|
2019-12-14 23:50:29 +00:00
|
|
|
g_StateManager->GetWorld()->GetArea(aId)->GetAreaAssetId(),
|
|
|
|
g_StateManager->GetAllObjectList().size(), layerBits);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-10 02:56:54 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-09-13 20:43:50 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean()) {
|
|
|
|
overlayText += fmt::format(FMT_STRING("CRandom16::Next calls: {}\n"), urde::CRandom16::GetNumNextCalls());
|
|
|
|
}
|
|
|
|
|
2020-04-14 19:20:51 +00:00
|
|
|
if (m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean())
|
2020-04-11 22:51:39 +00:00
|
|
|
overlayText += fmt::format(FMT_STRING("Resource Objects: {}\n"), g_SimplePool->GetLiveObjects());
|
2019-12-14 23:50:29 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!overlayText.empty())
|
|
|
|
m_debugText->typesetGlyphs(overlayText);
|
|
|
|
}
|
2016-02-18 02:42:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
specter::View* ViewManager::BuildSpaceViews() {
|
|
|
|
m_rootSpaceView = m_rootSpace->buildSpaceView(m_viewResources);
|
|
|
|
return m_rootSpaceView;
|
2015-12-12 00:37:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
specter::RootView* ViewManager::SetupRootView() {
|
|
|
|
m_rootView.reset(new specter::RootView(*this, m_viewResources, m_mainWindow.get()));
|
2019-02-24 07:15:54 +00:00
|
|
|
m_rootView->setBackground(zeus::skBlack);
|
2018-12-08 05:30:43 +00:00
|
|
|
return m_rootView.get();
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
SplashScreen* ViewManager::SetupSplashView() {
|
|
|
|
m_splash.reset(new SplashScreen(*this, m_viewResources));
|
|
|
|
if (!m_showSplash)
|
|
|
|
m_splash->close(true);
|
|
|
|
return m_splash.get();
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::RootSpaceViewBuilt(specter::View* view) {
|
|
|
|
std::vector<specter::View*>& cViews = m_rootView->accessContentViews();
|
|
|
|
cViews.clear();
|
|
|
|
cViews.push_back(view);
|
|
|
|
cViews.push_back(m_splash.get());
|
|
|
|
m_rootView->updateSize();
|
2016-01-11 02:17:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::ProjectChanged(hecl::Database::Project& proj) {
|
|
|
|
CDvdFile::Shutdown();
|
2020-09-17 23:34:21 +00:00
|
|
|
// FIXME trilogy hack
|
|
|
|
hecl::ProjectPath projectPath(proj.getProjectWorkingPath(), _SYS_STR("out/files/MP1"));
|
|
|
|
if (!projectPath.isDirectory()) {
|
|
|
|
projectPath = hecl::ProjectPath(proj.getProjectWorkingPath(), _SYS_STR("out/files"));
|
|
|
|
}
|
|
|
|
CDvdFile::Initialize(projectPath);
|
2016-03-07 03:12:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::SetupEditorView() {
|
|
|
|
m_rootSpace.reset(new RootSpace(*this));
|
2016-01-10 06:42:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
SplitSpace* split = new SplitSpace(*this, nullptr, specter::SplitView::Axis::Horizontal);
|
|
|
|
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
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
BuildSpaceViews();
|
2016-01-04 05:31:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::SetupEditorView(ConfigReader& r) {
|
|
|
|
m_rootSpace.reset(Space::NewRootSpaceFromConfigStream(*this, r));
|
|
|
|
BuildSpaceViews();
|
2016-01-05 00:01:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::SaveEditorView(ConfigWriter& w) {
|
|
|
|
if (!m_rootSpace)
|
|
|
|
return;
|
|
|
|
m_rootSpace->saveState(w);
|
2016-01-05 00:01:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::DismissSplash() {
|
|
|
|
if (!m_showSplash)
|
|
|
|
return;
|
|
|
|
m_showSplash = false;
|
|
|
|
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)
|
2019-07-20 04:27:21 +00:00
|
|
|
, m_locale(locale::SystemLocaleOrEnglish())
|
2020-04-11 22:51:39 +00:00
|
|
|
, m_recentProjectsPath(fmt::format(FMT_STRING(_SYS_STR("{}/recent_projects.txt")), fileMgr.getStoreRoot()))
|
|
|
|
, m_recentFilesPath(fmt::format(FMT_STRING(_SYS_STR("{}/recent_files.txt")), fileMgr.getStoreRoot())) {
|
2018-12-08 05:30:43 +00:00
|
|
|
Space::SpaceMenuNode::InitializeStrings(*this);
|
|
|
|
char path[2048];
|
|
|
|
hecl::Sstat theStat;
|
|
|
|
|
2019-08-26 18:37:19 +00:00
|
|
|
auto fp = hecl::FopenUnique(m_recentProjectsPath.c_str(), _SYS_STR("r"), hecl::FileLockType::Read);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (fp) {
|
2019-08-26 18:37:19 +00:00
|
|
|
while (std::fgets(path, std::size(path), fp.get())) {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::string pathStr(path);
|
|
|
|
pathStr.pop_back();
|
|
|
|
hecl::SystemStringConv pathStrView(pathStr);
|
2019-08-26 18:37:19 +00:00
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_recentProjects.emplace_back(pathStrView.sys_str());
|
2019-08-26 18:37:19 +00:00
|
|
|
}
|
2016-01-16 03:58:11 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 18:37:19 +00:00
|
|
|
fp = hecl::FopenUnique(m_recentFilesPath.c_str(), _SYS_STR("r"), hecl::FileLockType::Read);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (fp) {
|
2019-08-26 18:37:19 +00:00
|
|
|
while (std::fgets(path, std::size(path), fp.get())) {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::string pathStr(path);
|
|
|
|
pathStr.pop_back();
|
|
|
|
hecl::SystemStringConv pathStrView(pathStr);
|
2019-08-26 18:37:19 +00:00
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_recentFiles.emplace_back(pathStrView.sys_str());
|
2019-08-26 18:37:19 +00:00
|
|
|
}
|
2016-01-16 03:58:11 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-01-16 03:58:11 +00:00
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
|
|
|
|
ViewManager::~ViewManager() {}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::pushRecentProject(hecl::SystemStringView path) {
|
|
|
|
for (hecl::SystemString& testPath : m_recentProjects) {
|
|
|
|
if (path == testPath)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_recentProjects.emplace_back(path);
|
2019-08-26 18:37:19 +00:00
|
|
|
|
|
|
|
const auto fp = hecl::FopenUnique(m_recentProjectsPath.c_str(), _SYS_STR("w"), hecl::FileLockType::Write);
|
|
|
|
if (fp == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const hecl::SystemString& pPath : m_recentProjects) {
|
2020-04-11 22:51:39 +00:00
|
|
|
fmt::print(fp.get(), FMT_STRING("{}\n"), hecl::SystemUTF8Conv(pPath));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::pushRecentFile(hecl::SystemStringView path) {
|
|
|
|
for (hecl::SystemString& testPath : m_recentFiles) {
|
|
|
|
if (path == testPath)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_recentFiles.emplace_back(path);
|
2019-08-26 18:37:19 +00:00
|
|
|
|
|
|
|
const auto fp = hecl::FopenUnique(m_recentFilesPath.c_str(), _SYS_STR("w"), hecl::FileLockType::Write);
|
|
|
|
if (fp == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const hecl::SystemString& pPath : m_recentFiles) {
|
2020-04-11 22:51:39 +00:00
|
|
|
fmt::print(fp.get(), FMT_STRING("{}\n"), hecl::SystemUTF8Conv(pPath));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::init(boo::IApplication* app) {
|
|
|
|
m_mainWindow = app->newWindow(_SYS_STR("URDE"));
|
|
|
|
m_mainWindow->showWindow();
|
|
|
|
m_mainWindow->setWaitCursor(true);
|
|
|
|
|
|
|
|
float pixelFactor = m_mainWindow->getVirtualPixelFactor();
|
|
|
|
|
|
|
|
m_mainBooFactory = m_mainWindow->getMainContextDataFactory();
|
|
|
|
m_pipelineConv = hecl::NewPipelineConverter(m_mainBooFactory);
|
|
|
|
hecl::conv = m_pipelineConv.get();
|
|
|
|
m_mainPlatformName = m_mainBooFactory->platformName();
|
2020-04-11 22:51:39 +00:00
|
|
|
m_mainWindow->setTitle(fmt::format(FMT_STRING(_SYS_STR("URDE [{}]")), m_mainPlatformName));
|
2018-12-08 05:30:43 +00:00
|
|
|
m_mainCommandQueue = m_mainWindow->getCommandQueue();
|
|
|
|
m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor);
|
|
|
|
InitializeIcons(m_viewResources);
|
|
|
|
InitializeBadging(m_viewResources);
|
|
|
|
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
|
|
|
|
specter::RootView* root = SetupRootView();
|
|
|
|
m_showSplash = true;
|
|
|
|
root->accessContentViews().push_back(SetupSplashView());
|
|
|
|
root->updateSize();
|
|
|
|
m_renderTex = root->renderTex();
|
|
|
|
m_mainWindow->setWaitCursor(false);
|
|
|
|
m_voiceEngine = boo::NewAudioVoiceEngine();
|
|
|
|
m_voiceEngine->setVolume(0.7f);
|
|
|
|
m_amuseAllocWrapper.emplace(*m_voiceEngine);
|
|
|
|
|
|
|
|
for (const auto& arg : app->getArgs()) {
|
2021-01-24 00:28:22 +00:00
|
|
|
hecl::Sstat theStat;
|
|
|
|
if (!hecl::Stat((arg + _SYS_STR("/out")).c_str(), &theStat) && S_ISDIR(theStat.st_mode)) {
|
|
|
|
hecl::ProjectRootPath rootPath(arg);
|
|
|
|
hecl::Database::Project tmp(rootPath); // Force project creation
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m_deferedProject.empty() && hecl::SearchForProject(arg))
|
2021-01-24 00:28:22 +00:00
|
|
|
m_deferedProject = arg + _SYS_STR("/out");
|
2018-12-08 05:30:43 +00:00
|
|
|
if (arg == _SYS_STR("--no-shader-warmup"))
|
|
|
|
m_noShaderWarmup = true;
|
|
|
|
else if (arg == _SYS_STR("--no-sound"))
|
|
|
|
m_voiceEngine->setVolume(0.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_deferedProject.empty()) {
|
|
|
|
/* Default behavior - search upwards for packaged project containing the program */
|
2019-12-11 04:51:33 +00:00
|
|
|
if (hecl::ProjectRootPath projRoot = hecl::SearchForProject(ExeDir)) {
|
|
|
|
hecl::SystemString rootPath(projRoot.getAbsolutePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::Sstat theStat;
|
|
|
|
if (!hecl::Stat((rootPath + _SYS_STR("/out/files/Metroid1.upak")).c_str(), &theStat) && S_ISREG(theStat.st_mode))
|
|
|
|
m_deferedProject = rootPath + _SYS_STR("/out");
|
2018-01-02 01:04:23 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool ViewManager::proc() {
|
|
|
|
if (!m_deferedProject.empty() && m_viewResources.fontCacheReady()) {
|
|
|
|
m_projManager.openProject(m_deferedProject);
|
|
|
|
m_deferedProject.clear();
|
|
|
|
}
|
2017-01-22 06:28:55 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
|
|
|
if (m_rootView->isDestroyed())
|
|
|
|
return false;
|
2016-01-05 00:01:02 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m_updatePf) {
|
|
|
|
m_viewResources.resetPixelFactor(m_reqPf);
|
|
|
|
specter::RootView* root = SetupRootView();
|
2016-01-05 00:01:02 +00:00
|
|
|
if (m_rootSpace)
|
2018-12-08 05:30:43 +00:00
|
|
|
BuildSpaceViews();
|
|
|
|
else {
|
|
|
|
std::vector<specter::View*>& cViews = m_rootView->accessContentViews();
|
|
|
|
cViews.push_back(SetupSplashView());
|
2016-01-11 02:17:08 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
root->updateSize();
|
|
|
|
m_updatePf = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rootView->dispatchEvents();
|
|
|
|
m_rootView->internalThink();
|
|
|
|
if (m_rootSpace)
|
|
|
|
m_rootSpace->think();
|
|
|
|
if (m_splash)
|
|
|
|
m_splash->think();
|
|
|
|
|
|
|
|
if (m_deferSplit) {
|
|
|
|
SplitSpace* ss = static_cast<SplitSpace*>(m_deferSplit->spaceSplit(m_deferSplitAxis, m_deferSplitThisSlot));
|
|
|
|
m_rootView->startSplitDrag(ss->splitView(), m_deferSplitCoord);
|
|
|
|
m_deferSplit = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
++m_editorFrames;
|
|
|
|
if (m_rootSpaceView && m_editorFrames <= 30)
|
|
|
|
m_rootSpaceView->setMultiplyColor(zeus::CColor::lerp({1, 1, 1, 0}, {1, 1, 1, 1}, m_editorFrames / 30.0));
|
|
|
|
|
2019-09-29 12:44:37 +00:00
|
|
|
m_cvarManager.proc();
|
2018-12-08 05:30:43 +00:00
|
|
|
m_projManager.mainUpdate();
|
|
|
|
|
|
|
|
if (m_testGameView)
|
|
|
|
m_testGameView->think();
|
|
|
|
|
|
|
|
if (g_Renderer)
|
|
|
|
g_Renderer->BeginScene();
|
|
|
|
m_rootView->draw(gfxQ);
|
|
|
|
if (g_Renderer)
|
|
|
|
g_Renderer->EndScene();
|
|
|
|
gfxQ->execute();
|
|
|
|
if (g_ResFactory)
|
|
|
|
g_ResFactory->AsyncIdle();
|
2019-04-07 05:14:48 +00:00
|
|
|
#ifndef URDE_MSAN
|
2018-12-08 05:30:43 +00:00
|
|
|
m_voiceEngine->pumpAndMixVoices();
|
2019-04-07 05:14:48 +00:00
|
|
|
#endif
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!m_skipWait || !hecl::com_developer->toBoolean())
|
|
|
|
m_mainWindow->waitForRetrace();
|
|
|
|
CBooModel::ClearModelUniformCounters();
|
|
|
|
CGraphics::TickRenderTimings();
|
|
|
|
++logvisor::FrameIndex;
|
|
|
|
return true;
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ViewManager::stop() {
|
2019-07-01 06:14:42 +00:00
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
2018-12-08 05:30:43 +00:00
|
|
|
m_projManager.shutdown();
|
|
|
|
CDvdFile::Shutdown();
|
|
|
|
DestroyIcons();
|
|
|
|
DestroyBadging();
|
|
|
|
m_viewResources.destroyResData();
|
|
|
|
m_fontCache.destroyAtlases();
|
2015-12-06 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2018-05-14 03:38:36 +00:00
|
|
|
} // namespace urde
|