diff --git a/src/components/ComponentList.h b/src/components/ComponentList.h index 5a0730891..247f3884d 100644 --- a/src/components/ComponentList.h +++ b/src/components/ComponentList.h @@ -63,6 +63,7 @@ public: inline int getCursorId() const { return mCursor; } float getTotalRowHeight() const; + inline float getRowHeight(int row) const { return getRowHeight(mEntries.at(row).data); } protected: void onCursorChanged(const CursorState& state) override; @@ -72,9 +73,9 @@ private: void updateElementPosition(const ComponentListRow& row); void updateElementSize(const ComponentListRow& row); - - float getRowHeight(const ComponentListRow& row) const; + float getRowHeight(const ComponentListRow& row) const; + float mSelectorBarOffset; float mCameraOffset; }; diff --git a/src/guis/GuiDetectDevice.cpp b/src/guis/GuiDetectDevice.cpp index f2b96c5eb..0a3123334 100644 --- a/src/guis/GuiDetectDevice.cpp +++ b/src/guis/GuiDetectDevice.cpp @@ -15,7 +15,7 @@ using namespace Eigen; GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(window), - mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 4)) + mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)) { mHoldingConfig = NULL; mHoldTime = 0; @@ -30,28 +30,31 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w }; } - mTitle = std::make_shared(mWindow, firstRun ? "WELCOME TO EMULATIONSTATION" : "SELECT A DEVICE", + // title + mTitle = std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT", Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mTitle, Vector2i(0, 0), false, true); - - std::string msg = (firstRun ? "FIRST, WE NEED TO CONFIGURE YOUR INPUT DEVICE!\n" : ""); - msg += "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT.\n" - "PRESS F4 TO QUIT AT ANY TIME."; - mMsg = std::make_shared(mWindow, msg, Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mMsg, Vector2i(0, 1), false, true); + mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(1, 1), GridFlags::BORDER_BOTTOM); + // device info std::stringstream deviceInfo; int numDevices = mWindow->getInputManager()->getNumJoysticks(); if(numDevices > 0) - deviceInfo << "(" << numDevices << " JOYSTICK" << (numDevices > 1 ? "S" : "") << " DETECTED)"; + deviceInfo << numDevices << " GAMEPAD" << (numDevices > 1 ? "S" : "") << " DETECTED"; else - deviceInfo << "(NO JOYSTICKS DETECTED)"; + deviceInfo << "NO GAMEPADS DETECTED"; mDeviceInfo = std::make_shared(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, 1), false, true); + // message + mMsg1 = std::make_shared(mWindow, "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); + mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true); + mMsg2 = std::make_shared(mWindow, "PRESS F4 TO QUIT AT ANY TIME", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); + mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true); + + // currently held device mDeviceHeld = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mDeviceHeld, Vector2i(0, 3), false, true); + mGrid.setEntry(mDeviceHeld, Vector2i(0, 4), false, true); setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.5f); setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2); @@ -64,8 +67,10 @@ void GuiDetectDevice::onSizeChanged() // grid mGrid.setSize(mSize); mGrid.setRowHeightPerc(0, mTitle->getFont()->getHeight() / mSize.y()); - mGrid.setRowHeightPerc(2, mDeviceInfo->getFont()->getHeight() / mSize.y()); - mGrid.setRowHeightPerc(3, mDeviceHeld->getFont()->getHeight() / mSize.y()); + //mGrid.setRowHeightPerc(1, mDeviceInfo->getFont()->getHeight() / mSize.y()); + mGrid.setRowHeightPerc(2, mMsg1->getFont()->getHeight() / mSize.y()); + mGrid.setRowHeightPerc(3, mMsg2->getFont()->getHeight() / mSize.y()); + //mGrid.setRowHeightPerc(4, mDeviceHeld->getFont()->getHeight() / mSize.y()); } bool GuiDetectDevice::input(InputConfig* config, Input input) diff --git a/src/guis/GuiDetectDevice.h b/src/guis/GuiDetectDevice.h index 57ff8b4bd..71d133692 100644 --- a/src/guis/GuiDetectDevice.h +++ b/src/guis/GuiDetectDevice.h @@ -23,7 +23,8 @@ private: ComponentGrid mGrid; std::shared_ptr mTitle; - std::shared_ptr mMsg; + std::shared_ptr mMsg1; + std::shared_ptr mMsg2; std::shared_ptr mDeviceInfo; std::shared_ptr mDeviceHeld; diff --git a/src/guis/GuiInputConfig.cpp b/src/guis/GuiInputConfig.cpp index d7c106913..b66ca8d77 100644 --- a/src/guis/GuiInputConfig.cpp +++ b/src/guis/GuiInputConfig.cpp @@ -20,7 +20,7 @@ static const char* inputIcon[inputCount] = { ":/help/dpad_up.svg", ":/help/dpad_ using namespace Eigen; GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function& okCallback) : GuiComponent(window), - mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)), + mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 7)), mTargetConfig(target) { LOG(LogInfo) << "Configuring device " << target->getDeviceId() << " (" << target->getDeviceName() << ")."; @@ -34,17 +34,28 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, "PLEASE CONFIGURE INPUT FOR", Font::get(FONT_SIZE_SMALL), 0x555555FF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mTitle, Vector2i(0, 0), false, true); - - mSubtitle1 = std::make_shared(mWindow, strToUpper(target->getDeviceName()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mSubtitle1, Vector2i(0, 1), false, true); + // 0 is a spacer row + mGrid.setEntry(std::make_shared(mWindow), Vector2i(0, 0), false); - mSubtitle2 = std::make_shared(mWindow, /*"(HOLD ANY BUTTON TO SKIP)"*/ "", Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER); - mGrid.setEntry(mSubtitle2, Vector2i(0, 2), false, true); + mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); + mGrid.setEntry(mTitle, Vector2i(0, 1), false, true); + + std::stringstream ss; + if(target->getDeviceId() == DEVICE_KEYBOARD) + ss << "KEYBOARD"; + else + ss << "GAMEPAD " << (target->getDeviceId() + 1); + mSubtitle1 = std::make_shared(mWindow, strToUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, TextComponent::ALIGN_CENTER); + mGrid.setEntry(mSubtitle1, Vector2i(0, 2), false, true); + + mSubtitle2 = std::make_shared(mWindow, "HOLD ANY BUTTON TO SKIP", Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER); + mGrid.setEntry(mSubtitle2, Vector2i(0, 3), false, true); + + // 4 is a spacer row + mGrid.setEntry(std::make_shared(mWindow), Vector2i(4, 0), false); mList = std::make_shared(mWindow); - mGrid.setEntry(mList, Vector2i(0, 3), true, true); + mGrid.setEntry(mList, Vector2i(0, 5), true, true); for(int i = 0; i < inputCount; i++) { ComponentListRow row; @@ -52,7 +63,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi // icon auto icon = std::make_shared(mWindow); icon->setImage(inputIcon[i]); - icon->setResize(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * ((i < 4) ? 1.2f : 1.0f)); // hack to enlarge dpad + icon->setResize(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * ((i < 4) ? 1.25f : 1.0f)); // hack to enlarge dpad row.addElement(icon, false); // spacer between icon and text @@ -122,9 +133,9 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi delete this; })); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false); + mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false); - setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.7f); + setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.75f); setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2); } @@ -135,10 +146,13 @@ void GuiInputConfig::onSizeChanged() // update grid mGrid.setSize(mSize); - mGrid.setRowHeightPerc(0, mTitle->getFont()->getHeight() / mSize.y()); - mGrid.setRowHeightPerc(1, mSubtitle1->getFont()->getHeight() / mSize.y()); - mGrid.setRowHeightPerc(2, mSubtitle2->getFont()->getHeight() / mSize.y()); - mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y() / mSize.y()); + //mGrid.setRowHeightPerc(0, 0.025f); + mGrid.setRowHeightPerc(1, mTitle->getFont()->getHeight()*0.75f / mSize.y()); + mGrid.setRowHeightPerc(2, mSubtitle1->getFont()->getHeight() / mSize.y()); + mGrid.setRowHeightPerc(3, mSubtitle2->getFont()->getHeight() / mSize.y()); + //mGrid.setRowHeightPerc(4, 0.03f); + mGrid.setRowHeightPerc(5, (mList->getRowHeight(0) * 5 + 2) / mSize.y()); + mGrid.setRowHeightPerc(6, mButtonGrid->getSize().y() / mSize.y()); } void GuiInputConfig::setPress(const std::shared_ptr& text) diff --git a/src/resources/SVGResource.cpp b/src/resources/SVGResource.cpp index 1f50466f5..65cee8a97 100644 --- a/src/resources/SVGResource.cpp +++ b/src/resources/SVGResource.cpp @@ -50,15 +50,15 @@ void SVGResource::initFromMemory(const char* file, size_t length) void SVGResource::rasterizeAt(size_t width, size_t height) { + if(!mSVGImage) + return; + if(width != (int)round(mSVGImage->width) && height != (int)round(mSVGImage->height)) { mLastWidth = width; mLastHeight = height; } - if(!mSVGImage) - return; - unsigned char* imagePx = (unsigned char*)malloc(width * height * 4); NSVGrasterizer* rast = nsvgCreateRasterizer();