Sorted list after gamelist.xml is parsed. Added restart to GuiMenu.

This commit is contained in:
root 2012-08-04 16:38:37 -05:00
parent cd4ebeafa2
commit 284a7a5dc6
7 changed files with 33 additions and 19 deletions

View file

@ -1,6 +1,6 @@
August 4
-Moved configuration files to $HOME/.emulationstation/
-Renderer::loadFonts() will now fall back to /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf if LinLibertine.ttf is not
-Folders should now be sorted alphabetically
-Renderer::loadFonts() will now fall back to /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf if LinLibertine.ttf is not found.
-All folders should now be sorted alphabetically
-Added Menu button
-Added simple menu
-Added menu consisting of bash commands for "Restart" and "Shutdown"

View file

@ -60,9 +60,11 @@ void parseXMLFile(std::string xmlpath)
std::string path = pathNode.text().get();
GameData* game = NULL;
SystemData* system = NULL;
for(unsigned int i = 0; i < SystemData::sSystemVector.size(); i++)
{
game = searchFolderByPath(SystemData::sSystemVector.at(i)->getRootFolder(), path);
system = SystemData::sSystemVector.at(i);
game = searchFolderByPath(system->getRootFolder(), path);
if(game != NULL)
break;
}
@ -86,4 +88,12 @@ void parseXMLFile(std::string xmlpath)
}
std::cout << "XML parsing complete.\n";
//sort all systems
for(unsigned int i = 0; i < SystemData::sSystemVector.size(); i++)
{
SystemData::sSystemVector.at(i)->getRootFolder()->sort();
}
}

View file

@ -131,4 +131,6 @@ void GuiInputConfig::writeConfig()
{
file << "AXISNEG " << iter->first << " " << iter->second << "\n";
}
file.close();
}

View file

@ -2,7 +2,7 @@
#include <iostream>
template <typename listType>
GuiList<listType>::GuiList(int offsetX, int offsetY)
GuiList<listType>::GuiList(int offsetX, int offsetY, Renderer::FontSize fontsize)
{
mSelection = 0;
mScrollDir = 0;
@ -12,6 +12,8 @@ GuiList<listType>::GuiList(int offsetX, int offsetY)
mOffsetX = offsetX;
mOffsetY = offsetY;
mFont = fontsize;
InputManager::registerComponent(this);
}
@ -24,10 +26,8 @@ GuiList<listType>::~GuiList()
template <typename listType>
void GuiList<listType>::onRender()
{
Renderer::FontSize fontsize = Renderer::MEDIUM;
const int cutoff = mOffsetY;
const int entrySize = Renderer::getFontHeight(fontsize) + 5;
const int entrySize = Renderer::getFontHeight(mFont) + 5;
int startEntry = 0;
@ -48,7 +48,7 @@ void GuiList<listType>::onRender()
if(mRowVector.size() == 0)
{
Renderer::drawCenteredText("The list is empty.", 0, y, 0xFF0000);
Renderer::drawCenteredText("The list is empty.", 0, y, 0xFF0000, mFont);
return;
}
@ -60,11 +60,11 @@ void GuiList<listType>::onRender()
{
if(mSelection == i)
{
Renderer::drawRect(mOffsetX, y, Renderer::getScreenWidth(), Renderer::getFontHeight(fontsize), 0x000000);
Renderer::drawRect(mOffsetX, y, Renderer::getScreenWidth(), Renderer::getFontHeight(mFont), 0x000000);
}
ListRow row = mRowVector.at((unsigned int)i);
Renderer::drawCenteredText(row.name, mOffsetX, y, row.color);
Renderer::drawCenteredText(row.name, mOffsetX, y, row.color, mFont);
y += entrySize;
}
}

View file

@ -15,7 +15,7 @@ template <typename listType>
class GuiList : public GuiComponent
{
public:
GuiList(int offsetX = 0, int offsetY = 0);
GuiList(int offsetX = 0, int offsetY = 0, Renderer::FontSize fontsize = Renderer::MEDIUM);
~GuiList();
void onRender();
@ -32,6 +32,8 @@ private:
int mScrollDir, mScrollAccumulator;
bool mScrolling;
Renderer::FontSize mFont;
int mOffsetX, mOffsetY;
struct ListRow

View file

@ -6,14 +6,15 @@ GuiMenu::GuiMenu(GuiComponent* parent)
mParent = parent;
parent->pause();
mList = new GuiList<std::string>(Renderer::getScreenWidth() * 0.5, 20);
mList = new GuiList<std::string>(0, Renderer::getFontHeight(Renderer::LARGE) + 2, Renderer::LARGE);
populateList();
addChild(mList);
mSkippedMenuClose = false;
Renderer::registerComponent(this);
InputManager::registerComponent(this);
}
GuiMenu::~GuiMenu()
@ -48,8 +49,8 @@ void GuiMenu::populateList()
{
mList->clear();
mList->addObject("Nothing", "");
mList->addObject("Shutdown", "sudo shutdown -h now");
mList->addObject("Restart", "sudo shutdown -r now", 0x0000FF);
mList->addObject("Shutdown", "sudo shutdown -h now", 0x0000FF);
}
void GuiMenu::onRender()

View file

@ -67,7 +67,7 @@ int main(int argc, char* argv[])
std::string configDir = home + "/.emulationstation";
if(!boost::filesystem::exists(configDir))
{
std::cout << "Creating config directory " << configDir << "\n";
std::cout << "Creating config directory \"" << configDir << "\"\n";
boost::filesystem::create_directory(configDir);
}
@ -82,8 +82,7 @@ int main(int argc, char* argv[])
}
if(boost::filesystem::exists(oldInpPath))
{
std::cout << "Moving old input config file " << oldInpPath << " to new path at " << InputManager::getConfigPath() << "\n";
boost::filesystem::copy_file(oldInpPath, InputManager::getConfigPath());
std::cout << "Deleting old input config file\n";
boost::filesystem::remove(oldInpPath);
}