33 #include "util/base/exception.h"
35 #include "enginesettings.h"
38 const float MAXIMUM_VOLUME = 10.0;
43 m_initialvolume(MAXIMUM_VOLUME / 2),
44 m_renderbackend(
"SDL"),
45 m_sdlremovefakealpha(false),
48 m_windowtitle(
"FIFE"),
50 m_defaultfontpath(
""),
52 m_defaultfontglyphs(
""),
53 m_iscolorkeyenabled(false),
59 #if defined( __unix__ )
60 m_videodriver =
"x11";
61 #elif defined( WIN32 )
62 m_videodriver =
"windib";
63 #elif defined( __APPLE_CC__ )
64 m_videodriver =
"x11";
75 if (m_defaultfontpath ==
"") {
76 throw NotSet(
"Path for default font is not set");
78 std::string::size_type loc = m_defaultfontpath.find(
".ttf", 0);
79 if ((loc == std::string::npos) && (m_defaultfontglyphs ==
"")) {
80 throw NotSet(
"Glyphs for default font are not set");
85 SDL_Rect **modes = SDL_ListModes(NULL, ((
getRenderBackend() !=
"SDL") ? (SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL) : 0) | (
isFullScreen() ? SDL_FULLSCREEN : 0));
86 if(modes == (SDL_Rect **)0)
87 throw NotFound(
"No VideoMode Found");
89 std::vector<std::pair<uint16_t, uint16_t> > result;
90 if(modes != (SDL_Rect **)-1)
91 for(
unsigned int i = 0; modes[i]; ++i)
92 result.push_back(std::pair<uint16_t, uint16_t>(modes[i]->w, modes[i]->h));
98 std::vector<uint16_t>::iterator i = std::find(pv.begin(), pv.end(), bitsperpixel);
100 m_bitsperpixel = bitsperpixel;
103 throw NotSupported(
"Given bits per pixel value is not supported");
107 std::vector<uint16_t> tmp;
117 throw NotSupported(
"Given volume exceeds maximum volume");
120 throw NotSupported(
"Given volume is below 0");
122 m_initialvolume = volume;
126 return MAXIMUM_VOLUME;
131 std::vector<std::string>::iterator i = std::find(pv.begin(), pv.end(), renderbackend);
133 m_renderbackend = renderbackend;
136 throw NotSupported(
"Given render backend is not supported");
140 std::vector<std::string> tmp;
141 tmp.push_back(
"SDL");
142 tmp.push_back(
"OpenGL");
147 m_sdlremovefakealpha = sdlremovefakealpha;
151 m_screenwidth = screenwidth;
155 m_screenheight = screenheight;
159 m_defaultfontpath = defaultfontpath;
163 m_defaultfontsize = defaultfontsize;
167 m_defaultfontglyphs = defaultfontglyphs;
171 m_windowtitle = title;
179 m_iscolorkeyenabled = colorkeyenable;
183 return m_iscolorkeyenabled;
196 void EngineSettings::setVideoDriver(
const std::string& driver) {
197 m_videodriver = driver;
200 const std::string& EngineSettings::getVideoDriver()
const {
201 return m_videodriver;
205 m_lighting = lighting;
208 throw NotSupported(
"Given light model is not supported");