From 284a7a5dc629e473634d8ab60a7773a0b0757a67 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 4 Aug 2012 16:38:37 -0500 Subject: [PATCH] Sorted list after gamelist.xml is parsed. Added restart to GuiMenu. --- changelog.txt | 6 +++--- src/XMLReader.cpp | 12 +++++++++++- src/components/GuiInputConfig.cpp | 2 ++ src/components/GuiList.cpp | 14 +++++++------- src/components/GuiList.h | 4 +++- src/components/GuiMenu.cpp | 9 +++++---- src/main.cpp | 5 ++--- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1f5c27d8b..003b63224 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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" diff --git a/src/XMLReader.cpp b/src/XMLReader.cpp index cf81d9832..1c9f37744 100644 --- a/src/XMLReader.cpp +++ b/src/XMLReader.cpp @@ -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(); + } } diff --git a/src/components/GuiInputConfig.cpp b/src/components/GuiInputConfig.cpp index 2782c2386..e4fe5f586 100644 --- a/src/components/GuiInputConfig.cpp +++ b/src/components/GuiInputConfig.cpp @@ -131,4 +131,6 @@ void GuiInputConfig::writeConfig() { file << "AXISNEG " << iter->first << " " << iter->second << "\n"; } + + file.close(); } diff --git a/src/components/GuiList.cpp b/src/components/GuiList.cpp index 4c9407452..0b87843c5 100644 --- a/src/components/GuiList.cpp +++ b/src/components/GuiList.cpp @@ -2,7 +2,7 @@ #include template -GuiList::GuiList(int offsetX, int offsetY) +GuiList::GuiList(int offsetX, int offsetY, Renderer::FontSize fontsize) { mSelection = 0; mScrollDir = 0; @@ -12,6 +12,8 @@ GuiList::GuiList(int offsetX, int offsetY) mOffsetX = offsetX; mOffsetY = offsetY; + mFont = fontsize; + InputManager::registerComponent(this); } @@ -24,10 +26,8 @@ GuiList::~GuiList() template void GuiList::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::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::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; } } diff --git a/src/components/GuiList.h b/src/components/GuiList.h index e2e4ac9c4..d99b9351f 100644 --- a/src/components/GuiList.h +++ b/src/components/GuiList.h @@ -15,7 +15,7 @@ template 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 diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp index d26e789c8..a8591b4a2 100644 --- a/src/components/GuiMenu.cpp +++ b/src/components/GuiMenu.cpp @@ -6,14 +6,15 @@ GuiMenu::GuiMenu(GuiComponent* parent) mParent = parent; parent->pause(); - mList = new GuiList(Renderer::getScreenWidth() * 0.5, 20); - + mList = new GuiList(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() diff --git a/src/main.cpp b/src/main.cpp index 5caaed763..34fbeed8a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); }