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"
|
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
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
namespace urde
|
2015-12-06 01:27:02 +00:00
|
|
|
{
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
|
2016-02-18 02:42:32 +00:00
|
|
|
{
|
2016-08-22 00:11:18 +00:00
|
|
|
m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend");
|
2017-01-22 06:28:55 +00:00
|
|
|
#if 0
|
2016-09-21 05:41:51 +00:00
|
|
|
SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.*"));
|
2016-08-17 05:09:34 +00:00
|
|
|
SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend"));
|
|
|
|
SObjectTag bgModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_BC34D54C.blend"));
|
2016-09-12 04:53:28 +00:00
|
|
|
CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f{2.f, 2.f, 2.f}, 1, true);
|
2016-08-17 04:59:05 +00:00
|
|
|
g_GameState->GetWorldTransitionManager()->EnableTransition(samusAnimRes,
|
|
|
|
platModel.id, zeus::CVector3f::skOne,
|
2016-09-03 03:47:57 +00:00
|
|
|
bgModel.id, zeus::CVector3f::skOne, true);
|
2016-08-17 04:59:05 +00:00
|
|
|
|
2016-08-17 05:09:34 +00:00
|
|
|
SObjectTag areaTag = m_projManager.TagFromPath(
|
2016-08-13 01:23:27 +00:00
|
|
|
_S("MP1/Metroid1/!1IntroLevel1027/00 Exterior Docking Hangar/!area.blend"));
|
2016-08-12 19:42:18 +00:00
|
|
|
auto areaData = m_projManager.resourceFactoryMP1().LoadResourceSync(areaTag);
|
2017-01-22 06:28:55 +00:00
|
|
|
#endif
|
2016-08-12 19:42:18 +00:00
|
|
|
|
2016-08-01 06:36:51 +00:00
|
|
|
//m_modelTest = objStore.GetObj("gun_cmdl");
|
2016-08-22 00:11:18 +00:00
|
|
|
|
2016-04-05 01:51:25 +00:00
|
|
|
//m_modelTest = objStore.GetObj("CMDL_GameCube");
|
2016-03-31 06:18:56 +00:00
|
|
|
|
2016-12-12 20:10:55 +00:00
|
|
|
//m_partGenDesc = objStore.GetObj({hecl::FOURCC('PART'), 0x0deb9456});
|
2016-07-08 20:25:38 +00:00
|
|
|
//m_partGenDesc = objStore.GetObj("PowerCharge");
|
2016-07-08 00:07:11 +00:00
|
|
|
//m_partGen.reset(new urde::CElementGen(m_partGenDesc,
|
|
|
|
// urde::CElementGen::EModelOrientationType::Normal,
|
|
|
|
// urde::CElementGen::EOptionalSystemFlags::None));
|
|
|
|
//m_partGen->SetGlobalScale({5.f, 5.f, 5.f});
|
2016-03-04 23:04:53 +00:00
|
|
|
m_lineRenderer.reset(new urde::CLineRenderer(urde::CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true));
|
2016-03-28 21:38:48 +00:00
|
|
|
|
2016-08-20 04:22:13 +00:00
|
|
|
TLockedToken<CTexture> xrayPalette = objStore.GetObj("TXTR_XRayPalette");
|
2017-01-22 21:26:58 +00:00
|
|
|
m_testGameView.reset(new TestGameView(*this, m_viewResources, *m_rootView, xrayPalette));
|
2016-03-28 21:38:48 +00:00
|
|
|
|
2016-12-24 06:08:48 +00:00
|
|
|
#if 0
|
2016-12-14 01:10:17 +00:00
|
|
|
m_moviePlayer.reset(new CMoviePlayer("Video/SpecialEnding.thp", 1.f, false, true));
|
|
|
|
m_moviePlayer->SetFrame({-1.0f, 1.0f, 0.f}, {-1.0f, -1.0f, 0.f}, {1.0f, -1.0f, 0.f}, {1.0f, 1.0f, 0.f});
|
2016-03-08 22:51:13 +00:00
|
|
|
CDvdFile testRSF("Audio/frontend_1.rsf");
|
|
|
|
u64 rsfLen = testRSF.Length();
|
|
|
|
m_rsfBuf.reset(new u8[rsfLen]);
|
|
|
|
testRSF.SyncRead(m_rsfBuf.get(), rsfLen);
|
2016-12-14 01:10:17 +00:00
|
|
|
CMoviePlayer::SetStaticAudio(m_rsfBuf.get(), rsfLen, 416480, 1973664);
|
2016-03-09 20:03:35 +00:00
|
|
|
|
2016-03-24 00:05:56 +00:00
|
|
|
m_videoVoice = m_voiceEngine->allocateNewStereoVoice(32000, &m_voiceCallback);
|
2016-03-08 07:10:52 +00:00
|
|
|
m_videoVoice->start();
|
2016-12-14 01:10:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-01-17 01:23:19 +00:00
|
|
|
//m_newAudioPlayer.emplace(*m_voiceEngine, "Audio/frontend_1.rsf", 416480, 1973664);
|
|
|
|
//m_newAudioPlayer->StartMixing();
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-04-15 20:42:40 +00:00
|
|
|
void ViewManager::InitMP1(MP1::CMain& main)
|
|
|
|
{
|
2017-02-09 09:23:17 +00:00
|
|
|
main.Init(m_fileStoreManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
|
2016-04-15 20:42:40 +00:00
|
|
|
}
|
|
|
|
|
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]});
|
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-14 07:03:58 +00:00
|
|
|
gfxQ->clearTarget(true, true);
|
2016-08-17 04:59:05 +00:00
|
|
|
|
2016-08-17 05:00:25 +00:00
|
|
|
//g_GameState->GetWorldTransitionManager()->Update(1.f / 60.f);
|
|
|
|
//g_GameState->GetWorldTransitionManager()->Draw();
|
2016-08-17 04:59:05 +00:00
|
|
|
|
2016-04-01 01:00:37 +00:00
|
|
|
if (m_vm.m_modelTest.IsLoaded())
|
2016-03-31 06:18:56 +00:00
|
|
|
{
|
2017-03-18 05:12:27 +00:00
|
|
|
#if 0
|
2016-03-31 06:18:56 +00:00
|
|
|
CModelFlags flags;
|
2016-07-31 04:46:03 +00:00
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::Flat;
|
2016-08-02 22:14:05 +00:00
|
|
|
//flags.m_extendedShaderIdx = 2;
|
|
|
|
//if (std::fmod(m_theta, M_PIF) < M_PIF / 2.f)
|
|
|
|
// flags.m_extendedShaderIdx = 1;
|
2016-04-01 01:00:37 +00:00
|
|
|
|
2016-04-02 03:56:19 +00:00
|
|
|
m_theta += 0.01f;
|
2016-08-03 21:53:03 +00:00
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::RotateZ(m_theta));
|
2017-03-14 07:03:58 +00:00
|
|
|
g_Renderer->SetWorldViewpoint(zeus::lookAt(zeus::CVector3f{0.f, -20.f, 7.f},
|
2016-08-03 21:53:03 +00:00
|
|
|
{0.f, 0.f, 3.f}));
|
2016-04-01 01:00:37 +00:00
|
|
|
boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame();
|
|
|
|
float aspect = windowRect.size[0] / float(windowRect.size[1]);
|
2016-08-03 21:53:03 +00:00
|
|
|
|
2017-03-17 23:33:02 +00:00
|
|
|
CGraphics::SetPerspective(55.0, aspect, 0.2f, 50.f);
|
2016-08-20 04:22:13 +00:00
|
|
|
//CGraphics::SetFog(ERglFogMode::PerspExp, 7.f, 15.f, zeus::CColor::skRed);
|
2016-08-08 04:48:18 +00:00
|
|
|
//CGraphics::SetFog(ERglFogMode::PerspExp, 10.f + std::sin(m_theta) * 5.f, 15.f + std::sin(m_theta) * 5.f, zeus::CColor::skRed);
|
2016-08-03 21:53:03 +00:00
|
|
|
zeus::CFrustum frustum;
|
2017-03-17 23:33:02 +00:00
|
|
|
frustum.updatePlanes(CGraphics::g_GXModelView, zeus::SProjPersp(55.0, aspect, 0.2f, 50.f));
|
2016-08-03 21:53:03 +00:00
|
|
|
g_Renderer->SetClippingPlanes(frustum);
|
2016-04-01 01:00:37 +00:00
|
|
|
|
2016-08-02 22:14:05 +00:00
|
|
|
std::vector<CLight> lights = {CLight::BuildLocalAmbient({}, {0.05f, 0.05f, 0.05f, 1.f}),
|
|
|
|
CLight::BuildCustom({5.f, -20.f, 10.f}, {0.f, 1.f, 0.f},
|
|
|
|
{200.f, 200.f, 200.f}, 0.f, 0.f, 1.f, 1.f, 0.f, 0.f)};
|
2017-03-14 07:03:58 +00:00
|
|
|
lights = {CLight::BuildLocalAmbient({}, {0.5f, 0.5f, 0.5f, 1.f})};
|
2016-08-08 04:48:18 +00:00
|
|
|
m_vm.m_modelTest->GetInstance().ActivateLights(lights);
|
|
|
|
//g_Renderer->SetThermal(true, 1.f, zeus::CColor::skWhite);
|
|
|
|
//g_Renderer->SetThermalColdScale(std::sin(m_theta) * 0.5f + 0.5f);
|
|
|
|
//g_Renderer->DoThermalBlendCold();
|
2017-03-17 23:33:02 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
2017-03-14 07:03:58 +00:00
|
|
|
//m_widescreen.draw(zeus::CColor::skBlack, std::sin(m_theta * 3.f) / 2.f + 0.5f);
|
2016-03-31 06:18:56 +00:00
|
|
|
m_vm.m_modelTest->Draw(flags);
|
2017-03-14 07:03:58 +00:00
|
|
|
g_Renderer->ReallyRenderFogVolume(zeus::CColor::skRed, m_vm.m_modelTest->GetAABB(),
|
|
|
|
nullptr, nullptr);
|
2016-08-20 18:18:44 +00:00
|
|
|
//m_xrayBlur.draw(25.f);
|
2017-03-14 07:03:58 +00:00
|
|
|
//m_camBlur.draw((std::sin(m_theta * 3.f) / 2.f + 0.5f) * 3.f);
|
2016-08-08 04:48:18 +00:00
|
|
|
//g_Renderer->DoThermalBlendHot();
|
2016-08-03 21:53:03 +00:00
|
|
|
//m_spaceWarpFilter.setStrength(std::sin(m_theta * 5.f) * 0.5f + 0.5f);
|
2016-08-02 22:14:05 +00:00
|
|
|
//m_spaceWarpFilter.draw(zeus::CVector2f{0.f, 0.f});
|
2016-08-21 20:39:18 +00:00
|
|
|
#endif
|
|
|
|
|
2016-03-31 06:18:56 +00:00
|
|
|
}
|
2016-02-18 02:42:32 +00:00
|
|
|
if (m_vm.m_partGen)
|
|
|
|
{
|
|
|
|
m_vm.m_partGen->Update(1.0 / 60.0);
|
2016-02-25 06:23:35 +00:00
|
|
|
|
|
|
|
if (m_vm.m_partGen->IsSystemDeletable())
|
|
|
|
m_vm.m_partGen->Reset();
|
|
|
|
|
2016-04-01 01:00:37 +00:00
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
|
|
|
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity() + zeus::CVector3f(0.f, -10.f, 0.f));
|
2016-02-18 02:42:32 +00:00
|
|
|
boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame();
|
|
|
|
float aspect = windowRect.size[0] / float(windowRect.size[1]);
|
2016-07-31 23:36:53 +00:00
|
|
|
CGraphics::SetPerspective(55.0, aspect, 0.1f, 1000.f);
|
2016-02-18 02:42:32 +00:00
|
|
|
//gfxQ->clearTarget(false, true);
|
|
|
|
m_vm.m_partGen->Render();
|
|
|
|
|
|
|
|
/*
|
|
|
|
m_vm.m_lineRenderer->Reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
m_vm.m_lineRenderer->AddVertex({-0.5f, 0.f, -0.5f}, zeus::CColor::skBlue, 1.f);
|
|
|
|
m_vm.m_lineRenderer->AddVertex({-0.5f, 0.f, 0.5f}, zeus::CColor::skBlue, 1.f);
|
|
|
|
m_vm.m_lineRenderer->AddVertex({0.5f, 10.f, 0.5f}, zeus::CColor::skRed, 3.f);
|
|
|
|
m_vm.m_lineRenderer->AddVertex({0.5f, 0.f, -0.5f}, zeus::CColor::skBlue, 1.f);
|
2016-02-18 02:42:32 +00:00
|
|
|
m_vm.m_lineRenderer->Render();
|
|
|
|
*/
|
|
|
|
}
|
2016-03-07 22:48:54 +00:00
|
|
|
if (m_vm.m_moviePlayer)
|
|
|
|
{
|
2016-03-08 23:38:00 +00:00
|
|
|
if (m_vm.m_moviePlayer->GetIsMovieFinishedPlaying())
|
|
|
|
{
|
|
|
|
m_vm.m_moviePlayer.reset(new CMoviePlayer("Video/01_startloop.thp", -1.f, true, false));
|
|
|
|
m_vm.m_moviePlayer->SetFrame({-1.0f, 1.0f, 0.f}, {-1.0f, -1.0f, 0.f}, {1.0f, -1.0f, 0.f}, {1.0f, 1.0f, 0.f});
|
|
|
|
}
|
2016-03-09 20:03:35 +00:00
|
|
|
|
2016-03-07 22:48:54 +00:00
|
|
|
m_vm.m_moviePlayer->Update(1.f / 60.f);
|
|
|
|
m_vm.m_moviePlayer->DrawFrame();
|
|
|
|
}
|
2016-09-02 17:50:03 +00:00
|
|
|
|
2017-03-18 05:12:27 +00:00
|
|
|
m_vm.m_projManager.mainDraw();
|
2016-09-12 04:53:28 +00:00
|
|
|
|
|
|
|
++m_frame;
|
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
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +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();
|
|
|
|
CDvdFile::Initialize(hecl::ProjectPath(proj.getProjectWorkingPath(), _S("out/MP1")));
|
|
|
|
}
|
|
|
|
|
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)
|
2016-01-04 05:31:02 +00:00
|
|
|
: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this),
|
2016-03-08 07:10:52 +00:00
|
|
|
m_fontCache(fileMgr), m_translator(urde::SystemLocaleOrEnglish()), m_voiceCallback(*this),
|
2016-03-04 23:04:53 +00:00
|
|
|
m_recentProjectsPath(hecl::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().c_str())),
|
|
|
|
m_recentFilesPath(hecl::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().c_str()))
|
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();
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::SystemStringView pathStrView(pathStr);
|
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
2016-01-16 03:58:11 +00:00
|
|
|
m_recentProjects.push_back(pathStrView);
|
|
|
|
}
|
|
|
|
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();
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::SystemStringView pathStrView(pathStr);
|
|
|
|
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
2016-01-16 03:58:11 +00:00
|
|
|
m_recentFiles.push_back(pathStrView);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
|
|
|
|
ViewManager::~ViewManager() {}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ViewManager::pushRecentProject(const hecl::SystemString& 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;
|
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
m_recentProjects.push_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)
|
|
|
|
fprintf(fp, "%s\n", hecl::SystemUTF8View(pPath).c_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ViewManager::pushRecentFile(const hecl::SystemString& 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;
|
|
|
|
}
|
2016-01-02 02:27:46 +00:00
|
|
|
m_recentFiles.push_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)
|
|
|
|
fprintf(fp, "%s\n", hecl::SystemUTF8View(pPath).c_str());
|
2016-01-16 03:58:11 +00:00
|
|
|
fclose(fp);
|
|
|
|
}}
|
2016-01-02 02:27:46 +00:00
|
|
|
|
2015-12-06 01:27:02 +00:00
|
|
|
void ViewManager::init(boo::IApplication* app)
|
|
|
|
{
|
2016-02-24 03:20:07 +00:00
|
|
|
m_mainWindow = std::unique_ptr<boo::IWindow>(app->newWindow(_S("URDE"), 1));
|
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);
|
2016-01-18 23:33:23 +00:00
|
|
|
m_iconsToken = InitializeIcons(m_viewResources);
|
2016-07-16 19:21:12 +00:00
|
|
|
m_badgeToken = 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();
|
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())
|
|
|
|
{
|
|
|
|
if (hecl::SearchForProject(arg))
|
|
|
|
{
|
|
|
|
m_deferedProject = arg;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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)
|
2016-03-04 23:04:53 +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
|
|
|
|
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();
|
2016-03-28 04:36:55 +00:00
|
|
|
m_projManager.asyncIdle();
|
2017-02-15 06:02:30 +00:00
|
|
|
m_mainWindow->waitForRetrace(m_voiceEngine.get());
|
2016-09-09 04:19:19 +00:00
|
|
|
CBooModel::ClearModelUniformCounters();
|
2016-07-08 06:53:06 +00:00
|
|
|
CGraphics::TickRenderTimings();
|
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();
|
2016-02-24 21:21:09 +00:00
|
|
|
m_iconsToken.doDestroy();
|
|
|
|
m_viewResources.destroyResData();
|
|
|
|
m_fontCache.destroyAtlases();
|
2015-12-06 01:27:02 +00:00
|
|
|
m_mainWindow->getCommandQueue()->stopRenderer();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|