mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 12:05:39 +00:00
GuiFastSelect is working.
Should be able to map a joystick input to Fast Select too, but untested.
This commit is contained in:
parent
31aebf3a7d
commit
a3c128f4ce
|
@ -1,3 +1,6 @@
|
||||||
|
October 5
|
||||||
|
-GuiFastSelect is working, but ugly.
|
||||||
|
|
||||||
September 30
|
September 30
|
||||||
-Began implementing GuiFastSelect, currently invoked by holding F2. Unfortunately, it doesn't do anything yet.
|
-Began implementing GuiFastSelect, currently invoked by holding F2. Unfortunately, it doesn't do anything yet.
|
||||||
-Added <listSelectedColor>.
|
-Added <listSelectedColor>.
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
const int GuiFastSelect::SCROLLSPEED = 120;
|
const int GuiFastSelect::SCROLLSPEED = 100;
|
||||||
const int GuiFastSelect::SCROLLDELAY = 507;
|
const int GuiFastSelect::SCROLLDELAY = 507;
|
||||||
|
|
||||||
GuiFastSelect::GuiFastSelect(GuiComponent* parent, SystemData* system, char startLetter)
|
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter)
|
||||||
{
|
{
|
||||||
mLetterID = LETTERS.find(toupper(startLetter));
|
mLetterID = LETTERS.find(toupper(startLetter));
|
||||||
if(mLetterID == std::string::npos)
|
if(mLetterID == std::string::npos)
|
||||||
|
@ -16,7 +16,7 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, SystemData* system, char star
|
||||||
InputManager::registerComponent(this);
|
InputManager::registerComponent(this);
|
||||||
|
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
mSystem = system;
|
mList = list;
|
||||||
|
|
||||||
mScrolling = false;
|
mScrolling = false;
|
||||||
mScrollTimer = 0;
|
mScrollTimer = 0;
|
||||||
|
@ -64,6 +64,7 @@ void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
|
|
||||||
if(button == InputManager::SELECT && !keyDown)
|
if(button == InputManager::SELECT && !keyDown)
|
||||||
{
|
{
|
||||||
|
setListPos();
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,3 +99,33 @@ void GuiFastSelect::setLetterID(int id)
|
||||||
|
|
||||||
mLetterID = (size_t)id;
|
mLetterID = (size_t)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiFastSelect::setListPos()
|
||||||
|
{
|
||||||
|
char letter = LETTERS[mLetterID];
|
||||||
|
|
||||||
|
int min = 0;
|
||||||
|
int max = mList->getObjectCount() - 1;
|
||||||
|
|
||||||
|
int mid;
|
||||||
|
|
||||||
|
while(max >= min)
|
||||||
|
{
|
||||||
|
mid = ((max - min) / 2) + min;
|
||||||
|
|
||||||
|
char checkLetter = toupper(mList->getObject(mid)->getName()[0]);
|
||||||
|
|
||||||
|
if(checkLetter < letter)
|
||||||
|
{
|
||||||
|
min = mid + 1;
|
||||||
|
}else if(checkLetter > letter)
|
||||||
|
{
|
||||||
|
max = mid - 1;
|
||||||
|
}else{
|
||||||
|
//exact match found
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mList->setSelection(mid);
|
||||||
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
#include "../GuiComponent.h"
|
#include "../GuiComponent.h"
|
||||||
#include "../SystemData.h"
|
#include "../SystemData.h"
|
||||||
|
#include "../FolderData.h"
|
||||||
|
#include "GuiList.h"
|
||||||
|
|
||||||
class GuiFastSelect : GuiComponent
|
class GuiFastSelect : GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiFastSelect(GuiComponent* parent, SystemData* system, char startLetter);
|
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter);
|
||||||
~GuiFastSelect();
|
~GuiFastSelect();
|
||||||
|
|
||||||
void onRender();
|
void onRender();
|
||||||
|
@ -18,11 +20,15 @@ private:
|
||||||
static const int SCROLLSPEED;
|
static const int SCROLLSPEED;
|
||||||
static const int SCROLLDELAY;
|
static const int SCROLLDELAY;
|
||||||
|
|
||||||
|
void setListPos();
|
||||||
|
|
||||||
void setLetterID(int id);
|
void setLetterID(int id);
|
||||||
|
|
||||||
SystemData* mSystem;
|
GuiList<FileData*>* mList;
|
||||||
|
|
||||||
size_t mLetterID;
|
size_t mLetterID;
|
||||||
GuiComponent* mParent;
|
GuiComponent* mParent;
|
||||||
|
|
||||||
int mScrollTimer, mScrollOffset;
|
int mScrollTimer, mScrollOffset;
|
||||||
bool mScrolling;
|
bool mScrolling;
|
||||||
};
|
};
|
||||||
|
|
|
@ -154,8 +154,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
|
|
||||||
if(button == InputManager::SELECT && keyDown)
|
if(button == InputManager::SELECT && keyDown)
|
||||||
{
|
{
|
||||||
std::cout << "Creating GuiFastSelect\n";
|
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0]);
|
||||||
new GuiFastSelect(this, mSystem, mList->getSelectedObject()->getName()[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
std::string GuiInputConfig::sConfigPath = "./input.cfg";
|
std::string GuiInputConfig::sConfigPath = "./input.cfg";
|
||||||
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
|
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
|
int GuiInputConfig::sInputCount = 9;
|
||||||
|
|
||||||
GuiInputConfig::GuiInputConfig()
|
GuiInputConfig::GuiInputConfig()
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,3 +231,21 @@ void GuiList<listType>::setTextOffsetX(int textoffsetx)
|
||||||
{
|
{
|
||||||
mTextOffsetX = textoffsetx;
|
mTextOffsetX = textoffsetx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename listType>
|
||||||
|
int GuiList<listType>::getObjectCount()
|
||||||
|
{
|
||||||
|
return mRowVector.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename listType>
|
||||||
|
listType GuiList<listType>::getObject(int i)
|
||||||
|
{
|
||||||
|
return mRowVector.at(i).object;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename listType>
|
||||||
|
void GuiList<listType>::setSelection(int i)
|
||||||
|
{
|
||||||
|
mSelection = i;
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,10 @@ public:
|
||||||
|
|
||||||
void setTextOffsetX(int textoffsetx);
|
void setTextOffsetX(int textoffsetx);
|
||||||
|
|
||||||
|
int getObjectCount();
|
||||||
|
listType getObject(int i);
|
||||||
|
void setSelection(int i);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int SCROLLDELAY = 507;
|
static const int SCROLLDELAY = 507;
|
||||||
static const int SCROLLTIME = 200;
|
static const int SCROLLTIME = 200;
|
||||||
|
|
|
@ -77,7 +77,7 @@ void GuiTheme::readXML(std::string path)
|
||||||
if(path.empty())
|
if(path.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::cout << "Loading theme \"" << path << "\"...\n";
|
//std::cout << "Loading theme \"" << path << "\"...\n";
|
||||||
|
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
pugi::xml_parse_result result = doc.load_file(path.c_str());
|
pugi::xml_parse_result result = doc.load_file(path.c_str());
|
||||||
|
@ -108,7 +108,7 @@ void GuiTheme::readXML(std::string path)
|
||||||
//recursively create children for all <components> with proper parenting
|
//recursively create children for all <components> with proper parenting
|
||||||
createComponentChildren(root, this);
|
createComponentChildren(root, this);
|
||||||
|
|
||||||
std::cout << "Finished parsing theme.\n";
|
//std::cout << "Finished parsing theme.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiTheme::createComponentChildren(pugi::xml_node node, GuiComponent* parent)
|
void GuiTheme::createComponentChildren(pugi::xml_node node, GuiComponent* parent)
|
||||||
|
@ -152,7 +152,7 @@ GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
|
||||||
std::string originX, originY;
|
std::string originX, originY;
|
||||||
splitString(origin, ' ', &originX, &originY);
|
splitString(origin, ' ', &originX, &originY);
|
||||||
|
|
||||||
std::cout << "image, x: " << posX << " y: " << posY << " w: " << dimW << " h: " << dimH << " ox: " << originX << " oy: " << originY << " tiled: " << tiled << "\n";
|
//std::cout << "image, x: " << posX << " y: " << posY << " w: " << dimW << " h: " << dimH << " ox: " << originX << " oy: " << originY << " tiled: " << tiled << "\n";
|
||||||
|
|
||||||
//resolve to pixels from percentages/variables
|
//resolve to pixels from percentages/variables
|
||||||
int x = resolveExp(posX) * Renderer::getScreenWidth();
|
int x = resolveExp(posX) * Renderer::getScreenWidth();
|
||||||
|
|
Loading…
Reference in a new issue