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

Updated config setting parent classes

This commit is contained in:
narzoul 2023-05-21 11:22:25 +02:00
parent 324d6bd6de
commit 2e859b0918
33 changed files with 94 additions and 129 deletions

View File

@ -39,7 +39,7 @@ namespace Compat
return os; return os;
} }
Log::Log(bool isEnabled) : m_isEnabled(isEnabled) Log::Log(unsigned logLevel) : m_isEnabled(logLevel <= s_logLevel)
{ {
if (!m_isEnabled) if (!m_isEnabled)
{ {
@ -69,10 +69,6 @@ namespace Compat
} }
} }
Log::Log(unsigned logLevel) : Log(logLevel <= s_logLevel)
{
}
Log::~Log() Log::~Log()
{ {
if (m_isEnabled) if (m_isEnabled)
@ -148,6 +144,6 @@ namespace Compat
thread_local DWORD Log::s_indent = 0; thread_local DWORD Log::s_indent = 0;
bool Log::s_isLeaveLog = false; bool Log::s_isLeaveLog = false;
unsigned Log::s_logLevel = Config::Settings::LogLevel::INITIAL; unsigned Log::s_logLevel = Config::Settings::LogLevel::DEBUG;
std::ostream* Log::s_logStream = &g_initialLogStream; std::ostream* Log::s_logStream = &g_initialLogStream;
} }

View File

@ -248,7 +248,6 @@ namespace Compat
class Log class Log
{ {
public: public:
Log(bool isEnabled);
Log(unsigned logLevel); Log(unsigned logLevel);
~Log(); ~Log();

View File

@ -0,0 +1,18 @@
#pragma once
#include <Config/EnumSetting.h>
namespace Config
{
namespace Settings
{
class BoolSetting : public EnumSetting
{
public:
BoolSetting(const std::string& name, const std::string& default)
: EnumSetting(name, default, { "off", "on" })
{
}
};
}
}

View File

@ -42,7 +42,7 @@ namespace Config
const auto paramInfo = getParamInfo(); const auto paramInfo = getParamInfo();
if (!paramInfo.name.empty()) if (!paramInfo.name.empty())
{ {
return pair.first + '(' + std::to_string(paramInfo.current) + ')'; return pair.first + '(' + std::to_string(m_param) + ')';
} }
return pair.first; return pair.first;
} }

View File

@ -14,7 +14,6 @@ namespace Config
int min; int min;
int max; int max;
int default; int default;
int current;
}; };
Setting(const std::string& name, const std::string& default); Setting(const std::string& name, const std::string& default);

View File

