1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Added ConfigRows setting

This commit is contained in:
narzoul 2023-07-08 15:55:15 +02:00
parent 6f17e17bf9
commit dbb2a0c4f1
21 changed files with 317 additions and 99 deletions

View File

@ -5,6 +5,7 @@
#include <Config/Settings/BltFilter.h>
#include <Config/Settings/ColorKeyMethod.h>
#include <Config/Settings/ConfigHotKey.h>
#include <Config/Settings/ConfigRows.h>
#include <Config/Settings/ConfigTransparency.h>
#include <Config/Settings/CpuAffinity.h>
#include <Config/Settings/CpuAffinityRotation.h>
@ -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;

View File

@ -7,14 +7,6 @@
namespace
{
void append(std::vector<D3DDDIFORMAT>& 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<D3DDDIFORMAT>& allowedFormats,
const std::map<std::string, std::vector<D3DDDIFORMAT>>& allowedGroups,
const std::map<std::string, std::set<D3DDDIFORMAT>>& 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<D3DDDIFORMAT> formats;
for (auto formatName : values)
{
if ("all" == formatName)
{
throw ParsingError("'all' cannot be combined with other values");
}
std::set<D3DDDIFORMAT> formats;
std::set<std::string> 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<std::string> 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<const D3DDDIFORMAT*>(formatName.c_str()));
auto fourCC = *reinterpret_cast<const D3DDDIFORMAT*>(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);
}
}

View File

@ -2,7 +2,6 @@
#include <map>
#include <set>
#include <vector>
#include <d3d.h>
#include <d3dumddi.h>
@ -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<D3DDDIFORMAT>& allowedFormats,
const std::map<std::string, std::vector<D3DDDIFORMAT>>& allowedGroups,
const std::map<std::string, std::set<D3DDDIFORMAT>>& allowedGroups,
bool allowFourCCs);
virtual std::string getValueStr() const override;
virtual void setValues(const std::vector<std::string>& values) override;
private:
const std::set<D3DDDIFORMAT> m_allowedFormats;
const std::map<std::string, std::vector<D3DDDIFORMAT>> m_allowedGroups;
std::vector<D3DDDIFORMAT> m_formats;
const std::map<std::string, std::set<D3DDDIFORMAT>> m_allowedGroups;
std::set<D3DDDIFORMAT> m_formats;
std::string m_valueStr;
const bool m_allowFourCCs;
};
}

View File

@ -1,6 +1,5 @@
#include <fstream>
#include <locale>
#include <map>
#include <Common/Log.h>
#include <Common/Path.h>
@ -13,12 +12,6 @@ namespace
void setConfig(const std::string& name, const std::string& value, const std::string& source);
auto& getSettings()
{
static std::map<std::string, Config::Setting&> 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('(');

View File

@ -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);

View File

@ -1,6 +1,15 @@
#include <Config/Parser.h>
#include <Config/Setting.h>
namespace
{
std::map<std::string, Config::Setting&>& getSettings()
{
static std::map<std::string, Config::Setting&> 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<std::string, Setting&>& 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;
}
}

View File

@ -1,5 +1,6 @@
#pragma once
#include <map>
#include <string>
#include <vector>
@ -53,4 +54,7 @@ namespace Config
std::string m_baseValue;
std::string m_exportedValue;
};
const std::map<std::string, Setting&>& getAllSettings();
Setting* getSetting(const std::string& name);
}

View File

@ -0,0 +1,123 @@
#include <algorithm>
#include <Config/Parser.h>
#include <Config/Settings/ConfigRows.h>
#include <Overlay/ConfigWindow.h>
namespace
{
template <typename T>
void append(std::vector<T>& 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<Config::Setting*>& settings)
{
const auto& allSettings = Config::getAllSettings();
for (const auto& setting : allSettings)
{
append(settings, &setting.second);
}
}
void appendAllRo(std::vector<Config::Setting*>& 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<Config::Setting*>& 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<std::string>& values)
{
std::set<std::string> groups;
std::vector<Setting*> settings;
std::vector<std::string> 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);
}
}
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <string>
#include <vector>
#include <Config/ListSetting.h>
namespace Config
{
namespace Settings
{
class ConfigRows : public ListSetting
{
public:
ConfigRows();
virtual std::string getValueStr() const override;
const std::vector<Setting*>& get() const { return m_settings; }
private:
void setValues(const std::vector<std::string>& values) override;
std::vector<Setting*> m_settings;
std::string m_valueStr;
};
}
extern Settings::ConfigRows configRows;
}

