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;
}
Log::Log(bool isEnabled) : m_isEnabled(isEnabled)
Log::Log(unsigned logLevel) : m_isEnabled(logLevel <= s_logLevel)
{
if (!m_isEnabled)
{
@ -69,10 +69,6 @@ namespace Compat
}
}
Log::Log(unsigned logLevel) : Log(logLevel <= s_logLevel)
{
}
Log::~Log()
{
if (m_isEnabled)
@ -148,6 +144,6 @@ namespace Compat
thread_local DWORD Log::s_indent = 0;
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;
}

View File

@ -248,7 +248,6 @@ namespace Compat
class Log
{
public:
Log(bool isEnabled);
Log(unsigned logLevel);
~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();
if (!paramInfo.name.empty())
{
return pair.first + '(' + std::to_string(paramInfo.current) + ')';
return pair.first + '(' + std::to_string(m_param) + ')';
}
return pair.first;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ namespace Config
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,10 +9,10 @@ namespace Config
class StatsColumns : public EnumListSetting
{
public:
enum Column { CUR, AVG, MIN, MAX, LABEL };
enum Values { CUR, AVG, MIN, MAX, LABEL };
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
{
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)
{
return { "Interval", 1, 16, 1, m_param };
return { "Interval", 1, 16, 1 };
}
return {};
}

View File

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

View File

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

View File

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

View File

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