diff --git a/THEMES.md b/THEMES.md index 12af1e548..c908228c0 100644 --- a/THEMES.md +++ b/THEMES.md @@ -63,11 +63,13 @@ If EmulationStation is running in "basic" mode, it will try to use ` 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 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 `` 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:** -`` - the hex color to use for the letter display on the Fast Select box. +`` - the hex color to use for the letter display on the fast select box. -`` - path to a background image file. ~ and . are expanded. +`` - 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. -`` - if present, the background will be tiled instead of stretched. - -`` - path to the "left" border image file. It will be flipped for the right border. ~ and . are expanded. - -`` - if present, the horizontal image will be tiled instead of stretched downwards. - -`` - path to the "top" border image file. It will be flipped for the bottom border. ~ and . are expanded. - -`` - if present, the vertical image will be tiled instead of stretched to the right. - -`` - 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 `` font tag (see the Fonts section for more info). +`` - 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. `` - 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 `` t `` - 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 ================= diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 063742222..6ab7e4e58 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -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) diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index ed6d7e9bd..5adaec2b9 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -3,12 +3,14 @@ #include #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* 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 letterFont = mTheme->getFastSelectFont(); diff --git a/src/components/GuiFastSelect.h b/src/components/GuiFastSelect.h index a7bbd609f..b2ee4befc 100644 --- a/src/components/GuiFastSelect.h +++ b/src/components/GuiFastSelect.h @@ -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* list, char startLetter, ThemeComponent * theme); + GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent* 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* 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 mScrollSound; - ThemeComponent * mTheme; }; #endif diff --git a/src/components/NinePatchComponent.cpp b/src/components/NinePatchComponent.cpp index 0557ab72b..d5c9f57cf 100644 --- a/src/components/NinePatchComponent.cpp +++ b/src/components/NinePatchComponent.cpp @@ -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); diff --git a/src/components/ThemeComponent.cpp b/src/components/ThemeComponent.cpp index 3130a2549..7d5638d99 100644 --- a/src/components/ThemeComponent.cpp +++ b/src/components/ThemeComponent.cpp @@ -33,8 +33,6 @@ std::string ThemeComponent::getString(std::string name) return mStringMap[name]; } -GuiBoxData ThemeComponent::getBoxData() { return mBoxData; } - std::shared_ptr 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())); diff --git a/src/components/ThemeComponent.h b/src/components/ThemeComponent.h index e5e9c8ab6..a5da1d25a 100644 --- a/src/components/ThemeComponent.h +++ b/src/components/ThemeComponent.h @@ -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> mSoundMap; std::map mStringMap; - GuiBoxData mBoxData; - std::shared_ptr mListFont; std::shared_ptr mDescFont; std::shared_ptr mFastSelectFont;