From 97ab6961a2c9a7d5dfd3c84e72a933cdf7b5ee18 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Mon, 12 Dec 2016 18:56:43 -0800 Subject: [PATCH] Add GameMode viewerspace stub --- Editor/CMakeLists.txt | 4 +- Editor/GameMode.cpp | 16 ++ Editor/GameMode.hpp | 76 ++++++++ Editor/Space.cpp | 10 +- Editor/Space.hpp | 3 +- Editor/ViewManager.cpp | 2 +- Editor/icons/icons.cpp | 2 + Editor/icons/icons.hpp | 3 +- Editor/icons/icons.svg | 199 ++++++++++++++++++++- Editor/main.cpp | 1 + Runtime/World/CMakeLists.txt | 1 + Runtime/World/CScriptCameraHintTrigger.cpp | 16 ++ Runtime/World/CScriptCameraHintTrigger.hpp | 28 +++ Runtime/World/ScriptLoader.cpp | 16 +- specter | 2 +- 15 files changed, 365 insertions(+), 14 deletions(-) create mode 100644 Editor/GameMode.cpp create mode 100644 Editor/GameMode.hpp create mode 100644 Runtime/World/CScriptCameraHintTrigger.cpp create mode 100644 Runtime/World/CScriptCameraHintTrigger.hpp diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index b5262651e..8ed36b63f 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -8,6 +8,7 @@ atdna(atdna_ResourceBrowser.cpp ResourceBrowser.hpp) atdna(atdna_ModelViewer.cpp ModelViewer.hpp) atdna(atdna_ParticleEditor.cpp ParticleEditor.hpp) atdna(atdna_InformationCenter.cpp InformationCenter.hpp) +atdna(atdna_GameMode.cpp GameMode.hpp) if(WIN32) set(PLAT_SRCS platforms/win/urde.rc) @@ -32,7 +33,8 @@ add_executable(urde WIN32 MACOSX_BUNDLE ProjectManager.hpp ProjectManager.cpp ViewManager.hpp ViewManager.cpp Resource.hpp Resource.cpp - Camera.hpp Camera.cpp) + Camera.hpp Camera.cpp + GameMode.hpp GameMode.cpp atdna_GameMode.cpp) target_link_libraries(urde UrdeLocales diff --git a/Editor/GameMode.cpp b/Editor/GameMode.cpp new file mode 100644 index 000000000..a4954e68d --- /dev/null +++ b/Editor/GameMode.cpp @@ -0,0 +1,16 @@ +#include "GameMode.hpp" + +namespace urde +{ +void GameMode::think() +{ + ViewerSpace::think(); +} + +void GameMode::View::draw(boo::IGraphicsCommandQueue *gfxQ) +{ + if (m_gMode.m_main) + m_gMode.m_main->Draw(); +} + +} diff --git a/Editor/GameMode.hpp b/Editor/GameMode.hpp new file mode 100644 index 000000000..4707e8bdc --- /dev/null +++ b/Editor/GameMode.hpp @@ -0,0 +1,76 @@ +#ifndef URDE_GAMEMODE_HPP +#define URDE_GAMEMODE_HPP + +#include "Space.hpp" +#include "ViewManager.hpp" +#include "Runtime/IMain.hpp" + +namespace urde +{ +class GameMode : public ViewerSpace +{ + std::shared_ptr m_main; + + struct State : Space::State + { + DECL_YAML + Value showToolbar = true; + } m_state; + + const Space::State& spaceState() const { return m_state; } + + struct View : specter::View + { + GameMode& m_gMode; + + View(GameMode& gMode, specter::ViewResources& res) + : specter::View(res, gMode.m_vm.rootView()), m_gMode(gMode) {} + + void draw(boo::IGraphicsCommandQueue *gfxQ); + }; + + std::unique_ptr m_view; + +public: + GameMode(ViewManager& vm, Space* parent) + : ViewerSpace(vm, Class::GameMode, parent) + { + reloadState(); + } + + GameMode(ViewManager& vm, Space* parent, const GameMode& other) + : GameMode(vm, parent) + { + m_state = other.m_state; + reloadState(); + } + + GameMode(ViewManager& vm, Space* parent, ConfigReader& r) + : GameMode(vm, parent) + { + m_state.read(r); + reloadState(); + } + + void reloadState() + { + } + + virtual specter::View* buildContentView(specter::ViewResources &res) + { + m_view.reset(new View(*this, res)); + return m_view.get(); + } + + void think(); + + Space* copy(Space *parent) const + { + return new GameMode(m_vm, parent, *this); + } + + bool usesToolbar() const { return m_state.showToolbar; } +}; +} + +#endif // URDE_GAMEMODE_HPP diff --git a/Editor/Space.cpp b/Editor/Space.cpp index c71513ff1..1fad7204f 100644 --- a/Editor/Space.cpp +++ b/Editor/Space.cpp @@ -4,6 +4,7 @@ #include "ParticleEditor.hpp" #include "ModelViewer.hpp" #include "InformationCenter.hpp" +#include "GameMode.hpp" #include "icons/icons.hpp" namespace urde @@ -46,7 +47,8 @@ std::vector Space::SpaceMenuNode::s_subNodeDa {Class::ResourceBrowser, "resource_browser", "Resource Browser", GetIcon(SpaceIcon::ResourceBrowser), {0.0f, 1.0f, 0.0f, 1.0f}}, {Class::EffectEditor, "effect_editor", "Effect Editor", GetIcon(SpaceIcon::ParticleEditor), {1.0f, 0.5f, 0.0f, 1.0f}}, {Class::ModelViewer, "model_viewer", "Model Viewer", GetIcon(SpaceIcon::ModelViewer), {0.95f, 0.95f, 0.95f, 1.0f}}, - {Class::InformationCenter, "information_center", "Information Center", GetIcon(SpaceIcon::InformationCenter), {0.0f, 1.0f, 1.0f, 1.0f}} + {Class::InformationCenter, "information_center", "Information Center", GetIcon(SpaceIcon::InformationCenter), {0.0f, 1.0f, 1.0f, 1.0f}}, + {Class::GameMode, "game_mode", "Game Mode", GetIcon(SpaceIcon::GameMode), {}} }; std::string Space::SpaceMenuNode::s_text = "Space Types"; @@ -207,6 +209,8 @@ static Space* BuildNewSpace(ViewManager& vm, Space::Class cls, Space* parent, Re return new ModelViewer(vm, parent, r); case Class::InformationCenter: return new InformationCenter(vm, parent, r); + case Class::GameMode: + return new GameMode(vm, parent, r); default: break; } return nullptr; @@ -259,6 +263,10 @@ void Space::SpaceMenuNode::SubNode::activated(const boo::SWindowCoord &coord) if (typeid(ModelViewer) != typeid(m_space)) newSpace.reset(new ModelViewer(m_space.m_parent->m_vm, m_space.m_parent)); break; + case Class::GameMode: + if (typeid(GameMode) != typeid(m_space)) + newSpace.reset(new GameMode(m_space.m_parent->m_vm, m_space.m_parent)); + break; default: break; } if (newSpace) diff --git a/Editor/Space.hpp b/Editor/Space.hpp index 4117c915b..36a2d9e30 100644 --- a/Editor/Space.hpp +++ b/Editor/Space.hpp @@ -35,7 +35,8 @@ public: ResourceBrowser, ModelViewer, EffectEditor, - InformationCenter + InformationCenter, + GameMode }; struct State : athena::io::DNAYaml {Delete _d;}; diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index db5093aff..0f15bbf1d 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -70,7 +70,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) m_videoVoice = m_voiceEngine->allocateNewStereoVoice(32000, &m_voiceCallback); m_videoVoice->start(); - m_rootView->accessContentViews().clear(); + //m_rootView->accessContentViews().clear(); m_rootView->accessContentViews().push_back(m_particleView.get()); m_rootView->updateSize(); } diff --git a/Editor/icons/icons.cpp b/Editor/icons/icons.cpp index 77be9950f..2a2604d42 100644 --- a/Editor/icons/icons.cpp +++ b/Editor/icons/icons.cpp @@ -51,6 +51,8 @@ specter::Icon& GetIcon(SpaceIcon icon) return g_IconAtlas.getIcon(0, 3); case SpaceIcon::ModelViewer: return g_IconAtlas.getIcon(0, 4); + case SpaceIcon::GameMode: + return g_IconAtlas.getIcon(0, 5); default: return g_IconAtlas.getIcon(6, 0); } diff --git a/Editor/icons/icons.hpp b/Editor/icons/icons.hpp index da00a8517..df7f4a1ea 100644 --- a/Editor/icons/icons.hpp +++ b/Editor/icons/icons.hpp @@ -14,7 +14,8 @@ enum class SpaceIcon ParticleEditor, WorldEditor, ModelViewer, - InformationCenter + InformationCenter, + GameMode }; specter::Icon& GetIcon(SpaceIcon icon); diff --git a/Editor/icons/icons.svg b/Editor/icons/icons.svg index 7c0f73495..e5134622b 100644 --- a/Editor/icons/icons.svg +++ b/Editor/icons/icons.svg @@ -25,17 +25,17 @@ borderopacity="1.0" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="39.419828" - inkscape:cx="8.6860061" - inkscape:cy="72.349928" + inkscape:zoom="19.709914" + inkscape:cx="11.98074" + inkscape:cy="81.550111" inkscape:document-units="px" - inkscape:current-layer="g3516" + inkscape:current-layer="layer1-5" showgrid="true" units="px" - inkscape:window-width="1366" - inkscape:window-height="713" + inkscape:window-width="1920" + inkscape:window-height="1051" inkscape:window-x="0" - inkscape:window-y="31" + inkscape:window-y="0" inkscape:window-maximized="1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Editor/main.cpp b/Editor/main.cpp index 5e954ac9e..51688ab98 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -47,6 +47,7 @@ struct Application : boo::IApplicationCallback break; } m_viewManager->stop(); + m_viewManager->projectManager().saveProject(); m_cvarManager.serialize(); m_viewManager.reset(); return 0; diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index 64dcdb492..6538d2cc8 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -64,6 +64,7 @@ set(WORLD_SOURCES CScriptPlayerActor.hpp CScriptPlayerActor.cpp CScriptAiJumpPoint.hpp CScriptAiJumpPoint.cpp CScriptColorModulate.hpp CScriptColorModulate.cpp + CScriptCameraHintTrigger.hpp CScriptCameraHintTrigger.cpp CGrappleParameters.hpp CActorParameters.hpp CLightParameters.hpp diff --git a/Runtime/World/CScriptCameraHintTrigger.cpp b/Runtime/World/CScriptCameraHintTrigger.cpp new file mode 100644 index 000000000..75e957883 --- /dev/null +++ b/Runtime/World/CScriptCameraHintTrigger.cpp @@ -0,0 +1,16 @@ +#include "CScriptCameraHintTrigger.hpp" +#include "CActorParameters.hpp" + +namespace urde +{ + +CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& scale, const zeus::CTransform& xf, bool b2, bool b3) + : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::ThirtyFour), CActorParameters::None(), kInvalidUniqueId) + , xe8_obb(xf, scale) + , x124_scale(scale) + , x130_24_(b2) + , x130_25_(b3) +{ +} + +} diff --git a/Runtime/World/CScriptCameraHintTrigger.hpp b/Runtime/World/CScriptCameraHintTrigger.hpp new file mode 100644 index 000000000..4e08c0b14 --- /dev/null +++ b/Runtime/World/CScriptCameraHintTrigger.hpp @@ -0,0 +1,28 @@ +#ifndef __URDE_CSCRIPTCAMERAHINTTRIGGER_HPP__ +#define __URDE_CSCRIPTCAMERAHINTTRIGGER_HPP__ + +#include "CActor.hpp" +#include "zeus/COBBox.hpp" + +namespace urde +{ +class CScriptCameraHintTrigger : public CActor +{ + zeus::COBBox xe8_obb; + zeus::CVector3f x124_scale; + union + { + struct + { + bool x130_24_ : 1; + bool x130_25_ : 1; + bool x130_26_ : 1; + bool x130_27_ : 1; + }; + u8 _dummy = 0; + }; +public: + CScriptCameraHintTrigger(TUniqueId, bool, const std::string& name, const CEntityInfo&, const zeus::CVector3f&, const zeus::CTransform&, bool, bool); +}; +} +#endif // __URDE_CSCRIPTCAMERAHINTTRIGGER_HPP__ diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 020d5a2d8..5fd2ef8b0 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -47,6 +47,7 @@ #include "CScriptSpecialFunction.hpp" #include "CScriptAiJumpPoint.hpp" #include "CScriptColorModulate.hpp" +#include "CScriptCameraHintTrigger.hpp" #include "Camera/CCinematicCamera.hpp" #include "MP1/CNewIntroBoss.hpp" #include "MP1/CBeetle.hpp" @@ -1867,7 +1868,20 @@ CEntity* ScriptLoader::LoadAtomicAlpha(CStateManager& mgr, CInputStream& in, int CEntity* ScriptLoader::LoadCameraHintTrigger(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 7, "CameraHintTrigger")) + return nullptr; + + SActorHead aHead = LoadActorHead(in, mgr); + zeus::CVector3f scale = 0.5f * zeus::CVector3f::ReadBig(in); + bool active = in.readBool(); + bool b2 = in.readBool(); + bool b3 = in.readBool(); + + zeus::CTransform xfRot = aHead.x10_transform.getRotation(); + if (xfRot == zeus::CTransform::Identity()) + return new CScriptTrigger(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform.origin, zeus::CAABox(-scale, scale), CDamageInfo(), zeus::CVector3f::skZero, ETriggerFlags::DetectPlayer, active, b2, b3); + + return new CScriptCameraHintTrigger(mgr.AllocateUniqueId(), active, aHead.x0_name, info, scale, aHead.x10_transform, b2, b3); } CEntity* ScriptLoader::LoadRumbleEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) diff --git a/specter b/specter index a092a62d7..7236e5984 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit a092a62d709ae1c99722646494d917d7e4f35219 +Subproject commit 7236e59845cc0f99ec2bcf2774d739e60fd48bb5