Improved input config styling a little.

This commit is contained in:
Aloshi 2014-03-22 17:37:40 -05:00
parent 5f55288495
commit f084f29e61
2 changed files with 17 additions and 13 deletions

View file

@ -8,6 +8,7 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "../views/ViewController.h" #include "../views/ViewController.h"
#include "../Util.h"
#define HOLD_TIME 1000 #define HOLD_TIME 1000
@ -30,12 +31,12 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w
} }
mTitle = std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME TO EMULATIONSTATION" : "SELECT A DEVICE", mTitle = std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME TO EMULATIONSTATION" : "SELECT A DEVICE",
Font::get(FONT_SIZE_MEDIUM), 0x666666FF, TextComponent::ALIGN_CENTER); Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true); mGrid.setEntry(mTitle, Vector2i(0, 0), false, true);
std::string msg = (firstRun ? "First, we need to configure your input device!\n" : ""); std::string msg = (firstRun ? "FIRST, WE NEED TO CONFIGURE YOUR INPUT DEVICE!\n" : "");
msg += "Hold a button on your input device to configure it.\n" msg += "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT.\n"
"Press F4 to quit at any time."; "PRESS F4 TO QUIT AT ANY TIME.";
mMsg = std::make_shared<TextComponent>(mWindow, msg, Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); mMsg = std::make_shared<TextComponent>(mWindow, msg, Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mMsg, Vector2i(0, 1), false, true); mGrid.setEntry(mMsg, Vector2i(0, 1), false, true);
@ -43,13 +44,13 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w
int numDevices = mWindow->getInputManager()->getNumJoysticks(); int numDevices = mWindow->getInputManager()->getNumJoysticks();
if(numDevices > 0) if(numDevices > 0)
deviceInfo << numDevices << " joystick" << (numDevices > 1 ? "s" : "") << " detected."; deviceInfo << "(" << numDevices << " JOYSTICK" << (numDevices > 1 ? "S" : "") << " DETECTED)";
else else
deviceInfo << "No joysticks detected!"; deviceInfo << "(NO JOYSTICKS DETECTED)";
mDeviceInfo = std::make_shared<TextComponent>(mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x888888FF, TextComponent::ALIGN_CENTER); mDeviceInfo = std::make_shared<TextComponent>(mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mDeviceInfo, Vector2i(0, 2), false, true); mGrid.setEntry(mDeviceInfo, Vector2i(0, 2), false, true);
mDeviceHeld = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, TextComponent::ALIGN_CENTER); mDeviceHeld = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mDeviceHeld, Vector2i(0, 3), false, true); mGrid.setEntry(mDeviceHeld, Vector2i(0, 3), false, true);
setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.5f); setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.5f);
@ -76,7 +77,7 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
// started holding // started holding
mHoldingConfig = config; mHoldingConfig = config;
mHoldTime = HOLD_TIME; mHoldTime = HOLD_TIME;
mDeviceHeld->setText(config->getDeviceName()); mDeviceHeld->setText(strToUpper(config->getDeviceName()));
}else if(!input.value && mHoldingConfig == config) }else if(!input.value && mHoldingConfig == config)
{ {
// cancel // cancel
@ -93,6 +94,9 @@ void GuiDetectDevice::update(int deltaTime)
if(mHoldingConfig) if(mHoldingConfig)
{ {
mHoldTime -= deltaTime; mHoldTime -= deltaTime;
const float t = (float)mHoldTime / HOLD_TIME;
unsigned int c = (unsigned char)(t * 255);
mDeviceHeld->setColor((c << 24) | (c << 16) | (c << 8) | 0xFF);
if(mHoldTime <= 0) if(mHoldTime <= 0)
{ {
// picked one! // picked one!

View file

@ -9,7 +9,7 @@
static const int inputCount = 10; static const int inputCount = 10;
static const char* inputName[inputCount] = { "Up", "Down", "Left", "Right", "A", "B", "Start", "Select", "PageUp", "PageDown"}; static const char* inputName[inputCount] = { "Up", "Down", "Left", "Right", "A", "B", "Start", "Select", "PageUp", "PageDown"};
static const char* inputDispName[inputCount] = { "Up", "Down", "Left", "Right", "A", "B", "Start", "Select", "Page Up", "Page Down"}; static const char* inputDispName[inputCount] = { "UP", "DOWN", "LEFT", "RIGHT", "A", "B", "START", "SELECT", "PAGE UP", "PAGE DOWN"};
static const char* inputIcon[inputCount] = { ":/help/dpad_up.svg", ":/help/dpad_down.svg", ":/help/dpad_left.svg", ":/help/dpad_right.svg", static const char* inputIcon[inputCount] = { ":/help/dpad_up.svg", ":/help/dpad_down.svg", ":/help/dpad_left.svg", ":/help/dpad_right.svg",
":/help/button_a.svg", ":/help/button_b.svg", ":/help/button_start.svg", ":/help/button_select.svg", ":/help/button_a.svg", ":/help/button_b.svg", ":/help/button_start.svg", ":/help/button_select.svg",
":/help/button_l.svg", ":/help/button_r.svg" }; ":/help/button_l.svg", ":/help/button_r.svg" };
@ -23,7 +23,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)),
mTargetConfig(target) mTargetConfig(target)
{ {
LOG(LogInfo) << "Configuring device " << target->getDeviceId(); LOG(LogInfo) << "Configuring device " << target->getDeviceId() << " (" << target->getDeviceName() << ").";
if(reconfigureAll) if(reconfigureAll)
target->clear(); target->clear();
@ -37,10 +37,10 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
mTitle = std::make_shared<TextComponent>(mWindow, "PLEASE CONFIGURE INPUT FOR", Font::get(FONT_SIZE_SMALL), 0x555555FF, TextComponent::ALIGN_CENTER); mTitle = std::make_shared<TextComponent>(mWindow, "PLEASE CONFIGURE INPUT FOR", Font::get(FONT_SIZE_SMALL), 0x555555FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true); mGrid.setEntry(mTitle, Vector2i(0, 0), false, true);
mSubtitle1 = std::make_shared<TextComponent>(mWindow, target->getDeviceName(), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, TextComponent::ALIGN_CENTER); mSubtitle1 = std::make_shared<TextComponent>(mWindow, strToUpper(target->getDeviceName()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mSubtitle1, Vector2i(0, 1), false, true); mGrid.setEntry(mSubtitle1, Vector2i(0, 1), false, true);
mSubtitle2 = std::make_shared<TextComponent>(mWindow, "(HOLD ANY BUTTON TO SKIP BUT NOT YET)", Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER); mSubtitle2 = std::make_shared<TextComponent>(mWindow, /*"(HOLD ANY BUTTON TO SKIP)"*/ "", Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mSubtitle2, Vector2i(0, 2), false, true); mGrid.setEntry(mSubtitle2, Vector2i(0, 2), false, true);
mList = std::make_shared<ComponentList>(mWindow); mList = std::make_shared<ComponentList>(mWindow);