Mercurial > fife-parpg
comparison engine/core/controller/enginesettings.cpp @ 632:a7909cdcdc85
* A little data type cleanup in the FIFE::EngineSettings class
* Added some standard integer definitions
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 05 Oct 2010 19:42:54 +0000 |
parents | 356634098bd9 |
children | 855ad500f991 |
comparison
equal
deleted
inserted
replaced
631:f3457443c95f | 632:a7909cdcdc85 |
---|---|
1 /*************************************************************************** | 1 /*************************************************************************** |
2 * Copyright (C) 2005-2008 by the FIFE team * | 2 * Copyright (C) 2005-2010 by the FIFE team * |
3 * http://www.fifengine.de * | 3 * http://www.fifengine.net * |
4 * This file is part of FIFE. * | 4 * This file is part of FIFE. * |
5 * * | 5 * * |
6 * FIFE is free software; you can redistribute it and/or * | 6 * FIFE is free software; you can redistribute it and/or * |
7 * modify it under the terms of the GNU Lesser General Public * | 7 * modify it under the terms of the GNU Lesser General Public * |
8 * License as published by the Free Software Foundation; either * | 8 * License as published by the Free Software Foundation; either * |
67 if ((loc == std::string::npos) && (m_defaultfontglyphs == "")) { | 67 if ((loc == std::string::npos) && (m_defaultfontglyphs == "")) { |
68 throw NotSet("Glyphs for default font are not set"); | 68 throw NotSet("Glyphs for default font are not set"); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 std::vector<std::pair<unsigned int, unsigned int> > EngineSettings::getPossibleResolutions() const { | 72 std::vector<std::pair<uint16_t, uint16_t> > EngineSettings::getPossibleResolutions() const { |
73 SDL_Rect **modes = SDL_ListModes(NULL, ((getRenderBackend() != "SDL") ? (SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL) : 0) | (isFullScreen() ? SDL_FULLSCREEN : 0)); | 73 SDL_Rect **modes = SDL_ListModes(NULL, ((getRenderBackend() != "SDL") ? (SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL) : 0) | (isFullScreen() ? SDL_FULLSCREEN : 0)); |
74 if(modes == (SDL_Rect **)0) | 74 if(modes == (SDL_Rect **)0) |
75 throw NotFound("No VideoMode Found"); | 75 throw NotFound("No VideoMode Found"); |
76 | 76 |
77 std::vector<std::pair<unsigned int, unsigned int> > result; | 77 std::vector<std::pair<uint16_t, uint16_t> > result; |
78 if(modes != (SDL_Rect **)-1) | 78 if(modes != (SDL_Rect **)-1) |
79 for(unsigned int i = 0; modes[i]; ++i) | 79 for(unsigned int i = 0; modes[i]; ++i) |
80 result.push_back(std::pair<unsigned int, unsigned int>(modes[i]->w, modes[i]->h)); | 80 result.push_back(std::pair<uint16_t, uint16_t>(modes[i]->w, modes[i]->h)); |
81 return result; | 81 return result; |
82 } | 82 } |
83 | 83 |
84 void EngineSettings::setBitsPerPixel(unsigned int bitsperpixel) { | 84 void EngineSettings::setBitsPerPixel(uint8_t bitsperpixel) { |
85 std::vector<unsigned int> pv = getPossibleBitsPerPixel(); | 85 std::vector<uint8_t> pv = getPossibleBitsPerPixel(); |
86 std::vector<unsigned int>::iterator i = std::find(pv.begin(), pv.end(), bitsperpixel); | 86 std::vector<uint8_t>::iterator i = std::find(pv.begin(), pv.end(), bitsperpixel); |
87 if (i != pv.end()) { | 87 if (i != pv.end()) { |
88 m_bitsperpixel = bitsperpixel; | 88 m_bitsperpixel = bitsperpixel; |
89 return; | 89 return; |
90 } | 90 } |
91 throw NotSupported("Given bits per pixel value is not supported"); | 91 throw NotSupported("Given bits per pixel value is not supported"); |
92 } | 92 } |
93 | 93 |
94 std::vector<unsigned int> EngineSettings::getPossibleBitsPerPixel() const { | 94 std::vector<uint8_t> EngineSettings::getPossibleBitsPerPixel() const { |
95 std::vector<unsigned int> tmp; | 95 std::vector<uint8_t> tmp; |
96 tmp.push_back(0); | 96 tmp.push_back(0); |
97 tmp.push_back(16); | 97 tmp.push_back(16); |
98 tmp.push_back(24); | 98 tmp.push_back(24); |
99 tmp.push_back(32); | 99 tmp.push_back(32); |
100 return tmp; | 100 return tmp; |
133 | 133 |
134 void EngineSettings::setSDLRemoveFakeAlpha(bool sdlremovefakealpha) { | 134 void EngineSettings::setSDLRemoveFakeAlpha(bool sdlremovefakealpha) { |
135 m_sdlremovefakealpha = sdlremovefakealpha; | 135 m_sdlremovefakealpha = sdlremovefakealpha; |
136 } | 136 } |
137 | 137 |
138 void EngineSettings::setScreenWidth(unsigned int screenwidth) { | 138 void EngineSettings::setScreenWidth(uint16_t screenwidth) { |
139 m_screenwidth = screenwidth; | 139 m_screenwidth = screenwidth; |
140 } | 140 } |
141 | 141 |
142 void EngineSettings::setScreenHeight(unsigned int screenheight) { | 142 void EngineSettings::setScreenHeight(uint16_t screenheight) { |
143 m_screenheight = screenheight; | 143 m_screenheight = screenheight; |
144 } | 144 } |
145 | 145 |
146 void EngineSettings::setDefaultFontPath(const std::string& defaultfontpath) { | 146 void EngineSettings::setDefaultFontPath(const std::string& defaultfontpath) { |
147 m_defaultfontpath = defaultfontpath; | 147 m_defaultfontpath = defaultfontpath; |
148 } | 148 } |
149 | 149 |
150 void EngineSettings::setDefaultFontSize(const unsigned int defaultfontsize) { | 150 void EngineSettings::setDefaultFontSize(uint16_t defaultfontsize) { |
151 m_defaultfontsize = defaultfontsize; | 151 m_defaultfontsize = defaultfontsize; |
152 } | 152 } |
153 | 153 |
154 void EngineSettings::setDefaultFontGlyphs(const std::string& defaultfontglyphs) { | 154 void EngineSettings::setDefaultFontGlyphs(const std::string& defaultfontglyphs) { |
155 m_defaultfontglyphs = defaultfontglyphs; | 155 m_defaultfontglyphs = defaultfontglyphs; |
169 | 169 |
170 bool EngineSettings::isColorKeyEnabled() const { | 170 bool EngineSettings::isColorKeyEnabled() const { |
171 return m_iscolorkeyenabled; | 171 return m_iscolorkeyenabled; |
172 } | 172 } |
173 | 173 |
174 void EngineSettings::setColorKey(Uint8 r, Uint8 g, Uint8 b) { | 174 void EngineSettings::setColorKey(uint8_t r, uint8_t g, uint8_t b) { |
175 m_colorkey.r = r; | 175 m_colorkey.r = r; |
176 m_colorkey.g = g; | 176 m_colorkey.g = g; |
177 m_colorkey.b = b; | 177 m_colorkey.b = b; |
178 } | 178 } |
179 | 179 |