From 0ec20b23aa4a2cfad0145dc33fc0b16104b811bb Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 14 Sep 2014 12:48:00 +1000 Subject: [PATCH 01/90] Initial working version. Video/rendering options supported. No GUI yet. --- apps/opencs/editor.cpp | 32 ++++- apps/opencs/model/settings/usersettings.cpp | 130 ++++++++++++++++++-- apps/opencs/model/settings/usersettings.hpp | 1 + 3 files changed, 150 insertions(+), 13 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index e8e2d9077..d3e5c6720 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -259,21 +259,32 @@ int CS::Editor::run() std::auto_ptr 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 CS::Editor::setupGraphics() std::auto_ptr 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); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 04f98f0d6..be0e3ab26 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -4,10 +4,13 @@ #include #include +#include + #include #include "setting.hpp" #include "support.hpp" +#include #include /** @@ -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; diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 7e553caf6..9d9b5c9b0 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -33,6 +33,7 @@ namespace CSMSettings { const Files::ConfigurationManager& mCfgMgr; QSettings *mSettingDefinitions; + QSettings *mSettingCfgDefinitions; QList mSettings; public: From e4b836608cdeaf461a8bfd461e9d17164af97ac4 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 14 Sep 2014 14:04:47 +1000 Subject: [PATCH 02/90] Partially address feature #854 by reading the status bar setting from opencs.ini. Missing GUI update that will affect new top level windows. --- apps/opencs/view/doc/view.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index cf5148391..0ba9f80f7 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -98,6 +98,10 @@ void CSVDoc::View::setupViewMenu() mShowStatusBar = new QAction (tr ("Show Status Bar"), this); mShowStatusBar->setCheckable (true); connect (mShowStatusBar, SIGNAL (toggled (bool)), this, SLOT (toggleShowStatusBar (bool))); + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + if(showStatusBar == "true") + mShowStatusBar->setChecked(true); view->addAction (mShowStatusBar); QAction *filters = new QAction (tr ("Filters"), this); @@ -650,4 +654,4 @@ void CSVDoc::View::run (const std::string& profile, const std::string& startupIn void CSVDoc::View::stop() { mDocument->stopRunning(); -} \ No newline at end of file +} From ecb4154ac016b67e0289e16759fd2e21d42968fa Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 15 Sep 2014 19:33:38 +1000 Subject: [PATCH 03/90] Fixed default settings logic and cleaned up comments. --- apps/opencs/model/settings/usersettings.cpp | 73 +++------------------ 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index be0e3ab26..6ccc9ddb0 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -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 From ffaca7a8754c5540782554ec87337c6f277180a7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 16 Sep 2014 07:44:07 +1000 Subject: [PATCH 04/90] GUI added, but not yet functional. --- apps/opencs/CMakeLists.txt | 3 +- apps/opencs/editor.cpp | 4 +- apps/opencs/editor.hpp | 4 +- apps/opencs/model/settings/usersettings.cpp | 2 + apps/opencs/view/settings/settingsdialog.cpp | 126 +++++++ apps/opencs/view/settings/settingsdialog.hpp | 56 +++ apps/opencs/view/settings/settingwindow.cpp | 2 +- apps/opencs/view/settings/settingwindow.hpp | 2 +- files/ui/settingstab.ui | 343 +++++++++++++++++++ 9 files changed, 535 insertions(+), 7 deletions(-) create mode 100644 apps/opencs/view/settings/settingsdialog.cpp create mode 100644 apps/opencs/view/settings/settingsdialog.hpp create mode 100644 files/ui/settingstab.ui diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7094f8799..be536535e 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -99,7 +99,7 @@ opencs_units_noqt (view/tools opencs_units (view/settings settingwindow - dialog + settingsdialog page view booleanview @@ -142,6 +142,7 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc set (OPENCS_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ${CMAKE_SOURCE_DIR}/files/ui/filedialog.ui + ${CMAKE_SOURCE_DIR}/files/ui/settingstab.ui ) source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR}) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index d3e5c6720..1887629f9 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) setupDataFiles (config.first); CSMSettings::UserSettings::instance().loadSettings ("opencs.ini"); - mSettings.setModel (CSMSettings::UserSettings::instance()); + //mSettings.setModel (CSMSettings::UserSettings::instance()); ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); @@ -189,7 +189,7 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath) files.push_back(path.toUtf8().constData()); } - files.push_back(mFileDialog.filename().toUtf8().constData()); + files.push_back (savePath); mDocumentManager.addDocument (files, savePath, true); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index c87e24e77..4ccc61a02 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -26,7 +26,7 @@ #include "view/doc/filedialog.hpp" #include "view/doc/newgame.hpp" -#include "view/settings/dialog.hpp" +#include "view/settings/settingsdialog.hpp" namespace OgreInit { @@ -46,7 +46,7 @@ namespace CS CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; CSVDoc::NewGameDialogue mNewGame; - CSVSettings::Dialog mSettings; + CSVSettings::SettingsDialog mSettings; CSVDoc::FileDialog mFileDialog; boost::filesystem::path mLocal; boost::filesystem::path mResources; diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 6ccc9ddb0..e655a66a3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -40,6 +40,8 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf mUserSettingsInstance = this; buildSettingModelDefaults(); + + // for overriding opencs.ini settings with those from settings.cfg mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp new file mode 100644 index 000000000..db7b49a54 --- /dev/null +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -0,0 +1,126 @@ +#include "settingsdialog.hpp" + +#include +#include +#include +#include +#include + +#include "../../model/settings/usersettings.hpp" + +#include "page.hpp" + +#include + +#include + +#include +#include +#include + +#include +#include + +CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) + : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) +{ + setWindowTitle(QString::fromUtf8 ("User Settings")); + + setupUi(this); + + //setupDialog(); + + //connect (mPageListWidget, + //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + //this, + //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); +} + +void CSVSettings::SettingsDialog::slotChangePage + (QListWidgetItem *cur, QListWidgetItem *prev) +{ + //mStackedWidget->changePage + //(mPageListWidget->row (cur), mPageListWidget->row (prev)); + + layout()->activate(); + setFixedSize(minimumSizeHint()); +} + +void CSVSettings::SettingsDialog::setupDialog() +{ + //create central widget with it's layout and immediate children + QWidget *centralWidget = new QGroupBox (this); + + centralWidget->setLayout (new QHBoxLayout()); + centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); + //setCentralWidget (centralWidget); + //setDockOptions (QMainWindow::AllowNestedDocks); + + buildPageListWidget (centralWidget); + buildStackedWidget (centralWidget); +} + +void CSVSettings::SettingsDialog::buildPages() +{ + SettingWindow::createPages (); +#if 0 + + QFontMetrics fm (QApplication::font()); + + foreach (Page *page, SettingWindow::pages()) + { + QString pageName = page->objectName(); + + //int textWidth = fm.width(pageName); + + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); + + //mStackedWidget->addWidget (&dynamic_cast(*(page))); + } + + //resize (mStackedWidget->sizeHint()); +#endif +} + +void CSVSettings::SettingsDialog::buildPageListWidget (QWidget *centralWidget) +{ + //mPageListWidget = new QListWidget (centralWidget); + //mPageListWidget->setMinimumWidth(50); + //mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); + + //mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); + + //centralWidget->layout()->addWidget(mPageListWidget); +} + +void CSVSettings::SettingsDialog::buildStackedWidget (QWidget *centralWidget) +{ + //mStackedWidget = new ResizeableStackedWidget (centralWidget); + + //centralWidget->layout()->addWidget (mStackedWidget); +} + +void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +{ + //SettingWindow::closeEvent() must be called first to ensure + //model is updated + //SettingWindow::closeEvent (event); + + //saveSettings(); +} + +void CSVSettings::SettingsDialog::show() +{ + //if (pages().isEmpty()) + { + //buildPages(); + //setViewValues(); + } + //if( + + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + + move (screenCenter - geometry().center()); + QWidget::show(); +} diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp new file mode 100644 index 000000000..e9bd2d043 --- /dev/null +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -0,0 +1,56 @@ +#ifndef CSVSETTINGS_SETTINGSDIALOG_H +#define CSVSETTINGS_SETTINGSDIALOG_H + +#include "settingwindow.hpp" +//#include "resizeablestackedwidget.hpp" +#include + +#include "ui_settingstab.h" + +//class QStackedWidget; +//class QListWidget; +class QListWidgetItem; + +namespace CSVSettings { + + //class Page; + + class SettingsDialog : public SettingWindow, private Ui::TabWidget + { + Q_OBJECT + + //QListWidget *mPageListWidget; + //ResizeableStackedWidget *mStackedWidget; + bool mDebugMode; + + public: + + /*explicit*/ SettingsDialog (QMainWindow *parent = 0); + + ///Enables setting debug mode. When the dialog opens, a page is created + ///which displays the SettingModel's contents in a Tree view. + void enableDebugMode (bool state, QStandardItemModel *model = 0); + + protected: + + /// Settings are written on close + void closeEvent (QCloseEvent *event); + + void setupDialog(); + + private: + + void buildPages(); + void buildPageListWidget (QWidget *centralWidget); + void buildStackedWidget (QWidget *centralWidget); + + public slots: + + void show(); + + private slots: + + void slotChangePage (QListWidgetItem *, QListWidgetItem *); + }; +} +#endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..c70418553 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -9,7 +9,7 @@ #include "view.hpp" CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QMainWindow(parent) + : QTabWidget(parent) {} void CSVSettings::SettingWindow::createPages() diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..b1f55d67f 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QMainWindow + class SettingWindow : public QTabWidget { Q_OBJECT diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui new file mode 100644 index 000000000..620e8d0c5 --- /dev/null +++ b/files/ui/settingstab.ui @@ -0,0 +1,343 @@ + + + TabWidget + + + + 0 + 0 + 400 + 300 + + + + User Settings + + + 0 + + + + Video Settings + + + + + 20 + 181 + 351 + 71 + + + + + + + Standard: + + + true + + + buttonGroup + + + + + + + Resolution + + + + + + + Full Screen + + + + + + + Custom; + + + buttonGroup + + + + + + + + 180 + 0 + + + + + + + + + 186 + 16777215 + + + + + + + + + + + + + 10 + 8 + 371 + 153 + + + + Render System + + + + + + 10 + 165 + 371 + 99 + + + + Display + + + + + + 21 + 26 + 351 + 125 + + + + + + + + 0 + 22 + + + + Use Render System Settings from OpenMW + + + true + + + + + + + Rendering Subsystem + + + + + + + false + + + + OpenGL Rendering Subsystem + + + + + Direct3D9 Rendering Subsystem + + + + + + + + Vertical Sync + + + + + + + Antialiasing + + + + + + + + Off + + + + + MSAA 2 + + + + + MSAA 4 + + + + + MSAA 8 + + + + + MSAA 8 (Quality) + + + + + + + + Shader Language + + + + + + + + HLSL + + + + + CG + + + + + + + renderGroup + layoutWidget + displayGroup + layoutWidget_Screen + + + + Display Settings + + + + + 20 + 30 + 351 + 116 + + + + + + + Max Number of Subviews + + + + + + + Min Subview Width + + + + + + + Reuse Subviews + + + + + + + + Text Only + + + + + Text + Icon + + + + + + + + + + + 325 + + + 20000 + + + 5 + + + + + + + Show Icon + + + + + + + + + 10 + 10 + 371 + 151 + + + + GroupBox + + + groupBox + layoutWidget2 + + + + Misc Settings + + + + + + + + + From d679e0e0126c31fa77946e9480942a7782051334 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 16 Sep 2014 19:50:25 +1000 Subject: [PATCH 05/90] Made more progress. Grey out disabled settings. --- apps/opencs/CMakeLists.txt | 2 - apps/opencs/editor.cpp | 4 +- apps/opencs/model/settings/usersettings.cpp | 5 +- apps/opencs/view/settings/settingsdialog.cpp | 214 ++++++++++++++++++- apps/opencs/view/settings/settingsdialog.hpp | 12 +- apps/opencs/view/settings/settingwindow.cpp | 2 +- apps/opencs/view/settings/settingwindow.hpp | 2 +- files/ui/settingstab.ui | 123 ++++++----- 8 files changed, 296 insertions(+), 68 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index be536535e..a58c1a614 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -98,9 +98,7 @@ opencs_units_noqt (view/tools ) opencs_units (view/settings - settingwindow settingsdialog - page view booleanview textview diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1887629f9..77921a335 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -283,8 +283,10 @@ std::auto_ptr CS::Editor::setupGraphics() #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); #endif + // FIXME: don't apply the fullscreen here, apply to the editor window bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; - Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); sh::OgrePlatform* platform = diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e655a66a3..cd9bf6a33 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -377,8 +377,9 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey) QStringList defs; // check if video settings are overriden - if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) && - mSettingDefinitions->value("Video/use settings.cfg") == "true") + if(settingKey.contains(QRegExp("^Video\\b", Qt::CaseInsensitive)) && + mSettingDefinitions->value("Video/use settings.cfg") == "true" && + settingKey.contains(QRegExp("^Video/\\brender|antialiasing|vsync|fullscreen\\b", Qt::CaseInsensitive))) { if (!mSettingCfgDefinitions->contains (settingKey)) return QString(); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index db7b49a54..973a60e2c 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -8,6 +8,8 @@ #include "../../model/settings/usersettings.hpp" +//#include "ui_settingstab.h" + #include "page.hpp" #include @@ -20,15 +22,157 @@ #include #include +#include + +#include +#include +//#include +#include + +namespace +{ +// copied from launcher +QString getAspect(int x, int y) +{ + int gcd = boost::math::gcd (x, y); + int xaspect = x / gcd; + int yaspect = y / gcd; + // special case: 8 : 5 is usually referred to as 16:10 + if (xaspect == 8 && yaspect == 5) + return QString("16:10"); + + return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); +} + +QRect getMaximumResolution() +{ + QRect max; + int screens = QApplication::desktop()->screenCount(); + for(int i = 0; i < screens; ++i) + { + QRect res = QApplication::desktop()->screenGeometry(i); + if(res.width() > max.width()) + max.setWidth(res.width()); + if(res.height() > max.height()) + max.setHeight(res.height()); + } + return max; +} + +QString getCurrentResolution() +{ + QString result; + + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + for(;it != renderOpt.end(); ++it) + { + if(it->first == "Video Mode" ) + { + QRegExp re("^(\\d+) x (\\d+)"); + int pos = re.indexIn(it->second.currentValue.c_str(), 0); + if (pos > -1) + { + QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); + result = re.cap(1) + QString(" x ") + re.cap(2); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) + { + //result.append(QObject::tr("\t(Wide ") + aspect + ")"); + + } + else if (aspect == QLatin1String("4:3")) + { + //result.append(QObject::tr("\t(Standard 4:3)")); + } + } + } + } + return result; +} -CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) - : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) +QStringList getAvailableResolutions() { - setWindowTitle(QString::fromUtf8 ("User Settings")); + // store available rendering devices and available resolutions + QStringList result; + + Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + for(;it != renderOpt.end(); ++it) + { + if(it->first == "Rendering Device" ) + { + if(it->second.possibleValues.empty()) + { + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(QObject::tr("
Ogre Rendering Device empty<./b>

")); + msgBox.exec(); + return result; + } + //std::cout << "rd current: " << it->second.currentValue << std::endl; // FIXME: debug + // Store Available Rendering Devices + std::vector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + std::cout << "rd: " << *iter << std::endl; // FIXME: debug + } + } + if(it->first == "Video Mode" ) + { + if(it->second.possibleValues.empty()) + { + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("Error receiving resolutions")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(QObject::tr("
Ogre Video Modes empty.

")); + msgBox.exec(); + return result; + } + // FIXME: how to default to the current value? + std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug + // Store Available Resolutions + std::vector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + // extract x and y values + QRegExp re("^(\\d+) x (\\d+)"); + int pos = re.indexIn((*iter).c_str(), 0); + if (pos > -1) + { + QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); + QString resolution = re.cap(1) + QString(" x ") + re.cap(2); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { + resolution.append(QObject::tr("\t(Wide ") + aspect + ")"); + + } else if (aspect == QLatin1String("4:3")) { + resolution.append(QObject::tr("\t(Standard 4:3)")); + } + result.append(resolution); + } + } + } + } + result.removeDuplicates(); + return result; +} + +} + +CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) + : /*mStackedWidget (0), mDebugMode (false),*/ QTabWidget (parent) +{ + setObjectName("User Settings"); setupUi(this); - //setupDialog(); + // Set the maximum res we can set in windowed mode + QRect res = getMaximumResolution(); + spinBox_x->setMaximum(res.width()); + spinBox_y->setMaximum(res.height()); //connect (mPageListWidget, //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), @@ -36,6 +180,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } +// FIXME: don't need this one, as we don't use pages void CSVSettings::SettingsDialog::slotChangePage (QListWidgetItem *cur, QListWidgetItem *prev) { @@ -46,6 +191,7 @@ void CSVSettings::SettingsDialog::slotChangePage setFixedSize(minimumSizeHint()); } +// FIXME: don't need this one since we use setupUi void CSVSettings::SettingsDialog::setupDialog() { //create central widget with it's layout and immediate children @@ -62,8 +208,8 @@ void CSVSettings::SettingsDialog::setupDialog() void CSVSettings::SettingsDialog::buildPages() { - SettingWindow::createPages (); #if 0 + SettingWindow::createPages (); QFontMetrics fm (QApplication::font()); @@ -117,10 +263,62 @@ void CSVSettings::SettingsDialog::show() //buildPages(); //setViewValues(); } - //if( - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg").toStdString() == "true") + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + + } + else + checkBox_override->setChecked(false); - move (screenCenter - geometry().center()); + if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen").toStdString() == "true") + { + checkBox_fullscreen->setChecked(true); + + label_Resolution->setEnabled(false); + radioButton_standard_res->setEnabled(false); + radioButton_custom_res->setEnabled(false); + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + checkBox_fullscreen->setChecked(false); + } + + // update display resolution combo box + // FIXME: update opencs window size + comboBox_std_window_size->clear(); + comboBox_std_window_size->addItems(getAvailableResolutions()); + int index = comboBox_std_window_size->findData(getCurrentResolution(), + Qt::DisplayRole, + Qt::MatchStartsWith); + if(index != -1) + comboBox_std_window_size->setCurrentIndex(index); + + // place the widget and make it visible + QWidget *currView = QApplication::activeWindow(); + if(currView) + { + // place at the center of the window with focus + QSize size = currView->size(); + move(currView->geometry().x()+(size.width() - frameGeometry().width())/2, + currView->geometry().y()+(size.height() - frameGeometry().height())/2); + } + else + { + // something's gone wrong, place at the center of the screen + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + move(screenCenter - QPoint(frameGeometry().width()/2, + frameGeometry().height()/2)); + } QWidget::show(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index e9bd2d043..2d16efe34 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -1,7 +1,7 @@ #ifndef CSVSETTINGS_SETTINGSDIALOG_H #define CSVSETTINGS_SETTINGSDIALOG_H -#include "settingwindow.hpp" +//#include "settingwindow.hpp" //#include "resizeablestackedwidget.hpp" #include @@ -11,11 +11,17 @@ //class QListWidget; class QListWidgetItem; +#if 0 +namespace Ui { + class TabWidget; +} +#endif + namespace CSVSettings { //class Page; - class SettingsDialog : public SettingWindow, private Ui::TabWidget + class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT @@ -25,7 +31,7 @@ namespace CSVSettings { public: - /*explicit*/ SettingsDialog (QMainWindow *parent = 0); + /*explicit*/ SettingsDialog (QTabWidget *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index c70418553..7cdf2bded 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -9,7 +9,7 @@ #include "view.hpp" CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QTabWidget(parent) + : QMainWindow(parent) {} void CSVSettings::SettingWindow::createPages() diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index b1f55d67f..2266f130d 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QTabWidget + class SettingWindow : public QMainWindow { Q_OBJECT diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 620e8d0c5..b75db685f 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -7,7 +7,7 @@ 0 0 400 - 300 + 313 @@ -24,13 +24,13 @@ 20 - 181 + 188 351 - 71 + 81 - + Standard: @@ -43,7 +43,7 @@ - + Resolution @@ -57,7 +57,7 @@ - + Custom; @@ -67,7 +67,20 @@ - + + + + + 186 + 16777215 + + + + + + + + @@ -77,19 +90,19 @@ - - + + - 186 - 16777215 + 16777215 + 2 + + Qt::Horizontal + - - - @@ -98,7 +111,7 @@ 10 8 371 - 153 + 156 @@ -109,9 +122,9 @@ 10 - 165 + 170 371 - 99 + 108 @@ -121,21 +134,15 @@ - 21 + 20 26 351 - 125 + 129 - - - 0 - 22 - - Use Render System Settings from OpenMW @@ -144,14 +151,14 @@ - + Rendering Subsystem - + false @@ -168,21 +175,42 @@ - + + + + Antialiasing + + + + Vertical Sync - - + + - Antialiasing + Shader Language - + + + + + HLSL + + + + + CG + + + + + @@ -211,25 +239,20 @@ - - - - Shader Language + + + + + 16777215 + 2 + + + + color: rgb(215, 215, 215); + + + Qt::Horizontal - - - - - - - HLSL - - - - - CG - - From e3da37567b998ed25ab019e316c889699b5a29e2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 06:11:41 +1000 Subject: [PATCH 06/90] Cleaned up and got some signals going. --- apps/opencs/editor.cpp | 2 +- apps/opencs/view/settings/settingsdialog.cpp | 272 +++++++++---------- apps/opencs/view/settings/settingsdialog.hpp | 36 +-- files/ui/settingstab.ui | 25 -- 4 files changed, 134 insertions(+), 201 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 77921a335..1c54062d8 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -284,7 +284,7 @@ std::auto_ptr CS::Editor::setupGraphics() params.insert(std::make_pair("macAPI", "cocoa")); #endif // FIXME: don't apply the fullscreen here, apply to the editor window - bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; + //bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 973a60e2c..9162aa449 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -1,37 +1,17 @@ #include "settingsdialog.hpp" -#include -#include -#include -#include -#include - -#include "../../model/settings/usersettings.hpp" - -//#include "ui_settingstab.h" - -#include "page.hpp" - -#include - -#include - -#include -#include -#include - -#include -#include +#include #include -#include -#include -//#include #include +#include +#include "../../model/settings/usersettings.hpp" + namespace { -// copied from launcher +// copied from the launcher & adapted + QString getAspect(int x, int y) { int gcd = boost::math::gcd (x, y); @@ -61,34 +41,20 @@ QRect getMaximumResolution() QString getCurrentResolution() { - QString result; - Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(;it != renderOpt.end(); ++it) + for(; it != renderOpt.end(); ++it) { if(it->first == "Video Mode" ) { - QRegExp re("^(\\d+) x (\\d+)"); + QRegExp re("^(\\d+ x \\d+)"); int pos = re.indexIn(it->second.currentValue.c_str(), 0); if (pos > -1) - { - QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); - result = re.cap(1) + QString(" x ") + re.cap(2); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) - { - //result.append(QObject::tr("\t(Wide ") + aspect + ")"); - - } - else if (aspect == QLatin1String("4:3")) - { - //result.append(QObject::tr("\t(Standard 4:3)")); - } - } + return re.cap(1); } } - return result; + return QString(); // found nothing } QStringList getAvailableResolutions() @@ -104,15 +70,8 @@ QStringList getAvailableResolutions() { if(it->second.possibleValues.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Ogre Rendering Device empty<./b>

")); - msgBox.exec(); - return result; + return result; // FIXME: add error message } - //std::cout << "rd current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Rendering Devices std::vector::iterator iter = it->second.possibleValues.begin(); for(;iter != it->second.possibleValues.end(); ++iter) @@ -124,19 +83,13 @@ QStringList getAvailableResolutions() { if(it->second.possibleValues.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("Error receiving resolutions")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Ogre Video Modes empty.

")); - msgBox.exec(); - return result; + return result; // FIXME: add error message } // FIXME: how to default to the current value? std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions std::vector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) + for(; iter != it->second.possibleValues.end(); ++iter) { // extract x and y values QRegExp re("^(\\d+) x (\\d+)"); @@ -160,111 +113,111 @@ QStringList getAvailableResolutions() return result; } -} - -CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) - : /*mStackedWidget (0), mDebugMode (false),*/ QTabWidget (parent) +QStringList getAvailableOptions(const QString &key) { - setObjectName("User Settings"); + QStringList result; - setupUi(this); + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - spinBox_x->setMaximum(res.width()); - spinBox_y->setMaximum(res.height()); + uint row = 0; + for(; it != renderOpt.end(); ++it, ++row) + { + Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); + uint idx = 0; - //connect (mPageListWidget, - //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - //this, - //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); -} + for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) + { + if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) + { + result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + + QString::fromStdString((*opt_it).c_str()).simplified(); + } + } + } -// FIXME: don't need this one, as we don't use pages -void CSVSettings::SettingsDialog::slotChangePage - (QListWidgetItem *cur, QListWidgetItem *prev) -{ - //mStackedWidget->changePage - //(mPageListWidget->row (cur), mPageListWidget->row (prev)); + // Sort ascending + qSort(result.begin(), result.end(), naturalSortLessThanCI); - layout()->activate(); - setFixedSize(minimumSizeHint()); -} + // Replace the zero option with Off + int index = result.indexOf("MSAA 0"); -// FIXME: don't need this one since we use setupUi -void CSVSettings::SettingsDialog::setupDialog() -{ - //create central widget with it's layout and immediate children - QWidget *centralWidget = new QGroupBox (this); + if(index != -1) + result.replace(index, QObject::tr("Off")); - centralWidget->setLayout (new QHBoxLayout()); - centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); - //setCentralWidget (centralWidget); - //setDockOptions (QMainWindow::AllowNestedDocks); + return result; +} - buildPageListWidget (centralWidget); - buildStackedWidget (centralWidget); } -void CSVSettings::SettingsDialog::buildPages() +CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) + : /*mDebugMode (false),*/ QTabWidget (parent) { -#if 0 - SettingWindow::createPages (); - - QFontMetrics fm (QApplication::font()); - - foreach (Page *page, SettingWindow::pages()) - { - QString pageName = page->objectName(); - - //int textWidth = fm.width(pageName); + setObjectName("User Settings"); - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); + setupUi(this); - //mStackedWidget->addWidget (&dynamic_cast(*(page))); - } + // Set the maximum res we can set in windowed mode + QRect res = getMaximumResolution(); + spinBox_x->setMaximum(res.width()); + spinBox_y->setMaximum(res.height()); - //resize (mStackedWidget->sizeHint()); -#endif + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); + connect(checkBox_fullscreen, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); + connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } -void CSVSettings::SettingsDialog::buildPageListWidget (QWidget *centralWidget) +void CSVSettings::SettingsDialog::rendererChanged() { - //mPageListWidget = new QListWidget (centralWidget); - //mPageListWidget->setMinimumWidth(50); - //mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); - - //mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); - - //centralWidget->layout()->addWidget(mPageListWidget); + comboBox_antialiasing->clear(); + comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); } -void CSVSettings::SettingsDialog::buildStackedWidget (QWidget *centralWidget) +void CSVSettings::SettingsDialog::slotFullScreenChanged(int state) { - //mStackedWidget = new ResizeableStackedWidget (centralWidget); - - //centralWidget->layout()->addWidget (mStackedWidget); + if (state == Qt::Checked) { + label_Resolution->setEnabled(false); + radioButton_standard_res->setEnabled(false); + radioButton_custom_res->setEnabled(false); + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + label_Resolution->setEnabled(true); + radioButton_standard_res->setEnabled(true); + radioButton_custom_res->setEnabled(true); + comboBox_std_window_size->setEnabled(true); + spinBox_x->setEnabled(true); + spinBox_y->setEnabled(true); + } } -void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +// FIXME: what to do with updating window size +void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { - //SettingWindow::closeEvent() must be called first to ensure - //model is updated - //SettingWindow::closeEvent (event); - - //saveSettings(); + if (checked) + { + comboBox_std_window_size->setEnabled(true); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(true); + spinBox_y->setEnabled(true); + } } -void CSVSettings::SettingsDialog::show() +void CSVSettings::SettingsDialog::setViewValues() { - //if (pages().isEmpty()) - { - //buildPages(); - //setViewValues(); - } + //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); + rendererChanged(); // setup antialiasing options - if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg").toStdString() == "true") + if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg") == "true") { label_RenderingSubsystem->setEnabled(false); comboBox_rendersystem->setEnabled(false); @@ -278,20 +231,16 @@ void CSVSettings::SettingsDialog::show() else checkBox_override->setChecked(false); - if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen").toStdString() == "true") + if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "") { - checkBox_fullscreen->setChecked(true); - - label_Resolution->setEnabled(false); - radioButton_standard_res->setEnabled(false); - radioButton_custom_res->setEnabled(false); - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); + spinBox_x->setValue( + CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt()); } - else + + if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "") { - checkBox_fullscreen->setChecked(false); + spinBox_y->setValue( + CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt()); } // update display resolution combo box @@ -304,6 +253,33 @@ void CSVSettings::SettingsDialog::show() if(index != -1) comboBox_std_window_size->setCurrentIndex(index); + slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); + + if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen") == "true") + { + checkBox_fullscreen->setChecked(true); + slotFullScreenChanged(Qt::Checked); + } + else + { + checkBox_fullscreen->setChecked(false); + slotFullScreenChanged(Qt::Unchecked); + } +} + +void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +{ + //SettingWindow::closeEvent() must be called first to ensure + //model is updated + //SettingWindow::closeEvent (event); + + //saveSettings(); +} + +void CSVSettings::SettingsDialog::show() +{ + setViewValues(); + // place the widget and make it visible QWidget *currView = QApplication::activeWindow(); if(currView) diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 2d16efe34..8f80fbc12 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -1,62 +1,44 @@ #ifndef CSVSETTINGS_SETTINGSDIALOG_H #define CSVSETTINGS_SETTINGSDIALOG_H -//#include "settingwindow.hpp" -//#include "resizeablestackedwidget.hpp" #include #include "ui_settingstab.h" -//class QStackedWidget; -//class QListWidget; class QListWidgetItem; -#if 0 -namespace Ui { - class TabWidget; -} -#endif - namespace CSVSettings { - //class Page; - class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT - //QListWidget *mPageListWidget; - //ResizeableStackedWidget *mStackedWidget; - bool mDebugMode; - public: - /*explicit*/ SettingsDialog (QTabWidget *parent = 0); + SettingsDialog (QTabWidget *parent = 0); + + int windowWidth(); + int windowHeight(); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. - void enableDebugMode (bool state, QStandardItemModel *model = 0); + //void enableDebugMode (bool state, QStandardItemModel *model = 0); protected: /// Settings are written on close void closeEvent (QCloseEvent *event); - void setupDialog(); - private: - void buildPages(); - void buildPageListWidget (QWidget *centralWidget); - void buildStackedWidget (QWidget *centralWidget); + void setViewValues(); public slots: void show(); - - private slots: - - void slotChangePage (QListWidgetItem *, QListWidgetItem *); + void rendererChanged(); + void slotFullScreenChanged(int state); + void slotStandardToggled(bool checked); }; } #endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index b75db685f..8e69767f5 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -212,31 +212,6 @@
- - - Off - - - - - MSAA 2 - - - - - MSAA 4 - - - - - MSAA 8 - - - - - MSAA 8 (Quality) - - From cb15750e402327137273c0f57d13a5c2ff174cb5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 06:29:11 +1000 Subject: [PATCH 07/90] Removed fullscreen checkbox and associated code. Doesn't really make sense for opencs and a fullscreen windowed mode is just a click or keyboard shortcut away, anyway. --- apps/opencs/editor.cpp | 4 +- apps/opencs/view/settings/settingsdialog.cpp | 33 ---------- apps/opencs/view/settings/settingsdialog.hpp | 1 - files/ui/settingstab.ui | 67 +++++++------------- 4 files changed, 24 insertions(+), 81 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1c54062d8..79e33e56b 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -283,9 +283,7 @@ std::auto_ptr CS::Editor::setupGraphics() #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); #endif - // FIXME: don't apply the fullscreen here, apply to the editor window - //bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; - //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + // NOTE: fullscreen mode not supported (doesn't really make sense for opencs) Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 9162aa449..92447664f 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -164,7 +164,6 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_y->setMaximum(res.height()); connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); - connect(checkBox_fullscreen, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } @@ -174,27 +173,6 @@ void CSVSettings::SettingsDialog::rendererChanged() comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); } -void CSVSettings::SettingsDialog::slotFullScreenChanged(int state) -{ - if (state == Qt::Checked) { - label_Resolution->setEnabled(false); - radioButton_standard_res->setEnabled(false); - radioButton_custom_res->setEnabled(false); - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); - } - else - { - label_Resolution->setEnabled(true); - radioButton_standard_res->setEnabled(true); - radioButton_custom_res->setEnabled(true); - comboBox_std_window_size->setEnabled(true); - spinBox_x->setEnabled(true); - spinBox_y->setEnabled(true); - } -} - // FIXME: what to do with updating window size void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { @@ -254,17 +232,6 @@ void CSVSettings::SettingsDialog::setViewValues() comboBox_std_window_size->setCurrentIndex(index); slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); - - if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen") == "true") - { - checkBox_fullscreen->setChecked(true); - slotFullScreenChanged(Qt::Checked); - } - else - { - checkBox_fullscreen->setChecked(false); - slotFullScreenChanged(Qt::Unchecked); - } } void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 8f80fbc12..d971b9c2a 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -37,7 +37,6 @@ namespace CSVSettings { void show(); void rendererChanged(); - void slotFullScreenChanged(int state); void slotStandardToggled(bool checked); }; } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 8e69767f5..2b1b561da 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -26,11 +26,24 @@ 20 188 351 - 81 + 51
- + + + + + + + + 186 + 16777215 + + + + + Standard: @@ -43,21 +56,7 @@ - - - - Resolution - - - - - - - Full Screen - - - - + Custom; @@ -67,20 +66,14 @@ - - - - - 186 - 16777215 - + + + + Window Size - - - - + @@ -90,19 +83,6 @@ - - - - - 16777215 - 2 - - - - Qt::Horizontal - - - @@ -124,7 +104,7 @@ 10 170 371 - 108 + 81 @@ -211,8 +191,7 @@ - - + From 9dc4af69c6f4ec0df12a22bb43f05bcbc1c8ffa0 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 17:13:21 +1000 Subject: [PATCH 08/90] Got window size to work correctly. Started to incorporate parts of previous settings implementation where possible. --- apps/opencs/CMakeLists.txt | 3 + apps/opencs/editor.cpp | 2 +- apps/opencs/view/doc/view.cpp | 10 +- apps/opencs/view/settings/settingsdialog.cpp | 113 ++++++++++++++++--- apps/opencs/view/settings/settingsdialog.hpp | 24 +++- 5 files changed, 126 insertions(+), 26 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index a58c1a614..02a6c25a0 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -99,6 +99,9 @@ opencs_units_noqt (view/tools opencs_units (view/settings settingsdialog + settingwindow + dialog + page view booleanview textview diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 79e33e56b..5fc2562ed 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) setupDataFiles (config.first); CSMSettings::UserSettings::instance().loadSettings ("opencs.ini"); - //mSettings.setModel (CSMSettings::UserSettings::instance()); + mSettings.setModel (CSMSettings::UserSettings::instance()); ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 0ba9f80f7..28ef002d4 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "../../model/doc/document.hpp" #include "../../model/settings/usersettings.hpp" @@ -325,7 +326,14 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to QString height = CSMSettings::UserSettings::instance().settingValue ("Window Size/Height"); - resize (width.toInt(), height.toInt()); + // trick to get the window decorations and their sizes + show(); + hide(); + resize (width.toInt() - (frameGeometry().width() - geometry().width()), + height.toInt() - (frameGeometry().height() - geometry().height())); + // start at the centre of the screen + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + move(screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2)); mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 92447664f..b49ab2c34 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -39,7 +39,7 @@ QRect getMaximumResolution() return max; } -QString getCurrentResolution() +QString getCurrentOgreResolution() { Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); @@ -152,7 +152,7 @@ QStringList getAvailableOptions(const QString &key) } CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) - : /*mDebugMode (false),*/ QTabWidget (parent) + : QTabWidget (parent) { setObjectName("User Settings"); @@ -163,7 +163,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_x->setMaximum(res.width()); spinBox_y->setMaximum(res.height()); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged())); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } @@ -195,7 +195,7 @@ void CSVSettings::SettingsDialog::setViewValues() //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); rendererChanged(); // setup antialiasing options - if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg") == "true") + if(mModel->settingValue("Video/use settings.cfg") == "true") { label_RenderingSubsystem->setEnabled(false); comboBox_rendersystem->setEnabled(false); @@ -209,29 +209,105 @@ void CSVSettings::SettingsDialog::setViewValues() else checkBox_override->setChecked(false); - if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "") - { - spinBox_x->setValue( - CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt()); - } + if(mModel->settingValue("Window Size/Width") != "") + spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); - if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "") - { - spinBox_y->setValue( - CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt()); - } + if(mModel->settingValue("Window Size/Height") != "") + spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt()); // update display resolution combo box - // FIXME: update opencs window size comboBox_std_window_size->clear(); comboBox_std_window_size->addItems(getAvailableResolutions()); - int index = comboBox_std_window_size->findData(getCurrentResolution(), + + QString currRes = mModel->settingValue("Window Size/Width") + " x " + + mModel->settingValue("Window Size/Height"); + + int index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) + { + // show the values in ini file comboBox_std_window_size->setCurrentIndex(index); + slotStandardToggled(true); + } + else + { + // show what's in Ogre instead + index = comboBox_std_window_size->findData(getCurrentOgreResolution(), + Qt::DisplayRole, + Qt::MatchStartsWith); + if(index != -1) + comboBox_std_window_size->setCurrentIndex(index); + + radioButton_custom_res->setChecked(true); + slotStandardToggled(false); + } +} - slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); +void CSVSettings::SettingsDialog::saveSettings() +{ +#if 0 + //setting the definition in the model automatically syncs with the file + foreach (const Page *page, mPages) + { + foreach (const View *view, page->views()) + { + if (!view->serializable()) + continue; + + mModel->setDefinitions (view->viewKey(), view->selectedValues()); + } + } +#endif + mModel->saveDefinitions(); +} + +void CSVSettings::SettingsDialog::createConnections + (const QList &list) +{ +#if 0 + foreach (const CSMSettings::Setting *setting, list) + { + View *masterView = findView (setting->page(), setting->name()); + + CSMSettings::Connector *connector = + new CSMSettings::Connector (masterView, this); + + connect (masterView, + SIGNAL (viewUpdated(const QString &, const QStringList &)), + connector, + SLOT (slotUpdateSlaves()) + ); + + const CSMSettings::ProxyValueMap &proxyMap = setting->proxyLists(); + + foreach (const QString &key, proxyMap.keys()) + { + QStringList keyPair = key.split('/'); + + if (keyPair.size() != 2) + continue; + + View *slaveView = findView (keyPair.at(0), keyPair.at(1)); + + if (!slaveView) + { + qWarning () << "Unable to create connection for view " + << key; + continue; + } + + QList proxyList = proxyMap.value (key); + connector->addSlaveView (slaveView, proxyList); + + connect (slaveView, + SIGNAL (viewUpdated(const QString &, const QStringList &)), + connector, + SLOT (slotUpdateMaster())); + } + } +#endif } void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) @@ -239,8 +315,9 @@ void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) //SettingWindow::closeEvent() must be called first to ensure //model is updated //SettingWindow::closeEvent (event); + QApplication::focusWidget()->clearFocus(); - //saveSettings(); + saveSettings(); } void CSVSettings::SettingsDialog::show() diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index d971b9c2a..c5c848b59 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -7,35 +7,47 @@ class QListWidgetItem; +namespace CSMSettings +{ + class Setting; + class UserSettings; +} + namespace CSVSettings { class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT + CSMSettings::UserSettings *mModel; + public: SettingsDialog (QTabWidget *parent = 0); - int windowWidth(); - int windowHeight(); - - ///Enables setting debug mode. When the dialog opens, a page is created - ///which displays the SettingModel's contents in a Tree view. - //void enableDebugMode (bool state, QStandardItemModel *model = 0); + ///set the model the view uses (instance of UserSettings) + void setModel (CSMSettings::UserSettings &model) { mModel = &model; } protected: + ///save settings from the GUI to file + void saveSettings(); + /// Settings are written on close void closeEvent (QCloseEvent *event); private: + ///sets the defined values for the views that have been created void setViewValues(); + ///create connections between settings (used for proxy settings) + void createConnections (const QList &list); + public slots: void show(); + void rendererChanged(); void slotStandardToggled(bool checked); }; From 62d2811285df434be726d08275de195a72a90775 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 07:52:54 +1000 Subject: [PATCH 09/90] Window size improvements. Added promoted widgets but seems to be require signal filters for disabled widgets to receive mouse events. --- apps/opencs/CMakeLists.txt | 4 +- apps/opencs/editor.cpp | 2 +- apps/opencs/model/settings/usersettings.cpp | 68 +++++- apps/opencs/model/settings/usersettings.hpp | 3 + apps/opencs/view/doc/view.cpp | 8 + apps/opencs/view/settings/clickcombobox.cpp | 9 + apps/opencs/view/settings/clickcombobox.hpp | 20 ++ apps/opencs/view/settings/clickspinbox.cpp | 11 + apps/opencs/view/settings/clickspinbox.hpp | 20 ++ apps/opencs/view/settings/settingsdialog.cpp | 223 +++++++++++++------ apps/opencs/view/settings/settingsdialog.hpp | 5 +- files/ui/settingstab.ui | 196 ++++++++++------ 12 files changed, 430 insertions(+), 139 deletions(-) create mode 100644 apps/opencs/view/settings/clickcombobox.cpp create mode 100644 apps/opencs/view/settings/clickcombobox.hpp create mode 100644 apps/opencs/view/settings/clickspinbox.cpp create mode 100644 apps/opencs/view/settings/clickspinbox.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 02a6c25a0..0ee7c1aea 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -109,6 +109,8 @@ opencs_units (view/settings rangeview resizeablestackedwidget spinbox + clickspinbox + clickcombobox ) opencs_units_noqt (view/settings @@ -166,7 +168,7 @@ qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} view/settings) if(APPLE) set (OPENCS_MAC_ICON ${CMAKE_SOURCE_DIR}/files/mac/opencs.icns) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 5fc2562ed..8590657ad 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -297,7 +297,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("Shiny/language").toStdString(); + std::string shLang = mUserSettings.settingValue("Shader/language").toStdString(); enum sh::Language lang; if(shLang == "CG") lang = sh::Language_CG; else if(shLang == "HLSL") lang = sh::Language_HLSL; diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index cd9bf6a33..e8ee98277 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -5,9 +5,12 @@ #include #include +#include #include +#include + #include "setting.hpp" #include "support.hpp" #include @@ -344,17 +347,76 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) #endif } mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); - // force shiny language based on render system + // force shader language based on render system if(renderSystem == "Direct3D9 Rendering Subsystem") - mSettingDefinitions->setValue("Shiny/language", "CG"); + mSettingDefinitions->setValue("Shader/language", "CG"); else - mSettingDefinitions->setValue("Shiny/language", "GLSL"); + mSettingDefinitions->setValue("Shader/language", "GLSL"); // check if override entry exists (default: override) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } +QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) +{ + QStringList result; + + Ogre::ConfigOptionMap& renderOpt = + //Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + + uint row = 0; + for(; it != renderOpt.end(); ++it, ++row) + { + Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); + uint idx = 0; + + for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) + { + if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) + { + result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + + QString::fromStdString((*opt_it).c_str()).simplified(); + } + } + } + + // Sort ascending + qSort(result.begin(), result.end(), naturalSortLessThanCI); + + // Replace the zero option with Off + int index = result.indexOf("MSAA 0"); + + if(index != -1) + result.replace(index, QObject::tr("Off")); + + return result; +} + +QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString &renderer) +{ + QStringList result; + + if(renderer == "Direct3D9 Rendering Subsystem") + { + result.append("CG"); + result.append("HLSL"); + result.append("None"); + } + else if(renderer == "OpenGL Rendering Subsystem") + { + result.append("GLSL"); + result.append("GLSLES"); + result.append("None"); + } + else + result.append("None"); + + return result; +} + bool CSMSettings::UserSettings::hasSettingDefinitions (const QString &viewKey) const { diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 9d9b5c9b0..b45fa3d83 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -76,6 +76,9 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; + QStringList getShaderLanguageByRenderer(const QString &renderer); + QStringList getOgreOptions(const QString &key, const QString &renderer); + private: void buildSettingModelDefaults(); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 349b1e037..2ac5d7236 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -32,6 +32,14 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) event->ignore(); else { + // save window size first + CSMSettings::UserSettings::instance().setDefinitions( + "Window Size/Width", + QStringList(QString::number(frameGeometry().width()))); + CSMSettings::UserSettings::instance().setDefinitions( + "Window Size/Height", + QStringList(QString::number(frameGeometry().height()))); + CSMSettings::UserSettings::instance().saveDefinitions(); // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); } diff --git a/apps/opencs/view/settings/clickcombobox.cpp b/apps/opencs/view/settings/clickcombobox.cpp new file mode 100644 index 000000000..f313ffe84 --- /dev/null +++ b/apps/opencs/view/settings/clickcombobox.cpp @@ -0,0 +1,9 @@ +#include "clickcombobox.hpp" + +#include + +void ClickComboBox::mouseReleaseEvent(QMouseEvent *e) +{ + emit mouseReleased(); +} + diff --git a/apps/opencs/view/settings/clickcombobox.hpp b/apps/opencs/view/settings/clickcombobox.hpp new file mode 100644 index 000000000..f3385f407 --- /dev/null +++ b/apps/opencs/view/settings/clickcombobox.hpp @@ -0,0 +1,20 @@ +#ifndef CSVSETTINGS_CLICKCOMBOBOX_H +#define CSVSETTINGS_CLICKCOMBOBOX_H + +#include +#include + +class ClickComboBox : public QComboBox +{ + Q_OBJECT + + public: + explicit ClickComboBox(QWidget *parent = 0) { } + void mouseReleaseEvent(QMouseEvent *e); + + signals: + void mouseReleased(); + +}; + +#endif /* CSVSETTINGS_CLICKCOMBOBOX_H */ diff --git a/apps/opencs/view/settings/clickspinbox.cpp b/apps/opencs/view/settings/clickspinbox.cpp new file mode 100644 index 000000000..e94b9b3d0 --- /dev/null +++ b/apps/opencs/view/settings/clickspinbox.cpp @@ -0,0 +1,11 @@ +#include "clickspinbox.hpp" + +#include +#include + +void ClickSpinBox::mouseReleaseEvent(QMouseEvent *e) +{ + std::cout << "emit" << std::endl; + emit mouseReleased(); +} + diff --git a/apps/opencs/view/settings/clickspinbox.hpp b/apps/opencs/view/settings/clickspinbox.hpp new file mode 100644 index 000000000..0db534e51 --- /dev/null +++ b/apps/opencs/view/settings/clickspinbox.hpp @@ -0,0 +1,20 @@ +#ifndef CSVSETTINGS_CLICKSPINBOX_H +#define CSVSETTINGS_CLICKSPINBOX_H + +#include +#include + +class ClickSpinBox : public QSpinBox +{ + Q_OBJECT + + public: + explicit ClickSpinBox(QWidget *parent = 0) { } + void mouseReleaseEvent(QMouseEvent *e); + + signals: + void mouseReleased(); + +}; + +#endif /* CSVSETTINGS_CLICKSPINBOX_H */ diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index b49ab2c34..34a6c5527 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -5,7 +5,6 @@ #include -#include #include "../../model/settings/usersettings.hpp" namespace @@ -49,14 +48,35 @@ QString getCurrentOgreResolution() if(it->first == "Video Mode" ) { QRegExp re("^(\\d+ x \\d+)"); - int pos = re.indexIn(it->second.currentValue.c_str(), 0); - if (pos > -1) + if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) return re.cap(1); } } return QString(); // found nothing } +bool customCompare(const QString &s1, const QString &s2) +{ + int x1, x2, y1, y2; + QRegExp re("^(\\d+) x (\\d+)"); + + if(re.indexIn(s1) > -1) + { + x1 = re.cap(1).toInt(); + y1 = re.cap(2).toInt(); + } + if(re.indexIn(s2) > -1) + { + x2 = re.cap(1).toInt(); + y2 = re.cap(2).toInt(); + } + + if(x1 == x2) + return y1 > y2; + else + return x1 > x2; +} + QStringList getAvailableResolutions() { // store available rendering devices and available resolutions @@ -93,8 +113,7 @@ QStringList getAvailableResolutions() { // extract x and y values QRegExp re("^(\\d+) x (\\d+)"); - int pos = re.indexIn((*iter).c_str(), 0); - if (pos > -1) + if(re.indexIn((*iter).c_str(), 0) > -1) { QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); QString resolution = re.cap(1) + QString(" x ") + re.cap(2); @@ -110,42 +129,7 @@ QStringList getAvailableResolutions() } } result.removeDuplicates(); - return result; -} - -QStringList getAvailableOptions(const QString &key) -{ - QStringList result; - - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - uint row = 0; - for(; it != renderOpt.end(); ++it, ++row) - { - Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); - uint idx = 0; - - for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) - { - if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) - { - result << ((key == "FSAA") ? QString("MSAA ") : QString("")) - + QString::fromStdString((*opt_it).c_str()).simplified(); - } - } - } - - // Sort ascending - qSort(result.begin(), result.end(), naturalSortLessThanCI); - - // Replace the zero option with Off - int index = result.indexOf("MSAA 0"); - - if(index != -1) - result.replace(index, QObject::tr("Off")); - + qStableSort(result.begin(), result.end(), customCompare); return result; } @@ -163,17 +147,75 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_x->setMaximum(res.width()); spinBox_y->setMaximum(res.height()); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged())); + connect(checkBox_override, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + + connect(comboBox_std_window_size, SIGNAL(mouseReleased()), this, SLOT(slotStandardClicked())); + connect(spinBox_x, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); + connect(spinBox_y, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); } -void CSVSettings::SettingsDialog::rendererChanged() +void CSVSettings::SettingsDialog::slotStandardClicked() +{ + std::cout << "click" << std::endl; + if(!radioButton_standard_res->isChecked()) + radioButton_standard_res->toggle(); +} + +void CSVSettings::SettingsDialog::slotCustomClicked() +{ + std::cout << "click" << std::endl; + if(radioButton_standard_res->isChecked()) + radioButton_standard_res->toggle(); +} + +void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) { comboBox_antialiasing->clear(); - comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); + comboBox_antialiasing->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); + + comboBox_shaderlanguage->clear(); + comboBox_shaderlanguage->addItems(mModel->getShaderLanguageByRenderer(renderer)); + + if(mModel->settingValue("Video/use settings.cfg") == "true") + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + } + else + checkBox_override->setChecked(false); +} + +void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) +{ + if(checked) + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + } + else + { + label_RenderingSubsystem->setEnabled(true); + comboBox_rendersystem->setEnabled(true); + label_Antialiasing->setEnabled(true); + comboBox_antialiasing->setEnabled(true); + checkBox_vsync->setEnabled(true); + label_ShaderLanguage->setEnabled(true); + comboBox_shaderlanguage->setEnabled(true); + } } -// FIXME: what to do with updating window size void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { if (checked) @@ -192,22 +234,28 @@ void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) void CSVSettings::SettingsDialog::setViewValues() { - //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); - rendererChanged(); // setup antialiasing options + int index = -1; - if(mModel->settingValue("Video/use settings.cfg") == "true") - { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + // initialised in the constructor + slotOverrideToggled(checkBox_override->isChecked()); - } - else - checkBox_override->setChecked(false); + // Ogre initialised earlier + slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + + // antialiasing + QString antialiasing = mModel->settingValue("Video/antialiasing"); + index = comboBox_antialiasing->findData(antialiasing, Qt::DisplayRole); + if(index != -1) + comboBox_antialiasing->setCurrentIndex(index); + + // vsync + checkBox_vsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + + // shader lang + QString shaderlang = mModel->settingValue("Shader/language"); + index = comboBox_shaderlanguage->findData(shaderlang, Qt::DisplayRole); + if(index != -1) + comboBox_shaderlanguage->setCurrentIndex(index); if(mModel->settingValue("Window Size/Width") != "") spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); @@ -222,9 +270,7 @@ void CSVSettings::SettingsDialog::setViewValues() QString currRes = mModel->settingValue("Window Size/Width") + " x " + mModel->settingValue("Window Size/Height"); - int index = comboBox_std_window_size->findData(currRes, - Qt::DisplayRole, - Qt::MatchStartsWith); + index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) { // show the values in ini file @@ -234,9 +280,7 @@ void CSVSettings::SettingsDialog::setViewValues() else { // show what's in Ogre instead - index = comboBox_std_window_size->findData(getCurrentOgreResolution(), - Qt::DisplayRole, - Qt::MatchStartsWith); + index = comboBox_std_window_size->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) comboBox_std_window_size->setCurrentIndex(index); @@ -260,6 +304,55 @@ void CSVSettings::SettingsDialog::saveSettings() } } #endif + std::cout << "closeEvent" << std::endl; + + // override + if(checkBox_override->isChecked()) + mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); + else + mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); + + // render system + mModel->setDefinitions("Video/render system", + QStringList(comboBox_rendersystem->currentText())); + + // vsync + if(checkBox_vsync->isChecked()) + mModel->setDefinitions("Video/vsync", QStringList("true")); + else + mModel->setDefinitions("Video/vsync", QStringList("false")); + + // antialiasing + mModel->setDefinitions("Video/antialiasing", + QStringList(comboBox_antialiasing->currentText())); +#if 0 + QRegExp reAA("^\\D*(\\d+)\\D*"); + if(reAA.indexIn(comboBox_antialiasing->currentText()) > -1) + mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); +#endif + + // shader lang + mModel->setDefinitions("Shader/language", + QStringList(comboBox_shaderlanguage->currentText())); + + // window size + if(radioButton_standard_res->isChecked()) + { + QRegExp re("^(\\d+) x (\\d+)"); + if(re.indexIn(comboBox_std_window_size->currentText()) > -1) + { + mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); + mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); + } + } + else + { + mModel->setDefinitions("Window Size/Width", + QStringList(QString::number(spinBox_x->value()))); + mModel->setDefinitions("Window Size/Height", + QStringList(QString::number(spinBox_y->value()))); + } + mModel->saveDefinitions(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index c5c848b59..737ebdb07 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -48,7 +48,10 @@ namespace CSVSettings { void show(); - void rendererChanged(); + void slotStandardClicked(); + void slotCustomClicked(); + void slotRendererChanged(const QString &renderer); + void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); }; } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2b1b561da..51566869a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -31,56 +31,63 @@ - + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + - + 186 16777215 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + - - - - Standard: - - - true + + + + + 180 + 0 + - - buttonGroup - - + - Custom; + Custom: buttonGroup - + - Window Size + - - - - - 180 - 0 - + + + + Standard: + + true + + + buttonGroup + @@ -108,10 +115,10 @@ - Display + Window Size - + 20 @@ -180,7 +187,7 @@ - HLSL + GLSL @@ -212,7 +219,7 @@ renderGroup - layoutWidget + layoutWidget_Render displayGroup layoutWidget_Screen @@ -220,34 +227,46 @@ Display Settings - + - 20 - 30 + 10 + 10 + 371 + 71 + + + + + + + + + + 9 + 110 + 371 + 111 + + + + Subviews + + + + + + 21 + 20 351 - 116 + 45 - - - - - Max Number of Subviews - - - - - - - Min Subview Width - - - - - + + + - Reuse Subviews + Display Format: @@ -265,11 +284,51 @@ - - + + + + Show Status Bar + + - + + + + + + 21 + 130 + 351 + 71 + + + + + + + Max Number of Subviews: + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Min Subview Width: + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + 325 @@ -281,29 +340,18 @@ - - + + - Show Icon + Reuse Subviews - - - - 10 - 10 - 371 - 151 - - - - GroupBox - - + groupBox_2 groupBox + layoutWidget layoutWidget2 @@ -312,6 +360,18 @@ + + + ClickSpinBox + QSpinBox +
clickspinbox.hpp
+
+ + ClickComboBox + QComboBox +
clickcombobox.hpp
+
+
From 86636bd960add71e66efd8e5c429321ea1df67b3 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 12:23:41 +1000 Subject: [PATCH 10/90] Mouse events to disabled objects implemented via a signal filter. --- apps/opencs/CMakeLists.txt | 4 +- apps/opencs/view/settings/clickcombobox.cpp | 9 - apps/opencs/view/settings/clickcombobox.hpp | 20 -- apps/opencs/view/settings/clickspinbox.cpp | 11 - apps/opencs/view/settings/clickspinbox.hpp | 20 -- apps/opencs/view/settings/settingsdialog.cpp | 165 +++++++------ apps/opencs/view/settings/settingsdialog.hpp | 6 +- files/ui/settingstab.ui | 230 +++++++++---------- 8 files changed, 204 insertions(+), 261 deletions(-) delete mode 100644 apps/opencs/view/settings/clickcombobox.cpp delete mode 100644 apps/opencs/view/settings/clickcombobox.hpp delete mode 100644 apps/opencs/view/settings/clickspinbox.cpp delete mode 100644 apps/opencs/view/settings/clickspinbox.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 0ee7c1aea..02a6c25a0 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -109,8 +109,6 @@ opencs_units (view/settings rangeview resizeablestackedwidget spinbox - clickspinbox - clickcombobox ) opencs_units_noqt (view/settings @@ -168,7 +166,7 @@ qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -include_directories(${CMAKE_CURRENT_BINARY_DIR} view/settings) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) if(APPLE) set (OPENCS_MAC_ICON ${CMAKE_SOURCE_DIR}/files/mac/opencs.icns) diff --git a/apps/opencs/view/settings/clickcombobox.cpp b/apps/opencs/view/settings/clickcombobox.cpp deleted file mode 100644 index f313ffe84..000000000 --- a/apps/opencs/view/settings/clickcombobox.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "clickcombobox.hpp" - -#include - -void ClickComboBox::mouseReleaseEvent(QMouseEvent *e) -{ - emit mouseReleased(); -} - diff --git a/apps/opencs/view/settings/clickcombobox.hpp b/apps/opencs/view/settings/clickcombobox.hpp deleted file mode 100644 index f3385f407..000000000 --- a/apps/opencs/view/settings/clickcombobox.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CSVSETTINGS_CLICKCOMBOBOX_H -#define CSVSETTINGS_CLICKCOMBOBOX_H - -#include -#include - -class ClickComboBox : public QComboBox -{ - Q_OBJECT - - public: - explicit ClickComboBox(QWidget *parent = 0) { } - void mouseReleaseEvent(QMouseEvent *e); - - signals: - void mouseReleased(); - -}; - -#endif /* CSVSETTINGS_CLICKCOMBOBOX_H */ diff --git a/apps/opencs/view/settings/clickspinbox.cpp b/apps/opencs/view/settings/clickspinbox.cpp deleted file mode 100644 index e94b9b3d0..000000000 --- a/apps/opencs/view/settings/clickspinbox.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "clickspinbox.hpp" - -#include -#include - -void ClickSpinBox::mouseReleaseEvent(QMouseEvent *e) -{ - std::cout << "emit" << std::endl; - emit mouseReleased(); -} - diff --git a/apps/opencs/view/settings/clickspinbox.hpp b/apps/opencs/view/settings/clickspinbox.hpp deleted file mode 100644 index 0db534e51..000000000 --- a/apps/opencs/view/settings/clickspinbox.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CSVSETTINGS_CLICKSPINBOX_H -#define CSVSETTINGS_CLICKSPINBOX_H - -#include -#include - -class ClickSpinBox : public QSpinBox -{ - Q_OBJECT - - public: - explicit ClickSpinBox(QWidget *parent = 0) { } - void mouseReleaseEvent(QMouseEvent *e); - - signals: - void mouseReleased(); - -}; - -#endif /* CSVSETTINGS_CLICKSPINBOX_H */ diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 34a6c5527..4c426ff6d 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -144,75 +144,90 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) // Set the maximum res we can set in windowed mode QRect res = getMaximumResolution(); - spinBox_x->setMaximum(res.width()); - spinBox_y->setMaximum(res.height()); + sbWidth->setMaximum(res.width()); + sbHeight->setMaximum(res.height()); - connect(checkBox_override, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + // to enable mouse events on disabled widgets + cmbStdWinSize->installEventFilter(this); + sbWidth->installEventFilter(this); + sbHeight->installEventFilter(this); - connect(comboBox_std_window_size, SIGNAL(mouseReleased()), this, SLOT(slotStandardClicked())); - connect(spinBox_x, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); - connect(spinBox_y, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); + connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); + connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); + connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } -void CSVSettings::SettingsDialog::slotStandardClicked() +bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { - std::cout << "click" << std::endl; - if(!radioButton_standard_res->isChecked()) - radioButton_standard_res->toggle(); -} + QWidget *item = qobject_cast(target); + if (target == cmbStdWinSize) + { + if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) + { + rbCustWinSize->setChecked(false); + rbStdWinSize->setChecked(true); + slotStandardToggled(true); -void CSVSettings::SettingsDialog::slotCustomClicked() -{ - std::cout << "click" << std::endl; - if(radioButton_standard_res->isChecked()) - radioButton_standard_res->toggle(); + return false; + } + } + else if (target == sbWidth || target == sbHeight) + { + if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) + { + rbStdWinSize->setChecked(false); + rbCustWinSize->setChecked(true); + slotStandardToggled(false); + + return false; + } + } + return QTabWidget::eventFilter(target, event); } void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) { - comboBox_antialiasing->clear(); - comboBox_antialiasing->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); + cmbAntiAlias->clear(); + cmbAntiAlias->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); - comboBox_shaderlanguage->clear(); - comboBox_shaderlanguage->addItems(mModel->getShaderLanguageByRenderer(renderer)); + cmbShaderLang->clear(); + cmbShaderLang->addItems(mModel->getShaderLanguageByRenderer(renderer)); if(mModel->settingValue("Video/use settings.cfg") == "true") { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); } else - checkBox_override->setChecked(false); + cbOverride->setChecked(false); } void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) { if(checked) { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); } else { - label_RenderingSubsystem->setEnabled(true); - comboBox_rendersystem->setEnabled(true); - label_Antialiasing->setEnabled(true); - comboBox_antialiasing->setEnabled(true); - checkBox_vsync->setEnabled(true); - label_ShaderLanguage->setEnabled(true); - comboBox_shaderlanguage->setEnabled(true); + labRenderSys->setEnabled(true); + cmbRenderSys->setEnabled(true); + labAntiAlias->setEnabled(true); + cmbAntiAlias->setEnabled(true); + cbVsync->setEnabled(true); + labShaderLang->setEnabled(true); + cmbShaderLang->setEnabled(true); } } @@ -220,15 +235,15 @@ void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { if (checked) { - comboBox_std_window_size->setEnabled(true); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); + cmbStdWinSize->setEnabled(true); + sbWidth->setEnabled(false); + sbHeight->setEnabled(false); } else { - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(true); - spinBox_y->setEnabled(true); + cmbStdWinSize->setEnabled(false); + sbWidth->setEnabled(true); + sbHeight->setEnabled(true); } } @@ -237,54 +252,54 @@ void CSVSettings::SettingsDialog::setViewValues() int index = -1; // initialised in the constructor - slotOverrideToggled(checkBox_override->isChecked()); + slotOverrideToggled(cbOverride->isChecked()); // Ogre initialised earlier slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = mModel->settingValue("Video/antialiasing"); - index = comboBox_antialiasing->findData(antialiasing, Qt::DisplayRole); + index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); if(index != -1) - comboBox_antialiasing->setCurrentIndex(index); + cmbAntiAlias->setCurrentIndex(index); // vsync - checkBox_vsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); // shader lang QString shaderlang = mModel->settingValue("Shader/language"); - index = comboBox_shaderlanguage->findData(shaderlang, Qt::DisplayRole); + index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); if(index != -1) - comboBox_shaderlanguage->setCurrentIndex(index); + cmbShaderLang->setCurrentIndex(index); if(mModel->settingValue("Window Size/Width") != "") - spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); + sbWidth->setValue(mModel->settingValue("Window Size/Width").toInt()); if(mModel->settingValue("Window Size/Height") != "") - spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt()); + sbHeight->setValue(mModel->settingValue("Window Size/Height").toInt()); // update display resolution combo box - comboBox_std_window_size->clear(); - comboBox_std_window_size->addItems(getAvailableResolutions()); + cmbStdWinSize->clear(); + cmbStdWinSize->addItems(getAvailableResolutions()); QString currRes = mModel->settingValue("Window Size/Width") + " x " + mModel->settingValue("Window Size/Height"); - index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) { // show the values in ini file - comboBox_std_window_size->setCurrentIndex(index); + cmbStdWinSize->setCurrentIndex(index); slotStandardToggled(true); } else { // show what's in Ogre instead - index = comboBox_std_window_size->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) - comboBox_std_window_size->setCurrentIndex(index); + cmbStdWinSize->setCurrentIndex(index); - radioButton_custom_res->setChecked(true); + rbCustWinSize->setChecked(true); slotStandardToggled(false); } } @@ -307,39 +322,39 @@ void CSVSettings::SettingsDialog::saveSettings() std::cout << "closeEvent" << std::endl; // override - if(checkBox_override->isChecked()) + if(cbOverride->isChecked()) mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); else mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); // render system mModel->setDefinitions("Video/render system", - QStringList(comboBox_rendersystem->currentText())); + QStringList(cmbRenderSys->currentText())); // vsync - if(checkBox_vsync->isChecked()) + if(cbVsync->isChecked()) mModel->setDefinitions("Video/vsync", QStringList("true")); else mModel->setDefinitions("Video/vsync", QStringList("false")); // antialiasing mModel->setDefinitions("Video/antialiasing", - QStringList(comboBox_antialiasing->currentText())); + QStringList(cmbAntiAlias->currentText())); #if 0 QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(comboBox_antialiasing->currentText()) > -1) + if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); #endif // shader lang mModel->setDefinitions("Shader/language", - QStringList(comboBox_shaderlanguage->currentText())); + QStringList(cmbShaderLang->currentText())); // window size - if(radioButton_standard_res->isChecked()) + if(rbStdWinSize->isChecked()) { QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(comboBox_std_window_size->currentText()) > -1) + if(re.indexIn(cmbStdWinSize->currentText()) > -1) { mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); @@ -348,9 +363,9 @@ void CSVSettings::SettingsDialog::saveSettings() else { mModel->setDefinitions("Window Size/Width", - QStringList(QString::number(spinBox_x->value()))); + QStringList(QString::number(sbWidth->value()))); mModel->setDefinitions("Window Size/Height", - QStringList(QString::number(spinBox_y->value()))); + QStringList(QString::number(sbHeight->value()))); } mModel->saveDefinitions(); diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 737ebdb07..07f5ebf24 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -36,6 +36,8 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); + bool eventFilter(QObject *target, QEvent *event); + private: ///sets the defined values for the views that have been created @@ -48,8 +50,8 @@ namespace CSVSettings { void show(); - void slotStandardClicked(); - void slotCustomClicked(); + //void slotStandardClicked(); + //void slotCustomClicked(); void slotRendererChanged(const QString &renderer); void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 51566869a..2cef67b0e 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -20,104 +20,6 @@ Video Settings - - - - 20 - 188 - 351 - 51 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 180 - 0 - - - - - - - - Custom: - - - buttonGroup - - - - - - - - - - - - - - Standard: - - - true - - - buttonGroup - - - - - - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 10 - 170 - 371 - 81 - - - - Window Size - - @@ -129,7 +31,7 @@ - + Use Render System Settings from OpenMW @@ -139,14 +41,14 @@ - + Rendering Subsystem - + false @@ -163,28 +65,28 @@ - + Antialiasing - + Vertical Sync - + Shader Language - + GLSL @@ -198,7 +100,7 @@ - + @@ -218,10 +120,108 @@ - renderGroup + + + + 20 + 188 + 351 + 51 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 180 + 0 + + + + + + + + Custom: + + + buttonGroup + + + + + + + + + + + + + + Standard: + + + true + + + buttonGroup + + + + + + + + + 10 + 8 + 371 + 156 + + + + Render System + + + + + + 10 + 170 + 371 + 81 + + + + Window Size + + + displayGroup_Render layoutWidget_Render - displayGroup - layoutWidget_Screen + displayGroup_Window + layoutWidget_Window @@ -360,18 +360,6 @@ - - - ClickSpinBox - QSpinBox -
clickspinbox.hpp
-
- - ClickComboBox - QComboBox -
clickcombobox.hpp
-
-
From d9b0c8129969b425d60830eb9816a79db5ec5fa7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 16:05:32 +1000 Subject: [PATCH 11/90] Show status bar setting working (feature #854). Turns out signals were not needed, may need to clean up later. --- apps/opencs/editor.cpp | 2 ++ apps/opencs/view/doc/view.cpp | 14 ++++++++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/doc/viewmanager.cpp | 11 +++++++++++ apps/opencs/view/doc/viewmanager.hpp | 2 ++ apps/opencs/view/settings/settingsdialog.cpp | 15 ++++++++++++++- apps/opencs/view/settings/settingsdialog.hpp | 4 ++++ files/ui/settingstab.ui | 2 +- 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 8590657ad..766726bce 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -55,6 +55,8 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ())); connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ())); + connect (&mSettings, SIGNAL (toggleStatusBar(bool)), &mViewManager, SLOT (toggleStatusBar(bool))); + connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)), this, SLOT(openFiles (const boost::filesystem::path&))); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 2ac5d7236..c7186a4e6 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -40,6 +40,7 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) "Window Size/Height", QStringList(QString::number(frameGeometry().height()))); CSMSettings::UserSettings::instance().saveDefinitions(); + // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); } @@ -442,6 +443,14 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view->useHint (hint); view->setStatusBar (mShowStatusBar->isChecked()); +// NOTE: only required if show status bar setting should be applied to existing +// window +#if 0 + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + + view->setStatusBar (showStatusBar == "true"); +#endif mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); @@ -662,6 +671,11 @@ void CSVDoc::View::toggleShowStatusBar (bool show) } } +void CSVDoc::View::toggleStatusBar(bool checked) +{ + mShowStatusBar->setChecked(checked); +} + void CSVDoc::View::loadErrorLog() { addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0)); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 9b4f2099b..e7c813c5c 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -106,6 +106,8 @@ namespace CSVDoc void updateProgress (int current, int max, int type, int threads); + void toggleStatusBar(bool checked); + Operations *getOperations() const; /// Function called by view manager when user preferences are updated diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 638b42d5f..d5e5e7027 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -140,6 +140,10 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) mViews.push_back (view); + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + + view->toggleStatusBar (showStatusBar == "true"); view->show(); connect (view, SIGNAL (newGameRequest ()), this, SIGNAL (newGameRequest())); @@ -388,6 +392,13 @@ bool CSVDoc::ViewManager::removeDocument (CSVDoc::View *view) return true; } +void CSVDoc::ViewManager::toggleStatusBar(bool checked) +{ + // NOTE: below only required if status bar change is to be applied to existing + //for (std::vector::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter) + //(*iter)->toggleStatusBar(checked); +} + void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view) { if(!removeDocument(view)) // close the current document first diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 753d7f0cb..61b807960 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -74,6 +74,8 @@ namespace CSVDoc void exitApplication (CSVDoc::View *view); + void toggleStatusBar(bool checked); + private slots: void documentStateChanged (int state, CSMDoc::Document *document); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 4c426ff6d..886ba6da6 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -155,6 +155,9 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + + // to update the checkbox on the view menu + connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); } bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) @@ -295,13 +298,17 @@ void CSVSettings::SettingsDialog::setViewValues() else { // show what's in Ogre instead - index = cmbStdWinSize->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(getCurrentOgreResolution(), + Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) cmbStdWinSize->setCurrentIndex(index); rbCustWinSize->setChecked(true); slotStandardToggled(false); } + + // status bar + cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true"); } void CSVSettings::SettingsDialog::saveSettings() @@ -368,6 +375,12 @@ void CSVSettings::SettingsDialog::saveSettings() QStringList(QString::number(sbHeight->value()))); } + // status bar + if(cbStatusBar->isChecked()) + mModel->setDefinitions("Display/show statusbar", QStringList("true")); + else + mModel->setDefinitions("Display/show statusbar", QStringList("false")); + mModel->saveDefinitions(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 07f5ebf24..3dda0700c 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -55,6 +55,10 @@ namespace CSVSettings { void slotRendererChanged(const QString &renderer); void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); + + signals: + + void toggleStatusBar(bool checked); }; } #endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2cef67b0e..0b365634e 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -285,7 +285,7 @@
- + Show Status Bar From 575780ec0d32a3dda6f08b201eb5d6fdf128ee46 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 17:13:53 +1000 Subject: [PATCH 12/90] Display format settings working. --- apps/opencs/view/settings/settingsdialog.cpp | 17 +++ files/ui/settingstab.ui | 133 ++++++++++++------- 2 files changed, 100 insertions(+), 50 deletions(-) diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 886ba6da6..8cd811e11 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -309,6 +309,17 @@ void CSVSettings::SettingsDialog::setViewValues() // status bar cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true"); + + // display format + QString recStat = mModel->settingValue("Display Format/Record Status Display"); + index = cmbRecStatus->findData(recStat, Qt::DisplayRole); + if(index != -1) + cmbRecStatus->setCurrentIndex(index); + + QString refIdType = mModel->settingValue("Display Format/Referenceable ID Type Display"); + index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); + if(index != -1) + cmbRefIdType->setCurrentIndex(index); } void CSVSettings::SettingsDialog::saveSettings() @@ -381,6 +392,12 @@ void CSVSettings::SettingsDialog::saveSettings() else mModel->setDefinitions("Display/show statusbar", QStringList("false")); + // display format + mModel->setDefinitions("Display Format/Record Status Display", + QStringList(cmbRecStatus->currentText())); + mModel->setDefinitions("Display Format/Referenceable ID Type Display", + QStringList(cmbRefIdType->currentText())); + mModel->saveDefinitions(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 0b365634e..ab559d9e7 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -227,24 +227,88 @@ Display Settings - + 10 10 371 - 71 + 81 - + Display Format + + + + 10 + 20 + 351 + 48 + + + + + + + Record Status: + + + + + + + + Text Only + + + + + Icon Only + + + + + Icon and Text + + + + + + + + Referenceable ID Type: + + + + + + + + Text Only + + + + + Icon Only + + + + + Icon and Text + + + + + + - + 9 - 110 + 140 371 111 @@ -253,51 +317,11 @@ Subviews - - - - 21 - 20 - 351 - 45 - - - - - - - Display Format: - - - - - - - - Text Only - - - - - Text + Icon - - - - - - - - Show Status Bar - - - - - 21 - 130 + 160 351 71 @@ -349,10 +373,19 @@ - groupBox_2 - groupBox - layoutWidget - layoutWidget2 + + + + 20 + 110 + 102 + 17 + + + + Show Status Bar + + From 52354b14fc308cccd07086c43e04db43fcc43368 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 22:17:37 +1000 Subject: [PATCH 13/90] Fixed compilation issue on linux. Updated shader mode selection logic (thanks scrawl). Cleaned up a little but needs more once things are settled. --- apps/opencs/editor.cpp | 12 ++--- apps/opencs/model/settings/usersettings.cpp | 49 +++++++++++++------- apps/opencs/model/settings/usersettings.hpp | 1 + apps/opencs/view/settings/settingsdialog.cpp | 24 ++++++---- files/ui/settingstab.ui | 10 ---- 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 766726bce..d4ea32b26 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -299,14 +299,12 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("Shader/language").toStdString(); + std::string shLang = mUserSettings.settingValue("General/shader mode").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; + if(shLang == "glsl") lang = sh::Language_GLSL; + else if(shLang == "glsles") lang = sh::Language_GLSLES; + else if(shLang == "hlsl") lang = sh::Language_HLSL; + else lang = sh::Language_CG; factory->setCurrentLanguage (lang); factory->setWriteSourceCache (true); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e8ee98277..64d69eab8 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -347,24 +347,49 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) #endif } mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); + + std::string currShader = settings.getString("shader mode", "General"); + // can't call Ogre::Root at this point as it hasn't been initialised + QString rend = renderSystem.c_str(); + bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); + bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); + // force shader language based on render system - if(renderSystem == "Direct3D9 Rendering Subsystem") - mSettingDefinitions->setValue("Shader/language", "CG"); - else - mSettingDefinitions->setValue("Shader/language", "GLSL"); + if(currShader == "" + || (openGL && currShader == "hlsl") + || (!openGL && currShader == "glsl") + || (glES && currShader != "glsles")) + { + QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; + mSettingDefinitions->setValue("General/shader mode", shader); + } // check if override entry exists (default: override) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } +QStringList CSMSettings::UserSettings::getOgreRenderers() +{ + QStringList result; + + Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); + Ogre::RenderSystemList::iterator it = renderers.begin(); + for(; it != renderers.end(); ++it) + result.append((*it)->getName().c_str()); + + return result; +} + QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; - Ogre::ConfigOptionMap& renderOpt = - //Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())->getConfigOptions(); + Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystem(); + if(!rend) + return result; + + Ogre::ConfigOptionMap& renderOpt = rend->getConfigOptions(); Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); uint row = 0; @@ -400,19 +425,11 @@ QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString QStringList result; if(renderer == "Direct3D9 Rendering Subsystem") - { - result.append("CG"); result.append("HLSL"); - result.append("None"); - } else if(renderer == "OpenGL Rendering Subsystem") - { result.append("GLSL"); + else if(renderer.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive))) result.append("GLSLES"); - result.append("None"); - } - else - result.append("None"); return result; } diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index b45fa3d83..c957cd5b6 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -78,6 +78,7 @@ namespace CSMSettings { QStringList getShaderLanguageByRenderer(const QString &renderer); QStringList getOgreOptions(const QString &key, const QString &renderer); + QStringList getOgreRenderers(); private: diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 8cd811e11..bd39056c2 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -93,7 +93,7 @@ QStringList getAvailableResolutions() return result; // FIXME: add error message } // Store Available Rendering Devices - std::vector::iterator iter = it->second.possibleValues.begin(); + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(;iter != it->second.possibleValues.end(); ++iter) { std::cout << "rd: " << *iter << std::endl; // FIXME: debug @@ -108,7 +108,7 @@ QStringList getAvailableResolutions() // FIXME: how to default to the current value? std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions - std::vector::iterator iter = it->second.possibleValues.begin(); + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(; iter != it->second.possibleValues.end(); ++iter) { // extract x and y values @@ -202,7 +202,7 @@ void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - cbVsync->setEnabled(false); + //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -218,7 +218,7 @@ void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - cbVsync->setEnabled(false); + //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -228,7 +228,7 @@ void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(true); labAntiAlias->setEnabled(true); cmbAntiAlias->setEnabled(true); - cbVsync->setEnabled(true); + //cbVsync->setEnabled(true); labShaderLang->setEnabled(true); cmbShaderLang->setEnabled(true); } @@ -257,8 +257,10 @@ void CSVSettings::SettingsDialog::setViewValues() // initialised in the constructor slotOverrideToggled(cbOverride->isChecked()); - // Ogre initialised earlier - slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + // Ogre renderer + cmbRenderSys->clear(); + cmbRenderSys->addItems(mModel->getOgreRenderers()); + //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = mModel->settingValue("Video/antialiasing"); @@ -267,10 +269,12 @@ void CSVSettings::SettingsDialog::setViewValues() cmbAntiAlias->setCurrentIndex(index); // vsync - cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + //cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(false); // disable vsync option for now + cbVsync->setEnabled(false); // disable vsync option for now // shader lang - QString shaderlang = mModel->settingValue("Shader/language"); + QString shaderlang = mModel->settingValue("General/shader mode"); index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); if(index != -1) cmbShaderLang->setCurrentIndex(index); @@ -366,7 +370,7 @@ void CSVSettings::SettingsDialog::saveSettings() // shader lang mModel->setDefinitions("Shader/language", - QStringList(cmbShaderLang->currentText())); + QStringList(cmbShaderLang->currentText().toLower())); // window size if(rbStdWinSize->isChecked()) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index ab559d9e7..c818e3c7d 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -52,16 +52,6 @@ false - - - OpenGL Rendering Subsystem - - - - - Direct3D9 Rendering Subsystem - - From 5dfcd2ed01e7fe0ab4225848a28e4d4cbb10acf2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 19 Sep 2014 08:29:06 +1000 Subject: [PATCH 14/90] Removed standard window size combobox. Rearranged widgets. --- apps/opencs/model/settings/usersettings.cpp | 17 +- apps/opencs/model/settings/usersettings.hpp | 2 + apps/opencs/view/settings/settingsdialog.cpp | 20 +-- files/ui/settingstab.ui | 178 ++++++++----------- 4 files changed, 98 insertions(+), 119 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 64d69eab8..b3f17a4ff 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -371,21 +371,22 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) QStringList CSMSettings::UserSettings::getOgreRenderers() { - QStringList result; - - Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); - Ogre::RenderSystemList::iterator it = renderers.begin(); - for(; it != renderers.end(); ++it) - result.append((*it)->getName().c_str()); + if(mOgreRenderers.empty()) + { + Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); + Ogre::RenderSystemList::iterator it = renderers.begin(); + for(; it != renderers.end(); ++it) + mOgreRenderers.append((*it)->getName().c_str()); + } - return result; + return mOgreRenderers; } QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; - Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystem(); + Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()); if(!rend) return result; diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index c957cd5b6..dfefb131a 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -35,6 +35,8 @@ namespace CSMSettings { QSettings *mSettingDefinitions; QSettings *mSettingCfgDefinitions; QList mSettings; + QStringList mOgreRenderers; + public: diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index bd39056c2..7d5e5bec5 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -154,7 +154,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + //connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); // to update the checkbox on the view menu connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); @@ -167,9 +167,9 @@ bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) { - rbCustWinSize->setChecked(false); - rbStdWinSize->setChecked(true); - slotStandardToggled(true); + //rbCustWinSize->setChecked(false); + //rbStdWinSize->setChecked(true); + //slotStandardToggled(true); return false; } @@ -178,9 +178,9 @@ bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) { - rbStdWinSize->setChecked(false); - rbCustWinSize->setChecked(true); - slotStandardToggled(false); + //rbStdWinSize->setChecked(false); + //rbCustWinSize->setChecked(true); + //slotStandardToggled(false); return false; } @@ -307,7 +307,7 @@ void CSVSettings::SettingsDialog::setViewValues() if(index != -1) cmbStdWinSize->setCurrentIndex(index); - rbCustWinSize->setChecked(true); + //rbCustWinSize->setChecked(true); slotStandardToggled(false); } @@ -369,11 +369,11 @@ void CSVSettings::SettingsDialog::saveSettings() #endif // shader lang - mModel->setDefinitions("Shader/language", + mModel->setDefinitions("General/shader mode", QStringList(cmbShaderLang->currentText().toLower())); // window size - if(rbStdWinSize->isChecked()) + if(0) //rbStdWinSize->isChecked()) { QRegExp re("^(\\d+) x (\\d+)"); if(re.indexIn(cmbStdWinSize->currentText()) > -1) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index c818e3c7d..f5b0e6a5b 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -14,7 +14,7 @@ User Settings - 0 + 1 @@ -76,18 +76,7 @@ - - - - GLSL - - - - - CG - - - + @@ -110,78 +99,6 @@ - - - - 20 - 188 - 351 - 51 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 180 - 0 - - - - - - - - Custom: - - - buttonGroup - - - - - - - - - - - - - - Standard: - - - true - - - buttonGroup - - - - - @@ -195,23 +112,22 @@ Render System - + - 10 - 170 + 9 + 169 371 - 81 + 101 - Window Size + Shader displayGroup_Render layoutWidget_Render - displayGroup_Window - layoutWidget_Window + groupBox @@ -229,7 +145,7 @@ Display Format - + 10 @@ -298,9 +214,9 @@ 9 - 140 + 160 371 - 111 + 101 @@ -311,7 +227,7 @@ 21 - 160 + 180 351 71 @@ -363,11 +279,56 @@ + + + + 10 + 100 + 191 + 51 + + + + Window Size + + + + + 10 + 20 + 171 + 22 + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + - 20 - 110 + 240 + 120 102 17 @@ -376,16 +337,31 @@ Show Status Bar + displayGroup_Window + displayGroup_DisplayFormat + displayGroup_Subviews + layoutWidget2 + cbStatusBar Misc Settings + + + false + + + + 70 + 100 + 69 + 22 + + + - - - From dbd1ab05d3d47754b29e127f1cde300477a9e304 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 21 Sep 2014 20:55:52 +1000 Subject: [PATCH 15/90] Integrated into the original settings design, except using tabs rather than list & stacked widgets. Works but visuals need updating. --- apps/opencs/CMakeLists.txt | 1 - apps/opencs/editor.hpp | 4 +- apps/opencs/model/settings/setting.cpp | 13 +- apps/opencs/model/settings/setting.hpp | 5 +- apps/opencs/model/settings/support.hpp | 12 +- apps/opencs/model/settings/usersettings.cpp | 181 ++++++- apps/opencs/view/settings/dialog.cpp | 375 +++++++++++++- apps/opencs/view/settings/dialog.hpp | 30 +- apps/opencs/view/settings/settingsdialog.cpp | 486 ------------------- apps/opencs/view/settings/settingsdialog.hpp | 64 --- apps/opencs/view/settings/settingwindow.cpp | 168 ++++++- apps/opencs/view/settings/settingwindow.hpp | 9 +- files/ui/settingstab.ui | 108 +++-- 13 files changed, 790 insertions(+), 666 deletions(-) delete mode 100644 apps/opencs/view/settings/settingsdialog.cpp delete mode 100644 apps/opencs/view/settings/settingsdialog.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 02a6c25a0..ad04b8a37 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -98,7 +98,6 @@ opencs_units_noqt (view/tools ) opencs_units (view/settings - settingsdialog settingwindow dialog page diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 4ccc61a02..c87e24e77 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -26,7 +26,7 @@ #include "view/doc/filedialog.hpp" #include "view/doc/newgame.hpp" -#include "view/settings/settingsdialog.hpp" +#include "view/settings/dialog.hpp" namespace OgreInit { @@ -46,7 +46,7 @@ namespace CS CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; CSVDoc::NewGameDialogue mNewGame; - CSVSettings::SettingsDialog mSettings; + CSVSettings::Dialog mSettings; CSVDoc::FileDialog mFileDialog; boost::filesystem::path mLocal; boost::filesystem::path mResources; diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 2f86d4ff8..9e1b497b1 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -2,7 +2,7 @@ #include "support.hpp" CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, - const QString &pageName) + const QString &pageName, const QString §ion) : mIsEditorSetting (false) { buildDefaultSetting(); @@ -17,6 +17,7 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, setProperty (Property_SettingType, QVariant (settingType).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); + setProperty (Property_Section, section); } void CSMSettings::Setting::buildDefaultSetting() @@ -194,6 +195,16 @@ QString CSMSettings::Setting::page() const return property (Property_Page).at(0); } +void CSMSettings::Setting::setSection (const QString &value) +{ + setProperty (Property_Section, value); +} + +QString CSMSettings::Setting::section() const +{ + return property (Property_Section).at(0); +} + void CSMSettings::Setting::setPrefix (const QString &value) { setProperty (Property_Prefix, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index e40302f00..ed897e591 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -30,7 +30,7 @@ namespace CSMSettings public: explicit Setting(SettingType typ, const QString &settingName, - const QString &pageName); + const QString &pageName, const QString §ion = QString()); void addProxy (const Setting *setting, const QStringList &vals); void addProxy (const Setting *setting, const QList &list); @@ -80,6 +80,9 @@ namespace CSMSettings void setPage (const QString &value); QString page() const; + void setSection (const QString &value); + QString section() const; + void setPrefix (const QString &value); QString prefix() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 229e293b8..40db648dc 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -35,12 +35,13 @@ namespace CSMSettings Property_TickInterval = 19, Property_TicksAbove = 20, Property_TicksBelow = 21, + Property_Section = 22, //Stringlists should always be the last items - Property_DefaultValues = 22, - Property_DeclaredValues = 23, - Property_DefinedValues = 24, - Property_Proxies = 25 + Property_DefaultValues = 23, + Property_DeclaredValues = 24, + Property_DefinedValues = 25, + Property_Proxies = 26 }; ///Basic setting widget types. @@ -106,7 +107,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", + "tick_interval", "ticks_above", "ticks_below", "section", "defaults", "declarations", "definitions", "proxies" }; @@ -135,6 +136,7 @@ namespace CSMSettings "1", //tick interval "false", //ticks above "true", //ticks below + "", //Section "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index b3f17a4ff..664865289 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -32,9 +32,12 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ -CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; +namespace CSMSettings +{ + +UserSettings *UserSettings::mUserSettingsInstance = 0; -CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) +UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) : mCfgMgr (configurationManager) , mSettingDefinitions(NULL) , mSettingCfgDefinitions(NULL) @@ -48,9 +51,138 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -void CSMSettings::UserSettings::buildSettingModelDefaults() +/* + * Original Design: + * + * + * QGridLayout QGroupBox + * ^ ^ + * | | + * | 1 | + * SettingLayout......Frame + * ^ ^ QMainWindow + * | | ^ QObject + * / \ | ^ + * / \ | | + * / \ 0..n | | 0..n + * View......Page........SettingWindow......UserSettings......Setting + * ^ 0..n ^ + * | | + * | | + * ListView, | + * TextView, etc | + * | + * | + * QStackedWidget QListWidget.....Dialog + * ^ : + * | : + * | : + * ResizeableStackedWidget..... + * + * + * When a Page is created with a list of Views, the Views are added to the Frame. + * + * Editor ctor + * -> Dialog ctor + * -> SettingWindow ctor + * -> SettingWindow::setModel() + * -> Dialog::setupDialog() + * -> buildPageListWidget + * -> buildStackedWidget + * + * Editor::showSettings() + * -> Dialog::show() + * -> Dialog::buildPages() <-- [first time only] + * -> SettingWindow::createPages() + * -> Page ctor + * -> Page::setupViews() + * -> Page::addView() + * -> Frame::addWidget() + * -> SettingLayout::addWidget() + * -> [add page widgets to the stack] + * + */ +/* + * Modified Design: + * + * +----------------------------------------+ + * |+---------+---------+---------+ | + * || | | | | + * || +----------------------------+| + * || || + * || +--------------------------------+ || + * || | | || + * || | View View | || + * || | View View | || + * || | | || + * || +---- Section -------------------+ || + * || || + * || +--------------------------------+ || + * || | | || + * || | +-------------+ | || + * || | | View/Frame | | || + * || | +-------------+ | || + * || | | || + * || +---- Section -------------------+ || + * || || + * || || + * |+-------------- Page ------------------+| + * +---------- SettingWindow ---------------+ + * + * + * + * QGridLayout QGroupBox + * ^ ^ + * | | + * | 1 | + * SettingLayout......Frame + * ^ ^ QTabWidget + * | | ^ QObject + * / \ | ^ + * / \ | | + * / \ 0..n | | 0..n + * View......Page........SettingWindow......UserSettings......Setting + * ^ 0..n ^ + * | | + * | Ui::TabWidget | + * ListView, ^ | + * TextView, etc | | + * \ | + * \ | + * \ | + * Dialog + * + * + * + * + * + * View/Page is still used to uniquely identify a setting (i.e. Section is for + * visual presentation only). This means all views on a page should be unique + * (as before) + * + * + * Editor ctor + * -> Dialog ctor + * -> SettingWindow ctor + * -> SettingWindow::setModel() + * -> Dialog::setupDialog() <-- [no longer required] + * + * Editor::showSettings() + * -> Dialog::show() + * -> Dialog::buildPages() <-- [first time only] + * -> SettingWindow::createPages() + * -> Page ctor + * -> Page::setupViews() + * -> Page::addView() + * -> Frame::addWidget() + * -> SettingLayout::addWidget() + * -> [add pages to tabs then call showWidgets()] + */ +void UserSettings::buildSettingModelDefaults() { - QString section = "Window Size"; + QString section; + + section = "Window Size"; { Setting *width = createSetting (Type_LineEdit, section, "Width"); Setting *height = createSetting (Type_LineEdit, section, "Height"); @@ -283,12 +415,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() } } -CSMSettings::UserSettings::~UserSettings() +UserSettings::~UserSettings() { mUserSettingsInstance = 0; } -void CSMSettings::UserSettings::loadSettings (const QString &fileName) +void UserSettings::loadSettings (const QString &fileName) { QString userFilePath = QString::fromUtf8 (mCfgMgr.getUserConfigPath().string().c_str()); @@ -369,7 +501,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } -QStringList CSMSettings::UserSettings::getOgreRenderers() +QStringList UserSettings::getOgreRenderers() { if(mOgreRenderers.empty()) { @@ -382,7 +514,7 @@ QStringList CSMSettings::UserSettings::getOgreRenderers() return mOgreRenderers; } -QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) +QStringList UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; @@ -421,7 +553,7 @@ QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const return result; } -QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString &renderer) +QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) { QStringList result; @@ -435,24 +567,22 @@ QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString return result; } -bool CSMSettings::UserSettings::hasSettingDefinitions - (const QString &viewKey) const +bool UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); } -void CSMSettings::UserSettings::setDefinitions - (const QString &key, const QStringList &list) +void UserSettings::setDefinitions (const QString &key, const QStringList &list) { mSettingDefinitions->setValue (key, list); } -void CSMSettings::UserSettings::saveDefinitions() const +void UserSettings::saveDefinitions() const { mSettingDefinitions->sync(); } -QString CSMSettings::UserSettings::settingValue (const QString &settingKey) +QString UserSettings::settingValue (const QString &settingKey) { QStringList defs; @@ -480,22 +610,20 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey) return defs.at(0); } -CSMSettings::UserSettings& CSMSettings::UserSettings::instance() +UserSettings& UserSettings::instance() { assert(mUserSettingsInstance); return *mUserSettingsInstance; } -void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, - const QStringList &list) +void UserSettings::updateUserSetting(const QString &settingKey, const QStringList &list) { mSettingDefinitions->setValue (settingKey ,list); emit userSettingUpdated (settingKey, list); } -CSMSettings::Setting *CSMSettings::UserSettings::findSetting - (const QString &pageName, const QString &settingName) +Setting *UserSettings::findSetting (const QString &pageName, const QString &settingName) { foreach (Setting *setting, mSettings) { @@ -508,8 +636,7 @@ CSMSettings::Setting *CSMSettings::UserSettings::findSetting return 0; } -void CSMSettings::UserSettings::removeSetting - (const QString &pageName, const QString &settingName) +void UserSettings::removeSetting (const QString &pageName, const QString &settingName) { if (mSettings.isEmpty()) return; @@ -530,7 +657,7 @@ void CSMSettings::UserSettings::removeSetting } } -CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const +SettingPageMap UserSettings::settingPageMap() const { SettingPageMap pageMap; @@ -540,8 +667,8 @@ CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const return pageMap; } -CSMSettings::Setting *CSMSettings::UserSettings::createSetting - (CSMSettings::SettingType typ, const QString &page, const QString &name) +Setting *UserSettings::createSetting + (SettingType typ, const QString &page, const QString &name) { //get list of all settings for the current setting name if (findSetting (page, name)) @@ -560,10 +687,12 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting return setting; } -QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const +QStringList UserSettings::definitions (const QString &viewKey) const { if (mSettingDefinitions->contains (viewKey)) return mSettingDefinitions->value (viewKey).toStringList(); return QStringList(); } + +} diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 72a022c9d..e9ae194ce 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,39 +1,233 @@ #include "dialog.hpp" -#include +//#include #include +#include #include -#include -#include +//#include +//#include #include "../../model/settings/usersettings.hpp" #include "page.hpp" -#include +//#include -#include +//#include -#include -#include -#include +//#include +//#include +//#include #include #include -CSVSettings::Dialog::Dialog(QMainWindow *parent) - : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) +#include +#include + +namespace { + +QRect getMaximumResolution() +{ + QRect max; + int screens = QApplication::desktop()->screenCount(); + for(int i = 0; i < screens; ++i) + { + QRect res = QApplication::desktop()->screenGeometry(i); + if(res.width() > max.width()) + max.setWidth(res.width()); + if(res.height() > max.height()) + max.setHeight(res.height()); + } + return max; +} + +QString getAspect(int x, int y) +{ + int gcd = boost::math::gcd (x, y); + int xaspect = x / gcd; + int yaspect = y / gcd; + // special case: 8 : 5 is usually referred to as 16:10 + if (xaspect == 8 && yaspect == 5) + return QString("16:10"); + + return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); +} + +QString getCurrentOgreResolution() +{ + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + for(; it != renderOpt.end(); ++it) + { + if(it->first == "Video Mode" ) + { + QRegExp re("^(\\d+ x \\d+)"); + if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) + return re.cap(1); + } + } + return QString(); // found nothing +} + +bool customCompare(const QString &s1, const QString &s2) +{ + int x1, x2, y1, y2; + QRegExp re("^(\\d+) x (\\d+)"); + + if(re.indexIn(s1) > -1) + { + x1 = re.cap(1).toInt(); + y1 = re.cap(2).toInt(); + } + if(re.indexIn(s2) > -1) + { + x2 = re.cap(1).toInt(); + y2 = re.cap(2).toInt(); + } + + if(x1 == x2) + return y1 > y2; + else + return x1 > x2; +} + +QStringList getAvailableResolutions() { - setWindowTitle(QString::fromUtf8 ("User Settings")); + // store available rendering devices and available resolutions + QStringList result; + + Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + for(;it != renderOpt.end(); ++it) + { + if(it->first == "Rendering Device" ) + { + if(it->second.possibleValues.empty()) + { + return result; // FIXME: add error message + } + // Store Available Rendering Devices + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + std::cout << "rd: " << *iter << std::endl; // FIXME: debug + } + } + if(it->first == "Video Mode" ) + { + if(it->second.possibleValues.empty()) + { + return result; // FIXME: add error message + } + // FIXME: how to default to the current value? + std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug + // Store Available Resolutions + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); + for(; iter != it->second.possibleValues.end(); ++iter) + { + // extract x and y values + QRegExp re("^(\\d+) x (\\d+)"); + if(re.indexIn((*iter).c_str(), 0) > -1) + { + QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); + QString resolution = re.cap(1) + QString(" x ") + re.cap(2); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { + resolution.append(QObject::tr("\t(Wide ") + aspect + ")"); + + } else if (aspect == QLatin1String("4:3")) { + resolution.append(QObject::tr("\t(Standard 4:3)")); + } + result.append(resolution); + } + } + } + } + result.removeDuplicates(); + qStableSort(result.begin(), result.end(), customCompare); + return result; +} + +} + + +CSVSettings::Dialog::Dialog(QTabWidget *parent) + : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) +{ + setObjectName(QString::fromUtf8 ("User Settings")); + + setupUi(this); + + // Set the maximum res we can set in windowed mode + QRect res = getMaximumResolution(); + sbWidth->setMaximum(res.width()); + sbHeight->setMaximum(res.height()); + + connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); + connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); + // to update the checkbox on the view menu + connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); setupDialog(); +#if 0 + // FIXME: delete - don't need this for tabs connect (mPageListWidget, SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); +#endif +} + +void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) +{ + cmbAntiAlias->clear(); + cmbAntiAlias->addItems(model()->getOgreOptions(QString("FSAA"), renderer)); + + cmbShaderLang->clear(); + cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); + + if(model()->settingValue("Video/use settings.cfg") == "true") + { + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + //cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); + } + else + cbOverride->setChecked(false); +} + +void CSVSettings::Dialog::slotOverrideToggled(bool checked) +{ + if(checked) + { + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + //cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); + } + else + { + labRenderSys->setEnabled(true); + cmbRenderSys->setEnabled(true); + labAntiAlias->setEnabled(true); + cmbAntiAlias->setEnabled(true); + //cbVsync->setEnabled(true); + labShaderLang->setEnabled(true); + cmbShaderLang->setEnabled(true); + } } +#if 0 +// FIXME: delete - not required for tabs void CSVSettings::Dialog::slotChangePage (QListWidgetItem *cur, QListWidgetItem *prev) { @@ -43,9 +237,11 @@ void CSVSettings::Dialog::slotChangePage layout()->activate(); setFixedSize(minimumSizeHint()); } +#endif void CSVSettings::Dialog::setupDialog() { +#if 0 //create central widget with it's layout and immediate children QWidget *centralWidget = new QGroupBox (this); @@ -56,29 +252,112 @@ void CSVSettings::Dialog::setupDialog() buildPageListWidget (centralWidget); buildStackedWidget (centralWidget); +#endif } void CSVSettings::Dialog::buildPages() { + int index = -1; + + // initialised in the constructor + slotOverrideToggled(cbOverride->isChecked()); + + // Ogre renderer + cmbRenderSys->clear(); + cmbRenderSys->addItems(model()->getOgreRenderers()); + //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + + // antialiasing + QString antialiasing = model()->settingValue("Video/antialiasing"); + index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); + if(index != -1) + cmbAntiAlias->setCurrentIndex(index); + + // vsync + //cbVsync->setChecked(model()->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(false); // disable vsync option for now + cbVsync->setEnabled(false); // disable vsync option for now + + // shader lang + QString shaderlang = model()->settingValue("General/shader mode"); + index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); + if(index != -1) + cmbShaderLang->setCurrentIndex(index); + + if(model()->settingValue("Window Size/Width") != "") + sbWidth->setValue(model()->settingValue("Window Size/Width").toInt()); + + if(model()->settingValue("Window Size/Height") != "") + sbHeight->setValue(model()->settingValue("Window Size/Height").toInt()); + + // update display resolution combo box + cmbStdWinSize->clear(); + cmbStdWinSize->addItems(getAvailableResolutions()); + + QString currRes = model()->settingValue("Window Size/Width") + " x " + + model()->settingValue("Window Size/Height"); + + index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); + if(index != -1) + { + // show the values in ini file + cmbStdWinSize->setCurrentIndex(index); + //slotStandardToggled(true); + } + else + { + // show what's in Ogre instead + index = cmbStdWinSize->findData(getCurrentOgreResolution(), + Qt::DisplayRole, Qt::MatchStartsWith); + if(index != -1) + cmbStdWinSize->setCurrentIndex(index); + + //rbCustWinSize->setChecked(true); + //slotStandardToggled(false); + } + + // status bar + cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); + + // display format + QString recStat = model()->settingValue("Display Format/Record Status Display"); + index = cmbRecStatus->findData(recStat, Qt::DisplayRole); + if(index != -1) + cmbRecStatus->setCurrentIndex(index); + + QString refIdType = model()->settingValue("Display Format/Referenceable ID Type Display"); + index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); + if(index != -1) + cmbRefIdType->setCurrentIndex(index); + SettingWindow::createPages (); - QFontMetrics fm (QApplication::font()); + //QFontMetrics fm (QApplication::font()); foreach (Page *page, SettingWindow::pages()) { QString pageName = page->objectName(); - int textWidth = fm.width(pageName); + //int textWidth = fm.width(pageName); + + // each page is added as a tab to Ui::TabWiget + addTab(page, page->objectName()); + + // add section and views to the page + buildTabPage(page); + page->showWidgets(); - new QListWidgetItem (pageName, mPageListWidget); - mPageListWidget->setFixedWidth (textWidth + 50); + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); - mStackedWidget->addWidget (&dynamic_cast(*(page))); + //mStackedWidget->addWidget (&dynamic_cast(*(page))); } - resize (mStackedWidget->sizeHint()); + //resize (mStackedWidget->sizeHint()); } +#if 0 +// FIXME: delete - not required, using tabs instead void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) { mPageListWidget = new QListWidget (centralWidget); @@ -96,6 +375,7 @@ void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) centralWidget->layout()->addWidget (mStackedWidget); } +#endif void CSVSettings::Dialog::closeEvent (QCloseEvent *event) { @@ -103,6 +383,67 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) //model is updated SettingWindow::closeEvent (event); + // override + if(cbOverride->isChecked()) + model()->setDefinitions("Video/use settings.cfg", QStringList("true")); + else + model()->setDefinitions("Video/use settings.cfg", QStringList("false")); + + // render system + model()->setDefinitions("Video/render system", + QStringList(cmbRenderSys->currentText())); + + // vsync + if(cbVsync->isChecked()) + model()->setDefinitions("Video/vsync", QStringList("true")); + else + model()->setDefinitions("Video/vsync", QStringList("false")); + + // antialiasing + model()->setDefinitions("Video/antialiasing", + QStringList(cmbAntiAlias->currentText())); +#if 0 + QRegExp reAA("^\\D*(\\d+)\\D*"); + if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) + model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); +#endif + + // shader lang + model()->setDefinitions("General/shader mode", + QStringList(cmbShaderLang->currentText().toLower())); + + // window size + if(0) //rbStdWinSize->isChecked()) + { + QRegExp re("^(\\d+) x (\\d+)"); + if(re.indexIn(cmbStdWinSize->currentText()) > -1) + { + model()->setDefinitions("Window Size/Width", QStringList(re.cap(1))); + model()->setDefinitions("Window Size/Height", QStringList(re.cap(2))); + } + //} + //else + //{ + model()->setDefinitions("Window Size/Width", + QStringList(QString::number(sbWidth->value()))); + model()->setDefinitions("Window Size/Height", + QStringList(QString::number(sbHeight->value()))); + } + + // status bar + if(cbStatusBar->isChecked()) + model()->setDefinitions("Display/show statusbar", QStringList("true")); + else + model()->setDefinitions("Display/show statusbar", QStringList("false")); + + // display format + model()->setDefinitions("Display Format/Record Status Display", + QStringList(cmbRecStatus->currentText())); + model()->setDefinitions("Display Format/Referenceable ID Type Display", + QStringList(cmbRefIdType->currentText())); + + std::cout << "closeEvent" << std::endl; + saveSettings(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index b0e12c461..c82df8dad 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,28 +2,30 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" -#include "resizeablestackedwidget.hpp" +//#include "resizeablestackedwidget.hpp" #include -class QStackedWidget; -class QListWidget; -class QListWidgetItem; +//class QStackedWidget; +//class QListWidget; +//class QListWidgetItem; + +#include "ui_settingstab.h" namespace CSVSettings { class Page; - class Dialog : public SettingWindow + class Dialog : public SettingWindow, private Ui::TabWidget { Q_OBJECT - QListWidget *mPageListWidget; - ResizeableStackedWidget *mStackedWidget; + //QListWidget *mPageListWidget; + //ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: - explicit Dialog (QMainWindow *parent = 0); + explicit Dialog (QTabWidget *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. @@ -39,8 +41,8 @@ namespace CSVSettings { private: void buildPages(); - void buildPageListWidget (QWidget *centralWidget); - void buildStackedWidget (QWidget *centralWidget); + //void buildPageListWidget (QWidget *centralWidget); + //void buildStackedWidget (QWidget *centralWidget); public slots: @@ -48,7 +50,13 @@ namespace CSVSettings { private slots: - void slotChangePage (QListWidgetItem *, QListWidgetItem *); + //void slotChangePage (QListWidgetItem *, QListWidgetItem *); // FIXME: delete + void slotOverrideToggled(bool checked); + void slotRendererChanged(const QString &renderer); + + signals: + + void toggleStatusBar(bool checked); // FIXME: maybe not needed }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp deleted file mode 100644 index 7d5e5bec5..000000000 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ /dev/null @@ -1,486 +0,0 @@ -#include "settingsdialog.hpp" - -#include -#include - -#include - -#include "../../model/settings/usersettings.hpp" - -namespace -{ -// copied from the launcher & adapted - -QString getAspect(int x, int y) -{ - int gcd = boost::math::gcd (x, y); - int xaspect = x / gcd; - int yaspect = y / gcd; - // special case: 8 : 5 is usually referred to as 16:10 - if (xaspect == 8 && yaspect == 5) - return QString("16:10"); - - return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); -} - -QRect getMaximumResolution() -{ - QRect max; - int screens = QApplication::desktop()->screenCount(); - for(int i = 0; i < screens; ++i) - { - QRect res = QApplication::desktop()->screenGeometry(i); - if(res.width() > max.width()) - max.setWidth(res.width()); - if(res.height() > max.height()) - max.setHeight(res.height()); - } - return max; -} - -QString getCurrentOgreResolution() -{ - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(; it != renderOpt.end(); ++it) - { - if(it->first == "Video Mode" ) - { - QRegExp re("^(\\d+ x \\d+)"); - if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) - return re.cap(1); - } - } - return QString(); // found nothing -} - -bool customCompare(const QString &s1, const QString &s2) -{ - int x1, x2, y1, y2; - QRegExp re("^(\\d+) x (\\d+)"); - - if(re.indexIn(s1) > -1) - { - x1 = re.cap(1).toInt(); - y1 = re.cap(2).toInt(); - } - if(re.indexIn(s2) > -1) - { - x2 = re.cap(1).toInt(); - y2 = re.cap(2).toInt(); - } - - if(x1 == x2) - return y1 > y2; - else - return x1 > x2; -} - -QStringList getAvailableResolutions() -{ - // store available rendering devices and available resolutions - QStringList result; - - Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(;it != renderOpt.end(); ++it) - { - if(it->first == "Rendering Device" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Rendering Devices - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) - { - std::cout << "rd: " << *iter << std::endl; // FIXME: debug - } - } - if(it->first == "Video Mode" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // FIXME: how to default to the current value? - std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug - // Store Available Resolutions - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(; iter != it->second.possibleValues.end(); ++iter) - { - // extract x and y values - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn((*iter).c_str(), 0) > -1) - { - QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); - QString resolution = re.cap(1) + QString(" x ") + re.cap(2); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { - resolution.append(QObject::tr("\t(Wide ") + aspect + ")"); - - } else if (aspect == QLatin1String("4:3")) { - resolution.append(QObject::tr("\t(Standard 4:3)")); - } - result.append(resolution); - } - } - } - } - result.removeDuplicates(); - qStableSort(result.begin(), result.end(), customCompare); - return result; -} - -} - -CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) - : QTabWidget (parent) -{ - setObjectName("User Settings"); - - setupUi(this); - - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - sbWidth->setMaximum(res.width()); - sbHeight->setMaximum(res.height()); - - // to enable mouse events on disabled widgets - cmbStdWinSize->installEventFilter(this); - sbWidth->installEventFilter(this); - sbHeight->installEventFilter(this); - - connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - //connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); - - // to update the checkbox on the view menu - connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); -} - -bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) -{ - QWidget *item = qobject_cast(target); - if (target == cmbStdWinSize) - { - if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) - { - //rbCustWinSize->setChecked(false); - //rbStdWinSize->setChecked(true); - //slotStandardToggled(true); - - return false; - } - } - else if (target == sbWidth || target == sbHeight) - { - if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) - { - //rbStdWinSize->setChecked(false); - //rbCustWinSize->setChecked(true); - //slotStandardToggled(false); - - return false; - } - } - return QTabWidget::eventFilter(target, event); -} - -void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) -{ - cmbAntiAlias->clear(); - cmbAntiAlias->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); - - cmbShaderLang->clear(); - cmbShaderLang->addItems(mModel->getShaderLanguageByRenderer(renderer)); - - if(mModel->settingValue("Video/use settings.cfg") == "true") - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - cbOverride->setChecked(false); -} - -void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) -{ - if(checked) - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - { - labRenderSys->setEnabled(true); - cmbRenderSys->setEnabled(true); - labAntiAlias->setEnabled(true); - cmbAntiAlias->setEnabled(true); - //cbVsync->setEnabled(true); - labShaderLang->setEnabled(true); - cmbShaderLang->setEnabled(true); - } -} - -void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) -{ - if (checked) - { - cmbStdWinSize->setEnabled(true); - sbWidth->setEnabled(false); - sbHeight->setEnabled(false); - } - else - { - cmbStdWinSize->setEnabled(false); - sbWidth->setEnabled(true); - sbHeight->setEnabled(true); - } -} - -void CSVSettings::SettingsDialog::setViewValues() -{ - int index = -1; - - // initialised in the constructor - slotOverrideToggled(cbOverride->isChecked()); - - // Ogre renderer - cmbRenderSys->clear(); - cmbRenderSys->addItems(mModel->getOgreRenderers()); - //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); - - // antialiasing - QString antialiasing = mModel->settingValue("Video/antialiasing"); - index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); - if(index != -1) - cmbAntiAlias->setCurrentIndex(index); - - // vsync - //cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); - cbVsync->setChecked(false); // disable vsync option for now - cbVsync->setEnabled(false); // disable vsync option for now - - // shader lang - QString shaderlang = mModel->settingValue("General/shader mode"); - index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); - if(index != -1) - cmbShaderLang->setCurrentIndex(index); - - if(mModel->settingValue("Window Size/Width") != "") - sbWidth->setValue(mModel->settingValue("Window Size/Width").toInt()); - - if(mModel->settingValue("Window Size/Height") != "") - sbHeight->setValue(mModel->settingValue("Window Size/Height").toInt()); - - // update display resolution combo box - cmbStdWinSize->clear(); - cmbStdWinSize->addItems(getAvailableResolutions()); - - QString currRes = mModel->settingValue("Window Size/Width") + " x " + - mModel->settingValue("Window Size/Height"); - - index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - { - // show the values in ini file - cmbStdWinSize->setCurrentIndex(index); - slotStandardToggled(true); - } - else - { - // show what's in Ogre instead - index = cmbStdWinSize->findData(getCurrentOgreResolution(), - Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - cmbStdWinSize->setCurrentIndex(index); - - //rbCustWinSize->setChecked(true); - slotStandardToggled(false); - } - - // status bar - cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true"); - - // display format - QString recStat = mModel->settingValue("Display Format/Record Status Display"); - index = cmbRecStatus->findData(recStat, Qt::DisplayRole); - if(index != -1) - cmbRecStatus->setCurrentIndex(index); - - QString refIdType = mModel->settingValue("Display Format/Referenceable ID Type Display"); - index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); - if(index != -1) - cmbRefIdType->setCurrentIndex(index); -} - -void CSVSettings::SettingsDialog::saveSettings() -{ -#if 0 - //setting the definition in the model automatically syncs with the file - foreach (const Page *page, mPages) - { - foreach (const View *view, page->views()) - { - if (!view->serializable()) - continue; - - mModel->setDefinitions (view->viewKey(), view->selectedValues()); - } - } -#endif - std::cout << "closeEvent" << std::endl; - - // override - if(cbOverride->isChecked()) - mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); - else - mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); - - // render system - mModel->setDefinitions("Video/render system", - QStringList(cmbRenderSys->currentText())); - - // vsync - if(cbVsync->isChecked()) - mModel->setDefinitions("Video/vsync", QStringList("true")); - else - mModel->setDefinitions("Video/vsync", QStringList("false")); - - // antialiasing - mModel->setDefinitions("Video/antialiasing", - QStringList(cmbAntiAlias->currentText())); -#if 0 - QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) - mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); -#endif - - // shader lang - mModel->setDefinitions("General/shader mode", - QStringList(cmbShaderLang->currentText().toLower())); - - // window size - if(0) //rbStdWinSize->isChecked()) - { - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(cmbStdWinSize->currentText()) > -1) - { - mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); - mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); - } - } - else - { - mModel->setDefinitions("Window Size/Width", - QStringList(QString::number(sbWidth->value()))); - mModel->setDefinitions("Window Size/Height", - QStringList(QString::number(sbHeight->value()))); - } - - // status bar - if(cbStatusBar->isChecked()) - mModel->setDefinitions("Display/show statusbar", QStringList("true")); - else - mModel->setDefinitions("Display/show statusbar", QStringList("false")); - - // display format - mModel->setDefinitions("Display Format/Record Status Display", - QStringList(cmbRecStatus->currentText())); - mModel->setDefinitions("Display Format/Referenceable ID Type Display", - QStringList(cmbRefIdType->currentText())); - - mModel->saveDefinitions(); -} - -void CSVSettings::SettingsDialog::createConnections - (const QList &list) -{ -#if 0 - foreach (const CSMSettings::Setting *setting, list) - { - View *masterView = findView (setting->page(), setting->name()); - - CSMSettings::Connector *connector = - new CSMSettings::Connector (masterView, this); - - connect (masterView, - SIGNAL (viewUpdated(const QString &, const QStringList &)), - connector, - SLOT (slotUpdateSlaves()) - ); - - const CSMSettings::ProxyValueMap &proxyMap = setting->proxyLists(); - - foreach (const QString &key, proxyMap.keys()) - { - QStringList keyPair = key.split('/'); - - if (keyPair.size() != 2) - continue; - - View *slaveView = findView (keyPair.at(0), keyPair.at(1)); - - if (!slaveView) - { - qWarning () << "Unable to create connection for view " - << key; - continue; - } - - QList proxyList = proxyMap.value (key); - connector->addSlaveView (slaveView, proxyList); - - connect (slaveView, - SIGNAL (viewUpdated(const QString &, const QStringList &)), - connector, - SLOT (slotUpdateMaster())); - } - } -#endif -} - -void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) -{ - //SettingWindow::closeEvent() must be called first to ensure - //model is updated - //SettingWindow::closeEvent (event); - QApplication::focusWidget()->clearFocus(); - - saveSettings(); -} - -void CSVSettings::SettingsDialog::show() -{ - setViewValues(); - - // place the widget and make it visible - QWidget *currView = QApplication::activeWindow(); - if(currView) - { - // place at the center of the window with focus - QSize size = currView->size(); - move(currView->geometry().x()+(size.width() - frameGeometry().width())/2, - currView->geometry().y()+(size.height() - frameGeometry().height())/2); - } - else - { - // something's gone wrong, place at the center of the screen - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - move(screenCenter - QPoint(frameGeometry().width()/2, - frameGeometry().height()/2)); - } - QWidget::show(); -} diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp deleted file mode 100644 index 3dda0700c..000000000 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef CSVSETTINGS_SETTINGSDIALOG_H -#define CSVSETTINGS_SETTINGSDIALOG_H - -#include - -#include "ui_settingstab.h" - -class QListWidgetItem; - -namespace CSMSettings -{ - class Setting; - class UserSettings; -} - -namespace CSVSettings { - - class SettingsDialog : public QTabWidget, private Ui::TabWidget - { - Q_OBJECT - - CSMSettings::UserSettings *mModel; - - public: - - SettingsDialog (QTabWidget *parent = 0); - - ///set the model the view uses (instance of UserSettings) - void setModel (CSMSettings::UserSettings &model) { mModel = &model; } - - protected: - - ///save settings from the GUI to file - void saveSettings(); - - /// Settings are written on close - void closeEvent (QCloseEvent *event); - - bool eventFilter(QObject *target, QEvent *event); - - private: - - ///sets the defined values for the views that have been created - void setViewValues(); - - ///create connections between settings (used for proxy settings) - void createConnections (const QList &list); - - public slots: - - void show(); - - //void slotStandardClicked(); - //void slotCustomClicked(); - void slotRendererChanged(const QString &renderer); - void slotOverrideToggled(bool checked); - void slotStandardToggled(bool checked); - - signals: - - void toggleStatusBar(bool checked); - }; -} -#endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..f016f1e3d 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,15 +1,19 @@ +#include "settingwindow.hpp" + #include +//#include +//#include +//#include #include #include "../../model/settings/setting.hpp" #include "../../model/settings/connector.hpp" #include "../../model/settings/usersettings.hpp" -#include "settingwindow.hpp" #include "page.hpp" #include "view.hpp" -CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QMainWindow(parent) +CSVSettings::SettingWindow::SettingWindow(QTabWidget *parent) + : QTabWidget(parent) {} void CSVSettings::SettingWindow::createPages() @@ -19,7 +23,7 @@ void CSVSettings::SettingWindow::createPages() QList connectedSettings; foreach (const QString &pageName, pageMap.keys()) - { + { QList pageSettings = pageMap.value (pageName); mPages.append (new Page (pageName, pageSettings, this)); @@ -37,6 +41,162 @@ void CSVSettings::SettingWindow::createPages() createConnections(connectedSettings); } +void CSVSettings::SettingWindow::buildTabPage(Page* tab) +{ + CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); + QList pageSettings = pageMap.value (tab->objectName()); + //tab->setupViews(pageSettings); +#if 0 + QFontMetrics fm (QApplication::font()); + //int textWidth = fm.width(pageName); // FIXME: + QString pageName = tab->objectName(); + + std::cout << "pageName: " + pageName.toStdString() << std::endl; // FIXME: + QList settingList = mModel->settingPageMap.value(pageName); + //foreach (View *view, page->views()) + //{ + //std::cout << "view key: " + view->viewKey().toStdString() << std::endl; + //if(!settingList.empty()) + //{ + QGroupBox *section = new QGroupBox(tab); + section->setGeometry(5, 5, this->width()-15, this->height()-15); // FIXME: frame thickness calculation + // FIXME: assume a single grid for now + QGridLayout *gridLayout = new QGridLayout(section); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + gridLayout->setContentsMargins(5, 5, 5, 5); + + foreach(CSMSettings::Setting * setting, settingList) + { + // enum ViewType {ViewType_Boolean = 0, + // ViewType_List = 1, + // ViewType_Range = 2, + // ViewType_Text = 3, + // ViewType_Undefined = 4 }; + // enum SettingType {* 0 - 9 - Boolean widgets + // * 10-19 - List widgets + // * 21-29 - Range widgets + // * 31-39 - Text widgets + // * + // * Each range corresponds to a View_Type enum by a factor of 10. + // * + // * Even-numbered values are single-value widgets + // * Odd-numbered values are multi-valued widgets + // + // Type_CheckBox = 0, + // Type_RadioButton = 1, + // Type_ListView = 10, + // Type_ComboBox = 11, + // Type_SpinBox = 21, + // Type_DoubleSpinBox = 23, + // Type_Slider = 25, + // Type_Dial = 27, + // Type_TextArea = 30, + // Type_LineEdit = 31, + // Type_Undefined = 40 }; + // + std::cout << "view type: " + std::to_string(setting->viewType()) << std::endl; + std::cout << "setting type: " + std::to_string(setting->type()) << std::endl; + switch(setting->viewType()) + { + case ViewType_Boolean: + break; + case ViewType_List: + break; + case ViewType_Range: + break; + case ViewType_Text: + break; + default: + std::cerr << "ViewType_Undefined" << std::endl; + } + QLabel *lab = 0; + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + { + lab = new QLabel(section); + lab->setText(setting->name()); + int textWidth = fm.width(setting->name()); // FIXME: + lab->setMinimumWidth(std::max(textWidth, this->width()/3)); + } + else + { + lab = dynamic_cast (gridLayout->itemAtPosition(setting->viewRow(), 0)->widget()); + QString oldLabel = lab->text(); + lab->setText(oldLabel + ", " + setting->name()); + } + switch(setting->type()) + { + case CSMSettings::SettingType::Type_RadioButton: + { + int rowNum = gridLayout->rowCount(); + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, rowNum, 0); + //lab->setStyleSheet("background-color:yellow;"); // FIXME: + int colNum = 1; + if(setting->declaredValues().size() > 1) // button group FIXME: try isMultiValue() + { + QButtonGroup * buttonGroup = new QButtonGroup(section); + //buttonGroup->setStyleSheet("background-color:red;"); // FIXME: + //gridLayout->addWidget(buttonGroup, rowNum, 1); + foreach(QString string, setting->declaredValues()) + { + QRadioButton *rb = new QRadioButton(string, section); + //rb->setStyleSheet("background-color:blue;"); // FIXME: + gridLayout->addWidget(rb, rowNum, colNum++); + buttonGroup->addButton(rb); + } + } + else // single radio button + { + std::cout << "default values size: " + std::to_string(setting->declaredValues().size()) << std::endl; + QRadioButton *rb = new QRadioButton(section); + if(rb) rb->setText(setting->declaredValues().at(0)); + gridLayout->addWidget(rb, gridLayout->rowCount(), 1); + } + break; + } + case CSMSettings::SettingType::Type_LineEdit: + { + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); + QLineEdit *item = new QLineEdit(section); + //QLabel *lab = new QLabel(section); + //lab->setText(setting->name()); // FIXME: how to put lables in proper place if many items in the same row + gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, + setting->rowSpan(), setting->columnSpan()); + item->setText(setting->defaultValues().at(0)); //FIXME: check if empty first? + break; + } + case CSMSettings::SettingType::Type_ComboBox: + { + QComboBox *item = new QComboBox(section); + //QLabel *lab = new QLabel(section); + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); + //lab->setText(setting->name()); + gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, + setting->rowSpan(), setting->columnSpan()); + item->clear(); + item->addItems(setting->declaredValues()); //FIXME: check if empty first? + break; + } + default: + break; + } + } + section->resize(section->width(), gridLayout->rowCount() * (fm.lineSpacing() + 10)); // 10 is extra line space + //tab->adjustSize(); + //} + //QWidget *item = new QWidget(tab); + //item->setObjectName(QString::fromUtf8("cmbAntiAlias")); + //} + + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); + + //mStackedWidget->addWidget (&dynamic_cast(*(page))); +#endif +} + void CSVSettings::SettingWindow::createConnections (const QList &list) { diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..5ed02681c 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -1,7 +1,7 @@ #ifndef CSVSETTINGS_SETTINGWINDOW_HPP #define CSVSETTINGS_SETTINGWINDOW_HPP -#include +#include #include #include "../../model/settings/support.hpp" @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QMainWindow + class SettingWindow : public QTabWidget { Q_OBJECT @@ -26,7 +26,7 @@ namespace CSVSettings { CSMSettings::UserSettings *mModel; public: - explicit SettingWindow(QWidget *parent = 0); + explicit SettingWindow(QTabWidget *parent = 0); ///retrieve a reference to a view based on it's page and setting name View *findView (const QString &pageName, const QString &setting); @@ -50,6 +50,9 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); + void buildTabPage(Page* tab); + CSMSettings::UserSettings *model() { return mModel; } + private: ///create connections between settings (used for proxy settings) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index f5b0e6a5b..3d9a9ed46 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -145,7 +145,7 @@ Display Format - + 10 @@ -223,7 +223,7 @@ Subviews - + 21 @@ -291,37 +291,73 @@ Window Size - + + + true + 10 20 171 - 22 + 21 - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + + 0 + + + + true + + + + + 0 + 0 + 171 + 22 + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + false + + + + 0 + 0 + 171 + 22 + + + + @@ -340,27 +376,9 @@ displayGroup_Window displayGroup_DisplayFormat displayGroup_Subviews - layoutWidget2 + displayGroup_WindowSize cbStatusBar - - - Misc Settings - - - - false - - - - 70 - 100 - 69 - 22 - - - - From 17a74da65065c2617626d516904477492c83112b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 21 Sep 2014 21:10:18 +1000 Subject: [PATCH 16/90] Cleaned up comments and dead code. --- apps/opencs/model/settings/usersettings.cpp | 127 ---------------- apps/opencs/view/settings/dialog.cpp | 84 ----------- apps/opencs/view/settings/dialog.hpp | 8 - apps/opencs/view/settings/settingwindow.cpp | 159 -------------------- apps/opencs/view/settings/settingwindow.hpp | 1 - 5 files changed, 379 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 664865289..8ef56e202 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -51,133 +51,6 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -/* - * Original Design: - * - * - * QGridLayout QGroupBox - * ^ ^ - * | | - * | 1 | - * SettingLayout......Frame - * ^ ^ QMainWindow - * | | ^ QObject - * / \ | ^ - * / \ | | - * / \ 0..n | | 0..n - * View......Page........SettingWindow......UserSettings......Setting - * ^ 0..n ^ - * | | - * | | - * ListView, | - * TextView, etc | - * | - * | - * QStackedWidget QListWidget.....Dialog - * ^ : - * | : - * | : - * ResizeableStackedWidget..... - * - * - * When a Page is created with a list of Views, the Views are added to the Frame. - * - * Editor ctor - * -> Dialog ctor - * -> SettingWindow ctor - * -> SettingWindow::setModel() - * -> Dialog::setupDialog() - * -> buildPageListWidget - * -> buildStackedWidget - * - * Editor::showSettings() - * -> Dialog::show() - * -> Dialog::buildPages() <-- [first time only] - * -> SettingWindow::createPages() - * -> Page ctor - * -> Page::setupViews() - * -> Page::addView() - * -> Frame::addWidget() - * -> SettingLayout::addWidget() - * -> [add page widgets to the stack] - * - */ -/* - * Modified Design: - * - * +----------------------------------------+ - * |+---------+---------+---------+ | - * || | | | | - * || +----------------------------+| - * || || - * || +--------------------------------+ || - * || | | || - * || | View View | || - * || | View View | || - * || | | || - * || +---- Section -------------------+ || - * || || - * || +--------------------------------+ || - * || | | || - * || | +-------------+ | || - * || | | View/Frame | | || - * || | +-------------+ | || - * || | | || - * || +---- Section -------------------+ || - * || || - * || || - * |+-------------- Page ------------------+| - * +---------- SettingWindow ---------------+ - * - * - * - * QGridLayout QGroupBox - * ^ ^ - * | | - * | 1 | - * SettingLayout......Frame - * ^ ^ QTabWidget - * | | ^ QObject - * / \ | ^ - * / \ | | - * / \ 0..n | | 0..n - * View......Page........SettingWindow......UserSettings......Setting - * ^ 0..n ^ - * | | - * | Ui::TabWidget | - * ListView, ^ | - * TextView, etc | | - * \ | - * \ | - * \ | - * Dialog - * - * - * - * - * - * View/Page is still used to uniquely identify a setting (i.e. Section is for - * visual presentation only). This means all views on a page should be unique - * (as before) - * - * - * Editor ctor - * -> Dialog ctor - * -> SettingWindow ctor - * -> SettingWindow::setModel() - * -> Dialog::setupDialog() <-- [no longer required] - * - * Editor::showSettings() - * -> Dialog::show() - * -> Dialog::buildPages() <-- [first time only] - * -> SettingWindow::createPages() - * -> Page ctor - * -> Page::setupViews() - * -> Page::addView() - * -> Frame::addWidget() - * -> SettingLayout::addWidget() - * -> [add pages to tabs then call showWidgets()] - */ void UserSettings::buildSettingModelDefaults() { QString section; diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index e9ae194ce..df832cf92 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,27 +1,12 @@ #include "dialog.hpp" -//#include #include #include #include -//#include -//#include #include "../../model/settings/usersettings.hpp" - #include "page.hpp" -//#include - -//#include - -//#include -//#include -//#include - -#include -#include - #include #include @@ -170,14 +155,6 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); setupDialog(); - -#if 0 - // FIXME: delete - don't need this for tabs - connect (mPageListWidget, - SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - this, - SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); -#endif } void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) @@ -226,33 +203,8 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) } } -#if 0 -// FIXME: delete - not required for tabs -void CSVSettings::Dialog::slotChangePage - (QListWidgetItem *cur, QListWidgetItem *prev) -{ - mStackedWidget->changePage - (mPageListWidget->row (cur), mPageListWidget->row (prev)); - - layout()->activate(); - setFixedSize(minimumSizeHint()); -} -#endif - void CSVSettings::Dialog::setupDialog() { -#if 0 - //create central widget with it's layout and immediate children - QWidget *centralWidget = new QGroupBox (this); - - centralWidget->setLayout (new QHBoxLayout()); - centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); - setCentralWidget (centralWidget); - setDockOptions (QMainWindow::AllowNestedDocks); - - buildPageListWidget (centralWidget); - buildStackedWidget (centralWidget); -#endif } void CSVSettings::Dialog::buildPages() @@ -332,51 +284,17 @@ void CSVSettings::Dialog::buildPages() SettingWindow::createPages (); - //QFontMetrics fm (QApplication::font()); - foreach (Page *page, SettingWindow::pages()) { QString pageName = page->objectName(); - - //int textWidth = fm.width(pageName); - // each page is added as a tab to Ui::TabWiget addTab(page, page->objectName()); // add section and views to the page - buildTabPage(page); page->showWidgets(); - - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); - - //mStackedWidget->addWidget (&dynamic_cast(*(page))); } - - //resize (mStackedWidget->sizeHint()); -} - -#if 0 -// FIXME: delete - not required, using tabs instead -void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) -{ - mPageListWidget = new QListWidget (centralWidget); - mPageListWidget->setMinimumWidth(50); - mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); - - mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); - - centralWidget->layout()->addWidget(mPageListWidget); } -void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) -{ - mStackedWidget = new ResizeableStackedWidget (centralWidget); - - centralWidget->layout()->addWidget (mStackedWidget); -} -#endif - void CSVSettings::Dialog::closeEvent (QCloseEvent *event) { //SettingWindow::closeEvent() must be called first to ensure @@ -442,8 +360,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Display Format/Referenceable ID Type Display", QStringList(cmbRefIdType->currentText())); - std::cout << "closeEvent" << std::endl; - saveSettings(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index c82df8dad..d1c09fb1e 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,13 +2,8 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" -//#include "resizeablestackedwidget.hpp" #include -//class QStackedWidget; -//class QListWidget; -//class QListWidgetItem; - #include "ui_settingstab.h" namespace CSVSettings { @@ -41,8 +36,6 @@ namespace CSVSettings { private: void buildPages(); - //void buildPageListWidget (QWidget *centralWidget); - //void buildStackedWidget (QWidget *centralWidget); public slots: @@ -50,7 +43,6 @@ namespace CSVSettings { private slots: - //void slotChangePage (QListWidgetItem *, QListWidgetItem *); // FIXME: delete void slotOverrideToggled(bool checked); void slotRendererChanged(const QString &renderer); diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index f016f1e3d..d9bc890b1 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,9 +1,6 @@ #include "settingwindow.hpp" #include -//#include -//#include -//#include #include #include "../../model/settings/setting.hpp" @@ -41,162 +38,6 @@ void CSVSettings::SettingWindow::createPages() createConnections(connectedSettings); } -void CSVSettings::SettingWindow::buildTabPage(Page* tab) -{ - CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); - QList pageSettings = pageMap.value (tab->objectName()); - //tab->setupViews(pageSettings); -#if 0 - QFontMetrics fm (QApplication::font()); - //int textWidth = fm.width(pageName); // FIXME: - QString pageName = tab->objectName(); - - std::cout << "pageName: " + pageName.toStdString() << std::endl; // FIXME: - QList settingList = mModel->settingPageMap.value(pageName); - //foreach (View *view, page->views()) - //{ - //std::cout << "view key: " + view->viewKey().toStdString() << std::endl; - //if(!settingList.empty()) - //{ - QGroupBox *section = new QGroupBox(tab); - section->setGeometry(5, 5, this->width()-15, this->height()-15); // FIXME: frame thickness calculation - // FIXME: assume a single grid for now - QGridLayout *gridLayout = new QGridLayout(section); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - gridLayout->setContentsMargins(5, 5, 5, 5); - - foreach(CSMSettings::Setting * setting, settingList) - { - // enum ViewType {ViewType_Boolean = 0, - // ViewType_List = 1, - // ViewType_Range = 2, - // ViewType_Text = 3, - // ViewType_Undefined = 4 }; - // enum SettingType {* 0 - 9 - Boolean widgets - // * 10-19 - List widgets - // * 21-29 - Range widgets - // * 31-39 - Text widgets - // * - // * Each range corresponds to a View_Type enum by a factor of 10. - // * - // * Even-numbered values are single-value widgets - // * Odd-numbered values are multi-valued widgets - // - // Type_CheckBox = 0, - // Type_RadioButton = 1, - // Type_ListView = 10, - // Type_ComboBox = 11, - // Type_SpinBox = 21, - // Type_DoubleSpinBox = 23, - // Type_Slider = 25, - // Type_Dial = 27, - // Type_TextArea = 30, - // Type_LineEdit = 31, - // Type_Undefined = 40 }; - // - std::cout << "view type: " + std::to_string(setting->viewType()) << std::endl; - std::cout << "setting type: " + std::to_string(setting->type()) << std::endl; - switch(setting->viewType()) - { - case ViewType_Boolean: - break; - case ViewType_List: - break; - case ViewType_Range: - break; - case ViewType_Text: - break; - default: - std::cerr << "ViewType_Undefined" << std::endl; - } - QLabel *lab = 0; - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - { - lab = new QLabel(section); - lab->setText(setting->name()); - int textWidth = fm.width(setting->name()); // FIXME: - lab->setMinimumWidth(std::max(textWidth, this->width()/3)); - } - else - { - lab = dynamic_cast (gridLayout->itemAtPosition(setting->viewRow(), 0)->widget()); - QString oldLabel = lab->text(); - lab->setText(oldLabel + ", " + setting->name()); - } - switch(setting->type()) - { - case CSMSettings::SettingType::Type_RadioButton: - { - int rowNum = gridLayout->rowCount(); - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, rowNum, 0); - //lab->setStyleSheet("background-color:yellow;"); // FIXME: - int colNum = 1; - if(setting->declaredValues().size() > 1) // button group FIXME: try isMultiValue() - { - QButtonGroup * buttonGroup = new QButtonGroup(section); - //buttonGroup->setStyleSheet("background-color:red;"); // FIXME: - //gridLayout->addWidget(buttonGroup, rowNum, 1); - foreach(QString string, setting->declaredValues()) - { - QRadioButton *rb = new QRadioButton(string, section); - //rb->setStyleSheet("background-color:blue;"); // FIXME: - gridLayout->addWidget(rb, rowNum, colNum++); - buttonGroup->addButton(rb); - } - } - else // single radio button - { - std::cout << "default values size: " + std::to_string(setting->declaredValues().size()) << std::endl; - QRadioButton *rb = new QRadioButton(section); - if(rb) rb->setText(setting->declaredValues().at(0)); - gridLayout->addWidget(rb, gridLayout->rowCount(), 1); - } - break; - } - case CSMSettings::SettingType::Type_LineEdit: - { - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); - QLineEdit *item = new QLineEdit(section); - //QLabel *lab = new QLabel(section); - //lab->setText(setting->name()); // FIXME: how to put lables in proper place if many items in the same row - gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, - setting->rowSpan(), setting->columnSpan()); - item->setText(setting->defaultValues().at(0)); //FIXME: check if empty first? - break; - } - case CSMSettings::SettingType::Type_ComboBox: - { - QComboBox *item = new QComboBox(section); - //QLabel *lab = new QLabel(section); - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); - //lab->setText(setting->name()); - gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, - setting->rowSpan(), setting->columnSpan()); - item->clear(); - item->addItems(setting->declaredValues()); //FIXME: check if empty first? - break; - } - default: - break; - } - } - section->resize(section->width(), gridLayout->rowCount() * (fm.lineSpacing() + 10)); // 10 is extra line space - //tab->adjustSize(); - //} - //QWidget *item = new QWidget(tab); - //item->setObjectName(QString::fromUtf8("cmbAntiAlias")); - //} - - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); - - //mStackedWidget->addWidget (&dynamic_cast(*(page))); -#endif -} - void CSVSettings::SettingWindow::createConnections (const QList &list) { diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 5ed02681c..024873ae0 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -50,7 +50,6 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); - void buildTabPage(Page* tab); CSMSettings::UserSettings *model() { return mModel; } private: From 02f8f5419266d5b047aaf1edb988de93fbc5df5b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 07:50:35 +1000 Subject: [PATCH 17/90] Fixed checkbox behaviour. Added some shader settings. --- apps/opencs/editor.cpp | 6 +- apps/opencs/model/settings/usersettings.cpp | 135 +++++++++++++++++--- apps/opencs/view/settings/booleanview.cpp | 28 +++- apps/opencs/view/settings/dialog.cpp | 4 +- 4 files changed, 142 insertions(+), 31 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index d4ea32b26..c2e679eb3 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,10 +314,10 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", "true"); + sh::Factory::getInstance().setGlobalSetting ("fog", mUserSettings.settingValue("shader/fog").toStdString() == "true" ? "true" : "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows", "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows", mUserSettings.settingValue("shader/shadows").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", mUserSettings.settingValue("shader/shadows_pssm").toStdString() == "true" ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 8ef56e202..919e3dd98 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -53,12 +53,108 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana void UserSettings::buildSettingModelDefaults() { - QString section; + QString page; - section = "Window Size"; + page = "Shader"; { - Setting *width = createSetting (Type_LineEdit, section, "Width"); - Setting *height = createSetting (Type_LineEdit, section, "Height"); + QString section = "Group1"; + + Setting *fog = createSetting (Type_CheckBox, page, "fog"); + fog->setDeclaredValues(QStringList() << "true" << "false"); + fog->setDefaultValue("true"); + fog->setEditorSetting(true); + fog->setSpecialValueText("Enable Fog"); + fog->setWidgetWidth(15); + fog->setColumnSpan (2); + fog->setViewLocation(1, 1); + + Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); + shadows->setDeclaredValues(QStringList() << "true" << "false"); + shadows->setDefaultValue("false"); + shadows->setEditorSetting(true); + shadows->setSpecialValueText("Enable Shadows"); + shadows->setWidgetWidth(15); + //shadows->setColumnSpan (2); + shadows->setViewLocation(2, 1); + + Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); + shadows_pssm->setDeclaredValues(QStringList() << "true" << "false"); + shadows_pssm->setDefaultValue("false"); + shadows_pssm->setEditorSetting(true); + shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); + shadows_pssm->setWidgetWidth(15); + //shadows_pssm->setColumnSpan (2); + shadows_pssm->setViewLocation(3, 1); + + // FIXME: add option to put label elsewhere (i.e. no frame text) + Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); + numLights->setDefaultValue(8); + numLights->setEditorSetting(true); + numLights->setColumnSpan (2); + numLights->setMinimum (0); + numLights->setMaximum (100); // FIXME: not sure what the max value should be + numLights->setWidgetWidth (15); + numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 + numLights->setViewLocation(4, 1); + + Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); + simpleWater->setDeclaredValues(QStringList() << "true" << "false"); + simpleWater->setDefaultValue("false"); + simpleWater->setEditorSetting(true); + simpleWater->setSpecialValueText("Enable Simple Water"); + simpleWater->setWidgetWidth(15); + simpleWater->setColumnSpan (2); + simpleWater->setViewLocation(2, 4); + + Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); + waterEnabled->setDefaultValue(0.00); + waterEnabled->setEditorSetting(true); + //waterEnabled->setColumnSpan (2); + waterEnabled->setMinimum (0); + waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be + waterEnabled->setWidgetWidth (15); + waterEnabled->setViewLocation(3, 4); + + Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); + waterLevel->setDefaultValue(0.00); + waterLevel->setEditorSetting(true); + //waterLevel->setColumnSpan (2); + waterLevel->setMinimum (0); + waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be + waterLevel->setWidgetWidth (15); + waterLevel->setViewLocation(4, 4); + + Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); + waterTimer->setDefaultValue(0.00); + waterTimer->setEditorSetting(true); + //waterTimer->setColumnSpan (2); + waterTimer->setMinimum (0); + waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be + waterTimer->setWidgetWidth (15); + waterTimer->setViewLocation(5, 4); + +#if 0 + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); + + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); + + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); + + + +sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); +sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); +sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false"); +sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); +sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); +#endif + } + +#if 0 + page = "Window Size"; + { + Setting *width = createSetting (Type_LineEdit, page, "Width"); + Setting *height = createSetting (Type_LineEdit, page, "Height"); width->setWidgetWidth (5); height->setWidgetWidth (8); @@ -75,7 +171,7 @@ void UserSettings::buildSettingModelDefaults() /* *Create the proxy setting for predefined values */ - Setting *preDefined = createSetting (Type_ComboBox, section, + Setting *preDefined = createSetting (Type_ComboBox, page, "Pre-Defined"); preDefined->setDeclaredValues (QStringList() << "640 x 480" @@ -94,7 +190,7 @@ void UserSettings::buildSettingModelDefaults() ); } - section = "Display Format"; + page = "Display Format"; { QString defaultValue = "Icon and Text"; @@ -102,10 +198,10 @@ void UserSettings::buildSettingModelDefaults() << defaultValue << "Icon Only" << "Text Only"; Setting *rsd = createSetting (Type_RadioButton, - section, "Record Status Display"); + page, "Record Status Display"); Setting *ritd = createSetting (Type_RadioButton, - section, "Referenceable ID Type Display"); + page, "Referenceable ID Type Display"); rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); @@ -113,8 +209,9 @@ void UserSettings::buildSettingModelDefaults() rsd->setEditorSetting (true); ritd->setEditorSetting (true); } +#endif - section = "Proxy Selection Test"; + page = "Proxy Selection Test"; { /****************************************************************** * There are three types of values: @@ -142,30 +239,30 @@ void UserSettings::buildSettingModelDefaults() //create setting objects, specifying the basic widget type, //the page name, and the view name - Setting *masterBoolean = createSetting (Type_RadioButton, section, + Setting *masterBoolean = createSetting (Type_RadioButton, page, "Master Proxy"); - Setting *slaveBoolean = createSetting (Type_CheckBox, section, + Setting *slaveBoolean = createSetting (Type_CheckBox, page, "Proxy Checkboxes"); - Setting *slaveSingleText = createSetting (Type_LineEdit, section, + Setting *slaveSingleText = createSetting (Type_LineEdit, page, "Proxy TextBox 1"); - Setting *slaveMultiText = createSetting (Type_LineEdit, section, + Setting *slaveMultiText = createSetting (Type_LineEdit, page, "ProxyTextBox 2"); - Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, + Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, page, "Alpha Spinbox"); - Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, + Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, page, "Int Spinbox"); Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, - section, "Double Spinbox"); + page, "Double Spinbox"); - Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); + Setting *slaveSlider = createSetting (Type_Slider, page, "Slider"); - Setting *slaveDial = createSetting (Type_Dial, section, "Dial"); + Setting *slaveDial = createSetting (Type_Dial, page, "Dial"); //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() @@ -366,7 +463,7 @@ void UserSettings::loadSettings (const QString &fileName) || (glES && currShader != "glsles")) { QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; - mSettingDefinitions->setValue("General/shader mode", shader); + mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group } // check if override entry exists (default: override) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 2a3f0cba6..fa66a2a8f 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -20,8 +20,19 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, switch (setting->type()) { - case CSMSettings::Type_CheckBox: - button = new QCheckBox (value, this); + case CSMSettings::Type_CheckBox: { + if(mButtons.empty()) // show only one for checkboxes + { + button = new QCheckBox (value, this); + button->setChecked (setting->defaultValues().at(0) == "true" ? true : false); + + // special visual treatment option for checkboxes + if(setting->specialValueText() != "") { + Frame::setTitle(""); + button->setText(setting->specialValueText()); + } + } + } break; case CSMSettings::Type_RadioButton: @@ -32,14 +43,17 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - connect (button, SIGNAL (clicked (bool)), - this, SLOT (slotToggled (bool))); + if(setting->type() != CSMSettings::Type_CheckBox || mButtons.empty()) + { + connect (button, SIGNAL (clicked (bool)), + this, SLOT (slotToggled (bool))); - button->setObjectName (value); + button->setObjectName (value); - addWidget (button); + addWidget (button); - mButtons[value] = button; + mButtons[value] = button; + } } } diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index df832cf92..331cbc3f3 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -326,8 +326,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); #endif - // shader lang - model()->setDefinitions("General/shader mode", + // shader lang (no group means "General" group) + model()->setDefinitions("shader mode", QStringList(cmbShaderLang->currentText().toLower())); // window size From 71a38808840bcaa23f82822c20532c44dc6ced79 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 12:19:18 +1000 Subject: [PATCH 18/90] Added workarounds to add QLabel. Add stylesheet option to apply to View's QGroupBox. RangeViews are now right aligned. Added content margins to the page/tab's layout. --- apps/opencs/model/settings/setting.cpp | 10 ++++++++++ apps/opencs/model/settings/setting.hpp | 3 +++ apps/opencs/model/settings/support.hpp | 12 +++++++----- apps/opencs/model/settings/usersettings.cpp | 20 ++++++++++++++++---- apps/opencs/view/settings/frame.cpp | 4 ++++ apps/opencs/view/settings/page.cpp | 16 +++++++++++++++- apps/opencs/view/settings/rangeview.cpp | 1 + apps/opencs/view/settings/view.cpp | 3 +++ 8 files changed, 59 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 9e1b497b1..c29b0e2dd 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -205,6 +205,16 @@ QString CSMSettings::Setting::section() const return property (Property_Section).at(0); } +void CSMSettings::Setting::setStyleSheet (const QString &value) +{ + setProperty (Property_StyleSheet, value); +} + +QString CSMSettings::Setting::styleSheet() const +{ + return property (Property_StyleSheet).at(0); +} + void CSMSettings::Setting::setPrefix (const QString &value) { setProperty (Property_Prefix, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index ed897e591..b8c72c4bc 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -83,6 +83,9 @@ namespace CSMSettings void setSection (const QString &value); QString section() const; + void setStyleSheet (const QString &value); + QString styleSheet() const; + void setPrefix (const QString &value); QString prefix() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 40db648dc..8c82b17a6 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -36,12 +36,13 @@ namespace CSMSettings Property_TicksAbove = 20, Property_TicksBelow = 21, Property_Section = 22, + Property_StyleSheet = 23, //Stringlists should always be the last items - Property_DefaultValues = 23, - Property_DeclaredValues = 24, - Property_DefinedValues = 25, - Property_Proxies = 26 + Property_DefaultValues = 24, + Property_DeclaredValues = 25, + Property_DefinedValues = 26, + Property_Proxies = 27 }; ///Basic setting widget types. @@ -107,7 +108,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", "section", + "tick_interval", "ticks_above", "ticks_below", "section", "stylesheet", "defaults", "declarations", "definitions", "proxies" }; @@ -137,6 +138,7 @@ namespace CSMSettings "false", //ticks above "true", //ticks below "", //Section + "", //StyleSheet "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 919e3dd98..35c19a176 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -66,6 +66,7 @@ void UserSettings::buildSettingModelDefaults() fog->setSpecialValueText("Enable Fog"); fog->setWidgetWidth(15); fog->setColumnSpan (2); + fog->setStyleSheet ("QGroupBox { border: 0px; }"); fog->setViewLocation(1, 1); Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); @@ -75,6 +76,7 @@ void UserSettings::buildSettingModelDefaults() shadows->setSpecialValueText("Enable Shadows"); shadows->setWidgetWidth(15); //shadows->setColumnSpan (2); + shadows->setStyleSheet ("QGroupBox { border: 0px; }"); shadows->setViewLocation(2, 1); Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); @@ -84,6 +86,7 @@ void UserSettings::buildSettingModelDefaults() shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); shadows_pssm->setWidgetWidth(15); //shadows_pssm->setColumnSpan (2); + shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; }"); shadows_pssm->setViewLocation(3, 1); // FIXME: add option to put label elsewhere (i.e. no frame text) @@ -93,7 +96,7 @@ void UserSettings::buildSettingModelDefaults() numLights->setColumnSpan (2); numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be - numLights->setWidgetWidth (15); + numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 numLights->setViewLocation(4, 1); @@ -104,6 +107,7 @@ void UserSettings::buildSettingModelDefaults() simpleWater->setSpecialValueText("Enable Simple Water"); simpleWater->setWidgetWidth(15); simpleWater->setColumnSpan (2); + simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); simpleWater->setViewLocation(2, 4); Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); @@ -112,7 +116,7 @@ void UserSettings::buildSettingModelDefaults() //waterEnabled->setColumnSpan (2); waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be - waterEnabled->setWidgetWidth (15); + waterEnabled->setWidgetWidth (10); waterEnabled->setViewLocation(3, 4); Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); @@ -121,7 +125,7 @@ void UserSettings::buildSettingModelDefaults() //waterLevel->setColumnSpan (2); waterLevel->setMinimum (0); waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be - waterLevel->setWidgetWidth (15); + waterLevel->setWidgetWidth (10); waterLevel->setViewLocation(4, 4); Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); @@ -130,9 +134,17 @@ void UserSettings::buildSettingModelDefaults() //waterTimer->setColumnSpan (2); waterTimer->setMinimum (0); waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be - waterTimer->setWidgetWidth (15); + waterTimer->setWidgetWidth (10); waterTimer->setViewLocation(5, 4); + Setting *text = createSetting (Type_Undefined, page, "text"); + text->setSpecialValueText("This is a test"); // hack to place text labels + text->setEditorSetting(false); + text->setSerializable (false); + //text->setColumnSpan (1); + text->setWidgetWidth (15); + text->setViewLocation(5, 1); + #if 0 sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index 019024776..39aafe652 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -14,7 +14,11 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, mVisibleBoxStyle = styleSheet(); if (!isVisible) + { + // must be Page, not a View setStyleSheet (sInvisibleBoxStyle); + mLayout->setContentsMargins(10, 15, 10, 15); + } setLayout (mLayout); } diff --git a/apps/opencs/view/settings/page.cpp b/apps/opencs/view/settings/page.cpp index afd4bff5e..ed4cdd6bc 100644 --- a/apps/opencs/view/settings/page.cpp +++ b/apps/opencs/view/settings/page.cpp @@ -1,4 +1,7 @@ #include "page.hpp" + +#include + #include "view.hpp" #include "booleanview.hpp" #include "textview.hpp" @@ -38,7 +41,18 @@ void CSVSettings::Page::setupViews void CSVSettings::Page::addView (CSMSettings::Setting *setting) { if (setting->viewType() == ViewType_Undefined) - return; + { + if(setting->specialValueText() != "") + { + // hack to put a label + addWidget(new QLabel(setting->specialValueText()), + setting->viewRow(), setting->viewColumn(), + setting->rowSpan(), setting->columnSpan()); + return; + } + else + return; + } View *view = mViewFactories[setting->viewType()]->createView(setting, this); diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 8ae6caca0..606ad4939 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -127,6 +127,7 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("prefix", setting->prefix()); mRangeWidget->setProperty ("suffix", setting->suffix()); mRangeWidget->setProperty ("wrapping", setting->wrapping()); + dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); } diff --git a/apps/opencs/view/settings/view.cpp b/apps/opencs/view/settings/view.cpp index 69109e2b3..f95bb5c03 100644 --- a/apps/opencs/view/settings/view.cpp +++ b/apps/opencs/view/settings/view.cpp @@ -22,6 +22,9 @@ CSVSettings::View::View(CSMSettings::Setting *setting, setObjectName (setting->name()); buildView(); buildModel (setting); + // apply stylesheet to view's frame if exists + if(setting->styleSheet() != "") + Frame::setStyleSheet (setting->styleSheet()); } void CSVSettings::View::buildModel (const CSMSettings::Setting *setting) From fc8d6da6a2df0692c52738dd610cb40de66cbbca Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 16:24:06 +1000 Subject: [PATCH 19/90] Added more shader settings. --- apps/opencs/editor.cpp | 21 ++-- apps/opencs/model/settings/usersettings.cpp | 104 +++++++++++++++----- apps/opencs/view/settings/frame.cpp | 3 +- files/ui/settingstab.ui | 2 +- 4 files changed, 97 insertions(+), 33 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index c2e679eb3..25e65b7ee 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -263,7 +263,6 @@ std::auto_ptr CS::Editor::setupGraphics() { 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); @@ -300,6 +299,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); std::string shLang = mUserSettings.settingValue("General/shader mode").toStdString(); + //std::string shLang = mUserSettings.getShaderLanguageByRenderer(rendersystem.c_str()).at(0).toStdString(); enum sh::Language lang; if(shLang == "glsl") lang = sh::Language_GLSL; else if(shLang == "glsles") lang = sh::Language_GLSLES; @@ -314,16 +314,23 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", mUserSettings.settingValue("shader/fog").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("fog", + mUserSettings.settingValue("shader/fog").toStdString()); - sh::Factory::getInstance().setGlobalSetting ("shadows", mUserSettings.settingValue("shader/shadows").toStdString() == "true" ? "true" : "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", mUserSettings.settingValue("shader/shadows_pssm").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows", + mUserSettings.settingValue("shader/shadows").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", + mUserSettings.settingValue("shader/shadows_pssm").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", + mUserSettings.settingValue("shader/render_refraction").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("num_lights", "8"); + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", + mUserSettings.settingValue("shader/viewproj_fix").toStdString()); + + sh::Factory::getInstance ().setGlobalSetting ("num_lights", + mUserSettings.settingValue("shader/num_lights").toStdString()); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 35c19a176..3fcf083d1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -66,7 +66,7 @@ void UserSettings::buildSettingModelDefaults() fog->setSpecialValueText("Enable Fog"); fog->setWidgetWidth(15); fog->setColumnSpan (2); - fog->setStyleSheet ("QGroupBox { border: 0px; }"); + fog->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); fog->setViewLocation(1, 1); Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); @@ -75,7 +75,7 @@ void UserSettings::buildSettingModelDefaults() shadows->setEditorSetting(true); shadows->setSpecialValueText("Enable Shadows"); shadows->setWidgetWidth(15); - //shadows->setColumnSpan (2); + shadows->setColumnSpan (2); shadows->setStyleSheet ("QGroupBox { border: 0px; }"); shadows->setViewLocation(2, 1); @@ -85,65 +85,121 @@ void UserSettings::buildSettingModelDefaults() shadows_pssm->setEditorSetting(true); shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); shadows_pssm->setWidgetWidth(15); - //shadows_pssm->setColumnSpan (2); - shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; }"); + shadows_pssm->setColumnSpan (2); + shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); shadows_pssm->setViewLocation(3, 1); - // FIXME: add option to put label elsewhere (i.e. no frame text) Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); - numLights->setColumnSpan (2); + numLights->setColumnSpan (1); numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 - numLights->setViewLocation(4, 1); + numLights->setViewLocation(4, 2); + Setting *nlText = createSetting (Type_Undefined, page, "nlText"); + nlText->setSpecialValueText("Num Lights"); // hack to place text labels + nlText->setEditorSetting(false); + nlText->setSerializable (false); + nlText->setColumnSpan (1); + nlText->setWidgetWidth (10); + nlText->setViewLocation(4, 1); + + Setting *renderRefraction = createSetting (Type_CheckBox, page, "renderRefraction"); + renderRefraction->setDeclaredValues(QStringList() << "true" << "false"); + renderRefraction->setDefaultValue("false"); + renderRefraction->setEditorSetting(true); + renderRefraction->setSpecialValueText("Enable Render Refraction"); + renderRefraction->setWidgetWidth(20); + renderRefraction->setColumnSpan (2); + renderRefraction->setStyleSheet ("QGroupBox { border: 0px; }"); + renderRefraction->setViewLocation(5, 1); + + Setting *viewproj_fix = createSetting (Type_CheckBox, page, "viewproj_fix"); + viewproj_fix->setDeclaredValues(QStringList() << "true" << "false"); + viewproj_fix->setDefaultValue("false"); + viewproj_fix->setEditorSetting(true); + viewproj_fix->setSpecialValueText("View Proj Fix"); + viewproj_fix->setWidgetWidth(20); + viewproj_fix->setColumnSpan (2); + viewproj_fix->setStyleSheet ("QGroupBox { border: 0px; }"); + viewproj_fix->setViewLocation(6, 1); Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); simpleWater->setDeclaredValues(QStringList() << "true" << "false"); simpleWater->setDefaultValue("false"); simpleWater->setEditorSetting(true); simpleWater->setSpecialValueText("Enable Simple Water"); - simpleWater->setWidgetWidth(15); - simpleWater->setColumnSpan (2); + simpleWater->setWidgetWidth(25); + simpleWater->setColumnSpan (3); simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); - simpleWater->setViewLocation(2, 4); + simpleWater->setViewLocation(1, 5); Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); waterEnabled->setDefaultValue(0.00); waterEnabled->setEditorSetting(true); - //waterEnabled->setColumnSpan (2); + waterEnabled->setColumnSpan (1); waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be waterEnabled->setWidgetWidth (10); - waterEnabled->setViewLocation(3, 4); + //waterEnabled->setStyleSheet("QGroupBox { border:2px; padding 2px; margin: 2px;} QGroupBox::title { text: \"test\" }"); + waterEnabled->setViewLocation(2, 6); + Setting *weText = createSetting (Type_Undefined, page, "weText"); + weText->setSpecialValueText("Water Enabled"); + weText->setEditorSetting(false); + weText->setSerializable (false); + weText->setColumnSpan (1); + weText->setWidgetWidth (10); + weText->setViewLocation(2, 5); Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); waterLevel->setDefaultValue(0.00); waterLevel->setEditorSetting(true); - //waterLevel->setColumnSpan (2); + waterLevel->setColumnSpan (1); waterLevel->setMinimum (0); waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be waterLevel->setWidgetWidth (10); - waterLevel->setViewLocation(4, 4); + waterLevel->setViewLocation(3, 6); + Setting *wlText = createSetting (Type_Undefined, page, "wlText"); + wlText->setSpecialValueText("Water Level"); // hack to place text labels + wlText->setEditorSetting(false); + wlText->setSerializable (false); + wlText->setColumnSpan (1); + wlText->setWidgetWidth (10); + wlText->setViewLocation(3, 5); Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); waterTimer->setDefaultValue(0.00); waterTimer->setEditorSetting(true); - //waterTimer->setColumnSpan (2); + waterTimer->setColumnSpan (1); waterTimer->setMinimum (0); waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be waterTimer->setWidgetWidth (10); - waterTimer->setViewLocation(5, 4); - - Setting *text = createSetting (Type_Undefined, page, "text"); - text->setSpecialValueText("This is a test"); // hack to place text labels - text->setEditorSetting(false); - text->setSerializable (false); - //text->setColumnSpan (1); - text->setWidgetWidth (15); - text->setViewLocation(5, 1); + waterTimer->setViewLocation(4, 6); + Setting *wtText = createSetting (Type_Undefined, page, "wtText"); + wtText->setSpecialValueText("Water Timer"); // hack to place text labels + wtText->setEditorSetting(false); + wtText->setSerializable (false); + wtText->setColumnSpan (1); + wtText->setWidgetWidth (10); + wtText->setViewLocation(4, 5); + + + Setting *spaceText = createSetting (Type_Undefined, page, "spaceText"); + spaceText->setSpecialValueText(" "); + spaceText->setEditorSetting(false); + spaceText->setSerializable (false); + spaceText->setColumnSpan (1); + spaceText->setWidgetWidth (5); + spaceText->setViewLocation(3, 4); + Setting *spaceText2 = createSetting (Type_Undefined, page, "spaceText2"); + spaceText2->setSpecialValueText(" "); + spaceText2->setEditorSetting(false); + spaceText2->setSerializable (false); + spaceText2->setColumnSpan (1); + spaceText2->setWidgetWidth (5); + spaceText2->setViewLocation(3, 7); #if 0 sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index 39aafe652..c39eba890 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -16,7 +16,8 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, if (!isVisible) { // must be Page, not a View - setStyleSheet (sInvisibleBoxStyle); + //setStyleSheet (sInvisibleBoxStyle); + setStyleSheet("QGroupBox { border:0px; }"); mLayout->setContentsMargins(10, 15, 10, 15); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 3d9a9ed46..ceb0a898f 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -122,7 +122,7 @@ - Shader + title displayGroup_Render From 48f96df29d325026487eeffdb6c9a8033416436d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 18:50:48 +1000 Subject: [PATCH 20/90] Fixed checkboxes saving invalid values. --- apps/opencs/view/settings/booleanview.cpp | 16 +++++++++++----- apps/opencs/view/settings/booleanview.hpp | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index fa66a2a8f..58b822179 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -12,13 +12,13 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, Page *parent) - : View (setting, parent) + : mType(setting->type()), View (setting, parent) { foreach (const QString &value, setting->declaredValues()) { QAbstractButton *button = 0; - switch (setting->type()) + switch (mType) { case CSMSettings::Type_CheckBox: { if(mButtons.empty()) // show only one for checkboxes @@ -43,7 +43,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - if(setting->type() != CSMSettings::Type_CheckBox || mButtons.empty()) + if(mType != CSMSettings::Type_CheckBox || mButtons.empty()) { connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); @@ -67,8 +67,14 @@ void CSVSettings::BooleanView::slotToggled (bool state) foreach (QString key, mButtons.keys()) { - if (mButtons.value(key)->isChecked()) - values.append (key); + // checkbox values are true/false unlike radio buttons + if(mType == CSMSettings::Type_CheckBox) + values.append(mButtons.value(key)->isChecked() ? "true" : "false"); + else + { + if (mButtons.value(key)->isChecked()) + values.append (key); + } } setSelectedValues (values, false); diff --git a/apps/opencs/view/settings/booleanview.hpp b/apps/opencs/view/settings/booleanview.hpp index 55ef0bb08..53198234a 100644 --- a/apps/opencs/view/settings/booleanview.hpp +++ b/apps/opencs/view/settings/booleanview.hpp @@ -16,6 +16,7 @@ namespace CSVSettings Q_OBJECT QMap mButtons; + enum CSMSettings::SettingType mType; public: explicit BooleanView (CSMSettings::Setting *setting, From c4f11785ecd08839575acdb2715758e49532ec6d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 21:12:26 +1000 Subject: [PATCH 21/90] Added a window size change easter egg. --- apps/opencs/view/settings/dialog.cpp | 33 +++- apps/opencs/view/settings/dialog.hpp | 2 + files/ui/settingstab.ui | 264 ++++++++++++++------------- 3 files changed, 167 insertions(+), 132 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 331cbc3f3..3f8143aa2 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -154,9 +154,30 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) // to update the checkbox on the view menu connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); + displayGroup_Window->installEventFilter(this); + setupDialog(); } +bool CSVSettings::Dialog::eventFilter(QObject *target, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonDblClick) + { + if(stackedWidget->currentWidget() == page_1) + { + stackedWidget->setCurrentWidget(page_2); + return false; + } + else if(stackedWidget->currentWidget() == page_2) + { + stackedWidget->setCurrentWidget(page_1); + return false; + } + } + + return QTabWidget::eventFilter(target, event); +} + void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) { cmbAntiAlias->clear(); @@ -254,7 +275,6 @@ void CSVSettings::Dialog::buildPages() { // show the values in ini file cmbStdWinSize->setCurrentIndex(index); - //slotStandardToggled(true); } else { @@ -263,9 +283,6 @@ void CSVSettings::Dialog::buildPages() Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) cmbStdWinSize->setCurrentIndex(index); - - //rbCustWinSize->setChecked(true); - //slotStandardToggled(false); } // status bar @@ -331,7 +348,7 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) QStringList(cmbShaderLang->currentText().toLower())); // window size - if(0) //rbStdWinSize->isChecked()) + if(page_2->isEnabled()) { QRegExp re("^(\\d+) x (\\d+)"); if(re.indexIn(cmbStdWinSize->currentText()) > -1) @@ -339,9 +356,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Window Size/Width", QStringList(re.cap(1))); model()->setDefinitions("Window Size/Height", QStringList(re.cap(2))); } - //} - //else - //{ + } + else + { model()->setDefinitions("Window Size/Width", QStringList(QString::number(sbWidth->value()))); model()->setDefinitions("Window Size/Height", diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index d1c09fb1e..e2e93d8a1 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -33,6 +33,8 @@ namespace CSVSettings { void setupDialog(); + bool eventFilter(QObject *target, QEvent *event); + private: void buildPages(); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index ceb0a898f..de7014b4a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -14,121 +14,8 @@ User Settings - 1 + 0 - - - Video Settings - - - - - 20 - 26 - 351 - 129 - - - - - - - Use Render System Settings from OpenMW - - - true - - - - - - - Rendering Subsystem - - - - - - - false - - - - - - - Antialiasing - - - - - - - Vertical Sync - - - - - - - Shader Language - - - - - - - - - - - - - - 16777215 - 2 - - - - color: rgb(215, 215, 215); - - - Qt::Horizontal - - - - - - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 9 - 169 - 371 - 101 - - - - title - - - displayGroup_Render - layoutWidget_Render - groupBox - Display Settings @@ -284,7 +171,7 @@ 10 100 - 191 + 201 51 @@ -299,14 +186,14 @@ 10 20 - 171 - 21 + 181 + 22 0 - + true @@ -315,7 +202,7 @@ 0 0 - 171 + 181 22 @@ -344,15 +231,15 @@ + + true + - - false - 0 0 - 171 + 181 22 @@ -373,13 +260,142 @@ Show Status Bar + layoutWidget_Subviews displayGroup_Window displayGroup_DisplayFormat displayGroup_Subviews - displayGroup_WindowSize cbStatusBar + + + Video Settings + + + + + 20 + 26 + 351 + 129 + + + + + + + Use Render System Settings from OpenMW + + + true + + + + + + + Rendering Subsystem + + + + + + + false + + + + + + + Antialiasing + + + + + + + Vertical Sync + + + + + + + Shader Language + + + + + + + + + + + + + + 16777215 + 2 + + + + color: rgb(215, 215, 215); + + + Qt::Horizontal + + + + + + + + + 10 + 8 + 371 + 156 + + + + Render System + + + + + + 9 + 169 + 371 + 101 + + + + title + + + displayGroup_Render + layoutWidget_Render + groupBox + + + cmbRecStatus + cmbRefIdType + sbWidth + sbHeight + cbStatusBar + spinBox_max_subviews + spinBox_min_subview_width + checkBox_reuse_subview + cbOverride + cmbRenderSys + cbVsync + cmbAntiAlias + cmbShaderLang + cmbStdWinSize + From c8ae8f4a6d9e98ef6a450304a7c0b16c1b14cc49 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 06:30:41 +1000 Subject: [PATCH 22/90] Added minimum width setting for subviews - regionmap, table, scene, preview and dialogue. It should be noted that the setting is not the starting minimum width, i.e. it won't be possible to reduce the width of the subview after the creation. Also, one setting applies to all subviews. It may be desirable to have individual settings. --- apps/opencs/view/settings/dialog.cpp | 9 +++++++++ apps/opencs/view/world/dialoguesubview.cpp | 8 +++++++- apps/opencs/view/world/previewsubview.cpp | 11 ++++++++++- apps/opencs/view/world/regionmapsubview.cpp | 10 +++++++++- apps/opencs/view/world/scenesubview.cpp | 11 +++++++++-- apps/opencs/view/world/tablesubview.cpp | 8 ++++++++ files/ui/settingstab.ui | 6 +++--- 7 files changed, 55 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 3f8143aa2..561eccc5c 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -299,6 +299,12 @@ void CSVSettings::Dialog::buildPages() if(index != -1) cmbRefIdType->setCurrentIndex(index); + // subview + if(model()->hasSettingDefinitions("SubView/minimum width")) + sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); + else + sbMinSubViewWidth->setValue(325); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -376,6 +382,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) QStringList(cmbRecStatus->currentText())); model()->setDefinitions("Display Format/Referenceable ID Type Display", QStringList(cmbRefIdType->currentText())); + // subview + model()->setDefinitions("SubView/minimum width", + QStringList(QString::number(sbMinSubViewWidth->value()))); saveSettings(); } diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 57069bec0..d6a2bc13e 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -27,6 +27,7 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/commands.hpp" +#include "../../model/settings/usersettings.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" @@ -392,7 +393,12 @@ void CSVWorld::EditWidget::remake(int row) mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0)); - this->setMinimumWidth(325); /// \todo replace hardcoded value with a user setting + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + this->setMinimumWidth(minWidth); this->setWidget(mMainWidget); this->setWidgetResizable(true); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 1e106c69f..f56ca7674 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -8,6 +8,8 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" +#include "../../model/settings/usersettings.hpp" + CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) { @@ -41,6 +43,13 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest())); @@ -63,4 +72,4 @@ void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id) setWindowTitle ("Preview: Reference to "); else setWindowTitle (("Preview: Reference to " + id).c_str()); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index a7675a4a6..2e20be349 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -2,6 +2,7 @@ #include "regionmapsubview.hpp" #include "regionmap.hpp" +#include "../../model/settings/usersettings.hpp" CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document) @@ -9,6 +10,13 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, { mRegionMap = new RegionMap (universalId, document, this); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + mRegionMap->setMinimumWidth(minWidth); + setWidget (mRegionMap); connect (mRegionMap, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), @@ -24,4 +32,4 @@ void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id, const std::string& hint) { focusId (id, hint); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 52bd47b54..f2cc8505b 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -9,7 +9,7 @@ #include #include "../../model/doc/document.hpp" - +#include "../../model/settings/usersettings.hpp" #include "../../model/world/cellselection.hpp" #include "../filter/filterbox.hpp" @@ -74,6 +74,13 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); } @@ -254,4 +261,4 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index e2c8d5c1e..4a87319eb 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -6,6 +6,7 @@ #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../../model/settings/usersettings.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -34,6 +35,13 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index de7014b4a..88b7e9231 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -142,7 +142,7 @@ - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -260,10 +260,10 @@ Show Status Bar + displayGroup_Subviews layoutWidget_Subviews displayGroup_Window displayGroup_DisplayFormat - displayGroup_Subviews cbStatusBar @@ -387,7 +387,7 @@ sbHeight cbStatusBar spinBox_max_subviews - spinBox_min_subview_width + sbMinSubViewWidth checkBox_reuse_subview cbOverride cmbRenderSys From 437fb774c5c99966f637781914557566ce88ba87 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 07:16:07 +1000 Subject: [PATCH 23/90] Re-implemented subview minimum size setting. --- apps/opencs/view/doc/view.cpp | 7 +++++++ apps/opencs/view/settings/dialog.cpp | 2 -- apps/opencs/view/world/dialoguesubview.cpp | 7 ------- apps/opencs/view/world/previewsubview.cpp | 9 --------- apps/opencs/view/world/regionmapsubview.cpp | 8 -------- apps/opencs/view/world/scenesubview.cpp | 7 ------- apps/opencs/view/world/tablesubview.cpp | 8 -------- files/ui/settingstab.ui | 6 ------ 8 files changed, 7 insertions(+), 47 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index c7186a4e6..e77b995fc 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -442,6 +442,13 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); + int minWidth = 325; // default value if none found + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + view->setMinimumWidth(minWidth); + view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 561eccc5c..d35492ea2 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -302,8 +302,6 @@ void CSVSettings::Dialog::buildPages() // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); - else - sbMinSubViewWidth->setValue(325); SettingWindow::createPages (); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index d6a2bc13e..8790601ea 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -27,7 +27,6 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/commands.hpp" -#include "../../model/settings/usersettings.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" @@ -393,12 +392,6 @@ void CSVWorld::EditWidget::remake(int row) mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0)); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - this->setMinimumWidth(minWidth); this->setWidget(mMainWidget); this->setWidgetResizable(true); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index f56ca7674..316f7c71e 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -8,8 +8,6 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" -#include "../../model/settings/usersettings.hpp" - CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) { @@ -43,13 +41,6 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest())); diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index 2e20be349..411e24e75 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -2,7 +2,6 @@ #include "regionmapsubview.hpp" #include "regionmap.hpp" -#include "../../model/settings/usersettings.hpp" CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document) @@ -10,13 +9,6 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, { mRegionMap = new RegionMap (universalId, document, this); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - mRegionMap->setMinimumWidth(minWidth); - setWidget (mRegionMap); connect (mRegionMap, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index f2cc8505b..699bf81f6 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -74,13 +74,6 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); } diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 4a87319eb..e2c8d5c1e 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -6,7 +6,6 @@ #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" -#include "../../model/settings/usersettings.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -35,13 +34,6 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 88b7e9231..5a8d71976 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -146,12 +146,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 325 - - - 20000 - 5 From 62406d53221fac74240393bda1e6402ed759037d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 07:28:55 +1000 Subject: [PATCH 24/90] Use reasonable values for the spinbox. --- apps/opencs/view/settings/dialog.cpp | 2 ++ files/ui/settingstab.ui | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index d35492ea2..561eccc5c 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -302,6 +302,8 @@ void CSVSettings::Dialog::buildPages() // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); + else + sbMinSubViewWidth->setValue(325); SettingWindow::createPages (); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 5a8d71976..2aafdeb00 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -146,6 +146,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 50 + + + 20000 + 5 From ffae816aabea9ac173456999d76eb047bda5f750 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 17:01:08 +1000 Subject: [PATCH 25/90] Max subviews setting working. However there is no way to remove the last subview once the title bar is removed and the look of the filter box is broken without the title bar. --- apps/opencs/model/settings/usersettings.cpp | 10 --- apps/opencs/view/doc/subview.cpp | 9 +++ apps/opencs/view/doc/subview.hpp | 9 +++ apps/opencs/view/doc/view.cpp | 68 ++++++++++++++++++--- apps/opencs/view/doc/view.hpp | 6 +- apps/opencs/view/doc/viewmanager.cpp | 9 +++ apps/opencs/view/doc/viewmanager.hpp | 7 +++ apps/opencs/view/settings/dialog.cpp | 7 +++ files/ui/settingstab.ui | 7 ++- 9 files changed, 110 insertions(+), 22 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 3fcf083d1..82f4bc750 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -202,18 +202,8 @@ void UserSettings::buildSettingModelDefaults() spaceText2->setViewLocation(3, 7); #if 0 - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); - - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); - - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); - - - sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); -sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false"); -sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); #endif } diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index 9c3c4e5e9..be03f91a5 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -1,5 +1,7 @@ #include "subview.hpp" +#include "view.hpp" + CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id) { /// \todo add a button to the title bar that clones this sub view @@ -25,3 +27,10 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id) mUniversalId = id; setWindowTitle (mUniversalId.toString().c_str()); } + +void CSVDoc::SubView::closeEvent (QCloseEvent *event) +{ + // update title bars of view and subviews + if(mParent) + mParent->updateSubViewIndicies(this); +} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index 733a75bb0..6a3ddd8bd 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -18,11 +18,14 @@ namespace CSMWorld namespace CSVDoc { + class View; + class SubView : public QDockWidget { Q_OBJECT CSMWorld::UniversalId mUniversalId; + View *mParent; // not implemented SubView (const SubView&); @@ -44,6 +47,12 @@ namespace CSVDoc virtual void useHint (const std::string& hint); ///< Default implementation: ignored + void setParent(View *parent) { mParent = parent; } + + private: + + void closeEvent (QCloseEvent *event); + signals: void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index e77b995fc..b2317d77b 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -297,7 +297,7 @@ void CSVDoc::View::setupUi() setupDebugMenu(); } -void CSVDoc::View::updateTitle() +void CSVDoc::View::updateTitle(const std::string subview) { std::ostringstream stream; @@ -309,9 +309,37 @@ void CSVDoc::View::updateTitle() if (mViewTotal>1) stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]"; + if (subview != "") + stream << " - " << subview; + setWindowTitle (stream.str().c_str()); } +void CSVDoc::View::updateSubViewIndicies(SubView *view) +{ + if(view && mSubViews.contains(view)) + mSubViews.removeOne(view); + + if(mSubViews.size() == 1) + { + mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); + updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + } + else + { + updateTitle(); + if(mSubViews.size() > 1) + { + foreach(SubView * sb, mSubViews) + { + QWidget * tb = sb->titleBarWidget(); + if(tb) delete tb; + sb->setTitleBarWidget(0); + } + } + } +} + void CSVDoc::View::updateActions() { bool editing = !(mDocument->getState() & CSMDoc::State_Locked); @@ -421,11 +449,20 @@ void CSVDoc::View::updateProgress (int current, int max, int type, int threads) void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::string& hint) { - /// \todo add an user setting for limiting the number of sub views per top level view. Automatically open a new top level view if this - /// number is exceeded + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - /// \todo if the sub view limit setting is one, the sub view title bar should be hidden and the text in the main title bar adjusted - /// accordingly + int maxSubView = 3; + if(userSettings.hasSettingDefinitions("SubView/max subviews")) + maxSubView = userSettings.settingValue("SubView/max subviews").toInt(); + else + userSettings.setDefinitions("SubView/max subviews", (QStringList() << QString(maxSubView))); + + if(mSubViews.size() >= maxSubView) // create a new top level view + { + mViewManager.addView(mDocument, id, hint); + + return; + } /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) @@ -439,16 +476,29 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view = mSubViewFactory.makeSubView (id, *mDocument); } assert(view); + view->setParent(this); + mSubViews.append(view); // only after assert if (!hint.empty()) view->useHint (hint); - int minWidth = 325; // default value if none found - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + int minWidth = 325; // default value to use if none found + if(userSettings.hasSettingDefinitions("SubView/minimum width")) + minWidth = userSettings.settingValue("SubView/minimum width").toInt(); else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); view->setMinimumWidth(minWidth); +#if 0 + if(mSubViews.size() == 1) // remove subview title and add to the main window + { + updateTitle(id.getTypeName().c_str()); + // FIXME: search area broken + view->setTitleBarWidget(new QWidget(this)); + } + else +#endif + updateSubViewIndicies(); + view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index e7c813c5c..eab274a59 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -35,6 +35,7 @@ namespace CSVDoc CSMDoc::Document *mDocument; int mViewIndex; int mViewTotal; + QList mSubViews; QAction *mUndo; QAction *mRedo; QAction *mSave; @@ -74,7 +75,7 @@ namespace CSVDoc void setupUi(); - void updateTitle(); + void updateTitle(const std::string subview = ""); void updateActions(); @@ -113,6 +114,9 @@ namespace CSVDoc /// Function called by view manager when user preferences are updated void updateEditorSetting (const QString &, const QString &); + // called when subviews are added or removed + void updateSubViewIndicies(SubView *view = 0); + signals: void newGameRequest(); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index d5e5e7027..39cd7eeda 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -9,6 +9,7 @@ #include "../../model/doc/documentmanager.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/columns.hpp" +#include "../../model/world/universalid.hpp" #include "../world/util.hpp" #include "../world/enumdelegate.hpp" @@ -161,6 +162,14 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) return view; } +CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint) +{ + View* view = addView(document); + view->addSubView(id, hint); + + return view; +} + int CSVDoc::ViewManager::countViews (const CSMDoc::Document *document) const { int count = 0; diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 61b807960..d703b430a 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -18,6 +18,11 @@ namespace CSVWorld class CommandDelegateFactoryCollection; } +namespace CSMWorld +{ + class UniversalId; +} + namespace CSVDoc { class View; @@ -52,6 +57,8 @@ namespace CSVDoc View *addView (CSMDoc::Document *document); ///< The ownership of the returned view is not transferred. + View *addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint); + int countViews (const CSMDoc::Document *document) const; ///< Return number of views for \a document. diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 561eccc5c..e328384e8 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -305,6 +305,11 @@ void CSVSettings::Dialog::buildPages() else sbMinSubViewWidth->setValue(325); + if(model()->hasSettingDefinitions("SubView/max subviews")) + sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt()); + else + sbMaxSubViews->setValue(3); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -385,6 +390,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) // subview model()->setDefinitions("SubView/minimum width", QStringList(QString::number(sbMinSubViewWidth->value()))); + model()->setDefinitions("SubView/max subviews", + QStringList(QString::number(sbMaxSubViews->value()))); saveSettings(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2aafdeb00..95c10367a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -128,10 +128,13 @@ - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 1 + @@ -386,7 +389,7 @@ sbWidth sbHeight cbStatusBar - spinBox_max_subviews + sbMaxSubViews sbMinSubViewWidth checkBox_reuse_subview cbOverride From d41230a0c56b6ea9054f7fbccc31c3500352c00f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 20:51:14 +1000 Subject: [PATCH 26/90] Tweak the look of the recordfilterbox. Keep titlebar if floating. --- apps/opencs/view/doc/view.cpp | 23 ++++++++------------- apps/opencs/view/filter/recordfilterbox.cpp | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index b2317d77b..6c04ac322 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -322,8 +322,11 @@ void CSVDoc::View::updateSubViewIndicies(SubView *view) if(mSubViews.size() == 1) { - mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); - updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + if(!mSubViews.at(0)->isFloating()) + { + mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); + updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + } } else { @@ -471,7 +474,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if(std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end()) { view = mSubViewFactory.makeSubView (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()), *mDocument); - } else + } + else { view = mSubViewFactory.makeSubView (id, *mDocument); } @@ -488,17 +492,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); view->setMinimumWidth(minWidth); -#if 0 - if(mSubViews.size() == 1) // remove subview title and add to the main window - { - updateTitle(id.getTypeName().c_str()); - // FIXME: search area broken - view->setTitleBarWidget(new QWidget(this)); - } - else -#endif - updateSubViewIndicies(); - view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window @@ -511,6 +504,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); + updateSubViewIndicies(); + connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this, SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&))); diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index ef2aeb4d3..97490d508 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -11,7 +11,7 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare { QHBoxLayout *layout = new QHBoxLayout (this); - layout->setContentsMargins (0, 0, 0, 0); + layout->setContentsMargins (0, 6, 5, 0); QLabel *label = new QLabel("Record Filter", this); label->setIndent(2); From 67503c93b29839ab37929616a7d2f60d3241ddd9 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 22:33:49 +1000 Subject: [PATCH 27/90] Added some scenewidget user settings but noticed during testing that the spinbox view resets the value if enter key is pressed. --- apps/opencs/model/settings/usersettings.cpp | 51 +++++++++++++++++++++ apps/opencs/view/render/scenewidget.cpp | 26 +++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 82f4bc750..e4cbac3c3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -208,6 +208,57 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetDefaultValue(4); + fastFactor->setEditorSetting(false); + fastFactor->setColumnSpan (1); + fastFactor->setMinimum (1); // FIXME: this function appears to be broken + fastFactor->setMaximum (100); // FIXME: not sure what the max value should be + fastFactor->setWidgetWidth (10); + fastFactor->setViewLocation(1, 2); + Setting *ffText = createSetting (Type_Undefined, page, "ffText"); + ffText->setSpecialValueText("Fast Factor"); // hack to place text labels + ffText->setEditorSetting(false); + ffText->setSerializable (false); + ffText->setColumnSpan (1); + ffText->setWidgetWidth (10); + ffText->setViewLocation(1, 1); + + Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); + farClipDist->setDefaultValue(300000); + farClipDist->setEditorSetting(false); + farClipDist->setColumnSpan (1); + farClipDist->setMinimum (0); + farClipDist->setMaximum (1000000); // FIXME: not sure what the max value should be + farClipDist->setWidgetWidth (10); + farClipDist->setViewLocation(2, 2); + Setting *fcText = createSetting (Type_Undefined, page, "fcText"); + fcText->setSpecialValueText("Far Clip Distance"); // hack to place text labels + fcText->setEditorSetting(false); + fcText->setSerializable (false); + fcText->setColumnSpan (1); + fcText->setWidgetWidth (10); + fcText->setViewLocation(2, 1); + + Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); + timerStart->setDefaultValue(20); + timerStart->setEditorSetting(false); + timerStart->setColumnSpan (1); + timerStart->setMinimum (0); + timerStart->setMaximum (100); // FIXME: not sure what the max value should be + timerStart->setWidgetWidth (10); + timerStart->setViewLocation(3, 2); + Setting *tsText = createSetting (Type_Undefined, page, "tsText"); + tsText->setSpecialValueText("Timer Start"); // hack to place text labels + tsText->setEditorSetting(false); + tsText->setSerializable (false); + tsText->setColumnSpan (1); + tsText->setWidgetWidth (10); + tsText->setViewLocation(3, 1); + } + #if 0 page = "Window Size"; { diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1a720ff33..8605f5d0f 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -13,6 +13,7 @@ #include #include "../widget/scenetoolmode.hpp" +#include "../../model/settings/usersettings.hpp" #include "navigation.hpp" #include "lighting.hpp" @@ -27,7 +28,7 @@ namespace CSVRender , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false) , mKeyRollLeft (false), mKeyRollRight (false) , mFast (false), mDragging (false), mMod1 (false) - , mFastFactor (4) /// \todo make this configurable + , mFastFactor (4) , mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false) { setAttribute(Qt::WA_PaintOnScreen); @@ -44,7 +45,20 @@ namespace CSVRender mCamera->setPosition (300, 0, 0); mCamera->lookAt (0, 0, 0); mCamera->setNearClipDistance (0.1); - mCamera->setFarClipDistance (300000); ///< \todo make this configurable + + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + int farClipDist = 300000; + if(userSettings.hasSettingDefinitions("Scene/far clip distance")) + farClipDist = userSettings.settingValue("Scene/far clip distance").toInt(); + else + userSettings.setDefinitions("Scene/far clip distance", (QStringList() << QString(farClipDist))); + mCamera->setFarClipDistance (farClipDist); + + if(userSettings.hasSettingDefinitions("Scene/fast factor")) + mFastFactor = userSettings.settingValue("Scene/fast factor").toInt(); + else + userSettings.setDefinitions("Scene/fast factor", (QStringList() << QString(mFastFactor))); + mCamera->roll (Ogre::Degree (90)); setLighting (&mLightingDay); @@ -52,7 +66,13 @@ namespace CSVRender QTimer *timer = new QTimer (this); connect (timer, SIGNAL (timeout()), this, SLOT (update())); - timer->start (20); ///< \todo make this configurable + + int timerStart = 20; + if(userSettings.hasSettingDefinitions("Scene/timer start")) + timerStart = userSettings.settingValue("Scene/timer start").toInt(); + else + userSettings.setDefinitions("Scene/timer start", (QStringList() << QString(timerStart))); + timer->start (timerStart); /// \todo make shortcut configurable QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut); From 970f3609c9df83ae6bae5962a9943f9df0d53543 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 09:33:19 +1000 Subject: [PATCH 28/90] Fixed spinbox issue with integer entry via keyboard. Removed shader settings as per feedback comments. --- apps/opencs/editor.cpp | 37 ++++++++++---- apps/opencs/model/settings/usersettings.cpp | 55 ++------------------- apps/opencs/view/settings/spinbox.cpp | 2 +- 3 files changed, 31 insertions(+), 63 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 25e65b7ee..bdc61a5fe 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,20 +314,37 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", - mUserSettings.settingValue("shader/fog").toStdString()); + std::string fog("true"); // default if setting does not exist + if(mUserSettings.hasSettingDefinitions("Shader/fog")) + fog = mUserSettings.settingValue("Shader/fog").toStdString(); + else + mUserSettings.setDefinitions("Shader/fog", (QStringList() << QString(fog.c_str()))); + sh::Factory::getInstance().setGlobalSetting ("fog", fog); - sh::Factory::getInstance().setGlobalSetting ("shadows", - mUserSettings.settingValue("shader/shadows").toStdString()); + std::string shadows("false"); + if(mUserSettings.hasSettingDefinitions("Shader/shadows")) + shadows = mUserSettings.settingValue("Shader/shadows").toStdString(); + else + mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); + sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", - mUserSettings.settingValue("shader/shadows_pssm").toStdString()); + std::string shadows_pssm("false"); + if(mUserSettings.hasSettingDefinitions("Shader/shadows_pssm")) + shadows_pssm = mUserSettings.settingValue("Shader/shadows_pssm").toStdString(); + else + mUserSettings.setDefinitions("Shader/shadows_pssm", (QStringList() << QString(shadows_pssm.c_str()))); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", - mUserSettings.settingValue("shader/render_refraction").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", - mUserSettings.settingValue("shader/viewproj_fix").toStdString()); + std::string render_refraction("false"); + if(mUserSettings.hasSettingDefinitions("Shader/render_refraction")) + render_refraction = mUserSettings.settingValue("Shader/render_refraction").toStdString(); + else + mUserSettings.setDefinitions("Shader/render_refraction", (QStringList() << QString(render_refraction.c_str()))); + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", render_refraction); + + // internal setting - may be switched on or off by the use of shader configurations + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setGlobalSetting ("num_lights", mUserSettings.settingValue("shader/num_lights").toStdString()); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e4cbac3c3..95da7d150 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -59,36 +59,6 @@ void UserSettings::buildSettingModelDefaults() { QString section = "Group1"; - Setting *fog = createSetting (Type_CheckBox, page, "fog"); - fog->setDeclaredValues(QStringList() << "true" << "false"); - fog->setDefaultValue("true"); - fog->setEditorSetting(true); - fog->setSpecialValueText("Enable Fog"); - fog->setWidgetWidth(15); - fog->setColumnSpan (2); - fog->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); - fog->setViewLocation(1, 1); - - Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); - shadows->setDeclaredValues(QStringList() << "true" << "false"); - shadows->setDefaultValue("false"); - shadows->setEditorSetting(true); - shadows->setSpecialValueText("Enable Shadows"); - shadows->setWidgetWidth(15); - shadows->setColumnSpan (2); - shadows->setStyleSheet ("QGroupBox { border: 0px; }"); - shadows->setViewLocation(2, 1); - - Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); - shadows_pssm->setDeclaredValues(QStringList() << "true" << "false"); - shadows_pssm->setDefaultValue("false"); - shadows_pssm->setEditorSetting(true); - shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); - shadows_pssm->setWidgetWidth(15); - shadows_pssm->setColumnSpan (2); - shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); - shadows_pssm->setViewLocation(3, 1); - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); @@ -97,34 +67,15 @@ void UserSettings::buildSettingModelDefaults() numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 - numLights->setViewLocation(4, 2); + numLights->setViewLocation(1, 2); Setting *nlText = createSetting (Type_Undefined, page, "nlText"); nlText->setSpecialValueText("Num Lights"); // hack to place text labels nlText->setEditorSetting(false); nlText->setSerializable (false); nlText->setColumnSpan (1); nlText->setWidgetWidth (10); - nlText->setViewLocation(4, 1); - - Setting *renderRefraction = createSetting (Type_CheckBox, page, "renderRefraction"); - renderRefraction->setDeclaredValues(QStringList() << "true" << "false"); - renderRefraction->setDefaultValue("false"); - renderRefraction->setEditorSetting(true); - renderRefraction->setSpecialValueText("Enable Render Refraction"); - renderRefraction->setWidgetWidth(20); - renderRefraction->setColumnSpan (2); - renderRefraction->setStyleSheet ("QGroupBox { border: 0px; }"); - renderRefraction->setViewLocation(5, 1); - - Setting *viewproj_fix = createSetting (Type_CheckBox, page, "viewproj_fix"); - viewproj_fix->setDeclaredValues(QStringList() << "true" << "false"); - viewproj_fix->setDefaultValue("false"); - viewproj_fix->setEditorSetting(true); - viewproj_fix->setSpecialValueText("View Proj Fix"); - viewproj_fix->setWidgetWidth(20); - viewproj_fix->setColumnSpan (2); - viewproj_fix->setStyleSheet ("QGroupBox { border: 0px; }"); - viewproj_fix->setViewLocation(6, 1); + nlText->setViewLocation(1, 1); + Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); simpleWater->setDeclaredValues(QStringList() << "true" << "false"); diff --git a/apps/opencs/view/settings/spinbox.cpp b/apps/opencs/view/settings/spinbox.cpp index 4b1447f8f..c70fc36d1 100644 --- a/apps/opencs/view/settings/spinbox.cpp +++ b/apps/opencs/view/settings/spinbox.cpp @@ -24,7 +24,7 @@ QString CSVSettings::SpinBox::textFromValue(int val) const int CSVSettings::SpinBox::valueFromText(const QString &text) const { if (mValueList.isEmpty()) - return -1; + return text.toInt(); // TODO: assumed integer, untested error handling for alpha types if (mValueList.contains (text)) return mValueList.indexOf(text); From 3f9b73812b4a8a823f28631614d1492df6060776 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 11:55:22 +1000 Subject: [PATCH 29/90] Minor fixes and workarounds. --- apps/opencs/model/settings/usersettings.cpp | 14 ++++++++------ apps/opencs/view/settings/dialog.cpp | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 95da7d150..42fd897b2 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -94,7 +94,6 @@ void UserSettings::buildSettingModelDefaults() waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be waterEnabled->setWidgetWidth (10); - //waterEnabled->setStyleSheet("QGroupBox { border:2px; padding 2px; margin: 2px;} QGroupBox::title { text: \"test\" }"); waterEnabled->setViewLocation(2, 6); Setting *weText = createSetting (Type_Undefined, page, "weText"); weText->setSpecialValueText("Water Enabled"); @@ -113,7 +112,7 @@ void UserSettings::buildSettingModelDefaults() waterLevel->setWidgetWidth (10); waterLevel->setViewLocation(3, 6); Setting *wlText = createSetting (Type_Undefined, page, "wlText"); - wlText->setSpecialValueText("Water Level"); // hack to place text labels + wlText->setSpecialValueText("Water Level"); wlText->setEditorSetting(false); wlText->setSerializable (false); wlText->setColumnSpan (1); @@ -129,7 +128,7 @@ void UserSettings::buildSettingModelDefaults() waterTimer->setWidgetWidth (10); waterTimer->setViewLocation(4, 6); Setting *wtText = createSetting (Type_Undefined, page, "wtText"); - wtText->setSpecialValueText("Water Timer"); // hack to place text labels + wtText->setSpecialValueText("Water Timer"); wtText->setEditorSetting(false); wtText->setSerializable (false); wtText->setColumnSpan (1); @@ -165,7 +164,10 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); - fastFactor->setMinimum (1); // FIXME: this function appears to be broken + // FIXME: setMinimum or setSpecialVlueText appears to be broken, possibly due + // to there being an empty string default for special value text. + fastFactor->setMinimum (1); + fastFactor->setSpecialValueText("1"); // workaround for above fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); @@ -186,7 +188,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetWidgetWidth (10); farClipDist->setViewLocation(2, 2); Setting *fcText = createSetting (Type_Undefined, page, "fcText"); - fcText->setSpecialValueText("Far Clip Distance"); // hack to place text labels + fcText->setSpecialValueText("Far Clip Distance"); fcText->setEditorSetting(false); fcText->setSerializable (false); fcText->setColumnSpan (1); @@ -202,7 +204,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetWidgetWidth (10); timerStart->setViewLocation(3, 2); Setting *tsText = createSetting (Type_Undefined, page, "tsText"); - tsText->setSpecialValueText("Timer Start"); // hack to place text labels + tsText->setSpecialValueText("Timer Start"); tsText->setEditorSetting(false); tsText->setSerializable (false); tsText->setColumnSpan (1); diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index e328384e8..7d2b8f0a5 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -306,7 +306,7 @@ void CSVSettings::Dialog::buildPages() sbMinSubViewWidth->setValue(325); if(model()->hasSettingDefinitions("SubView/max subviews")) - sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt()); + sbMaxSubViews->setValue(model()->settingValue("SubView/max subviews").toInt()); else sbMaxSubViews->setValue(3); From fdf375fb4d21d19373e2be16b4ddba3069804c8f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 13:49:19 +1000 Subject: [PATCH 30/90] Reusing subviews implemented. --- apps/opencs/view/doc/view.cpp | 30 +++++++++++++++++++++++++--- apps/opencs/view/settings/dialog.cpp | 7 +++++++ files/ui/settingstab.ui | 4 ++-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 6c04ac322..baa3a3608 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -454,6 +454,33 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin { CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + const std::vector referenceables(CSMWorld::UniversalId::listReferenceableTypes()); + bool isReferenceable = std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end(); + + // User setting to reuse sub views (on a per top level view basis) + bool reuse = true; + if(userSettings.hasSettingDefinitions("SubView/reuse")) + reuse = userSettings.settingValue("SubView/reuse").toStdString() == "true" ? true : false; + else + userSettings.setDefinitions("SubView/reuse", (QStringList() << QString(reuse ? "true" : "false"))); + if(reuse) + { + foreach(SubView *sb, mSubViews) + { + if((isReferenceable && (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()) == CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, sb->getUniversalId().getId()))) + || (!isReferenceable && (id == sb->getUniversalId()))) + { + sb->setFocus(Qt::OtherFocusReason); // FIXME: focus not quite working + return; + } + } + } + + // User setting for limiting the number of sub views per top level view. + // Automatically open a new top level view if this number is exceeded + // + // If the sub view limit setting is one, the sub view title bar is hidden and the + // text in the main title bar is adjusted accordingly int maxSubView = 3; if(userSettings.hasSettingDefinitions("SubView/max subviews")) maxSubView = userSettings.settingValue("SubView/max subviews").toInt(); @@ -467,9 +494,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin return; } - /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) - - const std::vector referenceables(CSMWorld::UniversalId::listReferenceableTypes()); SubView *view = NULL; if(std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end()) { diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 7d2b8f0a5..f2d38bab9 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -310,6 +310,8 @@ void CSVSettings::Dialog::buildPages() else sbMaxSubViews->setValue(3); + cbReuseSubView->setChecked(model()->settingValue("SubView/reuse") == "true"); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -393,6 +395,11 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("SubView/max subviews", QStringList(QString::number(sbMaxSubViews->value()))); + if(cbReuseSubView->isChecked()) + model()->setDefinitions("SubView/reuse", QStringList("true")); + else + model()->setDefinitions("SubView/reuse", QStringList("false")); + saveSettings(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 95c10367a..e44a51f5a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -161,7 +161,7 @@ - + Reuse Subviews @@ -391,7 +391,7 @@ cbStatusBar sbMaxSubViews sbMinSubViewWidth - checkBox_reuse_subview + cbReuseSubView cbOverride cmbRenderSys cbVsync From 66852d5392fff015acab5081eea9a3284ec2fbd2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 22:41:49 +1000 Subject: [PATCH 31/90] Code cleanup and revert incorrect settings. --- apps/opencs/editor.cpp | 13 +- apps/opencs/model/settings/usersettings.cpp | 122 +----- apps/opencs/view/doc/view.cpp | 11 - apps/opencs/view/doc/viewmanager.cpp | 7 - apps/opencs/view/doc/viewmanager.hpp | 2 - apps/opencs/view/settings/dialog.cpp | 73 +--- apps/opencs/view/settings/dialog.hpp | 6 - apps/opencs/view/settings/frame.cpp | 5 +- files/ui/settingstab.ui | 404 ++++++++------------ 9 files changed, 183 insertions(+), 460 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index bdc61a5fe..960e54e88 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,7 +314,14 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - std::string fog("true"); // default if setting does not exist + bool shaders = true; // default if setting does not exist + if(mUserSettings.hasSettingDefinitions("Objects/shaders")) + shaders = mUserSettings.settingValue("Objects/shaders").toStdString() == "true" ? true : false; + else + mUserSettings.setDefinitions("Objects/shaders", (QStringList() << QString(shaders ? "true" : "false"))); + sh::Factory::getInstance ().setShadersEnabled (shaders); + + std::string fog("true"); if(mUserSettings.hasSettingDefinitions("Shader/fog")) fog = mUserSettings.settingValue("Shader/fog").toStdString(); else @@ -323,7 +330,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::string shadows("false"); if(mUserSettings.hasSettingDefinitions("Shader/shadows")) - shadows = mUserSettings.settingValue("Shader/shadows").toStdString(); + shadows = shaders? mUserSettings.settingValue("Shader/shadows").toStdString() : "false"; else mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); @@ -347,7 +354,7 @@ std::auto_ptr CS::Editor::setupGraphics() sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setGlobalSetting ("num_lights", - mUserSettings.settingValue("shader/num_lights").toStdString()); + mUserSettings.settingValue("Objects/num_lights").toStdString()); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 42fd897b2..44473c03d 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -55,7 +55,7 @@ void UserSettings::buildSettingModelDefaults() { QString page; - page = "Shader"; + page = "Objects"; { QString section = "Group1"; @@ -66,96 +66,17 @@ void UserSettings::buildSettingModelDefaults() numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); - numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 numLights->setViewLocation(1, 2); - Setting *nlText = createSetting (Type_Undefined, page, "nlText"); - nlText->setSpecialValueText("Num Lights"); // hack to place text labels - nlText->setEditorSetting(false); - nlText->setSerializable (false); - nlText->setColumnSpan (1); - nlText->setWidgetWidth (10); - nlText->setViewLocation(1, 1); - - - Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); - simpleWater->setDeclaredValues(QStringList() << "true" << "false"); - simpleWater->setDefaultValue("false"); - simpleWater->setEditorSetting(true); - simpleWater->setSpecialValueText("Enable Simple Water"); - simpleWater->setWidgetWidth(25); - simpleWater->setColumnSpan (3); - simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); - simpleWater->setViewLocation(1, 5); - - Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); - waterEnabled->setDefaultValue(0.00); - waterEnabled->setEditorSetting(true); - waterEnabled->setColumnSpan (1); - waterEnabled->setMinimum (0); - waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be - waterEnabled->setWidgetWidth (10); - waterEnabled->setViewLocation(2, 6); - Setting *weText = createSetting (Type_Undefined, page, "weText"); - weText->setSpecialValueText("Water Enabled"); - weText->setEditorSetting(false); - weText->setSerializable (false); - weText->setColumnSpan (1); - weText->setWidgetWidth (10); - weText->setViewLocation(2, 5); - - Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); - waterLevel->setDefaultValue(0.00); - waterLevel->setEditorSetting(true); - waterLevel->setColumnSpan (1); - waterLevel->setMinimum (0); - waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be - waterLevel->setWidgetWidth (10); - waterLevel->setViewLocation(3, 6); - Setting *wlText = createSetting (Type_Undefined, page, "wlText"); - wlText->setSpecialValueText("Water Level"); - wlText->setEditorSetting(false); - wlText->setSerializable (false); - wlText->setColumnSpan (1); - wlText->setWidgetWidth (10); - wlText->setViewLocation(3, 5); - - Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); - waterTimer->setDefaultValue(0.00); - waterTimer->setEditorSetting(true); - waterTimer->setColumnSpan (1); - waterTimer->setMinimum (0); - waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be - waterTimer->setWidgetWidth (10); - waterTimer->setViewLocation(4, 6); - Setting *wtText = createSetting (Type_Undefined, page, "wtText"); - wtText->setSpecialValueText("Water Timer"); - wtText->setEditorSetting(false); - wtText->setSerializable (false); - wtText->setColumnSpan (1); - wtText->setWidgetWidth (10); - wtText->setViewLocation(4, 5); - - - Setting *spaceText = createSetting (Type_Undefined, page, "spaceText"); - spaceText->setSpecialValueText(" "); - spaceText->setEditorSetting(false); - spaceText->setSerializable (false); - spaceText->setColumnSpan (1); - spaceText->setWidgetWidth (5); - spaceText->setViewLocation(3, 4); - Setting *spaceText2 = createSetting (Type_Undefined, page, "spaceText2"); - spaceText2->setSpecialValueText(" "); - spaceText2->setEditorSetting(false); - spaceText2->setSerializable (false); - spaceText2->setColumnSpan (1); - spaceText2->setWidgetWidth (5); - spaceText2->setViewLocation(3, 7); -#if 0 -sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); -sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); -sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); -#endif + Setting *shaders = createSetting (Type_CheckBox, page, "shaders"); + shaders->setDeclaredValues(QStringList() << "true" << "false"); + shaders->setDefaultValue("true"); + shaders->setEditorSetting(true); + shaders->setSpecialValueText("Enable Shaders"); + shaders->setWidgetWidth(25); + shaders->setColumnSpan (3); + shaders->setStyleSheet ("QGroupBox { border: 0px; }"); + shaders->setViewLocation(2, 1); } page = "Scene"; @@ -171,13 +92,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *ffText = createSetting (Type_Undefined, page, "ffText"); - ffText->setSpecialValueText("Fast Factor"); // hack to place text labels - ffText->setEditorSetting(false); - ffText->setSerializable (false); - ffText->setColumnSpan (1); - ffText->setWidgetWidth (10); - ffText->setViewLocation(1, 1); Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); farClipDist->setDefaultValue(300000); @@ -187,13 +101,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (1000000); // FIXME: not sure what the max value should be farClipDist->setWidgetWidth (10); farClipDist->setViewLocation(2, 2); - Setting *fcText = createSetting (Type_Undefined, page, "fcText"); - fcText->setSpecialValueText("Far Clip Distance"); - fcText->setEditorSetting(false); - fcText->setSerializable (false); - fcText->setColumnSpan (1); - fcText->setWidgetWidth (10); - fcText->setViewLocation(2, 1); Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); timerStart->setDefaultValue(20); @@ -203,13 +110,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (100); // FIXME: not sure what the max value should be timerStart->setWidgetWidth (10); timerStart->setViewLocation(3, 2); - Setting *tsText = createSetting (Type_Undefined, page, "tsText"); - tsText->setSpecialValueText("Timer Start"); - tsText->setEditorSetting(false); - tsText->setSerializable (false); - tsText->setColumnSpan (1); - tsText->setWidgetWidth (10); - tsText->setViewLocation(3, 1); } #if 0 @@ -251,6 +151,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetEditorSetting (true); ritd->setEditorSetting (true); } -#endif page = "Proxy Selection Test"; { diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index baa3a3608..3a62aeafb 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -376,9 +376,6 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to hide(); resize (width.toInt() - (frameGeometry().width() - geometry().width()), height.toInt() - (frameGeometry().height() - geometry().height())); - // start at the centre of the screen - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - move(screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2)); mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); @@ -517,14 +514,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view->setMinimumWidth(minWidth); view->setStatusBar (mShowStatusBar->isChecked()); -// NOTE: only required if show status bar setting should be applied to existing -// window -#if 0 - std::string showStatusBar = - CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); - - view->setStatusBar (showStatusBar == "true"); -#endif mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 39cd7eeda..2b46eecd2 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -401,13 +401,6 @@ bool CSVDoc::ViewManager::removeDocument (CSVDoc::View *view) return true; } -void CSVDoc::ViewManager::toggleStatusBar(bool checked) -{ - // NOTE: below only required if status bar change is to be applied to existing - //for (std::vector::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter) - //(*iter)->toggleStatusBar(checked); -} - void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view) { if(!removeDocument(view)) // close the current document first diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index d703b430a..cdd5ac768 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -81,8 +81,6 @@ namespace CSVDoc void exitApplication (CSVDoc::View *view); - void toggleStatusBar(bool checked); - private slots: void documentStateChanged (int state, CSMDoc::Document *document); diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index f2d38bab9..7648813bf 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -87,27 +87,12 @@ QStringList getAvailableResolutions() Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); for(;it != renderOpt.end(); ++it) { - if(it->first == "Rendering Device" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Rendering Devices - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) - { - std::cout << "rd: " << *iter << std::endl; // FIXME: debug - } - } if(it->first == "Video Mode" ) { if(it->second.possibleValues.empty()) { return result; // FIXME: add error message } - // FIXME: how to default to the current value? - std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(; iter != it->second.possibleValues.end(); ++iter) @@ -138,7 +123,7 @@ QStringList getAvailableResolutions() CSVSettings::Dialog::Dialog(QTabWidget *parent) - : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) + : mDebugMode (false), SettingWindow (parent) { setObjectName(QString::fromUtf8 ("User Settings")); @@ -151,12 +136,8 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - // to update the checkbox on the view menu - connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); displayGroup_Window->installEventFilter(this); - - setupDialog(); } bool CSVSettings::Dialog::eventFilter(QObject *target, QEvent *event) @@ -185,19 +166,6 @@ void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) cmbShaderLang->clear(); cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); - - if(model()->settingValue("Video/use settings.cfg") == "true") - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - cbOverride->setChecked(false); } void CSVSettings::Dialog::slotOverrideToggled(bool checked) @@ -208,7 +176,6 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -218,16 +185,11 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(true); labAntiAlias->setEnabled(true); cmbAntiAlias->setEnabled(true); - //cbVsync->setEnabled(true); labShaderLang->setEnabled(true); cmbShaderLang->setEnabled(true); } } -void CSVSettings::Dialog::setupDialog() -{ -} - void CSVSettings::Dialog::buildPages() { int index = -1; @@ -238,7 +200,6 @@ void CSVSettings::Dialog::buildPages() // Ogre renderer cmbRenderSys->clear(); cmbRenderSys->addItems(model()->getOgreRenderers()); - //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = model()->settingValue("Video/antialiasing"); @@ -246,11 +207,6 @@ void CSVSettings::Dialog::buildPages() if(index != -1) cmbAntiAlias->setCurrentIndex(index); - // vsync - //cbVsync->setChecked(model()->settingValue("Video/vsync") == "true"); - cbVsync->setChecked(false); // disable vsync option for now - cbVsync->setEnabled(false); // disable vsync option for now - // shader lang QString shaderlang = model()->settingValue("General/shader mode"); index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); @@ -288,17 +244,6 @@ void CSVSettings::Dialog::buildPages() // status bar cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); - // display format - QString recStat = model()->settingValue("Display Format/Record Status Display"); - index = cmbRecStatus->findData(recStat, Qt::DisplayRole); - if(index != -1) - cmbRecStatus->setCurrentIndex(index); - - QString refIdType = model()->settingValue("Display Format/Referenceable ID Type Display"); - index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); - if(index != -1) - cmbRefIdType->setCurrentIndex(index); - // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); @@ -341,20 +286,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Video/render system", QStringList(cmbRenderSys->currentText())); - // vsync - if(cbVsync->isChecked()) - model()->setDefinitions("Video/vsync", QStringList("true")); - else - model()->setDefinitions("Video/vsync", QStringList("false")); - // antialiasing model()->setDefinitions("Video/antialiasing", QStringList(cmbAntiAlias->currentText())); -#if 0 - QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) - model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); -#endif // shader lang (no group means "General" group) model()->setDefinitions("shader mode", @@ -384,11 +318,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) else model()->setDefinitions("Display/show statusbar", QStringList("false")); - // display format - model()->setDefinitions("Display Format/Record Status Display", - QStringList(cmbRecStatus->currentText())); - model()->setDefinitions("Display Format/Referenceable ID Type Display", - QStringList(cmbRefIdType->currentText())); // subview model()->setDefinitions("SubView/minimum width", QStringList(QString::number(sbMinSubViewWidth->value()))); diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index e2e93d8a1..cfe48b618 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -31,8 +31,6 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); - void setupDialog(); - bool eventFilter(QObject *target, QEvent *event); private: @@ -47,10 +45,6 @@ namespace CSVSettings { void slotOverrideToggled(bool checked); void slotRendererChanged(const QString &renderer); - - signals: - - void toggleStatusBar(bool checked); // FIXME: maybe not needed }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index c39eba890..a3df2a993 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -3,7 +3,7 @@ #include const QString CSVSettings::Frame::sInvisibleBoxStyle = - QString::fromUtf8("Frame { border:2px; padding 2px; margin: 2px;}"); + QString::fromUtf8("Frame { border:2px; padding: 2px; margin: 2px;}"); CSVSettings::Frame::Frame (bool isVisible, const QString &title, QWidget *parent) @@ -16,8 +16,7 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, if (!isVisible) { // must be Page, not a View - //setStyleSheet (sInvisibleBoxStyle); - setStyleSheet("QGroupBox { border:0px; }"); + setStyleSheet (sInvisibleBoxStyle); mLayout->setContentsMargins(10, 15, 10, 15); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index e44a51f5a..0a94348d1 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -20,161 +20,51 @@ Display Settings - + 10 - 10 + 200 371 - 81 + 79 - Display Format + Subviews - + - 10 - 20 - 351 - 48 + 240 + 21 + 102 + 17 - - - - - Record Status: - - - - - - - - Text Only - - - - - Icon Only - - - - - Icon and Text - - - - - - - - Referenceable ID Type: - - - - - - - - Text Only - - - - - Icon Only - - - - - Icon and Text - - - - - + + Show Status Bar + + + + + + 240 + 49 + 101 + 17 + + + + Reuse Subviews + - - - - - 9 - 160 - 371 - 101 - - - - Subviews - - - - - - 21 - 180 - 351 - 71 - - - - - - - Max Number of Subviews: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - - - - - Min Subview Width: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 50 - - - 20000 - - - 5 - - - - - - - Reuse Subviews - - - - 10 - 100 - 201 + 140 + 211 51 @@ -189,7 +79,7 @@ 10 20 - 181 + 191 22 @@ -205,7 +95,7 @@ 0 0 - 181 + 191 22 @@ -242,7 +132,7 @@ 0 0 - 181 + 191 22 @@ -250,153 +140,177 @@ - + - 240 - 120 - 102 + 21 + 29 + 231 17 - Show Status Bar + Use Render System Settings from OpenMW + + + true - displayGroup_Subviews - layoutWidget_Subviews - displayGroup_Window - displayGroup_DisplayFormat - cbStatusBar - - - - Video Settings - - + + + + 10 + 10 + 371 + 125 + + + + Render System + + + + + 172 + 42 + 181 + 20 + + + + false + + + + + + 12 + 94 + 54 + 16 + + + + Antialiasing + + + + + + 12 + 68 + 84 + 16 + + + + Shader Language + + + + + + 12 + 42 + 104 + 16 + + + + Rendering Subsystem + + + + + + 172 + 68 + 181 + 20 + + + + + + + 172 + 94 + 181 + 20 + + + + + 20 - 26 - 351 - 129 + 220 + 191 + 48 - - - - - Use Render System Settings from OpenMW - - - true - - - - - + + + - Rendering Subsystem + Max Number of Subviews: - - - - false + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - Antialiasing + + 1 - - + + - Vertical Sync + Min Subview Width: - - - - Shader Language + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - 16777215 - 2 - + + 50 - - color: rgb(215, 215, 215); + + 20000 - - Qt::Horizontal + + 5 - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 9 - 169 - 371 - 101 - - - - title - - displayGroup_Render - layoutWidget_Render - groupBox + displayGroup_Subviews + displayGroup_Window + cbOverride + layoutWidget_2 - cmbRecStatus - cmbRefIdType + cbOverride + cmbRenderSys + cmbShaderLang + cmbAntiAlias sbWidth sbHeight - cbStatusBar sbMaxSubViews sbMinSubViewWidth + cbStatusBar cbReuseSubView - cbOverride - cmbRenderSys - cbVsync - cmbAntiAlias - cmbShaderLang cmbStdWinSize From 31fb160376e710ad917e38a7add9b0b690012934 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 06:59:04 +1000 Subject: [PATCH 32/90] More cleanup. --- apps/opencs/view/settings/dialog.hpp | 2 -- apps/opencs/view/world/previewsubview.cpp | 2 +- apps/opencs/view/world/regionmapsubview.cpp | 2 +- apps/opencs/view/world/scenesubview.cpp | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index cfe48b618..47422feb4 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -14,8 +14,6 @@ namespace CSVSettings { { Q_OBJECT - //QListWidget *mPageListWidget; - //ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 316f7c71e..1e106c69f 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -63,4 +63,4 @@ void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id) setWindowTitle ("Preview: Reference to "); else setWindowTitle (("Preview: Reference to " + id).c_str()); -} +} \ No newline at end of file diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index 411e24e75..a7675a4a6 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -24,4 +24,4 @@ void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id, const std::string& hint) { focusId (id, hint); -} +} \ No newline at end of file diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 699bf81f6..52bd47b54 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -9,7 +9,7 @@ #include #include "../../model/doc/document.hpp" -#include "../../model/settings/usersettings.hpp" + #include "../../model/world/cellselection.hpp" #include "../filter/filterbox.hpp" @@ -254,4 +254,4 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} +} \ No newline at end of file From 61bab6b1f1b6b2b8bec9b47989f04da1cb1b3b18 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 08:15:07 +1000 Subject: [PATCH 33/90] Sanitised version. Some settings are only accessible via manually editing the config file. --- apps/opencs/CMakeLists.txt | 1 - apps/opencs/editor.cpp | 31 +- apps/opencs/model/settings/usersettings.cpp | 18 +- apps/opencs/model/settings/usersettings.hpp | 1 + apps/opencs/view/doc/view.cpp | 22 +- apps/opencs/view/render/scenewidget.cpp | 18 +- apps/opencs/view/settings/dialog.cpp | 356 ++++---------------- apps/opencs/view/settings/dialog.hpp | 18 +- apps/opencs/view/settings/settingwindow.cpp | 9 +- apps/opencs/view/settings/settingwindow.hpp | 8 +- files/ui/settingstab.ui | 318 ----------------- 11 files changed, 108 insertions(+), 692 deletions(-) delete mode 100644 files/ui/settingstab.ui diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index ad04b8a37..7094f8799 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -142,7 +142,6 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc set (OPENCS_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ${CMAKE_SOURCE_DIR}/files/ui/filedialog.ui - ${CMAKE_SOURCE_DIR}/files/ui/settingstab.ui ) source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR}) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 960e54e88..57b0707aa 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,40 +314,19 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - bool shaders = true; // default if setting does not exist - if(mUserSettings.hasSettingDefinitions("Objects/shaders")) - shaders = mUserSettings.settingValue("Objects/shaders").toStdString() == "true" ? true : false; - else - mUserSettings.setDefinitions("Objects/shaders", (QStringList() << QString(shaders ? "true" : "false"))); + bool shaders = mUserSettings.setting("Objects/shaders", (QStringList() << QString("true"))) == "true" ? true : false; sh::Factory::getInstance ().setShadersEnabled (shaders); - std::string fog("true"); - if(mUserSettings.hasSettingDefinitions("Shader/fog")) - fog = mUserSettings.settingValue("Shader/fog").toStdString(); - else - mUserSettings.setDefinitions("Shader/fog", (QStringList() << QString(fog.c_str()))); + std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); - std::string shadows("false"); - if(mUserSettings.hasSettingDefinitions("Shader/shadows")) - shadows = shaders? mUserSettings.settingValue("Shader/shadows").toStdString() : "false"; - else - mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); + std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - std::string shadows_pssm("false"); - if(mUserSettings.hasSettingDefinitions("Shader/shadows_pssm")) - shadows_pssm = mUserSettings.settingValue("Shader/shadows_pssm").toStdString(); - else - mUserSettings.setDefinitions("Shader/shadows_pssm", (QStringList() << QString(shadows_pssm.c_str()))); + std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - - std::string render_refraction("false"); - if(mUserSettings.hasSettingDefinitions("Shader/render_refraction")) - render_refraction = mUserSettings.settingValue("Shader/render_refraction").toStdString(); - else - mUserSettings.setDefinitions("Shader/render_refraction", (QStringList() << QString(render_refraction.c_str()))); + std::string render_refraction = mUserSettings.setting("Shader/render_refraction", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance ().setGlobalSetting ("render_refraction", render_refraction); // internal setting - may be switched on or off by the use of shader configurations diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 44473c03d..a4655f7bf 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -57,8 +57,6 @@ void UserSettings::buildSettingModelDefaults() page = "Objects"; { - QString section = "Group1"; - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); @@ -112,7 +110,6 @@ void UserSettings::buildSettingModelDefaults() timerStart->setViewLocation(3, 2); } -#if 0 page = "Window Size"; { Setting *width = createSetting (Type_LineEdit, page, "Width"); @@ -151,7 +148,6 @@ void UserSettings::buildSettingModelDefaults() QStringList() << "480" << "600" << "768" << "900" ); } -#endif page = "Display Format"; { @@ -499,6 +495,20 @@ QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) return result; } +// if the key is not found create one with a defaut value +QString UserSettings::setting(const QString &viewKey, const QStringList &list) +{ + if(mSettingDefinitions->contains(viewKey)) + return settingValue(viewKey); + else if(!list.empty()) + { + mSettingDefinitions->setValue (viewKey, list); + return list.at(0); + } + + return QString(); +} + bool UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index dfefb131a..01e50739f 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -81,6 +81,7 @@ namespace CSMSettings { QStringList getShaderLanguageByRenderer(const QString &renderer); QStringList getOgreOptions(const QString &key, const QString &renderer); QStringList getOgreRenderers(); + QString setting(const QString &viewKey, const QStringList &list = QStringList()); private: diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 3a62aeafb..2ff00a535 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -455,11 +455,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin bool isReferenceable = std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end(); // User setting to reuse sub views (on a per top level view basis) - bool reuse = true; - if(userSettings.hasSettingDefinitions("SubView/reuse")) - reuse = userSettings.settingValue("SubView/reuse").toStdString() == "true" ? true : false; - else - userSettings.setDefinitions("SubView/reuse", (QStringList() << QString(reuse ? "true" : "false"))); + bool reuse = + userSettings.setting("SubView/reuse", (QStringList() << QString("true"))) == "true" ? true : false; if(reuse) { foreach(SubView *sb, mSubViews) @@ -478,12 +475,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // // If the sub view limit setting is one, the sub view title bar is hidden and the // text in the main title bar is adjusted accordingly - int maxSubView = 3; - if(userSettings.hasSettingDefinitions("SubView/max subviews")) - maxSubView = userSettings.settingValue("SubView/max subviews").toInt(); - else - userSettings.setDefinitions("SubView/max subviews", (QStringList() << QString(maxSubView))); - + int maxSubView = + userSettings.setting("SubView/max subviews", (QStringList() << QString("3"))).toInt(); if(mSubViews.size() >= maxSubView) // create a new top level view { mViewManager.addView(mDocument, id, hint); @@ -506,11 +499,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); - int minWidth = 325; // default value to use if none found - if(userSettings.hasSettingDefinitions("SubView/minimum width")) - minWidth = userSettings.settingValue("SubView/minimum width").toInt(); - else - userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); + int minWidth = + userSettings.setting("SubView/minimum width", (QStringList() << QString("325"))).toInt(); view->setMinimumWidth(minWidth); view->setStatusBar (mShowStatusBar->isChecked()); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 8605f5d0f..ff1765f35 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -47,17 +47,11 @@ namespace CSVRender mCamera->setNearClipDistance (0.1); CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = 300000; - if(userSettings.hasSettingDefinitions("Scene/far clip distance")) - farClipDist = userSettings.settingValue("Scene/far clip distance").toInt(); - else - userSettings.setDefinitions("Scene/far clip distance", (QStringList() << QString(farClipDist))); + + int farClipDist = userSettings.setting("Scene/far clip distance", (QStringList() << QString("300000"))).toInt(); mCamera->setFarClipDistance (farClipDist); - if(userSettings.hasSettingDefinitions("Scene/fast factor")) - mFastFactor = userSettings.settingValue("Scene/fast factor").toInt(); - else - userSettings.setDefinitions("Scene/fast factor", (QStringList() << QString(mFastFactor))); + mFastFactor = userSettings.setting("Scene/fast factor", (QStringList() << QString("4"))).toInt(); mCamera->roll (Ogre::Degree (90)); @@ -67,11 +61,7 @@ namespace CSVRender connect (timer, SIGNAL (timeout()), this, SLOT (update())); - int timerStart = 20; - if(userSettings.hasSettingDefinitions("Scene/timer start")) - timerStart = userSettings.settingValue("Scene/timer start").toInt(); - else - userSettings.setDefinitions("Scene/timer start", (QStringList() << QString(timerStart))); + int timerStart = userSettings.setting("Scene/timer start", (QStringList() << QString("20"))).toInt(); timer->start (timerStart); /// \todo make shortcut configurable diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 7648813bf..56bc1fdfe 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,273 +1,100 @@ #include "dialog.hpp" +#include #include -#include #include +#include +#include #include "../../model/settings/usersettings.hpp" + #include "page.hpp" -#include -#include +#include -namespace { +#include -QRect getMaximumResolution() -{ - QRect max; - int screens = QApplication::desktop()->screenCount(); - for(int i = 0; i < screens; ++i) - { - QRect res = QApplication::desktop()->screenGeometry(i); - if(res.width() > max.width()) - max.setWidth(res.width()); - if(res.height() > max.height()) - max.setHeight(res.height()); - } - return max; -} +#include +#include +#include -QString getAspect(int x, int y) -{ - int gcd = boost::math::gcd (x, y); - int xaspect = x / gcd; - int yaspect = y / gcd; - // special case: 8 : 5 is usually referred to as 16:10 - if (xaspect == 8 && yaspect == 5) - return QString("16:10"); - - return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); -} +#include +#include -QString getCurrentOgreResolution() +CSVSettings::Dialog::Dialog(QMainWindow *parent) + : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) { - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(; it != renderOpt.end(); ++it) - { - if(it->first == "Video Mode" ) - { - QRegExp re("^(\\d+ x \\d+)"); - if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) - return re.cap(1); - } - } - return QString(); // found nothing + setWindowTitle(QString::fromUtf8 ("User Settings")); + + setupDialog(); + + connect (mPageListWidget, + SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, + SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } -bool customCompare(const QString &s1, const QString &s2) +void CSVSettings::Dialog::slotChangePage + (QListWidgetItem *cur, QListWidgetItem *prev) { - int x1, x2, y1, y2; - QRegExp re("^(\\d+) x (\\d+)"); - - if(re.indexIn(s1) > -1) - { - x1 = re.cap(1).toInt(); - y1 = re.cap(2).toInt(); - } - if(re.indexIn(s2) > -1) - { - x2 = re.cap(1).toInt(); - y2 = re.cap(2).toInt(); - } + mStackedWidget->changePage + (mPageListWidget->row (cur), mPageListWidget->row (prev)); - if(x1 == x2) - return y1 > y2; - else - return x1 > x2; + layout()->activate(); + setFixedSize(minimumSizeHint()); } -QStringList getAvailableResolutions() +void CSVSettings::Dialog::setupDialog() { - // store available rendering devices and available resolutions - QStringList result; + //create central widget with it's layout and immediate children + QWidget *centralWidget = new QGroupBox (this); - Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(;it != renderOpt.end(); ++it) - { - if(it->first == "Video Mode" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Resolutions - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(; iter != it->second.possibleValues.end(); ++iter) - { - // extract x and y values - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn((*iter).c_str(), 0) > -1) - { - QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); - QString resolution = re.cap(1) + QString(" x ") + re.cap(2); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { - resolution.append(QObject::tr("\t(Wide ") + aspect + ")"); - - } else if (aspect == QLatin1String("4:3")) { - resolution.append(QObject::tr("\t(Standard 4:3)")); - } - result.append(resolution); - } - } - } - } - result.removeDuplicates(); - qStableSort(result.begin(), result.end(), customCompare); - return result; -} + centralWidget->setLayout (new QHBoxLayout()); + centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); + setCentralWidget (centralWidget); + setDockOptions (QMainWindow::AllowNestedDocks); + buildPageListWidget (centralWidget); + buildStackedWidget (centralWidget); } - -CSVSettings::Dialog::Dialog(QTabWidget *parent) - : mDebugMode (false), SettingWindow (parent) +void CSVSettings::Dialog::buildPages() { - setObjectName(QString::fromUtf8 ("User Settings")); + SettingWindow::createPages (); - setupUi(this); + QFontMetrics fm (QApplication::font()); - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - sbWidth->setMaximum(res.width()); - sbHeight->setMaximum(res.height()); + foreach (Page *page, SettingWindow::pages()) + { + QString pageName = page->objectName(); - connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); + int textWidth = fm.width(pageName); - displayGroup_Window->installEventFilter(this); -} + new QListWidgetItem (pageName, mPageListWidget); + mPageListWidget->setFixedWidth (textWidth + 50); -bool CSVSettings::Dialog::eventFilter(QObject *target, QEvent *event) -{ - if (event->type() == QEvent::MouseButtonDblClick) - { - if(stackedWidget->currentWidget() == page_1) - { - stackedWidget->setCurrentWidget(page_2); - return false; - } - else if(stackedWidget->currentWidget() == page_2) - { - stackedWidget->setCurrentWidget(page_1); - return false; - } + mStackedWidget->addWidget (&dynamic_cast(*(page))); } - return QTabWidget::eventFilter(target, event); + resize (mStackedWidget->sizeHint()); } -void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) +void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) { - cmbAntiAlias->clear(); - cmbAntiAlias->addItems(model()->getOgreOptions(QString("FSAA"), renderer)); + mPageListWidget = new QListWidget (centralWidget); + mPageListWidget->setMinimumWidth(50); + mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); - cmbShaderLang->clear(); - cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); -} + mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); -void CSVSettings::Dialog::slotOverrideToggled(bool checked) -{ - if(checked) - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - { - labRenderSys->setEnabled(true); - cmbRenderSys->setEnabled(true); - labAntiAlias->setEnabled(true); - cmbAntiAlias->setEnabled(true); - labShaderLang->setEnabled(true); - cmbShaderLang->setEnabled(true); - } + centralWidget->layout()->addWidget(mPageListWidget); } -void CSVSettings::Dialog::buildPages() +void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) { - int index = -1; - - // initialised in the constructor - slotOverrideToggled(cbOverride->isChecked()); - - // Ogre renderer - cmbRenderSys->clear(); - cmbRenderSys->addItems(model()->getOgreRenderers()); - - // antialiasing - QString antialiasing = model()->settingValue("Video/antialiasing"); - index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); - if(index != -1) - cmbAntiAlias->setCurrentIndex(index); + mStackedWidget = new ResizeableStackedWidget (centralWidget); - // shader lang - QString shaderlang = model()->settingValue("General/shader mode"); - index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); - if(index != -1) - cmbShaderLang->setCurrentIndex(index); - - if(model()->settingValue("Window Size/Width") != "") - sbWidth->setValue(model()->settingValue("Window Size/Width").toInt()); - - if(model()->settingValue("Window Size/Height") != "") - sbHeight->setValue(model()->settingValue("Window Size/Height").toInt()); - - // update display resolution combo box - cmbStdWinSize->clear(); - cmbStdWinSize->addItems(getAvailableResolutions()); - - QString currRes = model()->settingValue("Window Size/Width") + " x " + - model()->settingValue("Window Size/Height"); - - index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - { - // show the values in ini file - cmbStdWinSize->setCurrentIndex(index); - } - else - { - // show what's in Ogre instead - index = cmbStdWinSize->findData(getCurrentOgreResolution(), - Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - cmbStdWinSize->setCurrentIndex(index); - } - - // status bar - cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); - - // subview - if(model()->hasSettingDefinitions("SubView/minimum width")) - sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); - else - sbMinSubViewWidth->setValue(325); - - if(model()->hasSettingDefinitions("SubView/max subviews")) - sbMaxSubViews->setValue(model()->settingValue("SubView/max subviews").toInt()); - else - sbMaxSubViews->setValue(3); - - cbReuseSubView->setChecked(model()->settingValue("SubView/reuse") == "true"); - - SettingWindow::createPages (); - - foreach (Page *page, SettingWindow::pages()) - { - QString pageName = page->objectName(); - // each page is added as a tab to Ui::TabWiget - addTab(page, page->objectName()); - - // add section and views to the page - page->showWidgets(); - } + centralWidget->layout()->addWidget (mStackedWidget); } void CSVSettings::Dialog::closeEvent (QCloseEvent *event) @@ -276,59 +103,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) //model is updated SettingWindow::closeEvent (event); - // override - if(cbOverride->isChecked()) - model()->setDefinitions("Video/use settings.cfg", QStringList("true")); - else - model()->setDefinitions("Video/use settings.cfg", QStringList("false")); - - // render system - model()->setDefinitions("Video/render system", - QStringList(cmbRenderSys->currentText())); - - // antialiasing - model()->setDefinitions("Video/antialiasing", - QStringList(cmbAntiAlias->currentText())); - - // shader lang (no group means "General" group) - model()->setDefinitions("shader mode", - QStringList(cmbShaderLang->currentText().toLower())); - - // window size - if(page_2->isEnabled()) - { - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(cmbStdWinSize->currentText()) > -1) - { - model()->setDefinitions("Window Size/Width", QStringList(re.cap(1))); - model()->setDefinitions("Window Size/Height", QStringList(re.cap(2))); - } - } - else - { - model()->setDefinitions("Window Size/Width", - QStringList(QString::number(sbWidth->value()))); - model()->setDefinitions("Window Size/Height", - QStringList(QString::number(sbHeight->value()))); - } - - // status bar - if(cbStatusBar->isChecked()) - model()->setDefinitions("Display/show statusbar", QStringList("true")); - else - model()->setDefinitions("Display/show statusbar", QStringList("false")); - - // subview - model()->setDefinitions("SubView/minimum width", - QStringList(QString::number(sbMinSubViewWidth->value()))); - model()->setDefinitions("SubView/max subviews", - QStringList(QString::number(sbMaxSubViews->value()))); - - if(cbReuseSubView->isChecked()) - model()->setDefinitions("SubView/reuse", QStringList("true")); - else - model()->setDefinitions("SubView/reuse", QStringList("false")); - saveSettings(); } @@ -340,20 +114,8 @@ void CSVSettings::Dialog::show() setViewValues(); } - QWidget *currView = QApplication::activeWindow(); - if(currView) - { - // place at the center of the window with focus - QSize size = currView->size(); - move(currView->geometry().x()+(size.width() - frameGeometry().width())/2, - currView->geometry().y()+(size.height() - frameGeometry().height())/2); - } - else - { - // something's gone wrong, place at the center of the screen - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - move(screenCenter - QPoint(frameGeometry().width()/2, - frameGeometry().height()/2)); - } + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + + move (screenCenter - geometry().center()); QWidget::show(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index 47422feb4..b0e12c461 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,23 +2,28 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" +#include "resizeablestackedwidget.hpp" #include -#include "ui_settingstab.h" +class QStackedWidget; +class QListWidget; +class QListWidgetItem; namespace CSVSettings { class Page; - class Dialog : public SettingWindow, private Ui::TabWidget + class Dialog : public SettingWindow { Q_OBJECT + QListWidget *mPageListWidget; + ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: - explicit Dialog (QTabWidget *parent = 0); + explicit Dialog (QMainWindow *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. @@ -29,11 +34,13 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); - bool eventFilter(QObject *target, QEvent *event); + void setupDialog(); private: void buildPages(); + void buildPageListWidget (QWidget *centralWidget); + void buildStackedWidget (QWidget *centralWidget); public slots: @@ -41,8 +48,7 @@ namespace CSVSettings { private slots: - void slotOverrideToggled(bool checked); - void slotRendererChanged(const QString &renderer); + void slotChangePage (QListWidgetItem *, QListWidgetItem *); }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index d9bc890b1..7cdf2bded 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,16 +1,15 @@ -#include "settingwindow.hpp" - #include #include #include "../../model/settings/setting.hpp" #include "../../model/settings/connector.hpp" #include "../../model/settings/usersettings.hpp" +#include "settingwindow.hpp" #include "page.hpp" #include "view.hpp" -CSVSettings::SettingWindow::SettingWindow(QTabWidget *parent) - : QTabWidget(parent) +CSVSettings::SettingWindow::SettingWindow(QWidget *parent) + : QMainWindow(parent) {} void CSVSettings::SettingWindow::createPages() @@ -20,7 +19,7 @@ void CSVSettings::SettingWindow::createPages() QList connectedSettings; foreach (const QString &pageName, pageMap.keys()) - { + { QList pageSettings = pageMap.value (pageName); mPages.append (new Page (pageName, pageSettings, this)); diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 024873ae0..2266f130d 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -1,7 +1,7 @@ #ifndef CSVSETTINGS_SETTINGWINDOW_HPP #define CSVSETTINGS_SETTINGWINDOW_HPP -#include +#include #include #include "../../model/settings/support.hpp" @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QTabWidget + class SettingWindow : public QMainWindow { Q_OBJECT @@ -26,7 +26,7 @@ namespace CSVSettings { CSMSettings::UserSettings *mModel; public: - explicit SettingWindow(QTabWidget *parent = 0); + explicit SettingWindow(QWidget *parent = 0); ///retrieve a reference to a view based on it's page and setting name View *findView (const QString &pageName, const QString &setting); @@ -50,8 +50,6 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); - CSMSettings::UserSettings *model() { return mModel; } - private: ///create connections between settings (used for proxy settings) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui deleted file mode 100644 index 0a94348d1..000000000 --- a/files/ui/settingstab.ui +++ /dev/null @@ -1,318 +0,0 @@ - - - TabWidget - - - - 0 - 0 - 400 - 313 - - - - User Settings - - - 0 - - - - Display Settings - - - - - 10 - 200 - 371 - 79 - - - - Subviews - - - - - 240 - 21 - 102 - 17 - - - - Show Status Bar - - - - - - 240 - 49 - 101 - 17 - - - - Reuse Subviews - - - - - - - 10 - 140 - 211 - 51 - - - - Window Size - - - - true - - - - 10 - 20 - 191 - 22 - - - - 0 - - - - true - - - - - 0 - 0 - 191 - 22 - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - true - - - - - 0 - 0 - 191 - 22 - - - - - - - - - - 21 - 29 - 231 - 17 - - - - Use Render System Settings from OpenMW - - - true - - - - - - 10 - 10 - 371 - 125 - - - - Render System - - - - - 172 - 42 - 181 - 20 - - - - false - - - - - - 12 - 94 - 54 - 16 - - - - Antialiasing - - - - - - 12 - 68 - 84 - 16 - - - - Shader Language - - - - - - 12 - 42 - 104 - 16 - - - - Rendering Subsystem - - - - - - 172 - 68 - 181 - 20 - - - - - - - 172 - 94 - 181 - 20 - - - - - - - - 20 - 220 - 191 - 48 - - - - - - - Max Number of Subviews: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - - - - - Min Subview Width: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 50 - - - 20000 - - - 5 - - - - - - displayGroup_Render - displayGroup_Subviews - displayGroup_Window - cbOverride - layoutWidget_2 - - - - cbOverride - cmbRenderSys - cmbShaderLang - cmbAntiAlias - sbWidth - sbHeight - sbMaxSubViews - sbMinSubViewWidth - cbStatusBar - cbReuseSubView - cmbStdWinSize - - - - From 127f9bb30d4f3081538a3e823c84188741767a97 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 09:16:10 +1000 Subject: [PATCH 34/90] Fix reverting to wrong version. --- apps/opencs/view/settings/dialog.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 56bc1fdfe..72a022c9d 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -114,8 +114,20 @@ void CSVSettings::Dialog::show() setViewValues(); } - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - - move (screenCenter - geometry().center()); + QWidget *currView = QApplication::activeWindow(); + if(currView) + { + // place at the center of the window with focus + QSize size = currView->size(); + move(currView->geometry().x()+(size.width() - frameGeometry().width())/2, + currView->geometry().y()+(size.height() - frameGeometry().height())/2); + } + else + { + // something's gone wrong, place at the center of the screen + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + move(screenCenter - QPoint(frameGeometry().width()/2, + frameGeometry().height()/2)); + } QWidget::show(); } From d5c8ff7d7384352d2be0277cff8e4ed1fdd776d5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 18:15:34 +1000 Subject: [PATCH 35/90] More removal. --- apps/opencs/editor.cpp | 3 +-- apps/opencs/model/settings/usersettings.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 57b0707aa..a8e5287e4 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -278,8 +278,7 @@ std::auto_ptr CS::Editor::setupGraphics() 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("vsync", "false")); params.insert(std::make_pair("hidden", "true")); #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index a4655f7bf..90758bdb0 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -424,9 +424,9 @@ void UserSettings::loadSettings (const QString &fileName) mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group } - // check if override entry exists (default: override) + // check if override entry exists (default: disabled) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) - mSettingDefinitions->setValue("Video/use settings.cfg", "true"); + mSettingDefinitions->setValue("Video/use settings.cfg", "false"); } QStringList UserSettings::getOgreRenderers() From 111a35bc382fa7df3ef01c4ffcbf83e5e92471fe Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 07:16:34 +1000 Subject: [PATCH 36/90] More strip back. --- apps/opencs/editor.cpp | 2 - apps/opencs/model/settings/setting.cpp | 13 +- apps/opencs/model/settings/setting.hpp | 5 +- apps/opencs/model/settings/support.hpp | 14 +- apps/opencs/model/settings/usersettings.cpp | 247 +++++++------------- apps/opencs/model/settings/usersettings.hpp | 4 - 6 files changed, 88 insertions(+), 197 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index a8e5287e4..290dc8732 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -55,8 +55,6 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ())); connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ())); - connect (&mSettings, SIGNAL (toggleStatusBar(bool)), &mViewManager, SLOT (toggleStatusBar(bool))); - connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)), this, SLOT(openFiles (const boost::filesystem::path&))); diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index c29b0e2dd..404ec58f7 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -2,7 +2,7 @@ #include "support.hpp" CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, - const QString &pageName, const QString §ion) + const QString &pageName) : mIsEditorSetting (false) { buildDefaultSetting(); @@ -17,7 +17,6 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, setProperty (Property_SettingType, QVariant (settingType).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); - setProperty (Property_Section, section); } void CSMSettings::Setting::buildDefaultSetting() @@ -195,16 +194,6 @@ QString CSMSettings::Setting::page() const return property (Property_Page).at(0); } -void CSMSettings::Setting::setSection (const QString &value) -{ - setProperty (Property_Section, value); -} - -QString CSMSettings::Setting::section() const -{ - return property (Property_Section).at(0); -} - void CSMSettings::Setting::setStyleSheet (const QString &value) { setProperty (Property_StyleSheet, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index b8c72c4bc..0068fd158 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -30,7 +30,7 @@ namespace CSMSettings public: explicit Setting(SettingType typ, const QString &settingName, - const QString &pageName, const QString §ion = QString()); + const QString &pageName); void addProxy (const Setting *setting, const QStringList &vals); void addProxy (const Setting *setting, const QList &list); @@ -80,9 +80,6 @@ namespace CSMSettings void setPage (const QString &value); QString page() const; - void setSection (const QString &value); - QString section() const; - void setStyleSheet (const QString &value); QString styleSheet() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 8c82b17a6..1e122a214 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -35,14 +35,13 @@ namespace CSMSettings Property_TickInterval = 19, Property_TicksAbove = 20, Property_TicksBelow = 21, - Property_Section = 22, - Property_StyleSheet = 23, + Property_StyleSheet = 22, //Stringlists should always be the last items - Property_DefaultValues = 24, - Property_DeclaredValues = 25, - Property_DefinedValues = 26, - Property_Proxies = 27 + Property_DefaultValues = 23, + Property_DeclaredValues = 24, + Property_DefinedValues = 25, + Property_Proxies = 26 }; ///Basic setting widget types. @@ -108,7 +107,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", "section", "stylesheet", + "tick_interval", "ticks_above", "ticks_below", "stylesheet", "defaults", "declarations", "definitions", "proxies" }; @@ -137,7 +136,6 @@ namespace CSMSettings "1", //tick interval "false", //ticks above "true", //ticks below - "", //Section "", //StyleSheet "", //default values "", //declared values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 90758bdb0..b70154ef9 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -5,12 +5,8 @@ #include #include -#include - #include -#include - #include "setting.hpp" #include "support.hpp" #include @@ -32,12 +28,9 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ -namespace CSMSettings -{ - -UserSettings *UserSettings::mUserSettingsInstance = 0; +CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; -UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) + CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) : mCfgMgr (configurationManager) , mSettingDefinitions(NULL) , mSettingCfgDefinitions(NULL) @@ -51,13 +44,13 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -void UserSettings::buildSettingModelDefaults() +void CSMSettings::UserSettings::buildSettingModelDefaults() { - QString page; + QString section; - page = "Objects"; + section = "Objects"; { - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); + Setting *numLights = createSetting (Type_SpinBox, section, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); @@ -66,7 +59,7 @@ void UserSettings::buildSettingModelDefaults() numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); - Setting *shaders = createSetting (Type_CheckBox, page, "shaders"); + Setting *shaders = createSetting (Type_CheckBox, section, "shaders"); shaders->setDeclaredValues(QStringList() << "true" << "false"); shaders->setDefaultValue("true"); shaders->setEditorSetting(true); @@ -77,9 +70,9 @@ void UserSettings::buildSettingModelDefaults() shaders->setViewLocation(2, 1); } - page = "Scene"; + section = "Scene"; { - Setting *fastFactor = createSetting (Type_SpinBox, page, "fast factor"); + Setting *fastFactor = createSetting (Type_SpinBox, section, "fast factor"); fastFactor->setDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); @@ -91,7 +84,7 @@ void UserSettings::buildSettingModelDefaults() fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); + Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); farClipDist->setEditorSetting(false); farClipDist->setColumnSpan (1); @@ -100,7 +93,7 @@ void UserSettings::buildSettingModelDefaults() farClipDist->setWidgetWidth (10); farClipDist->setViewLocation(2, 2); - Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); + Setting *timerStart = createSetting (Type_SpinBox, section, "timer start"); timerStart->setDefaultValue(20); timerStart->setEditorSetting(false); timerStart->setColumnSpan (1); @@ -110,10 +103,43 @@ void UserSettings::buildSettingModelDefaults() timerStart->setViewLocation(3, 2); } - page = "Window Size"; + section = "SubView"; { - Setting *width = createSetting (Type_LineEdit, page, "Width"); - Setting *height = createSetting (Type_LineEdit, page, "Height"); + Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); + maxSubView->setDefaultValue(3); + maxSubView->setEditorSetting(false); + maxSubView->setColumnSpan (1); + maxSubView->setMinimum (1); + maxSubView->setSpecialValueText("1"); // workaround for setMinimum + maxSubView->setMaximum (100); // FIXME: not sure what the max value should be + maxSubView->setWidgetWidth (10); + maxSubView->setViewLocation(1, 2); + + Setting *minWidth = createSetting (Type_SpinBox, section, "minimum width"); + minWidth->setDefaultValue(325); + minWidth->setEditorSetting(false); + minWidth->setColumnSpan (1); + minWidth->setMinimum (50); + maxSubView->setSpecialValueText("50"); // workaround for setMinimum + minWidth->setMaximum (10000); // FIXME: not sure what the max value should be + minWidth->setWidgetWidth (10); + minWidth->setViewLocation(2, 2); + + Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); + reuse->setDeclaredValues(QStringList() << "true" << "false"); + reuse->setDefaultValue("true"); + reuse->setEditorSetting(true); + reuse->setSpecialValueText("Reuse SubView"); + reuse->setWidgetWidth(25); + reuse->setColumnSpan (3); + reuse->setStyleSheet ("QGroupBox { border: 0px; }"); + reuse->setViewLocation(3, 2); + } + + section = "Window Size"; + { + Setting *width = createSetting (Type_LineEdit, section, "Width"); + Setting *height = createSetting (Type_LineEdit, section, "Height"); width->setWidgetWidth (5); height->setWidgetWidth (8); @@ -130,7 +156,7 @@ void UserSettings::buildSettingModelDefaults() /* *Create the proxy setting for predefined values */ - Setting *preDefined = createSetting (Type_ComboBox, page, + Setting *preDefined = createSetting (Type_ComboBox, section, "Pre-Defined"); preDefined->setDeclaredValues (QStringList() << "640 x 480" @@ -149,7 +175,7 @@ void UserSettings::buildSettingModelDefaults() ); } - page = "Display Format"; + section = "Display Format"; { QString defaultValue = "Icon and Text"; @@ -157,10 +183,10 @@ void UserSettings::buildSettingModelDefaults() << defaultValue << "Icon Only" << "Text Only"; Setting *rsd = createSetting (Type_RadioButton, - page, "Record Status Display"); + section, "Record Status Display"); Setting *ritd = createSetting (Type_RadioButton, - page, "Referenceable ID Type Display"); + section, "Referenceable ID Type Display"); rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); @@ -169,7 +195,7 @@ void UserSettings::buildSettingModelDefaults() ritd->setEditorSetting (true); } - page = "Proxy Selection Test"; + section = "Proxy Selection Test"; { /****************************************************************** * There are three types of values: @@ -197,30 +223,30 @@ void UserSettings::buildSettingModelDefaults() //create setting objects, specifying the basic widget type, //the page name, and the view name - Setting *masterBoolean = createSetting (Type_RadioButton, page, + Setting *masterBoolean = createSetting (Type_RadioButton, section, "Master Proxy"); - Setting *slaveBoolean = createSetting (Type_CheckBox, page, + Setting *slaveBoolean = createSetting (Type_CheckBox, section, "Proxy Checkboxes"); - Setting *slaveSingleText = createSetting (Type_LineEdit, page, + Setting *slaveSingleText = createSetting (Type_LineEdit, section, "Proxy TextBox 1"); - Setting *slaveMultiText = createSetting (Type_LineEdit, page, + Setting *slaveMultiText = createSetting (Type_LineEdit, section, "ProxyTextBox 2"); - Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, page, + Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, "Alpha Spinbox"); - Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, page, + Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, "Int Spinbox"); Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, - page, "Double Spinbox"); + section, "Double Spinbox"); - Setting *slaveSlider = createSetting (Type_Slider, page, "Slider"); + Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); - Setting *slaveDial = createSetting (Type_Dial, page, "Dial"); + Setting *slaveDial = createSetting (Type_Dial, section, "Dial"); //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() @@ -343,12 +369,12 @@ void UserSettings::buildSettingModelDefaults() } } -UserSettings::~UserSettings() +CSMSettings::UserSettings::~UserSettings() { mUserSettingsInstance = 0; } -void UserSettings::loadSettings (const QString &fileName) +void CSMSettings::UserSettings::loadSettings (const QString &fileName) { QString userFilePath = QString::fromUtf8 (mCfgMgr.getUserConfigPath().string().c_str()); @@ -375,128 +401,13 @@ void UserSettings::loadSettings (const QString &fileName) mSettingDefinitions = new QSettings (QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this); - // 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"; - - 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"); - 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()); - - std::string currShader = settings.getString("shader mode", "General"); - // can't call Ogre::Root at this point as it hasn't been initialised - QString rend = renderSystem.c_str(); - bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); - bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); - - // force shader language based on render system - if(currShader == "" - || (openGL && currShader == "hlsl") - || (!openGL && currShader == "glsl") - || (glES && currShader != "glsles")) - { - QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; - mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group - } - // check if override entry exists (default: disabled) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "false"); } -QStringList UserSettings::getOgreRenderers() -{ - if(mOgreRenderers.empty()) - { - Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); - Ogre::RenderSystemList::iterator it = renderers.begin(); - for(; it != renderers.end(); ++it) - mOgreRenderers.append((*it)->getName().c_str()); - } - - return mOgreRenderers; -} - -QStringList UserSettings::getOgreOptions(const QString &key, const QString &renderer) -{ - QStringList result; - - Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()); - if(!rend) - return result; - - Ogre::ConfigOptionMap& renderOpt = rend->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - uint row = 0; - for(; it != renderOpt.end(); ++it, ++row) - { - Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); - uint idx = 0; - - for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) - { - if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) - { - result << ((key == "FSAA") ? QString("MSAA ") : QString("")) - + QString::fromStdString((*opt_it).c_str()).simplified(); - } - } - } - - // Sort ascending - qSort(result.begin(), result.end(), naturalSortLessThanCI); - - // Replace the zero option with Off - int index = result.indexOf("MSAA 0"); - - if(index != -1) - result.replace(index, QObject::tr("Off")); - - return result; -} - -QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) -{ - QStringList result; - - if(renderer == "Direct3D9 Rendering Subsystem") - result.append("HLSL"); - else if(renderer == "OpenGL Rendering Subsystem") - result.append("GLSL"); - else if(renderer.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive))) - result.append("GLSLES"); - - return result; -} - // if the key is not found create one with a defaut value -QString UserSettings::setting(const QString &viewKey, const QStringList &list) +QString CSMSettings::UserSettings::setting(const QString &viewKey, const QStringList &list) { if(mSettingDefinitions->contains(viewKey)) return settingValue(viewKey); @@ -509,22 +420,23 @@ QString UserSettings::setting(const QString &viewKey, const QStringList &list) return QString(); } -bool UserSettings::hasSettingDefinitions (const QString &viewKey) const +bool CSMSettings::UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); } -void UserSettings::setDefinitions (const QString &key, const QStringList &list) +void CSMSettings::UserSettings::setDefinitions + (const QString &key, const QStringList &list) { mSettingDefinitions->setValue (key, list); } -void UserSettings::saveDefinitions() const +void CSMSettings::UserSettings::saveDefinitions() const { mSettingDefinitions->sync(); } -QString UserSettings::settingValue (const QString &settingKey) +QString CSMSettings::UserSettings::settingValue (const QString &settingKey) { QStringList defs; @@ -552,20 +464,22 @@ QString UserSettings::settingValue (const QString &settingKey) return defs.at(0); } -UserSettings& UserSettings::instance() +CSMSettings::UserSettings& CSMSettings::UserSettings::instance() { assert(mUserSettingsInstance); return *mUserSettingsInstance; } -void UserSettings::updateUserSetting(const QString &settingKey, const QStringList &list) +void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, + const QStringList &list) { mSettingDefinitions->setValue (settingKey ,list); emit userSettingUpdated (settingKey, list); } -Setting *UserSettings::findSetting (const QString &pageName, const QString &settingName) +CSMSettings::Setting *CSMSettings::UserSettings::findSetting + (const QString &pageName, const QString &settingName) { foreach (Setting *setting, mSettings) { @@ -578,7 +492,8 @@ Setting *UserSettings::findSetting (const QString &pageName, const QString &sett return 0; } -void UserSettings::removeSetting (const QString &pageName, const QString &settingName) +void CSMSettings::UserSettings::removeSetting + (const QString &pageName, const QString &settingName) { if (mSettings.isEmpty()) return; @@ -599,7 +514,7 @@ void UserSettings::removeSetting (const QString &pageName, const QString &settin } } -SettingPageMap UserSettings::settingPageMap() const +CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const { SettingPageMap pageMap; @@ -609,8 +524,8 @@ SettingPageMap UserSettings::settingPageMap() const return pageMap; } -Setting *UserSettings::createSetting - (SettingType typ, const QString &page, const QString &name) +CSMSettings::Setting *CSMSettings::UserSettings::createSetting + (CSMSettings::SettingType typ, const QString &page, const QString &name) { //get list of all settings for the current setting name if (findSetting (page, name)) @@ -629,12 +544,10 @@ Setting *UserSettings::createSetting return setting; } -QStringList UserSettings::definitions (const QString &viewKey) const +QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const { if (mSettingDefinitions->contains (viewKey)) return mSettingDefinitions->value (viewKey).toStringList(); return QStringList(); } - -} diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 01e50739f..e2851c9ac 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -35,7 +35,6 @@ namespace CSMSettings { QSettings *mSettingDefinitions; QSettings *mSettingCfgDefinitions; QList mSettings; - QStringList mOgreRenderers; public: @@ -78,9 +77,6 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; - QStringList getShaderLanguageByRenderer(const QString &renderer); - QStringList getOgreOptions(const QString &key, const QString &renderer); - QStringList getOgreRenderers(); QString setting(const QString &viewKey, const QStringList &list = QStringList()); private: From a1c0ec2feb996b236b2a3d21447e1c027e72acf6 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 11:26:33 +1000 Subject: [PATCH 37/90] Repair collateral damage from a purging session gone out of control. --- apps/opencs/editor.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 290dc8732..a753b0988 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -259,8 +259,15 @@ int CS::Editor::run() std::auto_ptr CS::Editor::setupGraphics() { - std::string rendersystem = mUserSettings.settingValue("Video/render system").toStdString(); - Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(rendersystem)); + std::string renderer = +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + "Direct3D9 Rendering Subsystem"; +#else + "OpenGL Rendering Subsystem"; +#endif + std::string renderSystem = mUserSettings.setting("Video/render system", QStringList() << renderer.c_str()).toStdString(); + + Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(renderSystem)); Ogre::Root::getSingleton().initialise(false); @@ -295,8 +302,21 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("General/shader mode").toStdString(); - //std::string shLang = mUserSettings.getShaderLanguageByRenderer(rendersystem.c_str()).at(0).toStdString(); + QString shLang = mUserSettings.settingValue("General/shader mode"); + QString rend = renderSystem.c_str(); + bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); + bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); + + // force shader language based on render system + if(shLang == "" + || (openGL && shLang == "hlsl") + || (!openGL && shLang == "glsl") + || (glES && shLang != "glsles")) + { + shLang = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; + //no group means "General" group in the "ini" file standard + mUserSettings.setDefinitions("shader mode", (QStringList() << shLang)); + } enum sh::Language lang; if(shLang == "glsl") lang = sh::Language_GLSL; else if(shLang == "glsles") lang = sh::Language_GLSLES; @@ -317,6 +337,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); + std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); From 8e71f092c5b525745b0c9f61607f3028b29d0afc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 12:36:55 +1000 Subject: [PATCH 38/90] Comment out setMinimum which is broken. --- apps/opencs/model/settings/usersettings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index b70154ef9..d28512e12 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -76,9 +76,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); - // FIXME: setMinimum or setSpecialVlueText appears to be broken, possibly due + // FIXME: setMinimum or setSpecialValueText appears to be broken, possibly due // to there being an empty string default for special value text. - fastFactor->setMinimum (1); + //fastFactor->setMinimum (1); fastFactor->setSpecialValueText("1"); // workaround for above fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); @@ -109,7 +109,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() maxSubView->setDefaultValue(3); maxSubView->setEditorSetting(false); maxSubView->setColumnSpan (1); - maxSubView->setMinimum (1); + //maxSubView->setMinimum (1); maxSubView->setSpecialValueText("1"); // workaround for setMinimum maxSubView->setMaximum (100); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); @@ -119,8 +119,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setDefaultValue(325); minWidth->setEditorSetting(false); minWidth->setColumnSpan (1); - minWidth->setMinimum (50); - maxSubView->setSpecialValueText("50"); // workaround for setMinimum + //minWidth->setMinimum (50); + minWidth->setSpecialValueText("50"); // workaround for setMinimum minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); From 810ba6190921572d3ac01cfb5d82bbe4b7fb171d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 17:46:48 +1000 Subject: [PATCH 39/90] While loading overwrite records with the same id. Should resolve bug #1750. --- apps/opencs/model/world/collection.hpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 1fb3e1f1d..387b33cf3 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -431,18 +432,27 @@ namespace CSMWorld const Record& record2 = dynamic_cast&> (record); - mRecords.insert (mRecords.begin()+index, record2); + std::pair::iterator, bool> insertResult = + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (record2.get())), + index)); + + if(!insertResult.second) // duplicate index found, replace the current record + { + std::cerr << "Duplicate record found, using new: " + IdAccessorT().getId(record2.get()) << std::endl; + replace(insertResult.first->second, record2); + return; + } + // else update the index except for the record to be inserted if (index (mRecords.size())-1) { - for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); - ++iter) - if (iter->second>=index) + std::string id = IdAccessorT().getId(record2.get()); + for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) + if (iter->second > index || (iter->second == index && iter->first != id)) ++(iter->second); } - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId ( - record2.get())), index)); + mRecords.insert (mRecords.begin()+index, record2); } template From a2d043f43a31195acd357f937a9cc8d9c5534b26 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 23:36:27 +1000 Subject: [PATCH 40/90] Re-check unknown record id after loading. --- apps/opencs/model/world/idcollection.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 7e7756ff3..940181c24 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -71,6 +71,14 @@ namespace CSMWorld record.load (reader); + if (index==-1) + { + std::string newId = IdAccessorT().getId(record); + int newIndex = this->searchId(newId); + if (newIndex != -1 && id != newId) + index = newIndex; + } + load (record, base, index); } } From d790b8edfa5d41107fb5f55e3eecf0455679f660 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 23:39:22 +1000 Subject: [PATCH 41/90] Revert old fix. --- apps/opencs/model/world/collection.hpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 387b33cf3..1fb3e1f1d 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include @@ -432,27 +431,18 @@ namespace CSMWorld const Record& record2 = dynamic_cast&> (record); - std::pair::iterator, bool> insertResult = - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (record2.get())), - index)); - - if(!insertResult.second) // duplicate index found, replace the current record - { - std::cerr << "Duplicate record found, using new: " + IdAccessorT().getId(record2.get()) << std::endl; - replace(insertResult.first->second, record2); - return; - } + mRecords.insert (mRecords.begin()+index, record2); - // else update the index except for the record to be inserted if (index (mRecords.size())-1) { - std::string id = IdAccessorT().getId(record2.get()); - for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) - if (iter->second > index || (iter->second == index && iter->first != id)) + for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); + ++iter) + if (iter->second>=index) ++(iter->second); } - mRecords.insert (mRecords.begin()+index, record2); + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId ( + record2.get())), index)); } template From ea956b537cc63f369daddcfea848b4ffb948bd81 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 27 Sep 2014 15:19:15 +0200 Subject: [PATCH 42/90] Don't search for fFatigueReturnBase and fFatigueReturnMult every frame --- apps/openmw/mwmechanics/actors.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index efca99b4e..cbc43636c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -470,13 +470,13 @@ namespace MWMechanics return; MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr); - const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified (); // restore fatigue - float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); - float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); + const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); + static float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); + static float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); float x = fFatigueReturnBase + fFatigueReturnMult * endurance; From 02dec787fda62398de31d0c2740ab9fc250f9b48 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 27 Sep 2014 22:44:20 +0200 Subject: [PATCH 43/90] Cache GMSTs in getDerivedDisposition --- .../mwmechanics/mechanicsmanagerimp.cpp | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 6ca4a4336..d5cb23806 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -566,11 +566,14 @@ namespace MWMechanics MWWorld::LiveCellRef* player = playerPtr.get(); const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr); + const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); + static float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace)) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispRaceMod")->getFloat(); + x += fDispRaceMod; - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityMult")->getFloat() - * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityBase")->getFloat()); + static float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); + static float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); + x += fDispPersonalityMult * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - fDispPersonalityBase); float reaction = 0; int rank = 0; @@ -606,16 +609,23 @@ namespace MWMechanics reaction = 0; rank = 0; } - x += (MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankMult")->getFloat() * rank - + MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankBase")->getFloat()) - * MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionMod")->getFloat() * reaction; - x -= MWBase::Environment::get().getWorld()->getStore().get().find("fDispCrimeMod")->getFloat() * playerStats.getBounty(); + static float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); + static float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); + static float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); + x += (fDispFactionRankMult * rank + + fDispFactionRankBase) + * fDispFactionMod * reaction; + + static float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); + static float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); + x -= fDispCrimeMod * playerStats.getBounty(); if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispDiseaseMod")->getFloat(); + x += fDispDiseaseMod; + static float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); if (playerStats.getDrawState() == MWMechanics::DrawState_Weapon) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispWeaponDrawn")->getFloat(); + x += fDispWeaponDrawn; x += ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Charm).getMagnitude(); From a25cffc2420382254295dcfd17b1abee840baf48 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 10:17:54 +1000 Subject: [PATCH 44/90] Fixed default value not being set for spinbox. Changed the default value of max subviews to 256. Simplified the call signature to get settings & set an initial value. Fixed missing settings for num_lights. --- apps/opencs/editor.cpp | 16 ++++---- apps/opencs/model/settings/usersettings.cpp | 43 +++++++++------------ apps/opencs/model/settings/usersettings.hpp | 2 +- apps/opencs/view/doc/view.cpp | 8 ++-- apps/opencs/view/render/scenewidget.cpp | 6 +-- apps/opencs/view/settings/rangeview.cpp | 2 + 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index a753b0988..de3e23965 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -265,7 +265,7 @@ std::auto_ptr CS::Editor::setupGraphics() #else "OpenGL Rendering Subsystem"; #endif - std::string renderSystem = mUserSettings.setting("Video/render system", QStringList() << renderer.c_str()).toStdString(); + std::string renderSystem = mUserSettings.setting("Video/render system", renderer.c_str()).toStdString(); Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(renderSystem)); @@ -331,27 +331,27 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - bool shaders = mUserSettings.setting("Objects/shaders", (QStringList() << QString("true"))) == "true" ? true : false; + bool shaders = mUserSettings.setting("Objects/shaders", QString("true")) == "true" ? true : false; sh::Factory::getInstance ().setShadersEnabled (shaders); - std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); + std::string fog = mUserSettings.setting("Shader/fog", QString("true")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); - std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); + std::string shadows = mUserSettings.setting("Shader/shadows", QString("false")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", (QStringList() << QString("false"))).toStdString(); + std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", QString("false")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - std::string render_refraction = mUserSettings.setting("Shader/render_refraction", (QStringList() << QString("false"))).toStdString(); + std::string render_refraction = mUserSettings.setting("Shader/render_refraction", QString("false")).toStdString(); sh::Factory::getInstance ().setGlobalSetting ("render_refraction", render_refraction); // internal setting - may be switched on or off by the use of shader configurations sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); - sh::Factory::getInstance ().setGlobalSetting ("num_lights", - mUserSettings.settingValue("Objects/num_lights").toStdString()); + std::string num_lights = mUserSettings.setting("Objects/num_lights", QString("8")).toStdString(); + sh::Factory::getInstance ().setGlobalSetting ("num_lights", num_lights); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index d28512e12..97c9431e1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -50,11 +50,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() section = "Objects"; { - Setting *numLights = createSetting (Type_SpinBox, section, "num lights"); + Setting *numLights = createSetting (Type_SpinBox, section, "num_lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); - numLights->setMinimum (0); + numLights->setMinimum (2); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); @@ -74,19 +74,16 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { Setting *fastFactor = createSetting (Type_SpinBox, section, "fast factor"); fastFactor->setDefaultValue(4); - fastFactor->setEditorSetting(false); + fastFactor->setEditorSetting(true); fastFactor->setColumnSpan (1); - // FIXME: setMinimum or setSpecialValueText appears to be broken, possibly due - // to there being an empty string default for special value text. - //fastFactor->setMinimum (1); - fastFactor->setSpecialValueText("1"); // workaround for above + fastFactor->setMinimum (1); fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); - farClipDist->setEditorSetting(false); + farClipDist->setEditorSetting(true); farClipDist->setColumnSpan (1); farClipDist->setMinimum (0); farClipDist->setMaximum (1000000); // FIXME: not sure what the max value should be @@ -95,7 +92,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *timerStart = createSetting (Type_SpinBox, section, "timer start"); timerStart->setDefaultValue(20); - timerStart->setEditorSetting(false); + timerStart->setEditorSetting(true); timerStart->setColumnSpan (1); timerStart->setMinimum (0); timerStart->setMaximum (100); // FIXME: not sure what the max value should be @@ -106,12 +103,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() section = "SubView"; { Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); - maxSubView->setDefaultValue(3); + maxSubView->setDefaultValue(256); maxSubView->setEditorSetting(false); maxSubView->setColumnSpan (1); - //maxSubView->setMinimum (1); - maxSubView->setSpecialValueText("1"); // workaround for setMinimum - maxSubView->setMaximum (100); // FIXME: not sure what the max value should be + maxSubView->setMinimum (1); + maxSubView->setMaximum (256); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); maxSubView->setViewLocation(1, 2); @@ -119,8 +115,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setDefaultValue(325); minWidth->setEditorSetting(false); minWidth->setColumnSpan (1); - //minWidth->setMinimum (50); - minWidth->setSpecialValueText("50"); // workaround for setMinimum + minWidth->setMinimum (50); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); @@ -128,7 +123,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); reuse->setDeclaredValues(QStringList() << "true" << "false"); reuse->setDefaultValue("true"); - reuse->setEditorSetting(true); + reuse->setEditorSetting(false); reuse->setSpecialValueText("Reuse SubView"); reuse->setWidgetWidth(25); reuse->setColumnSpan (3); @@ -147,8 +142,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() width->setDefaultValues (QStringList() << "1024"); height->setDefaultValues (QStringList() << "768"); - width->setEditorSetting (true); - height->setEditorSetting (true); + width->setEditorSetting (false); + height->setEditorSetting (false); height->setViewLocation (2,2); width->setViewLocation (2,1); @@ -191,8 +186,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); - rsd->setEditorSetting (true); - ritd->setEditorSetting (true); + rsd->setEditorSetting (false); + ritd->setEditorSetting (false); } section = "Proxy Selection Test"; @@ -407,14 +402,14 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) } // if the key is not found create one with a defaut value -QString CSMSettings::UserSettings::setting(const QString &viewKey, const QStringList &list) +QString CSMSettings::UserSettings::setting(const QString &viewKey, const QString &value) { if(mSettingDefinitions->contains(viewKey)) return settingValue(viewKey); - else if(!list.empty()) + else if(value != QString()) { - mSettingDefinitions->setValue (viewKey, list); - return list.at(0); + mSettingDefinitions->setValue (viewKey, QStringList() << value); + return value; } return QString(); diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index e2851c9ac..0aabd66e5 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -77,7 +77,7 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; - QString setting(const QString &viewKey, const QStringList &list = QStringList()); + QString setting(const QString &viewKey, const QString &value = QString()); private: diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 2ff00a535..744865f1c 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -456,7 +456,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // User setting to reuse sub views (on a per top level view basis) bool reuse = - userSettings.setting("SubView/reuse", (QStringList() << QString("true"))) == "true" ? true : false; + userSettings.setting("SubView/reuse", QString("true")) == "true" ? true : false; if(reuse) { foreach(SubView *sb, mSubViews) @@ -475,8 +475,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // // If the sub view limit setting is one, the sub view title bar is hidden and the // text in the main title bar is adjusted accordingly - int maxSubView = - userSettings.setting("SubView/max subviews", (QStringList() << QString("3"))).toInt(); + int maxSubView = userSettings.setting("SubView/max subviews", QString("256")).toInt(); if(mSubViews.size() >= maxSubView) // create a new top level view { mViewManager.addView(mDocument, id, hint); @@ -499,8 +498,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); - int minWidth = - userSettings.setting("SubView/minimum width", (QStringList() << QString("325"))).toInt(); + int minWidth = userSettings.setting("SubView/minimum width", QString("325")).toInt(); view->setMinimumWidth(minWidth); view->setStatusBar (mShowStatusBar->isChecked()); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index ff1765f35..cdf55a9eb 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -48,10 +48,10 @@ namespace CSVRender CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = userSettings.setting("Scene/far clip distance", (QStringList() << QString("300000"))).toInt(); + int farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toInt(); mCamera->setFarClipDistance (farClipDist); - mFastFactor = userSettings.setting("Scene/fast factor", (QStringList() << QString("4"))).toInt(); + mFastFactor = userSettings.setting("Scene/fast factor", QString("4")).toInt(); mCamera->roll (Ogre::Degree (90)); @@ -61,7 +61,7 @@ namespace CSVRender connect (timer, SIGNAL (timeout()), this, SLOT (update())); - int timerStart = userSettings.setting("Scene/timer start", (QStringList() << QString("20"))).toInt(); + int timerStart = userSettings.setting("Scene/timer start", QString("20")).toInt(); timer->start (timerStart); /// \todo make shortcut configurable diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 606ad4939..49cc170e1 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -129,6 +129,8 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("wrapping", setting->wrapping()); dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + if(setting->type() == CSMSettings::Type_SpinBox) + dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); // FIXME: can there be more than one? } void CSVSettings::RangeView::slotUpdateView (int value) From 9902e08773bb38ea846a44dc25dd9f36be04ee6c Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 11:05:27 +1000 Subject: [PATCH 45/90] Apply sh::Factory settings immediately. --- apps/opencs/model/settings/usersettings.cpp | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 97c9431e1..2e5aaad42 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -12,6 +12,8 @@ #include #include +#include + /** * Workaround for problems with whitespaces in paths in older versions of Boost library */ @@ -104,7 +106,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); maxSubView->setDefaultValue(256); - maxSubView->setEditorSetting(false); + maxSubView->setEditorSetting(true); maxSubView->setColumnSpan (1); maxSubView->setMinimum (1); maxSubView->setMaximum (256); // FIXME: not sure what the max value should be @@ -113,7 +115,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *minWidth = createSetting (Type_SpinBox, section, "minimum width"); minWidth->setDefaultValue(325); - minWidth->setEditorSetting(false); + minWidth->setEditorSetting(true); minWidth->setColumnSpan (1); minWidth->setMinimum (50); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be @@ -123,7 +125,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); reuse->setDeclaredValues(QStringList() << "true" << "false"); reuse->setDefaultValue("true"); - reuse->setEditorSetting(false); + reuse->setEditorSetting(true); reuse->setSpecialValueText("Reuse SubView"); reuse->setWidgetWidth(25); reuse->setColumnSpan (3); @@ -142,8 +144,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() width->setDefaultValues (QStringList() << "1024"); height->setDefaultValues (QStringList() << "768"); - width->setEditorSetting (false); - height->setEditorSetting (false); + width->setEditorSetting (true); + height->setEditorSetting (true); height->setViewLocation (2,2); width->setViewLocation (2,1); @@ -186,8 +188,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); - rsd->setEditorSetting (false); - ritd->setEditorSetting (false); + rsd->setEditorSetting (true); + ritd->setEditorSetting (true); } section = "Proxy Selection Test"; @@ -470,7 +472,18 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, { mSettingDefinitions->setValue (settingKey ,list); - emit userSettingUpdated (settingKey, list); + if(settingKey == "Objects/num_lights" + && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + { + sh::Factory::getInstance ().setGlobalSetting ("num_lights", list.at(0).toStdString()); + } + else if(settingKey == "Objects/shaders" + && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + { + sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); + } + + emit userSettingUpdated (settingKey, list); // TODO: isn't this circular? } CSMSettings::Setting *CSMSettings::UserSettings::findSetting From 8a0ff17c22891c036b92a484ce493bd4825169af Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 14:08:14 +1000 Subject: [PATCH 46/90] Update SceneWidget when relevant user settings change. --- apps/opencs/view/render/scenewidget.cpp | 6 ++++++ apps/opencs/view/render/scenewidget.hpp | 4 ++++ apps/opencs/view/world/scenesubview.cpp | 9 ++++++++- apps/opencs/view/world/scenesubview.hpp | 8 ++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index cdf55a9eb..1b0b578f6 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -397,4 +397,10 @@ namespace CSVRender else if (mode=="bright") setLighting (&mLightingBright); } + + void SceneWidget::updateUserSetting (const QString &key, const QStringList &list) + { + if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) + flagAsModified(); + } } diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 9f79aee17..f28504c2d 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -110,6 +110,10 @@ namespace CSVRender LightingNight mLightingNight; LightingBright mLightingBright; + public slots: + + void updateUserSetting (const QString &key, const QStringList &list); + private slots: void update(); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 52bd47b54..d10eebb30 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -247,6 +247,8 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mToolbar = toolbar; connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus())); + connect (this, SIGNAL (updateSceneUserSetting(const QString &, const QStringList &)), + mScene, SLOT (updateUserSetting(const QString &, const QStringList &))); connect (mToolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus())); mLayout->addWidget (mToolbar, 0); @@ -254,4 +256,9 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} \ No newline at end of file +} + +void CSVWorld::SceneSubView::updateUserSetting (const QString &key, const QStringList &list) +{ + emit updateSceneUserSetting(key, list); +} diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index b9dcdd6a3..c0905f0d6 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -82,6 +82,14 @@ namespace CSVWorld void cellSelectionChanged (const CSMWorld::UniversalId& id); void handleDrop(const std::vector& data); + + public slots: + + void updateUserSetting (const QString &, const QStringList &); + + signals: + + void updateSceneUserSetting (const QString &, const QStringList &); }; } From 303b0ee8c6c4e5ca6fab15dfdd08af3757de96c4 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 15:43:33 +1000 Subject: [PATCH 47/90] Update scenewidget when antialiasing settings change. --- apps/opencs/model/settings/usersettings.cpp | 13 +++++- apps/opencs/view/render/scenewidget.cpp | 44 ++++++++++++++++++++- apps/opencs/view/settings/rangeview.cpp | 4 +- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 2e5aaad42..bc197ab48 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -192,6 +192,17 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() ritd->setEditorSetting (true); } + section = "Video"; + { + QString defaultValue = "None"; + QStringList values = QStringList() + << defaultValue << "MSAA 2" << "MSAA 4" << "MSAA 8" << "MSAA 16"; + Setting *antialiasing = createSetting (Type_SpinBox, section, "antialiasing"); + antialiasing->setDeclaredValues (values); + antialiasing->setEditorSetting (true); + antialiasing->setWidgetWidth(15); + } + section = "Proxy Selection Test"; { /****************************************************************** @@ -483,7 +494,7 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); } - emit userSettingUpdated (settingKey, list); // TODO: isn't this circular? + emit userSettingUpdated (settingKey, list); } CSMSettings::Setting *CSMSettings::UserSettings::findSetting diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1b0b578f6..c399fca6b 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -128,7 +128,16 @@ namespace CSVRender params.insert(std::make_pair("externalWindowHandle", windowHandle.str())); params.insert(std::make_pair("title", windowTitle.str())); - params.insert(std::make_pair("FSAA", "0")); // TODO setting + + std::string antialiasing = + CSMSettings::UserSettings::instance().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)); + params.insert(std::make_pair("vsync", "false")); // TODO setting #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); @@ -402,5 +411,38 @@ namespace CSVRender { if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); + + // minimise unnecessary ogre window creation by updating only when there is a change + if(key == "Video/antialiasing") + { + std::string result; + + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + + for(; it != renderOpt.end(); ++it) + { + if(it->first == "FSAA") + result = it->second.currentValue; + } + + QString antialiasing = "0"; + if(!list.empty()) + { + antialiasing = list.at(0); + + 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"; + } + + if(result != antialiasing.toStdString()) + { + updateOgreWindow(); + } + } } } diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 49cc170e1..6b47b1cac 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -129,8 +129,8 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("wrapping", setting->wrapping()); dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - if(setting->type() == CSMSettings::Type_SpinBox) - dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); // FIXME: can there be more than one? + if(setting->type() == CSMSettings::Type_SpinBox && setting->declaredValues().isEmpty()) + dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); } void CSVSettings::RangeView::slotUpdateView (int value) From 6e8977348a07ff3c67c8e98834886dfca5e0579b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 19:43:26 +1000 Subject: [PATCH 48/90] Check the FSAA setting of windows rather than system value. --- apps/opencs/view/render/scenewidget.cpp | 31 ++++++------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index c399fca6b..9ff9ac4db 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -415,34 +415,17 @@ namespace CSVRender // minimise unnecessary ogre window creation by updating only when there is a change if(key == "Video/antialiasing") { - std::string result; - - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - for(; it != renderOpt.end(); ++it) - { - if(it->first == "FSAA") - result = it->second.currentValue; - } - - QString antialiasing = "0"; + unsigned int aa = mWindow->getFSAA(); + unsigned int antialiasing = 0; if(!list.empty()) { - antialiasing = list.at(0); - - 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"; + if(list.at(0) == "MSAA 16") antialiasing = 16; + else if(list.at(0) == "MSAA 8") antialiasing = 8; + else if(list.at(0) == "MSAA 4") antialiasing = 4; + else if(list.at(0) == "MSAA 2") antialiasing = 2; } - - if(result != antialiasing.toStdString()) - { + if(aa != antialiasing) updateOgreWindow(); - } } } } From 58571f7ac2c250ae73674f0225854c2b2f38b9b9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 12:18:46 +0200 Subject: [PATCH 49/90] Revert "Transfer item ownership to the buyer if item wasn't stolen" Fixes #1953. This reverts commit 5d77c5e8cac1c506f50a9e415dfeb489c0704ddb. --- apps/openmw/mwgui/containeritemmodel.cpp | 2 +- apps/openmw/mwgui/tradeitemmodel.cpp | 8 +++----- apps/openmw/mwgui/tradeitemmodel.hpp | 3 +-- apps/openmw/mwgui/tradewindow.cpp | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/containeritemmodel.cpp b/apps/openmw/mwgui/containeritemmodel.cpp index 520a32ef8..b2befc3ba 100644 --- a/apps/openmw/mwgui/containeritemmodel.cpp +++ b/apps/openmw/mwgui/containeritemmodel.cpp @@ -76,7 +76,7 @@ MWWorld::Ptr ContainerItemModel::copyItem (const ItemStack& item, size_t count, const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1]; if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source)) throw std::runtime_error("Item to copy needs to be from a different container!"); - return *source.getClass().getContainerStore(source).add(item.mBase, count, source, setNewOwner); + return *source.getClass().getContainerStore(source).add(item.mBase, count, source); } void ContainerItemModel::removeItem (const ItemStack& item, size_t count) diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index e1283c89d..3abfac997 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -119,7 +119,7 @@ namespace MWGui return mBorrowedToUs; } - void TradeItemModel::transferItems(const MWWorld::Ptr& transferFrom) + void TradeItemModel::transferItems() { std::vector::iterator it = mBorrowedToUs.begin(); for (; it != mBorrowedToUs.end(); ++it) @@ -135,11 +135,9 @@ namespace MWGui if (i == sourceModel->getItemCount()) throw std::runtime_error("The borrowed item disappeared"); + // reset owner while copying, but only for items bought by the player + bool setNewOwner = (mMerchant.isEmpty()); const ItemStack& item = sourceModel->getItem(i); - - bool setNewOwner = Misc::StringUtils::ciEqual(item.mBase.getCellRef().getOwner(), transferFrom.getCellRef().getRefId()) - || item.mBase.getCellRef().getOwner().empty(); - // copy the borrowed items to our model copyItem(item, it->mCount, setNewOwner); // then remove them from the source model diff --git a/apps/openmw/mwgui/tradeitemmodel.hpp b/apps/openmw/mwgui/tradeitemmodel.hpp index c463bf40b..1bfee9b2a 100644 --- a/apps/openmw/mwgui/tradeitemmodel.hpp +++ b/apps/openmw/mwgui/tradeitemmodel.hpp @@ -30,8 +30,7 @@ namespace MWGui void returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel* source, size_t count); /// Permanently transfers items that were borrowed to us from another model to this model - /// @param transferFrom the actor that lent us the items - void transferItems (const MWWorld::Ptr& transferFrom); + void transferItems (); /// Aborts trade void abort(); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 081a1e2c2..a4e5bbc16 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -370,8 +370,8 @@ namespace MWGui MWBase::Environment::get().getDialogueManager()->applyDispositionChange(iBarterSuccessDisposition); // make the item transfer - mTradeModel->transferItems(player); - playerItemModel->transferItems(mPtr); + mTradeModel->transferItems(); + playerItemModel->transferItems(); // transfer the gold if (mCurrentBalance != 0) From e9ed0211c9ef71b63c924c14727bd02a89425290 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 12:44:47 +0200 Subject: [PATCH 50/90] Attempt to fix Clang warnings --- apps/openmw/mwgui/savegamedialog.cpp | 3 ++- apps/openmw/mwgui/windowbase.cpp | 2 ++ apps/openmw/mwmechanics/aiescort.cpp | 6 +++++- apps/openmw/mwmechanics/autocalcspell.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 2 -- apps/openmw/mwworld/weather.cpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 2 +- components/esmterrain/storage.cpp | 4 ++-- components/widgets/box.cpp | 26 +++++++++++++++++++---- 10 files changed, 38 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 3920a5dcb..66c7a9238 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -322,7 +322,8 @@ namespace MWGui if (i == pos) mCurrentSlot = &*it; } - assert(mCurrentSlot && "Can't find selected slot"); + if (!mCurrentSlot) + throw std::runtime_error("Can't find selected slot"); std::stringstream text; time_t time = mCurrentSlot->mTimeStamp; diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index 432510a3e..9c12b04ef 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -76,6 +76,8 @@ void WindowModal::close() NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget) : mDrag(drag), mWidget(widget), mTransparent(false) { + if (!mWidget) + throw std::runtime_error("NoDrop needs a non-NULL widget!"); } void NoDrop::onFrame(float dt) diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 98fc64090..324bef322 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -92,7 +92,11 @@ namespace MWMechanics if(distanceBetweenResult <= mMaxDist * mMaxDist) { - if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete + ESM::Pathgrid::Point point(mX,mY,mZ); + point.mAutogenerated = 0; + point.mConnectionNum = 0; + point.mUnknown = 0; + if(pathTo(actor,point,duration)) //Returns true on path complete return true; mMaxDist = 450; } diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 255decdf7..01447c6e4 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -220,7 +220,7 @@ namespace MWMechanics if (spell->mData.mFlags & ESM::Spell::F_Always) return 100.f; - float skillTerm; + float skillTerm = 0; if (effectiveSchool != -1) skillTerm = 2.f * actorSkills[mapSchoolToSkill(effectiveSchool)]; else diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 8f1a8f718..7c7ea0c95 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1611,7 +1611,7 @@ void CharacterController::update(float duration) if(mMovementAnimationControlled && mPtr.getClass().isActor()) world->queueMovement(mPtr, moved); } - else if (mAnimation) + else mAnimation->updateEffects(duration); mSkipAnim = false; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 31d52e39d..d5267b8cf 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -385,7 +385,6 @@ namespace MWWorld if(tracer.mFraction >= 1.0f) { newPosition = tracer.mEndPos; // ok to move, so set newPosition - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } else @@ -406,7 +405,6 @@ namespace MWWorld // precision can be lost due to any math Bullet does internally). Since we // aren't performing any collision detection, we want to reject the next // position, so that we don't slowly move inside another object. - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 613fd712f..525352e7f 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -498,7 +498,8 @@ void WeatherManager::update(float duration) else if (sound == 1) soundName = &mThunderSoundID1; else if (sound == 2) soundName = &mThunderSoundID2; else if (sound == 3) soundName = &mThunderSoundID3; - MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); + if (soundName) + MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); mThunderSoundDelay = 1000; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c49f1f483..1f3cf01e1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1045,7 +1045,7 @@ namespace MWWorld CellStore *currCell = ptr.isInCell() ? ptr.getCell() : NULL; // currCell == NULL should only happen for player, during initial startup bool isPlayer = ptr == mPlayer->getPlayer(); - bool haveToMove = isPlayer || mWorldScene->isCellActive(*currCell); + bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); if (currCell != newCell) { diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 585c1495d..c4152533e 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -147,8 +147,8 @@ namespace ESMTerrain Ogre::Vector3 normal; Ogre::ColourValue color; - float vertY; - float vertX; + float vertY = 0; + float vertX = 0; float vertY_ = 0; // of current cell corner for (int cellY = startY; cellY < startY + std::ceil(size); ++cellY) diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index e1c148271..0ac2ff7fd 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -197,8 +197,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.left = curX; widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2; - int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count - : sizes[i].first.width; + + int width = 0; + if (sizes[i].second) + { + if (h_stretched_count == 0) + throw std::logic_error("unexpected"); + width = sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count; + } + else + width = sizes[i].first.width; + widgetCoord.width = width; widgetCoord.height = height; w->setCoord(widgetCoord); @@ -334,8 +343,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.top = curY; widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2; - int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count - : sizes[i].first.height; + + int height = 0; + if (sizes[i].second) + { + if (v_stretched_count == 0) + throw std::logic_error("unexpected"); + height = sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count; + } + else + height = sizes[i].first.height; + widgetCoord.height = height; widgetCoord.width = width; w->setCoord(widgetCoord); From 7c52d05f8527b075a07c92fd8e77f9aff81a22f0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 14:00:15 +0200 Subject: [PATCH 51/90] Disable topics list visually when in a choice --- apps/openmw/mwgui/dialogue.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index a3f82e65d..196e7d8c7 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -562,12 +562,11 @@ namespace MWGui MyGUI::Button* byeButton; getWidget(byeButton, "ByeButton"); - if(MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye) { - byeButton->setEnabled(false); - } - else { - byeButton->setEnabled(true); - } + bool goodbyeEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() || mGoodbye; + byeButton->setEnabled(goodbyeEnabled); + + bool topicsEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye; + mTopicsList->setEnabled(topicsEnabled); } void DialogueWindow::notifyLinkClicked (TypesetBook::InteractiveId link) @@ -657,7 +656,6 @@ namespace MWGui { mLinks.push_back(new Goodbye()); mGoodbye = true; - mTopicsList->setEnabled(false); mEnabled = false; updateHistory(); } From fedfd7129de88edaea4001ac5624a114e92a57d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 15:33:36 +0200 Subject: [PATCH 52/90] Add spacing between buttons to TabControl skin --- files/mygui/openmw_button.skin.xml | 30 ++++++++++++++++++++++++++++++ files/mygui/openmw_resources.xml | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index 9193e3874..73c266818 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -73,6 +73,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index ad5ac84bb..7d7ba07b6 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -33,7 +33,7 @@ - + @@ -46,7 +46,7 @@ - + From ff0b4e0583d7f0d1dd3b64fcfc273b8ea56b24d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 17:57:14 +0200 Subject: [PATCH 53/90] Add debug window (F10), displays Bullet's profiler output --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwgui/debugwindow.cpp | 116 +++++++++++++++++++++++ apps/openmw/mwgui/debugwindow.hpp | 24 +++++ apps/openmw/mwgui/windowmanagerimp.cpp | 11 +++ apps/openmw/mwgui/windowmanagerimp.hpp | 4 + apps/openmw/mwinput/inputmanagerimp.cpp | 4 + apps/openmw/mwinput/inputmanagerimp.hpp | 2 + files/mygui/CMakeLists.txt | 2 + files/mygui/core.xml | 1 + files/mygui/openmw_debug_window.layout | 16 ++++ files/mygui/openmw_debug_window.skin.xml | 17 ++++ files/mygui/openmw_layers.xml | 1 + 13 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwgui/debugwindow.cpp create mode 100644 apps/openmw/mwgui/debugwindow.hpp create mode 100644 files/mygui/openmw_debug_window.layout create mode 100644 files/mygui/openmw_debug_window.skin.xml diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 2417091f8..e37cd1391 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -40,7 +40,7 @@ add_openmw_dir (mwgui merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog - recharge mode videowidget backgroundimage itemwidget screenfader + recharge mode videowidget backgroundimage itemwidget screenfader debugwindow ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index e8286bdd1..bce3f516e 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -337,6 +337,8 @@ namespace MWBase virtual void fadeScreenTo(const int percent, const float time) = 0; /// Darken the screen by \a factor (1.0 = no darkening). Works independently from screen fading. virtual void setScreenFactor (float factor) = 0; + + virtual void toggleDebugWindow() = 0; }; } diff --git a/apps/openmw/mwgui/debugwindow.cpp b/apps/openmw/mwgui/debugwindow.cpp new file mode 100644 index 000000000..fab386bda --- /dev/null +++ b/apps/openmw/mwgui/debugwindow.cpp @@ -0,0 +1,116 @@ +#include "debugwindow.hpp" + + +#include + +namespace +{ + void bulletDumpRecursive(CProfileIterator* pit, int spacing, std::stringstream& os) + { + pit->First(); + if (pit->Is_Done()) + return; + + float accumulated_time=0,parent_time = pit->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : pit->Get_Current_Parent_Total_Time(); + int i,j; + int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + for (i=0;iGet_Current_Parent_Name())+" (total running time: "+MyGUI::utility::toString(parent_time,3)+" ms) ---\n"; + os << s; + //float totalTime = 0.f; + + int numChildren = 0; + + for (i = 0; !pit->Is_Done(); i++,pit->Next()) + { + numChildren++; + float current_total_time = pit->Get_Current_Total_Time(); + accumulated_time += current_total_time; + float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + + for (j=0;jGet_Current_Name()+" ("+MyGUI::utility::toString(fraction,2)+" %) :: "+MyGUI::utility::toString(ms,3)+" ms / frame ("+MyGUI::utility::toString(pit->Get_Current_Total_Calls())+" calls)\n"; + os << s; + //totalTime += current_total_time; + //recurse into children + } + + if (parent_time < accumulated_time) + { + os << "what's wrong\n"; + } + for (i=0;i SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f; + s = "Unaccounted: ("+MyGUI::utility::toString(unaccounted,3)+" %) :: "+MyGUI::utility::toString(parent_time - accumulated_time,3)+" ms\n"; + os << s; + + for (i=0;iEnter_Child(i); + bulletDumpRecursive(pit, spacing+3, os); + pit->Enter_Parent(); + } + } + + void bulletDumpAll(std::stringstream& os) + { + CProfileIterator* profileIterator = 0; + profileIterator = CProfileManager::Get_Iterator(); + + bulletDumpRecursive(profileIterator, 0, os); + + CProfileManager::Release_Iterator(profileIterator); + } +} + + +namespace MWGui +{ + + DebugWindow::DebugWindow() + : WindowBase("openmw_debug_window.layout") + { + getWidget(mTabControl, "TabControl"); + + // Ideas for other tabs: + // - Texture / compositor texture viewer + // - Log viewer + // - Material editor + // - Shader editor + + MyGUI::TabItem* item = mTabControl->addItem("Physics Profiler"); + mBulletProfilerEdit = item->createWidgetReal + ("LogEdit", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Stretch); + + MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); + mMainWidget->setSize(viewSize); + } + + void DebugWindow::onFrame(float dt) + { + if (!isVisible()) + return; + + static float timer = 0; + timer -= dt; + + if (timer > 0) + return; + timer = 1; + + std::stringstream stream; + bulletDumpAll(stream); + + if (mBulletProfilerEdit->isTextSelection()) // pause updating while user is trying to copy text + return; + + size_t previousPos = mBulletProfilerEdit->getVScrollPosition(); + mBulletProfilerEdit->setCaption(stream.str()); + mBulletProfilerEdit->setVScrollPosition(std::min(previousPos, mBulletProfilerEdit->getVScrollRange()-1)); + } + +} diff --git a/apps/openmw/mwgui/debugwindow.hpp b/apps/openmw/mwgui/debugwindow.hpp new file mode 100644 index 000000000..af5b914ea --- /dev/null +++ b/apps/openmw/mwgui/debugwindow.hpp @@ -0,0 +1,24 @@ +#ifndef OPENMW_MWGUI_DEBUGWINDOW_H +#define OPENMW_MWGUI_DEBUGWINDOW_H + +#include "windowbase.hpp" + +namespace MWGui +{ + + class DebugWindow : public WindowBase + { + public: + DebugWindow(); + + void onFrame(float dt); + + private: + MyGUI::TabControl* mTabControl; + + MyGUI::EditBox* mBulletProfilerEdit; + }; + +} + +#endif diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index fabdf4dae..70f4b5a2f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -72,6 +72,7 @@ #include "backgroundimage.hpp" #include "itemwidget.hpp" #include "screenfader.hpp" +#include "debugwindow.hpp" namespace MWGui { @@ -120,6 +121,7 @@ namespace MWGui , mVideoBackground(NULL) , mVideoWidget(NULL) , mScreenFader(NULL) + , mDebugWindow(NULL) , mTranslationDataStorage (translationDataStorage) , mCharGen(NULL) , mInputBlocker(NULL) @@ -266,6 +268,7 @@ namespace MWGui mCompanionWindow = new CompanionWindow(mDragAndDrop, mMessageBoxManager); trackWindow(mCompanionWindow, "companion"); mScreenFader = new ScreenFader(); + mDebugWindow = new DebugWindow(); mInputBlocker = MyGUI::Gui::getInstance().createWidget("",0,0,w,h,MyGUI::Align::Stretch,"Overlay"); @@ -357,6 +360,7 @@ namespace MWGui delete mRecharge; delete mCompanionWindow; delete mScreenFader; + delete mDebugWindow; cleanupGarbage(); @@ -859,6 +863,8 @@ namespace MWGui mCompanionWindow->onFrame(); mScreenFader->update(frameDuration); + + mDebugWindow->onFrame(frameDuration); } void WindowManager::changeCell(MWWorld::CellStore* cell) @@ -1749,4 +1755,9 @@ namespace MWGui SDL_free(text); } + void WindowManager::toggleDebugWindow() + { + mDebugWindow->setVisible(!mDebugWindow->isVisible()); + } + } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index e7853b84f..29d40c2e7 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -89,6 +89,7 @@ namespace MWGui class VideoWidget; class WindowModal; class ScreenFader; + class DebugWindow; class WindowManager : public MWBase::WindowManager { @@ -333,6 +334,8 @@ namespace MWGui /// Darken the screen by \a factor (1.0 = no darkening). Works independently from screen fading. virtual void setScreenFactor (float factor); + virtual void toggleDebugWindow(); + private: bool mConsoleOnlyScripts; @@ -386,6 +389,7 @@ namespace MWGui MyGUI::ImageBox* mVideoBackground; VideoWidget* mVideoWidget; ScreenFader* mScreenFader; + DebugWindow* mDebugWindow; Translation::Storage& mTranslationDataStorage; Cursor* mSoftwareCursor; diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 86b01cdc4..3cd30819c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -279,6 +279,9 @@ namespace MWInput case A_ToggleHUD: MWBase::Environment::get().getWindowManager()->toggleGui(); break; + case A_ToggleDebug: + MWBase::Environment::get().getWindowManager()->toggleDebugWindow(); + break; case A_QuickSave: quickSave(); break; @@ -902,6 +905,7 @@ namespace MWInput defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0; defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12; defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11; + defaultKeyBindings[A_ToggleDebug] = SDL_SCANCODE_F10; defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK; defaultKeyBindings[A_QuickSave] = SDL_SCANCODE_F5; defaultKeyBindings[A_QuickLoad] = SDL_SCANCODE_F9; diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index a94b61c8b..346e02ff9 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -259,6 +259,8 @@ namespace MWInput A_ToggleHUD, + A_ToggleDebug, + A_Last // Marker for the last item }; }; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 87e750cc9..651adf403 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -83,6 +83,8 @@ set(MYGUI_FILES openmw_recharge_dialog.layout openmw_screen_fader.layout openmw_edit_note.layout + openmw_debug_window.layout + openmw_debug_window.skin.xml DejaVuLGCSansMono.ttf ../launcher/images/openmw.png OpenMWResourcePlugin.xml diff --git a/files/mygui/core.xml b/files/mygui/core.xml index ea1627875..133109375 100644 --- a/files/mygui/core.xml +++ b/files/mygui/core.xml @@ -22,6 +22,7 @@ + diff --git a/files/mygui/openmw_debug_window.layout b/files/mygui/openmw_debug_window.layout new file mode 100644 index 000000000..9af646c6e --- /dev/null +++ b/files/mygui/openmw_debug_window.layout @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_debug_window.skin.xml b/files/mygui/openmw_debug_window.skin.xml new file mode 100644 index 000000000..587101b7f --- /dev/null +++ b/files/mygui/openmw_debug_window.skin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_layers.xml b/files/mygui/openmw_layers.xml index 1df4841af..38a98d133 100644 --- a/files/mygui/openmw_layers.xml +++ b/files/mygui/openmw_layers.xml @@ -6,6 +6,7 @@ + From bdab3fa3216a5c4ee5385c7131604bfd40fb143a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 18:02:57 +0200 Subject: [PATCH 54/90] Bullet optimization: Don't update AABBs of static objects every frame --- apps/openmw/mwworld/physicssystem.cpp | 18 +++++++++++++++--- libs/openengine/bullet/physic.cpp | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index d5267b8cf..97ea7ca91 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -40,7 +40,7 @@ using namespace Ogre; namespace { -void animateCollisionShapes (std::map& map) +void animateCollisionShapes (std::map& map, btDynamicsWorld* dynamicsWorld) { for (std::map::iterator it = map.begin(); it != map.end(); ++it) @@ -79,6 +79,9 @@ void animateCollisionShapes (std::mapgetChildShape(shapeIt->second)->setLocalScaling(BtOgre::Convert::toBullet(bone->_getDerivedScale())); compound->updateChildTransform(shapeIt->second, trans); } + + // needed because we used btDynamicsWorld::setForceUpdateAllAabbs(false) + dynamicsWorld->updateSingleAabb(it->first); } } @@ -670,11 +673,18 @@ namespace MWWorld const Ogre::Vector3 &position = node->getPosition(); if(OEngine::Physic::RigidBody *body = mEngine->getRigidBody(handle)) + { body->getWorldTransform().setOrigin(btVector3(position.x,position.y,position.z)); + mEngine->mDynamicsWorld->updateSingleAabb(body); + } if(OEngine::Physic::RigidBody *body = mEngine->getRigidBody(handle, true)) + { body->getWorldTransform().setOrigin(btVector3(position.x,position.y,position.z)); + mEngine->mDynamicsWorld->updateSingleAabb(body); + } + // Actors update their AABBs every frame (DISABLE_DEACTIVATION), so no need to do it manually if(OEngine::Physic::PhysicActor *physact = mEngine->getCharacter(handle)) physact->setPosition(position); } @@ -696,6 +706,7 @@ namespace MWWorld body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); else mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation); + mEngine->mDynamicsWorld->updateSingleAabb(body); } if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle, true)) { @@ -703,6 +714,7 @@ namespace MWWorld body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); else mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation); + mEngine->mDynamicsWorld->updateSingleAabb(body); } } @@ -864,8 +876,8 @@ namespace MWWorld void PhysicsSystem::stepSimulation(float dt) { - animateCollisionShapes(mEngine->mAnimatedShapes); - animateCollisionShapes(mEngine->mAnimatedRaycastingShapes); + animateCollisionShapes(mEngine->mAnimatedShapes, mEngine->mDynamicsWorld); + animateCollisionShapes(mEngine->mAnimatedRaycastingShapes, mEngine->mDynamicsWorld); mEngine->stepSimulation(dt); } diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index f2be11386..d3aa714f1 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -97,6 +97,8 @@ namespace Physic (0,0, mShape.get()); mBody = new RigidBody(CI, name); mBody->mPlaceable = false; + mBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT); + mBody->setActivationState(DISABLE_DEACTIVATION); setPosition(position); setRotation(rotation); @@ -233,6 +235,11 @@ namespace Physic // The world. mDynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration); + + // Don't update AABBs of all objects every frame. Most objects in MW are static, so we don't need this. + // Should a "static" object ever be moved, we have to update its AABB manually using DynamicsWorld::updateSingleAabb. + mDynamicsWorld->setForceUpdateAllAabbs(false); + mDynamicsWorld->setGravity(btVector3(0,0,-10)); if(BulletShapeManager::getSingletonPtr() == NULL) From 358257ca6b0e02d0e7f4c5b80da7d1f7b7edb36a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 18:11:19 +0200 Subject: [PATCH 55/90] Rename some skin files to .skin.xml for consistency --- files/mygui/CMakeLists.txt | 10 +++++----- files/mygui/core.xml | 10 +++++----- ...window_skin.xml => openmw_dialogue_window.skin.xml} | 0 ...openmw_journal_skin.xml => openmw_journal.skin.xml} | 0 ...enmw_mainmenu_skin.xml => openmw_mainmenu.skin.xml} | 0 ..._map_window_skin.xml => openmw_map_window.skin.xml} | 0 .../{openmw_scroll_skin.xml => openmw_scroll.skin.xml} | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename files/mygui/{openmw_dialogue_window_skin.xml => openmw_dialogue_window.skin.xml} (100%) rename files/mygui/{openmw_journal_skin.xml => openmw_journal.skin.xml} (100%) rename files/mygui/{openmw_mainmenu_skin.xml => openmw_mainmenu.skin.xml} (100%) rename files/mygui/{openmw_map_window_skin.xml => openmw_map_window.skin.xml} (100%) rename files/mygui/{openmw_scroll_skin.xml => openmw_scroll.skin.xml} (100%) diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 651adf403..0099f9a46 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -28,7 +28,7 @@ set(MYGUI_FILES openmw_container_window.layout openmw_count_window.layout openmw_dialogue_window.layout - openmw_dialogue_window_skin.xml + openmw_dialogue_window.skin.xml openmw_edit.skin.xml openmw_font.xml openmw_hud_box.skin.xml @@ -38,19 +38,19 @@ set(MYGUI_FILES openmw_interactive_messagebox.layout openmw_inventory_window.layout openmw_journal.layout - openmw_journal_skin.xml + openmw_journal.skin.xml openmw_layers.xml openmw_list.skin.xml openmw_mainmenu.layout - openmw_mainmenu_skin.xml + openmw_mainmenu.skin.xml openmw_map_window.layout - openmw_map_window_skin.xml + openmw_map_window.skin.xml openmw_messagebox.layout openmw_pointer.xml openmw_progress.skin.xml openmw_resources.xml openmw_scroll.layout - openmw_scroll_skin.xml + openmw_scroll.skin.xml openmw_settings_window.layout openmw_settings.xml openmw_spell_window.layout diff --git a/files/mygui/core.xml b/files/mygui/core.xml index 133109375..f3b482d50 100644 --- a/files/mygui/core.xml +++ b/files/mygui/core.xml @@ -15,12 +15,12 @@ - + - - - - + + + + diff --git a/files/mygui/openmw_dialogue_window_skin.xml b/files/mygui/openmw_dialogue_window.skin.xml similarity index 100% rename from files/mygui/openmw_dialogue_window_skin.xml rename to files/mygui/openmw_dialogue_window.skin.xml diff --git a/files/mygui/openmw_journal_skin.xml b/files/mygui/openmw_journal.skin.xml similarity index 100% rename from files/mygui/openmw_journal_skin.xml rename to files/mygui/openmw_journal.skin.xml diff --git a/files/mygui/openmw_mainmenu_skin.xml b/files/mygui/openmw_mainmenu.skin.xml similarity index 100% rename from files/mygui/openmw_mainmenu_skin.xml rename to files/mygui/openmw_mainmenu.skin.xml diff --git a/files/mygui/openmw_map_window_skin.xml b/files/mygui/openmw_map_window.skin.xml similarity index 100% rename from files/mygui/openmw_map_window_skin.xml rename to files/mygui/openmw_map_window.skin.xml diff --git a/files/mygui/openmw_scroll_skin.xml b/files/mygui/openmw_scroll.skin.xml similarity index 100% rename from files/mygui/openmw_scroll_skin.xml rename to files/mygui/openmw_scroll.skin.xml From f0c739b7634b90aee464f71cf5fd1d5f71afee67 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 06:27:54 +1000 Subject: [PATCH 56/90] Apply camera setting changes immediately. Remove current value check for shader setting changes. --- apps/opencs/model/settings/usersettings.cpp | 10 ++++------ apps/opencs/view/render/scenewidget.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index bc197ab48..156bff22a 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -83,7 +83,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); + Setting *farClipDist = createSetting (Type_DoubleSpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); farClipDist->setEditorSetting(true); farClipDist->setColumnSpan (1); @@ -483,15 +483,13 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, { mSettingDefinitions->setValue (settingKey ,list); - if(settingKey == "Objects/num_lights" - && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + if(settingKey == "Objects/num_lights" && !list.empty()) { sh::Factory::getInstance ().setGlobalSetting ("num_lights", list.at(0).toStdString()); } - else if(settingKey == "Objects/shaders" - && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + else if(settingKey == "Objects/shaders" && !list.empty()) { - sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); + sh::Factory::getInstance ().setShadersEnabled (list.at(0).toStdString() == "true" ? true : false); } emit userSettingUpdated (settingKey, list); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 9ff9ac4db..3ca2a171c 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -48,7 +48,7 @@ namespace CSVRender CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toInt(); + float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat(); mCamera->setFarClipDistance (farClipDist); mFastFactor = userSettings.setting("Scene/fast factor", QString("4")).toInt(); @@ -412,6 +412,12 @@ namespace CSVRender if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); + if(key == "Objects/far clip distance" && !list.empty()) + { + if(mCamera->getFarClipDistance() != list.at(0).toFloat()) + mCamera->setFarClipDistance(list.at(0).toFloat()); + } + // minimise unnecessary ogre window creation by updating only when there is a change if(key == "Video/antialiasing") { From 54c77cf875e3238119d477c452b7abaabf7d45f2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 06:39:44 +1000 Subject: [PATCH 57/90] Silence clang warnings. --- apps/opencs/view/settings/booleanview.cpp | 2 +- apps/opencs/view/settings/rangeview.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 58b822179..29f9775af 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -43,7 +43,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - if(mType != CSMSettings::Type_CheckBox || mButtons.empty()) + if(button && (mType != CSMSettings::Type_CheckBox || mButtons.empty())) { connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 6b47b1cac..c96df9859 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -36,8 +36,11 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, break; } - mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); - mRangeWidget->setObjectName (setting->name()); + if(mRangeWidget) + { + mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); + mRangeWidget->setObjectName (setting->name()); + } addWidget (mRangeWidget); } @@ -75,13 +78,16 @@ void CSVSettings::RangeView::buildSlider (CSMSettings::Setting *setting) break; } - mRangeWidget->setProperty ("minimum", setting->minimum()); - mRangeWidget->setProperty ("maximum", setting->maximum()); - mRangeWidget->setProperty ("tracking", false); - mRangeWidget->setProperty ("singleStep", setting->singleStep()); + if(mRangeWidget) + { + mRangeWidget->setProperty ("minimum", setting->minimum()); + mRangeWidget->setProperty ("maximum", setting->maximum()); + mRangeWidget->setProperty ("tracking", false); + mRangeWidget->setProperty ("singleStep", setting->singleStep()); - connect (mRangeWidget, SIGNAL (valueChanged (int)), - this, SLOT (slotUpdateView (int))); + connect (mRangeWidget, SIGNAL (valueChanged (int)), + this, SLOT (slotUpdateView (int))); + } } void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) From 7675df60bab0f9e4a384ffc774903a8deb3b9673 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 08:17:51 +1000 Subject: [PATCH 58/90] Fix far clip distance (again), workaround for broken settings minimum value. --- apps/opencs/model/settings/usersettings.cpp | 5 ++++- apps/opencs/view/render/scenewidget.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 156bff22a..11fdc54f4 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -56,7 +56,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); - numLights->setMinimum (2); + numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); @@ -79,6 +79,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setEditorSetting(true); fastFactor->setColumnSpan (1); fastFactor->setMinimum (1); + fastFactor->setSpecialValueText ("1"); // FIXME: workaround fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); @@ -109,6 +110,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() maxSubView->setEditorSetting(true); maxSubView->setColumnSpan (1); maxSubView->setMinimum (1); + maxSubView->setSpecialValueText ("1"); maxSubView->setMaximum (256); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); maxSubView->setViewLocation(1, 2); @@ -118,6 +120,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setEditorSetting(true); minWidth->setColumnSpan (1); minWidth->setMinimum (50); + minWidth->setSpecialValueText ("50"); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 3ca2a171c..2b2c8ade0 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -412,7 +412,7 @@ namespace CSVRender if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); - if(key == "Objects/far clip distance" && !list.empty()) + if(key == "Scene/far clip distance" && !list.empty()) { if(mCamera->getFarClipDistance() != list.at(0).toFloat()) mCamera->setFarClipDistance(list.at(0).toFloat()); From 7f18f85a1d51c122e919f69d36110d0d838b957f Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 12:04:19 +0200 Subject: [PATCH 59/90] Forgot const --- apps/openmw/mwmechanics/actors.cpp | 4 ++-- .../openmw/mwmechanics/mechanicsmanagerimp.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index cbc43636c..a5063594a 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -475,8 +475,8 @@ namespace MWMechanics // restore fatigue const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); - static float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); - static float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); + static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); + static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); float x = fFatigueReturnBase + fFatigueReturnMult * endurance; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index d5cb23806..ef03d285c 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -567,12 +567,12 @@ namespace MWMechanics const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr); const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); - static float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); + static const float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace)) x += fDispRaceMod; - static float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); - static float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); + static const float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); + static const float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); x += fDispPersonalityMult * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - fDispPersonalityBase); float reaction = 0; @@ -610,20 +610,20 @@ namespace MWMechanics rank = 0; } - static float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); - static float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); - static float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); + static const float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); + static const float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); + static const float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); x += (fDispFactionRankMult * rank + fDispFactionRankBase) * fDispFactionMod * reaction; - static float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); - static float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); + static const float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); + static const float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); x -= fDispCrimeMod * playerStats.getBounty(); if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) x += fDispDiseaseMod; - static float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); + static const float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); if (playerStats.getDrawState() == MWMechanics::DrawState_Weapon) x += fDispWeaponDrawn; From b345c50a86531d9c8b93899ef0716cf780aa7168 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 14:55:31 +0200 Subject: [PATCH 60/90] Run stepSimulation before moving actors Shouldn't make too much of a difference, but a nice side effect is seeing the convexSweepTest calls for actor movements in the profiler results. --- apps/openmw/mwworld/worldimp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 1f3cf01e1..dd766eed1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1309,6 +1309,8 @@ namespace MWWorld void World::doPhysics(float duration) { + mPhysics->stepSimulation(duration); + processDoors(duration); mProjectileManager->update(duration); @@ -1327,8 +1329,6 @@ namespace MWWorld } if(player != results.end()) moveObjectImp(player->first, player->second.x, player->second.y, player->second.z); - - mPhysics->stepSimulation(duration); } bool World::castRay (float x1, float y1, float z1, float x2, float y2, float z2) From 3e153d0a9b8ce88e4d74ef54ab46aee631ee5749 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 22:30:21 +0200 Subject: [PATCH 61/90] Optimize actor physics: Use only one convexSweepTest for stepping down and checking onGround status, instead of 2 --- apps/openmw/mwworld/physicssystem.cpp | 36 +++++++++++---------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 97ea7ca91..7ca3c10cf 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -286,8 +286,9 @@ namespace MWWorld */ OEngine::Physic::ActorTracer tracer; - bool wasOnGround = false; - bool isOnGround = false; + bool isOnGround = physicActor->getOnGround(); + if (movement.z > 0.f) + isOnGround = false; Ogre::Vector3 inertia(0.0f); Ogre::Vector3 velocity; @@ -320,23 +321,6 @@ namespace MWWorld velocity = newVelocity; } inertia = velocity; // NOTE: velocity is for z axis only in this code block - - if(!(movement.z > 0.0f)) // falling or moving horizontally (or stationary?) check if we're on ground now - { - wasOnGround = physicActor->getOnGround(); // store current state - tracer.doTrace(colobj, position, position - Ogre::Vector3(0,0,2), engine); // check if down 2 possible - if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) - { - const btCollisionObject* standingOn = tracer.mHitObject; - if (const OEngine::Physic::RigidBody* body = dynamic_cast(standingOn)) - { - standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName; - } - isOnGround = true; - // if we're on the ground, don't try to fall any more - velocity.z = std::max(0.0f, velocity.z); - } - } } ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0; @@ -439,12 +423,22 @@ namespace MWWorld } } - if(isOnGround || wasOnGround) + if (!(inertia.z > 0.f) && !(newPosition.z < waterlevel || isFlying)) { - tracer.doTrace(colobj, newPosition, newPosition - Ogre::Vector3(0,0,sStepSize+2.0f), engine); + Ogre::Vector3 from = newPosition; + Ogre::Vector3 to = newPosition - (isOnGround ? + Ogre::Vector3(0,0,sStepSize+2.f) : Ogre::Vector3(0,0,2.f)); + tracer.doTrace(colobj, from, to, engine); if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) { + const btCollisionObject* standingOn = tracer.mHitObject; + if (const OEngine::Physic::RigidBody* body = dynamic_cast(standingOn)) + { + standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName; + } + newPosition.z = tracer.mEndPos.z + 1.0f; + isOnGround = true; } else From da9d8582017fe358c426831c3567236098e6171f Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Mon, 29 Sep 2014 20:59:10 -0500 Subject: [PATCH 62/90] Add 'const' to a spell helper function. --- apps/openmw/mwmechanics/spells.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index 7caeba6e8..ab799ffe1 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -74,7 +74,7 @@ namespace MWMechanics TIterator end() const; - bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); } + bool hasSpell(const std::string& spell) const { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); } void add (const std::string& spell); ///< Adding a spell that is already listed in *this is a no-op. From 850a40d4e2fa963e53cf4bface73a702f236084b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 30 Sep 2014 13:15:15 +0200 Subject: [PATCH 63/90] fixed resources table drag source problem --- apps/opencs/model/world/resourcesmanager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/world/resourcesmanager.cpp b/apps/opencs/model/world/resourcesmanager.cpp index ec6746521..50014f4b5 100644 --- a/apps/opencs/model/world/resourcesmanager.cpp +++ b/apps/opencs/model/world/resourcesmanager.cpp @@ -6,18 +6,20 @@ void CSMWorld::ResourcesManager::addResources (const Resources& resources) { mResources.insert (std::make_pair (resources.getType(), resources)); + mResources.insert (std::make_pair (UniversalId::getParentType (resources.getType()), + resources)); } void CSMWorld::ResourcesManager::listResources() { static const char * const sMeshTypes[] = { "nif", 0 }; - addResources (Resources ("meshes", UniversalId::Type_Meshes, sMeshTypes)); - addResources (Resources ("icons", UniversalId::Type_Icons)); - addResources (Resources ("music", UniversalId::Type_Musics)); - addResources (Resources ("sound", UniversalId::Type_SoundsRes)); - addResources (Resources ("textures", UniversalId::Type_Textures)); - addResources (Resources ("videos", UniversalId::Type_Videos)); + addResources (Resources ("meshes", UniversalId::Type_Mesh, sMeshTypes)); + addResources (Resources ("icons", UniversalId::Type_Icon)); + addResources (Resources ("music", UniversalId::Type_Music)); + addResources (Resources ("sound", UniversalId::Type_SoundRes)); + addResources (Resources ("textures", UniversalId::Type_Texture)); + addResources (Resources ("videos", UniversalId::Type_Video)); } const CSMWorld::Resources& CSMWorld::ResourcesManager::get (UniversalId::Type type) const From c010c28337d73a502cb17ee8f2602e4225212073 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Sep 2014 15:53:27 +0200 Subject: [PATCH 64/90] Implement ToggleWorld instruction --- apps/openmw/mwbase/world.hpp | 1 + apps/openmw/mwrender/renderingmanager.cpp | 10 ++++++++++ apps/openmw/mwrender/renderingmanager.hpp | 3 +++ apps/openmw/mwscript/docs/vmformat.txt | 3 ++- apps/openmw/mwscript/miscextensions.cpp | 12 ++++++++++++ apps/openmw/mwworld/worldimp.cpp | 5 +++++ apps/openmw/mwworld/worldimp.hpp | 1 + components/compiler/extensions0.cpp | 2 ++ components/compiler/opcodes.hpp | 1 + 9 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 2055aeeae..3f6260c05 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -119,6 +119,7 @@ namespace MWBase virtual void setWaterHeight(const float height) = 0; virtual bool toggleWater() = 0; + virtual bool toggleWorld() = 0; virtual void adjustSky() = 0; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 4512bbbeb..68d5f515d 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -63,6 +63,7 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b , mPhysicsEngine(engine) , mTerrain(NULL) , mEffectManager(NULL) + , mRenderWorld(true) { mActors = new MWRender::Actors(mRendering, this); mObjects = new MWRender::Objects(mRendering); @@ -232,6 +233,15 @@ bool RenderingManager::toggleWater() return mWater->toggle(); } +bool RenderingManager::toggleWorld() +{ + mRenderWorld = !mRenderWorld; + + int visibilityMask = mRenderWorld ? ~int(0) : 0; + mRendering.getViewport()->setVisibilityMask(visibilityMask); + return mRenderWorld; +} + void RenderingManager::cellAdded (MWWorld::CellStore *store) { if (store->isExterior()) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 43d22d5ca..1c735f056 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -123,6 +123,7 @@ public: void setWaterHeight(const float height); bool toggleWater(); + bool toggleWorld(); /// Updates object rendering after cell change /// \param old Object reference in previous cell @@ -266,6 +267,8 @@ private: MWRender::LocalMap* mLocalMap; MWRender::Shadows* mShadows; + + bool mRenderWorld; }; } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 626332564..b80c84d67 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -432,5 +432,6 @@ op 0x20002ac-0x20002c3: SetMagicEffect, explicit op 0x20002c4-0x20002db: ModMagicEffect op 0x20002dc-0x20002f3: ModMagicEffect, explicit op 0x20002f4: ResetActors +op 0x20002f5: ToggleWorld -opcodes 0x20002f5-0x3ffffff unused +opcodes 0x20002f6-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index be8c85bbf..ef879a95a 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -290,6 +290,17 @@ namespace MWScript } }; + class OpToggleWorld : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + runtime.getContext().report(MWBase::Environment::get().getWorld()->toggleWorld() ? "World -> On" + : "World -> Off"); + } + }; + class OpDontSaveObject : public Interpreter::Opcode0 { public: @@ -979,6 +990,7 @@ namespace MWScript interpreter.installSegment5 (Compiler::Misc::opcodeFadeTo, new OpFadeTo); interpreter.installSegment5 (Compiler::Misc::opcodeTogglePathgrid, new OpTogglePathgrid); interpreter.installSegment5 (Compiler::Misc::opcodeToggleWater, new OpToggleWater); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleWorld, new OpToggleWorld); interpreter.installSegment5 (Compiler::Misc::opcodeDontSaveObject, new OpDontSaveObject); interpreter.installSegment5 (Compiler::Misc::opcodeToggleVanityMode, new OpToggleVanityMode); interpreter.installSegment5 (Compiler::Misc::opcodeGetPcSleep, new OpGetPcSleep); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index dd766eed1..91fcf2b95 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1663,6 +1663,11 @@ namespace MWWorld return mRendering->toggleWater(); } + bool World::toggleWorld() + { + return mRendering->toggleWorld(); + } + void World::PCDropped (const Ptr& item) { std::string script = item.getClass().getScript(item); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index d4f11f5b6..8fd27dec9 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -180,6 +180,7 @@ namespace MWWorld virtual void setWaterHeight(const float height); virtual bool toggleWater(); + virtual bool toggleWorld(); virtual void adjustSky(); diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index e12ab65eb..25ee6fdb6 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -256,6 +256,8 @@ namespace Compiler extensions.registerInstruction ("fadeto", "ff", opcodeFadeTo); extensions.registerInstruction ("togglewater", "", opcodeToggleWater); extensions.registerInstruction ("twa", "", opcodeToggleWater); + extensions.registerInstruction ("toggleworld", "", opcodeToggleWorld); + extensions.registerInstruction ("tw", "", opcodeToggleWorld); extensions.registerInstruction ("togglepathgrid", "", opcodeTogglePathgrid); extensions.registerInstruction ("tpg", "", opcodeTogglePathgrid); extensions.registerInstruction ("dontsaveobject", "", opcodeDontSaveObject); diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 440475773..5063397e1 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -212,6 +212,7 @@ namespace Compiler const int opcodeFadeOut = 0x200013d; const int opcodeFadeTo = 0x200013e; const int opcodeToggleWater = 0x2000144; + const int opcodeToggleWorld = 0x20002f5; const int opcodeTogglePathgrid = 0x2000146; const int opcodeDontSaveObject = 0x2000153; const int opcodeToggleVanityMode = 0x2000174; From 795dfdb5576da3cb1d46b1838c2f8d3ab0fb5d58 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Sep 2014 18:14:25 +0200 Subject: [PATCH 65/90] Fix size_t underflow for journals with 1 page (Fixes #1958) --- apps/openmw/mwgui/journalwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 4139a7d24..0bcd5062d 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -490,7 +490,7 @@ namespace unsigned int & page = mStates.top ().mPage; Book book = mStates.top ().mBook; - if (page < book->pageCount () - 2) + if (page+2 < book->pageCount()) { page += 2; updateShowingPages (); From c826de49a515fbf9cdb623308b284e945b933061 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Sep 2014 22:57:00 +0200 Subject: [PATCH 66/90] Potential shader compatibility fix --- files/materials/water.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/materials/water.shader b/files/materials/water.shader index 701154ffa..418b13715 100644 --- a/files/materials/water.shader +++ b/files/materials/water.shader @@ -40,7 +40,7 @@ SH_START_PROGRAM { - shOutputColour(0).xyz = shSample(animatedTexture, UV * 15).xyz * float3(1.0, 1.0, 1.0); + shOutputColour(0).xyz = shSample(animatedTexture, UV * float2(15.0, 15.0)).xyz * float3(1.0, 1.0, 1.0); shOutputColour(0).w = 0.7; #if FOG From ee8b85aa2ca4da655adf19ab4401ac3c539557e7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Sep 2014 22:57:38 +0200 Subject: [PATCH 67/90] Fix priority bug in AiSequence::stack (Fixes #1959) --- apps/openmw/mwmechanics/aisequence.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 0341c9745..f28809d4f 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -260,15 +260,14 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor) for(std::list::iterator it = mPackages.begin(); it != mPackages.end(); ++it) { - if(mPackages.front()->getPriority() <= package.getPriority()) + if((*it)->getPriority() <= package.getPriority()) { mPackages.insert(it,package.clone()); return; } } - if(mPackages.empty()) - mPackages.push_front (package.clone()); + mPackages.push_front (package.clone()); } AiPackage* MWMechanics::AiSequence::getActivePackage() From 46adf6344a60f57c66a6a03876e344d630f00f86 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 17:45:20 +0200 Subject: [PATCH 68/90] Adjust third person camera height and default distance to match vanilla MW --- apps/openmw/mwrender/camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index bb196f282..51fcb4686 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -26,8 +26,8 @@ namespace MWRender mNearest(30.f), mFurthest(800.f), mIsNearest(false), - mHeight(128.f), - mCameraDistance(300.f), + mHeight(124.f), + mCameraDistance(192.f), mDistanceAdjusted(false), mVanityToggleQueued(false), mViewModeToggleQueued(false) From f9b6cc468db9d826f260fdc1d893b4c323ffd9ab Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 17:54:18 +0200 Subject: [PATCH 69/90] Don't reset an unbound input action to its default binding if the key/mouse button for that default binding is already used by another action (Fixes #1960) --- apps/openmw/mwinput/inputmanagerimp.cpp | 6 ++++-- extern/oics/ICSInputControlSystem.h | 4 +++- extern/oics/ICSInputControlSystem_keyboard.cpp | 5 +++++ extern/oics/ICSInputControlSystem_mouse.cpp | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 3cd30819c..10cd34749 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -936,9 +936,11 @@ namespace MWInput { clearAllBindings (control); - if (defaultKeyBindings.find(i) != defaultKeyBindings.end()) + if (defaultKeyBindings.find(i) != defaultKeyBindings.end() + && !mInputBinder->isKeyBound(defaultKeyBindings[i])) mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE); - else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()) + else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end() + && !mInputBinder->isMouseButtonBound(defaultMouseButtonBindings[i])) mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); } } diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index f874abaf8..6a6a6bf09 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -119,9 +119,11 @@ namespace ICS //bool sliderMoved(const OIS::JoyStickEvent &evt, int index); void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction); + bool isKeyBound(SDL_Scancode key) const; void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction); void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction); - void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction); + bool isMouseButtonBound(unsigned int button) const; + void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction); void addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction); void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction); void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction); diff --git a/extern/oics/ICSInputControlSystem_keyboard.cpp b/extern/oics/ICSInputControlSystem_keyboard.cpp index af0eec82a..ed35d9870 100644 --- a/extern/oics/ICSInputControlSystem_keyboard.cpp +++ b/extern/oics/ICSInputControlSystem_keyboard.cpp @@ -61,6 +61,11 @@ namespace ICS mControlsKeyBinderMap[ key ] = controlKeyBinderItem; } + bool InputControlSystem::isKeyBound(SDL_Scancode key) const + { + return mControlsKeyBinderMap.find(key) != mControlsKeyBinderMap.end(); + } + void InputControlSystem::removeKeyBinding(SDL_Scancode key) { ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key); diff --git a/extern/oics/ICSInputControlSystem_mouse.cpp b/extern/oics/ICSInputControlSystem_mouse.cpp index d1ef721b2..9742d389c 100644 --- a/extern/oics/ICSInputControlSystem_mouse.cpp +++ b/extern/oics/ICSInputControlSystem_mouse.cpp @@ -139,6 +139,11 @@ namespace ICS mControlsMouseButtonBinderMap[ button ] = controlMouseButtonBinderItem; } + bool InputControlSystem::isMouseButtonBound(unsigned int button) const + { + return mControlsMouseButtonBinderMap.find(button) != mControlsMouseButtonBinderMap.end(); + } + // get bindings InputControlSystem::NamedAxis InputControlSystem::getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction) { From 517a797a3ed219632ee1240f32b3d078d0e04f40 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 2 Oct 2014 07:00:15 +1000 Subject: [PATCH 70/90] Remove seemingly unnecessary clearFocus() call (thanks scrawl for help). Fix saving window size on linux. --- apps/opencs/view/doc/view.cpp | 14 ++++++++++++-- apps/opencs/view/settings/settingwindow.cpp | 6 +----- apps/opencs/view/settings/settingwindow.hpp | 2 -- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 744865f1c..8edeeaec7 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -33,12 +33,22 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) else { // save window size first + int width = 0; + int height = 0; + +#ifdef Q_WS_WIN + width = frameGeometry().width(); + height = frameGeometry().height(); +#else + width = geometry().width(); + height = geometry().height(); +#endif CSMSettings::UserSettings::instance().setDefinitions( "Window Size/Width", - QStringList(QString::number(frameGeometry().width()))); + QStringList(QString::number(width))); CSMSettings::UserSettings::instance().setDefinitions( "Window Size/Height", - QStringList(QString::number(frameGeometry().height()))); + QStringList(QString::number(height))); CSMSettings::UserSettings::instance().saveDefinitions(); // closeRequest() returns true if last document diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..590b6f7a5 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -19,7 +19,7 @@ void CSVSettings::SettingWindow::createPages() QList connectedSettings; foreach (const QString &pageName, pageMap.keys()) - { + { QList pageSettings = pageMap.value (pageName); mPages.append (new Page (pageName, pageSettings, this)); @@ -129,7 +129,3 @@ void CSVSettings::SettingWindow::saveSettings() mModel->saveDefinitions(); } -void CSVSettings::SettingWindow::closeEvent (QCloseEvent *event) -{ - QApplication::focusWidget()->clearFocus(); -} diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..11bceee96 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -36,8 +36,6 @@ namespace CSVSettings { protected: - virtual void closeEvent (QCloseEvent *event); - ///construct the pages to be displayed in the dialog void createPages(); From 85f5754bb67fe61bc3c92617860782d4c67007d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 18:55:35 +0200 Subject: [PATCH 71/90] Apply third person camera distance to the camera node instead of only the camera itself (Fixes #1705) --- apps/openmw/mwrender/camera.cpp | 72 +++++++++++++++-------- apps/openmw/mwrender/camera.hpp | 6 +- apps/openmw/mwrender/renderingmanager.cpp | 12 +++- apps/openmw/mwrender/renderingmanager.hpp | 2 + apps/openmw/mwrender/sky.cpp | 32 ++++++---- apps/openmw/mwrender/sky.hpp | 3 + 6 files changed, 86 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 51fcb4686..5a4b51504 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -19,6 +19,7 @@ namespace MWRender Camera::Camera (Ogre::Camera *camera) : mCamera(camera), mCameraNode(NULL), + mCameraPosNode(NULL), mAnimation(NULL), mFirstPersonView(true), mPreviewMode(false), @@ -66,12 +67,16 @@ namespace MWRender } Ogre::Quaternion xr(Ogre::Radian(getPitch() + Ogre::Math::HALF_PI), Ogre::Vector3::UNIT_X); - if (!mVanity.enabled && !mPreviewMode) { - mCamera->getParentNode()->setOrientation(xr); - } else { + Ogre::Quaternion orient = xr; + if (mVanity.enabled || mPreviewMode) { Ogre::Quaternion zr(Ogre::Radian(getYaw()), Ogre::Vector3::UNIT_Z); - mCamera->getParentNode()->setOrientation(zr * xr); + orient = zr * xr; } + + if (isFirstPerson()) + mCamera->getParentNode()->setOrientation(orient); + else + mCameraNode->setOrientation(orient); } const std::string &Camera::getHandle() const @@ -79,20 +84,40 @@ namespace MWRender return mTrackingPtr.getRefData().getHandle(); } - void Camera::attachTo(const MWWorld::Ptr &ptr) + Ogre::SceneNode* Camera::attachTo(const MWWorld::Ptr &ptr) { mTrackingPtr = ptr; Ogre::SceneNode *node = mTrackingPtr.getRefData().getBaseNode()->createChildSceneNode(Ogre::Vector3(0.0f, 0.0f, mHeight)); + node->setInheritScale(false); + Ogre::SceneNode *posNode = node->createChildSceneNode(); + posNode->setInheritScale(false); if(mCameraNode) { node->setOrientation(mCameraNode->getOrientation()); - node->setPosition(mCameraNode->getPosition()); - node->setScale(mCameraNode->getScale()); + posNode->setPosition(mCameraPosNode->getPosition()); mCameraNode->getCreator()->destroySceneNode(mCameraNode); + mCameraNode->getCreator()->destroySceneNode(mCameraPosNode); } mCameraNode = node; - if(!mCamera->isAttached()) - mCameraNode->attachObject(mCamera); + mCameraPosNode = posNode; + + if (!isFirstPerson()) + { + mCamera->detachFromParent(); + mCameraPosNode->attachObject(mCamera); + } + + return mCameraPosNode; + } + + void Camera::setPosition(const Ogre::Vector3& position) + { + mCameraPosNode->setPosition(position); + } + + void Camera::setPosition(float x, float y, float z) + { + setPosition(Ogre::Vector3(x,y,z)); } void Camera::updateListener() @@ -155,9 +180,9 @@ namespace MWRender processViewChange(); if (mFirstPersonView) { - mCamera->setPosition(0.f, 0.f, 0.f); + setPosition(0.f, 0.f, 0.f); } else { - mCamera->setPosition(0.f, 0.f, mCameraDistance); + setPosition(0.f, 0.f, mCameraDistance); } } @@ -191,14 +216,14 @@ namespace MWRender Ogre::Vector3 rot(0.f, 0.f, 0.f); if (mVanity.enabled) { rot.x = Ogre::Degree(-30.f).valueRadians(); - mMainCam.offset = mCamera->getPosition().z; + mMainCam.offset = mCameraPosNode->getPosition().z; } else { rot.x = getPitch(); offset = mMainCam.offset; } rot.z = getYaw(); - mCamera->setPosition(0.f, 0.f, offset); + setPosition(0.f, 0.f, offset); rotateCamera(rot, false); return true; @@ -215,7 +240,7 @@ namespace MWRender mPreviewMode = enable; processViewChange(); - float offset = mCamera->getPosition().z; + float offset = mCameraPosNode->getPosition().z; if (mPreviewMode) { mMainCam.offset = offset; offset = mPreviewCam.offset; @@ -224,7 +249,7 @@ namespace MWRender offset = mMainCam.offset; } - mCamera->setPosition(0.f, 0.f, offset); + setPosition(0.f, 0.f, offset); } void Camera::setSneakOffset(float offset) @@ -283,7 +308,7 @@ namespace MWRender float Camera::getCameraDistance() const { - return mCamera->getPosition().z; + return mCameraPosNode->getPosition().z; } void Camera::setCameraDistance(float dist, bool adjust, bool override) @@ -295,7 +320,7 @@ namespace MWRender Ogre::Vector3 v(0.f, 0.f, dist); if (adjust) { - v += mCamera->getPosition(); + v += mCameraPosNode->getPosition(); } if (v.z >= mFurthest) { v.z = mFurthest; @@ -305,7 +330,7 @@ namespace MWRender v.z = mNearest; mIsNearest = true; } - mCamera->setPosition(v); + setPosition(v); if (override) { if (mVanity.enabled || mPreviewMode) { @@ -322,9 +347,9 @@ namespace MWRender { if (mDistanceAdjusted) { if (mVanity.enabled || mPreviewMode) { - mCamera->setPosition(0, 0, mPreviewCam.offset); + setPosition(0, 0, mPreviewCam.offset); } else if (!mFirstPersonView) { - mCamera->setPosition(0, 0, mCameraDistance); + setPosition(0, 0, mCameraDistance); } } mDistanceAdjusted = false; @@ -355,10 +380,10 @@ namespace MWRender Ogre::TagPoint *tag = mAnimation->attachObjectToBone("Head", mCamera); tag->setInheritOrientation(false); } - else + else { mAnimation->setViewMode(NpcAnimation::VM_Normal); - mCameraNode->attachObject(mCamera); + mCameraPosNode->attachObject(mCamera); } rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false); } @@ -368,8 +393,7 @@ namespace MWRender mCamera->getParentSceneNode()->needUpdate(true); camera = mCamera->getRealPosition(); - focal = Ogre::Vector3((mCamera->getParentNode()->_getFullTransform() * - Ogre::Vector4(0.0f, 0.0f, 0.0f, 1.0f)).ptr()); + focal = mCameraNode->_getDerivedPosition(); } void Camera::togglePlayerLooking(bool enable) diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index f7b0ae6e8..c542dc96c 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -27,6 +27,7 @@ namespace MWRender Ogre::Camera *mCamera; Ogre::SceneNode *mCameraNode; + Ogre::SceneNode *mCameraPosNode; NpcAnimation *mAnimation; @@ -52,6 +53,9 @@ namespace MWRender /// Updates sound manager listener data void updateListener(); + void setPosition(const Ogre::Vector3& position); + void setPosition(float x, float y, float z); + public: Camera(Ogre::Camera *camera); ~Camera(); @@ -72,7 +76,7 @@ namespace MWRender const std::string &getHandle() const; /// Attach camera to object - void attachTo(const MWWorld::Ptr &); + Ogre::SceneNode* attachTo(const MWWorld::Ptr &); /// @param Force view mode switch, even if currently not allowed by the animation. void toggleViewMode(bool force=false); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 68d5f515d..f476a7807 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -312,7 +312,7 @@ void RenderingManager::updatePlayerPtr(const MWWorld::Ptr &ptr) if(mPlayerAnimation) mPlayerAnimation->updatePtr(ptr); if(mCamera->getHandle() == ptr.getRefData().getHandle()) - mCamera->attachTo(ptr); + attachCameraTo(ptr); } void RenderingManager::rebuildPtr(const MWWorld::Ptr &ptr) @@ -327,7 +327,7 @@ void RenderingManager::rebuildPtr(const MWWorld::Ptr &ptr) anim->rebuild(); if(mCamera->getHandle() == ptr.getRefData().getHandle()) { - mCamera->attachTo(ptr); + attachCameraTo(ptr); mCamera->setAnimation(anim); } } @@ -869,7 +869,13 @@ void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned i void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr) { ptr.getRefData().setBaseNode(mRendering.getScene()->getSceneNode("player")); - mCamera->attachTo(ptr); + attachCameraTo(ptr); +} + +void RenderingManager::attachCameraTo(const MWWorld::Ptr &ptr) +{ + Ogre::SceneNode* cameraNode = mCamera->attachTo(ptr); + mSkyManager->attachToNode(cameraNode); } void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 1c735f056..fa48deafa 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -221,6 +221,8 @@ private: void setAmbientMode(); void applyFog(bool underwater); + void attachCameraTo(const MWWorld::Ptr& ptr); + void setMenuTransparency(float val); bool mSunEnabled; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 4620173b5..8e7bd3d89 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -382,9 +382,7 @@ void SkyManager::clearRain() for (std::map::iterator it = mRainModels.begin(); it != mRainModels.end();) { it->second.setNull(); - Ogre::SceneNode* parent = it->first->getParentSceneNode(); mSceneMgr->destroySceneNode(it->first); - mSceneMgr->destroySceneNode(parent); mRainModels.erase(it++); } } @@ -402,9 +400,7 @@ void SkyManager::updateRain(float dt) if (pos.z < -minHeight) { it->second.setNull(); - Ogre::SceneNode* parent = it->first->getParentSceneNode(); mSceneMgr->destroySceneNode(it->first); - mSceneMgr->destroySceneNode(parent); mRainModels.erase(it++); } else @@ -420,17 +416,20 @@ void SkyManager::updateRain(float dt) { mRainTimer = 0; + // TODO: handle rain settings from Morrowind.ini const float rangeRandom = 100; float xOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2); float yOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2); - Ogre::SceneNode* sceneNode = mCamera->getParentSceneNode()->createChildSceneNode(); - sceneNode->setInheritOrientation(false); // Create a separate node to control the offset, since a node with setInheritOrientation(false) will still // consider the orientation of the parent node for its position, just not for its orientation float startHeight = 700; - Ogre::SceneNode* offsetNode = sceneNode->createChildSceneNode(Ogre::Vector3(xOffs,yOffs,startHeight)); + Ogre::SceneNode* offsetNode = mParticleNode->createChildSceneNode(Ogre::Vector3(xOffs,yOffs,startHeight)); + // Spawn a new rain object for each instance. + // TODO: this is inefficient. We could try to use an Ogre::ParticleSystem instead, but then we would need to make assumptions + // about the rain meshes being Quads and their dimensions. + // Or we could clone meshes into one vertex buffer manually. NifOgre::ObjectScenePtr objects = NifOgre::Loader::createObjects(offsetNode, mRainEffect); for (unsigned int i=0; imEntities.size(); ++i) { @@ -562,12 +561,6 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) } else { - if (!mParticleNode) - { - mParticleNode = mCamera->getParentSceneNode()->createChildSceneNode(); - mParticleNode->setInheritOrientation(false); - } - mParticle = NifOgre::Loader::createObjects(mParticleNode, mCurrentParticleEffect); for(size_t i = 0; i < mParticle->mParticles.size(); ++i) { @@ -783,3 +776,16 @@ void SkyManager::setGlareEnabled (bool enabled) return; mSunGlare->setVisible (mSunEnabled && enabled); } + +void SkyManager::attachToNode(SceneNode *sceneNode) +{ + if (!mParticleNode) + { + mParticleNode = sceneNode->createChildSceneNode(); + mParticleNode->setInheritOrientation(false); + } + else + { + sceneNode->addChild(mParticleNode); + } +} diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index e40eb1dce..0544f17ef 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -116,6 +116,9 @@ namespace MWRender SkyManager(Ogre::SceneNode* root, Ogre::Camera* pCamera); ~SkyManager(); + /// Attach weather particle effects to this scene node (should be the Camera's parent node) + void attachToNode(Ogre::SceneNode* sceneNode); + void update(float duration); void enable(); From 88da7f5157777f8b5e4159cbb3a845cb41e6b272 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 19:53:50 +0200 Subject: [PATCH 72/90] Adjust border skin for loading bar and message boxes to match vanilla MW --- apps/openmw/mwgui/messagebox.cpp | 8 +++----- files/mygui/openmw_loading_screen.layout | 2 +- files/mygui/openmw_messagebox.layout | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 80f38ba40..d4520aad7 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -157,12 +157,11 @@ namespace MWGui , mMaxTime(0) { // defines - mBottomPadding = 20; - mNextBoxPadding = 20; + mBottomPadding = 48; + mNextBoxPadding = 4; getWidget(mMessageWidget, "message"); - mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setCaptionWithReplacing(mMessage); } @@ -178,7 +177,7 @@ namespace MWGui int MessageBox::getHeight () { - return mMainWidget->getHeight()+mNextBoxPadding; // 20 is the padding between this and the next MessageBox + return mMainWidget->getHeight()+mNextBoxPadding; } @@ -204,7 +203,6 @@ namespace MWGui getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); - mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setSize(400, mMessageWidget->getHeight()); mMessageWidget->setCaptionWithReplacing(message); diff --git a/files/mygui/openmw_loading_screen.layout b/files/mygui/openmw_loading_screen.layout index eda002040..49ee0a1de 100644 --- a/files/mygui/openmw_loading_screen.layout +++ b/files/mygui/openmw_loading_screen.layout @@ -4,7 +4,7 @@ - + diff --git a/files/mygui/openmw_messagebox.layout b/files/mygui/openmw_messagebox.layout index 8264d64b9..a70e14503 100644 --- a/files/mygui/openmw_messagebox.layout +++ b/files/mygui/openmw_messagebox.layout @@ -1,7 +1,7 @@ - + From cd52002740b410c4af9e48d1d32d053ac25425a8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 21:41:45 +0200 Subject: [PATCH 73/90] Remove some unneeded bits from collision mask --- libs/openengine/bullet/physic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d3aa714f1..97418fae0 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -387,7 +387,7 @@ namespace Physic mHeightFieldMap [name] = hf; mDynamicsWorld->addRigidBody(body,CollisionType_HeightMap, - CollisionType_World|CollisionType_Actor|CollisionType_Raycasting); + CollisionType_Actor|CollisionType_Raycasting); } void PhysicEngine::removeHeightField(int x, int y) @@ -494,7 +494,7 @@ namespace Physic { assert (mCollisionObjectMap.find(name) == mCollisionObjectMap.end()); mCollisionObjectMap[name] = body; - mDynamicsWorld->addRigidBody(body,CollisionType_World,CollisionType_World|CollisionType_Actor|CollisionType_HeightMap); + mDynamicsWorld->addRigidBody(body,CollisionType_World,CollisionType_Actor|CollisionType_HeightMap); } else { From 1c51694aa98963f02c0493b0817f4f0d7b176c41 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 21:54:59 +0200 Subject: [PATCH 74/90] Don't update physics and animation for actors outside the AI processing distance --- apps/openmw/mwmechanics/actors.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index a5063594a..82f60221b 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1122,20 +1122,21 @@ namespace MWMechanics int hostilesCount = 0; // need to know this to play Battle music + // AI processing is only done within distance of 7168 units to the player. Note the "AI distance" slider doesn't affect this + // (it only does some throttling for targets beyond the "AI distance", so doesn't give any guarantees as to whether AI will be enabled or not) + // This distance could be made configurable later, but the setting must be marked with a big warning: + // using higher values will make a quest in Bloodmoon harder or impossible to complete (bug #1876) + const float sqrProcessingDistance = 7168*7168; + // AI and magic effects update for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { if (!iter->first.getClass().getCreatureStats(iter->first).isDead()) { updateActor(iter->first, duration); - - // AI processing is only done within distance of 7168 units to the player. Note the "AI distance" slider doesn't affect this - // (it only does some throttling for targets beyond the "AI distance", so doesn't give any guarantees as to whether AI will be enabled or not) - // This distance could be made configurable later, but the setting must be marked with a big warning: - // using higher values will make a quest in Bloodmoon harder or impossible to complete (bug #1876) if (MWBase::Environment::get().getMechanicsManager()->isAIActive() && Ogre::Vector3(player.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(iter->first.getRefData().getPosition().pos)) - <= 7168*7168) + <= sqrProcessingDistance) { if (timerUpdateAITargets == 0) { @@ -1182,6 +1183,11 @@ namespace MWMechanics CharacterController* playerCharacter = NULL; for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { + if (iter->first != player && + Ogre::Vector3(player.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(iter->first.getRefData().getPosition().pos)) + > sqrProcessingDistance) + continue; + if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( ESM::MagicEffect::Paralyze).getMagnitude() > 0) iter->second->skipAnim(); From a9a0930b855b76ef6af00ce01e3f163c7f880b33 Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Wed, 1 Oct 2014 19:24:54 -0500 Subject: [PATCH 75/90] Disease check: Reuse corprus check from spells.hpp. --- apps/openmw/mwmechanics/disease.hpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index fa97f1541..21dd82054 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -33,18 +33,8 @@ namespace MWMechanics if (actor.getClass().getCreatureStats(actor).getSpells().hasSpell(spell->mId)) continue; - bool hasCorprusEffect = false; - for (std::vector::const_iterator effectIt = spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) - { - if (effectIt->mEffectID == ESM::MagicEffect::Corprus) - { - hasCorprusEffect = true; - break; - } - } - float resist = 0.f; - if (hasCorprusEffect) + if (spells.hasCorprusEffect(spell)) resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Disease) From 3bc91c66e66820a5da0b79614f93090ff94d3623 Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Wed, 1 Oct 2014 19:27:10 -0500 Subject: [PATCH 76/90] Disease Check: Shorten the resistance calculations. --- apps/openmw/mwmechanics/disease.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index 21dd82054..a973c0e35 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -25,6 +25,8 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->getStore().get().find( "fDiseaseXferChance")->getFloat(); + MagicEffects& actorEffects = actor.getClass().getCreatureStats(actor).getMagicEffects(); + Spells& spells = carrier.getClass().getCreatureStats(carrier).getSpells(); for (Spells::TIterator it = spells.begin(); it != spells.end(); ++it) { @@ -35,14 +37,14 @@ namespace MWMechanics float resist = 0.f; if (spells.hasCorprusEffect(spell)) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Disease) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCommonDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCommonDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Blight) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistBlightDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistBlightDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude()); else continue; From a33514fa1db5d18cfa931bfc7fb57db362df53f6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 23:19:23 +0200 Subject: [PATCH 77/90] More shader compatibility fixes --- files/materials/atmosphere.shader | 12 ++++++------ files/materials/clouds.shader | 12 ++++++------ files/materials/moon.shader | 12 ++++++------ files/materials/sun.shader | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/files/materials/atmosphere.shader b/files/materials/atmosphere.shader index c8a8e0220..5040052fc 100644 --- a/files/materials/atmosphere.shader +++ b/files/materials/atmosphere.shader @@ -12,13 +12,13 @@ { float4x4 viewFixed = view; #if !SH_GLSL - viewFixed[0][3] = 0; - viewFixed[1][3] = 0; - viewFixed[2][3] = 0; + viewFixed[0][3] = 0.0; + viewFixed[1][3] = 0.0; + viewFixed[2][3] = 0.0; #else - viewFixed[3][0] = 0; - viewFixed[3][1] = 0; - viewFixed[3][2] = 0; + viewFixed[3][0] = 0.0; + viewFixed[3][1] = 0.0; + viewFixed[3][2] = 0.0; #endif shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shInputPosition)); alphaFade = shInputPosition.z < 150.0 ? 0.0 : 1.0; diff --git a/files/materials/clouds.shader b/files/materials/clouds.shader index 9e9b10256..90c4d0f84 100644 --- a/files/materials/clouds.shader +++ b/files/materials/clouds.shader @@ -14,13 +14,13 @@ float4x4 worldviewFixed = worldview; #if !SH_GLSL - worldviewFixed[0][3] = 0; - worldviewFixed[1][3] = 0; - worldviewFixed[2][3] = 0; + worldviewFixed[0][3] = 0.0; + worldviewFixed[1][3] = 0.0; + worldviewFixed[2][3] = 0.0; #else - worldviewFixed[3][0] = 0; - worldviewFixed[3][1] = 0; - worldviewFixed[3][2] = 0; + worldviewFixed[3][0] = 0.0; + worldviewFixed[3][1] = 0.0; + worldviewFixed[3][2] = 0.0; #endif shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition)); diff --git a/files/materials/moon.shader b/files/materials/moon.shader index a7d183d10..d369a1c68 100644 --- a/files/materials/moon.shader +++ b/files/materials/moon.shader @@ -13,13 +13,13 @@ shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix) { float4x4 viewFixed = view; #if !SH_GLSL - viewFixed[0][3] = 0; - viewFixed[1][3] = 0; - viewFixed[2][3] = 0; + viewFixed[0][3] = 0.0; + viewFixed[1][3] = 0.0; + viewFixed[2][3] = 0.0; #else - viewFixed[3][0] = 0; - viewFixed[3][1] = 0; - viewFixed[3][2] = 0; + viewFixed[3][0] = 0.0; + viewFixed[3][1] = 0.0; + viewFixed[3][2] = 0.0; #endif shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shMatrixMult(world, shInputPosition))); UV = uv0; diff --git a/files/materials/sun.shader b/files/materials/sun.shader index abe4c97f1..fc747b522 100644 --- a/files/materials/sun.shader +++ b/files/materials/sun.shader @@ -13,13 +13,13 @@ shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix) { float4x4 viewFixed = view; #if !SH_GLSL - viewFixed[0][3] = 0; - viewFixed[1][3] = 0; - viewFixed[2][3] = 0; + viewFixed[0][3] = 0.0; + viewFixed[1][3] = 0.0; + viewFixed[2][3] = 0.0; #else - viewFixed[3][0] = 0; - viewFixed[3][1] = 0; - viewFixed[3][2] = 0; + viewFixed[3][0] = 0.0; + viewFixed[3][1] = 0.0; + viewFixed[3][2] = 0.0; #endif shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shMatrixMult(world, shInputPosition))); UV = uv0; From 0bd9f30c6732a83102b5cb31ad51d7b550ead8b9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 23:24:03 +0200 Subject: [PATCH 78/90] Remove comment for old MyGUI version --- apps/openmw/mwgui/race.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index e3bec3789..2bfc4f141 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -41,12 +41,11 @@ namespace MWGui getWidget(mHeadRotate, "HeadRotate"); - // Mouse wheel step is hardcoded to 50 in MyGUI 3.2 ("FIXME"). - // Give other steps the same value to accomodate. mHeadRotate->setScrollRange(1000); mHeadRotate->setScrollPosition(500); mHeadRotate->setScrollViewPage(50); mHeadRotate->setScrollPage(50); + mHeadRotate->setScrollWheelPage(50); mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); // Set up next/previous buttons From d99e416208e22fde052ff683ce28b30da24abb75 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 23:39:17 +0200 Subject: [PATCH 79/90] Remove some unused methods from OEngine::Gui::Layout --- libs/openengine/gui/layout.hpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index 26a3fdab8..cd530a1d9 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -42,6 +42,7 @@ namespace GUI MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' in layout '" << mLayoutName << "' not found."); } + private: void initialise(const std::string & _layout, MyGUI::Widget* _parent = nullptr) { @@ -74,6 +75,7 @@ namespace GUI mListWindowRoot.clear(); } + public: void setCoord(int x, int y, int w, int h) { mMainWidget->setCoord(x,y,w,h); @@ -121,29 +123,6 @@ namespace GUI adjustWindowCaption(); } - void setState(const std::string& widget, const std::string& state) - { - MyGUI::Widget* pt; - getWidget(pt, widget); - pt->_setWidgetState(state); - } - - void setTextColor(const std::string& name, float r, float g, float b) - { - MyGUI::Widget* pt; - getWidget(pt, name); - MyGUI::TextBox *st = dynamic_cast(pt); - if(st != NULL) - st->setTextColour(MyGUI::Colour(b,g,r)); - } - - void setImage(const std::string& name, const std::string& imgName) - { - MyGUI::ImageBox* pt; - getWidget(pt, name); - pt->setImageTexture(imgName); - } - void adjustButtonSize(MyGUI::Button* button) { // adjust size of button to fit its text From 7e10818bdfa5c5f7e0bce710ca771538b42869c3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 00:32:22 +0200 Subject: [PATCH 80/90] Fix uninitialized flags for custom-made spells --- apps/openmw/mwgui/spellcreationdialog.cpp | 4 ++-- apps/openmw/mwmechanics/enchanting.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 1116d6543..e2fac9d6d 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -422,12 +422,12 @@ namespace MWGui y *= 1.5; } - mSpell.mData.mCost = int(y); - ESM::EffectList effectList; effectList.mList = mEffects; mSpell.mEffects = effectList; + mSpell.mData.mCost = int(y); mSpell.mData.mType = ESM::Spell::ST_Spell; + mSpell.mData.mFlags = 0; mMagickaCost->setCaption(boost::lexical_cast(int(y))); diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 63ffbc7e8..c134942b8 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -53,6 +53,9 @@ namespace MWMechanics MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); ESM::Enchantment enchantment; enchantment.mData.mCharge = getGemCharge(); + enchantment.mData.mAutocalc = 0; + enchantment.mData.mType = mCastStyle; + enchantment.mData.mCost = getEnchantPoints(); store.remove(mSoulGemPtr, 1, player); @@ -72,8 +75,6 @@ namespace MWMechanics { enchantment.mData.mCharge=0; } - enchantment.mData.mType = mCastStyle; - enchantment.mData.mCost = getEnchantPoints(); enchantment.mEffects = mEffectList; // Apply the enchantment From afbd2de51154d1ced815b2fed299b7ce683af33a Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 13:54:56 +0200 Subject: [PATCH 81/90] Fix broken alchemy magnitude/duration --- apps/openmw/mwmechanics/alchemy.cpp | 20 ++++++++++++-------- apps/openmw/mwmechanics/alchemy.hpp | 3 +-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 24e7b5aa1..90c180817 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -133,7 +133,7 @@ void MWMechanics::Alchemy::updateEffects() std::set effects (listEffects()); // general alchemy factor - float x = getChance(); + float x = getAlchemyFactor(); x *= mTools[ESM::Apparatus::MortarPestle].get()->mBase->mData.mQuality; x *= MWBase::Environment::get().getWorld()->getStore().get().find ("fPotionStrengthMult")->getFloat(); @@ -306,18 +306,15 @@ void MWMechanics::Alchemy::increaseSkill() mAlchemist.getClass().skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0); } -float MWMechanics::Alchemy::getChance() const +float MWMechanics::Alchemy::getAlchemyFactor() const { const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist); const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist); - if (beginEffects() == endEffects()) - return 0.f; - return (npcStats.getSkill (ESM::Skill::Alchemy).getModified() + - 0.1 * creatureStats.getAttribute (1).getModified() - + 0.1 * creatureStats.getAttribute (7).getModified()); + 0.1 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified() + + 0.1 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified()); } int MWMechanics::Alchemy::countIngredients() const @@ -461,7 +458,14 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na if (listEffects().empty()) return Result_NoEffects; - if (getChance() (RAND_MAX)*100) + if (beginEffects() == endEffects()) + { + // all effects were nullified due to insufficient skill + removeIngredients(); + return Result_RandomFailure; + } + + if (getAlchemyFactor() (RAND_MAX)*100) { removeIngredients(); return Result_RandomFailure; diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index a2429ca8e..e6b8c6650 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -69,8 +69,7 @@ namespace MWMechanics void increaseSkill(); ///< Increase alchemist's skill. - float getChance() const; - ///< Return chance of success. + float getAlchemyFactor() const; int countIngredients() const; From cc63f7f05127e94d8913b2ff38051fd4440e9428 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 14:23:13 +0200 Subject: [PATCH 82/90] Fix broken idle camera --- apps/openmw/mwrender/camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 5a4b51504..1850df904 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -197,7 +197,7 @@ namespace MWRender { // Changing the view will stop all playing animations, so if we are playing // anything important, queue the view change for later - if (!mPreviewMode) + if (isFirstPerson() && !mAnimation->upperBodyReady()) { mVanityToggleQueued = true; return false; From 861cc26aa6f5fe8b393d271caf092ff74119a678 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 14:45:57 +0200 Subject: [PATCH 83/90] Don't sell racial spells (Fixes #1961) --- apps/openmw/mwgui/spellbuyingwindow.cpp | 9 +++++++++ apps/openmw/mwmechanics/autocalcspell.cpp | 2 +- components/esm/spelllist.cpp | 8 ++++++++ components/esm/spelllist.hpp | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index cd378aadf..dd6339b4c 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -100,6 +100,15 @@ namespace MWGui if (spell->mData.mType!=ESM::Spell::ST_Spell) continue; // don't try to sell diseases, curses or powers + if (actor.getClass().isNpc()) + { + const ESM::Race* race = + MWBase::Environment::get().getWorld()->getStore().get().find( + actor.get()->mBase->mRace); + if (race->mPowers.exists(spell->mId)) + continue; + } + if (playerHasSpell(iter->first)) continue; diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 01447c6e4..7b8c43a06 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -72,7 +72,7 @@ namespace MWMechanics if (baseMagicka < iAutoSpellTimesCanCast * spell->mData.mCost) continue; - if (race && std::find(race->mPowers.mList.begin(), race->mPowers.mList.end(), spell->mId) != race->mPowers.mList.end()) + if (race && race->mPowers.exists(spell->mId)) continue; if (!attrSkillCheck(spell, actorSkills, actorAttributes)) diff --git a/components/esm/spelllist.cpp b/components/esm/spelllist.cpp index aeface617..8ec386db4 100644 --- a/components/esm/spelllist.cpp +++ b/components/esm/spelllist.cpp @@ -20,4 +20,12 @@ void SpellList::save(ESMWriter &esm) const } } +bool SpellList::exists(const std::string &spell) const +{ + for (std::vector::const_iterator it = mList.begin(); it != mList.end(); ++it) + if (Misc::StringUtils::ciEqual(*it, spell)) + return true; + return false; +} + } diff --git a/components/esm/spelllist.hpp b/components/esm/spelllist.hpp index 934bdda7a..bcd6ba798 100644 --- a/components/esm/spelllist.hpp +++ b/components/esm/spelllist.hpp @@ -16,6 +16,9 @@ namespace ESM { std::vector mList; + /// Is this spell ID in mList? + bool exists(const std::string& spell) const; + void load(ESMReader &esm); void save(ESMWriter &esm) const; }; From eda296f1e391e3be38e75ad3edbefe879fe1dd6c Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 16:15:56 +0200 Subject: [PATCH 84/90] Remove workaround for Ogre 1.8 (no longer supported) --- components/terrain/quadtreenode.cpp | 34 +---------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index 44974eeb1..57379a334 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -73,38 +73,6 @@ namespace return NULL; } - - // Ogre::AxisAlignedBox::distance is broken in 1.8. - Ogre::Real distance(const Ogre::AxisAlignedBox& box, const Ogre::Vector3& v) - { - - if (box.contains(v)) - return 0; - else - { - Ogre::Vector3 maxDist(0,0,0); - const Ogre::Vector3& minimum = box.getMinimum(); - const Ogre::Vector3& maximum = box.getMaximum(); - - if (v.x < minimum.x) - maxDist.x = minimum.x - v.x; - else if (v.x > maximum.x) - maxDist.x = v.x - maximum.x; - - if (v.y < minimum.y) - maxDist.y = minimum.y - v.y; - else if (v.y > maximum.y) - maxDist.y = v.y - maximum.y; - - if (v.z < minimum.z) - maxDist.z = minimum.z - v.z; - else if (v.z > maximum.z) - maxDist.z = v.z - maximum.z; - - return maxDist.length(); - } - } - // Create a 2D quad void makeQuad(Ogre::SceneManager* sceneMgr, float left, float top, float right, float bottom, Ogre::MaterialPtr material) { @@ -270,7 +238,7 @@ bool QuadTreeNode::update(const Ogre::Vector3 &cameraPos) if (mBounds.isNull()) return true; - float dist = distance(mWorldBounds, cameraPos); + float dist = mWorldBounds.distance(cameraPos); // Make sure our scene node is attached if (!mSceneNode->isInSceneGraph()) From 7d36a202a8919e85bc9eaf497e6ed29f1b480c91 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 16:30:23 +0200 Subject: [PATCH 85/90] Implement cell loading threshold (Fixes #1874) The cell loading threshold (default: 1024 units) prevents exterior cell loading until the player has travelled part-way into the next cell. This gets rid of excessive cell loadings when walking along an exterior cell border. Lower the maximum allowed view distance in options menu to accomodate. Change setting name so that old settings files are upgraded. --- apps/openmw/mwbase/windowmanager.hpp | 2 +- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 26 ++-- apps/openmw/mwgui/mapwindow.hpp | 4 +- apps/openmw/mwgui/windowmanagerimp.cpp | 15 +- apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- apps/openmw/mwrender/localmap.cpp | 9 +- apps/openmw/mwrender/localmap.hpp | 1 - apps/openmw/mwrender/renderingmanager.cpp | 6 +- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 163 ++++++++++++++-------- apps/openmw/mwworld/scene.hpp | 18 ++- apps/openmw/mwworld/worldimp.cpp | 19 ++- apps/openmw/mwworld/worldimp.hpp | 2 +- files/mygui/openmw_console.layout | 3 +- files/mygui/openmw_settings_window.layout | 4 +- files/settings-default.cfg | 8 +- 17 files changed, 167 insertions(+), 119 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index bce3f516e..58fa221e6 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -177,7 +177,7 @@ namespace MWBase virtual void changeCell(MWWorld::CellStore* cell) = 0; ///< change the active cell - virtual void setPlayerPos(const float x, const float y) = 0; + virtual void setPlayerPos(int cellX, int cellY, const float x, const float y) = 0; ///< set player position in map space virtual void setPlayerDir(const float x, const float y) = 0; diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 3f6260c05..73fa92529 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -137,7 +137,7 @@ namespace MWBase virtual MWWorld::LocalScripts& getLocalScripts() = 0; virtual bool hasCellChanged() const = 0; - ///< Has the player moved to a different cell, since the last frame? + ///< Has the set of active cells changed, since the last frame? virtual bool isCellExterior() const = 0; diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 37bc4d1e3..80a3c5ae4 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -159,8 +159,6 @@ namespace MWGui , mLocalMap(NULL) , mPrefix() , mChanged(true) - , mLastPositionX(0.0f) - , mLastPositionY(0.0f) , mLastDirectionX(0.0f) , mLastDirectionY(0.0f) , mCompass(NULL) @@ -425,24 +423,24 @@ namespace MWGui mLocalMap->getParent()->_updateChilds(); } - void LocalMapBase::setPlayerPos(const float x, const float y) + void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny) { updateMagicMarkers(); - if (x == mLastPositionX && y == mLastPositionY) - return; - notifyPlayerUpdate (); - MyGUI::IntSize size = mLocalMap->getCanvasSize(); - MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height); - MyGUI::IntCoord viewsize = mLocalMap->getCoord(); - MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); - mLocalMap->setViewOffset(pos); + MyGUI::IntPoint pos(widgetSize+nx*widgetSize-16, widgetSize+ny*widgetSize-16); + pos.left += (cellX - mCurX) * widgetSize; + pos.top -= (cellY - mCurY) * widgetSize; - mCompass->setPosition(MyGUI::IntPoint(widgetSize+x*widgetSize-16, widgetSize+y*widgetSize-16)); - mLastPositionX = x; - mLastPositionY = y; + if (pos != mCompass->getPosition()) + { + mCompass->setPosition(pos); + MyGUI::IntPoint middle (pos.left+16, pos.top+16); + MyGUI::IntCoord viewsize = mLocalMap->getCoord(); + MyGUI::IntPoint viewOffset(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); + mLocalMap->setViewOffset(viewOffset); + } } void LocalMapBase::setPlayerDir(const float x, const float y) diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index e9c0c1a69..a8aaa8e45 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -75,7 +75,7 @@ namespace MWGui void setCellPrefix(const std::string& prefix); void setActiveCell(const int x, const int y, bool interior=false); void setPlayerDir(const float x, const float y); - void setPlayerPos(const float x, const float y); + void setPlayerPos(int cellX, int cellY, const float nx, const float ny); void onFrame(float dt); @@ -129,8 +129,6 @@ namespace MWGui float mMarkerUpdateTimer; - float mLastPositionX; - float mLastPositionY; float mLastDirectionX; float mLastDirectionY; }; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 70f4b5a2f..16295d3a5 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -880,9 +880,6 @@ namespace MWGui mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->getCell()->getGridX (), cell->getCell()->getGridY ()); mMap->cellExplored (cell->getCell()->getGridX(), cell->getCell()->getGridY()); - - mMap->setCellPrefix("Cell"); - mHud->setCellPrefix("Cell"); } else { @@ -900,14 +897,20 @@ namespace MWGui void WindowManager::setActiveMap(int x, int y, bool interior) { + if (!interior) + { + mMap->setCellPrefix("Cell"); + mHud->setCellPrefix("Cell"); + } + mMap->setActiveCell(x,y, interior); mHud->setActiveCell(x,y, interior); } - void WindowManager::setPlayerPos(const float x, const float y) + void WindowManager::setPlayerPos(int cellX, int cellY, const float x, const float y) { - mMap->setPlayerPos(x,y); - mHud->setPlayerPos(x,y); + mMap->setPlayerPos(cellX, cellY, x, y); + mHud->setPlayerPos(cellX, cellY, x, y); } void WindowManager::setPlayerDir(const float x, const float y) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 29d40c2e7..1dae77641 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -183,7 +183,7 @@ namespace MWGui virtual void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty virtual void changeCell(MWWorld::CellStore* cell); ///< change the active cell - virtual void setPlayerPos(const float x, const float y); ///< set player position in map space + virtual void setPlayerPos(int cellX, int cellY, const float x, const float y); ///< set player position in map space virtual void setPlayerDir(const float x, const float y); ///< set player view direction in map space virtual void setFocusObject(const MWWorld::Ptr& focus); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 85f73ab7e..f4388eec5 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -25,7 +25,7 @@ using namespace MWRender; using namespace Ogre; LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) : - mInterior(false), mCellX(0), mCellY(0) + mInterior(false) { mRendering = rend; mRenderingManager = rendering; @@ -522,10 +522,9 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni { x = std::ceil(pos.x / sSize)-1; y = std::ceil(pos.y / sSize)-1; - mCellX = x; - mCellY = y; } - MWBase::Environment::get().getWindowManager()->setActiveMap(x,y,mInterior); + else + MWBase::Environment::get().getWindowManager()->setActiveMap(x,y,mInterior); // convert from world coordinates to texture UV coordinates std::string texBaseName; @@ -540,7 +539,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni texBaseName = mInteriorName + "_"; } - MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v); + MWBase::Environment::get().getWindowManager()->setPlayerPos(x, y, u, v); MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, playerdirection.y); // explore radius (squared) diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index b531c3e29..4c60cbb11 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -134,7 +134,6 @@ namespace MWRender Ogre::RenderTarget* mRenderTarget; bool mInterior; - int mCellX, mCellY; Ogre::AxisAlignedBox mBounds; std::string mInteriorName; }; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index f476a7807..6ed11b71f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -499,7 +499,7 @@ bool RenderingManager::toggleRenderMode(int mode) } } -void RenderingManager::configureFog(MWWorld::CellStore &mCell) +void RenderingManager::configureFog(const MWWorld::CellStore &mCell) { Ogre::ColourValue color; color.setAsABGR (mCell.getCell()->mAmbi.mFog); @@ -510,7 +510,7 @@ void RenderingManager::configureFog(MWWorld::CellStore &mCell) void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour) { mFogColour = colour; - float max = Settings::Manager::getFloat("max viewing distance", "Viewing distance"); + float max = Settings::Manager::getFloat("viewing distance", "Viewing distance"); if (density == 0) { @@ -742,7 +742,7 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec { setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); } - else if (it->second == "max viewing distance" && it->first == "Viewing distance") + else if (it->second == "viewing distance" && it->first == "Viewing distance") { if (!MWBase::Environment::get().getWorld()->isCellExterior() && !MWBase::Environment::get().getWorld()->isCellQuasiExterior() && MWBase::Environment::get().getWorld()->getPlayerPtr().mCell) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index fa48deafa..2da084074 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -183,7 +183,7 @@ public: ///< request the local map for a cell /// configure fog according to cell - void configureFog(MWWorld::CellStore &mCell); + void configureFog(const MWWorld::CellStore &mCell); /// configure fog manually void configureFog(const float density, const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index a316f0bb2..c98485dc9 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -5,7 +5,7 @@ #include #include "../mwbase/environment.hpp" -#include "../mwbase/world.hpp" /// FIXME +#include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/windowmanager.hpp" @@ -117,6 +117,28 @@ namespace MWWorld } } + void Scene::getGridCenter(int &cellX, int &cellY) + { + int maxX = std::numeric_limits().min(); + int maxY = std::numeric_limits().min(); + int minX = std::numeric_limits().max(); + int minY = std::numeric_limits().max(); + CellStoreCollection::iterator iter = mActiveCells.begin(); + while (iter!=mActiveCells.end()) + { + assert ((*iter)->getCell()->isExterior()); + int x = (*iter)->getCell()->getGridX(); + int y = (*iter)->getCell()->getGridY(); + maxX = std::max(x, maxX); + maxY = std::max(y, maxY); + minX = std::min(x, minX); + minY = std::min(y, minY); + ++iter; + } + cellX = (minX + maxX) / 2; + cellY = (minY + maxY) / 2; + } + void Scene::update (float duration, bool paused) { if (mNeedMapUpdate) @@ -126,6 +148,13 @@ namespace MWWorld for (CellStoreCollection::iterator active = mActiveCells.begin(); active!=mActiveCells.end(); ++active) mRendering.requestMap(*active); mNeedMapUpdate = false; + + if (mCurrentCell->isExterior()) + { + int cellX, cellY; + getGridCenter(cellX, cellY); + MWBase::Environment::get().getWindowManager()->setActiveMap(cellX,cellY,false); + } } mRendering.update (duration, paused); @@ -213,41 +242,6 @@ namespace MWWorld MWBase::Environment::get().getWorld()->getLocalScripts().addCell (cell); } - void Scene::playerCellChange(CellStore *cell, const ESM::Position& pos, bool adjustPlayerPos) - { - MWBase::World *world = MWBase::Environment::get().getWorld(); - MWWorld::Ptr old = world->getPlayerPtr(); - world->getPlayer().setCell(cell); - - MWWorld::Ptr player = world->getPlayerPtr(); - mRendering.updatePlayerPtr(player); - - if (adjustPlayerPos) { - world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]); - - float x = Ogre::Radian(pos.rot[0]).valueDegrees(); - float y = Ogre::Radian(pos.rot[1]).valueDegrees(); - float z = Ogre::Radian(pos.rot[2]).valueDegrees(); - world->rotateObject(player, x, y, z); - - player.getClass().adjustPosition(player, true); - } - - MWBase::MechanicsManager *mechMgr = - MWBase::Environment::get().getMechanicsManager(); - - mechMgr->updateCell(old, player); - mechMgr->watchActor(player); - - mRendering.updateTerrain(); - - // Delay the map update until scripts have been given a chance to run. - // If we don't do this, objects that should be disabled will still appear on the map. - mNeedMapUpdate = true; - - MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell); - } - void Scene::changeToVoid() { CellStoreCollection::iterator active = mActiveCells.begin(); @@ -257,7 +251,28 @@ namespace MWWorld mCurrentCell = NULL; } - void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) + void Scene::playerMoved(const Ogre::Vector3 &pos) + { + if (!mCurrentCell || !mCurrentCell->isExterior()) + return; + + // figure out the center of the current cell grid (*not* necessarily mCurrentCell, which is the cell the player is in) + int cellX, cellY; + getGridCenter(cellX, cellY); + float centerX, centerY; + MWBase::Environment::get().getWorld()->indexToPosition(cellX, cellY, centerX, centerY, true); + const float maxDistance = 8192/2 + 1024; // 1/2 cell size + threshold + float distance = std::max(std::abs(centerX-pos.x), std::abs(centerY-pos.y)); + if (distance > maxDistance) + { + int newX, newY; + MWBase::Environment::get().getWorld()->positionToIndex(pos.x, pos.y, newX, newY); + changeCellGrid(newX, newY); + mRendering.updateTerrain(); + } + } + + void Scene::changeCellGrid (int X, int Y) { Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); Loading::ScopedLoad load(loadingListener); @@ -286,6 +301,7 @@ namespace MWWorld int refsToLoad = 0; // get the number of refs to load for (int x=X-1; x<=X+1; ++x) + { for (int y=Y-1; y<=Y+1; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); @@ -304,11 +320,13 @@ namespace MWWorld if (iter==mActiveCells.end()) refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count(); } + } loadingListener->setProgressRange(refsToLoad); // Load cells for (int x=X-1; x<=X+1; ++x) + { for (int y=Y-1; y<=Y+1; ++y) { CellStoreCollection::iterator iter = mActiveCells.begin(); @@ -331,32 +349,47 @@ namespace MWWorld loadCell (cell, loadingListener); } } + } - // find current cell - CellStoreCollection::iterator iter = mActiveCells.begin(); + CellStore* current = MWBase::Environment::get().getWorld()->getExterior(X,Y); + MWBase::Environment::get().getWindowManager()->changeCell(current); - while (iter!=mActiveCells.end()) - { - assert ((*iter)->getCell()->isExterior()); + mCellChanged = true; - if (X==(*iter)->getCell()->getGridX() && - Y==(*iter)->getCell()->getGridY()) - break; + // Delay the map update until scripts have been given a chance to run. + // If we don't do this, objects that should be disabled will still appear on the map. + mNeedMapUpdate = true; + } - ++iter; - } + void Scene::changePlayerCell(CellStore *cell, const ESM::Position &pos, bool adjustPlayerPos) + { + mCurrentCell = cell; - assert (iter!=mActiveCells.end()); + MWBase::World *world = MWBase::Environment::get().getWorld(); + MWWorld::Ptr old = world->getPlayerPtr(); + world->getPlayer().setCell(cell); - mCurrentCell = *iter; + MWWorld::Ptr player = world->getPlayerPtr(); + mRendering.updatePlayerPtr(player); - // adjust player - playerCellChange (mCurrentCell, position, adjustPlayerPos); + if (adjustPlayerPos) { + world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]); - // Sky system - MWBase::Environment::get().getWorld()->adjustSky(); + float x = Ogre::Radian(pos.rot[0]).valueDegrees(); + float y = Ogre::Radian(pos.rot[1]).valueDegrees(); + float z = Ogre::Radian(pos.rot[2]).valueDegrees(); + world->rotateObject(player, x, y, z); - mCellChanged = true; + player.getClass().adjustPosition(player, true); + } + + MWBase::MechanicsManager *mechMgr = + MWBase::Environment::get().getMechanicsManager(); + + mechMgr->updateCell(old, player); + mechMgr->watchActor(player); + + MWBase::Environment::get().getWorld()->adjustSky(); } //We need the ogre renderer and a scene node. @@ -427,33 +460,39 @@ namespace MWWorld // Load cell. std::cout << "cellName: " << cell->getCell()->mName << std::endl; - //Loading Interior loading text - loadCell (cell, loadingListener); - mCurrentCell = cell; + changePlayerCell(cell, position, true); // adjust fog mRendering.configureFog(*mCurrentCell); - // adjust player - playerCellChange (mCurrentCell, position); - // Sky system MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5); + + MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell); + + // Delay the map update until scripts have been given a chance to run. + // If we don't do this, objects that should be disabled will still appear on the map. + mNeedMapUpdate = true; } - void Scene::changeToExteriorCell (const ESM::Position& position) + void Scene::changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos) { int x = 0; int y = 0; MWBase::Environment::get().getWorld()->positionToIndex (position.pos[0], position.pos[1], x, y); - changeCell (x, y, position, true); + changeCellGrid(x, y); + + CellStore* current = MWBase::Environment::get().getWorld()->getExterior(x, y); + changePlayerCell(current, position, adjustPlayerPos); + + mRendering.updateTerrain(); } CellStore* Scene::getCurrentCell () diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index e0eeee187..a9d80bf17 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -60,11 +60,13 @@ namespace MWWorld bool mNeedMapUpdate; - void playerCellChange (CellStore *cell, const ESM::Position& position, - bool adjustPlayerPos = true); - void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener); + // Load and unload cells as necessary to create a cell grid with "X" and "Y" in the center + void changeCellGrid (int X, int Y); + + void getGridCenter(int& cellX, int& cellY); + public: Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics); @@ -75,19 +77,21 @@ namespace MWWorld void loadCell (CellStore *cell, Loading::Listener* loadingListener); - void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos); + void playerMoved (const Ogre::Vector3& pos); + + void changePlayerCell (CellStore* newCell, const ESM::Position& position, bool adjustPlayerPos); - CellStore* getCurrentCell (); + CellStore *getCurrentCell(); const CellStoreCollection& getActiveCells () const; bool hasCellChanged() const; - ///< Has the player moved to a different cell, since the last frame? + ///< Has the set of active cells changed, since the last frame? void changeToInteriorCell (const std::string& cellName, const ESM::Position& position); ///< Move to interior cell. - void changeToExteriorCell (const ESM::Position& position); + void changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos); ///< Move to exterior cell. void changeToVoid(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 91fcf2b95..cf8c11574 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -241,7 +241,7 @@ namespace MWWorld pos.rot[0] = 0; pos.rot[1] = 0; pos.rot[2] = 0; - mWorldScene->changeToExteriorCell(pos); + mWorldScene->changeToExteriorCell(pos, true); } } @@ -920,7 +920,7 @@ namespace MWWorld mRendering->notifyWorldSpaceChanged(); } removeContainerScripts(getPlayerPtr()); - mWorldScene->changeToExteriorCell(position); + mWorldScene->changeToExteriorCell(position, true); addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell()); } @@ -1057,9 +1057,10 @@ namespace MWWorld changeToInteriorCell(Misc::StringUtils::lowerCase(newCell->getCell()->mName), pos); else { - int cellX = newCell->getCell()->getGridX(); - int cellY = newCell->getCell()->getGridY(); - mWorldScene->changeCell(cellX, cellY, pos, false); + if (mWorldScene->isCellActive(*newCell)) + mWorldScene->changePlayerCell(newCell, pos, false); + else + mWorldScene->changeToExteriorCell(pos, false); } addContainerScripts (getPlayerPtr(), newCell); } @@ -1120,6 +1121,10 @@ namespace MWWorld mRendering->moveObject(ptr, vec); mPhysics->moveObject (ptr); } + if (isPlayer) + { + mWorldScene->playerMoved (vec); + } } bool World::moveObjectImp(const Ptr& ptr, float x, float y, float z) @@ -1565,7 +1570,7 @@ namespace MWWorld bool World::isCellExterior() const { - CellStore *currentCell = mWorldScene->getCurrentCell(); + const CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { return currentCell->getCell()->isExterior(); @@ -1575,7 +1580,7 @@ namespace MWWorld bool World::isCellQuasiExterior() const { - CellStore *currentCell = mWorldScene->getCurrentCell(); + const CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { if (!(currentCell->getCell()->mData.mFlags & ESM::Cell::QuasiEx)) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 8fd27dec9..1a25edbe5 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -198,7 +198,7 @@ namespace MWWorld virtual LocalScripts& getLocalScripts(); virtual bool hasCellChanged() const; - ///< Has the player moved to a different cell, since the last frame? + ///< Has the set of active cells changed, since the last frame? virtual bool isCellExterior() const; diff --git a/files/mygui/openmw_console.layout b/files/mygui/openmw_console.layout index c88c1955d..854568f9b 100644 --- a/files/mygui/openmw_console.layout +++ b/files/mygui/openmw_console.layout @@ -2,8 +2,7 @@ - - + diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 5945c68d7..fa6485688 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -346,10 +346,10 @@ - + - + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 67fd5ee8c..06d999189 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -122,8 +122,12 @@ small object size = 250 # Rendering distance for small objects small object distance = 3500 -# Max viewing distance at clear weather conditions -max viewing distance = 5600 +# Viewing distance at normal weather conditions +# The maximum distance with no pop-in will be: (see RenderingManager::configureFog) +# viewing distance / minimum weather fog depth (.69) * view frustum factor <= cell size (8192) - loading threshold (1024) +# view frustum factor takes into account that the view frustum end is a plane, so at the edges of the screen you can see further than you should be able to. +# exact factor would depend on FOV +viewing distance = 4600 # Distance at which fog starts (proportional to viewing distance) fog start factor = 0.5 From db086a4d89fa8d8db9de7e688ebc52317218992e Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 17:21:46 +0200 Subject: [PATCH 86/90] Remove unused PairCachingGhostObject --- libs/openengine/bullet/physic.cpp | 6 ------ libs/openengine/bullet/physic.hpp | 16 ---------------- 2 files changed, 22 deletions(-) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 97418fae0..b4d5e49a5 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -226,11 +226,6 @@ namespace Physic // The actual physics solver solver = new btSequentialImpulseConstraintSolver; - //btOverlappingPairCache* pairCache = new btSortedOverlappingPairCache(); - pairCache = new btSortedOverlappingPairCache(); - - //pairCache->setInternalGhostPairCallback( new btGhostPairCallback() ); - broadphase = new btDbvtBroadphase(); // The world. @@ -341,7 +336,6 @@ namespace Physic delete collisionConfiguration; delete dispatcher; delete broadphase; - delete pairCache; delete mShapeLoader; delete BulletShapeManager::getSingletonPtr(); diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index e330a7621..0d280c4fe 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -49,21 +49,6 @@ namespace Physic CollisionType_Raycasting = 1<<3 //Still used? }; - /** - *This is just used to be able to name objects. - */ - class PairCachingGhostObject : public btPairCachingGhostObject - { - public: - PairCachingGhostObject(std::string name) - :btPairCachingGhostObject(),mName(name) - { - } - virtual ~PairCachingGhostObject(){} - - std::string mName; - }; - /** *This class is just an extension of normal btRigidBody in order to add extra info. *When bullet give back a btRigidBody, you can just do a static_cast to RigidBody, @@ -317,7 +302,6 @@ namespace Physic btCollisionObject *object); //Bullet Stuff - btOverlappingPairCache* pairCache; btBroadphaseInterface* broadphase; btDefaultCollisionConfiguration* collisionConfiguration; btSequentialImpulseConstraintSolver* solver; From 58672c6bb535223766042aab0c922a316c02ada9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 18:12:49 +0200 Subject: [PATCH 87/90] Fix for crash in main menu when reflections are enabled --- apps/openmw/mwrender/refraction.cpp | 3 ++- apps/openmw/mwrender/water.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/refraction.cpp b/apps/openmw/mwrender/refraction.cpp index 7d728b721..164380866 100644 --- a/apps/openmw/mwrender/refraction.cpp +++ b/apps/openmw/mwrender/refraction.cpp @@ -50,7 +50,8 @@ namespace MWRender void Refraction::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { - mParentCamera->getParentSceneNode ()->needUpdate (); + if (mParentCamera->isAttached()) + mParentCamera->getParentSceneNode ()->needUpdate (); mCamera->setOrientation(mParentCamera->getDerivedOrientation()); mCamera->setPosition(mParentCamera->getDerivedPosition()); mCamera->setNearClipDistance(mParentCamera->getNearClipDistance()); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 752da30df..fd790b363 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -74,7 +74,8 @@ CubeReflection::~CubeReflection () void CubeReflection::update () { - mParentCamera->getParentSceneNode ()->needUpdate (); + if (mParentCamera->isAttached()) + mParentCamera->getParentSceneNode ()->needUpdate (); mCamera->setPosition(mParentCamera->getDerivedPosition()); } @@ -133,7 +134,8 @@ void PlaneReflection::renderQueueEnded (Ogre::uint8 queueGroupId, const Ogre::St void PlaneReflection::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { - mParentCamera->getParentSceneNode ()->needUpdate (); + if (mParentCamera->isAttached()) + mParentCamera->getParentSceneNode ()->needUpdate (); mCamera->setOrientation(mParentCamera->getDerivedOrientation()); mCamera->setPosition(mParentCamera->getDerivedPosition()); mCamera->setNearClipDistance(mParentCamera->getNearClipDistance()); From 083bcaf483534c43830d995b11c2128573a7b1a2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 19:26:37 +0200 Subject: [PATCH 88/90] Fix journal quest logs not being marked finished when there are multiple quest IDs in the log --- apps/openmw/mwgui/journalviewmodel.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index 45a1858d2..0ab56200d 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -201,12 +201,23 @@ struct JournalViewModelImpl : JournalViewModel std::set visitedQuests; + // Note that for purposes of the journal GUI, quests are identified by the name, not the ID, so several + // different quest IDs can end up in the same quest log. A quest log should be considered finished + // when any quest ID in that log is finished. for (MWBase::Journal::TQuestIter i = journal->questBegin (); i != journal->questEnd (); ++i) { - if (active_only && i->second.isFinished ()) + const MWDialogue::Quest& quest = i->second; + + bool isFinished = false; + for (MWBase::Journal::TQuestIter j = journal->questBegin (); j != journal->questEnd (); ++j) + { + if (quest.getName() == j->second.getName() && j->second.isFinished()) + isFinished = true; + } + + if (active_only && isFinished) continue; - const MWDialogue::Quest& quest = i->second; // Unfortunately Morrowind.esm has no quest names, since the quest book was added with tribunal. // Note that even with Tribunal, some quests still don't have quest names. I'm assuming those are not supposed // to appear in the quest book. From 115841d31dab16380b3114e0c97bfc629299535e Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 3 Oct 2014 05:59:24 +1000 Subject: [PATCH 89/90] Do not save window size on exit. --- apps/opencs/view/doc/view.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 8edeeaec7..73beee60c 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -32,25 +32,6 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) event->ignore(); else { - // save window size first - int width = 0; - int height = 0; - -#ifdef Q_WS_WIN - width = frameGeometry().width(); - height = frameGeometry().height(); -#else - width = geometry().width(); - height = geometry().height(); -#endif - CSMSettings::UserSettings::instance().setDefinitions( - "Window Size/Width", - QStringList(QString::number(width))); - CSMSettings::UserSettings::instance().setDefinitions( - "Window Size/Height", - QStringList(QString::number(height))); - CSMSettings::UserSettings::instance().saveDefinitions(); - // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); } From 81a9dc0655baf830b52447ed83a42b8c6d86e999 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 2 Oct 2014 22:44:06 +0200 Subject: [PATCH 90/90] Hotfix for not being able to scroll the world map --- apps/openmw/mwgui/mapwindow.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 80a3c5ae4..0262c4d0e 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -425,16 +425,14 @@ namespace MWGui void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny) { - updateMagicMarkers(); - - notifyPlayerUpdate (); - MyGUI::IntPoint pos(widgetSize+nx*widgetSize-16, widgetSize+ny*widgetSize-16); pos.left += (cellX - mCurX) * widgetSize; pos.top -= (cellY - mCurY) * widgetSize; if (pos != mCompass->getPosition()) { + notifyPlayerUpdate (); + mCompass->setPosition(pos); MyGUI::IntPoint middle (pos.left+16, pos.top+16); MyGUI::IntCoord viewsize = mLocalMap->getCoord();