Merge 94e32f198b from unstable branch top master

Had to hand-merge GuiGameList.cpp again :/
This commit is contained in:
Bim 2013-07-02 22:49:53 +02:00
commit ded54a6884
5 changed files with 45 additions and 26 deletions

View file

@ -18,8 +18,9 @@ public:
{ {
ComparisonFunction & comparisonFunction; ComparisonFunction & comparisonFunction;
bool ascending; bool ascending;
std::string description;
SortState(ComparisonFunction & sortFunction, bool sortAscending) : comparisonFunction(sortFunction), ascending(sortAscending) {} SortState(ComparisonFunction & sortFunction, bool sortAscending, const std::string & sortDescription) : comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {}
}; };
private: private:

View file

@ -7,17 +7,15 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int GuiFastSelect::SCROLLSPEED = 100; const int GuiFastSelect::SCROLLSPEED = 100;
const int GuiFastSelect::SCROLLDELAY = 507; const int GuiFastSelect::SCROLLDELAY = 507;
GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, GuiBoxData data, GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, ThemeComponent * theme)
int textcolor, std::shared_ptr<Sound> & scrollsound, Font* font) : GuiComponent(window) : GuiComponent(window), mParent(parent), mList(list), mTheme(theme)
{ {
mLetterID = LETTERS.find(toupper(startLetter)); mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos) if(mLetterID == std::string::npos)
mLetterID = 0; mLetterID = 0;
mParent = parent; mScrollSound = mTheme->getSound("menuScroll");
mList = list; mTextColor = mTheme->getColor("fastSelect");
mScrollSound = scrollsound;
mFont = font;
mScrolling = false; mScrolling = false;
mScrollTimer = 0; mScrollTimer = 0;
@ -25,9 +23,7 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, TextListCompon
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
mBox = new GuiBox(window, (int)(sw * 0.2f), (int)(sh * 0.2f), (int)(sw * 0.6f), (int)(sh * 0.6f)); mBox = new GuiBox(window, (int)(sw * 0.2f), (int)(sh * 0.2f), (int)(sw * 0.6f), (int)(sh * 0.6f));
mBox->setData(data); mBox->setData(mTheme->getBoxData());
mTextColor = textcolor;
} }
GuiFastSelect::~GuiFastSelect() GuiFastSelect::~GuiFastSelect()
@ -41,11 +37,14 @@ void GuiFastSelect::render()
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
if(!mBox->hasBackground()) if(!mBox->hasBackground())
Renderer::drawRect((int)(sw * 0.2f), (int)(sh * 0.2f), (int)(sw * 0.6f), (int)(sh * 0.6f), 0x000FF0FF); Renderer::drawRect((int)(sw * 0.3f), (int)(sh * 0.3f), (int)(sw * 0.4f), (int)(sh * 0.4f), 0x000FF0AA);
mBox->render(); mBox->render();
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, (int)(sh * 0.5f - (mFont->getHeight() * 0.5f)), mTextColor, mFont); Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, (int)(sh * 0.5f - (mTheme->getFastSelectFont()->getHeight() * 0.5f)), mTextColor, mTheme->getFastSelectFont());
Renderer::drawCenteredText("Sort order:", 0, (int)(sh * 0.6f - (mTheme->getDescriptionFont()->getHeight() * 0.5f)), mTextColor, mTheme->getDescriptionFont());
std::string sortString = "<- " + mParent->getSortState().description + " ->";
Renderer::drawCenteredText(sortString, 0, (int)(sh * 0.6f + (mTheme->getDescriptionFont()->getHeight() * 0.5f)), mTextColor, mTheme->getDescriptionFont());
} }
bool GuiFastSelect::input(InputConfig* config, Input input) bool GuiFastSelect::input(InputConfig* config, Input input)
@ -64,6 +63,19 @@ bool GuiFastSelect::input(InputConfig* config, Input input)
return true; return true;
} }
if(config->isMappedTo("left", input) && input.value != 0)
{
mParent->setPreviousSortIndex();
mScrollSound->play();
return true;
}
else if(config->isMappedTo("right", input) && input.value != 0)
{
mParent->setNextSortIndex();
mScrollSound->play();
return true;
}
if((config->isMappedTo("up", input) || config->isMappedTo("down", input)) && input.value == 0) if((config->isMappedTo("up", input) || config->isMappedTo("down", input)) && input.value == 0)
{ {
mScrolling = false; mScrolling = false;

View file

@ -5,6 +5,7 @@
#include "../SystemData.h" #include "../SystemData.h"
#include "../FolderData.h" #include "../FolderData.h"
#include "../Sound.h" #include "../Sound.h"
#include "ThemeComponent.h"
#include "TextListComponent.h" #include "TextListComponent.h"
#include "GuiBox.h" #include "GuiBox.h"
@ -13,8 +14,7 @@ class GuiGameList;
class GuiFastSelect : public GuiComponent class GuiFastSelect : public GuiComponent
{ {
public: public:
GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, GuiBoxData data, GuiFastSelect(Window* window, GuiGameList* parent, TextListComponent<FileData*>* list, char startLetter, ThemeComponent * theme);
int textcolor, std::shared_ptr<Sound> & scrollsound, Font* font);
~GuiFastSelect(); ~GuiFastSelect();
bool input(InputConfig* config, Input input); bool input(InputConfig* config, Input input);
@ -41,7 +41,7 @@ private:
bool mScrolling; bool mScrolling;
std::shared_ptr<Sound> mScrollSound; std::shared_ptr<Sound> mScrollSound;
Font* mFont; ThemeComponent * mTheme;
}; };
#endif #endif

View file

@ -34,16 +34,16 @@ GuiGameList::GuiGameList(Window* window) : GuiComponent(window),
{ {
//first object initializes the vector //first object initializes the vector
if (sortStates.empty()) { if (sortStates.empty()) {
sortStates.push_back(FolderData::SortState(FolderData::compareFileName, true)); sortStates.push_back(FolderData::SortState(FolderData::compareFileName, true, "file name, ascending"));
sortStates.push_back(FolderData::SortState(FolderData::compareFileName, false)); sortStates.push_back(FolderData::SortState(FolderData::compareFileName, false, "file name, descending"));
sortStates.push_back(FolderData::SortState(FolderData::compareRating, true)); sortStates.push_back(FolderData::SortState(FolderData::compareRating, true, "database rating, ascending"));
sortStates.push_back(FolderData::SortState(FolderData::compareRating, false)); sortStates.push_back(FolderData::SortState(FolderData::compareRating, false, "database rating, descending"));
sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, true)); sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, true, "your rating, ascending"));
sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, false)); sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, false, "your rating, descending"));
sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, true)); sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, true, "played least often"));
sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, false)); sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, false, "played most often"));
sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, true)); sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, true, "played least recently"));
sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, false)); sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, false, "played most recently"));
} }
mImageAnimation.addChild(&mScreenshot); mImageAnimation.addChild(&mScreenshot);
@ -212,7 +212,7 @@ bool GuiGameList::input(InputConfig* config, Input input)
//open the fast select menu //open the fast select menu
if(config->isMappedTo("select", input) && input.value != 0) if(config->isMappedTo("select", input) && input.value != 0)
{ {
mWindow->pushGui(new GuiFastSelect(mWindow, this, &mList, mList.getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getColor("fastSelect"), mTheme->getSound("menuScroll"), mTheme->getFastSelectFont())); mWindow->pushGui(new GuiFastSelect(mWindow, this, &mList, mList.getSelectedObject()->getName()[0], mTheme));
return true; return true;
} }
@ -231,6 +231,11 @@ bool GuiGameList::input(InputConfig* config, Input input)
return false; return false;
} }
const FolderData::SortState & GuiGameList::getSortState() const
{
return sortStates.at(sortStateIndex);
}
void GuiGameList::setSortIndex(size_t index) void GuiGameList::setSortIndex(size_t index)
{ {
//make the index valid //make the index valid

View file

@ -35,6 +35,7 @@ public:
void updateDetailData(); void updateDetailData();
const FolderData::SortState & getSortState() const;
void setSortIndex(size_t index); void setSortIndex(size_t index);
void setNextSortIndex(); void setNextSortIndex();
void setPreviousSortIndex(); void setPreviousSortIndex();