metaforce/Editor/GameMode.hpp

55 lines
1.4 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-12-13 02:56:43 +00:00
#include "Space.hpp"
#include "ViewManager.hpp"
#include "Runtime/IMain.hpp"
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
class GameMode : public ViewerSpace {
std::shared_ptr<IMain> m_main;
2016-12-13 02:56:43 +00:00
2018-12-08 05:30:43 +00:00
struct State : Space::State {
2019-08-11 00:49:41 +00:00
AT_DECL_DNA_YAMLV
2018-12-08 05:30:43 +00:00
Value<bool> showToolbar = true;
} m_state;
2016-12-13 02:56:43 +00:00
const Space::State& spaceState() const override { return m_state; }
2016-12-13 02:56:43 +00:00
2018-12-08 05:30:43 +00:00
struct View : specter::View {
GameMode& m_gMode;
2016-12-13 02:56:43 +00:00
2018-12-08 05:30:43 +00:00
View(GameMode& gMode, specter::ViewResources& res) : specter::View(res, gMode.m_vm.rootView()), m_gMode(gMode) {}
2016-12-13 02:56:43 +00:00
void draw(boo::IGraphicsCommandQueue* gfxQ) override;
2018-12-08 05:30:43 +00:00
};
2016-12-13 02:56:43 +00:00
2018-12-08 05:30:43 +00:00
std::unique_ptr<View> m_view;
2016-12-13 02:56:43 +00:00
public:
2018-12-08 05:30:43 +00:00
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() override {}
2016-12-13 02:56:43 +00:00
specter::View* buildContentView(specter::ViewResources& res) override {
2018-12-08 05:30:43 +00:00
m_view.reset(new View(*this, res));
return m_view.get();
}
void think() override;
2018-12-08 05:30:43 +00:00
Space* copy(Space* parent) const override { return new GameMode(m_vm, parent, *this); }
2018-12-08 05:30:43 +00:00
bool usesToolbar() const override { return m_state.showToolbar; }
2018-12-08 05:30:43 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce