2012-07-20 01:08:29 +00:00
|
|
|
#include "GuiGameList.h"
|
2012-07-21 19:06:24 +00:00
|
|
|
#include "../InputManager.h"
|
2012-07-20 16:14:09 +00:00
|
|
|
#include <iostream>
|
2012-08-02 04:03:15 +00:00
|
|
|
#include "GuiMenu.h"
|
2012-10-01 03:29:55 +00:00
|
|
|
#include "GuiFastSelect.h"
|
2012-08-10 19:28:34 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2013-01-04 23:31:51 +00:00
|
|
|
#include "../Log.h"
|
2013-06-17 19:01:03 +00:00
|
|
|
#include "../Settings.h"
|
2012-08-16 15:23:23 +00:00
|
|
|
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
|
|
|
|
std::vector<FolderData::SortState> GuiGameList::sortStates;
|
|
|
|
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Vector3f GuiGameList::getImagePos()
|
2013-06-14 15:48:13 +00:00
|
|
|
{
|
2013-07-10 11:29:43 +00:00
|
|
|
return Eigen::Vector3f(Renderer::getScreenWidth() * mTheme->getFloat("gameImageOffsetX"), Renderer::getScreenHeight() * mTheme->getFloat("gameImageOffsetY"), 0.0f);
|
2013-06-14 15:48:13 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
bool GuiGameList::isDetailed() const
|
2012-07-20 01:08:29 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
if(mSystem == NULL)
|
|
|
|
return false;
|
2012-08-02 01:43:55 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
return mSystem->hasGamelist();
|
|
|
|
}
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
GuiGameList::GuiGameList(Window* window) : GuiComponent(window),
|
|
|
|
mTheme(new ThemeComponent(mWindow)),
|
2013-07-10 11:29:43 +00:00
|
|
|
mList(window, 0.0f, 0.0f, Font::get(*window->getResourceManager(), Font::getDefaultPath(), FONT_SIZE_MEDIUM)),
|
2013-07-02 07:04:52 +00:00
|
|
|
mScreenshot(window),
|
|
|
|
mDescription(window),
|
2013-07-03 01:01:58 +00:00
|
|
|
mDescContainer(window),
|
2013-07-10 11:29:43 +00:00
|
|
|
mTransitionImage(window, 0.0f, 0.0f, "", (float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight(), true),
|
2013-07-02 21:14:33 +00:00
|
|
|
sortStateIndex(Settings::getInstance()->getInt("GameListSortIndex"))
|
2013-07-02 07:04:52 +00:00
|
|
|
{
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
//first object initializes the vector
|
|
|
|
if (sortStates.empty()) {
|
2013-06-30 17:24:09 +00:00
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareFileName, true, "file name, ascending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareFileName, false, "file name, descending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareRating, true, "database rating, ascending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareRating, false, "database rating, descending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, true, "your rating, ascending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareUserRating, false, "your rating, descending"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, true, "played least often"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareTimesPlayed, false, "played most often"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, true, "played least recently"));
|
|
|
|
sortStates.push_back(FolderData::SortState(FolderData::compareLastPlayed, false, "played most recently"));
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
}
|
2012-08-02 01:43:55 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
mImageAnimation.addChild(&mScreenshot);
|
2013-07-03 01:01:58 +00:00
|
|
|
mDescContainer.addChild(&mDescription);
|
2013-06-21 21:54:41 +00:00
|
|
|
|
2013-07-02 05:57:31 +00:00
|
|
|
//scale delay with screen width (higher width = more text per line)
|
2013-07-02 07:53:23 +00:00
|
|
|
//the scroll speed is automatically scaled by component size
|
2013-07-03 01:01:58 +00:00
|
|
|
mDescContainer.setAutoScroll((int)(1500 + (Renderer::getScreenWidth() * 0.5)), 0.025f);
|
2013-07-02 05:57:31 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mTransitionImage.setPosition((float)Renderer::getScreenWidth(), 0);
|
2013-06-16 21:23:04 +00:00
|
|
|
mTransitionImage.setOrigin(0, 0);
|
|
|
|
mTransitionAnimation.addChild(&mTransitionImage);
|
|
|
|
|
|
|
|
//a hack! the GuiGameList doesn't use the children system right now because I haven't redone it to do so yet.
|
|
|
|
//the list depends on knowing it's final window coordinates (getGlobalOffset), which requires knowing the where the GuiGameList is.
|
|
|
|
//the GuiGameList now moves during screen transitions, so we have to let it know somehow.
|
|
|
|
//this should be removed in favor of using real children soon.
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setParent(this);
|
2013-06-16 21:23:04 +00:00
|
|
|
|
2012-07-21 20:57:53 +00:00
|
|
|
setSystemId(0);
|
2012-07-21 19:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuiGameList::~GuiGameList()
|
|
|
|
{
|
2013-06-16 21:23:04 +00:00
|
|
|
//undo the parenting hack because otherwise it's not really a child and will try to remove itself on delete
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setParent(NULL);
|
|
|
|
|
2013-06-14 15:48:13 +00:00
|
|
|
delete mTheme;
|
2012-07-20 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 20:57:53 +00:00
|
|
|
void GuiGameList::setSystemId(int id)
|
|
|
|
{
|
2012-07-23 23:53:33 +00:00
|
|
|
if(SystemData::sSystemVector.size() == 0)
|
|
|
|
{
|
2013-01-04 23:31:51 +00:00
|
|
|
LOG(LogError) << "Error - no systems found!";
|
2012-07-23 23:53:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-21 20:57:53 +00:00
|
|
|
//make sure the id is within range
|
|
|
|
if(id >= (int)SystemData::sSystemVector.size())
|
|
|
|
id -= SystemData::sSystemVector.size();
|
|
|
|
if(id < 0)
|
|
|
|
id += SystemData::sSystemVector.size();
|
|
|
|
|
|
|
|
mSystemId = id;
|
|
|
|
mSystem = SystemData::sSystemVector.at(mSystemId);
|
|
|
|
|
2012-10-13 23:37:51 +00:00
|
|
|
//clear the folder stack
|
2012-07-27 16:58:27 +00:00
|
|
|
while(mFolderStack.size()){ mFolderStack.pop(); }
|
|
|
|
|
|
|
|
mFolder = mSystem->getRootFolder();
|
|
|
|
|
2012-08-11 04:17:52 +00:00
|
|
|
updateTheme();
|
2012-07-21 20:57:53 +00:00
|
|
|
updateList();
|
2012-08-12 14:43:09 +00:00
|
|
|
updateDetailData();
|
2012-07-21 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
void GuiGameList::render(const Eigen::Affine3f& parentTrans)
|
2012-07-20 01:08:29 +00:00
|
|
|
{
|
2013-07-10 11:29:43 +00:00
|
|
|
if(mTransitionImage.getPosition().x() > 0) //transitioning in from the left
|
|
|
|
mPosition[0] = mTransitionImage.getPosition().x() - Renderer::getScreenWidth();
|
2013-06-16 21:23:04 +00:00
|
|
|
else //transitioning in from the right
|
2013-07-10 11:29:43 +00:00
|
|
|
mPosition[0] = mTransitionImage.getPosition().x() + Renderer::getScreenWidth();
|
2013-06-16 21:23:04 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Affine3f trans = parentTrans * getTransform();
|
|
|
|
Renderer::setMatrix(trans);
|
2013-06-16 21:23:04 +00:00
|
|
|
|
2012-08-10 19:28:34 +00:00
|
|
|
if(mTheme)
|
2013-07-10 11:29:43 +00:00
|
|
|
mTheme->render(trans);
|
|
|
|
|
|
|
|
//reset modelview matrix if mTheme changed it
|
|
|
|
Renderer::setMatrix(trans);
|
2012-08-02 01:43:55 +00:00
|
|
|
|
2013-07-09 05:44:24 +00:00
|
|
|
std::shared_ptr<Font> headerFont = Font::get(*mWindow->getResourceManager(), Font::getDefaultPath(), FONT_SIZE_LARGE);
|
2013-07-03 07:54:55 +00:00
|
|
|
|
2012-08-13 18:32:53 +00:00
|
|
|
//header
|
2012-11-17 18:39:49 +00:00
|
|
|
if(!mTheme->getBool("hideHeader"))
|
2013-07-03 07:54:55 +00:00
|
|
|
headerFont->drawCenteredText(mSystem->getDescName(), 0, 1, 0xFF0000FF);
|
2012-08-02 01:43:55 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
if(isDetailed())
|
2012-08-02 01:43:55 +00:00
|
|
|
{
|
2012-08-14 01:27:39 +00:00
|
|
|
//divider
|
2012-11-17 18:39:49 +00:00
|
|
|
if(!mTheme->getBool("hideDividers"))
|
2013-07-03 07:54:55 +00:00
|
|
|
Renderer::drawRect((int)(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX")) - 4, headerFont->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF);
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mScreenshot.render(trans);
|
|
|
|
mDescContainer.render(trans);
|
2012-08-02 01:43:55 +00:00
|
|
|
}
|
2013-04-08 17:40:15 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mList.render(trans);
|
|
|
|
mTransitionImage.render(trans);
|
2012-07-20 16:14:09 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 15:08:32 +00:00
|
|
|
bool GuiGameList::input(InputConfig* config, Input input)
|
2012-07-21 19:06:24 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.input(config, input);
|
2013-04-09 18:13:47 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("a", input) && mFolder->getFileCount() > 0 && input.value != 0)
|
2012-07-21 20:57:53 +00:00
|
|
|
{
|
2013-04-08 16:52:40 +00:00
|
|
|
//play select sound
|
|
|
|
mTheme->getSound("menuSelect")->play();
|
2012-10-13 20:05:43 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
FileData* file = mList.getSelectedObject();
|
2013-04-08 16:52:40 +00:00
|
|
|
if(file->isFolder()) //if you selected a folder, add this directory to the stack, and use the selected one
|
|
|
|
{
|
|
|
|
mFolderStack.push(mFolder);
|
|
|
|
mFolder = (FolderData*)file;
|
|
|
|
updateList();
|
2013-06-14 15:48:13 +00:00
|
|
|
updateDetailData();
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2013-04-08 16:52:40 +00:00
|
|
|
}else{
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.stopScrolling();
|
2012-10-14 17:49:57 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
//wait for the sound to finish or we'll never hear it...
|
|
|
|
while(mTheme->getSound("menuSelect")->isPlaying());
|
2012-10-13 20:05:43 +00:00
|
|
|
|
2013-04-08 17:40:15 +00:00
|
|
|
mSystem->launchGame(mWindow, (GameData*)file);
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-07-27 16:58:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-14 01:27:39 +00:00
|
|
|
//if there's something on the directory stack, return to it
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("b", input) && input.value != 0 && mFolderStack.size())
|
2012-07-27 16:58:27 +00:00
|
|
|
{
|
|
|
|
mFolder = mFolderStack.top();
|
|
|
|
mFolderStack.pop();
|
|
|
|
updateList();
|
2012-08-12 14:43:09 +00:00
|
|
|
updateDetailData();
|
2012-10-13 20:05:43 +00:00
|
|
|
|
|
|
|
//play the back sound
|
2012-11-17 18:39:49 +00:00
|
|
|
mTheme->getSound("menuBack")->play();
|
2013-06-02 15:08:32 +00:00
|
|
|
|
|
|
|
return true;
|
2012-07-21 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 21:44:07 +00:00
|
|
|
//only allow switching systems if more than one exists (otherwise it'll reset your position when you switch and it's annoying)
|
2013-04-08 16:52:40 +00:00
|
|
|
if(SystemData::sSystemVector.size() > 1 && input.value != 0)
|
2012-07-21 19:06:24 +00:00
|
|
|
{
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("right", input))
|
2012-09-07 21:44:07 +00:00
|
|
|
{
|
|
|
|
setSystemId(mSystemId + 1);
|
2013-06-16 21:23:04 +00:00
|
|
|
doTransition(-1);
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-09-07 21:44:07 +00:00
|
|
|
}
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("left", input))
|
2012-09-07 21:44:07 +00:00
|
|
|
{
|
|
|
|
setSystemId(mSystemId - 1);
|
2013-06-16 21:23:04 +00:00
|
|
|
doTransition(1);
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-09-07 21:44:07 +00:00
|
|
|
}
|
2012-07-21 19:06:24 +00:00
|
|
|
}
|
2012-08-02 01:43:55 +00:00
|
|
|
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
//change sort order
|
|
|
|
if(config->isMappedTo("sortordernext", input) && input.value != 0) {
|
|
|
|
setNextSortIndex();
|
|
|
|
//std::cout << "Sort order is " << FolderData::getSortStateName(sortStates.at(sortStateIndex).comparisonFunction, sortStates.at(sortStateIndex).ascending) << std::endl;
|
|
|
|
}
|
|
|
|
else if(config->isMappedTo("sortorderprevious", input) && input.value != 0) {
|
|
|
|
setPreviousSortIndex();
|
|
|
|
//std::cout << "Sort order is " << FolderData::getSortStateName(sortStates.at(sortStateIndex).comparisonFunction, sortStates.at(sortStateIndex).ascending) << std::endl;
|
|
|
|
}
|
|
|
|
|
2012-10-13 20:05:43 +00:00
|
|
|
//open the "start menu"
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("menu", input) && input.value != 0)
|
2012-08-02 04:03:15 +00:00
|
|
|
{
|
2013-04-09 18:13:47 +00:00
|
|
|
mWindow->pushGui(new GuiMenu(mWindow, this));
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-08-02 04:03:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 20:05:43 +00:00
|
|
|
//open the fast select menu
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("select", input) && input.value != 0)
|
2012-10-01 03:29:55 +00:00
|
|
|
{
|
2013-07-02 20:49:53 +00:00
|
|
|
mWindow->pushGui(new GuiFastSelect(mWindow, this, &mList, mList.getSelectedObject()->getName()[0], mTheme));
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-10-01 03:29:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
if(isDetailed())
|
2012-08-02 01:43:55 +00:00
|
|
|
{
|
2013-04-08 16:52:40 +00:00
|
|
|
if(config->isMappedTo("up", input) || config->isMappedTo("down", input) || config->isMappedTo("pageup", input) || config->isMappedTo("pagedown", input))
|
2012-08-02 01:43:55 +00:00
|
|
|
{
|
2013-04-08 16:52:40 +00:00
|
|
|
if(input.value == 0)
|
2012-08-16 15:23:23 +00:00
|
|
|
updateDetailData();
|
|
|
|
else
|
2012-10-17 17:15:58 +00:00
|
|
|
clearDetailData();
|
2012-08-02 01:43:55 +00:00
|
|
|
}
|
2013-06-02 15:08:32 +00:00
|
|
|
return true;
|
2012-08-02 01:43:55 +00:00
|
|
|
}
|
2013-06-02 15:08:32 +00:00
|
|
|
|
|
|
|
return false;
|
2012-07-21 19:06:24 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 17:24:09 +00:00
|
|
|
const FolderData::SortState & GuiGameList::getSortState() const
|
|
|
|
{
|
|
|
|
return sortStates.at(sortStateIndex);
|
|
|
|
}
|
|
|
|
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
void GuiGameList::setSortIndex(size_t index)
|
|
|
|
{
|
|
|
|
//make the index valid
|
|
|
|
if (index >= sortStates.size()) {
|
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
if (index != sortStateIndex) {
|
|
|
|
//get sort state from vector and sort list
|
|
|
|
sortStateIndex = index;
|
|
|
|
sort(sortStates.at(sortStateIndex).comparisonFunction, sortStates.at(sortStateIndex).ascending);
|
|
|
|
}
|
2013-07-02 21:14:33 +00:00
|
|
|
//save new index to settings
|
|
|
|
Settings::getInstance()->setInt("GameListSortIndex", sortStateIndex);
|
Support sorting of game list via input
You can now map the functions "sortordernext" and "sortorderprevious" to
inputs (in es_input.cfg) and toggle the game list sort order with them.
The order is: "file name, ascending" (default), "file name, descending",
"rating ascending", "rating descending", "user rating ascending", "user
rating descending", "time played ascending", "times played descending",
"last played time ascending", "last played time descending".
2013-06-28 17:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameList::setNextSortIndex()
|
|
|
|
{
|
|
|
|
//make the index wrap around
|
|
|
|
if ((sortStateIndex - 1) >= sortStates.size()) {
|
|
|
|
setSortIndex(0);
|
|
|
|
}
|
|
|
|
setSortIndex(sortStateIndex + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameList::setPreviousSortIndex()
|
|
|
|
{
|
|
|
|
//make the index wrap around
|
|
|
|
if (((int)sortStateIndex - 1) < 0) {
|
|
|
|
setSortIndex(sortStates.size() - 1);
|
|
|
|
}
|
|
|
|
setSortIndex(sortStateIndex - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameList::sort(FolderData::ComparisonFunction & comparisonFunction, bool ascending)
|
|
|
|
{
|
|
|
|
//resort list and update it
|
|
|
|
mFolder->sort(comparisonFunction, ascending);
|
|
|
|
updateList();
|
|
|
|
updateDetailData();
|
|
|
|
}
|
|
|
|
|
2012-07-20 16:14:09 +00:00
|
|
|
void GuiGameList::updateList()
|
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.clear();
|
2012-07-20 16:14:09 +00:00
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
for(unsigned int i = 0; i < mFolder->getFileCount(); i++)
|
2012-07-20 16:14:09 +00:00
|
|
|
{
|
2012-07-27 16:58:27 +00:00
|
|
|
FileData* file = mFolder->getFile(i);
|
2012-07-21 20:57:53 +00:00
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
if(file->isFolder())
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.addObject(file->getName(), file, mTheme->getColor("secondary"));
|
2012-07-27 16:58:27 +00:00
|
|
|
else
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.addObject(file->getName(), file, mTheme->getColor("primary"));
|
2012-07-20 16:14:09 +00:00
|
|
|
}
|
2012-07-20 01:08:29 +00:00
|
|
|
}
|
2012-08-02 04:03:15 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
std::string GuiGameList::getThemeFile()
|
|
|
|
{
|
2012-12-17 19:29:43 +00:00
|
|
|
std::string themePath;
|
|
|
|
|
2013-05-13 19:53:28 +00:00
|
|
|
themePath = getHomePath();
|
2012-12-17 19:29:43 +00:00
|
|
|
themePath += "/.emulationstation/" + mSystem->getName() + "/theme.xml";
|
|
|
|
if(boost::filesystem::exists(themePath))
|
|
|
|
return themePath;
|
|
|
|
|
|
|
|
themePath = mSystem->getStartPath() + "/theme.xml";
|
|
|
|
if(boost::filesystem::exists(themePath))
|
|
|
|
return themePath;
|
|
|
|
|
2013-05-13 19:53:28 +00:00
|
|
|
themePath = getHomePath();
|
2012-12-17 19:29:43 +00:00
|
|
|
themePath += "/.emulationstation/es_theme.xml";
|
|
|
|
if(boost::filesystem::exists(themePath))
|
|
|
|
return themePath;
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2012-08-10 19:28:34 +00:00
|
|
|
void GuiGameList::updateTheme()
|
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mTheme->readXML(getThemeFile(), isDetailed());
|
2012-08-13 18:32:53 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setSelectorColor(mTheme->getColor("selector"));
|
|
|
|
mList.setSelectedTextColor(mTheme->getColor("selected"));
|
|
|
|
mList.setScrollSound(mTheme->getSound("menuScroll"));
|
2012-09-15 21:24:33 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setFont(mTheme->getListFont());
|
2013-07-10 11:29:43 +00:00
|
|
|
mList.setPosition(0.0f, Font::get(*mWindow->getResourceManager(), Font::getDefaultPath(), FONT_SIZE_LARGE)->getHeight() + 2.0f);
|
2012-10-31 14:46:06 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
if(isDetailed())
|
2012-09-15 21:24:33 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setCentered(mTheme->getBool("listCentered"));
|
2012-10-13 23:40:44 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mList.setPosition(mTheme->getFloat("listOffsetX") * Renderer::getScreenWidth(), mList.getPosition().y());
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.setTextOffsetX((int)(mTheme->getFloat("listTextOffsetX") * Renderer::getScreenWidth()));
|
2012-10-13 23:37:51 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mScreenshot.setPosition(mTheme->getFloat("gameImageOffsetX") * Renderer::getScreenWidth(), mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight());
|
2013-07-02 07:04:52 +00:00
|
|
|
mScreenshot.setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY"));
|
2013-07-10 11:29:43 +00:00
|
|
|
mScreenshot.setResize(mTheme->getFloat("gameImageWidth") * Renderer::getScreenWidth(), mTheme->getFloat("gameImageHeight") * Renderer::getScreenHeight(), false);
|
2013-06-14 15:48:13 +00:00
|
|
|
|
|
|
|
mDescription.setColor(mTheme->getColor("description"));
|
|
|
|
mDescription.setFont(mTheme->getDescriptionFont());
|
2013-07-02 07:04:52 +00:00
|
|
|
}else{
|
|
|
|
mList.setCentered(true);
|
2013-07-10 11:29:43 +00:00
|
|
|
mList.setPosition(0, mList.getPosition().y());
|
2013-07-10 00:02:59 +00:00
|
|
|
mList.setTextOffsetX(0);
|
2012-09-15 21:24:33 +00:00
|
|
|
}
|
2012-08-10 19:28:34 +00:00
|
|
|
}
|
|
|
|
|
2012-08-12 14:43:09 +00:00
|
|
|
void GuiGameList::updateDetailData()
|
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
if(!isDetailed())
|
2012-08-12 14:43:09 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mScreenshot.setImage("");
|
|
|
|
mDescription.setText("");
|
|
|
|
}else{
|
|
|
|
//if we've selected a game
|
|
|
|
if(mList.getSelectedObject() && !mList.getSelectedObject()->isFolder())
|
|
|
|
{
|
|
|
|
//set image to either "not found" image or metadata image
|
|
|
|
if(((GameData*)mList.getSelectedObject())->getImagePath().empty())
|
|
|
|
mScreenshot.setImage(mTheme->getString("imageNotFoundPath"));
|
|
|
|
else
|
|
|
|
mScreenshot.setImage(((GameData*)mList.getSelectedObject())->getImagePath());
|
2012-10-25 17:36:30 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Vector3f imgOffset = Eigen::Vector3f(Renderer::getScreenWidth() * 0.10f, 0, 0);
|
|
|
|
mScreenshot.setPosition(getImagePos() - imgOffset);
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
mImageAnimation.fadeIn(35);
|
2013-07-10 11:29:43 +00:00
|
|
|
mImageAnimation.move(imgOffset.x(), imgOffset.y(), 20);
|
2013-06-14 15:48:13 +00:00
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mDescContainer.setPosition(Eigen::Vector3f(Renderer::getScreenWidth() * 0.03f, getImagePos().y() + mScreenshot.getSize().y() + 12, 0));
|
|
|
|
mDescContainer.setSize(Eigen::Vector2f(Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03f), Renderer::getScreenHeight() - mDescContainer.getPosition().y()));
|
|
|
|
mDescContainer.setScrollPos(Eigen::Vector2d(0, 0));
|
2013-07-03 01:01:58 +00:00
|
|
|
mDescContainer.resetAutoScrollTimer();
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
mDescription.setPosition(0, 0);
|
|
|
|
mDescription.setSize(Eigen::Vector2f(Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03f), 0));
|
2013-07-02 07:04:52 +00:00
|
|
|
mDescription.setText(((GameData*)mList.getSelectedObject())->getDescription());
|
|
|
|
}else{
|
|
|
|
mScreenshot.setImage("");
|
|
|
|
mDescription.setText("");
|
|
|
|
}
|
2012-08-12 14:43:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-17 17:15:58 +00:00
|
|
|
void GuiGameList::clearDetailData()
|
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
if(isDetailed())
|
2012-10-17 17:15:58 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mImageAnimation.fadeOut(35);
|
|
|
|
mDescription.setText("");
|
2012-10-17 17:15:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
GuiGameList* GuiGameList::create(Window* window)
|
2012-10-05 20:18:36 +00:00
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
GuiGameList* list = new GuiGameList(window);
|
2013-04-08 17:40:15 +00:00
|
|
|
window->pushGui(list);
|
|
|
|
return list;
|
2012-10-05 20:18:36 +00:00
|
|
|
}
|
2013-04-09 18:13:47 +00:00
|
|
|
|
|
|
|
void GuiGameList::update(int deltaTime)
|
|
|
|
{
|
2013-07-02 07:04:52 +00:00
|
|
|
mImageAnimation.update(deltaTime);
|
2013-04-12 02:59:19 +00:00
|
|
|
|
2013-06-16 21:23:04 +00:00
|
|
|
mTransitionAnimation.update(deltaTime);
|
|
|
|
|
2013-07-02 07:04:52 +00:00
|
|
|
mList.update(deltaTime);
|
2013-07-02 05:57:31 +00:00
|
|
|
|
2013-07-03 01:01:58 +00:00
|
|
|
mDescContainer.update(deltaTime);
|
2013-04-09 18:13:47 +00:00
|
|
|
}
|
2013-06-16 21:23:04 +00:00
|
|
|
|
|
|
|
void GuiGameList::doTransition(int dir)
|
|
|
|
{
|
|
|
|
mTransitionImage.copyScreen();
|
|
|
|
mTransitionImage.setOpacity(255);
|
2013-07-10 11:29:43 +00:00
|
|
|
mTransitionImage.setPosition(0, 0);
|
2013-06-16 21:23:04 +00:00
|
|
|
mTransitionAnimation.move(Renderer::getScreenWidth() * dir, 0, 50);
|
|
|
|
}
|