2015-12-13 02:27:34 +00:00
|
|
|
#include "SplashScreen.hpp"
|
2015-12-13 21:01:32 +00:00
|
|
|
#include "version.h"
|
2016-07-16 19:21:12 +00:00
|
|
|
#include "badging/Badging.hpp"
|
2015-12-13 02:27:34 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2015-12-13 02:27:34 +00:00
|
|
|
|
|
|
|
#define SPLASH_WIDTH 555
|
|
|
|
#define SPLASH_HEIGHT 300
|
|
|
|
|
|
|
|
#define WIRE_START 0
|
|
|
|
#define WIRE_FRAMES 60
|
|
|
|
#define SOLID_START 40
|
|
|
|
#define SOLID_FRAMES 40
|
|
|
|
#define TEXT_START 80
|
|
|
|
#define TEXT_FRAMES 40
|
|
|
|
|
2015-12-13 21:01:32 +00:00
|
|
|
#define LINE_WIDTH 2
|
2015-12-13 02:27:34 +00:00
|
|
|
#define TEXT_MARGIN 10
|
|
|
|
|
2016-07-16 19:21:12 +00:00
|
|
|
#define BADGE_WIDTH 551
|
|
|
|
#define BADGE_HEIGHT 217
|
|
|
|
#define BADGE_MARGIN 35
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
SplashScreen::SplashScreen(ViewManager& vm, specter::ViewResources& res)
|
2015-12-20 19:20:07 +00:00
|
|
|
: ModalWindow(res, vm.rootView(),
|
2018-12-08 05:30:43 +00:00
|
|
|
specter::RectangleConstraint(SPLASH_WIDTH * res.pixelFactor(), SPLASH_HEIGHT * res.pixelFactor()))
|
|
|
|
, m_vm(vm)
|
|
|
|
, m_textColor(res.themeData().uiText())
|
|
|
|
, m_textColorClear(m_textColor)
|
2019-07-20 04:27:21 +00:00
|
|
|
, m_newString(m_vm.translate<locale::new_project>())
|
|
|
|
, m_openString(m_vm.translate<locale::open_project>())
|
|
|
|
, m_extractString(m_vm.translate<locale::extract_game>())
|
2018-12-08 05:30:43 +00:00
|
|
|
, m_newProjBind(*this)
|
|
|
|
, m_openProjBind(*this)
|
|
|
|
, m_extractProjBind(*this) {
|
2021-04-06 22:58:11 +00:00
|
|
|
if (METAFORCE_WC_DATE[0] != '\0' && METAFORCE_WC_REVISION[0] != '\0' && METAFORCE_WC_BRANCH[0] != '\0') {
|
2021-03-29 22:32:55 +00:00
|
|
|
m_buildInfoStr = fmt::format(FMT_STRING("{}: {}\n{}: {}\n{}: {}"),
|
2021-04-06 22:58:11 +00:00
|
|
|
vm.translate<locale::version>(), METAFORCE_WC_DESCRIBE,
|
|
|
|
vm.translate<locale::branch>(), METAFORCE_WC_BRANCH,
|
|
|
|
vm.translate<locale::commit>(), METAFORCE_WC_REVISION/*,
|
|
|
|
vm.translate<locale::date>(), METAFORCE_WC_DATE*/);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2019-07-20 04:27:21 +00:00
|
|
|
m_openProjBind.m_openRecentMenuRoot.m_text = vm.translate<locale::recent_projects>();
|
2018-12-08 05:30:43 +00:00
|
|
|
m_textColorClear[3] = 0.0;
|
|
|
|
}
|
2016-01-15 03:38:03 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::think() {
|
|
|
|
if (phase() == Phase::Done) {
|
2015-12-15 21:56:40 +00:00
|
|
|
if (m_fileBrowser.m_view)
|
2018-12-08 05:30:43 +00:00
|
|
|
m_fileBrowser.m_view.reset();
|
|
|
|
return;
|
|
|
|
}
|
2021-04-03 16:48:39 +00:00
|
|
|
OPTICK_EVENT();
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
ModalWindow::think();
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->think();
|
|
|
|
|
|
|
|
if (m_openButt.m_view)
|
|
|
|
m_openButt.m_view->think();
|
|
|
|
|
|
|
|
if (m_newProjBind.m_deferPath.size()) {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Making project '{}'")), m_newProjBind.m_deferPath);
|
2018-12-08 05:30:43 +00:00
|
|
|
m_vm.projectManager().newProject(m_newProjBind.m_deferPath);
|
|
|
|
m_newProjBind.m_deferPath.clear();
|
|
|
|
} else if (m_openProjBind.m_deferPath.size()) {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Opening project '{}'")), m_openProjBind.m_deferPath);
|
2018-12-08 05:30:43 +00:00
|
|
|
m_vm.projectManager().openProject(m_openProjBind.m_deferPath);
|
|
|
|
m_openProjBind.m_deferPath.clear();
|
|
|
|
} else if (m_extractProjBind.m_deferPath.size()) {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Extracting game '{}'")), m_extractProjBind.m_deferPath);
|
2018-12-08 05:30:43 +00:00
|
|
|
m_vm.projectManager().extractGame(m_extractProjBind.m_deferPath);
|
|
|
|
m_extractProjBind.m_deferPath.clear();
|
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::updateContentOpacity(float opacity) {
|
|
|
|
specter::ViewResources& res = rootView().viewRes();
|
2015-12-13 02:27:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!m_title && res.fontCacheReady()) {
|
|
|
|
m_title.reset(new specter::TextView(res, *this, res.m_titleFont));
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CColor clearColor = res.themeData().uiText();
|
2015-12-15 21:56:40 +00:00
|
|
|
clearColor[3] = 0.0;
|
2018-12-08 05:30:43 +00:00
|
|
|
m_title->typesetGlyphs("URDE", clearColor);
|
|
|
|
|
|
|
|
m_buildInfo.reset(new specter::MultiLineTextView(res, *this, res.m_mainFont, specter::TextView::Alignment::Right));
|
|
|
|
m_buildInfo->typesetGlyphs(m_buildInfoStr, clearColor);
|
|
|
|
|
|
|
|
m_badgeIcon.reset(new specter::IconView(res, *this, GetBadge()));
|
|
|
|
m_badgeText.reset(new specter::TextView(res, *this, res.m_heading18, specter::TextView::Alignment::Right));
|
|
|
|
m_badgeText->typesetGlyphs(BADGE_PHRASE, clearColor);
|
|
|
|
|
|
|
|
m_newButt.m_view.reset(
|
|
|
|
new specter::Button(res, *this, &m_newProjBind, m_newString, nullptr, specter::Button::Style::Text));
|
|
|
|
m_openButt.m_view.reset(
|
|
|
|
new specter::Button(res, *this, &m_openProjBind, m_openString, nullptr, specter::Button::Style::Text));
|
|
|
|
m_extractButt.m_view.reset(
|
|
|
|
new specter::Button(res, *this, &m_extractProjBind, m_extractString, nullptr, specter::Button::Style::Text));
|
|
|
|
|
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CColor clearColor = res.themeData().uiText();
|
|
|
|
clearColor[3] = 0.0;
|
|
|
|
zeus::CColor color = zeus::CColor::lerp(clearColor, res.themeData().uiText(), opacity);
|
|
|
|
m_title->colorGlyphs(color);
|
|
|
|
m_buildInfo->colorGlyphs(color);
|
|
|
|
m_badgeIcon->setMultiplyColor({1.f, 1.f, 1.f, color.a()});
|
|
|
|
m_badgeText->colorGlyphs(color);
|
|
|
|
m_newButt.m_view->colorGlyphs(color);
|
|
|
|
m_openButt.m_view->colorGlyphs(color);
|
|
|
|
m_extractButt.m_view->colorGlyphs(color);
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
|
|
|
if (skipBuildInAnimation())
|
|
|
|
return;
|
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
|
|
|
m_fileBrowser.m_view->mouseDown(coord, button, mod);
|
|
|
|
else {
|
|
|
|
m_newButt.mouseDown(coord, button, mod);
|
|
|
|
m_openButt.mouseDown(coord, button, mod);
|
|
|
|
m_extractButt.mouseDown(coord, button, mod);
|
|
|
|
}
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
|
|
|
m_fileBrowser.m_view->mouseUp(coord, button, mod);
|
|
|
|
else {
|
|
|
|
m_newButt.mouseUp(coord, button, mod);
|
|
|
|
m_openButt.mouseUp(coord, button, mod);
|
|
|
|
m_extractButt.mouseUp(coord, button, mod);
|
|
|
|
}
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::mouseMove(const boo::SWindowCoord& coord) {
|
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
|
|
|
m_fileBrowser.m_view->mouseMove(coord);
|
|
|
|
else {
|
|
|
|
m_newButt.mouseMove(coord);
|
|
|
|
m_openButt.mouseMove(coord);
|
|
|
|
m_extractButt.mouseMove(coord);
|
|
|
|
}
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::mouseEnter(const boo::SWindowCoord& coord) {
|
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
|
|
|
m_fileBrowser.m_view->mouseEnter(coord);
|
|
|
|
else {
|
|
|
|
m_newButt.mouseEnter(coord);
|
|
|
|
m_openButt.mouseEnter(coord);
|
|
|
|
m_extractButt.mouseEnter(coord);
|
|
|
|
}
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::mouseLeave(const boo::SWindowCoord& coord) {
|
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
|
|
|
m_fileBrowser.m_view->mouseLeave(coord);
|
|
|
|
else {
|
|
|
|
m_newButt.mouseLeave(coord);
|
|
|
|
m_openButt.mouseLeave(coord);
|
|
|
|
m_extractButt.mouseLeave(coord);
|
|
|
|
}
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll) {
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->scroll(coord, scroll);
|
2015-12-20 19:20:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::touchDown(const boo::STouchCoord& coord, uintptr_t tid) {
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchDown(coord, tid);
|
2015-12-20 19:20:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::touchUp(const boo::STouchCoord& coord, uintptr_t tid) {
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchUp(coord, tid);
|
2015-12-20 19:20:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::touchMove(const boo::STouchCoord& coord, uintptr_t tid) {
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchMove(coord, tid);
|
2015-12-20 19:20:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat) {
|
|
|
|
if (skipBuildInAnimation())
|
|
|
|
return;
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->charKeyDown(charCode, mods, isRepeat);
|
2016-01-02 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat) {
|
|
|
|
if (skipBuildInAnimation())
|
|
|
|
return;
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->specialKeyDown(key, mods, isRepeat);
|
2015-12-20 19:20:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
|
|
|
ModalWindow::resized(root, sub);
|
|
|
|
float pf = rootView().viewRes().pixelFactor();
|
|
|
|
|
|
|
|
boo::SWindowRect centerRect = subRect();
|
|
|
|
centerRect.location[0] = root.size[0] / 2 - (SPLASH_WIDTH * pf / 2.0);
|
|
|
|
centerRect.location[1] = root.size[1] / 2 - (SPLASH_HEIGHT * pf / 2.0);
|
|
|
|
|
|
|
|
boo::SWindowRect badgeRect = centerRect;
|
|
|
|
badgeRect.location[0] += LINE_WIDTH * pf;
|
|
|
|
badgeRect.location[1] += BADGE_MARGIN * pf;
|
|
|
|
badgeRect.size[0] = BADGE_WIDTH * pf;
|
|
|
|
badgeRect.size[1] = BADGE_HEIGHT * pf;
|
|
|
|
|
|
|
|
boo::SWindowRect textRect = centerRect;
|
|
|
|
textRect.location[0] += TEXT_MARGIN * pf;
|
|
|
|
textRect.location[1] += (SPLASH_HEIGHT - 36) * pf;
|
|
|
|
if (m_title) {
|
|
|
|
m_title->resized(root, textRect);
|
|
|
|
textRect.location[0] = centerRect.location[0] + (SPLASH_WIDTH - TEXT_MARGIN) * pf;
|
|
|
|
textRect.location[1] -= 5 * pf;
|
|
|
|
m_buildInfo->resized(root, textRect);
|
|
|
|
|
|
|
|
textRect.location[0] = centerRect.location[0] + (SPLASH_WIDTH - TEXT_MARGIN) * pf;
|
|
|
|
textRect.location[1] = centerRect.location[1] + (BADGE_MARGIN + TEXT_MARGIN) * pf;
|
|
|
|
m_badgeIcon->resized(root, badgeRect);
|
|
|
|
m_badgeText->resized(root, textRect);
|
|
|
|
|
|
|
|
textRect.size[0] = m_newButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_newButt.m_view->nominalHeight();
|
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH / 4 * pf - m_newButt.m_view->nominalWidth() / 2;
|
|
|
|
m_newButt.m_view->resized(root, textRect);
|
|
|
|
|
|
|
|
textRect.size[0] = m_openButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_openButt.m_view->nominalHeight();
|
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 2 / 4 * pf - m_openButt.m_view->nominalWidth() / 2;
|
|
|
|
m_openButt.m_view->resized(root, textRect);
|
|
|
|
|
|
|
|
textRect.size[0] = m_extractButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_extractButt.m_view->nominalHeight();
|
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
|
|
|
textRect.location[0] =
|
|
|
|
centerRect.location[0] + SPLASH_WIDTH * 3 / 4 * pf - m_extractButt.m_view->nominalWidth() / 2;
|
|
|
|
m_extractButt.m_view->resized(root, textRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->resized(root, root);
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::draw(boo::IGraphicsCommandQueue* gfxQ) {
|
|
|
|
if (phase() == Phase::Done)
|
|
|
|
return;
|
|
|
|
ModalWindow::draw(gfxQ);
|
|
|
|
|
|
|
|
if (m_title) {
|
|
|
|
m_title->draw(gfxQ);
|
|
|
|
m_buildInfo->draw(gfxQ);
|
|
|
|
m_badgeIcon->draw(gfxQ);
|
|
|
|
m_badgeText->draw(gfxQ);
|
|
|
|
m_newButt.m_view->draw(gfxQ);
|
|
|
|
m_openButt.m_view->draw(gfxQ);
|
|
|
|
m_extractButt.m_view->draw(gfxQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->draw(gfxQ);
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|