metaforce/Editor/SplashScreen/SplashScreen.cpp

194 lines
6.2 KiB
C++
Raw Normal View History

2015-12-12 18:27:34 -08:00
#include "SplashScreen.hpp"
2015-12-13 13:01:32 -08:00
#include "version.h"
2015-12-12 18:27:34 -08:00
namespace RUDE
{
#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 13:01:32 -08:00
#define LINE_WIDTH 2
2015-12-12 18:27:34 -08:00
#define TEXT_MARGIN 10
SplashScreen::SplashScreen(ViewManager& vm, Specter::ViewResources& res)
2015-12-17 19:26:43 -08:00
: ModalWindow(res, vm.rootView(), SPLASH_WIDTH * res.pixelFactor(), SPLASH_HEIGHT * res.pixelFactor()), m_vm(vm),
2015-12-12 18:27:34 -08:00
m_textColor(res.themeData().uiText()),
2015-12-15 13:56:40 -08:00
m_textColorClear(m_textColor),
m_newProjBind(*this),
m_openProjBind(*this),
m_extractProjBind(*this)
2015-12-12 18:27:34 -08:00
{
m_textColorClear[3] = 0.0;
commitResources(res);
}
2015-12-15 13:56:40 -08:00
void SplashScreen::think()
2015-12-12 18:27:34 -08:00
{
2015-12-15 13:56:40 -08:00
ModalWindow::think();
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->think();
2015-12-12 18:27:34 -08:00
}
2015-12-15 13:56:40 -08:00
void SplashScreen::updateContentOpacity(float opacity)
2015-12-12 18:27:34 -08:00
{
Specter::ViewResources& res = rootView().viewRes();
2015-12-15 13:56:40 -08:00
if (!m_title && res.fontCacheReady())
2015-12-12 18:27:34 -08:00
{
m_title.reset(new Specter::TextView(res, *this, res.m_titleFont));
Zeus::CColor clearColor = res.themeData().uiText();
clearColor[3] = 0.0;
m_title->typesetGlyphs("RUDE", clearColor);
2015-12-13 13:01:32 -08:00
m_buildInfo.reset(new Specter::MultiLineTextView(res, *this, res.m_mainFont, Specter::TextView::Alignment::Right));
m_buildInfo->typesetGlyphs(HECL::Format("Branch: %s\nCommit: %s\nDate: %s",
GIT_BRANCH, GIT_COMMIT_HASH, GIT_COMMIT_DATE),
clearColor);
2015-12-15 13:56:40 -08:00
m_newButt.m_view.reset(new Specter::Button(res, *this, &m_newProjBind, "New Project", Specter::Button::Style::Text));
m_openButt.m_view.reset(new Specter::Button(res, *this, &m_openProjBind, "Open Project", Specter::Button::Style::Text));
m_extractButt.m_view.reset(new Specter::Button(res, *this, &m_extractProjBind, "Extract Game", Specter::Button::Style::Text));
2015-12-13 13:01:32 -08:00
2015-12-12 18:27:34 -08:00
updateSize();
}
2015-12-15 13:56:40 -08: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-12 18:27:34 -08:00
}
2015-12-13 13:01:32 -08:00
void SplashScreen::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
2015-12-15 13:56:40 -08:00
if (skipBuildInAnimation())
return;
if (m_fileBrowser.m_view)
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 13:01:32 -08:00
}
void SplashScreen::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
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 13:01:32 -08:00
}
void SplashScreen::mouseMove(const boo::SWindowCoord& coord)
{
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->mouseMove(coord);
else
{
m_newButt.mouseMove(coord);
m_openButt.mouseMove(coord);
m_extractButt.mouseMove(coord);
}
2015-12-13 13:01:32 -08:00
}
void SplashScreen::mouseEnter(const boo::SWindowCoord& coord)
{
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->mouseEnter(coord);
else
{
m_newButt.mouseEnter(coord);
m_openButt.mouseEnter(coord);
m_extractButt.mouseEnter(coord);
}
2015-12-13 13:01:32 -08:00
}
void SplashScreen::mouseLeave(const boo::SWindowCoord& coord)
{
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->mouseLeave(coord);
else
{
m_newButt.mouseLeave(coord);
m_openButt.mouseLeave(coord);
m_extractButt.mouseLeave(coord);
}
2015-12-13 13:01:32 -08:00
}
2015-12-12 18:27:34 -08:00
void SplashScreen::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
{
2015-12-15 13:56:40 -08:00
ModalWindow::resized(root, sub);
2015-12-12 18:27:34 -08:00
float pf = rootView().viewRes().pixelFactor();
2015-12-15 13:56:40 -08:00
boo::SWindowRect centerRect = subRect();
2015-12-12 18:27:34 -08: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 13:01:32 -08:00
{
2015-12-12 18:27:34 -08:00
m_title->resized(root, textRect);
2015-12-13 13:01:32 -08: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 13:56:40 -08:00
textRect.size[0] = m_newButt.m_view->nominalWidth();
textRect.size[1] = m_newButt.m_view->nominalHeight();
2015-12-13 13:01:32 -08:00
textRect.location[1] = centerRect.location[1] + 20 * pf;
2015-12-15 13:56:40 -08: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 13:01:32 -08:00
2015-12-15 13:56:40 -08:00
textRect.size[0] = m_openButt.m_view->nominalWidth();
textRect.size[1] = m_openButt.m_view->nominalHeight();
2015-12-13 13:01:32 -08:00
textRect.location[1] = centerRect.location[1] + 20 * pf;
2015-12-15 13:56:40 -08: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 13:01:32 -08:00
2015-12-15 13:56:40 -08:00
textRect.size[0] = m_extractButt.m_view->nominalWidth();
textRect.size[1] = m_extractButt.m_view->nominalHeight();
2015-12-13 13:01:32 -08:00
textRect.location[1] = centerRect.location[1] + 20 * pf;
2015-12-15 13:56:40 -08: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 13:01:32 -08:00
}
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->resized(root, root);
2015-12-12 18:27:34 -08:00
}
void SplashScreen::draw(boo::IGraphicsCommandQueue* gfxQ)
{
2015-12-15 13:56:40 -08:00
ModalWindow::draw(gfxQ);
if (m_title)
2015-12-13 13:01:32 -08:00
{
2015-12-12 18:27:34 -08:00
m_title->draw(gfxQ);
2015-12-13 13:01:32 -08:00
m_buildInfo->draw(gfxQ);
2015-12-15 13:56:40 -08:00
m_newButt.m_view->draw(gfxQ);
m_openButt.m_view->draw(gfxQ);
m_extractButt.m_view->draw(gfxQ);
2015-12-13 13:01:32 -08:00
}
2015-12-12 18:27:34 -08:00
2015-12-15 13:56:40 -08:00
if (m_fileBrowser.m_view)
m_fileBrowser.m_view->draw(gfxQ);
2015-12-12 18:27:34 -08:00
}
}