Fixed default settings logic and cleaned up comments.

This commit is contained in:
cc9cii 2014-09-15 19:33:38 +10:00
parent e4b836608c
commit ecb4154ac0

View file

@ -29,54 +29,6 @@ namespace boost
} /* namespace boost */
#endif /* (BOOST_VERSION <= 104600) */
/*
* FIXME: temporary notes
*
* - CSVSettings::Dialog::Dialog is the settings window
* - provide a hard coded default if not found in config file
* - provide tooltips
* - save/cancel option (or auto-save?)
* - opencs.ini: where all these settings are saved
* . error if can't create file (directory permissions) or save file (file permissions)
* - settings.cfg: where Graphics default settings come from (read only)
* . warning if neither default or user cfg not found or not readable (file permissions)
* - openmw.cfg: not used
*
* - Tabbed view similar to OpenMW or Launcher
* . Video Settings
* . Display Settngs
* . Misc Settings
*
* - Video settings: tick box for "Use the video settings from OpenMW" (default,
* individual settings greyed out)
* . CS::Editor::setupGraphics()
* . the defaults should be the initial setting when unticked, unless previous user
* settings were found
* # OpenGL/Direct3D9 Rendering Subsystem
* # Vsync
* # FSAA (antialiasing)
* # GLSL/CG shader language
* . other shiny options
* . screen number
* # full screen / windowed (resolution) <- replace already existing
*
* - Display Settings
* . text only / icon + text <- replace already existing
* . limit the number of subviews per top level view
* . option to reuse subviews
* . v/w/dialoguesubview min width 325
* . filter pattern syntax
*
* - misc
* . v/r/scenewidget mFastFactor(4)
* . v/r/scenewidget far clip distance
* . v/r/scenewidget start timer 20
* . v/r/scenewidget shortcut
* . v/d/adjusterwidget error
* . v/r/navigation factor /= 2
* . v/w/table redirect extended action
*/
CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0;
CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager)
@ -88,7 +40,7 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf
mUserSettingsInstance = this;
buildSettingModelDefaults();
mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "");
mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this);
}
void CSMSettings::UserSettings::buildSettingModelDefaults()
@ -328,8 +280,6 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
CSMSettings::UserSettings::~UserSettings()
{
delete mSettingDefinitions;
delete mSettingCfgDefinitions;
mUserSettingsInstance = 0;
}
@ -360,15 +310,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
mSettingDefinitions = new QSettings
(QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this);
// if user setting (opencs.ini) exists
// if readable, then check whether the option to use settings.cfg video settings should be used is set
// use the config settings from settings.cfg
// else if video config found
// use the config settings from opencs.ini
// if any of the config option is not found, use hard coded default in this file
//
// Create the settings manager and load default settings file
// prepare to use the settings from settings.cfg
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg";
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg";
@ -391,8 +333,6 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
settings.loadUser(globaldefault);
std::string renderSystem = settings.getString("render system", "Video");
std::cout << "user settings: render system " + renderSystem << std::endl; // FIXME: debug
if(renderSystem == "")
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
@ -402,11 +342,15 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
#endif
}
mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str());
// Force shiny language based on render system
// force shiny language based on render system
if(renderSystem == "Direct3D9 Rendering Subsystem")
mSettingDefinitions->setValue("Shiny/language", "CG");
else
mSettingDefinitions->setValue("Shiny/language", "GLSL");
// check if override entry exists (default: override)
if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive))
mSettingDefinitions->setValue("Video/use settings.cfg", "true");
}
bool CSMSettings::UserSettings::hasSettingDefinitions
@ -432,9 +376,8 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
// check if video settings are overriden
if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) &&
mSettingDefinitions->value("Video/override settings.cfg") == "true")
mSettingDefinitions->value("Video/use settings.cfg") == "true")
{
std::cout << "user settings: override " << std::endl; // FIXME: debug
if (!mSettingCfgDefinitions->contains (settingKey))
return QString();
else