From 7ef4d2f89eac79e6b75b9fccb02470fb3629a2a7 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Fri, 18 Apr 2014 12:27:00 -0500 Subject: [PATCH 1/2] Display number of games available under SystemView. --- src/views/SystemView.cpp | 47 ++++++++++++++++++++++++++++++++++++++-- src/views/SystemView.h | 2 ++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 5f8f7d2de..8070400e0 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -6,16 +6,24 @@ #include "ViewController.h" #include "../animations/LambdaAnimation.h" #include "../SystemData.h" +#include "../Util.h" #define SELECTED_SCALE 1.5f #define LOGO_PADDING ((logoSize().x() * (SELECTED_SCALE - 1)/2) + (mSize.x() * 0.06f)) -SystemView::SystemView(Window* window) : IList(window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP) +SystemView::SystemView(Window* window) : IList(window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP), + mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x77777700, TextComponent::ALIGN_CENTER) { mCamOffset = 0; setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); + mSystemInfo.setSize(mSize.x(), 0); + + float yOff = (mSize.y() - logoSize().y())/2; + mSystemInfo.setPosition(0, (yOff - (logoSize().y() * (SELECTED_SCALE - 1)) / 2) + (logoSize().y() * SELECTED_SCALE) - mSystemInfo.getSize().y()); + //(mSize.y() - mSystemInfo.getSize().y()) / 2); + populate(); } @@ -141,8 +149,41 @@ void SystemView::onCursorChanged(const CursorState& state) f -= posMax; this->mCamOffset = f; }, 500); + setAnimation(anim, 0, nullptr, false, 0); - setAnimation(anim); + // animate mSystemInfo's opacity (fade out, wait, fade back in) + + cancelAnimation(1); + cancelAnimation(2); + + const float infoStartOpacity = mSystemInfo.getOpacity() / 255.f; + + Animation* infoFadeOut = new LambdaAnimation( + [infoStartOpacity, this] (float t) + { + mSystemInfo.setOpacity((unsigned char)(lerp(infoStartOpacity, 0.f, t) * 255)); + }, (int)(infoStartOpacity * 300)); + + // also change the text after we've fully faded out + setAnimation(infoFadeOut, 0, [this] { + std::stringstream ss; + unsigned int gameCount = getSelected()->getGameCount(); + + // only display a game count if there are at least 2 games + if(gameCount > 1) + ss << gameCount << " GAMES AVAILABLE"; + + mSystemInfo.setText(ss.str()); + }, false, 1); + + Animation* infoFadeIn = new LambdaAnimation( + [this] (float t) + { + mSystemInfo.setOpacity((unsigned char)(lerp(0.f, 1.f, t) * 255)); + }, 300); + + // wait 600ms to fade in + setAnimation(infoFadeIn, 700, nullptr, false, 2); } void SystemView::render(const Eigen::Affine3f& parentTrans) @@ -206,6 +247,8 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) comp->render(logoTrans); } } + + mSystemInfo.render(trans); } std::vector SystemView::getHelpPrompts() diff --git a/src/views/SystemView.h b/src/views/SystemView.h index 59c6f3230..bd42dd3e5 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -37,6 +37,8 @@ private: void populate(); + TextComponent mSystemInfo; + // unit is list index float mCamOffset; }; From da581b70f2df2dc1c39419e6c3a7bb535998c631 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Fri, 18 Apr 2014 17:28:28 -0500 Subject: [PATCH 2/2] Changed how game count is shown. --- src/views/SystemView.cpp | 20 ++++++++++++-------- src/views/SystemView.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 8070400e0..9045b263c 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -10,19 +10,21 @@ #define SELECTED_SCALE 1.5f #define LOGO_PADDING ((logoSize().x() * (SELECTED_SCALE - 1)/2) + (mSize.x() * 0.06f)) +#define BAND_HEIGHT (logoSize().y() * SELECTED_SCALE) SystemView::SystemView(Window* window) : IList(window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP), - mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x77777700, TextComponent::ALIGN_CENTER) + mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, TextComponent::ALIGN_CENTER) { mCamOffset = 0; setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); - mSystemInfo.setSize(mSize.x(), 0); + mSystemInfo.setSize(mSize.x(), mSystemInfo.getSize().y() * 2.f); + mSystemInfo.setPosition(0, (mSize.y() + BAND_HEIGHT) / 2); - float yOff = (mSize.y() - logoSize().y())/2; - mSystemInfo.setPosition(0, (yOff - (logoSize().y() * (SELECTED_SCALE - 1)) / 2) + (logoSize().y() * SELECTED_SCALE) - mSystemInfo.getSize().y()); - //(mSize.y() - mSystemInfo.getSize().y()) / 2); + //const float sysInfoHeight = mSystemInfo.getSize().y() * 1.3f; + //mSystemInfo.setSize(mSize.x(), sysInfoHeight); + //mSystemInfo.setPosition(0, (mSize.y() - BAND_HEIGHT) / 2 + BAND_HEIGHT - sysInfoHeight); populate(); } @@ -183,7 +185,7 @@ void SystemView::onCursorChanged(const CursorState& state) }, 300); // wait 600ms to fade in - setAnimation(infoFadeIn, 700, nullptr, false, 2); + setAnimation(infoFadeIn, 2000, nullptr, false, 2); } void SystemView::render(const Eigen::Affine3f& parentTrans) @@ -220,8 +222,7 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) // background behind the logos Renderer::setMatrix(trans); - Renderer::drawRect(0, (int)(yOff - (logoSize().y() * (SELECTED_SCALE - 1)) / 2), - (int)mSize.x(), (int)(logoSize().y() * SELECTED_SCALE), 0xDDDDDDD8); + Renderer::drawRect(0.f, (mSize.y() - BAND_HEIGHT) / 2, mSize.x(), BAND_HEIGHT, 0xFFFFFFD8); Eigen::Affine3f logoTrans = trans; for(int i = center - logoCount/2; i < center + logoCount/2 + 1; i++) @@ -248,6 +249,9 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) } } + Renderer::setMatrix(trans); + Renderer::drawRect(mSystemInfo.getPosition().x(), mSystemInfo.getPosition().y() - 1, mSize.x(), mSystemInfo.getSize().y(), 0xDDDDDD00 | (unsigned char)(mSystemInfo.getOpacity() / 255.f * 0xD8)); + //Renderer::drawRect(mSystemInfo.getPosition().x() + mSize.x() * 0.025f, mSystemInfo.getPosition().y() - 1, mSize.x() * 0.95f, 2.f, 0x777777FF); mSystemInfo.render(trans); } diff --git a/src/views/SystemView.h b/src/views/SystemView.h index bd42dd3e5..4272ad9bc 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -33,7 +33,7 @@ protected: void onCursorChanged(const CursorState& state) override; private: - inline Eigen::Vector2f logoSize() const { return Eigen::Vector2f(mSize.x() * 0.25f, mSize.y() * 0.175f); } + inline Eigen::Vector2f logoSize() const { return Eigen::Vector2f(mSize.x() * 0.25f, mSize.y() * 0.155f); } void populate();