diff --git a/Makefile b/Makefile index 17a0c174a..afaad31e9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=g++ CFLAGS=-c -Wall LDFLAGS=-lSDL -lSDL_ttf -lSDL_image -lboost_system -lboost_filesystem -SRCSOURCES=main.cpp Renderer.cpp Renderer_draw.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp components/GuiList.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp pugiXML/pugixml.cpp +SRCSOURCES=main.cpp Renderer.cpp Renderer_draw.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp components/GuiList.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp pugiXML/pugixml.cpp SOURCES=$(addprefix src/,$(SRCSOURCES)) OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=emulationstation diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 000000000..1f5c27d8b --- /dev/null +++ b/changelog.txt @@ -0,0 +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 +-Added Menu button +-Added simple menu diff --git a/src/FolderData.cpp b/src/FolderData.cpp index fa7932654..0e21aa109 100644 --- a/src/FolderData.cpp +++ b/src/FolderData.cpp @@ -1,5 +1,6 @@ #include "FolderData.h" #include "SystemData.h" +#include bool FolderData::isFolder() { return true; } std::string FolderData::getName() { return mName; } @@ -29,3 +30,32 @@ void FolderData::pushFileData(FileData* file) mFileVector.push_back(file); } +//returns if file1 should come before file2 +bool filesort(FileData* file1, FileData* file2) +{ + std::string name1 = file1->getName(); + std::string name2 = file2->getName(); + + for(unsigned int i = 0; i < name1.length(); i++) + { + if(name1[i] != name2[i]) + { + if(name1[i] < name2[i]) + { + return true; + }else{ + return false; + } + } + } + + if(name1.length() < name2.length()) + return true; + else + return false; +} + +void FolderData::sort() +{ + std::sort(mFileVector.begin(), mFileVector.end(), filesort); +} diff --git a/src/FolderData.h b/src/FolderData.h index 781046c38..52fd5ea47 100644 --- a/src/FolderData.h +++ b/src/FolderData.h @@ -20,6 +20,8 @@ public: FileData* getFile(unsigned int i); void pushFileData(FileData* file); + + void sort(); private: SystemData* mSystem; std::string mPath; diff --git a/src/GuiComponent.cpp b/src/GuiComponent.cpp index 45a75aa07..3ea988eb7 100644 --- a/src/GuiComponent.cpp +++ b/src/GuiComponent.cpp @@ -57,3 +57,18 @@ void GuiComponent::render() } } +void GuiComponent::pause() +{ + onPause(); + + for(unsigned int i = 0; i < mChildren.size(); i++) + mChildren.at(i)->pause(); +} + +void GuiComponent::resume() +{ + onResume(); + + for(unsigned int i = 0; i < mChildren.size(); i++) + mChildren.at(i)->resume(); +} diff --git a/src/GuiComponent.h b/src/GuiComponent.h index 9bd2f8358..0648444c6 100644 --- a/src/GuiComponent.h +++ b/src/GuiComponent.h @@ -15,6 +15,11 @@ public: virtual void onRender() { }; virtual void onTick(int deltaTime) { }; + void pause(); + void resume(); + virtual void onPause() { }; + virtual void onResume() { }; + virtual void onInput(InputManager::InputButton button, bool keyDown) { }; void addChild(GuiComponent* comp); diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 13819eb10..01fb86155 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -39,4 +39,3 @@ void Renderer::render() renderVector.at(i)->render(); } } - diff --git a/src/SystemData.cpp b/src/SystemData.cpp index 8c3863776..62869537e 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -97,6 +97,8 @@ void SystemData::populateFolder(FolderData* folder) } } } + + folder->sort(); } diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index 649728ba9..dc013a67c 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -1,6 +1,7 @@ #include "GuiGameList.h" #include "../InputManager.h" #include +#include "GuiMenu.h" #define SCREENSHOTWIDTH 256 #define SCREENSHOTHEIGHT 256 @@ -128,6 +129,11 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown) setSystemId(mSystemId - 1); } + if(button == InputManager::MENU && keyDown) + { + new GuiMenu(this); + } + if(mDetailed) { if(!keyDown && (button == InputManager::UP || button == InputManager::DOWN)) @@ -159,3 +165,16 @@ void GuiGameList::updateList() mList->addObject(file->getName(), file); } } + +//these are called when the menu opens/closes +void GuiGameList::onPause() +{ + InputManager::unregisterComponent(this); + InputManager::unregisterComponent(mList); +} + +void GuiGameList::onResume() +{ + InputManager::registerComponent(this); + InputManager::registerComponent(mList); +} diff --git a/src/components/GuiGameList.h b/src/components/GuiGameList.h index 9e322f46f..a5a7d2a3c 100644 --- a/src/components/GuiGameList.h +++ b/src/components/GuiGameList.h @@ -21,6 +21,8 @@ public: void onRender(); void onInput(InputManager::InputButton button, bool keyDown); + void onPause(); + void onResume(); private: SystemData* mSystem; diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp new file mode 100644 index 000000000..c9309a6e0 --- /dev/null +++ b/src/components/GuiMenu.cpp @@ -0,0 +1,50 @@ +#include "GuiMenu.h" +#include + +GuiMenu::GuiMenu(GuiComponent* parent) +{ + mParent = parent; + parent->pause(); + + mList = new GuiList(Renderer::getScreenWidth() * 0.5, 20); + + addChild(mList); + + mSkippedMenuClose = false; + + Renderer::registerComponent(this); + InputManager::registerComponent(this); +} + +GuiMenu::~GuiMenu() +{ + Renderer::unregisterComponent(this); + InputManager::unregisterComponent(this); + + delete mList; + mParent->resume(); +} + +void GuiMenu::onInput(InputManager::InputButton button, bool keyDown) +{ + if(button == InputManager::MENU && !keyDown) + { + if(!mSkippedMenuClose) + { + mSkippedMenuClose = true; + }else{ + delete this; + return; + } + } +} + +void GuiMenu::populateList() +{ + +} + +void GuiMenu::onRender() +{ + Renderer::drawRect(Renderer::getScreenWidth() * 0.25, 0, Renderer::getScreenWidth() * 0.5, Renderer::getScreenHeight(), 0xFF00FF); +} diff --git a/src/components/GuiMenu.h b/src/components/GuiMenu.h new file mode 100644 index 000000000..82525caa1 --- /dev/null +++ b/src/components/GuiMenu.h @@ -0,0 +1,22 @@ +#ifndef _GUIMENU_H_ +#define _GUIMENU_H_ + +#include "../GuiComponent.h" +#include "GuiList.h" + +class GuiMenu : public GuiComponent +{ +public: + GuiMenu(GuiComponent* parent); + ~GuiMenu(); + + void onInput(InputManager::InputButton button, bool keyDown); + void onRender(); + +private: + GuiComponent* mParent; + GuiList* mList; + bool mSkippedMenuClose; +}; + +#endif