2012-05-22 21:40:42 +02:00
|
|
|
#include "settingswindow.hpp"
|
|
|
|
|
2022-01-25 21:53:00 +01:00
|
|
|
#include <regex>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <numeric>
|
|
|
|
#include <array>
|
|
|
|
|
2022-07-25 08:54:05 +04:00
|
|
|
#include <unicode/locid.h>
|
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_ScrollBar.h>
|
|
|
|
#include <MyGUI_Window.h>
|
|
|
|
#include <MyGUI_ComboBox.h>
|
|
|
|
#include <MyGUI_ScrollView.h>
|
|
|
|
#include <MyGUI_Gui.h>
|
2015-06-04 23:09:40 +03:00
|
|
|
#include <MyGUI_TabControl.h>
|
2022-07-04 21:45:44 +04:00
|
|
|
#include <MyGUI_LanguageManager.h>
|
2012-05-23 05:28:25 +02:00
|
|
|
|
2013-07-29 13:34:56 +02:00
|
|
|
#include <SDL_video.h>
|
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2022-08-03 00:00:54 +02:00
|
|
|
#include <components/misc/strings/algorithm.hpp>
|
|
|
|
#include <components/misc/strings/format.hpp>
|
2019-04-29 12:40:07 +04:00
|
|
|
#include <components/misc/constants.hpp>
|
2022-07-25 08:54:05 +04:00
|
|
|
#include <components/misc/pathhelpers.hpp>
|
2014-12-06 16:50:09 +01:00
|
|
|
#include <components/widgets/sharedstatebutton.hpp>
|
2015-01-31 23:27:34 +01:00
|
|
|
#include <components/settings/settings.hpp>
|
2021-04-09 17:41:33 -07:00
|
|
|
#include <components/resource/resourcesystem.hpp>
|
|
|
|
#include <components/resource/scenemanager.hpp>
|
2021-04-03 22:25:13 -07:00
|
|
|
#include <components/sceneutil/lightmanager.hpp>
|
2022-01-25 21:53:00 +01:00
|
|
|
#include <components/lua_ui/scriptsettings.hpp>
|
2022-07-25 08:54:05 +04:00
|
|
|
#include <components/vfs/manager.hpp>
|
2014-12-06 16:50:09 +01:00
|
|
|
|
2012-05-23 01:32:36 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-08-09 14:33:21 +02:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2012-08-11 17:53:39 +02:00
|
|
|
#include "../mwbase/inputmanager.hpp"
|
2018-09-21 16:34:23 +04:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
|
2012-05-23 05:28:25 +02:00
|
|
|
#include "confirmationdialog.hpp"
|
2022-08-24 22:16:03 +02:00
|
|
|
#include "ustring.hpp"
|
2012-05-22 21:40:42 +02:00
|
|
|
|
2012-05-24 11:50:48 +02:00
|
|
|
namespace
|
|
|
|
{
|
2015-12-13 11:24:23 -08:00
|
|
|
std::string textureMipmappingToStr(const std::string& val)
|
|
|
|
{
|
2022-07-04 21:45:44 +04:00
|
|
|
if (val == "linear") return "#{SettingsMenu:TextureFilteringTrilinear}";
|
|
|
|
if (val == "nearest") return "#{SettingsMenu:TextureFilteringBilinear}";
|
|
|
|
if (val == "none") return "#{SettingsMenu:TextureFilteringDisabled}";
|
2018-08-14 23:05:43 +04:00
|
|
|
|
2022-07-04 21:45:44 +04:00
|
|
|
Log(Debug::Warning) << "Warning: Invalid texture mipmap option: "<< val;
|
|
|
|
return "#{SettingsMenu:TextureFilteringOther}";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string lightingMethodToStr(SceneUtil::LightingMethod method)
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
switch (method)
|
|
|
|
{
|
|
|
|
case SceneUtil::LightingMethod::FFP:
|
|
|
|
result = "#{SettingsMenu:LightingMethodLegacy}";
|
|
|
|
break;
|
|
|
|
case SceneUtil::LightingMethod::PerObjectUniform:
|
|
|
|
result = "#{SettingsMenu:LightingMethodShadersCompatibility}";
|
|
|
|
break;
|
|
|
|
case SceneUtil::LightingMethod::SingleUBO:
|
|
|
|
default:
|
|
|
|
result = "#{SettingsMenu:LightingMethodShaders}";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MyGUI::LanguageManager::getInstance().replaceTags(result);
|
2012-05-29 04:54:54 +02:00
|
|
|
}
|
2012-06-23 12:25:28 +02:00
|
|
|
|
|
|
|
void parseResolution (int &x, int &y, const std::string& str)
|
|
|
|
{
|
|
|
|
std::vector<std::string> split;
|
2020-01-09 15:57:05 +04:00
|
|
|
Misc::StringUtils::split (str, split, "@(x");
|
2012-06-23 12:25:28 +02:00
|
|
|
assert (split.size() >= 2);
|
2020-01-09 15:57:05 +04:00
|
|
|
Misc::StringUtils::trim(split[0]);
|
|
|
|
Misc::StringUtils::trim(split[1]);
|
2015-01-10 03:01:01 +01:00
|
|
|
x = MyGUI::utility::parseInt (split[0]);
|
|
|
|
y = MyGUI::utility::parseInt (split[1]);
|
2012-06-23 12:25:28 +02:00
|
|
|
}
|
2012-06-26 15:41:13 +02:00
|
|
|
|
|
|
|
bool sortResolutions (std::pair<int, int> left, std::pair<int, int> right)
|
|
|
|
{
|
|
|
|
if (left.first == right.first)
|
|
|
|
return left.second > right.second;
|
|
|
|
return left.first > right.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getAspect (int x, int y)
|
|
|
|
{
|
2020-10-09 06:50:17 +02:00
|
|
|
int gcd = std::gcd (x, y);
|
2021-04-10 09:52:46 +04:00
|
|
|
if (gcd == 0)
|
|
|
|
return std::string();
|
|
|
|
|
2012-06-26 15:41:13 +02:00
|
|
|
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 "16 : 10";
|
2015-01-10 03:01:01 +01:00
|
|
|
return MyGUI::utility::toString(xaspect) + " : " + MyGUI::utility::toString(yaspect);
|
2012-06-26 15:41:13 +02:00
|
|
|
}
|
2012-07-11 03:19:51 +02:00
|
|
|
|
2014-03-22 19:02:14 +01:00
|
|
|
const char* checkButtonType = "CheckButton";
|
|
|
|
const char* sliderType = "Slider";
|
|
|
|
|
|
|
|
std::string getSettingType(MyGUI::Widget* widget)
|
|
|
|
{
|
|
|
|
return widget->getUserString("SettingType");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getSettingName(MyGUI::Widget* widget)
|
|
|
|
{
|
|
|
|
return widget->getUserString("SettingName");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getSettingCategory(MyGUI::Widget* widget)
|
|
|
|
{
|
|
|
|
return widget->getUserString("SettingCategory");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getSettingValueType(MyGUI::Widget* widget)
|
|
|
|
{
|
|
|
|
return widget->getUserString("SettingValueType");
|
|
|
|
}
|
|
|
|
|
|
|
|
void getSettingMinMax(MyGUI::Widget* widget, float& min, float& max)
|
|
|
|
{
|
|
|
|
const char* settingMin = "SettingMin";
|
|
|
|
const char* settingMax = "SettingMax";
|
|
|
|
min = 0.f;
|
|
|
|
max = 1.f;
|
|
|
|
if (!widget->getUserString(settingMin).empty())
|
2015-01-10 03:01:01 +01:00
|
|
|
min = MyGUI::utility::parseFloat(widget->getUserString(settingMin));
|
2014-03-22 19:02:14 +01:00
|
|
|
if (!widget->getUserString(settingMax).empty())
|
2015-01-10 03:01:01 +01:00
|
|
|
max = MyGUI::utility::parseFloat(widget->getUserString(settingMax));
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
2021-04-09 17:41:33 -07:00
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
void updateMaxLightsComboBox(MyGUI::ComboBox* box)
|
|
|
|
{
|
|
|
|
constexpr int min = 8;
|
|
|
|
constexpr int max = 32;
|
|
|
|
constexpr int increment = 8;
|
|
|
|
int maxLights = Settings::Manager::getInt("max lights", "Shaders");
|
|
|
|
// show increments of 8 in dropdown
|
|
|
|
if (maxLights >= min && maxLights <= max && !(maxLights % increment))
|
|
|
|
box->setIndexSelected((maxLights / increment)-1);
|
|
|
|
else
|
|
|
|
box->setIndexSelected(MyGUI::ITEM_NONE);
|
2021-04-09 17:41:33 -07:00
|
|
|
}
|
2012-05-24 11:50:48 +02:00
|
|
|
}
|
|
|
|
|
2012-05-22 21:40:42 +02:00
|
|
|
namespace MWGui
|
|
|
|
{
|
2021-04-03 22:25:13 -07:00
|
|
|
void SettingsWindow::configureWidgets(MyGUI::Widget* widget, bool init)
|
2014-03-22 19:02:14 +01:00
|
|
|
{
|
|
|
|
MyGUI::EnumeratorWidgetPtr widgets = widget->getEnumerator();
|
|
|
|
while (widgets.next())
|
|
|
|
{
|
|
|
|
MyGUI::Widget* current = widgets.current();
|
|
|
|
|
|
|
|
std::string type = getSettingType(current);
|
|
|
|
if (type == checkButtonType)
|
|
|
|
{
|
|
|
|
std::string initialValue = Settings::Manager::getBool(getSettingName(current),
|
|
|
|
getSettingCategory(current))
|
|
|
|
? "#{sOn}" : "#{sOff}";
|
|
|
|
current->castType<MyGUI::Button>()->setCaptionWithReplacing(initialValue);
|
2021-04-03 22:25:13 -07:00
|
|
|
if (init)
|
|
|
|
current->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
|
|
|
if (type == sliderType)
|
|
|
|
{
|
|
|
|
MyGUI::ScrollBar* scroll = current->castType<MyGUI::ScrollBar>();
|
2016-01-05 22:37:36 +01:00
|
|
|
std::string valueStr;
|
2019-03-17 06:37:20 +03:00
|
|
|
std::string valueType = getSettingValueType(current);
|
2019-04-29 12:40:07 +04:00
|
|
|
if (valueType == "Float" || valueType == "Integer" || valueType == "Cell")
|
2014-03-22 19:02:14 +01:00
|
|
|
{
|
|
|
|
// TODO: ScrollBar isn't meant for this. should probably use a dedicated FloatSlider widget
|
|
|
|
float min,max;
|
|
|
|
getSettingMinMax(scroll, min, max);
|
|
|
|
float value = Settings::Manager::getFloat(getSettingName(current), getSettingCategory(current));
|
2019-04-29 12:40:07 +04:00
|
|
|
|
|
|
|
if (valueType == "Cell")
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::fixed << std::setprecision(2) << value/Constants::CellSizeInUnits;
|
|
|
|
valueStr = ss.str();
|
|
|
|
}
|
2021-04-03 22:25:13 -07:00
|
|
|
else if (valueType == "Float")
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::fixed << std::setprecision(2) << value;
|
|
|
|
valueStr = ss.str();
|
|
|
|
}
|
2019-04-29 12:40:07 +04:00
|
|
|
else
|
|
|
|
valueStr = MyGUI::utility::toString(int(value));
|
|
|
|
|
2021-11-06 07:30:28 +03:00
|
|
|
value = std::clamp(value, min, max);
|
2014-03-22 19:02:14 +01:00
|
|
|
value = (value-min)/(max-min);
|
|
|
|
|
2015-03-08 13:22:56 +13:00
|
|
|
scroll->setScrollPosition(static_cast<size_t>(value * (scroll->getScrollRange() - 1)));
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-08 13:07:29 +13:00
|
|
|
int value = Settings::Manager::getInt(getSettingName(current), getSettingCategory(current));
|
2016-01-05 22:37:36 +01:00
|
|
|
valueStr = MyGUI::utility::toString(value);
|
2014-03-22 19:02:14 +01:00
|
|
|
scroll->setScrollPosition(value);
|
|
|
|
}
|
2021-04-03 22:25:13 -07:00
|
|
|
if (init)
|
|
|
|
scroll->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
2019-04-29 12:40:07 +04:00
|
|
|
if (scroll->getVisible())
|
|
|
|
updateSliderLabel(scroll, valueStr);
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
|
|
|
|
2021-04-03 22:25:13 -07:00
|
|
|
configureWidgets(current, init);
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-05 22:37:36 +01:00
|
|
|
void SettingsWindow::updateSliderLabel(MyGUI::ScrollBar *scroller, const std::string& value)
|
|
|
|
{
|
|
|
|
std::string labelWidgetName = scroller->getUserString("SettingLabelWidget");
|
|
|
|
if (!labelWidgetName.empty())
|
|
|
|
{
|
|
|
|
MyGUI::TextBox* textBox;
|
|
|
|
getWidget(textBox, labelWidgetName);
|
|
|
|
std::string labelCaption = scroller->getUserString("SettingLabelCaption");
|
2019-05-19 12:33:57 +04:00
|
|
|
labelCaption = Misc::StringUtils::format(labelCaption, value);
|
2016-01-05 22:37:36 +01:00
|
|
|
textBox->setCaptionWithReplacing(labelCaption);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-28 21:35:05 +01:00
|
|
|
SettingsWindow::SettingsWindow() : WindowBase("openmw_settings_window.layout")
|
|
|
|
, mKeyboardMode(true)
|
|
|
|
, mCurrentPage(-1)
|
2012-05-22 21:40:42 +02:00
|
|
|
{
|
2019-04-29 12:40:07 +04:00
|
|
|
bool terrain = Settings::Manager::getBool("distant terrain", "Terrain");
|
2022-08-28 15:06:31 +02:00
|
|
|
const std::string_view widgetName = terrain ? "RenderingDistanceSlider" : "LargeRenderingDistanceSlider";
|
2019-04-29 12:40:07 +04:00
|
|
|
MyGUI::Widget* unusedSlider;
|
|
|
|
getWidget(unusedSlider, widgetName);
|
|
|
|
unusedSlider->setVisible(false);
|
|
|
|
|
2021-04-03 22:25:13 -07:00
|
|
|
configureWidgets(mMainWidget, true);
|
2014-03-22 19:02:14 +01:00
|
|
|
|
2014-07-20 16:22:52 +02:00
|
|
|
setTitle("#{sOptions}");
|
|
|
|
|
2015-06-04 23:09:40 +03:00
|
|
|
getWidget(mSettingsTab, "SettingsTab");
|
2012-05-22 21:40:42 +02:00
|
|
|
getWidget(mOkButton, "OkButton");
|
2012-05-23 01:32:36 +02:00
|
|
|
getWidget(mResolutionList, "ResolutionList");
|
2022-05-03 22:50:31 -07:00
|
|
|
getWidget(mWindowModeList, "WindowModeList");
|
2014-12-24 15:09:50 +01:00
|
|
|
getWidget(mWindowBorderButton, "WindowBorderButton");
|
2012-05-29 04:54:54 +02:00
|
|
|
getWidget(mTextureFilteringButton, "TextureFilteringButton");
|
2012-08-13 01:26:15 +02:00
|
|
|
getWidget(mControlsBox, "ControlsBox");
|
2012-08-13 02:55:22 +02:00
|
|
|
getWidget(mResetControlsButton, "ResetControlsButton");
|
2014-12-08 21:57:32 -06:00
|
|
|
getWidget(mKeyboardSwitch, "KeyboardButton");
|
|
|
|
getWidget(mControllerSwitch, "ControllerButton");
|
2015-10-28 21:49:01 +01:00
|
|
|
getWidget(mWaterTextureSize, "WaterTextureSize");
|
2019-02-21 20:14:18 +04:00
|
|
|
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
2021-10-31 10:33:28 -04:00
|
|
|
getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail");
|
2022-07-25 08:54:05 +04:00
|
|
|
getWidget(mPrimaryLanguage, "PrimaryLanguage");
|
|
|
|
getWidget(mSecondaryLanguage, "SecondaryLanguage");
|
2021-04-16 11:55:40 -07:00
|
|
|
getWidget(mLightingMethodButton, "LightingMethodButton");
|
2021-04-03 22:25:13 -07:00
|
|
|
getWidget(mLightsResetButton, "LightsResetButton");
|
2021-04-16 11:55:40 -07:00
|
|
|
getWidget(mMaxLights, "MaxLights");
|
2022-01-25 21:53:00 +01:00
|
|
|
getWidget(mScriptFilter, "ScriptFilter");
|
|
|
|
getWidget(mScriptList, "ScriptList");
|
2022-01-27 23:12:30 +01:00
|
|
|
getWidget(mScriptBox, "ScriptBox");
|
2022-01-25 21:53:00 +01:00
|
|
|
getWidget(mScriptView, "ScriptView");
|
2022-01-29 23:06:43 +01:00
|
|
|
getWidget(mScriptAdapter, "ScriptAdapter");
|
2022-07-30 08:07:24 +00:00
|
|
|
getWidget(mScriptDisabled, "ScriptDisabled");
|
2012-05-22 21:40:42 +02:00
|
|
|
|
2015-01-02 16:49:22 +03:00
|
|
|
#ifndef WIN32
|
|
|
|
// hide gamma controls since it currently does not work under Linux
|
|
|
|
MyGUI::ScrollBar *gammaSlider;
|
|
|
|
getWidget(gammaSlider, "GammaSlider");
|
|
|
|
gammaSlider->setVisible(false);
|
|
|
|
MyGUI::TextBox *textBox;
|
|
|
|
getWidget(textBox, "GammaText");
|
|
|
|
textBox->setVisible(false);
|
|
|
|
getWidget(textBox, "GammaTextDark");
|
|
|
|
textBox->setVisible(false);
|
|
|
|
getWidget(textBox, "GammaTextLight");
|
|
|
|
textBox->setVisible(false);
|
|
|
|
#endif
|
|
|
|
|
2014-10-16 15:07:26 +02:00
|
|
|
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &SettingsWindow::onWindowResize);
|
|
|
|
|
2015-06-04 23:09:40 +03:00
|
|
|
mSettingsTab->eventTabChangeSelect += MyGUI::newDelegate(this, &SettingsWindow::onTabChanged);
|
2012-05-22 21:40:42 +02:00
|
|
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
2013-11-05 19:50:24 +01:00
|
|
|
mTextureFilteringButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringChanged);
|
2012-05-23 05:28:25 +02:00
|
|
|
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
2012-05-22 21:40:42 +02:00
|
|
|
|
2015-10-28 21:49:01 +01:00
|
|
|
mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged);
|
2019-02-21 20:14:18 +04:00
|
|
|
mWaterReflectionDetail->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterReflectionDetailChanged);
|
2021-10-31 10:33:28 -04:00
|
|
|
mWaterRainRippleDetail->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterRainRippleDetailChanged);
|
2015-10-28 21:49:01 +01:00
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
mLightingMethodButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onLightingMethodButtonChanged);
|
2021-04-03 22:25:13 -07:00
|
|
|
mLightsResetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onLightsResetButtonClicked);
|
2021-04-16 11:55:40 -07:00
|
|
|
mMaxLights->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onMaxLightsChanged);
|
2021-04-03 22:25:13 -07:00
|
|
|
|
2022-05-03 22:50:31 -07:00
|
|
|
mWindowModeList->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWindowModeChanged);
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
|
|
|
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
|
|
|
|
2022-07-25 08:54:05 +04:00
|
|
|
mPrimaryLanguage->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onPrimaryLanguageChanged);
|
|
|
|
mSecondaryLanguage->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSecondaryLanguageChanged);
|
|
|
|
|
2021-11-13 13:48:12 +00:00
|
|
|
computeMinimumWindowSize();
|
|
|
|
|
2012-05-22 21:40:42 +02:00
|
|
|
center();
|
|
|
|
|
2012-08-13 02:55:22 +02:00
|
|
|
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
|
|
|
|
2012-05-23 01:32:36 +02:00
|
|
|
// fill resolution list
|
2013-07-29 13:34:56 +02:00
|
|
|
int screen = Settings::Manager::getInt("screen", "Video");
|
|
|
|
int numDisplayModes = SDL_GetNumDisplayModes(screen);
|
2012-06-26 15:41:13 +02:00
|
|
|
std::vector < std::pair<int, int> > resolutions;
|
2013-07-29 13:34:56 +02:00
|
|
|
for (int i = 0; i < numDisplayModes; i++)
|
2012-05-23 01:32:36 +02:00
|
|
|
{
|
2013-07-29 13:34:56 +02:00
|
|
|
SDL_DisplayMode mode;
|
|
|
|
SDL_GetDisplayMode(screen, i, &mode);
|
2020-10-17 12:26:35 +04:00
|
|
|
resolutions.emplace_back(mode.w, mode.h);
|
2012-06-26 15:41:13 +02:00
|
|
|
}
|
|
|
|
std::sort(resolutions.begin(), resolutions.end(), sortResolutions);
|
2019-03-02 13:27:59 +04:00
|
|
|
for (std::pair<int, int>& resolution : resolutions)
|
2012-06-26 15:41:13 +02:00
|
|
|
{
|
2021-04-10 09:52:46 +04:00
|
|
|
std::string str = MyGUI::utility::toString(resolution.first) + " x " + MyGUI::utility::toString(resolution.second);
|
|
|
|
std::string aspect = getAspect(resolution.first, resolution.second);
|
|
|
|
if (!aspect.empty())
|
|
|
|
str = str + " (" + aspect + ")";
|
2012-06-23 12:25:28 +02:00
|
|
|
|
|
|
|
if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE)
|
|
|
|
mResolutionList->addItem(str);
|
2012-05-23 01:32:36 +02:00
|
|
|
}
|
2015-07-13 18:00:41 +02:00
|
|
|
highlightCurrentResolution();
|
2012-05-23 01:32:36 +02:00
|
|
|
|
2022-08-28 16:38:11 +02:00
|
|
|
const std::string& tmip = Settings::Manager::getString("texture mipmap", "General");
|
2022-07-04 21:45:44 +04:00
|
|
|
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
|
2012-05-29 04:54:54 +02:00
|
|
|
|
2019-02-21 20:14:18 +04:00
|
|
|
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
|
2015-10-28 21:49:01 +01:00
|
|
|
if (waterTextureSize >= 512)
|
|
|
|
mWaterTextureSize->setIndexSelected(0);
|
|
|
|
if (waterTextureSize >= 1024)
|
|
|
|
mWaterTextureSize->setIndexSelected(1);
|
|
|
|
if (waterTextureSize >= 2048)
|
|
|
|
mWaterTextureSize->setIndexSelected(2);
|
|
|
|
|
2021-10-31 12:23:36 -04:00
|
|
|
int waterReflectionDetail = std::clamp(Settings::Manager::getInt("reflection detail", "Water"), 0, 5);
|
2019-02-21 20:14:18 +04:00
|
|
|
mWaterReflectionDetail->setIndexSelected(waterReflectionDetail);
|
|
|
|
|
2021-10-31 12:23:36 -04:00
|
|
|
int waterRainRippleDetail = std::clamp(Settings::Manager::getInt("rain ripple detail", "Water"), 0, 2);
|
2021-10-31 10:33:28 -04:00
|
|
|
mWaterRainRippleDetail->setIndexSelected(waterRainRippleDetail);
|
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
updateMaxLightsComboBox(mMaxLights);
|
|
|
|
|
2022-05-03 22:50:31 -07:00
|
|
|
Settings::WindowMode windowMode = static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video"));
|
2022-05-08 22:56:35 -07:00
|
|
|
mWindowBorderButton->setEnabled(windowMode != Settings::WindowMode::Fullscreen && windowMode != Settings::WindowMode::WindowedFullscreen);
|
2014-12-09 14:48:34 -06:00
|
|
|
|
|
|
|
mKeyboardSwitch->setStateSelected(true);
|
|
|
|
mControllerSwitch->setStateSelected(false);
|
2022-01-25 21:53:00 +01:00
|
|
|
|
|
|
|
mScriptFilter->eventEditTextChange += MyGUI::newDelegate(this, &SettingsWindow::onScriptFilterChange);
|
|
|
|
mScriptList->eventListMouseItemActivate += MyGUI::newDelegate(this, &SettingsWindow::onScriptListSelection);
|
2022-07-25 08:54:05 +04:00
|
|
|
|
|
|
|
std::vector<std::string> availableLanguages;
|
|
|
|
const VFS::Manager* vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
|
|
|
for (const auto& path : vfs->getRecursiveDirectoryIterator("l10n/"))
|
|
|
|
{
|
|
|
|
if (Misc::getFileExtension(path) == "yaml")
|
|
|
|
{
|
|
|
|
std::string localeName(Misc::stemFile(path));
|
|
|
|
if (std::find(availableLanguages.begin(), availableLanguages.end(), localeName) == availableLanguages.end())
|
|
|
|
availableLanguages.push_back(localeName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort (availableLanguages.begin(), availableLanguages.end());
|
|
|
|
|
|
|
|
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
|
|
|
|
if (currentLocales.empty())
|
|
|
|
currentLocales.push_back("en");
|
|
|
|
|
|
|
|
icu::Locale primaryLocale(currentLocales[0].c_str());
|
|
|
|
|
|
|
|
mPrimaryLanguage->removeAllItems();
|
2022-07-27 10:51:36 +04:00
|
|
|
mPrimaryLanguage->setIndexSelected(MyGUI::ITEM_NONE);
|
|
|
|
|
2022-07-25 08:54:05 +04:00
|
|
|
mSecondaryLanguage->removeAllItems();
|
2022-07-27 10:51:36 +04:00
|
|
|
mSecondaryLanguage->addItem(MyGUI::LanguageManager::getInstance().replaceTags("#{sNone}"), std::string());
|
|
|
|
mSecondaryLanguage->setIndexSelected(0);
|
2022-07-25 08:54:05 +04:00
|
|
|
|
2022-07-27 10:51:36 +04:00
|
|
|
size_t i = 0;
|
2022-07-25 08:54:05 +04:00
|
|
|
for (const auto& language : availableLanguages)
|
|
|
|
{
|
|
|
|
icu::Locale locale(language.c_str());
|
|
|
|
|
|
|
|
icu::UnicodeString str(language.c_str());
|
|
|
|
locale.getDisplayName(primaryLocale, str);
|
|
|
|
std::string localeString;
|
|
|
|
str.toUTF8String(localeString);
|
2022-07-27 10:51:36 +04:00
|
|
|
|
|
|
|
mPrimaryLanguage->addItem(localeString, language);
|
|
|
|
mSecondaryLanguage->addItem(localeString, language);
|
2022-07-25 08:54:05 +04:00
|
|
|
|
|
|
|
if (language == currentLocales[0])
|
2022-07-27 10:51:36 +04:00
|
|
|
mPrimaryLanguage->setIndexSelected(i);
|
2022-07-25 08:54:05 +04:00
|
|
|
if (currentLocales.size() > 1 && language == currentLocales[1])
|
2022-07-27 10:51:36 +04:00
|
|
|
mSecondaryLanguage->setIndexSelected(i + 1);
|
2022-07-25 08:54:05 +04:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2012-05-22 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
2022-01-27 23:12:30 +01:00
|
|
|
void SettingsWindow::onTabChanged(MyGUI::TabControl* /*_sender*/, size_t /*index*/)
|
2015-06-04 23:09:40 +03:00
|
|
|
{
|
|
|
|
resetScrollbars();
|
|
|
|
}
|
|
|
|
|
2012-05-22 21:40:42 +02:00
|
|
|
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2017-09-23 12:18:39 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
|
2012-05-22 21:40:42 +02:00
|
|
|
}
|
2012-05-23 01:32:36 +02:00
|
|
|
|
2012-05-23 05:28:25 +02:00
|
|
|
void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index)
|
|
|
|
{
|
|
|
|
if (index == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
|
2013-04-10 00:32:05 -04:00
|
|
|
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
2015-06-04 20:31:28 +02:00
|
|
|
dialog->askForConfirmation("#{sNotifyMessage67}");
|
2012-05-23 05:28:25 +02:00
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept);
|
2012-05-28 12:34:29 +02:00
|
|
|
dialog->eventCancelClicked.clear();
|
2012-08-10 15:15:48 +02:00
|
|
|
dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionCancel);
|
2012-05-23 05:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::onResolutionAccept()
|
|
|
|
{
|
|
|
|
std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected());
|
2012-06-23 12:25:28 +02:00
|
|
|
int resX, resY;
|
|
|
|
parseResolution (resX, resY, resStr);
|
2012-05-23 05:28:25 +02:00
|
|
|
|
|
|
|
Settings::Manager::setInt("resolution x", "Video", resX);
|
|
|
|
Settings::Manager::setInt("resolution y", "Video", resY);
|
|
|
|
|
2012-05-24 04:34:53 +02:00
|
|
|
apply();
|
2012-05-28 12:34:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::onResolutionCancel()
|
2015-07-13 18:00:41 +02:00
|
|
|
{
|
|
|
|
highlightCurrentResolution();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::highlightCurrentResolution()
|
2012-05-28 12:34:29 +02:00
|
|
|
{
|
|
|
|
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
|
2015-07-13 18:00:41 +02:00
|
|
|
|
|
|
|
int currentX = Settings::Manager::getInt("resolution x", "Video");
|
|
|
|
int currentY = Settings::Manager::getInt("resolution y", "Video");
|
|
|
|
|
|
|
|
for (size_t i=0; i<mResolutionList->getItemCount(); ++i)
|
|
|
|
{
|
|
|
|
int resX, resY;
|
|
|
|
parseResolution (resX, resY, mResolutionList->getItemNameAt(i));
|
|
|
|
|
|
|
|
if (resX == currentX && resY == currentY)
|
|
|
|
{
|
|
|
|
mResolutionList->setIndexSelected(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-05-23 05:28:25 +02:00
|
|
|
}
|
|
|
|
|
2015-10-28 21:49:01 +01:00
|
|
|
void SettingsWindow::onWaterTextureSizeChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
|
|
|
int size = 0;
|
|
|
|
if (pos == 0)
|
|
|
|
size = 512;
|
|
|
|
else if (pos == 1)
|
|
|
|
size = 1024;
|
|
|
|
else if (pos == 2)
|
|
|
|
size = 2048;
|
|
|
|
Settings::Manager::setInt("rtt size", "Water", size);
|
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2019-02-21 20:14:18 +04:00
|
|
|
void SettingsWindow::onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
2021-10-31 17:48:03 -04:00
|
|
|
unsigned int level = static_cast<unsigned int>(std::min<size_t>(pos, 5));
|
2019-02-21 20:14:18 +04:00
|
|
|
Settings::Manager::setInt("reflection detail", "Water", level);
|
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2021-10-31 10:33:28 -04:00
|
|
|
void SettingsWindow::onWaterRainRippleDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
2021-10-31 17:48:03 -04:00
|
|
|
unsigned int level = static_cast<unsigned int>(std::min<size_t>(pos, 2));
|
2021-10-31 12:23:36 -04:00
|
|
|
Settings::Manager::setInt("rain ripple detail", "Water", level);
|
2021-10-31 10:33:28 -04:00
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
void SettingsWindow::onLightingMethodButtonChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
|
|
|
if (pos == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
|
2022-07-27 09:51:14 +04:00
|
|
|
_sender->setCaptionWithReplacing(_sender->getItemNameAt(_sender->getIndexSelected()));
|
|
|
|
|
2022-07-04 21:45:44 +04:00
|
|
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox("#{SettingsMenu:ChangeRequiresRestart}", {"#{sOK}"}, true);
|
2021-04-16 11:55:40 -07:00
|
|
|
|
2022-07-27 13:03:24 +04:00
|
|
|
Settings::Manager::setString("lighting method", "Shaders", *_sender->getItemDataAt<std::string>(pos));
|
2021-04-16 11:55:40 -07:00
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2022-07-25 08:54:05 +04:00
|
|
|
void SettingsWindow::onLanguageChanged(size_t langPriority, MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
|
|
|
if (pos == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
|
2022-07-27 09:51:14 +04:00
|
|
|
_sender->setCaptionWithReplacing(_sender->getItemNameAt(_sender->getIndexSelected()));
|
|
|
|
|
2022-07-25 08:54:05 +04:00
|
|
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox("#{SettingsMenu:ChangeRequiresRestart}", {"#{sOK}"}, true);
|
|
|
|
|
|
|
|
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
|
|
|
|
if (currentLocales.size() <= langPriority)
|
|
|
|
currentLocales.resize(langPriority + 1, "en");
|
2022-07-27 10:51:36 +04:00
|
|
|
|
|
|
|
const auto& languageCode = *_sender->getItemDataAt<std::string>(pos);
|
|
|
|
if (!languageCode.empty())
|
2022-07-27 13:03:24 +04:00
|
|
|
currentLocales[langPriority] = languageCode;
|
2022-07-27 10:51:36 +04:00
|
|
|
else
|
|
|
|
currentLocales.resize(1);
|
2022-07-25 08:54:05 +04:00
|
|
|
|
|
|
|
Settings::Manager::setStringArray("preferred locales", "General", currentLocales);
|
|
|
|
}
|
|
|
|
|
2022-05-03 22:50:31 -07:00
|
|
|
void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
|
|
|
if (pos == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Settings::Manager::setInt("window mode", "Video", static_cast<int>(_sender->getIndexSelected()));
|
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
void SettingsWindow::onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
|
|
{
|
|
|
|
int count = 8 * (pos + 1);
|
|
|
|
|
|
|
|
Settings::Manager::setInt("max lights", "Shaders", count);
|
|
|
|
apply();
|
|
|
|
configureWidgets(mMainWidget, false);
|
|
|
|
}
|
|
|
|
|
2021-04-03 22:25:13 -07:00
|
|
|
void SettingsWindow::onLightsResetButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
std::vector<std::string> buttons = {"#{sYes}", "#{sNo}"};
|
2022-07-04 21:45:44 +04:00
|
|
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox("#{SettingsMenu:LightingResetToDefaults}", buttons, true);
|
2021-04-03 22:25:13 -07:00
|
|
|
int selectedButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
|
|
|
|
if (selectedButton == 1 || selectedButton == -1)
|
|
|
|
return;
|
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
constexpr std::array<const char*, 6> settings = {
|
|
|
|
"light bounds multiplier",
|
|
|
|
"maximum light distance",
|
|
|
|
"light fade start",
|
|
|
|
"minimum interior brightness",
|
|
|
|
"max lights",
|
|
|
|
"lighting method",
|
|
|
|
};
|
2021-04-08 18:58:53 -07:00
|
|
|
for (const auto& setting : settings)
|
|
|
|
Settings::Manager::setString(setting, "Shaders", Settings::Manager::mDefaultSettings[{"Shaders", setting}]);
|
2021-04-03 22:25:13 -07:00
|
|
|
|
2022-07-04 21:45:44 +04:00
|
|
|
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(Settings::Manager::mDefaultSettings[{"Shaders", "lighting method"}]);
|
|
|
|
auto lightIndex = mLightingMethodButton->findItemIndexWith(lightingMethodToStr(lightingMethod));
|
|
|
|
mLightingMethodButton->setIndexSelected(lightIndex);
|
2021-04-16 11:55:40 -07:00
|
|
|
updateMaxLightsComboBox(mMaxLights);
|
|
|
|
|
2021-04-03 22:25:13 -07:00
|
|
|
apply();
|
|
|
|
configureWidgets(mMainWidget, false);
|
|
|
|
}
|
|
|
|
|
2012-05-23 05:28:25 +02:00
|
|
|
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
|
|
|
{
|
2022-08-24 22:16:03 +02:00
|
|
|
MyGUI::UString on = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On"));
|
2012-05-23 05:28:25 +02:00
|
|
|
bool newState;
|
|
|
|
if (_sender->castType<MyGUI::Button>()->getCaption() == on)
|
|
|
|
{
|
2022-08-24 22:16:03 +02:00
|
|
|
MyGUI::UString off = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOff", "Off"));
|
2012-05-23 05:28:25 +02:00
|
|
|
_sender->castType<MyGUI::Button>()->setCaption(off);
|
|
|
|
newState = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_sender->castType<MyGUI::Button>()->setCaption(on);
|
|
|
|
newState = true;
|
|
|
|
}
|
|
|
|
|
2014-03-22 19:02:14 +01:00
|
|
|
if (getSettingType(_sender) == checkButtonType)
|
2012-05-29 06:45:44 +02:00
|
|
|
{
|
2014-03-22 19:02:14 +01:00
|
|
|
Settings::Manager::setBool(getSettingName(_sender), getSettingCategory(_sender), newState);
|
2012-05-29 06:45:44 +02:00
|
|
|
apply();
|
2014-03-22 19:02:14 +01:00
|
|
|
return;
|
2012-05-29 06:45:44 +02:00
|
|
|
}
|
2012-05-24 11:50:48 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 19:50:24 +01:00
|
|
|
void SettingsWindow::onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos)
|
2012-05-29 04:54:54 +02:00
|
|
|
{
|
2015-12-13 15:02:36 -08:00
|
|
|
if(pos == 0)
|
2015-12-13 16:02:09 -08:00
|
|
|
Settings::Manager::setString("texture mipmap", "General", "nearest");
|
2015-12-13 15:02:36 -08:00
|
|
|
else if(pos == 1)
|
2015-12-13 16:02:09 -08:00
|
|
|
Settings::Manager::setString("texture mipmap", "General", "linear");
|
2015-12-13 15:02:36 -08:00
|
|
|
else
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Warning) << "Unexpected option pos " << pos;
|
2015-12-13 11:24:23 -08:00
|
|
|
apply();
|
|
|
|
}
|
|
|
|
|
2012-05-23 01:32:36 +02:00
|
|
|
void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
|
|
|
{
|
2014-03-22 19:02:14 +01:00
|
|
|
if (getSettingType(scroller) == "Slider")
|
2012-05-29 04:54:54 +02:00
|
|
|
{
|
2016-01-05 22:37:36 +01:00
|
|
|
std::string valueStr;
|
2019-03-17 06:37:20 +03:00
|
|
|
std::string valueType = getSettingValueType(scroller);
|
2019-04-29 12:40:07 +04:00
|
|
|
if (valueType == "Float" || valueType == "Integer" || valueType == "Cell")
|
2014-03-22 19:02:14 +01:00
|
|
|
{
|
|
|
|
float value = pos / float(scroller->getScrollRange()-1);
|
|
|
|
|
|
|
|
float min,max;
|
|
|
|
getSettingMinMax(scroller, min, max);
|
|
|
|
value = min + (max-min) * value;
|
2019-03-17 06:37:20 +03:00
|
|
|
if (valueType == "Float")
|
|
|
|
Settings::Manager::setFloat(getSettingName(scroller), getSettingCategory(scroller), value);
|
|
|
|
else
|
|
|
|
Settings::Manager::setInt(getSettingName(scroller), getSettingCategory(scroller), (int)value);
|
2019-04-29 12:40:07 +04:00
|
|
|
|
|
|
|
if (valueType == "Cell")
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::fixed << std::setprecision(2) << value/Constants::CellSizeInUnits;
|
|
|
|
valueStr = ss.str();
|
|
|
|
}
|
2021-04-03 22:25:13 -07:00
|
|
|
else if (valueType == "Float")
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::fixed << std::setprecision(2) << value;
|
|
|
|
valueStr = ss.str();
|
|
|
|
}
|
2019-04-29 12:40:07 +04:00
|
|
|
else
|
|
|
|
valueStr = MyGUI::utility::toString(int(value));
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Settings::Manager::setInt(getSettingName(scroller), getSettingCategory(scroller), pos);
|
2016-01-05 22:37:36 +01:00
|
|
|
valueStr = MyGUI::utility::toString(pos);
|
2014-03-22 19:02:14 +01:00
|
|
|
}
|
2016-01-05 22:37:36 +01:00
|
|
|
updateSliderLabel(scroller, valueStr);
|
|
|
|
|
2014-03-22 19:02:14 +01:00
|
|
|
apply();
|
2012-05-29 04:54:54 +02:00
|
|
|
}
|
2012-05-24 04:34:53 +02:00
|
|
|
}
|
2012-05-23 01:32:36 +02:00
|
|
|
|
2012-05-24 04:34:53 +02:00
|
|
|
void SettingsWindow::apply()
|
|
|
|
{
|
2019-05-04 21:38:36 +04:00
|
|
|
const Settings::CategorySettingVector changed = Settings::Manager::getPendingChanges();
|
2012-05-24 04:34:53 +02:00
|
|
|
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
|
2012-05-24 11:50:48 +02:00
|
|
|
MWBase::Environment::get().getSoundManager()->processChangedSettings(changed);
|
|
|
|
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
|
2012-05-28 09:19:25 +02:00
|
|
|
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
|
2018-09-21 16:34:23 +04:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed);
|
2019-05-04 21:38:36 +04:00
|
|
|
Settings::Manager::resetPendingChanges();
|
2012-05-23 01:32:36 +02:00
|
|
|
}
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
if(mKeyboardMode)
|
|
|
|
return;
|
|
|
|
mKeyboardMode = true;
|
2014-12-09 14:48:34 -06:00
|
|
|
mKeyboardSwitch->setStateSelected(true);
|
|
|
|
mControllerSwitch->setStateSelected(false);
|
2014-12-08 21:57:32 -06:00
|
|
|
updateControlsBox();
|
2015-06-04 23:09:40 +03:00
|
|
|
resetScrollbars();
|
2014-12-08 21:57:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::onControllerSwitchClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
if(!mKeyboardMode)
|
|
|
|
return;
|
|
|
|
mKeyboardMode = false;
|
2014-12-09 14:48:34 -06:00
|
|
|
mKeyboardSwitch->setStateSelected(false);
|
|
|
|
mControllerSwitch->setStateSelected(true);
|
2014-12-08 21:57:32 -06:00
|
|
|
updateControlsBox();
|
2015-06-04 23:09:40 +03:00
|
|
|
resetScrollbars();
|
2014-12-08 21:57:32 -06:00
|
|
|
}
|
|
|
|
|
2012-08-13 01:26:15 +02:00
|
|
|
void SettingsWindow::updateControlsBox()
|
|
|
|
{
|
|
|
|
while (mControlsBox->getChildCount())
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mControlsBox->getChildAt(0));
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
MWBase::Environment::get().getWindowManager()->removeStaticMessageBox();
|
2022-08-12 18:42:12 +02:00
|
|
|
const auto inputManager = MWBase::Environment::get().getInputManager();
|
|
|
|
const auto& actions = mKeyboardMode ? inputManager->getActionKeySorting() : inputManager->getActionControllerSorting();
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
for (const int& action : actions)
|
2012-08-13 01:26:15 +02:00
|
|
|
{
|
2022-08-12 18:42:12 +02:00
|
|
|
std::string desc{inputManager->getActionDescription(action)};
|
|
|
|
if (desc.empty())
|
2012-08-13 01:26:15 +02:00
|
|
|
continue;
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
std::string binding;
|
|
|
|
if(mKeyboardMode)
|
2022-08-12 18:42:12 +02:00
|
|
|
binding = inputManager->getActionKeyBindingName(action);
|
2014-12-08 21:57:32 -06:00
|
|
|
else
|
2022-08-12 18:42:12 +02:00
|
|
|
binding = inputManager->getActionControllerBindingName(action);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2016-11-01 16:37:00 +01:00
|
|
|
Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
|
2012-08-13 01:26:15 +02:00
|
|
|
leftText->setCaptionWithReplacing(desc);
|
|
|
|
|
2016-11-01 16:37:00 +01:00
|
|
|
Gui::SharedStateButton* rightText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
|
2012-08-13 01:26:15 +02:00
|
|
|
rightText->setCaptionWithReplacing(binding);
|
|
|
|
rightText->setTextAlign (MyGUI::Align::Right);
|
2019-03-02 13:27:59 +04:00
|
|
|
rightText->setUserData(action); // save the action id for callbacks
|
2012-08-13 01:26:15 +02:00
|
|
|
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
|
2012-08-13 02:55:22 +02:00
|
|
|
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);
|
2014-12-06 16:50:09 +01:00
|
|
|
|
|
|
|
Gui::ButtonGroup group;
|
|
|
|
group.push_back(leftText);
|
|
|
|
group.push_back(rightText);
|
|
|
|
Gui::SharedStateButton::createButtonGroup(group);
|
2012-08-13 01:26:15 +02:00
|
|
|
}
|
|
|
|
|
2016-11-01 16:37:00 +01:00
|
|
|
layoutControlsBox();
|
|
|
|
}
|
|
|
|
|
2021-04-09 17:41:33 -07:00
|
|
|
void SettingsWindow::updateLightSettings()
|
|
|
|
{
|
|
|
|
auto lightingMethod = MWBase::Environment::get().getResourceSystem()->getSceneManager()->getLightingMethod();
|
2022-07-04 21:45:44 +04:00
|
|
|
std::string lightingMethodStr = lightingMethodToStr(lightingMethod);
|
2021-04-16 11:55:40 -07:00
|
|
|
|
|
|
|
mLightingMethodButton->removeAllItems();
|
|
|
|
|
|
|
|
std::array<SceneUtil::LightingMethod, 3> methods = {
|
|
|
|
SceneUtil::LightingMethod::FFP,
|
|
|
|
SceneUtil::LightingMethod::PerObjectUniform,
|
|
|
|
SceneUtil::LightingMethod::SingleUBO,
|
|
|
|
};
|
2021-04-09 17:41:33 -07:00
|
|
|
|
2021-04-16 11:55:40 -07:00
|
|
|
for (const auto& method : methods)
|
2021-04-09 17:41:33 -07:00
|
|
|
{
|
2021-04-16 11:55:40 -07:00
|
|
|
if (!MWBase::Environment::get().getResourceSystem()->getSceneManager()->isSupportedLightingMethod(method))
|
|
|
|
continue;
|
|
|
|
|
2022-07-27 13:03:24 +04:00
|
|
|
mLightingMethodButton->addItem(lightingMethodToStr(method), SceneUtil::LightManager::getLightingMethodString(method));
|
2021-04-09 17:41:33 -07:00
|
|
|
}
|
2021-04-16 11:55:40 -07:00
|
|
|
mLightingMethodButton->setIndexSelected(mLightingMethodButton->findItemIndexWith(lightingMethodStr));
|
2021-04-09 17:41:33 -07:00
|
|
|
}
|
|
|
|
|
2022-05-03 22:50:31 -07:00
|
|
|
void SettingsWindow::updateWindowModeSettings()
|
|
|
|
{
|
|
|
|
size_t index = static_cast<size_t>(Settings::Manager::getInt("window mode", "Video"));
|
|
|
|
|
|
|
|
if (index > static_cast<size_t>(Settings::WindowMode::Windowed))
|
|
|
|
index = MyGUI::ITEM_NONE;
|
|
|
|
|
|
|
|
mWindowModeList->setIndexSelected(index);
|
|
|
|
|
|
|
|
if (index != static_cast<size_t>(Settings::WindowMode::Windowed) && index != MyGUI::ITEM_NONE)
|
|
|
|
{
|
|
|
|
// check if this resolution is supported in fullscreen
|
|
|
|
if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE)
|
|
|
|
{
|
|
|
|
std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected());
|
|
|
|
int resX, resY;
|
|
|
|
parseResolution (resX, resY, resStr);
|
|
|
|
Settings::Manager::setInt("resolution x", "Video", resX);
|
|
|
|
Settings::Manager::setInt("resolution y", "Video", resY);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool supported = false;
|
|
|
|
int fallbackX = 0, fallbackY = 0;
|
|
|
|
for (unsigned int i=0; i<mResolutionList->getItemCount(); ++i)
|
|
|
|
{
|
|
|
|
std::string resStr = mResolutionList->getItemNameAt(i);
|
|
|
|
int resX, resY;
|
|
|
|
parseResolution (resX, resY, resStr);
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
fallbackX = resX;
|
|
|
|
fallbackY = resY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resX == Settings::Manager::getInt("resolution x", "Video")
|
|
|
|
&& resY == Settings::Manager::getInt("resolution y", "Video"))
|
|
|
|
supported = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!supported && mResolutionList->getItemCount())
|
|
|
|
{
|
|
|
|
if (fallbackX != 0 && fallbackY != 0)
|
|
|
|
{
|
|
|
|
Settings::Manager::setInt("resolution x", "Video", fallbackX);
|
|
|
|
Settings::Manager::setInt("resolution y", "Video", fallbackY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mWindowBorderButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-01 16:37:00 +01:00
|
|
|
void SettingsWindow::layoutControlsBox()
|
|
|
|
{
|
2022-08-17 21:51:36 +04:00
|
|
|
const int h = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
|
2016-11-01 16:37:00 +01:00
|
|
|
const int w = mControlsBox->getWidth() - 28;
|
|
|
|
const int noWidgetsInRow = 2;
|
|
|
|
const int totalH = mControlsBox->getChildCount() / noWidgetsInRow * h;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mControlsBox->getChildCount(); i++)
|
|
|
|
{
|
|
|
|
MyGUI::Widget * widget = mControlsBox->getChildAt(i);
|
|
|
|
widget->setCoord(0, i / noWidgetsInRow * h, w, h);
|
|
|
|
}
|
|
|
|
|
2014-07-26 02:23:42 +02:00
|
|
|
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
|
|
|
|
mControlsBox->setVisibleVScroll(false);
|
2016-11-01 16:37:00 +01:00
|
|
|
mControlsBox->setCanvasSize (mControlsBox->getWidth(), std::max(totalH, mControlsBox->getHeight()));
|
2014-07-26 02:23:42 +02:00
|
|
|
mControlsBox->setVisibleVScroll(true);
|
2012-08-13 01:26:15 +02:00
|
|
|
}
|
|
|
|
|
2022-01-30 14:25:20 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
std::string escapeRegex(const std::string& str)
|
|
|
|
{
|
2022-02-02 15:27:48 +01:00
|
|
|
static const std::regex specialChars(R"r([\^\.\[\$\(\)\|\*\+\?\{])r", std::regex_constants::extended);
|
2022-01-30 14:25:20 +01:00
|
|
|
return std::regex_replace(str, specialChars, R"(\$&)");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::regex wordSearch(const std::string& query)
|
|
|
|
{
|
2022-02-02 15:27:48 +01:00
|
|
|
static const std::regex wordsRegex(R"([^[:space:]]+)", std::regex_constants::extended);
|
2022-01-30 14:25:20 +01:00
|
|
|
auto wordsBegin = std::sregex_iterator(query.begin(), query.end(), wordsRegex);
|
|
|
|
auto wordsEnd = std::sregex_iterator();
|
|
|
|
std::string searchRegex("(");
|
|
|
|
for (auto it = wordsBegin; it != wordsEnd; ++it)
|
|
|
|
{
|
|
|
|
if (it != wordsBegin)
|
|
|
|
searchRegex += '|';
|
|
|
|
searchRegex += escapeRegex(query.substr(it->position(), it->length()));
|
|
|
|
}
|
|
|
|
searchRegex += ')';
|
|
|
|
// query had only whitespace characters
|
|
|
|
if (searchRegex == "()")
|
|
|
|
searchRegex = "^(.*)$";
|
2022-02-02 15:27:48 +01:00
|
|
|
return std::regex(searchRegex, std::regex_constants::extended | std::regex_constants::icase);
|
2022-01-30 14:25:20 +01:00
|
|
|
}
|
|
|
|
|
2022-02-01 22:03:01 +01:00
|
|
|
double weightedSearch(const std::regex& regex, const std::string& text)
|
2022-01-30 14:25:20 +01:00
|
|
|
{
|
|
|
|
std::smatch matches;
|
|
|
|
std::regex_search(text, matches, regex);
|
2022-02-02 15:27:48 +01:00
|
|
|
// need a signed value, so cast to double (not an integer type to guarantee no overflow)
|
|
|
|
return static_cast<double>(matches.size());
|
2022-01-30 14:25:20 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-03 12:49:37 -07:00
|
|
|
|
2022-01-25 21:53:00 +01:00
|
|
|
void SettingsWindow::renderScriptSettings()
|
|
|
|
{
|
2022-01-29 23:06:43 +01:00
|
|
|
mScriptAdapter->detach();
|
2022-06-07 16:18:13 +02:00
|
|
|
|
2022-01-25 21:53:00 +01:00
|
|
|
mScriptList->removeAllItems();
|
2022-01-27 23:12:30 +01:00
|
|
|
mScriptView->setCanvasSize({0, 0});
|
2022-01-25 21:53:00 +01:00
|
|
|
|
2022-02-02 15:27:48 +01:00
|
|
|
struct WeightedPage {
|
|
|
|
size_t mIndex;
|
|
|
|
std::string mName;
|
|
|
|
double mNameWeight;
|
|
|
|
double mHintWeight;
|
|
|
|
|
|
|
|
constexpr auto tie() const { return std::tie(mNameWeight, mHintWeight, mName); }
|
|
|
|
|
|
|
|
constexpr bool operator<(const WeightedPage& rhs) const { return tie() < rhs.tie(); }
|
|
|
|
};
|
|
|
|
|
2022-01-30 14:25:20 +01:00
|
|
|
std::regex searchRegex = wordSearch(mScriptFilter->getCaption());
|
2022-02-02 15:27:48 +01:00
|
|
|
std::vector<WeightedPage> weightedPages;
|
2022-01-30 14:25:20 +01:00
|
|
|
weightedPages.reserve(LuaUi::scriptSettingsPageCount());
|
2022-01-29 18:33:14 +01:00
|
|
|
for (size_t i = 0; i < LuaUi::scriptSettingsPageCount(); ++i)
|
2022-01-25 21:53:00 +01:00
|
|
|
{
|
2022-01-29 18:33:14 +01:00
|
|
|
LuaUi::ScriptSettingsPage page = LuaUi::scriptSettingsPageAt(i);
|
2022-02-02 15:27:48 +01:00
|
|
|
double nameWeight = weightedSearch(searchRegex, page.mName);
|
|
|
|
double hintWeight = weightedSearch(searchRegex, page.mSearchHints);
|
|
|
|
if ((nameWeight + hintWeight) > 0)
|
|
|
|
weightedPages.push_back({ i, page.mName, -nameWeight, -hintWeight });
|
2022-01-25 21:53:00 +01:00
|
|
|
}
|
2022-02-02 15:27:48 +01:00
|
|
|
std::sort(weightedPages.begin(), weightedPages.end());
|
|
|
|
for (const WeightedPage& weightedPage : weightedPages)
|
|
|
|
mScriptList->addItem(weightedPage.mName, weightedPage.mIndex);
|
2022-01-25 21:53:00 +01:00
|
|
|
|
2022-07-30 08:07:24 +00:00
|
|
|
// Hide script settings when the game world isn't loaded
|
2022-01-29 18:33:14 +01:00
|
|
|
bool disabled = LuaUi::scriptSettingsPageCount() == 0;
|
2022-01-25 21:53:00 +01:00
|
|
|
mScriptFilter->setVisible(!disabled);
|
|
|
|
mScriptList->setVisible(!disabled);
|
2022-01-27 23:12:30 +01:00
|
|
|
mScriptBox->setVisible(!disabled);
|
2022-07-30 08:07:24 +00:00
|
|
|
mScriptDisabled->setVisible(disabled);
|
2022-06-07 16:18:13 +02:00
|
|
|
|
|
|
|
LuaUi::attachPageAt(mCurrentPage, mScriptAdapter);
|
|
|
|
mScriptView->setCanvasSize(mScriptAdapter->getSize());
|
2022-01-25 21:53:00 +01:00
|
|
|
}
|
|
|
|
|
2022-01-28 21:45:13 +01:00
|
|
|
void SettingsWindow::onScriptFilterChange(MyGUI::EditBox*)
|
2022-01-25 21:53:00 +01:00
|
|
|
{
|
|
|
|
renderScriptSettings();
|
|
|
|
}
|
|
|
|
|
2022-01-28 21:45:13 +01:00
|
|
|
void SettingsWindow::onScriptListSelection(MyGUI::ListBox*, size_t index)
|
2022-01-25 21:53:00 +01:00
|
|
|
{
|
2022-01-29 23:06:43 +01:00
|
|
|
mScriptAdapter->detach();
|
2022-01-28 21:35:05 +01:00
|
|
|
mCurrentPage = -1;
|
2022-01-29 16:59:43 +01:00
|
|
|
if (index < mScriptList->getItemCount())
|
|
|
|
{
|
|
|
|
mCurrentPage = *mScriptList->getItemDataAt<size_t>(index);
|
2022-01-29 23:06:43 +01:00
|
|
|
LuaUi::attachPageAt(mCurrentPage, mScriptAdapter);
|
2022-01-29 16:59:43 +01:00
|
|
|
}
|
2022-02-01 22:03:01 +01:00
|
|
|
mScriptView->setCanvasSize(mScriptAdapter->getSize());
|
2022-01-29 16:59:43 +01:00
|
|
|
}
|
|
|
|
|
2012-08-13 01:26:15 +02:00
|
|
|
void SettingsWindow::onRebindAction(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
int actionId = *_sender->getUserData<int>();
|
|
|
|
|
2014-09-13 04:07:40 +02:00
|
|
|
_sender->castType<MyGUI::Button>()->setCaptionWithReplacing("#{sNone}");
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2013-05-03 12:44:27 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->staticMessageBox ("#{sControlsMenu3}");
|
2012-08-13 01:26:15 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->disallowMouse();
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
MWBase::Environment::get().getInputManager ()->enableDetectingBindingMode (actionId, mKeyboardMode);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-13 02:55:22 +02:00
|
|
|
void SettingsWindow::onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel)
|
|
|
|
{
|
2015-03-08 13:07:29 +13:00
|
|
|
if (mControlsBox->getViewOffset().top + _rel*0.3f > 0)
|
2012-08-13 02:55:22 +02:00
|
|
|
mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0));
|
|
|
|
else
|
2015-03-08 13:07:29 +13:00
|
|
|
mControlsBox->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mControlsBox->getViewOffset().top + _rel*0.3f)));
|
2012-08-13 02:55:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::onResetDefaultBindings(MyGUI::Widget* _sender)
|
|
|
|
{
|
2013-04-10 00:32:05 -04:00
|
|
|
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
2015-06-04 20:31:28 +02:00
|
|
|
dialog->askForConfirmation("#{sNotifyMessage66}");
|
2012-08-13 02:55:22 +02:00
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindingsAccept);
|
|
|
|
dialog->eventCancelClicked.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::onResetDefaultBindingsAccept()
|
|
|
|
{
|
2014-12-08 21:57:32 -06:00
|
|
|
if(mKeyboardMode)
|
|
|
|
MWBase::Environment::get().getInputManager ()->resetToDefaultKeyBindings ();
|
|
|
|
else
|
|
|
|
MWBase::Environment::get().getInputManager()->resetToDefaultControllerBindings();
|
2012-08-13 02:55:22 +02:00
|
|
|
updateControlsBox ();
|
|
|
|
}
|
|
|
|
|
2017-09-22 17:10:53 +02:00
|
|
|
void SettingsWindow::onOpen()
|
2012-08-13 01:26:15 +02:00
|
|
|
{
|
2019-05-02 19:00:47 +04:00
|
|
|
highlightCurrentResolution();
|
2018-06-12 19:33:41 +03:00
|
|
|
updateControlsBox();
|
2021-04-09 17:41:33 -07:00
|
|
|
updateLightSettings();
|
2022-05-03 22:50:31 -07:00
|
|
|
updateWindowModeSettings();
|
2015-06-04 23:09:40 +03:00
|
|
|
resetScrollbars();
|
2022-01-25 21:53:00 +01:00
|
|
|
renderScriptSettings();
|
2019-06-09 02:08:09 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mOkButton);
|
2012-08-13 01:26:15 +02:00
|
|
|
}
|
2014-05-26 23:13:37 -04:00
|
|
|
|
2014-10-16 15:07:26 +02:00
|
|
|
void SettingsWindow::onWindowResize(MyGUI::Window *_sender)
|
|
|
|
{
|
2016-11-01 16:37:00 +01:00
|
|
|
layoutControlsBox();
|
2014-10-16 15:07:26 +02:00
|
|
|
}
|
2015-06-04 23:09:40 +03:00
|
|
|
|
2021-11-13 13:48:12 +00:00
|
|
|
void SettingsWindow::computeMinimumWindowSize()
|
|
|
|
{
|
|
|
|
auto* window = mMainWidget->castType<MyGUI::Window>();
|
|
|
|
auto minSize = window->getMinSize();
|
|
|
|
|
|
|
|
// Window should be at minimum wide enough to show all tabs.
|
|
|
|
int tabBarWidth = 0;
|
|
|
|
for (uint32_t i = 0; i < mSettingsTab->getItemCount(); i++)
|
|
|
|
{
|
|
|
|
tabBarWidth += mSettingsTab->getButtonWidthAt(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to include window margins
|
|
|
|
int margins = mMainWidget->getWidth() - mSettingsTab->getWidth();
|
|
|
|
int minimumWindowWidth = tabBarWidth + margins;
|
|
|
|
|
|
|
|
if (minimumWindowWidth > minSize.width)
|
|
|
|
{
|
|
|
|
minSize.width = minimumWindowWidth;
|
|
|
|
window->setMinSize(minSize);
|
|
|
|
|
|
|
|
// Make a dummy call to setSize so MyGUI can apply any resize resulting from the change in MinSize
|
|
|
|
mMainWidget->setSize(mMainWidget->getSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 23:09:40 +03:00
|
|
|
void SettingsWindow::resetScrollbars()
|
|
|
|
{
|
|
|
|
mResolutionList->setScrollPosition(0);
|
|
|
|
mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0));
|
|
|
|
}
|
2012-05-22 21:40:42 +02:00
|
|
|
}
|