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
|
2021-05-23 03:25:27 +00:00
|
|
|
#define SPLASH_HEIGHT 100
|
2015-12-13 02:27:34 +00:00
|
|
|
|
|
|
|
#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-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)
|
2021-05-23 03:25:27 +00:00
|
|
|
, m_textColor(res.themeData().uiText()) {
|
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
|
|
|
}
|
|
|
|
}
|
2016-01-15 03:38:03 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SplashScreen::think() {
|
|
|
|
if (phase() == Phase::Done) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-03 16:48:39 +00:00
|
|
|
OPTICK_EVENT();
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
ModalWindow::think();
|
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;
|
2021-05-23 03:25:27 +00:00
|
|
|
m_title->typesetGlyphs("Metaforce", clearColor);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
m_buildInfo.reset(new specter::MultiLineTextView(res, *this, res.m_mainFont, specter::TextView::Alignment::Right));
|
|
|
|
m_buildInfo->typesetGlyphs(m_buildInfoStr, clearColor);
|
|
|
|
|
2021-05-23 03:25:27 +00:00
|
|
|
m_badgeText.reset(new specter::TextView(res, *this, res.m_heading18));
|
2018-12-08 05:30:43 +00:00
|
|
|
m_badgeText->typesetGlyphs(BADGE_PHRASE, clearColor);
|
|
|
|
|
2021-05-23 03:25:27 +00:00
|
|
|
m_infoStr = std::make_unique<specter::TextView>(res, *this, res.m_mainFont);
|
|
|
|
m_infoStr->typesetGlyphs("No game detected. Use metaforce-gui or check README for command-line options."sv, clearColor);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
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_badgeText->colorGlyphs(color);
|
2021-05-23 03:25:27 +00:00
|
|
|
m_infoStr->colorGlyphs(color);
|
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 textRect = centerRect;
|
|
|
|
textRect.location[0] += TEXT_MARGIN * pf;
|
2021-05-23 03:25:27 +00:00
|
|
|
textRect.location[1] += (SPLASH_HEIGHT - 28) * pf;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m_title) {
|
|
|
|
m_title->resized(root, textRect);
|
|
|
|
|
2021-05-23 03:25:27 +00:00
|
|
|
textRect.location[1] -= m_title->nominalHeight() * 0.75;
|
2018-12-08 05:30:43 +00:00
|
|
|
m_badgeText->resized(root, textRect);
|
|
|
|
|
2021-05-23 03:25:27 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + (SPLASH_WIDTH - TEXT_MARGIN) * pf;
|
|
|
|
textRect.location[1] = centerRect.location[1] + (SPLASH_HEIGHT - 36) * pf - 5 * pf;
|
|
|
|
m_buildInfo->resized(root, textRect);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2021-05-23 03:25:27 +00:00
|
|
|
textRect.size[0] = m_infoStr->nominalWidth();
|
|
|
|
textRect.size[1] = m_infoStr->nominalHeight();
|
2018-12-08 05:30:43 +00:00
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
2021-05-23 03:25:27 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 2 / 4 * pf - m_infoStr->nominalWidth() / 2;
|
|
|
|
m_infoStr->resized(root, textRect);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
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_badgeText->draw(gfxQ);
|
2021-05-23 03:25:27 +00:00
|
|
|
m_infoStr->draw(gfxQ);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|