@ -6,17 +6,13 @@ namespace Config
{ {
namespace Settings namespace Settings
{ {
class AltTabFix : public MappedSetting<UINT> class AltTabFix : public EnumSetting
{ {
public: public:
static const UINT OFF = 0; enum Values { OFF, KEEPVIDMEM };
static const UINT KEEPVIDMEM = 1;
AltTabFix() AltTabFix()
: MappedSetting("AltTabFix", "off", { : EnumSetting("AltTabFix", "off", { "off", "keepvidmem" })
{"off", OFF},
{"keepvidmem", KEEPVIDMEM}
})
{ {
} }
}; };

View File

@ -22,7 +22,7 @@ namespace Config
{ {
if (D3DDDIMULTISAMPLE_NONE != m_value) if (D3DDDIMULTISAMPLE_NONE != m_value)
{ {
return { "Quality", 0, 7, 7, m_param }; return { "Quality", 0, 7, 7 };
} }
return {}; return {};
} }

View File

@ -1,19 +1,18 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class BltFilter : public MappedSetting<UINT> class BltFilter : public EnumSetting
{ {
public: public:
static const UINT POINT = 1; enum Values { POINT, BILINEAR };
static const UINT BILINEAR = 2;
BltFilter::BltFilter() BltFilter::BltFilter()
: MappedSetting("BltFilter", "point", { {"point", POINT}, {"bilinear", BILINEAR} }) : EnumSetting("BltFilter", "point", { "point", "bilinear" })
{ {
} }
}; };

View File

@ -5,11 +5,7 @@ namespace Config
namespace Settings namespace Settings
{ {
ColorKeyMethod::ColorKeyMethod() ColorKeyMethod::ColorKeyMethod()
: MappedSetting("ColorKeyMethod", "native", { : EnumSetting("ColorKeyMethod", "native", { "none", "native", "alphatest" })
{"none", NONE},
{"native", NATIVE},
{"alphatest", ALPHATEST}
})
{ {
} }
@ -17,7 +13,7 @@ namespace Config
{ {
if (ALPHATEST == m_value) if (ALPHATEST == m_value)
{ {
return { "AlphaRef", 1, 255, 1, m_param }; return { "AlphaRef", 1, 255, 1 };
} }
return {}; return {};
} }

View File

@ -1,17 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class ColorKeyMethod : public MappedSetting<UINT> class ColorKeyMethod : public EnumSetting
{ {
public: public:
static const UINT NONE = 0; enum Values { NONE, NATIVE, ALPHATEST };
static const UINT NATIVE = 1;
static const UINT ALPHATEST = 2;
ColorKeyMethod(); ColorKeyMethod();

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <Config/EnumSetting.h> #include <Config/BoolSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class CpuAffinityRotation : public MappedSetting<bool> class CpuAffinityRotation : public BoolSetting
{ {
public: public:
CpuAffinityRotation() CpuAffinityRotation()
: MappedSetting("CpuAffinityRotation", "on", { {"off", false}, {"on", true} }) : BoolSetting("CpuAffinityRotation", "on")
{ {
} }
}; };

View File

@ -5,13 +5,7 @@ namespace Config
namespace Settings namespace Settings
{ {
DisplayFilter::DisplayFilter() DisplayFilter::DisplayFilter()
: MappedSetting("DisplayFilter", "bilinear", { : EnumSetting("DisplayFilter", "bilinear", { "point", "bilinear", "bicubic", "lanczos", "spline" })
{"point", POINT},
{"bilinear", BILINEAR},
{"bicubic", BICUBIC},
{"lanczos", LANCZOS},
{"spline", SPLINE}
})
{ {
} }
@ -21,10 +15,10 @@ namespace Config
{ {
case BILINEAR: case BILINEAR:
case BICUBIC: case BICUBIC:
return { "Blur", 0, 100, 0, m_param }; return { "Blur", 0, 100, 0 };
case LANCZOS: case LANCZOS:
case SPLINE: case SPLINE:
return { "Lobes", 2, 4, 2, m_param }; return { "Lobes", 2, 4, 2 };
default: default:
return {}; return {};
} }

View File

@ -1,19 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class DisplayFilter : public MappedSetting<UINT> class DisplayFilter : public EnumSetting
{ {
public: public:
static const UINT POINT = 0; enum Values { POINT, BILINEAR, BICUBIC, LANCZOS, SPLINE };
static const UINT BILINEAR = 1;
static const UINT BICUBIC = 2;
static const UINT LANCZOS = 3;
static const UINT SPLINE = 4;
DisplayFilter(); DisplayFilter();

View File

@ -6,15 +6,13 @@ namespace Config
{ {
namespace Settings namespace Settings
{ {
class FontAntialiasing : public MappedSetting<UINT> class FontAntialiasing : public EnumSetting
{ {
public: public:
static const UINT APP = 0; enum Values { APP, OFF, ON };
static const UINT OFF = 1;
static const UINT ON = 2;
FontAntialiasing() FontAntialiasing()
: MappedSetting("FontAntialiasing", "app", { {"app", APP}, {"off", OFF}, {"on", ON} }) : EnumSetting("FontAntialiasing", "app", { "app", "off", "on" })
{ {
} }
}; };

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <Config/EnumSetting.h> #include <Config/BoolSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class ForceD3D9On12 : public MappedSetting<bool> class ForceD3D9On12 : public BoolSetting
{ {
public: public:
ForceD3D9On12() ForceD3D9On12()
: MappedSetting("ForceD3D9On12", "off", { {"off", false}, {"on", true} }) : BoolSetting("ForceD3D9On12", "off")
{ {
} }
}; };

View File

@ -5,12 +5,7 @@ namespace Config
namespace Settings namespace Settings
{ {
FpsLimiter::FpsLimiter() FpsLimiter::FpsLimiter()
: MappedSetting("FpsLimiter", "off", { : EnumSetting("FpsLimiter", "off", { "off", "flipstart", "flipend", "msgloop" })
{"off", OFF},
{"flipstart", FLIPSTART},
{"flipend", FLIPEND},
{"msgloop", MSGLOOP}
})
{ {
} }
@ -18,7 +13,7 @@ namespace Config
{ {
if (OFF != m_value) if (OFF != m_value)
{ {
return { "MaxFPS", 10, 200, 60, m_param }; return { "MaxFPS", 10, 200, 60 };
} }
return {}; return {};
} }

View File

@ -1,18 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class FpsLimiter : public MappedSetting<UINT> class FpsLimiter : public EnumSetting
{ {
public: public:
static const UINT OFF = 0; enum Values { OFF, FLIPSTART, FLIPEND, MSGLOOP };
static const UINT FLIPSTART = 1;
static const UINT FLIPEND = 2;
static const UINT MSGLOOP = 3;
FpsLimiter(); FpsLimiter();

View File

@ -1,19 +1,19 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class FullscreenMode : public MappedSetting<UINT> class FullscreenMode : public EnumSetting
{ {
public: public:
static const UINT BORDERLESS = 0; static const UINT BORDERLESS = 0;
static const UINT EXCLUSIVE = 1; static const UINT EXCLUSIVE = 1;
FullscreenMode() FullscreenMode()
: MappedSetting("FullscreenMode", "borderless", { {"borderless", BORDERLESS}, {"exclusive", EXCLUSIVE} }) : EnumSetting("FullscreenMode", "borderless", { "borderless", "exclusive" })
{ {
} }
}; };

View File

@ -1,27 +1,24 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class LogLevel : public MappedSetting<UINT> class LogLevel : public EnumSetting
{ {
public: public:
static const UINT NONE = 0; enum Values { NONE, INFO, DEBUG };
static const UINT INFO = 1;
static const UINT DEBUG = 2;
static const UINT INITIAL = MAXUINT;
LogLevel::LogLevel() LogLevel::LogLevel()
: MappedSetting("LogLevel", : EnumSetting("LogLevel",
#ifdef _DEBUG #ifdef _DEBUG
"debug", "debug",
#else #else
"info", "info",
#endif #endif
{ {"none", NONE}, {"info", INFO}, {"debug", DEBUG} }) { "none", "info", "debug" })
{ {
} }
}; };

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <Config/EnumSetting.h> #include <Config/BoolSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class PalettizedTextures : public MappedSetting<bool> class PalettizedTextures : public BoolSetting
{ {
public: public:
PalettizedTextures() PalettizedTextures()
: MappedSetting("PalettizedTextures", "on", { {"off", false}, {"on", true} }) : BoolSetting("PalettizedTextures", "on")
{ {
} }
}; };

View File

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <Config/EnumSetting.h> #include <Config/BoolSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class RemoveBorders : public MappedSetting<bool> class RemoveBorders : public BoolSetting
{ {
public: public:
RemoveBorders() RemoveBorders()
: MappedSetting("RemoveBorders", "off", { {"off", false}, {"on", true} }) : BoolSetting("RemoveBorders", "off")
{ {
} }
}; };

View File

@ -23,7 +23,7 @@ namespace Config
Setting::ParamInfo ResolutionScale::getParamInfo() const Setting::ParamInfo ResolutionScale::getParamInfo() const
{ {
return { "Multiplier", APP == m_value ? 1 : -16, 16, 1, m_param }; return { "Multiplier", APP == m_value ? 1 : -16, 16, 1 };
} }
void ResolutionScale::setValue(const std::string& value) void ResolutionScale::setValue(const std::string& value)

View File

@ -1,19 +1,19 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class ResolutionScaleFilter : public MappedSetting<UINT> class ResolutionScaleFilter : public EnumSetting
{ {
public: public:
static const UINT POINT = 0; static const UINT POINT = 0;
static const UINT BILINEAR = 1; static const UINT BILINEAR = 1;
ResolutionScaleFilter::ResolutionScaleFilter() ResolutionScaleFilter::ResolutionScaleFilter()
: MappedSetting("ResolutionScaleFilter", "point", { {"point", POINT}, {"bilinear", BILINEAR} }) : EnumSetting("ResolutionScaleFilter", "point", { "point", "bilinear" })
{ {
} }
}; };

View File

@ -5,12 +5,7 @@ namespace Config
namespace Settings namespace Settings
{ {
SpriteDetection::SpriteDetection() SpriteDetection::SpriteDetection()
: MappedSetting("SpriteDetection", "off", { : EnumSetting("SpriteDetection", "off", { "off", "zconst", "zmax", "point" })
{"off", OFF},
{"zconst", ZCONST},
{"zmax", ZMAX},
{"point", POINT}
})
{ {
} }
@ -18,7 +13,7 @@ namespace Config
{ {
if (ZMAX == m_value) if (ZMAX == m_value)
{ {
return { "ZMax", 0, 100, 0, m_param }; return { "ZMax", 0, 100, 0 };
} }
return {}; return {};
} }

View File

@ -1,18 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class SpriteDetection : public MappedSetting<UINT> class SpriteDetection : public EnumSetting
{ {
public: public:
static const UINT OFF = 0; enum Values { OFF, ZCONST, ZMAX, POINT };
static const UINT ZCONST = 1;
static const UINT ZMAX = 2;
static const UINT POINT = 3;
SpriteDetection(); SpriteDetection();

View File

@ -5,11 +5,7 @@ namespace Config
namespace Settings namespace Settings
{ {
SpriteTexCoord::SpriteTexCoord() SpriteTexCoord::SpriteTexCoord()
: MappedSetting("SpriteTexCoord", "app", { : EnumSetting("SpriteTexCoord", "app", { "app", "clamp", "clampall", "round" })
{"app", APP},
{"clamp", CLAMP},
{"clampall", CLAMPALL},
{"round", ROUND}})
{ {
} }
@ -17,7 +13,7 @@ namespace Config
{ {
if (ROUND == m_value) if (ROUND == m_value)
{ {
return { "Offset", -50, 50, 0, m_param }; return { "Offset", -50, 50, 0 };
} }
return {}; return {};
} }

View File

@ -1,18 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class SpriteTexCoord : public MappedSetting<UINT> class SpriteTexCoord : public EnumSetting
{ {
public: public:
static const UINT APP = 0; enum Values { APP, CLAMP, CLAMPALL, ROUND };
static const UINT CLAMP = 1;
static const UINT CLAMPALL = 2;
static const UINT ROUND = 3;
SpriteTexCoord(); SpriteTexCoord();

View File

@ -9,10 +9,10 @@ namespace Config
class StatsColumns : public EnumListSetting class StatsColumns : public EnumListSetting
{ {
public: public:
enum Column { CUR, AVG, MIN, MAX, LABEL }; enum Values { CUR, AVG, MIN, MAX, LABEL };
StatsColumns() StatsColumns()
: EnumListSetting("StatsColumns", "label, cur, avg, min, max", { "cur", "avg", "min", "max", "label"}) : EnumListSetting("StatsColumns", "label, cur, avg, min, max", { "cur", "avg", "min", "max", "label" })
{ {
} }
}; };

View File

@ -8,7 +8,7 @@ namespace Config
namespace Settings namespace Settings
{ {
VSync::VSync() VSync::VSync()
: MappedSetting("VSync", "app", { {"app", APP}, {"off", OFF}, {"on", ON} }) : EnumSetting("VSync", "app", { "app", "off", "on" })
{ {
} }
@ -16,7 +16,7 @@ namespace Config
{ {
if (ON == m_value) if (ON == m_value)
{ {
return { "Interval", 1, 16, 1, m_param }; return { "Interval", 1, 16, 1 };
} }
return {}; return {};
} }

View File

@ -1,17 +1,15 @@
#pragma once #pragma once
#include <Config/MappedSetting.h> #include <Config/EnumSetting.h>
namespace Config namespace Config
{ {
namespace Settings namespace Settings
{ {
class VSync : public MappedSetting<int> class VSync : public EnumSetting
{ {
public: public:
static const int APP = -1; enum Values { APP, OFF, ON };
static const int OFF = 0;
static const int ON = 1;
VSync(); VSync();

View File

@ -27,7 +27,7 @@ namespace Config
{ {
if (0 != m_value.version) if (0 != m_value.version)
{ {
return { "SP", 0, 5, 0, m_param }; return { "SP", 0, 5, 0 };
} }
return {}; return {};
} }

View File

@ -153,6 +153,7 @@
<ClInclude Include="Common\Hook.h" /> <ClInclude Include="Common\Hook.h" />
<ClInclude Include="Common\ScopedCriticalSection.h" /> <ClInclude Include="Common\ScopedCriticalSection.h" />
<ClInclude Include="Common\Time.h" /> <ClInclude Include="Common\Time.h" />
<ClInclude Include="Config\BoolSetting.h" />
<ClInclude Include="Config\EnumListSetting.h" /> <ClInclude Include="Config\EnumListSetting.h" />
<ClInclude Include="Config\EnumSetting.h" /> <ClInclude Include="Config\EnumSetting.h" />
<ClInclude Include="Config\FormatListSetting.h" /> <ClInclude Include="Config\FormatListSetting.h" />

View File

@ -672,6 +672,9 @@
<ClInclude Include="Config\EnumListSetting.h"> <ClInclude Include="Config\EnumListSetting.h">
<Filter>Header Files\Config</Filter> <Filter>Header Files\Config</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Config\BoolSetting.h">
<Filter>Header Files\Config</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Gdi\Gdi.cpp"> <ClCompile Include="Gdi\Gdi.cpp">