00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <graph/OptionsDisplay.h>
00022 #include <common/Defines.h>
00023 #include <stdio.h>
00024
00025
00026
00027 static OptionEntryEnum::EnumEntry accessorySortKeyEnum[] =
00028 {
00029 { "SortNothing", 0 },
00030 { "SortName", 1 },
00031 { "SortPrice", 2 },
00032 { "", -1 }
00033 };
00034
00035 OptionsDisplay *OptionsDisplay::instance_ = 0;
00036
00037 OptionsDisplay *OptionsDisplay::instance()
00038 {
00039 if (!instance_)
00040 {
00041 instance_ = new OptionsDisplay;
00042 }
00043
00044 return instance_;
00045 }
00046
00047 OptionsDisplay::OptionsDisplay() :
00048 detailTexture_(options_, "DetailTexture",
00049 "Use detail textures on the landscape."
00050 "Adds the texture seen when very close to the landscape."
00051 "Requires multi-texturing", RWAccess, true),
00052 hideFinalScore_(options_, "HideFinalScore",
00053 "Hide the score dialog that is automatically shown after shots", RWAccess | NoRestore, false),
00054 depricatedUniqueUserId_(options_, "UniqueUserId",
00055 "The unique string given by this client to any servers to uniquely identify itself."
00056 "Used for server stats and logging (confidentially)", RAccess | OptionEntry::DataDepricated | NoRestore, ""),
00057 hostDescription_(options_, "HostDescription",
00058 "The description of this host given to any servers for stats.", RAccess | NoRestore, ""),
00059 onlineUserIcon_(options_, "OnlineUserIcon",
00060 "The players icon, must be PNG 32x32 and less than 5000 bytes by default.", RAccess | NoRestore, ""),
00061 buyTab_(options_, "BuyTab",
00062 "The default buy tab", RWAccess | NoRestore, ""),
00063 depricatedRoamVarianceStart_(options_, "RoamVarianceStart",
00064 "The minimum variance to allow", RWAccess | OptionEntry::DataDepricated, 2),
00065 depricatedRoamVarianceRamp_(options_, "RoamVarianceRamp",
00066 "The variance ramping for each distance unit", RWAccess | OptionEntry::DataDepricated, 10),
00067 depricatedRoamVarianceTank_(options_, "RoamVarianceTank",
00068 "The variance difference for ROAM areas with tanks on them", RWAccess | OptionEntry::DataDepricated, 50),
00069 onlineUserName_(options_, "OnlineUserName",
00070 "The player name that will be used for all online games.", RAccess | NoRestore, "Player"),
00071 onlineTankModel_(options_, "OnlineTankModel",
00072 "The tank model that will be used for all online games.", RAccess | NoRestore, ""),
00073 onlineColor_(options_, "OnlineColor",
00074 "The tank color that will be used for all online (non-team) games.", RAccess | NoRestore, Vector::getNullVector(), true),
00075 explosionParts_(options_, "ExplosionParts",
00076 "How many explosion clouds are drawn", RAccess, 8, 0, 10, 1),
00077 explosionSubParts_(options_, "ExplosionSubParts",
00078 "How many explosion sub clouds are drawn", RAccess, 4, 0, 5, 1),
00079 dialogSize_(options_, "DialogSize",
00080 "How large the on screen dialogs and menus are.", RAccess, 2, 0, 3, 1),
00081 tankModelSize_(options_, "TankModelSize",
00082 "The percentage size of the tank models", RWAccess, 100),
00083 depricatedMaxModelTriPercentage_(options_, "MaxModelTriPercentage",
00084 "", RAccess | OptionEntry::DataDepricated, 100, 50, 100, 1),
00085 explosionParticleMult_(options_, "ExplosionParticleMult",
00086 "The number of particles that each explosion will create (relative to explosion size)", RAccess, 20, 0, 100, 10),
00087 depricatedDayTime_(options_, "DayTime",
00088 "", RWAccess | OptionEntry::DataDepricated, 2),
00089 depricatedSunXYAng_(options_, "SunXYAng",
00090 "", RAccess | OptionEntry::DataDepricated, 110),
00091 depricatedSunYZAng_(options_, "SunYZAng",
00092 "", RAccess | OptionEntry::DataDepricated, 25),
00093 toolTipTime_(options_, "ToolTipTime",
00094 "The milliseconds before showing a tool tip.", RWAccess, 100),
00095 toolTipSpeed_(options_, "ToolTipSpeed",
00096 "The speed at which a tool tip will fade in.", RWAccess, 6),
00097 framesPerSecondLimit_(options_, "FramesPerSecondLimit",
00098 "The maximum frame rate that the game will run at", RWAccess, 250),
00099 brightness_(options_, "Brightness",
00100 "The game screen brightness (gamma).", RAccess, 10, 3, 40, 1),
00101 fullScreen_(options_, "FullScreen",
00102 "Run the game in a full screen mode.", RAccess | NoRestore, (S3D::getOSDesc() == "Windows")),
00103 moreRes_(options_, "MoreRes",
00104 "Show more screen resolutions in the drop down. By default only hardware supported modes are shown.", RAccess, false),
00105 depricatedFullClear_(options_, "FullClear",
00106 "Completely clear the screen before drawing each frame", RWAccess | OptionEntry::DataDepricated, true),
00107 invertElevation_(options_, "InvertUpDownKeys",
00108 "Invert/reverse the tanks up/down elevation directions.", RWAccess | NoRestore, false),
00109 invertMouse_(options_, "InvertMouse",
00110 "Invert/reverse the mouses y-axis when rotating camera.", RWAccess | NoRestore, false),
00111 saveWindowPositions_(options_, "SaveWindowPositions",
00112 "Save the positions of all the onscreen windows.", RWAccess | NoRestore, true),
00113 swapYAxis_(options_, "SwapYAxis",
00114 "Remaps mouse pointer from top of window to the bottom and vice-versa (MAC/OSX)", RWAccess | NoRestore, false),
00115 sideScroll_(options_, "SideScroll",
00116 "Allows the user to scroll the viewport moving the mouse to the sides of the screen", RWAccess | NoRestore, true),
00117 storePlayerCamera_(options_, "StorePlayerCamera",
00118 "Stores the camera position for each player and resets to that position on thier turn", RWAccess | NoRestore, false),
00119 drawPlayerNames_(options_, "DrawPlayerNames",
00120 "Draw the names above the tanks", RWAccess, true),
00121 drawPlayerIcons_(options_, "DrawPlayerIcons",
00122 "Draw the icons above the tanks", RWAccess, true),
00123 smoothLines_(options_, "SmoothLines",
00124 "Smooth/AA the dialog lines", RWAccess, true),
00125 drawPlayerSight_(options_, "DrawPlayerSight",
00126 "Draw the aiming sight infront of the tanks", RWAccess, true),
00127 depricatedDrawDistance_(options_, "DrawDistance",
00128 "The distance at which objects will be culled", OptionEntry::DataDepricated, 160.0f),
00129 depricatedDrawDistanceFade_(options_, "DrawDistanceFade",
00130 "The distance before the draw distance at which objects will be faded", OptionEntry::DataDepricated, 100.0f),
00131 drawCullingDistance_(options_, "DrawCullingDistance",
00132 "The distance at which objects will be culled", RWAccess, 200.0f),
00133 drawFadeStartDistance_(options_, "DrawFadeStartDistance",
00134 "The distance before the draw distance at which objects will be faded", RWAccess, 180.0f),
00135 oldSightPosition_(options_, "OldSightPosition",
00136 "Draw the aiming sight aligned with the model and not the shot", RWAccess, false),
00137 drawPlayerColor_(options_, "DrawPlayerColor",
00138 "Draw the player color triangle over the tank", RWAccess, true),
00139 drawPlayerHealth_(options_, "DrawPlayerHealth",
00140 "Draw the health bars above the tank", RWAccess, true),
00141 depricatedFirstTimePlayed_(options_, "FirstTimePlayed",
00142 "Is this the first time the user has played Scorched3D", OptionEntry::DataDepricated, true),
00143 lastVersionPlayed_(options_, "LastVersionPlayed",
00144 "What was the last version of scorched3d played", RWAccess | NoRestore, ""),
00145 hideMenus_(options_, "HideMenus",
00146 "Should the menu title bars always be visible", RWAccess, false),
00147 noGLTexSubImage_(options_, "NoGLTexSubImage",
00148 "Do not use texture area replacing. Required to be able to scorch the ground.", RAccess, false),
00149 noGLShaders_(options_, "NoGLShaders",
00150 "Do not use shaders.", RAccess, false),
00151 simpleWaterShaders_(options_, "SimpleWaterShaders",
00152 "Use simple shaders for the water.", RAccess, false),
00153 noPlanDraw_(options_, "NoPlanDraw",
00154 "Do not show any drawings from other players on the plan window.", RWAccess, false),
00155 noFog_(options_, "NoFog",
00156 "Do not use any fog extensions.", RWAccess, false),
00157 noGLExt_(options_, "NoGLExt",
00158 "Do not use any OpenGL extensions. Turn off to disable any extra OpenGL features.", RAccess, false),
00159 noGLMultiTex_(options_, "NoGLMultiTex",
00160 "Only use one texture for all models and the landscape.", RAccess, false),
00161 depricatedNoGLCompiledArrays_(options_, "NoGLCompiledArrays",
00162 "Do not compile vertex arrays.", OptionEntry::DataDepricated, false),
00163 noThreadedDraw_(options_, "NoThreadedDraw",
00164 "Don't calculate landscape in another thread", RWAccess, false),
00165 noGLEnvCombine_(options_, "NoGLEnvCombine",
00166 "Only use one texture on the landscape.", RAccess, false),
00167 noGLCubeMap_(options_, "NoGLCubeMap",
00168 "Draw the water without using cubemap relfections.", RAccess, false),
00169 noGLSphereMap_(options_, "NoGLSphereMap",
00170 "Draw the water without using sphere map relfections.", RAccess, false),
00171 noGLDrawElements_(options_, "NoGLDrawElements",
00172 "Draw grids without using draw elements.", RWAccess, false),
00173 noGLHardwareMipmaps_(options_, "NoGLHardwareMipmaps",
00174 "Generate texture LOD in software only.", RAccess, false),
00175 soundChannels_(options_, "SoundChannels",
00176 "Number of sound channels to mix.", RAccess, 8),
00177 noSound_(options_, "NoSound",
00178 "Do not play any sound.", RWAccess, false),
00179 noMusic_(options_, "NoMusic",
00180 "Do not play any music.", RWAccess, false),
00181 noProgressBackdrop_(options_, "NoProgressBackdrop",
00182 "Do capture a screen shot and use it as the progress backdrop", RWAccess, false),
00183 noArenaMoveVisibility_(options_, "NoArenaMoveVisibility",
00184 "Do not show the arena area when moving the viewport", RWAccess, false),
00185 depricatedNoAmbientSound_(options_, "NoAmbientSound",
00186 "Do not play any ambient sounds.", OptionEntry::DataDepricated, false),
00187 depricatedNoBoidSound_(options_, "NoBoidSound",
00188 "Do not play any sounds from boids.", OptionEntry::DataDepricated, false),
00189 noShadows_(options_, "NoShadows",
00190 "Do not draw real-time shadows.", RWAccess, false),
00191 noGLShadows_(options_, "NoGLShadows",
00192 "Do not draw GL shadow map shadows.", RAccess, false),
00193 noGLObjectShadows_(options_, "NoGLObjectShadows",
00194 "Do not draw GL shadow map shadows for objects (trees/tanks).", RWAccess, true),
00195 noSimulateParticles_(options_, "NoParticleSimulate",
00196 "Do not use custom simulations for the particles.", RWAccess, false),
00197 noDrawParticles_(options_, "NoParticleDraw",
00198 "Do not draw any particles.", RWAccess, false),
00199 noTrees_(options_, "NoTrees",
00200 "Do not draw any trees", RWAccess, false),
00201 lowTreeDetail_(options_, "LowTreeDetail",
00202 "Only use low detail trees. Faster.", RWAccess, false),
00203 depricatedNoWaves_(options_, "NoWaves",
00204 "Do not draw the moving shore waves.", OptionEntry::DataDepricated, false),
00205 noDepthSorting_(options_, "NoDepthSorting",
00206 "Do not depth sort sprites.", RWAccess, false),
00207 clientLogToFile_(options_, "ClientLogToFile",
00208 "Client logs to file", RAccess, false),
00209 clientLogState_(options_, "ClientLogState",
00210 "Client logs state (0 is off)", RAccess, 0),
00211 validateServerIp_(options_, "ValidateServerIp",
00212 "Checks if the server ip address matches the published address", RAccess, true),
00213 drawLines_(options_, "DrawLines",
00214 "Do not fill in the landscape", DebugOnly | RWAccess, false),
00215 drawLandLOD_(options_, "DrawLandLOD",
00216 "Show the LOD levels and indices of the land patches", DebugOnly | RWAccess, false),
00217 drawNormals_(options_, "DrawNormals",
00218 "Show landscape normals on the landscape", RWAccess, false),
00219 drawGraphicalShadowMap_(options_, "DrawGraphicalShadowMap",
00220 "Shows the depth map used for shadowing", RWAccess, false),
00221 drawGraphicalReflectionMap_(options_, "DrawGraphicalReflectionMap",
00222 "Shows the reflection map used for water reflections", RWAccess, false),
00223 drawCollisionGeoms_(options_, "DrawCollisionGeoms",
00224 "Show object collision geoms", DebugOnly | RWAccess, false),
00225 drawCollisionSpace_(options_, "DrawCollisionSpace",
00226 "Show object collision space", DebugOnly | RWAccess, false),
00227 drawBoundingSpheres_(options_, "DrawBoundingSpheres",
00228 "Show landscape bounding spheres on the landscape", DebugOnly | RWAccess, false),
00229 depricatedDrawShipPaths_(options_, "DrawShipPaths",
00230 "Show paths for the ships", OptionEntry::DataDepricated, false),
00231 frameTimer_(options_, "FrameTimer",
00232 "Show the current number of frames per second (FPS)", RWAccess | NoRestore, false),
00233 noSkins_(options_,"NoTankSkins",
00234 "Do not texture the tank models.", RAccess, false),
00235 drawWater_(options_,"DrawWater",
00236 "Draw the water", RWAccess, true),
00237 drawLandscape_(options_, "DrawLandscape",
00238 "Draw the landscape", DebugOnly | RWAccess, true),
00239 drawSurround_(options_, "DrawSurround",
00240 "Draw the surround", RWAccess, true),
00241 drawMovement_(options_, "DrawMovement",
00242 "Draw the movement paths", DebugOnly | RWAccess, false),
00243 noWaterMovement_(options_, "NoWaterMovement",
00244 "Draw simpler less detailed water", RWAccess, false),
00245 noWaterReflections_(options_, "NoWaterReflections",
00246 "Draw reflections in the water", RWAccess, false),
00247 noWaterWaves_(options_, "NoWaterWaves",
00248 "Draw water waves (breakers)", RWAccess, false),
00249 noWaterLOD_(options_, "NoWaterLOD",
00250 "Draw water at minimum detail", RWAccess, false),
00251 noLandLOD_(options_, "NoLandLOD",
00252 "Draw water at MAXIMUM detail", RWAccess, false),
00253 noSkyLayers_(options_, "NoSkyLayers",
00254 "Only draw one sky layer.", RWAccess, false),
00255 noSkyMovement_(options_, "NoSkyMovement",
00256 "Do not animate the sky", RWAccess, false),
00257 depricatedNoROAM_(options_, "NoROAM",
00258 "Do not use ROAM algorithm", RWAccess | OptionEntry::DataDepricated, false),
00259 depricatedNoBOIDS_(options_,"NoBOIDS",
00260 "Do not use BOIDS", OptionEntry::DataDepricated, false),
00261 depricatedNoShips_(options_,"NoShips",
00262 "Do not use ships", OptionEntry::DataDepricated, false),
00263 noPrecipitation_(options_, "NoPrecipitation",
00264 "Do not draw precipitation", RWAccess, false),
00265 depricatedNoTessalation_(options_,"NoTessalation",
00266 "Do not use ROAM tessalation algorithm", OptionEntry::DataDepricated, false),
00267 noVBO_(options_,"NoVBO",
00268 "Do not use Vertex Buffer Objects (if avaialable)", RWAccess, false),
00269 depricatedMoWaterBuffers_(options_, "NoWaterBuffers",
00270 "Do not use Vertex Buffers for water (if avaialable)", RAccess | OptionEntry::DataDepricated, false),
00271 depricatedNoCg_(options_,"NoCg",
00272 "Do not use vertex or pixel shaders (if avaialable)", RWAccess | OptionEntry::DataDepricated, true),
00273 noModelLOD_(options_, "NoModelLOD",
00274 "Do not use LOD optimizations for models", RWAccess, true),
00275 noModelLighting_(options_, "NoModelLighting",
00276 "Do not use dynamic lighting calculations for models", RWAccess, false),
00277 useLandscapeTexture_(options_, "LandscapeTexture",
00278 "Texture the landscape", RWAccess, true),
00279 useWaterTexture_(options_, "WaterTexture",
00280 "Texture the water", RWAccess, true),
00281 noLenseFlare_(options_,"NoLenseFlare",
00282 "Do not show the full lense flare effect", RWAccess, true),
00283 softwareMouse_(options_,"SoftwareMouse",
00284 "Use a software mouse pointer. Useful if mouse clicks are not aligned.", RWAccess, false),
00285 depricatedUseHex_(options_,"UseHexidecimal",
00286 "Show the tank angles and amounts in hex", RWAccess | OptionEntry::DataDepricated, false),
00287 soundVolume_(options_, "SoundVolume",
00288 "The master volume. Max = 128, Min = 0", RAccess | NoRestore, 128, 0, 128, 1),
00289 ambientSoundVolume_(options_, "AmbientSoundVolume",
00290 "The ambient sound effect volume. Max = 128, Min = 0", RAccess | NoRestore, 128, 0, 128, 1),
00291 musicVolume_(options_, "MusicVolume",
00292 "The music effect volume. Max = 128, Min = 0", RAccess | NoRestore, 128, 0, 128, 1),
00293 antiAlias_(options_, "AntiAlias",
00294 "Use anti aliasing", RAccess, 0, 0, 4, 1),
00295 texSize_(options_, "TexureSize",
00296 "The texture details setting. Lower is faster.", RAccess, 1, 0, 2, 1),
00297 bannerRowsDepricated_(options_, "BannerRows",
00298 "", RAccess | OptionEntry::DataDepricated, 6),
00299 tankDetail_(options_, "TankDetail",
00300 "The tank details setting. Lower is faster but shows less tank models.", RAccess, 2, 0, 2, 1),
00301 effectsDetail_(options_, "EffectsDetail",
00302 "The number of effects allowed at once.", RAccess, 1, 0, 2, 1),
00303 screenWidth_(options_, "ScreenWidth",
00304 "The window width to use (in pixels)", RAccess, 800),
00305 screenHeight_(options_, "ScreenHeight",
00306 "The window height to use (in pixels)", RAccess, 600),
00307 depthBufferBits_(options_, "DepthBufferBits",
00308 "The number of bits requested for the depth buffer", RAccess, 24),
00309 doubleBuffer_(options_, "DoubleBuffer",
00310 "Use double buffering", RAccess, true),
00311 colorComponentSize_(options_, "ColorComponentSize",
00312 "The number of bits to use for each of the RGBA components (0 = use default)", RAccess, 0),
00313 bitsPerPixel_(options_, "BitsPerPixel",
00314 "The number of bits per pixel to use for the display (0 = current display bbp)", RAccess, 0),
00315 landDetailLevelRamp_(options_, "LandDetailLevelRamp",
00316 "The amount of error allowed for each land patch as it gains in distance (more is less error)", RWAccess, 128),
00317 waterDetailLevelRamp_(options_, "WaterDetailLevelRamp",
00318 "The amount of error allowed for each water patch as it gains in distance (more is less error)", RWAccess, 128),
00319 showContextHelp_(options_, "ShowContextHelp",
00320 "Show in game help tooltips for items that have it", RWAccess, true),
00321 showContextInfo_(options_, "ShowContextInfo",
00322 "Show in game information tooltips for items that have it", RWAccess, true),
00323 deprecatedSortAccessories_(options_, "SortAccessories",
00324 "Sort accessories alphabetically by name before displaying",
00325 RWAccess | OptionEntry::DataDepricated, false),
00326 accessorySortKey_(options_, "AccessorySortKey",
00327 "The key to sort accessories by before displaying",
00328 RWAccess, 0, accessorySortKeyEnum),
00329 focusPause_(options_, "FocusPause",
00330 "Pause the graphics display when mouse leaves window.", RWAccess, true)
00331
00332 {
00333 }
00334
00335 OptionsDisplay::~OptionsDisplay()
00336 {
00337 }
00338
00339 bool OptionsDisplay::writeOptionsToFile()
00340 {
00341 std::string path = S3D::getSettingsFile("display.xml");
00342
00343
00344 FILE *checkfile = fopen(path.c_str(), "a");
00345 if (!checkfile)
00346 {
00347 S3D::dialogMessage(
00348 "Scorched3D", S3D::formatStringBuffer(
00349 "Warning: Your display settings file (%s) cannot be\n"
00350 "written to. Your settings will not be saved from one game to the next.\n\n"
00351 "To fix this problem correct the permissions for this file.",
00352 path.c_str()));
00353 }
00354 else fclose(checkfile);
00355
00356 if (!OptionEntryHelper::writeToFile(options_, path)) return false;
00357 return true;
00358 }
00359
00360 bool OptionsDisplay::readOptionsFromFile()
00361 {
00362 std::string path = S3D::getSettingsFile("display.xml");
00363
00364 if (!OptionEntryHelper::readFromFile(options_, path))
00365 {
00366 S3D::dialogMessage(
00367 "Scorched3D", S3D::formatStringBuffer(
00368 "Warning: Your display settings file (%s) cannot be\n"
00369 "read. This may be because it was create by an out of date version of Scorched3D.\n"
00370 "If this is the case it can be safely deleted.",
00371 path.c_str()));
00372 return false;
00373 }
00374
00375 return true;
00376 }
00377
00378 void OptionsDisplay::loadDefaultValues()
00379 {
00380 std::list<OptionEntry *>::iterator itor;
00381 for (itor = options_.begin();
00382 itor != options_.end();
00383 itor++)
00384 {
00385 OptionEntry *entry = (*itor);
00386 if (!(entry->getData() & NoRestore))
00387 {
00388 entry->setValueFromString(entry->getDefaultValueAsString());
00389 }
00390 }
00391 }
00392
00393 void OptionsDisplay::loadSafeValues()
00394 {
00395 std::string path = S3D::getDataFile("data/safedisplay.xml");
00396 OptionEntryHelper::readFromFile(options_, path);
00397 }
00398
00399 void OptionsDisplay::loadMediumValues()
00400 {
00401 std::string path = S3D::getDataFile("data/mediumdisplay.xml");
00402 OptionEntryHelper::readFromFile(options_, path);
00403 }
00404
00405 void OptionsDisplay::loadFastestValues()
00406 {
00407 std::string path = S3D::getDataFile("data/fastestdisplay.xml");
00408 OptionEntryHelper::readFromFile(options_, path);
00409 }
00410