metaforce/Editor/SplashScreen.hpp

188 lines
7.7 KiB
C++
Raw Normal View History

2016-01-05 09:53:16 +00:00
#ifndef URDE_SPLASH_SCREEN_HPP
#define URDE_SPLASH_SCREEN_HPP
2015-12-13 02:27:34 +00:00
2016-03-04 23:04:53 +00:00
#include <specter/View.hpp>
#include <specter/ModalWindow.hpp>
#include <specter/MultiLineTextView.hpp>
#include <specter/FileBrowser.hpp>
#include <specter/Menu.hpp>
2016-07-16 19:21:12 +00:00
#include <specter/Icon.hpp>
2015-12-13 02:27:34 +00:00
#include "ViewManager.hpp"
2016-03-05 00:03:41 +00:00
namespace urde
2015-12-13 02:27:34 +00:00
{
2016-03-04 23:04:53 +00:00
static logvisor::Module Log("specter::SplashScreen");
2016-01-02 02:27:46 +00:00
2016-03-04 23:04:53 +00:00
class SplashScreen : public specter::ModalWindow
2015-12-13 02:27:34 +00:00
{
ViewManager& m_vm;
2016-03-04 23:04:53 +00:00
zeus::CColor m_textColor;
zeus::CColor m_textColorClear;
2015-12-13 02:27:34 +00:00
2016-03-04 23:04:53 +00:00
std::unique_ptr<specter::TextView> m_title;
2015-12-31 03:20:52 +00:00
std::string m_buildInfoStr;
2016-03-04 23:04:53 +00:00
std::unique_ptr<specter::MultiLineTextView> m_buildInfo;
2016-07-16 19:21:12 +00:00
std::unique_ptr<specter::IconView> m_badgeIcon;
std::unique_ptr<specter::TextView> m_badgeText;
2015-12-13 21:01:32 +00:00
2015-12-31 03:20:52 +00:00
std::string m_newString;
2016-03-04 23:04:53 +00:00
specter::ViewChild<std::unique_ptr<specter::Button>> m_newButt;
2015-12-31 03:20:52 +00:00
std::string m_openString;
2016-03-04 23:04:53 +00:00
specter::ViewChild<std::unique_ptr<specter::Button>> m_openButt;
2015-12-31 03:20:52 +00:00
std::string m_extractString;
2016-03-04 23:04:53 +00:00
specter::ViewChild<std::unique_ptr<specter::Button>> m_extractButt;
2015-12-13 02:27:34 +00:00
2016-03-04 23:04:53 +00:00
specter::ViewChild<std::unique_ptr<specter::FileBrowser>> m_fileBrowser;
2015-12-13 21:01:32 +00:00
2016-03-04 23:04:53 +00:00
struct NewProjBinding : specter::IButtonBinding
2015-12-13 21:01:32 +00:00
{
2015-12-15 21:56:40 +00:00
SplashScreen& m_splash;
2016-03-04 23:04:53 +00:00
hecl::SystemString m_deferPath;
2015-12-15 21:56:40 +00:00
NewProjBinding(SplashScreen& splash) : m_splash(splash) {}
2016-03-04 23:04:53 +00:00
const char* name(const specter::Control* control) const {return m_splash.m_newString.c_str();}
const char* help(const specter::Control* control) const {return "Creates an empty project at selected path";}
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
2015-12-13 21:01:32 +00:00
{
2015-12-30 22:05:17 +00:00
m_splash.m_fileBrowser.m_view.reset(
2016-03-04 23:04:53 +00:00
new specter::FileBrowser(m_splash.rootView().viewRes(),
2015-12-31 03:20:52 +00:00
m_splash, m_splash.m_newString,
2016-03-04 23:04:53 +00:00
specter::FileBrowser::Type::NewHECLProject,
[&](bool ok, const hecl::SystemString& path)
2016-01-02 02:27:46 +00:00
{
2016-01-03 04:06:18 +00:00
if (ok)
2016-01-08 05:54:00 +00:00
m_deferPath = path;
2016-01-02 02:27:46 +00:00
}));
2015-12-15 21:56:40 +00:00
m_splash.updateSize();
m_splash.m_newButt.mouseLeave(coord);
2015-12-13 21:01:32 +00:00
}
} m_newProjBind;
2016-03-04 23:04:53 +00:00
struct OpenProjBinding : specter::IButtonBinding
2015-12-13 21:01:32 +00:00
{
2015-12-15 21:56:40 +00:00
SplashScreen& m_splash;
2016-03-04 23:04:53 +00:00
hecl::SystemString m_deferPath;
2016-01-15 03:38:03 +00:00
OpenProjBinding(SplashScreen& splash) : m_splash(splash), m_openRecentMenuRoot(*this) {}
2016-03-04 23:04:53 +00:00
const char* name(const specter::Control* control) const {return m_splash.m_openString.c_str();}
const char* help(const specter::Control* control) const {return "Opens an existing project at selected path";}
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
2015-12-13 21:01:32 +00:00
{
2015-12-30 22:05:17 +00:00
m_splash.m_fileBrowser.m_view.reset(
2016-03-04 23:04:53 +00:00
new specter::FileBrowser(m_splash.rootView().viewRes(),
2015-12-31 03:20:52 +00:00
m_splash, m_splash.m_openString,
2016-03-04 23:04:53 +00:00
specter::FileBrowser::Type::OpenHECLProject,
[&](bool ok, const hecl::SystemString& path)
2016-01-02 02:27:46 +00:00
{
2016-01-03 04:06:18 +00:00
if (ok)
2016-01-08 05:54:00 +00:00
m_deferPath = path;
2016-01-02 02:27:46 +00:00
}));
2015-12-15 21:56:40 +00:00
m_splash.updateSize();
m_splash.m_openButt.mouseLeave(coord);
2015-12-13 21:01:32 +00:00
}
2016-01-15 03:38:03 +00:00
2016-03-04 23:04:53 +00:00
struct OpenRecentMenuRoot : specter::IMenuNode
2016-01-15 03:38:03 +00:00
{
OpenProjBinding& m_openProjBind;
OpenRecentMenuRoot(OpenProjBinding& openProjBind) : m_openProjBind(openProjBind) {}
std::string m_text;
const std::string* text() const {return &m_text;}
2016-03-04 23:04:53 +00:00
struct OpenRecentMenuItem : specter::IMenuNode
2016-01-15 03:38:03 +00:00
{
OpenRecentMenuRoot& m_parent;
2016-03-04 23:04:53 +00:00
hecl::SystemString m_path;
2016-01-15 03:38:03 +00:00
std::string m_text;
const std::string* text() const {return &m_text;}
2016-01-16 03:58:11 +00:00
void activated(const boo::SWindowCoord& coord)
{
m_parent.m_openProjBind.m_deferPath = m_path;
m_parent.m_openProjBind.m_splash.m_openButt.m_view->closeMenu(coord);
}
2016-01-15 03:38:03 +00:00
2016-03-04 23:04:53 +00:00
OpenRecentMenuItem(OpenRecentMenuRoot& parent, const hecl::SystemString& path)
2016-01-15 03:38:03 +00:00
: m_parent(parent), m_path(path)
{
2016-03-04 23:04:53 +00:00
std::vector<hecl::SystemString> pathComps = specter::FileBrowser::PathComponents(path);
2016-01-15 03:38:03 +00:00
if (pathComps.size())
2016-03-04 23:04:53 +00:00
m_text = hecl::SystemUTF8View(pathComps.back()).str();
2016-01-15 03:38:03 +00:00
}
};
std::vector<OpenRecentMenuItem> m_items;
size_t subNodeCount() const {return m_items.size();}
2016-03-04 23:04:53 +00:00
specter::IMenuNode* subNode(size_t idx) {return &m_items[idx];}
2016-01-15 03:38:03 +00:00
2016-03-04 23:04:53 +00:00
void buildNodes(const std::vector<hecl::SystemString>* recentProjects)
2016-01-15 03:38:03 +00:00
{
m_items.clear();
if (recentProjects)
{
m_items.reserve(recentProjects->size());
2016-03-04 23:04:53 +00:00
for (const hecl::SystemString& path : *recentProjects)
2016-01-15 03:38:03 +00:00
m_items.emplace_back(*this, path);
}
}
} m_openRecentMenuRoot;
2016-03-04 23:04:53 +00:00
MenuStyle menuStyle(const specter::Button* button) const {return MenuStyle::Auxiliary;}
std::unique_ptr<View> buildMenu(const specter::Button* button)
2016-01-15 03:38:03 +00:00
{
m_openRecentMenuRoot.buildNodes(m_splash.m_vm.recentProjects());
2016-03-04 23:04:53 +00:00
return std::unique_ptr<View>(new specter::Menu(m_splash.rootView().viewRes(),
2016-01-15 03:38:03 +00:00
m_splash, &m_openRecentMenuRoot));
}
2015-12-13 21:01:32 +00:00
} m_openProjBind;
2016-03-04 23:04:53 +00:00
struct ExtractProjBinding : specter::IButtonBinding
2015-12-13 21:01:32 +00:00
{
2015-12-15 21:56:40 +00:00
SplashScreen& m_splash;
2016-03-04 23:04:53 +00:00
hecl::SystemString m_deferPath;
2015-12-15 21:56:40 +00:00
ExtractProjBinding(SplashScreen& splash) : m_splash(splash) {}
2016-03-04 23:04:53 +00:00
const char* name(const specter::Control* control) const {return m_splash.m_extractString.c_str();}
const char* help(const specter::Control* control) const {return "Extracts game image as project at selected path";}
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
2015-12-13 21:01:32 +00:00
{
2015-12-30 22:05:17 +00:00
m_splash.m_fileBrowser.m_view.reset(
2016-03-04 23:04:53 +00:00
new specter::FileBrowser(m_splash.rootView().viewRes(),
2015-12-31 03:20:52 +00:00
m_splash, m_splash.m_extractString,
2016-03-04 23:04:53 +00:00
specter::FileBrowser::Type::OpenFile,
[&](bool ok, const hecl::SystemString& path)
2016-01-02 02:27:46 +00:00
{
2016-01-03 04:06:18 +00:00
if (ok)
2016-01-08 05:54:00 +00:00
m_deferPath = path;
2016-01-02 02:27:46 +00:00
}));
2015-12-15 21:56:40 +00:00
m_splash.updateSize();
m_splash.m_extractButt.mouseLeave(coord);
2015-12-13 21:01:32 +00:00
}
} m_extractProjBind;
2015-12-13 02:27:34 +00:00
public:
2016-03-04 23:04:53 +00:00
SplashScreen(ViewManager& vm, specter::ViewResources& res);
2015-12-13 02:27:34 +00:00
void think();
2015-12-15 21:56:40 +00:00
void updateContentOpacity(float opacity);
2015-12-13 02:27:34 +00:00
2015-12-13 21:01:32 +00:00
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
2015-12-20 19:20:07 +00:00
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta&);
void touchDown(const boo::STouchCoord&, uintptr_t);
void touchUp(const boo::STouchCoord&, uintptr_t);
void touchMove(const boo::STouchCoord&, uintptr_t);
void charKeyDown(unsigned long, boo::EModifierKey, bool);
2016-01-02 02:27:46 +00:00
void specialKeyDown(boo::ESpecialKey, boo::EModifierKey, bool);
2015-12-20 19:20:07 +00:00
2015-12-13 02:27:34 +00:00
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
};
}
2016-01-05 09:53:16 +00:00
#endif // URDE_SPLASH_SCREEN_HPP