diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index 275af31..3dcc8a5 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ namespace Config Settings::BltFilter bltFilter; Settings::ColorKeyMethod colorKeyMethod; Settings::ConfigHotKey configHotKey; + Settings::ConfigRows configRows; Settings::ConfigTransparency configTransparency; Settings::CpuAffinity cpuAffinity; Settings::CpuAffinityRotation cpuAffinityRotation; diff --git a/DDrawCompat/Config/FormatListSetting.cpp b/DDrawCompat/Config/FormatListSetting.cpp index 28735af..0db71da 100644 --- a/DDrawCompat/Config/FormatListSetting.cpp +++ b/DDrawCompat/Config/FormatListSetting.cpp @@ -7,14 +7,6 @@ namespace { - void append(std::vector& formats, D3DDDIFORMAT format) - { - if (std::find(formats.begin(), formats.end(), format) == formats.end()) - { - formats.push_back(format); - } - } - std::string getFormatName(D3DDDIFORMAT format) { if (format > 0xFF) @@ -33,12 +25,13 @@ namespace Config { FormatListSetting::FormatListSetting(const std::string& name, const std::string& default, const std::set& allowedFormats, - const std::map>& allowedGroups, + const std::map>& allowedGroups, bool allowFourCCs) : ListSetting(name, default) , m_allowedFormats(allowedFormats) , m_allowedGroups(allowedGroups) , m_allowFourCCs(allowFourCCs) + , m_valueStr("all") { } @@ -73,27 +66,32 @@ namespace Config throw ParsingError("empty list is not allowed"); } - if (1 == values.size() && "all" == values[0]) + if (std::find(values.begin(), values.end(), "all") != values.end()) { m_formats.clear(); + m_valueStr = "all"; return; } - std::vector formats; - for (auto formatName : values) - { - if ("all" == formatName) - { - throw ParsingError("'all' cannot be combined with other values"); - } + std::set formats; + std::set groups; + for (const auto& formatName : values) + { auto group = m_allowedGroups.find(formatName); if (group != m_allowedGroups.end()) { - for (auto fmt : group->second) - { - append(formats, fmt); - } + formats.insert(group->second.begin(), group->second.end()); + groups.insert(group->first); + } + } + + std::set valueSet(groups); + + for (auto formatName : values) + { + if (groups.find(formatName) != groups.end()) + { continue; } @@ -102,14 +100,21 @@ namespace Config [&](auto fmt) { return getFormatName(fmt) == formatName; }); if (it != m_allowedFormats.end()) { - append(formats, *it); + if (formats.insert(*it).second) + { + valueSet.insert(formatName); + } continue; } if (m_allowFourCCs && 4 == formatName.length() && formatName.end() == std::find_if(formatName.begin(), formatName.end(), [](char c) { return !std::isalnum(c); })) { - append(formats, *reinterpret_cast(formatName.c_str())); + auto fourCC = *reinterpret_cast(formatName.c_str()); + if (formats.insert(fourCC).second) + { + valueSet.insert(formatName); + } continue; } @@ -117,5 +122,12 @@ namespace Config } m_formats = formats; + + m_valueStr.clear(); + for (const auto& value : valueSet) + { + m_valueStr += ", " + value; + } + m_valueStr = m_valueStr.substr(2); } } diff --git a/DDrawCompat/Config/FormatListSetting.h b/DDrawCompat/Config/FormatListSetting.h index ff5713b..2ef68fc 100644 --- a/DDrawCompat/Config/FormatListSetting.h +++ b/DDrawCompat/Config/FormatListSetting.h @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -16,19 +15,21 @@ namespace Config public: bool isSupported(D3DDDIFORMAT format) const; + virtual std::string getValueStr() const override; + protected: FormatListSetting(const std::string& name, const std::string& default, const std::set& allowedFormats, - const std::map>& allowedGroups, + const std::map>& allowedGroups, bool allowFourCCs); - virtual std::string getValueStr() const override; virtual void setValues(const std::vector& values) override; private: const std::set m_allowedFormats; - const std::map> m_allowedGroups; - std::vector m_formats; + const std::map> m_allowedGroups; + std::set m_formats; + std::string m_valueStr; const bool m_allowFourCCs; }; } diff --git a/DDrawCompat/Config/Parser.cpp b/DDrawCompat/Config/Parser.cpp index 628c0b1..fccef45 100644 --- a/DDrawCompat/Config/Parser.cpp +++ b/DDrawCompat/Config/Parser.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -13,12 +12,6 @@ namespace void setConfig(const std::string& name, const std::string& value, const std::string& source); - auto& getSettings() - { - static std::map settings; - return settings; - } - void loadConfigFile(const std::string& source, const std::filesystem::path& path) { LOG_INFO << "Loading " << source << " config file: " << path.u8string(); @@ -68,20 +61,19 @@ namespace throw Config::ParsingError("missing setting name before '='"); } - auto it = std::find_if(getSettings().cbegin(), getSettings().cend(), [&](const auto& v) { - return 0 == _stricmp(v.first.c_str(), name.c_str()); }); - if (it == getSettings().end()) + auto setting = Config::getSetting(name); + if (!setting) { throw Config::ParsingError("unknown setting: '" + name + "'"); } try { - it->second.set(Config::Parser::tolower(value), source); + setting->set(Config::Parser::tolower(value), source); } catch (const Config::ParsingError& error) { - throw Config::ParsingError(it->second.getName() + ": " + error.what()); + throw Config::ParsingError(setting->getName() + ": " + error.what()); } } } @@ -97,7 +89,7 @@ namespace Config void loadAllConfigFiles(const std::filesystem::path& processPath) { - for (auto& setting : getSettings()) { + for (auto& setting : Config::getAllSettings()) { setting.second.reset(); } @@ -114,20 +106,20 @@ namespace Config processConfigPath.replace_filename(L"DDrawCompat-" + processConfigPath.filename().native() + L".ini"); loadConfigFile("process", processConfigPath); - for (auto& setting : getSettings()) { + for (auto& setting : Config::getAllSettings()) { setting.second.setBaseValue(); } g_overlayConfigPath.replace_filename(L"DDrawCompatOverlay-" + g_overlayConfigPath.filename().native() + L".ini"); loadConfigFile("overlay", g_overlayConfigPath); - for (auto& setting : getSettings()) { + for (auto& setting : Config::getAllSettings()) { setting.second.setExportedValue(); } std::size_t maxNameLength = 0; std::size_t maxSourceLength = 0; - for (const auto& setting : getSettings()) + for (auto& setting : Config::getAllSettings()) { if (setting.second.getName().length() > maxNameLength) { @@ -140,7 +132,7 @@ namespace Config } LOG_INFO << "Final configuration:"; - for (const auto& setting : getSettings()) + for (auto& setting : Config::getAllSettings()) { std::string name(setting.second.getName()); name.insert(name.end(), maxNameLength - name.length(), ' '); @@ -200,12 +192,6 @@ namespace Config throw ParsingError("invalid resolution: '" + value + "'"); } - void registerSetting(Setting& setting) - { - const auto& name = setting.getName(); - getSettings().emplace(name, setting); - } - std::string removeParam(const std::string& value) { auto paramPos = value.find('('); diff --git a/DDrawCompat/Config/Parser.h b/DDrawCompat/Config/Parser.h index 9063542..88a73a3 100644 --- a/DDrawCompat/Config/Parser.h +++ b/DDrawCompat/Config/Parser.h @@ -23,7 +23,6 @@ namespace Config SIZE parseAspectRatio(const std::string& value); int parseInt(const std::string& value, int min, int max); SIZE parseResolution(const std::string& value); - void registerSetting(Setting& setting); std::string removeParam(const std::string& value); std::string tolower(const std::string& str); std::string toupper(const std::string& str); diff --git a/DDrawCompat/Config/Setting.cpp b/DDrawCompat/Config/Setting.cpp index d41d2be..851d4c7 100644 --- a/DDrawCompat/Config/Setting.cpp +++ b/DDrawCompat/Config/Setting.cpp @@ -1,6 +1,15 @@ #include #include +namespace +{ + std::map& getSettings() + { + static std::map settings; + return settings; + } +} + namespace Config { Setting::Setting(const std::string& name, const std::string& default) @@ -8,7 +17,7 @@ namespace Config , m_name(name) , m_default(default) { - Parser::registerSetting(*this); + getSettings().emplace(name, *this); } void Setting::reset() @@ -87,4 +96,22 @@ namespace Config throw ParsingError("invalid parameter value: '" + param + "'"); } } + + const std::map& getAllSettings() + { + return getSettings(); + } + + Setting* getSetting(const std::string& name) + { + auto& settings = getAllSettings(); + for (auto& setting : settings) + { + if (0 == _stricmp(setting.first.c_str(), name.c_str())) + { + return &setting.second; + } + } + return nullptr; + } } diff --git a/DDrawCompat/Config/Setting.h b/DDrawCompat/Config/Setting.h index 1d924ff..83cbfba 100644 --- a/DDrawCompat/Config/Setting.h +++ b/DDrawCompat/Config/Setting.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -53,4 +54,7 @@ namespace Config std::string m_baseValue; std::string m_exportedValue; }; + + const std::map& getAllSettings(); + Setting* getSetting(const std::string& name); } diff --git a/DDrawCompat/Config/Settings/ConfigRows.cpp b/DDrawCompat/Config/Settings/ConfigRows.cpp new file mode 100644 index 0000000..8471654 --- /dev/null +++ b/DDrawCompat/Config/Settings/ConfigRows.cpp @@ -0,0 +1,123 @@ +#include + +#include +#include +#include + +namespace +{ + template + void append(std::vector& values, const T& value, bool overwrite = false) + { + auto it = std::find(values.begin(), values.end(), value); + if (it != values.end()) + { + if (!overwrite) + { + return; + } + values.erase(it); + } + values.push_back(value); + } + + void appendAll(std::vector& settings) + { + const auto& allSettings = Config::getAllSettings(); + for (const auto& setting : allSettings) + { + append(settings, &setting.second); + } + } + + void appendAllRo(std::vector& settings) + { + const auto& allSettings = Config::getAllSettings(); + const auto& rwSettingNames = Overlay::ConfigWindow::getRwSettingNames(); + for (const auto& setting : allSettings) + { + if (rwSettingNames.find(setting.first) == rwSettingNames.end()) + { + append(settings, &setting.second); + } + } + } + + void appendAllRw(std::vector& settings) + { + const auto& rwSettingNames = Overlay::ConfigWindow::getRwSettingNames(); + for (const auto& settingName : rwSettingNames) + { + append(settings, Config::getSetting(settingName)); + } + } +} + +namespace Config +{ + namespace Settings + { + ConfigRows::ConfigRows() + : ListSetting("ConfigRows", "allrw, allro") + { + } + + std::string ConfigRows::getValueStr() const + { + return m_valueStr; + } + + void ConfigRows::setValues(const std::vector& values) + { + std::set groups; + std::vector settings; + std::vector valueStr; + + for (auto value : values) + { + if ("all" == value || "allro" == value || "allrw" == value) + { + if (groups.find(value) != groups.end()) + { + continue; + } + + if ("all" == value) + { + appendAll(settings); + } + else if ("allro" == value) + { + appendAllRo(settings); + } + else if ("allrw" == value) + { + appendAllRw(settings); + } + + valueStr.push_back(value); + continue; + } + + auto setting = getSetting(value); + if (!setting) + { + throw ParsingError("invalid value: '" + value + "'"); + } + + const bool overwrite = true; + append(settings, setting, overwrite); + append(valueStr, setting->getName(), overwrite); + } + + m_settings = settings; + + m_valueStr.clear(); + for (const auto& v : valueStr) + { + m_valueStr += ", " + v; + } + m_valueStr = m_valueStr.substr(2); + } + } +} diff --git a/DDrawCompat/Config/Settings/ConfigRows.h b/DDrawCompat/Config/Settings/ConfigRows.h new file mode 100644 index 0000000..774de5a --- /dev/null +++ b/DDrawCompat/Config/Settings/ConfigRows.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +#include + +namespace Config +{ + namespace Settings + { + class ConfigRows : public ListSetting + { + public: + ConfigRows(); + + virtual std::string getValueStr() const override; + + const std::vector& get() const { return m_settings; } + + private: + void setValues(const std::vector& values) override; + + std::vector m_settings; + std::string m_valueStr; + }; + } + + extern Settings::ConfigRows configRows; +} diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 0ebbf85..6acb57e 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -170,6 +170,7 @@ + @@ -347,6 +348,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index d5ba8d4..dd51b6f 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -699,6 +699,9 @@ Header Files\Config\Settings + + Header Files\Config\Settings + @@ -1091,6 +1094,9 @@ Source Files\Config + + Source Files\Config\Settings + diff --git a/DDrawCompat/Input/Input.cpp b/DDrawCompat/Input/Input.cpp index e1d91cf..471e86f 100644 --- a/DDrawCompat/Input/Input.cpp +++ b/DDrawCompat/Input/Input.cpp @@ -113,6 +113,11 @@ namespace DDraw::RealPrimarySurface::scheduleOverlayUpdate(); } + if (!g_capture->isEnabled()) + { + return 1; + } + auto cp = Input::getRelativeCursorPos(); switch (wParam) diff --git a/DDrawCompat/Overlay/ButtonControl.cpp b/DDrawCompat/Overlay/ButtonControl.cpp index 80b62be..f2ab0b8 100644 --- a/DDrawCompat/Overlay/ButtonControl.cpp +++ b/DDrawCompat/Overlay/ButtonControl.cpp @@ -13,11 +13,6 @@ namespace Overlay void ButtonControl::onLButtonDown(POINT pos) { - if (m_style & WS_DISABLED) - { - return; - } - Input::setCapture(this); onMouseMove(pos); } diff --git a/DDrawCompat/Overlay/ConfigWindow.cpp b/DDrawCompat/Overlay/ConfigWindow.cpp index f71a4b9..a3fb88f 100644 --- a/DDrawCompat/Overlay/ConfigWindow.cpp +++ b/DDrawCompat/Overlay/ConfigWindow.cpp @@ -1,6 +1,7 @@ -#include +#include #include #include +#include #include #include @@ -8,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -41,9 +43,9 @@ namespace const int CAPTION_HEIGHT = 22; const int ROW_HEIGHT = 25; - const int ROWS = 15; + const int ROWS = 16; - std::array g_settingRows = { { + std::vector g_settingRows = { { &Config::alternatePixelCenter }, { &Config::antialiasing, &D3dDdi::Device::updateAllConfig }, { &Config::bltFilter }, @@ -64,14 +66,13 @@ namespace { &Config::statsTransparency, [&]() { Gdi::GuiThread::getStatsWindow()->setAlpha(Config::statsTransparency.get()); }}, { &Config::textureFilter, &D3dDdi::Device::updateAllConfig }, { &Config::vSync } - } }; + }; } namespace Overlay { ConfigWindow::ConfigWindow() - : Window(nullptr, { 0, 0, SettingControl::TOTAL_WIDTH + ARROW_SIZE + BORDER / 2, ROWS * ROW_HEIGHT + 80 }, - WS_BORDER, Config::configTransparency.get(), Config::configHotKey.get()) + : Window(nullptr, { 0, 0, 640, 480 }, WS_BORDER, Config::configTransparency.get(), Config::configHotKey.get()) , m_buttonCount(0) , m_focus(nullptr) { @@ -81,11 +82,14 @@ namespace Overlay r = { m_rect.right - CAPTION_HEIGHT, 0, m_rect.right, CAPTION_HEIGHT }; m_captionCloseButton.reset(new ButtonControl(*this, r, "X", onClose)); - r.left = SettingControl::TOTAL_WIDTH; + r.right = m_rect.right - BORDER; + r.left = r.right - ARROW_SIZE; r.top = CAPTION_HEIGHT + BORDER; - r.right = r.left + ARROW_SIZE; r.bottom = r.top + ROWS * ROW_HEIGHT; - m_scrollBar.reset(new ScrollBarControl(*this, r, 0, g_settingRows.size() - ROWS, 0)); + + const auto settingCount = Config::configRows.get().size(); + m_scrollBar.reset(new ScrollBarControl(*this, r, 0, settingCount - ROWS, 0, + WS_VISIBLE | (settingCount < ROWS ? WS_DISABLED : 0))); addSettingControls(); @@ -110,22 +114,27 @@ namespace Overlay return std::make_unique(*this, r, label, clickHandler); } - void ConfigWindow::addSettingControl(Config::Setting& setting, SettingControl::UpdateFunc updateFunc) + void ConfigWindow::addSettingControl(Config::Setting& setting, SettingControl::UpdateFunc updateFunc, bool isReadOnly) { const int index = m_settingControls.size(); RECT rect = { 0, index * ROW_HEIGHT + BORDER, SettingControl::TOTAL_WIDTH, (index + 1) * ROW_HEIGHT + BORDER }; OffsetRect(&rect, 0, CAPTION_HEIGHT); - m_settingControls.emplace_back(*this, rect, setting, updateFunc); + m_settingControls.emplace_back(*this, rect, setting, updateFunc, isReadOnly); } void ConfigWindow::addSettingControls() { m_settingControls.clear(); - const int pos = m_scrollBar->getPos(); - for (int i = 0; i < ROWS; ++i) + const auto& configRows = Config::configRows.get(); + const unsigned pos = m_scrollBar->getPos(); + + for (int i = 0; i < ROWS && pos + i < configRows.size(); ++i) { - auto& row = g_settingRows[pos + i]; - addSettingControl(*row.setting, row.updateFunc); + const auto setting = configRows[pos + i]; + const auto it = std::find_if(g_settingRows.begin(), g_settingRows.end(), + [&](auto& settingRow) { return setting == settingRow.setting; }); + const bool isReadOnly = it == g_settingRows.end(); + addSettingControl(*setting, isReadOnly ? SettingControl::UpdateFunc() : it->updateFunc, isReadOnly); } } @@ -174,6 +183,16 @@ namespace Overlay updateButtons(); } + std::set ConfigWindow::getRwSettingNames() + { + std::set names; + for (const auto& row : g_settingRows) + { + names.insert(row.setting->getName()); + } + return names; + } + void ConfigWindow::importSettings() { for (auto& settingControl : m_settingControls) diff --git a/DDrawCompat/Overlay/ConfigWindow.h b/DDrawCompat/Overlay/ConfigWindow.h index 65450cb..54d6d16 100644 --- a/DDrawCompat/Overlay/ConfigWindow.h +++ b/DDrawCompat/Overlay/ConfigWindow.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -24,6 +25,8 @@ namespace Overlay void setFocus(SettingControl* control); void updateButtons(); + static std::set getRwSettingNames(); + private: static void onClose(Control& control); static void onExport(Control& control); @@ -33,7 +36,7 @@ namespace Overlay virtual RECT calculateRect(const RECT& monitorRect) const override; std::unique_ptr addButton(const std::string& label, ButtonControl::ClickHandler clickHandler); - void addSettingControl(Config::Setting& setting, SettingControl::UpdateFunc updateFunc); + void addSettingControl(Config::Setting& setting, SettingControl::UpdateFunc updateFunc, bool isReadOnly); void addSettingControls(); std::string constructFileContent(); void exportSettings(); diff --git a/DDrawCompat/Overlay/Control.cpp b/DDrawCompat/Overlay/Control.cpp index 9f2fed4..8f6ea4d 100644 --- a/DDrawCompat/Overlay/Control.cpp +++ b/DDrawCompat/Overlay/Control.cpp @@ -30,7 +30,9 @@ namespace Overlay void Control::drawAll(HDC dc) { + SetDCPenColor(dc, isEnabled() ? FOREGROUND_COLOR : DISABLED_COLOR); draw(dc); + SetDCPenColor(dc, FOREGROUND_COLOR); for (auto control : m_children) { @@ -145,11 +147,6 @@ namespace Overlay void Control::onMouseMove(POINT pos) { - if (m_style & WS_DISABLED) - { - return; - } - auto prevHighlightedChild = m_highlightedChild; m_highlightedChild = nullptr; propagateMouseEvent(&Control::onMouseMove, pos); @@ -171,14 +168,9 @@ namespace Overlay template void Control::propagateMouseEvent(void(Control::* onEvent)(POINT, Params...), POINT pos, Params... params) { - if (m_style & WS_DISABLED) - { - return; - } - for (auto child : m_children) { - if (PtInRect(&child->m_rect, pos)) + if (PtInRect(&child->m_rect, pos) && !(child->getStyle() & WS_DISABLED)) { (child->*onEvent)(pos, params...); return; diff --git a/DDrawCompat/Overlay/Control.h b/DDrawCompat/Overlay/Control.h index adb2d98..a2a4ad0 100644 --- a/DDrawCompat/Overlay/Control.h +++ b/DDrawCompat/Overlay/Control.h @@ -35,12 +35,13 @@ namespace Overlay RECT getRect() const { return m_rect; } const Control& getRoot() const; Control& getRoot(); + DWORD getStyle() const { return m_style; } bool isEnabled() const; bool isVisible() const { return m_style & WS_VISIBLE; } void setEnabled(bool isEnabled); protected: - static const COLORREF DISABLED_COLOR = RGB(128, 128, 128); + static const COLORREF DISABLED_COLOR = RGB(192, 192, 192); static const COLORREF FOREGROUND_COLOR = RGB(0, 255, 0); static const COLORREF HIGHLIGHT_COLOR = RGB(255, 255, 0); diff --git a/DDrawCompat/Overlay/ScrollBarControl.cpp b/DDrawCompat/Overlay/ScrollBarControl.cpp index 6fc8ad3..de5bb00 100644 --- a/DDrawCompat/Overlay/ScrollBarControl.cpp +++ b/DDrawCompat/Overlay/ScrollBarControl.cpp @@ -19,8 +19,8 @@ namespace namespace Overlay { - ScrollBarControl::ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos) - : Control(&parent, rect, WS_VISIBLE) + ScrollBarControl::ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos, DWORD style) + : Control(&parent, rect, style) , m_min(min) , m_max(std::max(min, max)) , m_pos(std::max(min, std::min(max, pos))) @@ -70,7 +70,7 @@ namespace Overlay RECT ScrollBarControl::getThumbRect() const { - const int thumbPos = (m_pos - m_min) * (m_rect.*m_right - m_rect.*m_left - 3 * ARROW_SIZE) / (m_max - m_min); + const int thumbPos = (m_pos - m_min) * (m_rect.*m_right - m_rect.*m_left - 3 * ARROW_SIZE) / std::max(m_max - m_min, 1); RECT r = m_rect; r.*m_left = m_rect.*m_left + ARROW_SIZE + thumbPos; r.*m_right = r.*m_left + ARROW_SIZE; diff --git a/DDrawCompat/Overlay/ScrollBarControl.h b/DDrawCompat/Overlay/ScrollBarControl.h index 8c814bf..ffc2e67 100644 --- a/DDrawCompat/Overlay/ScrollBarControl.h +++ b/DDrawCompat/Overlay/ScrollBarControl.h @@ -7,7 +7,7 @@ namespace Overlay class ScrollBarControl : public Control { public: - ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos); + ScrollBarControl(Control& parent, const RECT& rect, int min, int max, int pos, DWORD style = WS_VISIBLE); virtual void onLButtonDown(POINT pos) override; virtual void onLButtonUp(POINT pos) override; diff --git a/DDrawCompat/Overlay/SettingControl.cpp b/DDrawCompat/Overlay/SettingControl.cpp index 7434be8..8b37816 100644 --- a/DDrawCompat/Overlay/SettingControl.cpp +++ b/DDrawCompat/Overlay/SettingControl.cpp @@ -31,17 +31,27 @@ namespace namespace Overlay { - SettingControl::SettingControl(ConfigWindow& parent, const RECT& rect, Config::Setting& setting, UpdateFunc updateFunc) - : Control(&parent, rect, WS_VISIBLE | WS_TABSTOP) + SettingControl::SettingControl(ConfigWindow& parent, const RECT& rect, Config::Setting& setting, + UpdateFunc updateFunc, bool isReadOnly) + : Control(&parent, rect, WS_VISIBLE | WS_TABSTOP | (isReadOnly ? WS_DISABLED : 0)) , m_setting(setting) , m_updateFunc(updateFunc) , m_settingLabel(*this, { rect.left, rect.top, rect.left + SETTING_LABEL_WIDTH, rect.bottom }, setting.getName() + ':', 0) { - const RECT r = { rect.left + SETTING_LABEL_WIDTH, rect.top + BORDER / 2, + RECT r = { rect.left + SETTING_LABEL_WIDTH, rect.top + BORDER / 2, rect.left + SETTING_LABEL_WIDTH + SETTING_CONTROL_WIDTH, rect.bottom - BORDER / 2 }; - m_valueControl.reset(new ComboBoxControl(*this, r, getValueStrings(setting))); - getValueComboBox().setValue(setting.getValueStr()); - onValueChanged(); + + if (isReadOnly) + { + r.right += PARAM_LABEL_WIDTH + PARAM_CONTROL_WIDTH; + m_valueControl.reset(new LabelControl(*this, r, setting.getValueStr(), 0)); + } + else + { + m_valueControl.reset(new ComboBoxControl(*this, r, getValueStrings(setting))); + getValueComboBox().setValue(setting.getValueStr()); + onValueChanged(); + } } RECT SettingControl::getHighlightRect() const diff --git a/DDrawCompat/Overlay/SettingControl.h b/DDrawCompat/Overlay/SettingControl.h index f8ff460..3b25e01 100644 --- a/DDrawCompat/Overlay/SettingControl.h +++ b/DDrawCompat/Overlay/SettingControl.h @@ -23,12 +23,13 @@ namespace Overlay static const int PARAM_LABEL_WIDTH = 70; static const int PARAM_CONTROL_WIDTH = 241; - static const int SETTING_LABEL_WIDTH = 130; - static const int SETTING_CONTROL_WIDTH = 141; + static const int SETTING_LABEL_WIDTH = 140; + static const int SETTING_CONTROL_WIDTH = 150; static const int TOTAL_WIDTH = SETTING_LABEL_WIDTH + SETTING_CONTROL_WIDTH + PARAM_LABEL_WIDTH + PARAM_CONTROL_WIDTH + BORDER; - SettingControl(ConfigWindow& parent, const RECT& rect, Config::Setting& setting, UpdateFunc updateFunc); + SettingControl(ConfigWindow& parent, const RECT& rect, Config::Setting& setting, + UpdateFunc updateFunc, bool isReadOnly); virtual RECT getHighlightRect() const override; virtual void onLButtonDown(POINT pos) override;