| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
#ifndef FIFE_ENGINESETTINGS_H |
| 23 |
#define FIFE_ENGINESETTINGS_H |
| 24 |
|
| 25 |
// Standard C++ library includes |
| 26 |
#include <vector> |
| 27 |
|
| 28 |
// 3rd party library includes |
| 29 |
|
| 30 |
// FIFE includes |
| 31 |
// These includes are split up in two parts, separated by one empty line |
| 32 |
// First block: files included from the FIFE root src directory |
| 33 |
// Second block: files included from the same folder |
| 34 |
#include "util/base/exception.h" |
| 35 |
#include "video/renderbackend.h" |
| 36 |
|
| 37 |
namespace FIFE { |
| 38 |
class NotSupported; |
| 39 |
|
| 40 |
/** This class defines the engine settings on engine init |
| 41 |
* |
| 42 |
*/ |
| 43 |
class EngineSettings { |
| 44 |
public: |
| 45 |
/** Constructor |
| 46 |
*/ |
| 47 |
EngineSettings(); |
| 48 |
|
| 49 |
/** Destructor |
| 50 |
*/ |
| 51 |
~EngineSettings(); |
| 52 |
|
| 53 |
/** Sets bits per pixel |
| 54 |
* @see getPossibleBitsPerPixel |
| 55 |
*/ |
| 56 |
void setBitsPerPixel(uint8_t bitsperpixel); |
| 57 |
|
| 58 |
/** Gets currently set bits per pixel value |
| 59 |
*/ |
| 60 |
uint8_t getBitsPerPixel() const { |
| 61 |
return m_bitsperpixel; |
| 62 |
} |
| 63 |
|
| 64 |
/** Gets all possible bits per pixel values |
| 65 |
*/ |
| 66 |
std::vector<uint8_t> getPossibleBitsPerPixel() const; |
| 67 |
|
| 68 |
/** Sets fullscreen / windowed mode |
| 69 |
*/ |
| 70 |
void setFullScreen(bool fullscreen) { |
| 71 |
m_fullscreen = fullscreen; |
| 72 |
} |
| 73 |
|
| 74 |
/** True, if set to fullscreen. False = windowed |
| 75 |
*/ |
| 76 |
bool isFullScreen() const { |
| 77 |
return m_fullscreen; |
| 78 |
} |
| 79 |
|
| 80 |
/** Sets refresh rate |
| 81 |
*/ |
| 82 |
void setRefreshRate(uint16_t rate) { |
| 83 |
m_refreshRate = rate; |
| 84 |
} |
| 85 |
|
| 86 |
/** Gets the refresh rate |
| 87 |
*/ |
| 88 |
uint16_t getRefreshRate() const { |
| 89 |
return m_refreshRate; |
| 90 |
} |
| 91 |
|
| 92 |
/** Sets display index, starts with 0 |
| 93 |
*/ |
| 94 |
void setDisplay(uint8_t display) { |
| 95 |
m_displayIndex = display; |
| 96 |
} |
| 97 |
|
| 98 |
/** Gets the display index, starts with 0 |
| 99 |
*/ |
| 100 |
uint8_t getDisplay() const { |
| 101 |
return m_displayIndex; |
| 102 |
} |
| 103 |
|
| 104 |
/** Sets Vsync. Synchronized updates with vertical refresh rate. |
| 105 |
*/ |
| 106 |
void setVSync(bool vsync) { |
| 107 |
m_vSync = vsync; |
| 108 |
} |
| 109 |
|
| 110 |
/** True, if vsync is enable, otherwise false. |
| 111 |
*/ |
| 112 |
bool isVSync() const { |
| 113 |
return m_vSync; |
| 114 |
} |
| 115 |
|
| 116 |
/** Sets the used SDL render driver. Values depends on platform |
| 117 |
* and is useless for the OpenGL backend. |
| 118 |
* If none is set, SDL use the first one that supports the requested flags. |
| 119 |
* @see DeviceCaps::getAvailableRenderDrivers() |
| 120 |
*/ |
| 121 |
void setSDLDriver(const std::string& driver) { |
| 122 |
m_renderDriver = driver; |
| 123 |
} |
| 124 |
|
| 125 |
/** Gets the used SDL render driver. |
| 126 |
* Default is a empty string, that indicates SDL chooses the driver. |
| 127 |
* @see setSDLDriver() |
| 128 |
*/ |
| 129 |
const std::string& getSDLDriver() const { |
| 130 |
return m_renderDriver; |
| 131 |
} |
| 132 |
|
| 133 |
/** Sets initial engine sound volume |
| 134 |
* @see getInitialMaxVolume |
| 135 |
*/ |
| 136 |
void setInitialVolume(float volume); |
| 137 |
|
| 138 |
/** Gets initial engine sound volume |
| 139 |
*/ |
| 140 |
float getInitialVolume() const { |
| 141 |
return m_initialvolume; |
| 142 |
} |
| 143 |
|
| 144 |
/** Gets maximum volume that can be set |
| 145 |
*/ |
| 146 |
float getMaxVolume() const; |
| 147 |
|
| 148 |
/** Sets name for renderbackend |
| 149 |
* @see getPossibleRenderBackends |
| 150 |
*/ |
| 151 |
void setRenderBackend(const std::string& renderbackend); |
| 152 |
|
| 153 |
/** Gets currently set renderbackend name |
| 154 |
*/ |
| 155 |
const std::string& getRenderBackend() const { |
| 156 |
return m_renderbackend; |
| 157 |
} |
| 158 |
|
| 159 |
/** Gets currently set renderbackend name |
| 160 |
*/ |
| 161 |
std::string getRenderBackend() { |
| 162 |
return m_renderbackend; |
| 163 |
} |
| 164 |
|
| 165 |
/** Gets all possible renderbackend names |
| 166 |
*/ |
| 167 |
std::vector<std::string> getPossibleRenderBackends(); |
| 168 |
|
| 169 |
/** Sets if fake alpha is removed in SDL renderbackend |
| 170 |
*/ |
| 171 |
void setSDLRemoveFakeAlpha(bool sdlremovefakealpha); |
| 172 |
|
| 173 |
/** Tells if fake alpha is removed in SDL renderbackend |
| 174 |
*/ |
| 175 |
bool isSDLRemoveFakeAlpha() const { |
| 176 |
return m_sdlremovefakealpha; |
| 177 |
} |
| 178 |
|
| 179 |
/** Sets if images are compress by video driver in OpenGL renderbackend |
| 180 |
*/ |
| 181 |
void setGLCompressImages(bool oglcompressimages); |
| 182 |
|
| 183 |
/** Tells if images are compress by video driver in OpenGL renderbackend |
| 184 |
*/ |
| 185 |
bool isGLCompressImages() const { |
| 186 |
return m_oglcompressimages; |
| 187 |
} |
| 188 |
|
| 189 |
/** Sets if OpenGL renderbackend should use FramebufferObject (when available) |
| 190 |
*/ |
| 191 |
void setGLUseFramebuffer(bool ogluseframebuffer); |
| 192 |
|
| 193 |
/** Tells if OpenGL renderbackend should use FramebufferObject |
| 194 |
*/ |
| 195 |
bool isGLUseFramebuffer() const { |
| 196 |
return m_ogluseframebuffer; |
| 197 |
} |
| 198 |
|
| 199 |
/** Sets if OpenGL renderbackend should use NPOT Textures (when available) |
| 200 |
*/ |
| 201 |
void setGLUseNPOT(bool oglusenpot); |
| 202 |
|
| 203 |
/** Tells if OpenGL renderbackend should use NPOT Textures |
| 204 |
*/ |
| 205 |
bool isGLUseNPOT() const { |
| 206 |
return m_oglusenpot; |
| 207 |
} |
| 208 |
|
| 209 |
/** Sets texture filtering method for OpenGL renderbackend. |
| 210 |
*/ |
| 211 |
void setGLTextureFiltering(TextureFiltering filter); |
| 212 |
|
| 213 |
/** Gets current texture filter which uses OpenGL. |
| 214 |
*/ |
| 215 |
TextureFiltering getGLTextureFiltering() const; |
| 216 |
|
| 217 |
/** Sets if OpenGL renderbackend should use mipmapping. |
| 218 |
*/ |
| 219 |
void setGLUseMipmapping(bool mipmapping); |
| 220 |
|
| 221 |
/** Tells if OpenGL renderbackend should use mipmapping. |
| 222 |
*/ |
| 223 |
bool isGLUseMipmapping() const; |
| 224 |
|
| 225 |
/** Sets if OpenGL renderbackend should render only monochrome. |
| 226 |
*/ |
| 227 |
void setGLUseMonochrome(bool monochrome); |
| 228 |
|
| 229 |
/** Tells if OpenGL renderbackend should render only monochrome. |
| 230 |
*/ |
| 231 |
bool isGLUseMonochrome() const; |
| 232 |
|
| 233 |
/** Sets if OpenGL renderbackend should use depth buffer. |
| 234 |
*/ |
| 235 |
void setGLUseDepthBuffer(bool buffer); |
| 236 |
|
| 237 |
/** Tells if OpenGL renderbackend should use depth buffer. |
| 238 |
*/ |
| 239 |
bool isGLUseDepthBuffer() const; |
| 240 |
|
| 241 |
/** Sets alpha test value for OpenGL renderbackend. |
| 242 |
*/ |
| 243 |
void setGLAlphaTestValue(float alpha); |
| 244 |
|
| 245 |
/** Gets current alpha test value which uses OpenGL. |
| 246 |
*/ |
| 247 |
float getGLAlphaTestValue() const; |
| 248 |
|
| 249 |
/** Sets screen width (pixels) |
| 250 |
*/ |
| 251 |
void setScreenWidth(uint16_t screenwidth); |
| 252 |
|
| 253 |
/** Gets screen width (pixels) |
| 254 |
*/ |
| 255 |
uint16_t getScreenWidth() const { |
| 256 |
return m_screenwidth; |
| 257 |
} |
| 258 |
|
| 259 |
/** Sets screen height (pixels) |
| 260 |
*/ |
| 261 |
void setScreenHeight(uint16_t screenheight); |
| 262 |
|
| 263 |
/** Gets screen height (pixels) |
| 264 |
*/ |
| 265 |
uint16_t getScreenHeight() const { |
| 266 |
return m_screenheight; |
| 267 |
} |
| 268 |
|
| 269 |
/** Sets path for default font |
| 270 |
*/ |
| 271 |
void setDefaultFontPath(const std::string& defaultfontpath); |
| 272 |
|
| 273 |
/** Gets current path for default font |
| 274 |
*/ |
| 275 |
const std::string& getDefaultFontPath() const { |
| 276 |
return m_defaultfontpath; |
| 277 |
} |
| 278 |
|
| 279 |
/** Gets current path for default font |
| 280 |
*/ |
| 281 |
std::string getDefaultFontPath() { |
| 282 |
return m_defaultfontpath; |
| 283 |
} |
| 284 |
|
| 285 |
/** Sets size for default font |
| 286 |
*/ |
| 287 |
void setDefaultFontSize(uint16_t defaultfontsize); |
| 288 |
|
| 289 |
/** Gets size for default font |
| 290 |
*/ |
| 291 |
uint16_t getDefaultFontSize() const { |
| 292 |
return m_defaultfontsize; |
| 293 |
} |
| 294 |
|
| 295 |
/** Sets glyphs for default font |
| 296 |
*/ |
| 297 |
void setDefaultFontGlyphs(const std::string& defaultfontglyphs); |
| 298 |
|
| 299 |
/** Gets current glyphs for default font |
| 300 |
*/ |
| 301 |
const std::string& getDefaultFontGlyphs() const { |
| 302 |
return m_defaultfontglyphs; |
| 303 |
} |
| 304 |
|
| 305 |
/** Gets current glyphs for default font |
| 306 |
*/ |
| 307 |
std::string getDefaultFontGlyphs() { |
| 308 |
return m_defaultfontglyphs; |
| 309 |
} |
| 310 |
|
| 311 |
/** Sets the title of the window |
| 312 |
*/ |
| 313 |
void setWindowTitle(const std::string& title); |
| 314 |
|
| 315 |
/** Gets the current window title |
| 316 |
*/ |
| 317 |
const std::string& getWindowTitle() const { |
| 318 |
return m_windowtitle; |
| 319 |
} |
| 320 |
|
| 321 |
/** Gets the current window title |
| 322 |
*/ |
| 323 |
std::string getWindowTitle() { |
| 324 |
return m_windowtitle; |
| 325 |
} |
| 326 |
|
| 327 |
/** Sets the icon that appears in the window title bar |
| 328 |
*/ |
| 329 |
void setWindowIcon(const std::string& icon); |
| 330 |
|
| 331 |
/** Gets the icon in the window title bar |
| 332 |
*/ |
| 333 |
const std::string& getWindowIcon() const { |
| 334 |
return m_windowicon; |
| 335 |
} |
| 336 |
|
| 337 |
/** Gets the icon in the window title bar |
| 338 |
*/ |
| 339 |
std::string getWindowIcon() { |
| 340 |
return m_windowicon; |
| 341 |
} |
| 342 |
|
| 343 |
/** Sets whether to use the colorkey feature |
| 344 |
*/ |
| 345 |
void setColorKeyEnabled(bool colorkeyenable); |
| 346 |
|
| 347 |
/** Gets whether the colorkey feature is in use |
| 348 |
*/ |
| 349 |
bool isColorKeyEnabled() const; |
| 350 |
|
| 351 |
/** Sets the global colorkey to use for images |
| 352 |
*/ |
| 353 |
void setColorKey(uint8_t r, uint8_t g, uint8_t b); |
| 354 |
|
| 355 |
/** Gets the global colorkey setting |
| 356 |
*/ |
| 357 |
const SDL_Color& getColorKey() const; |
| 358 |
|
| 359 |
/** Sets the video driver. Values depends on platform. |
| 360 |
* If none is set, SDL chooses it. |
| 361 |
* @see DeviceCaps::getAvailableVideoDrivers() |
| 362 |
*/ |
| 363 |
void setVideoDriver(const std::string& driver); |
| 364 |
|
| 365 |
/** Gets the video driver. |
| 366 |
* Default is a empty string. |
| 367 |
* @see setVideoDriver() |
| 368 |
*/ |
| 369 |
const std::string& getVideoDriver() const; |
| 370 |
|
| 371 |
/** Sets the light model |
| 372 |
*/ |
| 373 |
void setLightingModel(uint32_t lighting); |
| 374 |
|
| 375 |
/** Gets the currently set light model |
| 376 |
*/ |
| 377 |
uint32_t getLightingModel() const { |
| 378 |
return m_lighting; |
| 379 |
} |
| 380 |
|
| 381 |
/** Sets whether to use the frame limiter |
| 382 |
*/ |
| 383 |
void setFrameLimitEnabled(bool limited); |
| 384 |
|
| 385 |
/** Gets whether the frame limiter is in use |
| 386 |
*/ |
| 387 |
bool isFrameLimitEnabled() const; |
| 388 |
|
| 389 |
/** Sets the frame limit |
| 390 |
*/ |
| 391 |
void setFrameLimit(uint16_t framelimit); |
| 392 |
|
| 393 |
/** Gets the frame limit |
| 394 |
*/ |
| 395 |
uint16_t getFrameLimit() const; |
| 396 |
|
| 397 |
/** Sets mouse sensitivity |
| 398 |
*/ |
| 399 |
void setMouseSensitivity(float sens); |
| 400 |
|
| 401 |
/** Gets mouse sensitivity |
| 402 |
*/ |
| 403 |
float getMouseSensitivity() const; |
| 404 |
|
| 405 |
/** Sets mouse acceleration |
| 406 |
* if mouse acceleration is enabled, |
| 407 |
* then the mouse sensitivity is used as speed max. |
| 408 |
*/ |
| 409 |
void setMouseAccelerationEnabled(bool acceleration); |
| 410 |
|
| 411 |
/** Returns if mouse acceleration is enabled or not. |
| 412 |
* |
| 413 |
* @return True if mouse acceleration is enabled, false if not. |
| 414 |
*/ |
| 415 |
bool isMouseAccelerationEnabled() const; |
| 416 |
|
| 417 |
/** Enables or disables native image cursor. |
| 418 |
* @see Cursor::setNativeImageCursorEnabled() |
| 419 |
*/ |
| 420 |
void setNativeImageCursorEnabled(bool nativeimagecursor); |
| 421 |
|
| 422 |
/** Returns whether cursors set to an image or an animation are drawn natively. |
| 423 |
* @see Cursor::setNativeImageCursorEnabled() |
| 424 |
*/ |
| 425 |
bool isNativeImageCursorEnabled() const; |
| 426 |
|
| 427 |
/** Enables or disables joystick and gamepad support. |
| 428 |
*/ |
| 429 |
void setJoystickSupport(bool support); |
| 430 |
|
| 431 |
/** Returns whether joystick and gamepad support is enabled or not. |
| 432 |
*/ |
| 433 |
bool isJoystickSupport() const; |
| 434 |
|
| 435 |
private: |
| 436 |
uint8_t m_bitsperpixel; |
| 437 |
bool m_fullscreen; |
| 438 |
uint16_t m_refreshRate; |
| 439 |
uint8_t m_displayIndex; |
| 440 |
bool m_vSync; |
| 441 |
std::string m_renderDriver; |
| 442 |
float m_initialvolume; |
| 443 |
std::string m_renderbackend; |
| 444 |
bool m_sdlremovefakealpha; |
| 445 |
bool m_oglcompressimages; |
| 446 |
bool m_ogluseframebuffer; |
| 447 |
bool m_oglusenpot; |
| 448 |
bool m_oglMipmapping; |
| 449 |
bool m_oglMonochrome; |
| 450 |
TextureFiltering m_oglTextureFilter; |
| 451 |
bool m_oglDepthBuffer; |
| 452 |
float m_alphaTestValue; |
| 453 |
uint16_t m_screenwidth; |
| 454 |
uint16_t m_screenheight; |
| 455 |
std::string m_windowtitle; |
| 456 |
std::string m_windowicon; |
| 457 |
|
| 458 |
|
| 459 |
std::string m_defaultfontpath; |
| 460 |
uint16_t m_defaultfontsize; |
| 461 |
std::string m_defaultfontglyphs; |
| 462 |
bool m_iscolorkeyenabled; |
| 463 |
SDL_Color m_colorkey; |
| 464 |
std::string m_videodriver; |
| 465 |
uint32_t m_lighting; |
| 466 |
bool m_isframelimit; |
| 467 |
uint16_t m_framelimit; |
| 468 |
float m_mousesensitivity; |
| 469 |
bool m_mouseacceleration; |
| 470 |
bool m_nativeimagecursor; |
| 471 |
bool m_joystickSupport; |
| 472 |
}; |
| 473 |
|
| 474 |
}//FIFE |
| 475 |
|
| 476 |
#endif |
| 477 |
|