mirror of https://github.com/AxioDL/metaforce.git
Initial space selection menu
This commit is contained in:
parent
e248379d76
commit
51e295e311
|
@ -6,6 +6,10 @@ namespace URDE
|
||||||
{
|
{
|
||||||
static LogVisor::LogModule Log("URDE::Space");
|
static LogVisor::LogModule Log("URDE::Space");
|
||||||
|
|
||||||
|
Space::Space(ViewManager& vm, Class cls, Space* parent)
|
||||||
|
: m_spaceMenuNode(*this), m_spaceSelectBind(*this),
|
||||||
|
m_vm(vm), m_class(cls), m_parent(parent) {}
|
||||||
|
|
||||||
Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
||||||
{
|
{
|
||||||
if (usesToolbar())
|
if (usesToolbar())
|
||||||
|
@ -13,7 +17,12 @@ Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
||||||
m_spaceView.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::Bottom));
|
m_spaceView.reset(new Specter::Space(res, m_vm.rootView(), *this, Specter::Toolbar::Position::Bottom));
|
||||||
Specter::View* sview = buildContentView(res);
|
Specter::View* sview = buildContentView(res);
|
||||||
m_spaceView->setContentView(sview);
|
m_spaceView->setContentView(sview);
|
||||||
buildToolbarView(res, *m_spaceView->toolbar());
|
Specter::Toolbar& tb = *m_spaceView->toolbar();
|
||||||
|
const std::string* classStr = SpaceMenuNode::lookupClassString(m_class);
|
||||||
|
m_spaceSelectButton.reset(new Specter::Button(res, tb, &m_spaceSelectBind,
|
||||||
|
classStr?*classStr:"Unknown Class"));
|
||||||
|
tb.push_back(m_spaceSelectButton.get());
|
||||||
|
buildToolbarView(res, tb);
|
||||||
return m_spaceView.get();
|
return m_spaceView.get();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -25,6 +34,25 @@ Specter::View* Space::buildSpaceView(Specter::ViewResources& res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Space::SpaceMenuNode::SubNodeData> Space::SpaceMenuNode::s_subNodeDats =
|
||||||
|
{
|
||||||
|
{Class::ResourceBrowser, "resource_browser", "Resource Browser"}
|
||||||
|
};
|
||||||
|
std::string Space::SpaceMenuNode::s_text = "Space Types";
|
||||||
|
|
||||||
|
void Space::SpaceMenuNode::initializeStrings(ViewManager& vm)
|
||||||
|
{
|
||||||
|
s_text = vm.translateOr("space_types", s_text.c_str());
|
||||||
|
for (SubNodeData& sn : s_subNodeDats)
|
||||||
|
sn.m_text = vm.translateOr(sn.m_key, sn.m_text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Specter::View> Space::SpaceSelectBind::buildMenu(const Specter::Button* button)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<Specter::View>(new Specter::Menu(m_space.m_vm.rootView().viewRes(),
|
||||||
|
*m_space.m_spaceView, &m_space.m_spaceMenuNode));
|
||||||
|
}
|
||||||
|
|
||||||
Specter::View* RootSpace::buildSpaceView(Specter::ViewResources& res)
|
Specter::View* RootSpace::buildSpaceView(Specter::ViewResources& res)
|
||||||
{
|
{
|
||||||
Specter::View* newRoot = buildContentView(res);
|
Specter::View* newRoot = buildContentView(res);
|
||||||
|
|
|
@ -38,6 +38,67 @@ public:
|
||||||
static Space* NewSpaceFromConfigStream(ViewManager& vm, Space* parent, ConfigReader& r);
|
static Space* NewSpaceFromConfigStream(ViewManager& vm, Space* parent, ConfigReader& r);
|
||||||
static RootSpace* NewRootSpaceFromConfigStream(ViewManager& vm, ConfigReader& r);
|
static RootSpace* NewRootSpaceFromConfigStream(ViewManager& vm, ConfigReader& r);
|
||||||
|
|
||||||
|
struct SpaceMenuNode : Specter::IMenuNode
|
||||||
|
{
|
||||||
|
struct SubNodeData : Specter::IMenuNode
|
||||||
|
{
|
||||||
|
Class m_cls;
|
||||||
|
std::string m_key;
|
||||||
|
std::string m_text;
|
||||||
|
const std::string* text() const {return &m_text;}
|
||||||
|
void activated(const boo::SWindowCoord& coord) {}
|
||||||
|
|
||||||
|
SubNodeData(Class cls, const char* key, const char* text)
|
||||||
|
: m_cls(cls), m_key(key), m_text(text) {}
|
||||||
|
};
|
||||||
|
static std::vector<SubNodeData> s_subNodeDats;
|
||||||
|
|
||||||
|
struct SubNode : Specter::IMenuNode
|
||||||
|
{
|
||||||
|
Space& m_space;
|
||||||
|
const SubNodeData& m_data;
|
||||||
|
const std::string* text() const {return &m_data.m_text;}
|
||||||
|
void activated(const boo::SWindowCoord& coord) {}
|
||||||
|
|
||||||
|
SubNode(Space& space, const SubNodeData& data) : m_space(space), m_data(data) {}
|
||||||
|
};
|
||||||
|
std::vector<SubNode> m_subNodes;
|
||||||
|
|
||||||
|
SpaceMenuNode(Space& space)
|
||||||
|
{
|
||||||
|
m_subNodes.reserve(s_subNodeDats.size());
|
||||||
|
for (const SubNodeData& sn : s_subNodeDats)
|
||||||
|
m_subNodes.emplace_back(space, sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string s_text;
|
||||||
|
const std::string* text() const {return &s_text;}
|
||||||
|
|
||||||
|
size_t subNodeCount() const {return m_subNodes.size();}
|
||||||
|
IMenuNode* subNode(size_t idx) {return &m_subNodes[idx];}
|
||||||
|
|
||||||
|
static void initializeStrings(ViewManager& vm);
|
||||||
|
static const std::string* lookupClassString(Class cls)
|
||||||
|
{
|
||||||
|
for (const SubNodeData& sn : s_subNodeDats)
|
||||||
|
if (sn.m_cls == cls)
|
||||||
|
return &sn.m_text;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
} m_spaceMenuNode;
|
||||||
|
|
||||||
|
struct SpaceSelectBind : Specter::IButtonBinding
|
||||||
|
{
|
||||||
|
Space& m_space;
|
||||||
|
const char* name(const Specter::Control* control) const {return SpaceMenuNode::s_text.c_str();}
|
||||||
|
|
||||||
|
MenuStyle menuStyle(const Specter::Button* button) const {return MenuStyle::Primary;}
|
||||||
|
std::unique_ptr<Specter::View> buildMenu(const Specter::Button* button);
|
||||||
|
|
||||||
|
SpaceSelectBind(Space& space) : m_space(space) {}
|
||||||
|
} m_spaceSelectBind;
|
||||||
|
std::unique_ptr<Specter::Button> m_spaceSelectButton;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class ViewManager;
|
friend class ViewManager;
|
||||||
friend class RootSpace;
|
friend class RootSpace;
|
||||||
|
@ -45,7 +106,7 @@ protected:
|
||||||
Class m_class = Class::None;
|
Class m_class = Class::None;
|
||||||
Space* m_parent;
|
Space* m_parent;
|
||||||
std::unique_ptr<Specter::Space> m_spaceView;
|
std::unique_ptr<Specter::Space> m_spaceView;
|
||||||
Space(ViewManager& vm, Class cls, Space* parent) : m_vm(vm), m_class(cls), m_parent(parent) {}
|
Space(ViewManager& vm, Class cls, Space* parent);
|
||||||
|
|
||||||
/* Allows common Space code to access DNA-encoded state */
|
/* Allows common Space code to access DNA-encoded state */
|
||||||
virtual const Space::State& spaceState() const=0;
|
virtual const Space::State& spaceState() const=0;
|
||||||
|
|
|
@ -80,6 +80,7 @@ ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarMan
|
||||||
m_recentProjectsPath(HECL::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().c_str())),
|
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()))
|
m_recentFilesPath(HECL::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().c_str()))
|
||||||
{
|
{
|
||||||
|
Space::SpaceMenuNode::initializeStrings(*this);
|
||||||
char path[2048];
|
char path[2048];
|
||||||
HECL::Sstat theStat;
|
HECL::Sstat theStat;
|
||||||
|
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit c964328bd3c286e6d87d1375549103777045fad8
|
Subproject commit a6c4d42965764850e362dbbfef47bd3022af91cd
|
Loading…
Reference in New Issue