From ffe573d1d63bc359ddfee3a1dc4fa7a6cb1f48e9 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Mon, 13 May 2013 14:53:28 -0500 Subject: [PATCH] Ported to Windows. Added --windowed for desktop builds. --- .../EmulationStation_vs2010.sln | 20 ++ .../EmulationStation_vs2010.vcxproj | 126 ++++++++++++ .../EmulationStation_vs2010.vcxproj.filters | 192 ++++++++++++++++++ .../EmulationStation_vs2010/lib_paths.props | 19 ++ Makefile.common | 2 +- changelog.txt | 4 + src/Font.cpp | 17 +- src/InputManager.cpp | 7 +- src/Log.cpp | 3 +- src/Renderer_draw_gl.cpp | 15 +- src/Renderer_init_sdlgl.cpp | 14 +- src/SystemData.cpp | 8 +- src/components/GuiAnimation.cpp | 6 +- src/components/GuiDetectDevice.cpp | 8 +- src/components/GuiFastSelect.cpp | 6 +- src/components/GuiGameList.cpp | 24 +-- src/components/GuiImage.cpp | 4 +- src/components/GuiImage.h | 6 +- src/components/GuiList.cpp | 2 +- src/components/GuiMenu.cpp | 4 +- src/components/GuiTheme.cpp | 26 +-- src/main.cpp | 19 +- src/platform.cpp | 14 ++ src/platform.h | 12 +- 24 files changed, 483 insertions(+), 75 deletions(-) create mode 100644 EmulationStation_vs2010/EmulationStation_vs2010.sln create mode 100644 EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj create mode 100644 EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj.filters create mode 100644 EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props create mode 100644 src/platform.cpp diff --git a/EmulationStation_vs2010/EmulationStation_vs2010.sln b/EmulationStation_vs2010/EmulationStation_vs2010.sln new file mode 100644 index 000000000..2e2783b31 --- /dev/null +++ b/EmulationStation_vs2010/EmulationStation_vs2010.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EmulationStation_vs2010", "EmulationStation_vs2010\EmulationStation_vs2010.vcxproj", "{0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}.Debug|Win32.ActiveCfg = Debug|Win32 + {0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}.Debug|Win32.Build.0 = Debug|Win32 + {0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}.Release|Win32.ActiveCfg = Release|Win32 + {0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj b/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj new file mode 100644 index 000000000..2aa89d26e --- /dev/null +++ b/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj @@ -0,0 +1,126 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3} + EmulationStation_vs2010 + + + + Application + true + MultiByte + + + Application + false + true + MultiByte + + + + + + + + + + + + + + + + + Level3 + Disabled + + + true + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj.filters b/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj.filters new file mode 100644 index 000000000..3e6fba0b0 --- /dev/null +++ b/EmulationStation_vs2010/EmulationStation_vs2010/EmulationStation_vs2010.vcxproj.filters @@ -0,0 +1,192 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {31a8e8d1-9795-42bf-99fd-500e57ac87d4} + + + {bec1ca52-69f2-42eb-b134-57016057661a} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + PugiXML + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + components + + + PugiXML + + + PugiXML + + + \ No newline at end of file diff --git a/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props new file mode 100644 index 000000000..4a5c3779c --- /dev/null +++ b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props @@ -0,0 +1,19 @@ + + + + + + C:\Games\VC++ Includes\freetype-2.3.5-1-bin\include\freetype2;C:\Games\VC++ Includes\SDL_mixer-1.2.12\include;C:\Games\VC++ Includes\FreeImage\Dist;C:\boost_1_53_0;C:\Games\VC++ Includes\SDL-1.2.15\include;$(IncludePath) + C:\Games\VC++ Includes\freetype-2.3.5-1-bin\lib;C:\Games\VC++ Includes\SDL_mixer-1.2.12\lib\x86;C:\Games\VC++ Includes\FreeImage\Dist;C:\boost_1_53_0\stage\lib;C:\Games\VC++ Includes\SDL-1.2.15\lib\x86;$(LibraryPath) + + + + _DESKTOP_;%(PreprocessorDefinitions) + + + SDLmain.lib;SDL.lib;FreeImage.lib;freetype.lib;opengl32.lib;SDL_mixer.lib;%(AdditionalDependencies) + Windows + + + + \ No newline at end of file diff --git a/Makefile.common b/Makefile.common index 11ac458c4..15ec7a98c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -2,7 +2,7 @@ CXX=g++ CXXFLAGS=-Wall -g -O2 LDFLAGS= -SRC_SOURCES=AudioManager.cpp Window.cpp InputConfig.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp Gui.cpp InputManager.cpp main.cpp MathExp.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiInputConfig.cpp components/GuiDetectDevice.cpp pugiXML/pugixml.cpp +SRC_SOURCES=platform.cpp AudioManager.cpp Window.cpp InputConfig.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp Gui.cpp InputManager.cpp main.cpp MathExp.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiInputConfig.cpp components/GuiDetectDevice.cpp pugiXML/pugixml.cpp SOURCES=$(addprefix src/,$(SRC_SOURCES)) OBJECTS=$(SOURCES:.cpp=.o) DEPS=$(SOURCES:.cpp=.d) diff --git a/changelog.txt b/changelog.txt index d078ec685..ae49ec397 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +May 13, 2013 +-Ported to Windows. You'll need to change the lib_paths property sheet Include and Library directories (I didn't include dependencies!). +-Added --windowed (only works for desktop builds). + April 13, 2013 -Finally merged the unstable branch, which means better input everything! -Can now use multiple joysticks. diff --git a/src/Font.cpp b/src/Font.cpp index e5395c3f2..9c19b2476 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -16,10 +16,11 @@ int Font::getSize() { return mSize; } std::string Font::getDefaultPath() { - int fontCount = 3; - std::string fonts[] = {"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf", + const int fontCount = 4; + std::string fonts[fontCount] = { "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf", "/usr/share/fonts/TTF/DejaVuSerif.ttf", - "/usr/share/fonts/dejavu/DejaVuSerif.ttf" }; + "/usr/share/fonts/dejavu/DejaVuSerif.ttf", + "font.ttf" }; for(int i = 0; i < fontCount; i++) { @@ -226,7 +227,7 @@ void Font::drawText(std::string text, int startx, int starty, int color) starty += mMaxGlyphHeight; //padding (another 0.5% is added to the bottom through the sizeText function) - starty += mMaxGlyphHeight * 0.1; + starty += (int)(mMaxGlyphHeight * 0.1f); int pointCount = text.length() * 2; @@ -248,8 +249,8 @@ void Font::drawText(std::string text, int startx, int starty, int color) int p = 0; int i = 0; - float x = startx; - float y = starty; + float x = (float)startx; + float y = (float)starty; for(; p < pointCount; i++, p++) { unsigned char letter = text[i]; @@ -321,10 +322,10 @@ void Font::sizeText(std::string text, int* w, int* h) *w = cwidth; if(h != NULL) - *h = mMaxGlyphHeight + mMaxGlyphHeight * 0.5; + *h = (int)(mMaxGlyphHeight + mMaxGlyphHeight * 0.5f); } int Font::getHeight() { - return mMaxGlyphHeight * 1.5; + return (int)(mMaxGlyphHeight * 1.5f); } diff --git a/src/InputManager.cpp b/src/InputManager.cpp index dcdbf1553..b28341f59 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -4,6 +4,7 @@ #include "Log.h" #include "pugiXML/pugixml.hpp" #include +#include "platform.h" namespace fs = boost::filesystem; @@ -189,7 +190,7 @@ void InputManager::loadConfig() mNumPlayers = 0; - bool configuredDevice[mNumJoysticks]; + bool* configuredDevice = new bool[mNumJoysticks]; for(int i = 0; i < mNumJoysticks; i++) { mInputConfigs[i]->setPlayerNum(-1); @@ -232,6 +233,8 @@ void InputManager::loadConfig() } } + delete[] configuredDevice; + if(mNumPlayers == 0) { LOG(LogInfo) << "No input configs loaded. Loading default keyboard config."; @@ -285,7 +288,7 @@ void InputManager::writeConfig() std::string InputManager::getConfigPath() { - std::string path = getenv("HOME"); + std::string path = getHomePath(); path += "/.emulationstation/es_input.cfg"; return path; } diff --git a/src/Log.cpp b/src/Log.cpp index eaf84eae2..fe3c50c6c 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "platform.h" LogLevel Log::reportingLevel = LogInfo; FILE* Log::file = NULL; //fopen(getLogPath().c_str(), "w"); @@ -13,7 +14,7 @@ LogLevel Log::getReportingLevel() std::string Log::getLogPath() { - std::string home = getenv("HOME"); + std::string home = getHomePath(); return home + "/.emulationstation/es_log.txt"; } diff --git a/src/Renderer_draw_gl.cpp b/src/Renderer_draw_gl.cpp index 0b23fa434..9cdcbba9c 100644 --- a/src/Renderer_draw_gl.cpp +++ b/src/Renderer_draw_gl.cpp @@ -1,5 +1,5 @@ -#include "Renderer.h" #include "platform.h" +#include "Renderer.h" #include GLHEADER #include #include "Font.h" @@ -28,7 +28,7 @@ namespace Renderer { void drawRect(int x, int y, int w, int h, unsigned int color) { - GLfloat points[12]; + GLint points[12]; points[0] = x; points [1] = y; points[2] = x; points[3] = y + h; @@ -46,7 +46,7 @@ namespace Renderer { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, points); + glVertexPointer(2, GL_INT, 0, points); glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -90,7 +90,7 @@ namespace Renderer { return; } - float fontSizes[] = {0.035, 0.045, 0.1}; + float fontSizes[] = {0.035f, 0.045f, 0.1f}; for(unsigned int i = 0; i < 3; i++) { fonts[i] = new Font(fontPath, (unsigned int)(fontSizes[i] * getScreenHeight())); @@ -119,10 +119,9 @@ namespace Renderer { int w, h; font->sizeText(text, &w, &h); - int x = (int)getScreenWidth() - w; - x *= 0.5; - - x += xOffset * 0.5; + int x = getScreenWidth() - w; + x = x / 2; + x += xOffset / 2; drawText(text, x, y, color, font); } diff --git a/src/Renderer_init_sdlgl.cpp b/src/Renderer_init_sdlgl.cpp index ac76d92c1..38f4d03d6 100644 --- a/src/Renderer_init_sdlgl.cpp +++ b/src/Renderer_init_sdlgl.cpp @@ -1,12 +1,20 @@ #include "Renderer.h" #include #include "platform.h" + +#ifdef _WINDOWS_ + #include +#endif + #include GLHEADER + #include "Font.h" -#include +#include #include "InputManager.h" #include "Log.h" +extern bool WINDOWED; + namespace Renderer { unsigned int display_width = 0; @@ -32,7 +40,7 @@ namespace Renderer SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL | SDL_FULLSCREEN | SDL_DOUBLEBUF); + sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL | (WINDOWED ? 0 : SDL_FULLSCREEN) | SDL_DOUBLEBUF); if(sdlScreen == NULL) { @@ -40,6 +48,8 @@ namespace Renderer return false; } + SDL_WM_SetCaption("EmulationStation", NULL); + //usually display width/height are not specified, i.e. zero, which SDL automatically takes as "native resolution" //so, since other things rely on the size of the screen (damn currently unnormalized coordinate system), we set it here //even though the system was already initialized diff --git a/src/SystemData.cpp b/src/SystemData.cpp index ef63adc4a..c4719d5f2 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "Renderer.h" #include "AudioManager.h" #include "Log.h" @@ -30,7 +30,7 @@ SystemData::SystemData(std::string name, std::string descName, std::string start if(startPath[0] == '~') { startPath.erase(0, 1); - std::string home = getenv("HOME"); + std::string home = getHomePath(); startPath.insert(0, home); } @@ -292,7 +292,7 @@ void SystemData::deleteSystems() std::string SystemData::getConfigPath() { - std::string home = getenv("HOME"); + std::string home = getHomePath(); if(home.empty()) { LOG(LogError) << "$HOME environment variable empty or nonexistant!"; @@ -316,7 +316,7 @@ std::string SystemData::getGamelistPath(){ if(fs::exists(filePath)) return filePath; - filePath = getenv("HOME"); + filePath = getHomePath(); filePath += "/.emulationstation/"+ getName() + "/gamelist.xml"; if(fs::exists(filePath)) return filePath; diff --git a/src/components/GuiAnimation.cpp b/src/components/GuiAnimation.cpp index 379bdc08b..1353fb8bb 100644 --- a/src/components/GuiAnimation.cpp +++ b/src/components/GuiAnimation.cpp @@ -33,15 +33,15 @@ void GuiAnimation::fadeOut(int time) void GuiAnimation::update(int deltaTime) { - float mult = deltaTime * 0.05; + float mult = deltaTime * 0.05f; if(mMoveX != 0 || mMoveY != 0) { int offsetx = (mMoveX > mMoveSpeed) ? mMoveSpeed : mMoveX; int offsety = (mMoveY > mMoveSpeed) ? mMoveSpeed : mMoveY; - offsetx *= mult; - offsety *= mult; + offsetx = (int)(offsetx * mult); + offsety = (int)(offsety * mult); moveChildren(offsetx, offsety); diff --git a/src/components/GuiDetectDevice.cpp b/src/components/GuiDetectDevice.cpp index 587a71b13..a46ccf0f4 100644 --- a/src/components/GuiDetectDevice.cpp +++ b/src/components/GuiDetectDevice.cpp @@ -83,17 +83,17 @@ void GuiDetectDevice::render() stream >> playerString; Renderer::drawCenteredText("Press a button on the device for", 0, Renderer::getScreenHeight() / 3, 0x000000FF, font); - Renderer::drawCenteredText("PLAYER " + playerString, 0, (int)(Renderer::getScreenHeight()*1.5) / 3, 0x333333FF, font); + Renderer::drawCenteredText("PLAYER " + playerString, 0, (int)(Renderer::getScreenHeight()*1.5f) / 3, 0x333333FF, font); if(mWindow->getInputManager()->getNumPlayers() > 0) { - Renderer::drawCenteredText("(P1 - hold a button to finish)", 0, (int)(Renderer::getScreenHeight()*2) / 3, (mHoldingFinish ? 0x0000FFFF : 0x000066FF), font); + Renderer::drawCenteredText("(P1 - hold a button to finish)", 0, (Renderer::getScreenHeight()*2) / 3, (mHoldingFinish ? 0x0000FFFF : 0x000066FF), font); } if(mWindow->getInputManager()->getNumJoysticks() == 0) { - Renderer::drawCenteredText("No joysticks detected!", 0, Renderer::getScreenHeight()-(font->getHeight()*2)-10, 0xFF0000FF, font); + Renderer::drawCenteredText("No joysticks detected!", 0, Renderer::getScreenHeight() - (font->getHeight()*2)-10, 0xFF0000FF, font); } - Renderer::drawCenteredText("Press F4 to quit.", 0, Renderer::getScreenHeight()-font->getHeight() - 2 , 0x000000FF, font); + Renderer::drawCenteredText("Press F4 to quit.", 0, Renderer::getScreenHeight() - font->getHeight() - 2 , 0x000000FF, font); } diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index 321edfb40..93735c217 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -24,7 +24,7 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, GuiListsetData(data); mTextColor = textcolor; @@ -41,11 +41,11 @@ void GuiFastSelect::render() unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); if(!mBox->hasBackground()) - Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0FF); + Renderer::drawRect((int)(sw * 0.2f), (int)(sh * 0.2f), (int)(sw * 0.6f), (int)(sh * 0.6f), 0x000FF0FF); mBox->render(); - Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (mFont->getHeight() * 0.5), mTextColor, mFont); + Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, (int)(sh * 0.5f - (mFont->getHeight() * 0.5f)), mTextColor, mFont); } void GuiFastSelect::input(InputConfig* config, Input input) diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index 9389f2aff..ffdebc921 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -17,9 +17,9 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : Gui(window) //Those with smaller displays may prefer the older view. if(mDetailed) { - mList = new GuiList(mWindow, Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX"), Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM)); + mList = new GuiList(mWindow, (int)(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX")), Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM)); - mScreenshot = new GuiImage(mWindow, Renderer::getScreenWidth() * mTheme->getFloat("gameImageOffsetX"), Renderer::getScreenHeight() * mTheme->getFloat("gameImageOffsetY"), "", mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false); + mScreenshot = new GuiImage(mWindow, (int)(Renderer::getScreenWidth() * mTheme->getFloat("gameImageOffsetX")), (int)(Renderer::getScreenHeight() * mTheme->getFloat("gameImageOffsetY")), "", (unsigned int)mTheme->getFloat("gameImageWidth"), (unsigned int)mTheme->getFloat("gameImageHeight"), false); mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY")); mImageAnimation = new GuiAnimation(); @@ -85,7 +85,7 @@ void GuiGameList::render() { //divider if(!mTheme->getBool("hideDividers")) - Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX") - 4, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF); + Renderer::drawRect((int)(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX")) - 4, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF); //if we're not scrolling and we have selected a non-folder if(!mList->isScrolling() && mList->getSelectedObject() && !mList->getSelectedObject()->isFolder()) @@ -94,7 +94,7 @@ void GuiGameList::render() std::string desc = game->getDescription(); if(!desc.empty()) - Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03), mTheme->getColor("description"), mTheme->getDescriptionFont()); + Renderer::drawWrappedText(desc, (int)(Renderer::getScreenWidth() * 0.03), mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, (int)(Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03)), mTheme->getColor("description"), mTheme->getDescriptionFont()); } mScreenshot->render(); @@ -200,7 +200,7 @@ std::string GuiGameList::getThemeFile() { std::string themePath; - themePath = getenv("HOME"); + themePath = getHomePath(); themePath += "/.emulationstation/" + mSystem->getName() + "/theme.xml"; if(boost::filesystem::exists(themePath)) return themePath; @@ -209,7 +209,7 @@ std::string GuiGameList::getThemeFile() if(boost::filesystem::exists(themePath)) return themePath; - themePath = getenv("HOME"); + themePath = getHomePath(); themePath += "/.emulationstation/es_theme.xml"; if(boost::filesystem::exists(themePath)) return themePath; @@ -235,13 +235,13 @@ void GuiGameList::updateTheme() { mList->setCentered(mTheme->getBool("listCentered")); - mList->setOffsetX(mTheme->getFloat("listOffsetX") * Renderer::getScreenWidth()); - mList->setTextOffsetX(mTheme->getFloat("listTextOffsetX") * Renderer::getScreenWidth()); + mList->setOffsetX((int)(mTheme->getFloat("listOffsetX") * Renderer::getScreenWidth())); + mList->setTextOffsetX((int)(mTheme->getFloat("listTextOffsetX") * Renderer::getScreenWidth())); - mScreenshot->setOffsetX(mTheme->getFloat("gameImageOffsetX") * Renderer::getScreenWidth()); - mScreenshot->setOffsetY(mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight()); + mScreenshot->setOffsetX((int)(mTheme->getFloat("gameImageOffsetX") * Renderer::getScreenWidth())); + mScreenshot->setOffsetY((int)(mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight())); mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY")); - mScreenshot->setResize(mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false); + mScreenshot->setResize((int)mTheme->getFloat("gameImageWidth"), (int)mTheme->getFloat("gameImageHeight"), false); } } @@ -252,7 +252,7 @@ void GuiGameList::updateDetailData() if(mList->getSelectedObject() && !mList->getSelectedObject()->isFolder()) { - mScreenshot->setOffset((mTheme->getFloat("gameImageOffsetX") - 0.05) * Renderer::getScreenWidth(), mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight()); + mScreenshot->setOffset((int)((mTheme->getFloat("gameImageOffsetX") - 0.05) * Renderer::getScreenWidth()), (int)(mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight())); if(((GameData*)mList->getSelectedObject())->getImagePath().empty()) mScreenshot->setImage(mTheme->getString("imageNotFoundPath")); diff --git a/src/components/GuiImage.cpp b/src/components/GuiImage.cpp index e8e125163..97a768735 100644 --- a/src/components/GuiImage.cpp +++ b/src/components/GuiImage.cpp @@ -200,9 +200,9 @@ void GuiImage::resize() resizeScaleX = resizeScaleY; if(resizeScaleX) - mDrawWidth *= resizeScaleX; + mDrawWidth = (int)(mDrawWidth * resizeScaleX); if(resizeScaleY) - mDrawHeight *= resizeScaleY; + mDrawHeight = (int)(mDrawHeight * resizeScaleY); } } diff --git a/src/components/GuiImage.h b/src/components/GuiImage.h index ead109b95..9454ce798 100644 --- a/src/components/GuiImage.h +++ b/src/components/GuiImage.h @@ -1,11 +1,13 @@ #ifndef _GUIIMAGE_H_ #define _GUIIMAGE_H_ +#include "../platform.h" +#include GLHEADER + #include "../Gui.h" #include #include -#include "../platform.h" -#include GLHEADER + class GuiImage : public Gui { diff --git a/src/components/GuiList.cpp b/src/components/GuiList.cpp index 112e3fdd3..e2f9a6b61 100644 --- a/src/components/GuiList.cpp +++ b/src/components/GuiList.cpp @@ -42,7 +42,7 @@ void GuiList::render() if((int)mRowVector.size() >= screenCount) { - startEntry = mSelection - (screenCount * 0.5); + startEntry = mSelection - (int)(screenCount * 0.5); if(startEntry < 0) startEntry = 0; if(startEntry >= (int)mRowVector.size() - screenCount) diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp index 17634931a..6bf58319c 100644 --- a/src/components/GuiMenu.cpp +++ b/src/components/GuiMenu.cpp @@ -1,6 +1,6 @@ #include "GuiMenu.h" #include -#include +#include #include "../Log.h" #include "../SystemData.h" #include "GuiGameList.h" @@ -84,6 +84,6 @@ void GuiMenu::update(int deltaTime) void GuiMenu::render() { - Renderer::drawRect(Renderer::getScreenWidth() * 0.25, 0, Renderer::getScreenWidth() * 0.5, Renderer::getScreenHeight(), 0x999999); + Renderer::drawRect(Renderer::getScreenWidth() / 4, 0, Renderer::getScreenWidth() / 2, Renderer::getScreenHeight(), 0x999999); mList->render(); } diff --git a/src/components/GuiTheme.cpp b/src/components/GuiTheme.cpp index 76d4a691a..7a9793ca8 100644 --- a/src/components/GuiTheme.cpp +++ b/src/components/GuiTheme.cpp @@ -97,7 +97,7 @@ void GuiTheme::setDefaults() mBoolMap["listCentered"] = true; mFloatMap["listOffsetX"] = 0.5; - mFloatMap["listTextOffsetX"] = 0.005; + mFloatMap["listTextOffsetX"] = 0.005f; mFloatMap["gameImageOriginX"] = 0.5; mFloatMap["gameImageOriginY"] = 0; mFloatMap["gameImageOffsetX"] = mFloatMap["listOffsetX"] / 2; @@ -204,16 +204,16 @@ void GuiTheme::readXML(std::string path) mColorMap["description"] = resolveColor(root.child("descColor").text().get(), mColorMap["description"]); mColorMap["fastSelect"] = resolveColor(root.child("fastSelectColor").text().get(), mColorMap["fastSelect"]); - mBoolMap["hideHeader"] = root.child("hideHeader"); - mBoolMap["hideDividers"] = root.child("hideDividers"); + mBoolMap["hideHeader"] = root.child("hideHeader") != 0; + mBoolMap["hideDividers"] = root.child("hideDividers") != 0; //GuiBox theming data mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get()); - mBoxData.backgroundTiled = root.child("boxBackgroundTiled"); + mBoxData.backgroundTiled = root.child("boxBackgroundTiled") != 0; mBoxData.horizontalPath = expandPath(root.child("boxHorizontal").text().get()); - mBoxData.horizontalTiled = root.child("boxHorizontalTiled"); + mBoxData.horizontalTiled = root.child("boxHorizontalTiled") != 0; mBoxData.verticalPath = expandPath(root.child("boxVertical").text().get()); - mBoxData.verticalTiled = root.child("boxVerticalTiled"); + mBoxData.verticalTiled = root.child("boxVerticalTiled") != 0; mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get()); //list stuff @@ -288,7 +288,7 @@ Gui* GuiTheme::createElement(pugi::xml_node data, Gui* parent) std::string dim = data.child("dim").text().get(); std::string origin = data.child("origin").text().get(); - bool tiled = data.child("tiled"); + bool tiled = data.child("tiled") != 0; //split position and dimension information std::string posX, posY; @@ -301,10 +301,10 @@ Gui* GuiTheme::createElement(pugi::xml_node data, Gui* parent) splitString(origin, ' ', &originX, &originY); //resolve to pixels from percentages/variables - int x = resolveExp(posX) * Renderer::getScreenWidth(); - int y = resolveExp(posY) * Renderer::getScreenHeight(); - int w = resolveExp(dimW) * Renderer::getScreenWidth(); - int h = resolveExp(dimH) * Renderer::getScreenHeight(); + int x = (int)(resolveExp(posX) * Renderer::getScreenWidth()); + int y = (int)(resolveExp(posY) * Renderer::getScreenHeight()); + int w = (int)(resolveExp(dimW) * Renderer::getScreenWidth()); + int h = (int)(resolveExp(dimH) * Renderer::getScreenHeight()); float ox = strToFloat(originX); float oy = strToFloat(originY); @@ -327,7 +327,7 @@ Gui* GuiTheme::createElement(pugi::xml_node data, Gui* parent) std::string GuiTheme::expandPath(std::string path) { if(path[0] == '~') - path = getenv("HOME") + path.substr(1, path.length() - 1); + path = getHomePath() + path.substr(1, path.length() - 1); else if(path[0] == '.') path = boost::filesystem::path(mPath).parent_path().string() + path.substr(1, path.length() - 1); @@ -344,7 +344,7 @@ float GuiTheme::resolveExp(std::string str, float defaultVal) exp.setExpression(str); //set variables - exp.setVariable("headerHeight", Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / Renderer::getScreenHeight()); + exp.setVariable("headerHeight", (float)(Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / Renderer::getScreenHeight())); exp.setVariable("infoWidth", mFloatMap["listOffsetX"]); return exp.eval(); diff --git a/src/main.cpp b/src/main.cpp index 5e5729bb9..6d0c324ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,12 @@ //EmulationStation, a graphical front-end for ROM browsing. Created by Alec "Aloshi" Lofquist. +#include #include #include "Renderer.h" #include "components/GuiGameList.h" #include "SystemData.h" #include #include "components/GuiDetectDevice.h" -#include #include "AudioManager.h" #include "platform.h" #include "Log.h" @@ -24,6 +24,7 @@ bool IGNOREGAMELIST = false; bool DRAWFRAMERATE = false; bool DONTSHOWEXIT = false; bool DEBUG = false; +bool WINDOWED = false; unsigned int DIMTIME = 30*1000; namespace fs = boost::filesystem; @@ -39,11 +40,11 @@ int main(int argc, char* argv[]) if(strcmp(argv[i], "-w") == 0) { width = atoi(argv[i + 1]); - i++; + i++; //skip the argument value }else if(strcmp(argv[i], "-h") == 0) { height = atoi(argv[i + 1]); - i++; + i++; //skip the argument value }else if(strcmp(argv[i], "--gamelist-only") == 0) { PARSEGAMELISTONLY = true; @@ -63,7 +64,10 @@ int main(int argc, char* argv[]) }else if(strcmp(argv[i], "--dimtime") == 0) { DIMTIME = atoi(argv[i + 1]) * 1000; - i++; + i++; //skip the argument value + }else if(strcmp(argv[i], "--windowed") == 0) + { + WINDOWED = true; }else if(strcmp(argv[i], "--help") == 0) { std::cout << "EmulationStation, a graphical front-end for ROM browsing.\n"; @@ -76,6 +80,11 @@ int main(int argc, char* argv[]) std::cout << "--no-exit don't show the exit option in the menu\n"; std::cout << "--debug even more logging\n"; std::cout << "--dimtime [seconds] time to wait before dimming the screen (default 30, use 0 for never)\n"; + + #ifdef _DESKTOP_ + std::cout << "--windowed not fullscreen\n"; + #endif + std::cout << "--help summon a sentient, angry tuba\n\n"; std::cout << "More information available in README.md.\n"; return 0; @@ -90,7 +99,7 @@ int main(int argc, char* argv[]) bool running = true; //make sure the config directory exists - std::string home = getenv("HOME"); + std::string home = getHomePath(); std::string configDir = home + "/.emulationstation"; if(!fs::exists(configDir)) { diff --git a/src/platform.cpp b/src/platform.cpp new file mode 100644 index 000000000..3f4a03f21 --- /dev/null +++ b/src/platform.cpp @@ -0,0 +1,14 @@ +#include "platform.h" + +std::string getHomePath() +{ + #ifdef _WIN32 + return "C:\\"; + #else + const char* home = getenv("HOME"); + if(home == NULL) + return ""; + else + return home; + #endif +} diff --git a/src/platform.h b/src/platform.h index 7074f61a6..f3b88de12 100644 --- a/src/platform.h +++ b/src/platform.h @@ -2,12 +2,20 @@ //#define _RPI_ //#define _DESKTOP_ - #ifdef _RPI_ #define GLHEADER #endif #ifdef _DESKTOP_ - #define GLHEADER + //why the hell this naming inconsistency exists is well beyond me + #ifdef _WIN32 + #define sleep Sleep + #endif + + #define GLHEADER #endif + +#include + +std::string getHomePath(); \ No newline at end of file