View File

@ -170,6 +170,7 @@
<ClInclude Include="Config\Settings\BltFilter.h" />
<ClInclude Include="Config\Settings\ColorKeyMethod.h" />
<ClInclude Include="Config\Settings\ConfigHotKey.h" />
<ClInclude Include="Config\Settings\ConfigRows.h" />
<ClInclude Include="Config\Settings\ConfigTransparency.h" />
<ClInclude Include="Config\Settings\CpuAffinity.h" />
<ClInclude Include="Config\Settings\CpuAffinityRotation.h" />
@ -347,6 +348,7 @@
<ClCompile Include="Config\Setting.cpp" />
<ClCompile Include="Config\Settings\Antialiasing.cpp" />
<ClCompile Include="Config\Settings\ColorKeyMethod.cpp" />
<ClCompile Include="Config\Settings\ConfigRows.cpp" />
<ClCompile Include="Config\Settings\CpuAffinity.cpp" />
<ClCompile Include="Config\Settings\DesktopResolution.cpp" />
<ClCompile Include="Config\Settings\DisplayAspectRatio.cpp" />

View File

@ -699,6 +699,9 @@
<ClInclude Include="Config\Settings\StatsTransparency.h">
<Filter>Header Files\Config\Settings</Filter>
</ClInclude>
<ClInclude Include="Config\Settings\ConfigRows.h">
<Filter>Header Files\Config\Settings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Gdi\Gdi.cpp">
@ -1091,6 +1094,9 @@
<ClCompile Include="Config\EnumListSetting.cpp">
<Filter>Source Files\Config</Filter>
</ClCompile>
<ClCompile Include="Config\Settings\ConfigRows.cpp">
<Filter>Source Files\Config\Settings</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DDrawCompat.rc">

View File

@ -113,6 +113,11 @@ namespace
DDraw::RealPrimarySurface::scheduleOverlayUpdate();
}
if (!g_capture->isEnabled())
{
return 1;
}
auto cp = Input::getRelativeCursorPos();
switch (wParam)

View File

@ -13,11 +13,6 @@ namespace Overlay
void ButtonControl::onLButtonDown(POINT pos)
{
if (m_style & WS_DISABLED)
{
return;
}
Input::setCapture(this);
onMouseMove(pos);
}

View File

@ -1,6 +1,7 @@
#include <array>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <Common/Log.h>
#include <Config/Settings/AlternatePixelCenter.h>
@ -8,6 +9,7 @@
#include <Config/Settings/BltFilter.h>
#include <Config/Settings/ColorKeyMethod.h>
#include <Config/Settings/ConfigHotKey.h>
#include <Config/Settings/ConfigRows.h>
#include <Config/Settings/ConfigTransparency.h>
#include <Config/Settings/DepthFormat.h>
#include <Config/Settings/DisplayFilter.h>
@ -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<SettingRow, 20> g_settingRows = { {
std::vector<SettingRow> 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<ButtonControl>(*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<std::string> ConfigWindow::getRwSettingNames()
{
std::set<std::string> names;
for (const auto& row : g_settingRows)
{
names.insert(row.setting->getName());
}
return names;
}
void ConfigWindow::importSettings()
{
for (auto& settingControl : m_settingControls)

View File

@ -2,6 +2,7 @@
#include <list>
#include <memory>
#include <set>
#include <string>
#include <Overlay/ButtonControl.h>
@ -24,6 +25,8 @@ namespace Overlay
void setFocus(SettingControl* control);
void updateButtons();
static std::set<std::string> 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<ButtonControl> 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();

View File

@ -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 <typename... Params>
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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;