mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Initial working version. Video/rendering options supported. No GUI yet.
This commit is contained in:
parent
162ae607a1
commit
0ec20b23aa
3 changed files with 150 additions and 13 deletions
|
@ -259,21 +259,32 @@ int CS::Editor::run()
|
|||
|
||||
std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
||||
{
|
||||
// TODO: setting
|
||||
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem"));
|
||||
std::string rendersystem = mUserSettings.settingValue("Video/render system").toStdString();
|
||||
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(rendersystem));
|
||||
std::cout << "editor: render system " + rendersystem << std::endl; // FIXME: debug
|
||||
|
||||
Ogre::Root::getSingleton().initialise(false);
|
||||
|
||||
// Create a hidden background window to keep resources
|
||||
Ogre::NameValuePairList params;
|
||||
params.insert(std::make_pair("title", ""));
|
||||
params.insert(std::make_pair("FSAA", "0"));
|
||||
params.insert(std::make_pair("vsync", "false"));
|
||||
|
||||
std::string antialiasing = mUserSettings.settingValue("Video/antialiasing").toStdString();
|
||||
if(antialiasing == "MSAA 16") antialiasing = "16";
|
||||
else if(antialiasing == "MSAA 8") antialiasing = "8";
|
||||
else if(antialiasing == "MSAA 4") antialiasing = "4";
|
||||
else if(antialiasing == "MSAA 2") antialiasing = "2";
|
||||
else antialiasing = "0";
|
||||
params.insert(std::make_pair("FSAA", antialiasing));
|
||||
|
||||
std::string vsync = mUserSettings.settingValue("Video/vsync").toStdString() == "true" ? "true" : "false";
|
||||
params.insert(std::make_pair("vsync", vsync));
|
||||
params.insert(std::make_pair("hidden", "true"));
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||
params.insert(std::make_pair("macAPI", "cocoa"));
|
||||
#endif
|
||||
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms);
|
||||
bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false;
|
||||
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms);
|
||||
hiddenWindow->setActive(false);
|
||||
|
||||
sh::OgrePlatform* platform =
|
||||
|
@ -286,7 +297,16 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
|||
|
||||
std::auto_ptr<sh::Factory> factory (new sh::Factory (platform));
|
||||
|
||||
factory->setCurrentLanguage (sh::Language_GLSL); /// \todo make this configurable
|
||||
std::string shLang = mUserSettings.settingValue("Shiny/language").toStdString();
|
||||
enum sh::Language lang;
|
||||
if(shLang == "CG") lang = sh::Language_CG;
|
||||
else if(shLang == "HLSL") lang = sh::Language_HLSL;
|
||||
else if(shLang == "GLSL") lang = sh::Language_GLSL;
|
||||
else if(shLang == "GLSLES") lang = sh::Language_GLSLES;
|
||||
else if(shLang == "Count") lang = sh::Language_Count;
|
||||
else lang = sh::Language_None;
|
||||
|
||||
factory->setCurrentLanguage (lang);
|
||||
factory->setWriteSourceCache (true);
|
||||
factory->setReadSourceCache (true);
|
||||
factory->setReadMicrocodeCache (true);
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
#include <QFile>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#include "setting.hpp"
|
||||
#include "support.hpp"
|
||||
#include <QTextCodec>
|
||||
#include <QDebug>
|
||||
|
||||
/**
|
||||
|
@ -26,17 +29,66 @@ 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)
|
||||
: mCfgMgr (configurationManager)
|
||||
: mCfgMgr (configurationManager)
|
||||
, mSettingDefinitions(NULL)
|
||||
, mSettingCfgDefinitions(NULL)
|
||||
{
|
||||
assert(!mUserSettingsInstance);
|
||||
mUserSettingsInstance = this;
|
||||
|
||||
mSettingDefinitions = 0;
|
||||
|
||||
buildSettingModelDefaults();
|
||||
mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "");
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||
|
@ -276,6 +328,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
|
||||
CSMSettings::UserSettings::~UserSettings()
|
||||
{
|
||||
delete mSettingDefinitions;
|
||||
delete mSettingCfgDefinitions;
|
||||
mUserSettingsInstance = 0;
|
||||
}
|
||||
|
||||
|
@ -305,6 +359,54 @@ 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
|
||||
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg";
|
||||
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg";
|
||||
|
||||
Settings::Manager settings;
|
||||
// prefer local
|
||||
if (boost::filesystem::exists(localdefault))
|
||||
settings.loadDefault(localdefault);
|
||||
else if (boost::filesystem::exists(globaldefault))
|
||||
settings.loadDefault(globaldefault);
|
||||
else
|
||||
std::cerr<< "No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."<< std::endl;
|
||||
|
||||
// load user settings if they exist, otherwise just load the default settings as user settings
|
||||
const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "/settings.cfg";
|
||||
if (boost::filesystem::exists(settingspath))
|
||||
settings.loadUser(settingspath);
|
||||
else if (boost::filesystem::exists(localdefault))
|
||||
settings.loadUser(localdefault);
|
||||
else if (boost::filesystem::exists(globaldefault))
|
||||
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
|
||||
renderSystem = "Direct3D9 Rendering Subsystem";
|
||||
#else
|
||||
renderSystem = "OpenGL Rendering Subsystem";
|
||||
#endif
|
||||
}
|
||||
mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str());
|
||||
// Force shiny language based on render system
|
||||
if(renderSystem == "Direct3D9 Rendering Subsystem")
|
||||
mSettingDefinitions->setValue("Shiny/language", "CG");
|
||||
else
|
||||
mSettingDefinitions->setValue("Shiny/language", "GLSL");
|
||||
}
|
||||
|
||||
bool CSMSettings::UserSettings::hasSettingDefinitions
|
||||
|
@ -326,10 +428,25 @@ void CSMSettings::UserSettings::saveDefinitions() const
|
|||
|
||||
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
||||
{
|
||||
if (!mSettingDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
QStringList defs;
|
||||
|
||||
QStringList defs = mSettingDefinitions->value (settingKey).toStringList();
|
||||
// check if video settings are overriden
|
||||
if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) &&
|
||||
mSettingDefinitions->value("Video/override settings.cfg") == "true")
|
||||
{
|
||||
std::cout << "user settings: override " << std::endl; // FIXME: debug
|
||||
if (!mSettingCfgDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
else
|
||||
defs = mSettingCfgDefinitions->value (settingKey).toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mSettingDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
|
||||
defs = mSettingDefinitions->value (settingKey).toStringList();
|
||||
}
|
||||
|
||||
if (defs.isEmpty())
|
||||
return QString();
|
||||
|
@ -387,7 +504,6 @@ void CSMSettings::UserSettings::removeSetting
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
|
||||
{
|
||||
SettingPageMap pageMap;
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace CSMSettings {
|
|||
const Files::ConfigurationManager& mCfgMgr;
|
||||
|
||||
QSettings *mSettingDefinitions;
|
||||
QSettings *mSettingCfgDefinitions;
|
||||
QList <Setting *> mSettings;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue