Ported to Windows.

Added --windowed for desktop builds.
This commit is contained in:
Aloshi 2013-05-13 14:53:28 -05:00
parent 149c1bcbdd
commit ffe573d1d6
24 changed files with 483 additions and 75 deletions

View file

@ -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

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0AB5C397-7B64-4AAD-92AD-E6B72FEDE8C3}</ProjectGuid>
<RootNamespace>EmulationStation_vs2010</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="lib_paths.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="lib_paths.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\AudioManager.cpp" />
<ClCompile Include="..\..\src\components\GuiAnimation.cpp" />
<ClCompile Include="..\..\src\components\GuiBox.cpp" />
<ClCompile Include="..\..\src\components\GuiDetectDevice.cpp" />
<ClCompile Include="..\..\src\components\GuiFastSelect.cpp" />
<ClCompile Include="..\..\src\components\GuiGameList.cpp" />
<ClCompile Include="..\..\src\components\GuiImage.cpp" />
<ClCompile Include="..\..\src\components\GuiInputConfig.cpp" />
<ClCompile Include="..\..\src\components\GuiMenu.cpp" />
<ClCompile Include="..\..\src\components\GuiTheme.cpp" />
<ClCompile Include="..\..\src\FolderData.cpp" />
<ClCompile Include="..\..\src\Font.cpp" />
<ClCompile Include="..\..\src\GameData.cpp" />
<ClCompile Include="..\..\src\Gui.cpp" />
<ClCompile Include="..\..\src\InputConfig.cpp" />
<ClCompile Include="..\..\src\InputManager.cpp" />
<ClCompile Include="..\..\src\Log.cpp" />
<ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\MathExp.cpp" />
<ClCompile Include="..\..\src\platform.cpp" />
<ClCompile Include="..\..\src\pugiXML\pugixml.cpp" />
<ClCompile Include="..\..\src\Renderer_draw_gl.cpp" />
<ClCompile Include="..\..\src\Renderer_init.cpp" />
<ClCompile Include="..\..\src\Sound.cpp" />
<ClCompile Include="..\..\src\SystemData.cpp" />
<ClCompile Include="..\..\src\Window.cpp" />
<ClCompile Include="..\..\src\XMLReader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\AudioManager.h" />
<ClInclude Include="..\..\src\components\GuiAnimation.h" />
<ClInclude Include="..\..\src\components\GuiBox.h" />
<ClInclude Include="..\..\src\components\GuiDetectDevice.h" />
<ClInclude Include="..\..\src\components\GuiFastSelect.h" />
<ClInclude Include="..\..\src\components\GuiGameList.h" />
<ClInclude Include="..\..\src\components\GuiImage.h" />
<ClInclude Include="..\..\src\components\GuiInputConfig.h" />
<ClInclude Include="..\..\src\components\GuiList.h" />
<ClInclude Include="..\..\src\components\GuiMenu.h" />
<ClInclude Include="..\..\src\components\GuiTheme.h" />
<ClInclude Include="..\..\src\FileData.h" />
<ClInclude Include="..\..\src\FolderData.h" />
<ClInclude Include="..\..\src\Font.h" />
<ClInclude Include="..\..\src\GameData.h" />
<ClInclude Include="..\..\src\Gui.h" />
<ClInclude Include="..\..\src\InputConfig.h" />
<ClInclude Include="..\..\src\InputManager.h" />
<ClInclude Include="..\..\src\Log.h" />
<ClInclude Include="..\..\src\MathExp.h" />
<ClInclude Include="..\..\src\platform.h" />
<ClInclude Include="..\..\src\pugiXML\pugiconfig.hpp" />
<ClInclude Include="..\..\src\pugiXML\pugixml.hpp" />
<ClInclude Include="..\..\src\Renderer.h" />
<ClInclude Include="..\..\src\Sound.h" />
<ClInclude Include="..\..\src\SystemData.h" />
<ClInclude Include="..\..\src\Window.h" />
<ClInclude Include="..\..\src\XMLReader.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="components">
<UniqueIdentifier>{31a8e8d1-9795-42bf-99fd-500e57ac87d4}</UniqueIdentifier>
</Filter>
<Filter Include="PugiXML">
<UniqueIdentifier>{bec1ca52-69f2-42eb-b134-57016057661a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\AudioManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\FolderData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Font.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\GameData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Gui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\InputConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\InputManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Log.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\MathExp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Renderer_draw_gl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Renderer_init.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\SystemData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Window.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\XMLReader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiAnimation.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiTheme.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiBox.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiDetectDevice.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiFastSelect.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiGameList.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiImage.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiInputConfig.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\components\GuiMenu.cpp">
<Filter>components</Filter>
</ClCompile>
<ClCompile Include="..\..\src\pugiXML\pugixml.cpp">
<Filter>PugiXML</Filter>
</ClCompile>
<ClCompile Include="..\..\src\platform.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\AudioManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\FileData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\FolderData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Font.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\GameData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Gui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\InputConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\InputManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\MathExp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Renderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\SystemData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Window.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\XMLReader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiTheme.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiAnimation.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiBox.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiDetectDevice.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiFastSelect.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiGameList.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiImage.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiInputConfig.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiList.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\components\GuiMenu.h">
<Filter>components</Filter>
</ClInclude>
<ClInclude Include="..\..\src\pugiXML\pugiconfig.hpp">
<Filter>PugiXML</Filter>
</ClInclude>
<ClInclude Include="..\..\src\pugiXML\pugixml.hpp">
<Filter>PugiXML</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>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)</IncludePath>
<LibraryPath>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)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_DESKTOP_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>SDLmain.lib;SDL.lib;FreeImage.lib;freetype.lib;opengl32.lib;SDL_mixer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View file

