Fixed multiple file extensions breaking stuff.

Added Makefile.x86 for building on a desktop (use SDL to acquire an OpenGL rendering context).
This commit is contained in:
Aloshi 2012-09-10 13:10:59 -05:00
parent 5786ecae7c
commit e17499c9b3
8 changed files with 52 additions and 24 deletions

View file

@ -1,7 +1,7 @@
CC=g++ CC=g++
CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_RPI_
LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
SRCSOURCES=main.cpp Renderer.cpp Renderer_init_rpi.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
SOURCES=$(addprefix src/,$(SRCSOURCES)) SOURCES=$(addprefix src/,$(SRCSOURCES))
OBJECTS=$(SOURCES:.cpp=.o) OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=emulationstation EXECUTABLE=emulationstation

View file

@ -1,3 +1,7 @@
September 10
-Fixed multiple extensions breaking things.
-Added Makefile.x86 for building on a desktop (acquire OpenGL context through SDL instead of EGL).
September 8 September 8
-Added support for multiple filetypes for systems - just separate them with a space. -Added support for multiple filetypes for systems - just separate them with a space.
-Updated example systems config to include example for multiple filetypes and be a little clearer. -Updated example systems config to include example for multiple filetypes and be a little clearer.

View file

@ -1,9 +1,9 @@
#ifndef _FONT_H_ #ifndef _FONT_H_
#define _FONT_H_ #define _FONT_H_
#include <string> #include <string>
#include <GLES/gl.h> #include "platform.h"
#include GLHEADER
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H

View file

@ -1,5 +1,6 @@
#include "Renderer.h" #include "Renderer.h"
#include <GLES/gl.h> #include "platform.h"
#include GLHEADER
#include <iostream> #include <iostream>
#include "Font.h" #include "Font.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -122,8 +123,8 @@ namespace Renderer {
if(!loadedFonts) if(!loadedFonts)
loadFonts(); loadFonts();
if(x < 0) //if(x < 0)
std::cout << "drawing at " << x << std::endl; // std::cout << "drawing at " << x << std::endl;
getFont(font)->drawText(text, x, y, color); getFont(font)->drawText(text, x, y, color);
} }

View file

@ -122,6 +122,7 @@ void SystemData::populateFolder(FolderData* folder)
std::string extension = filePath.extension().string(); std::string extension = filePath.extension().string();
std::string chkExt; std::string chkExt;
size_t extPos = 0; size_t extPos = 0;
do { do {
//now we loop through every extension in the list //now we loop through every extension in the list
size_t cpos = extPos; size_t cpos = extPos;
@ -129,7 +130,7 @@ void SystemData::populateFolder(FolderData* folder)
chkExt = mSearchExtension.substr(cpos, ((extPos == std::string::npos) ? mSearchExtension.length() - cpos: extPos - cpos)); chkExt = mSearchExtension.substr(cpos, ((extPos == std::string::npos) ? mSearchExtension.length() - cpos: extPos - cpos));
//if it matches, add it //if it matches, add it
if(chkExt == mSearchExtension) if(chkExt == extension)
{ {
GameData* newGame = new GameData(this, filePath.string(), filePath.stem().string()); GameData* newGame = new GameData(this, filePath.string(), filePath.stem().string());
folder->pushFileData(newGame); folder->pushFileData(newGame);
@ -139,7 +140,7 @@ void SystemData::populateFolder(FolderData* folder)
extPos++; extPos++;
} }
} while(extPos != std::string::npos && chkExt != ""); } while(extPos != std::string::npos && chkExt != "" && chkExt.find(".") != std::string::npos);
} }
} }
} }

View file

@ -51,6 +51,7 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system)
unsigned int separator = 0; unsigned int separator = 0;
unsigned int nextSeparator = 0; unsigned int nextSeparator = 0;
unsigned int loops = 0;
while(nextSeparator != std::string::npos) while(nextSeparator != std::string::npos)
{ {
//determine which chunk of the path we're testing right now //determine which chunk of the path we're testing right now
@ -81,6 +82,13 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system)
folder->pushFileData(newFolder); folder->pushFileData(newFolder);
folder = newFolder; folder = newFolder;
} }
if(loops > gamePath.length())
{
std::cerr << "breaking out of loop for path \"" << gamePath << "\"\n";
break;
}
loops++;
} }

View file

@ -4,7 +4,8 @@
#include "../GuiComponent.h" #include "../GuiComponent.h"
#include <string> #include <string>
#include <FreeImage.h> #include <FreeImage.h>
#include <GLES/gl.h> #include "../platform.h"
#include GLHEADER
class GuiImage : public GuiComponent class GuiImage : public GuiComponent
{ {

View file

@ -7,7 +7,13 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include "components/GuiInputConfig.h" #include "components/GuiInputConfig.h"
#include <SDL.h> #include <SDL.h>
#include <bcm_host.h>
#include "platform.h"
#ifdef _RPI_
#include <bcm_host.h>
#endif
#include <sstream> #include <sstream>
//these can be set by command-line arguments //these can be set by command-line arguments
@ -59,12 +65,16 @@ int main(int argc, char* argv[])
} }
#ifdef _RPI_
bcm_host_init(); bcm_host_init();
#endif
bool running = true; bool running = true;
//desktop uses SDL to set up an OpenGL context, and has its own SDL window...so I #ifdefed here.
//ALWAYS INITIALIZE VIDEO. It starts SDL's event system, and without it, input won't work. //ALWAYS INITIALIZE VIDEO. It starts SDL's event system, and without it, input won't work.
#ifdef _RPI_
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
{ {
std::cerr << "Error - could not initialize SDL!\n"; std::cerr << "Error - could not initialize SDL!\n";
@ -75,6 +85,7 @@ int main(int argc, char* argv[])
SDL_Surface* sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE); SDL_Surface* sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE);
std::cout << "Fake SDL window is " << sdlScreen->w << "x" << sdlScreen->h << "\n"; std::cout << "Fake SDL window is " << sdlScreen->w << "x" << sdlScreen->h << "\n";
#endif
bool renderInit = Renderer::init(width, height); bool renderInit = Renderer::init(width, height);
if(!renderInit) if(!renderInit)
@ -199,7 +210,9 @@ int main(int argc, char* argv[])
SDL_Quit(); SDL_Quit();
#ifdef _RPI_
bcm_host_deinit(); bcm_host_deinit();
#endif
return 0; return 0;
} }