mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Moved the fast select GUI to nine patches.
Luckily, no one ever used it anyway.
This commit is contained in:
parent
b0d156d6bd
commit
d7a6cae4ce
30
THEMES.md
30
THEMES.md
|
@ -63,11 +63,13 @@ If EmulationStation is running in "basic" mode, it will try to use `<themeBasic>
|
|||
|
||||
Components
|
||||
==========
|
||||
|
||||
A theme is made up of components, which have various types. At the moment, the only type is `image`. Components are rendered in the order they are defined - that means you'll want to define the background first, a header image second, etc.
|
||||
|
||||
|
||||
The "image" component
|
||||
=====================
|
||||
|
||||
Used to display an image.
|
||||
|
||||
`<path>` - path to the image file. Most common file types are supported, and . and ~ are properly expanded.
|
||||
|
@ -83,6 +85,7 @@ Used to display an image.
|
|||
|
||||
Display tags
|
||||
============
|
||||
|
||||
Display tags define some "meta" display attributes about your theme. Display tags must be at the root of the `<theme>` tree - for example, they can't be inside a component tag. They are not required.
|
||||
|
||||
|
||||
|
@ -124,23 +127,11 @@ Display tags define some "meta" display attributes about your theme. Display tag
|
|||
|
||||
**Fast Select box attributes:**
|
||||
|
||||
`<fastSelectColor>` - the hex color to use for the letter display on the Fast Select box.
|
||||
`<fastSelectColor>` - the hex color to use for the letter display on the fast select box.
|
||||
|
||||
`<boxBackground>` - path to a background image file. ~ and . are expanded.
|
||||
`<fastSelectFrame>` - the path to a "nine patch" image to use for the "background" of the fast select box. See the "Nine Patches" section for more info.
|
||||
|
||||
`<boxBackgroundTiled />` - if present, the background will be tiled instead of stretched.
|
||||
|
||||
`<boxHorizontal>` - path to the "left" border image file. It will be flipped for the right border. ~ and . are expanded.
|
||||
|
||||
`<boxHorizontalTiled />` - if present, the horizontal image will be tiled instead of stretched downwards.
|
||||
|
||||
`<boxVertical>` - path to the "top" border image file. It will be flipped for the bottom border. ~ and . are expanded.
|
||||
|
||||
`<boxVerticalTiled />` - if present, the vertical image will be tiled instead of stretched to the right.
|
||||
|
||||
`<boxCorner>` - path to the "top left corner" image file. It will be flipped for the top right, bottom right, and bottom left corners. ~ and . are expanded.
|
||||
|
||||
There is also a `<fastSelectFont>` font tag (see the Fonts section for more info).
|
||||
`<fastSelectFont>` - font definition to use for the fast select letter. See the "Fonts" section for more info.
|
||||
|
||||
|
||||
Fonts
|
||||
|
@ -157,7 +148,7 @@ Fonts are defined like so:
|
|||
|
||||
You can leave off any tags you don't want to use, and they'll use the default. Size is defined as a percentage of the screen height. "." and "~" are expanded for paths.
|
||||
|
||||
NOTE: If your font size is too big, it'll overrun the maximum texture size.
|
||||
NOTE: If your font size is too big, it'll overrun the maximum OpenGL texture size. ES will attempt to rasterize it in progressively smaller sizes until one fits, then upscale it.
|
||||
|
||||
**Font tags:**
|
||||
|
||||
|
@ -167,6 +158,7 @@ NOTE: If your font size is too big, it'll overrun the maximum texture size.
|
|||
|
||||
`<fastSelectFont>` - font to use for the fast select letter.
|
||||
|
||||
|
||||
Audio
|
||||
=====
|
||||
|
||||
|
@ -181,6 +173,12 @@ Themes can also define menu sounds. These tags go in the root of the `<theme>` t
|
|||
`<menuOpenSound>` - path to the sound to play when the user opens a menu (either the "main menu" or the fast select menu).
|
||||
|
||||
|
||||
Nine Patches
|
||||
============
|
||||
|
||||
EmulationStation borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png).
|
||||
|
||||
|
||||
List of variables
|
||||
=================
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ bool InputManager::parseEvent(const SDL_Event& ev)
|
|||
return true;
|
||||
}
|
||||
|
||||
if(ev.key.repeat && !SDL_IsTextInputActive())
|
||||
if(ev.key.repeat)
|
||||
return false;
|
||||
|
||||
if(ev.key.keysym.sym == SDLK_F4)
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
#include <iostream>
|
||||
#include "GuiGameList.h"
|
||||
|
||||
#define DEFAULT_FS_IMAGE ":/frame.png"
|
||||
|
||||
const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const int GuiFastSelect::SCROLLSPEED = 100;
|
||||
const int GuiFastSelect::SCROLLDELAY = 507;
|
||||
|
||||
GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, ThemeComponent * theme)
|
||||
: GuiComponent(window), mParent(parent), mList(list), mTheme(theme)
|
||||
: GuiComponent(window), mParent(parent), mList(list), mTheme(theme), mBox(mWindow, "")
|
||||
{
|
||||
mLetterID = LETTERS.find(toupper(startLetter));
|
||||
if(mLetterID == std::string::npos)
|
||||
|
@ -22,27 +24,34 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, TextListCompon
|
|||
mScrollOffset = 0;
|
||||
|
||||
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
||||
mBox = new GuiBox(window, sw * 0.2f, sh * 0.2f, sw * 0.6f, sh * 0.6f);
|
||||
mBox->setData(mTheme->getBoxData());
|
||||
|
||||
|
||||
if(theme->getString("fastSelectFrame").empty())
|
||||
{
|
||||
mBox.setImagePath(DEFAULT_FS_IMAGE);
|
||||
//mBox.setEdgeColor(0x0096ffFF);
|
||||
mBox.setEdgeColor(0x005493FF);
|
||||
mBox.setCenterColor(0x5e5e5eFF);
|
||||
}else{
|
||||
mBox.setImagePath(theme->getString("fastSelectFrame"));
|
||||
}
|
||||
|
||||
mBox.setPosition(sw * 0.2f, sh * 0.2f);
|
||||
mBox.setSize(sw * 0.6f, sh * 0.6f);
|
||||
}
|
||||
|
||||
GuiFastSelect::~GuiFastSelect()
|
||||
{
|
||||
mParent->updateDetailData();
|
||||
delete mBox;
|
||||
}
|
||||
|
||||
void GuiFastSelect::render(const Eigen::Affine3f& parentTrans)
|
||||
{
|
||||
Eigen::Affine3f trans = parentTrans * getTransform();
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
||||
|
||||
if(!mBox->hasBackground())
|
||||
Renderer::drawRect((int)(sw * 0.3f), (int)(sh * 0.3f), (int)(sw * 0.4f), (int)(sh * 0.4f), 0x000FF0AA);
|
||||
|
||||
mBox->render(trans);
|
||||
mBox.render(trans);
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
std::shared_ptr<Font> letterFont = mTheme->getFastSelectFont();
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#include "../Sound.h"
|
||||
#include "ThemeComponent.h"
|
||||
#include "TextListComponent.h"
|
||||
#include "GuiBox.h"
|
||||
#include "NinePatchComponent.h"
|
||||
|
||||
class GuiGameList;
|
||||
|
||||
class GuiFastSelect : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, ThemeComponent * theme);
|
||||
GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, ThemeComponent* theme);
|
||||
~GuiFastSelect();
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
@ -30,19 +30,19 @@ private:
|
|||
void scroll();
|
||||
void setLetterID(int id);
|
||||
|
||||
GuiGameList* mParent;
|
||||
TextListComponent<FileData*>* mList;
|
||||
ThemeComponent * mTheme;
|
||||
NinePatchComponent mBox;
|
||||
|
||||
size_t mLetterID;
|
||||
GuiGameList* mParent;
|
||||
|
||||
GuiBox* mBox;
|
||||
int mTextColor;
|
||||
|
||||
unsigned int mTextColor;
|
||||
|
||||
int mScrollTimer, mScrollOffset;
|
||||
bool mScrolling;
|
||||
|
||||
std::shared_ptr<Sound> mScrollSound;
|
||||
ThemeComponent * mTheme;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -124,7 +124,7 @@ void NinePatchComponent::buildVertices()
|
|||
void NinePatchComponent::render(const Eigen::Affine3f& parentTrans)
|
||||
{
|
||||
Eigen::Affine3f trans = parentTrans * getTransform();
|
||||
if(mTexture)
|
||||
if(mTexture && mVertices != NULL)
|
||||
{
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ std::string ThemeComponent::getString(std::string name)
|
|||
return mStringMap[name];
|
||||
}
|
||||
|
||||
GuiBoxData ThemeComponent::getBoxData() { return mBoxData; }
|
||||
|
||||
std::shared_ptr<Font> ThemeComponent::getListFont()
|
||||
{
|
||||
if(mListFont)
|
||||
|
@ -108,14 +106,7 @@ void ThemeComponent::setDefaults()
|
|||
mSoundMap["menuOpen"]->loadFile("");
|
||||
|
||||
mStringMap["imageNotFoundPath"] = "";
|
||||
|
||||
mBoxData.backgroundPath = "";
|
||||
mBoxData.backgroundTiled = false;
|
||||
mBoxData.horizontalPath = "";
|
||||
mBoxData.horizontalTiled = false;
|
||||
mBoxData.verticalPath = "";
|
||||
mBoxData.verticalTiled = false;
|
||||
mBoxData.cornerPath = "";
|
||||
mStringMap["fastSelectFrame"] = "";
|
||||
|
||||
mListFont.reset();
|
||||
mDescFont.reset();
|
||||
|
@ -189,15 +180,6 @@ void ThemeComponent::readXML(std::string path, bool detailed)
|
|||
mBoolMap["hideHeader"] = root.child("hideHeader") != 0;
|
||||
mBoolMap["hideDividers"] = root.child("hideDividers") != 0;
|
||||
|
||||
//GuiBox theming data
|
||||
mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get());
|
||||
mBoxData.backgroundTiled = root.child("boxBackgroundTiled") != 0;
|
||||
mBoxData.horizontalPath = expandPath(root.child("boxHorizontal").text().get());
|
||||
mBoxData.horizontalTiled = root.child("boxHorizontalTiled") != 0;
|
||||
mBoxData.verticalPath = expandPath(root.child("boxVertical").text().get());
|
||||
mBoxData.verticalTiled = root.child("boxVerticalTiled") != 0;
|
||||
mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get());
|
||||
|
||||
//list stuff
|
||||
mBoolMap["listCentered"] = !root.child("listLeftAlign");
|
||||
mFloatMap["listOffsetX"] = strToFloat(root.child("listOffsetX").text().get(), mFloatMap["listOffsetX"]);
|
||||
|
@ -221,6 +203,7 @@ void ThemeComponent::readXML(std::string path, bool detailed)
|
|||
mFloatMap["gameImageOriginY"] = resolveExp(artOriginY, mFloatMap["gameImageOriginY"]);
|
||||
|
||||
mStringMap["imageNotFoundPath"] = expandPath(root.child("gameImageNotFound").text().get());
|
||||
mStringMap["fastSelectFrame"] = expandPath(root.child("fastSelectFrame").text().get());
|
||||
|
||||
//sounds
|
||||
mSoundMap["menuScroll"]->loadFile(expandPath(root.child("menuScrollSound").text().get()));
|
||||
|
|
|
@ -18,8 +18,6 @@ public:
|
|||
|
||||
void readXML(std::string path, bool detailed);
|
||||
|
||||
GuiBoxData getBoxData();
|
||||
|
||||
unsigned int getColor(std::string name);
|
||||
bool getBool(std::string name);
|
||||
float getFloat(std::string name);
|
||||
|
@ -52,8 +50,6 @@ private:
|
|||
std::map<std::string, std::shared_ptr<Sound>> mSoundMap;
|
||||
std::map<std::string, std::string> mStringMap;
|
||||
|
||||
GuiBoxData mBoxData;
|
||||
|
||||
std::shared_ptr<Font> mListFont;
|
||||
std::shared_ptr<Font> mDescFont;
|
||||
std::shared_ptr<Font> mFastSelectFont;
|
||||
|
|
Loading…
Reference in a new issue