@ -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)

View file

@ -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.

View file

@ -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);
}

View file

@ -4,6 +4,7 @@
#include "Log.h"
#include "pugiXML/pugixml.hpp"
#include <boost/filesystem.hpp>
#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;
}

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#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";
}

View file

@ -1,5 +1,5 @@
#include "Renderer.h"
#include "platform.h"
#include "Renderer.h"
#include GLHEADER
#include <iostream>
#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);
}

View file

@ -1,12 +1,20 @@
#include "Renderer.h"
#include <iostream>
#include "platform.h"
#ifdef _WINDOWS_
#include <Windows.h>
#endif
#include GLHEADER
#include "Font.h"
#include <SDL/SDL.h>
#include <SDL.h>
#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

View file

@ -4,7 +4,7 @@
#include <boost/filesystem.hpp>
#include <fstream>
#include <stdlib.h>
#include <SDL/SDL_joystick.h>
#include <SDL_joystick.h>
#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;

View file

@ -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);

View file

@ -83,11 +83,11 @@ 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)

View file

@ -24,7 +24,7 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, GuiList<FileDa
mScrollOffset = 0;
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
mBox = new GuiBox(window, sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6);
mBox = new GuiBox(window, (int)(sw * 0.2f), (int)(sh * 0.2f), (int)(sw * 0.6f), (int)(sh * 0.6f));
mBox->setData(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)

View file

@ -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<FileData*>(mWindow, Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX"), Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
mList = new GuiList<FileData*>(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"));

View file

@ -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);
}
}

View file

@ -1,11 +1,13 @@
#ifndef _GUIIMAGE_H_
#define _GUIIMAGE_H_
#include "../platform.h"
#include GLHEADER
#include "../Gui.h"
#include <string>
#include <FreeImage.h>
#include "../platform.h"
#include GLHEADER
class GuiImage : public Gui
{

View file

@ -42,7 +42,7 @@ void GuiList<listType>::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)

View file

@ -1,6 +1,6 @@
#include "GuiMenu.h"
#include <iostream>
#include <SDL/SDL.h>
#include <SDL.h>
#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();
}

View file

@ -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();

View file

@ -1,12 +1,12 @@
//EmulationStation, a graphical front-end for ROM browsing. Created by Alec "Aloshi" Lofquist.
#include <SDL.h>
#include <iostream>
#include "Renderer.h"
#include "components/GuiGameList.h"
#include "SystemData.h"
#include <boost/filesystem.hpp>
#include "components/GuiDetectDevice.h"
#include <SDL.h>
#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))
{

14
src/platform.cpp Normal file
View file

@ -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
}

View file

@ -2,12 +2,20 @@
//#define _RPI_
//#define _DESKTOP_
#ifdef _RPI_
#define GLHEADER <GLES/gl.h>
#endif
#ifdef _DESKTOP_
#define GLHEADER <GL/gl.h>
//why the hell this naming inconsistency exists is well beyond me
#ifdef _WIN32
#define sleep Sleep
#endif
#define GLHEADER <SDL_opengl.h>
#endif
#include <string>
std::string getHomePath();