2015-12-13 02:27:34 +00:00
|
|
|
#include "SplashScreen.hpp"
|
2015-12-13 21:01:32 +00:00
|
|
|
#include "version.h"
|
2015-12-13 02:27:34 +00:00
|
|
|
|
2016-01-05 09:53:16 +00:00
|
|
|
namespace URDE
|
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
|
|
|
|
|
|
|
|
SplashScreen::SplashScreen(ViewManager& vm, Specter::ViewResources& res)
|
2015-12-20 19:20:07 +00:00
|
|
|
: ModalWindow(res, vm.rootView(),
|
|
|
|
Specter::RectangleConstraint(SPLASH_WIDTH * res.pixelFactor(),
|
|
|
|
SPLASH_HEIGHT * res.pixelFactor())),
|
|
|
|
m_vm(vm),
|
2015-12-13 02:27:34 +00:00
|
|
|
m_textColor(res.themeData().uiText()),
|
2015-12-15 21:56:40 +00:00
|
|
|
m_textColorClear(m_textColor),
|
2015-12-31 03:20:52 +00:00
|
|
|
m_newString(m_vm.translateOr("new_project", "New Project")),
|
2015-12-15 21:56:40 +00:00
|
|
|
m_newProjBind(*this),
|
2015-12-31 03:20:52 +00:00
|
|
|
m_openString(m_vm.translateOr("open_project", "Open Project")),
|
2015-12-15 21:56:40 +00:00
|
|
|
m_openProjBind(*this),
|
2015-12-31 03:20:52 +00:00
|
|
|
m_extractString(m_vm.translateOr("extract_game", "Extract Game")),
|
2015-12-15 21:56:40 +00:00
|
|
|
m_extractProjBind(*this)
|
2015-12-13 02:27:34 +00:00
|
|
|
{
|
2016-01-17 16:10:33 +00:00
|
|
|
if (GIT_COMMIT_DATE[0] != '\0' &&
|
|
|
|
GIT_COMMIT_HASH[0] != '\0' &&
|
|
|
|
GIT_BRANCH[0] != '\0')
|
|
|
|
{
|
|
|
|
m_buildInfoStr = HECL::Format("%s: %s\n%s: %s\n%s: %s",
|
|
|
|
vm.translateOr("branch", "Branch").c_str(), GIT_BRANCH,
|
|
|
|
vm.translateOr("commit", "Commit").c_str(), GIT_COMMIT_HASH,
|
|
|
|
vm.translateOr("date", "Date").c_str(), GIT_COMMIT_DATE);
|
|
|
|
}
|
|
|
|
|
2016-01-15 03:38:03 +00:00
|
|
|
m_openProjBind.m_openRecentMenuRoot.m_text = vm.translateOr("recent_projects", "Recent Projects");
|
2015-12-13 02:27:34 +00:00
|
|
|
m_textColorClear[3] = 0.0;
|
|
|
|
commitResources(res);
|
|
|
|
}
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
void SplashScreen::think()
|
2015-12-13 02:27:34 +00:00
|
|
|
{
|
2016-01-15 03:38:03 +00:00
|
|
|
if (phase() == Phase::Done)
|
|
|
|
{
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view.reset();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
ModalWindow::think();
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->think();
|
2016-01-08 05:54:00 +00:00
|
|
|
|
2016-01-15 23:35:59 +00:00
|
|
|
if (m_openButt.m_view)
|
|
|
|
m_openButt.m_view->think();
|
|
|
|
|
2016-01-08 05:54:00 +00:00
|
|
|
if (m_newProjBind.m_deferPath.size())
|
|
|
|
{
|
|
|
|
Log.report(LogVisor::Info, _S("Making project '%s'"), m_newProjBind.m_deferPath.c_str());
|
|
|
|
m_vm.projectManager().newProject(m_newProjBind.m_deferPath);
|
|
|
|
m_newProjBind.m_deferPath.clear();
|
|
|
|
}
|
|
|
|
else if (m_openProjBind.m_deferPath.size())
|
|
|
|
{
|
|
|
|
Log.report(LogVisor::Info, _S("Opening project '%s'"), m_openProjBind.m_deferPath.c_str());
|
|
|
|
m_vm.projectManager().openProject(m_openProjBind.m_deferPath);
|
|
|
|
m_openProjBind.m_deferPath.clear();
|
|
|
|
}
|
|
|
|
else if (m_extractProjBind.m_deferPath.size())
|
|
|
|
{
|
|
|
|
Log.report(LogVisor::Info, _S("Extracting game '%s'"), m_extractProjBind.m_deferPath.c_str());
|
|
|
|
m_vm.projectManager().extractGame(m_extractProjBind.m_deferPath);
|
|
|
|
m_extractProjBind.m_deferPath.clear();
|
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
void SplashScreen::updateContentOpacity(float opacity)
|
2015-12-13 02:27:34 +00:00
|
|
|
{
|
|
|
|
Specter::ViewResources& res = rootView().viewRes();
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
if (!m_title && res.fontCacheReady())
|
2016-01-15 23:35:59 +00:00
|
|
|
{
|
2015-12-13 02:27:34 +00:00
|
|
|
m_title.reset(new Specter::TextView(res, *this, res.m_titleFont));
|
|
|
|
Zeus::CColor clearColor = res.themeData().uiText();
|
|
|
|
clearColor[3] = 0.0;
|
2016-01-05 09:53:16 +00:00
|
|
|
m_title->typesetGlyphs("URDE", clearColor);
|
2015-12-13 21:01:32 +00:00
|
|
|
|
|
|
|
m_buildInfo.reset(new Specter::MultiLineTextView(res, *this, res.m_mainFont, Specter::TextView::Alignment::Right));
|
2015-12-31 03:20:52 +00:00
|
|
|
m_buildInfo->typesetGlyphs(m_buildInfoStr, clearColor);
|
2015-12-13 21:01:32 +00:00
|
|
|
|
2015-12-31 03:20:52 +00:00
|
|
|
m_newButt.m_view.reset(new Specter::Button(res, *this, &m_newProjBind, m_newString,
|
|
|
|
Specter::Button::Style::Text));
|
|
|
|
m_openButt.m_view.reset(new Specter::Button(res, *this, &m_openProjBind, m_openString,
|
|
|
|
Specter::Button::Style::Text));
|
|
|
|
m_extractButt.m_view.reset(new Specter::Button(res, *this, &m_extractProjBind, m_extractString,
|
|
|
|
Specter::Button::Style::Text));
|
2015-12-13 21:01:32 +00:00
|
|
|
|
2015-12-13 02:27:34 +00:00
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
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_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
|
|
|
}
|
|
|
|
|
2015-12-13 21:01:32 +00:00
|
|
|
void SplashScreen::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-15 21:56:40 +00:00
|
|
|
if (skipBuildInAnimation())
|
|
|
|
return;
|
2015-12-23 00:26:30 +00:00
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
2015-12-15 21:56:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-23 00:26:30 +00:00
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
2015-12-15 21:56:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::mouseMove(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-23 00:26:30 +00:00
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
2015-12-15 21:56:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::mouseEnter(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-23 00:26:30 +00:00
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
2015-12-15 21:56:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-23 00:26:30 +00:00
|
|
|
if (m_fileBrowser.m_view && !m_fileBrowser.m_view->closed())
|
2015-12-15 21:56:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-20 19:20:07 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::touchDown(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchDown(coord, tid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::touchUp(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchUp(coord, tid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::touchMove(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->touchMove(coord, tid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
|
|
|
{
|
2016-01-02 02:27:46 +00:00
|
|
|
if (skipBuildInAnimation())
|
|
|
|
return;
|
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->charKeyDown(charCode, mods, isRepeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-13 02:27:34 +00:00
|
|
|
void SplashScreen::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
2015-12-15 21:56:40 +00:00
|
|
|
ModalWindow::resized(root, sub);
|
2015-12-13 02:27:34 +00:00
|
|
|
float pf = rootView().viewRes().pixelFactor();
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
boo::SWindowRect centerRect = subRect();
|
2015-12-13 02:27:34 +00:00
|
|
|
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;
|
|
|
|
textRect.location[1] += (SPLASH_HEIGHT - 36) * pf;
|
|
|
|
if (m_title)
|
2015-12-13 21:01:32 +00:00
|
|
|
{
|
2015-12-13 02:27:34 +00:00
|
|
|
m_title->resized(root, textRect);
|
2015-12-13 21:01:32 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + (SPLASH_WIDTH - TEXT_MARGIN) * pf;
|
|
|
|
textRect.location[1] -= 5 * pf;
|
|
|
|
m_buildInfo->resized(root, textRect);
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.size[0] = m_newButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_newButt.m_view->nominalHeight();
|
2015-12-13 21:01:32 +00:00
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH / 4 * pf - m_newButt.m_view->nominalWidth() / 2;
|
|
|
|
m_newButt.m_view->resized(root, textRect);
|
2015-12-13 21:01:32 +00:00
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.size[0] = m_openButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_openButt.m_view->nominalHeight();
|
2015-12-13 21:01:32 +00:00
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 2 / 4 * pf - m_openButt.m_view->nominalWidth() / 2;
|
|
|
|
m_openButt.m_view->resized(root, textRect);
|
2015-12-13 21:01:32 +00:00
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.size[0] = m_extractButt.m_view->nominalWidth();
|
|
|
|
textRect.size[1] = m_extractButt.m_view->nominalHeight();
|
2015-12-13 21:01:32 +00:00
|
|
|
textRect.location[1] = centerRect.location[1] + 20 * pf;
|
2015-12-15 21:56:40 +00:00
|
|
|
textRect.location[0] = centerRect.location[0] + SPLASH_WIDTH * 3 / 4 * pf - m_extractButt.m_view->nominalWidth() / 2;
|
|
|
|
m_extractButt.m_view->resized(root, textRect);
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->resized(root, root);
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SplashScreen::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
2016-01-15 03:38:03 +00:00
|
|
|
if (phase() == Phase::Done)
|
|
|
|
return;
|
2015-12-15 21:56:40 +00:00
|
|
|
ModalWindow::draw(gfxQ);
|
|
|
|
|
|
|
|
if (m_title)
|
2015-12-13 21:01:32 +00:00
|
|
|
{
|
2015-12-13 02:27:34 +00:00
|
|
|
m_title->draw(gfxQ);
|
2015-12-13 21:01:32 +00:00
|
|
|
m_buildInfo->draw(gfxQ);
|
2015-12-15 21:56:40 +00:00
|
|
|
m_newButt.m_view->draw(gfxQ);
|
|
|
|
m_openButt.m_view->draw(gfxQ);
|
|
|
|
m_extractButt.m_view->draw(gfxQ);
|
2015-12-13 21:01:32 +00:00
|
|
|
}
|
2015-12-13 02:27:34 +00:00
|
|
|
|
2015-12-15 21:56:40 +00:00
|
|
|
if (m_fileBrowser.m_view)
|
|
|
|
m_fileBrowser.m_view->draw(gfxQ);
|
2015-12-13 02:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|