mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added <listSelectedColor> tag.
Began implementing GuiFastSelect. You can see what's currently in place by holding F2 and pressing up/down. Hopefully fixed nearest neighbor filters with GuiImage.
This commit is contained in:
parent
e08391080b
commit
31aebf3a7d
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
|||
CC=g++
|
||||
CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_RPI_
|
||||
LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp pugiXML/pugixml.cpp
|
||||
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
||||
OBJECTS=$(SOURCES:.cpp=.o)
|
||||
EXECUTABLE=emulationstation
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CC=g++
|
||||
CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ -g
|
||||
LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp pugiXML/pugixml.cpp
|
||||
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
||||
OBJECTS=$(SOURCES:.cpp=.o)
|
||||
EXECUTABLE=emulationstation
|
||||
|
|
|
@ -63,6 +63,8 @@ Display tags must be at the root of the <theme> tree - for example, they can't b
|
|||
|
||||
`<listSelectorColor>` - the hex color to use for the "selector bar" on the GuiGameList.
|
||||
|
||||
`<listSelectedColor>` - the hex color to use for selected text on the GuiGameList. Default is -1, which will not change the color.
|
||||
|
||||
`<listLeftAlign />` - if present, the games list names will be left aligned to the value of `<listOffsetX>` (default 0.5).
|
||||
|
||||
`<hideHeader />` - if present, the system name header won't be displayed (useful for replacing it with an image).
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
September 30
|
||||
-Began implementing GuiFastSelect, currently invoked by holding F2. Unfortunately, it doesn't do anything yet.
|
||||
-Added <listSelectedColor>.
|
||||
-Fixed OpenGL mipmap generation not setting a magnification filter. Hopefully this fixes the weird scaling. If not, I can switch from nearest neighbor to linear.
|
||||
|
||||
September 29
|
||||
-SDL is now completely shut down on both the RPi and SDL GL renderer. You may see the flicker of a terminal when you launch a game. This was done in preparation for audio.
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ void InputManager::processEvent(SDL_Event* event)
|
|||
case SDLK_F1:
|
||||
button = MENU;
|
||||
break;
|
||||
case SDLK_F2:
|
||||
button = SELECT;
|
||||
break;
|
||||
|
||||
default:
|
||||
button = UNKNOWN;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace InputManager {
|
|||
void loadConfig();
|
||||
|
||||
//enum for identifying input, regardless of configuration
|
||||
enum InputButton { UNKNOWN, UP, DOWN, LEFT, RIGHT, BUTTON1, BUTTON2, MENU };
|
||||
enum InputButton { UNKNOWN, UP, DOWN, LEFT, RIGHT, BUTTON1, BUTTON2, MENU, SELECT};
|
||||
|
||||
void processEvent(SDL_Event* event);
|
||||
|
||||
|
|
100
src/components/GuiFastSelect.cpp
Normal file
100
src/components/GuiFastSelect.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
#include "GuiFastSelect.h"
|
||||
#include "../Renderer.h"
|
||||
#include <iostream>
|
||||
|
||||
const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const int GuiFastSelect::SCROLLSPEED = 120;
|
||||
const int GuiFastSelect::SCROLLDELAY = 507;
|
||||
|
||||
GuiFastSelect::GuiFastSelect(GuiComponent* parent, SystemData* system, char startLetter)
|
||||
{
|
||||
mLetterID = LETTERS.find(toupper(startLetter));
|
||||
if(mLetterID == std::string::npos)
|
||||
mLetterID = 0;
|
||||
|
||||
Renderer::registerComponent(this);
|
||||
InputManager::registerComponent(this);
|
||||
|
||||
mParent = parent;
|
||||
mSystem = system;
|
||||
|
||||
mScrolling = false;
|
||||
mScrollTimer = 0;
|
||||
mScrollOffset = 0;
|
||||
|
||||
mParent->pause();
|
||||
}
|
||||
|
||||
GuiFastSelect::~GuiFastSelect()
|
||||
{
|
||||
Renderer::unregisterComponent(this);
|
||||
InputManager::unregisterComponent(this);
|
||||
|
||||
mParent->resume();
|
||||
}
|
||||
|
||||
void GuiFastSelect::onRender()
|
||||
{
|
||||
int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
||||
|
||||
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0);
|
||||
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), 0xFF0000, Renderer::LARGE);
|
||||
}
|
||||
|
||||
void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)
|
||||
{
|
||||
if(button == InputManager::UP && keyDown)
|
||||
{
|
||||
setLetterID(mLetterID - 1);
|
||||
mScrollOffset = -1;
|
||||
}
|
||||
|
||||
if(button == InputManager::DOWN && keyDown)
|
||||
{
|
||||
setLetterID(mLetterID + 1);
|
||||
mScrollOffset = 1;
|
||||
}
|
||||
|
||||
if((button == InputManager::UP || button == InputManager::DOWN) && !keyDown)
|
||||
{
|
||||
mScrolling = false;
|
||||
mScrollTimer = 0;
|
||||
mScrollOffset = 0;
|
||||
}
|
||||
|
||||
if(button == InputManager::SELECT && !keyDown)
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GuiFastSelect::onTick(int deltaTime)
|
||||
{
|
||||
if(mScrollOffset != 0)
|
||||
{
|
||||
mScrollTimer += deltaTime;
|
||||
|
||||
if(!mScrolling && mScrollTimer >= SCROLLDELAY)
|
||||
{
|
||||
mScrolling = true;
|
||||
mScrollTimer = SCROLLSPEED;
|
||||
}
|
||||
|
||||
if(mScrolling && mScrollTimer >= SCROLLSPEED)
|
||||
{
|
||||
mScrollTimer = 0;
|
||||
setLetterID(mLetterID + mScrollOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuiFastSelect::setLetterID(int id)
|
||||
{
|
||||
while(id < 0)
|
||||
id += LETTERS.length();
|
||||
while(id >= (int)LETTERS.length())
|
||||
id -= LETTERS.length();
|
||||
|
||||
mLetterID = (size_t)id;
|
||||
}
|
30
src/components/GuiFastSelect.h
Normal file
30
src/components/GuiFastSelect.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef _GUIFASTSELECT_H_
|
||||
#define _GUIFASTSELECT_H_
|
||||
|
||||
#include "../GuiComponent.h"
|
||||
#include "../SystemData.h"
|
||||
|
||||
class GuiFastSelect : GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiFastSelect(GuiComponent* parent, SystemData* system, char startLetter);
|
||||
~GuiFastSelect();
|
||||
|
||||
void onRender();
|
||||
void onInput(InputManager::InputButton button, bool keyDown);
|
||||
void onTick(int deltaTime);
|
||||
private:
|
||||
static const std::string LETTERS;
|
||||
static const int SCROLLSPEED;
|
||||
static const int SCROLLDELAY;
|
||||
|
||||
void setLetterID(int id);
|
||||
|
||||
SystemData* mSystem;
|
||||
size_t mLetterID;
|
||||
GuiComponent* mParent;
|
||||
int mScrollTimer, mScrollOffset;
|
||||
bool mScrolling;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -2,6 +2,7 @@
|
|||
#include "../InputManager.h"
|
||||
#include <iostream>
|
||||
#include "GuiMenu.h"
|
||||
#include "GuiFastSelect.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
||||
|
@ -13,7 +14,6 @@ GuiGameList::GuiGameList(bool useDetail)
|
|||
std::cout << "Creating GuiGameList\n";
|
||||
mDetailed = useDetail;
|
||||
|
||||
|
||||
mTheme = new GuiTheme(); //not a child because it's rendered manually by GuiGameList::onRender (to make sure it's rendered first)
|
||||
|
||||
//The GuiGameList can use the older, simple game list if so desired.
|
||||
|
@ -152,6 +152,12 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
|||
new GuiMenu(this);
|
||||
}
|
||||
|
||||
if(button == InputManager::SELECT && keyDown)
|
||||
{
|
||||
std::cout << "Creating GuiFastSelect\n";
|
||||
new GuiFastSelect(this, mSystem, mList->getSelectedObject()->getName()[0]);
|
||||
}
|
||||
|
||||
if(mDetailed)
|
||||
{
|
||||
if(button == InputManager::UP || button == InputManager::DOWN)
|
||||
|
@ -199,6 +205,7 @@ void GuiGameList::updateTheme()
|
|||
mTheme->readXML(""); //clears any current theme
|
||||
|
||||
mList->setSelectorColor(mTheme->getSelectorColor());
|
||||
mList->setSelectedTextColor(mTheme->getSelectedTextColor());
|
||||
mList->setCentered(mTheme->getListCentered());
|
||||
|
||||
if(mDetailed)
|
||||
|
|
|
@ -149,6 +149,7 @@ void GuiImage::loadImage(std::string path)
|
|||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageRGBA);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include <fstream>
|
||||
|
||||
std::string GuiInputConfig::sConfigPath = "./input.cfg";
|
||||
std::string GuiInputConfig::sInputs[] = { "UNKNOWN", "UP", "DOWN", "LEFT", "RIGHT", "BUTTON1 (Accept)", "BUTTON2 (Back)", "START (Menu)" }; //must be same order as InputManager::InputButton enum
|
||||
int GuiInputConfig::sInputCount = 8;
|
||||
std::string GuiInputConfig::sInputs[] = { "UNKNOWN", "UP", "DOWN", "LEFT", "RIGHT", "BUTTON1 (Accept)", "BUTTON2 (Back)", "START (Menu)", "SELECT (Jump-to-letter)" }; //must be same order as InputManager::InputButton enum
|
||||
int GuiInputConfig::sInputCount = 8; //set to 9 after fast select is in
|
||||
|
||||
GuiInputConfig::GuiInputConfig()
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@ GuiList<listType>::GuiList(int offsetX, int offsetY, Renderer::FontSize fontsize
|
|||
|
||||
mFont = fontsize;
|
||||
mSelectorColor = 0x000000;
|
||||
mSelectedTextColorOverride = -1;
|
||||
|
||||
mDrawCentered = true;
|
||||
|
||||
InputManager::registerComponent(this);
|
||||
|
@ -74,7 +76,7 @@ void GuiList<listType>::onRender()
|
|||
if(mDrawCentered)
|
||||
Renderer::drawCenteredText(row.name, getOffsetX(), y, row.color, mFont);
|
||||
else
|
||||
Renderer::drawText(row.name, getOffsetX() + mTextOffsetX, y, row.color, mFont);
|
||||
Renderer::drawText(row.name, getOffsetX() + mTextOffsetX, y, (mSelectedTextColorOverride != -1 && mSelection == i ? mSelectedTextColorOverride : row.color), mFont);
|
||||
|
||||
y += entrySize;
|
||||
}
|
||||
|
@ -212,6 +214,12 @@ void GuiList<listType>::setSelectorColor(int selectorColor)
|
|||
mSelectorColor = selectorColor;
|
||||
}
|
||||
|
||||
template <typename listType>
|
||||
void GuiList<listType>::setSelectedTextColor(int selectedColor)
|
||||
{
|
||||
mSelectedTextColorOverride = selectedColor;
|
||||
}
|
||||
|
||||
template<typename listType>
|
||||
void GuiList<listType>::setCentered(bool centered)
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define SCROLLDELAY 507
|
||||
#define SCROLLTIME 200
|
||||
|
||||
//A graphical list. Supports multiple colors for rows and scrolling.
|
||||
//TODO - add truncation to text rendering if name exceeds a maximum width (a trailing elipses, perhaps).
|
||||
template <typename listType>
|
||||
|
@ -35,16 +32,20 @@ public:
|
|||
bool isScrolling();
|
||||
|
||||
void setSelectorColor(int selectorColor);
|
||||
void setSelectedTextColor(int selectedColor);
|
||||
void setCentered(bool centered);
|
||||
|
||||
void setTextOffsetX(int textoffsetx);
|
||||
|
||||
private:
|
||||
static const int SCROLLDELAY = 507;
|
||||
static const int SCROLLTIME = 200;
|
||||
|
||||
int mScrollDir, mScrollAccumulator;
|
||||
bool mScrolling;
|
||||
|
||||
Renderer::FontSize mFont;
|
||||
int mSelectorColor;
|
||||
int mSelectorColor, mSelectedTextColorOverride;
|
||||
bool mDrawCentered;
|
||||
|
||||
int mTextOffsetX;
|
||||
|
|
|
@ -15,11 +15,12 @@ bool GuiTheme::getHeaderHidden() { return mHideHeader; }
|
|||
bool GuiTheme::getDividersHidden() { return mHideDividers; }
|
||||
bool GuiTheme::getListCentered() { return mListCentered; }
|
||||
|
||||
//not yet implemented
|
||||
float GuiTheme::getListOffsetX() { return mListOffsetX; }
|
||||
float GuiTheme::getGameImageOffsetY() { return mGameImageOffsetY; }
|
||||
float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; }
|
||||
|
||||
int GuiTheme::getSelectedTextColor() { return mListSelectedColor; }
|
||||
|
||||
GuiTheme::GuiTheme(std::string path)
|
||||
{
|
||||
setDefaults();
|
||||
|
@ -38,6 +39,7 @@ void GuiTheme::setDefaults()
|
|||
mListPrimaryColor = 0x0000FF;
|
||||
mListSecondaryColor = 0x00FF00;
|
||||
mListSelectorColor = 0x000000;
|
||||
mListSelectedColor = -1; //-1 = use original list color when selected
|
||||
mDescColor = 0x0000FF;
|
||||
mHideHeader = false;
|
||||
mHideDividers = false;
|
||||
|
@ -93,6 +95,7 @@ void GuiTheme::readXML(std::string path)
|
|||
mListPrimaryColor = resolveColor(root.child("listPrimaryColor").text().get(), mListPrimaryColor);
|
||||
mListSecondaryColor = resolveColor(root.child("listSecondaryColor").text().get(), mListSecondaryColor);
|
||||
mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor);
|
||||
mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListSelectedColor);
|
||||
mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor);
|
||||
mHideHeader = root.child("hideHeader");
|
||||
mHideDividers = root.child("hideDividers");
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
int getPrimaryColor();
|
||||
int getSecondaryColor();
|
||||
int getSelectorColor();
|
||||
int getSelectedTextColor();
|
||||
int getDescColor();
|
||||
bool getHeaderHidden();
|
||||
bool getDividersHidden();
|
||||
|
@ -39,7 +40,7 @@ private:
|
|||
|
||||
std::vector<GuiComponent*> mComponentVector;
|
||||
std::string mPath;
|
||||
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mDescColor;
|
||||
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor;
|
||||
bool mHideHeader, mHideDividers, mListCentered;
|
||||
|
||||
float mListOffsetX, mGameImageOffsetY, mListTextOffsetX;
|
||||
|
|
Loading…
Reference in a new issue