diff --git a/DDrawCompat/Common/Log.cpp b/DDrawCompat/Common/Log.cpp index c13ca69..873608f 100644 --- a/DDrawCompat/Common/Log.cpp +++ b/DDrawCompat/Common/Log.cpp @@ -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; } diff --git a/DDrawCompat/Common/Log.h b/DDrawCompat/Common/Log.h index 36af951..26e3103 100644 --- a/DDrawCompat/Common/Log.h +++ b/DDrawCompat/Common/Log.h @@ -248,7 +248,6 @@ namespace Compat class Log { public: - Log(bool isEnabled); Log(unsigned logLevel); ~Log(); diff --git a/DDrawCompat/Config/BoolSetting.h b/DDrawCompat/Config/BoolSetting.h new file mode 100644 index 0000000..03c1822 --- /dev/null +++ b/DDrawCompat/Config/BoolSetting.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class BoolSetting : public EnumSetting + { + public: + BoolSetting(const std::string& name, const std::string& default) + : EnumSetting(name, default, { "off", "on" }) + { + } + }; + } +} diff --git a/DDrawCompat/Config/MappedSetting.h b/DDrawCompat/Config/MappedSetting.h index 7808293..3c9cf04 100644 --- a/DDrawCompat/Config/MappedSetting.h +++ b/DDrawCompat/Config/MappedSetting.h @@ -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; } diff --git a/DDrawCompat/Config/Setting.h b/DDrawCompat/Config/Setting.h index e472d7a..1d924ff 100644 --- a/DDrawCompat/Config/Setting.h +++ b/DDrawCompat/Config/Setting.h @@ -14,7 +14,6 @@ namespace Config int min; int max; int default; - int current; }; Setting(const std::string& name, const std::string& default); diff --git a/DDrawCompat/Config/Settings/AltTabFix.h b/DDrawCompat/Config/Settings/AltTabFix.h index 6d3f460..15205d2 100644 --- a/DDrawCompat/Config/Settings/AltTabFix.h +++ b/DDrawCompat/Config/Settings/AltTabFix.h @@ -6,17 +6,13 @@ namespace Config { namespace Settings { - class AltTabFix : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/Antialiasing.cpp b/DDrawCompat/Config/Settings/Antialiasing.cpp index 3c051b2..11707f7 100644 --- a/DDrawCompat/Config/Settings/Antialiasing.cpp +++ b/DDrawCompat/Config/Settings/Antialiasing.cpp @@ -22,7 +22,7 @@ namespace Config { if (D3DDDIMULTISAMPLE_NONE != m_value) { - return { "Quality", 0, 7, 7, m_param }; + return { "Quality", 0, 7, 7 }; } return {}; } diff --git a/DDrawCompat/Config/Settings/BltFilter.h b/DDrawCompat/Config/Settings/BltFilter.h index 09231aa..468c6e7 100644 --- a/DDrawCompat/Config/Settings/BltFilter.h +++ b/DDrawCompat/Config/Settings/BltFilter.h @@ -1,19 +1,18 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class BltFilter : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/ColorKeyMethod.cpp b/DDrawCompat/Config/Settings/ColorKeyMethod.cpp index b49d2a5..fcb0ca9 100644 --- a/DDrawCompat/Config/Settings/ColorKeyMethod.cpp +++ b/DDrawCompat/Config/Settings/ColorKeyMethod.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/ColorKeyMethod.h b/DDrawCompat/Config/Settings/ColorKeyMethod.h index 35d069d..59ca08b 100644 --- a/DDrawCompat/Config/Settings/ColorKeyMethod.h +++ b/DDrawCompat/Config/Settings/ColorKeyMethod.h @@ -1,17 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class ColorKeyMethod : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/CpuAffinityRotation.h b/DDrawCompat/Config/Settings/CpuAffinityRotation.h index 469d723..5a71502 100644 --- a/DDrawCompat/Config/Settings/CpuAffinityRotation.h +++ b/DDrawCompat/Config/Settings/CpuAffinityRotation.h @@ -1,16 +1,16 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class CpuAffinityRotation : public MappedSetting + class CpuAffinityRotation : public BoolSetting { public: CpuAffinityRotation() - : MappedSetting("CpuAffinityRotation", "on", { {"off", false}, {"on", true} }) + : BoolSetting("CpuAffinityRotation", "on") { } }; diff --git a/DDrawCompat/Config/Settings/DisplayFilter.cpp b/DDrawCompat/Config/Settings/DisplayFilter.cpp index 84273d8..6f25220 100644 --- a/DDrawCompat/Config/Settings/DisplayFilter.cpp +++ b/DDrawCompat/Config/Settings/DisplayFilter.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/DisplayFilter.h b/DDrawCompat/Config/Settings/DisplayFilter.h index ee3f57f..6d8228e 100644 --- a/DDrawCompat/Config/Settings/DisplayFilter.h +++ b/DDrawCompat/Config/Settings/DisplayFilter.h @@ -1,19 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class DisplayFilter : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/FontAntialiasing.h b/DDrawCompat/Config/Settings/FontAntialiasing.h index d05487d..2cca69a 100644 --- a/DDrawCompat/Config/Settings/FontAntialiasing.h +++ b/DDrawCompat/Config/Settings/FontAntialiasing.h @@ -6,15 +6,13 @@ namespace Config { namespace Settings { - class FontAntialiasing : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/ForceD3D9On12.h b/DDrawCompat/Config/Settings/ForceD3D9On12.h index 28a1ad0..f1db1c0 100644 --- a/DDrawCompat/Config/Settings/ForceD3D9On12.h +++ b/DDrawCompat/Config/Settings/ForceD3D9On12.h @@ -1,16 +1,16 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class ForceD3D9On12 : public MappedSetting + class ForceD3D9On12 : public BoolSetting { public: ForceD3D9On12() - : MappedSetting("ForceD3D9On12", "off", { {"off", false}, {"on", true} }) + : BoolSetting("ForceD3D9On12", "off") { } }; diff --git a/DDrawCompat/Config/Settings/FpsLimiter.cpp b/DDrawCompat/Config/Settings/FpsLimiter.cpp index 88e9428..0af9a2b 100644 --- a/DDrawCompat/Config/Settings/FpsLimiter.cpp +++ b/DDrawCompat/Config/Settings/FpsLimiter.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/FpsLimiter.h b/DDrawCompat/Config/Settings/FpsLimiter.h index 38a5d6a..a27a082 100644 --- a/DDrawCompat/Config/Settings/FpsLimiter.h +++ b/DDrawCompat/Config/Settings/FpsLimiter.h @@ -1,18 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class FpsLimiter : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/FullscreenMode.h b/DDrawCompat/Config/Settings/FullscreenMode.h index 7522f5c..9a4f2b4 100644 --- a/DDrawCompat/Config/Settings/FullscreenMode.h +++ b/DDrawCompat/Config/Settings/FullscreenMode.h @@ -1,19 +1,19 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class FullscreenMode : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/LogLevel.h b/DDrawCompat/Config/Settings/LogLevel.h index a41181a..96191c8 100644 --- a/DDrawCompat/Config/Settings/LogLevel.h +++ b/DDrawCompat/Config/Settings/LogLevel.h @@ -1,27 +1,24 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class LogLevel : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/PalettizedTextures.h b/DDrawCompat/Config/Settings/PalettizedTextures.h index 7b37d41..d403dc0 100644 --- a/DDrawCompat/Config/Settings/PalettizedTextures.h +++ b/DDrawCompat/Config/Settings/PalettizedTextures.h @@ -1,16 +1,16 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class PalettizedTextures : public MappedSetting + class PalettizedTextures : public BoolSetting { public: PalettizedTextures() - : MappedSetting("PalettizedTextures", "on", { {"off", false}, {"on", true} }) + : BoolSetting("PalettizedTextures", "on") { } }; diff --git a/DDrawCompat/Config/Settings/RemoveBorders.h b/DDrawCompat/Config/Settings/RemoveBorders.h index c5536e9..3d1d08a 100644 --- a/DDrawCompat/Config/Settings/RemoveBorders.h +++ b/DDrawCompat/Config/Settings/RemoveBorders.h @@ -1,16 +1,16 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class RemoveBorders : public MappedSetting + class RemoveBorders : public BoolSetting { public: RemoveBorders() - : MappedSetting("RemoveBorders", "off", { {"off", false}, {"on", true} }) + : BoolSetting("RemoveBorders", "off") { } }; diff --git a/DDrawCompat/Config/Settings/ResolutionScale.cpp b/DDrawCompat/Config/Settings/ResolutionScale.cpp index 37e4633..42edc70 100644 --- a/DDrawCompat/Config/Settings/ResolutionScale.cpp +++ b/DDrawCompat/Config/Settings/ResolutionScale.cpp @@ -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) diff --git a/DDrawCompat/Config/Settings/ResolutionScaleFilter.h b/DDrawCompat/Config/Settings/ResolutionScaleFilter.h index b9a4ab1..065261f 100644 --- a/DDrawCompat/Config/Settings/ResolutionScaleFilter.h +++ b/DDrawCompat/Config/Settings/ResolutionScaleFilter.h @@ -1,19 +1,19 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class ResolutionScaleFilter : public MappedSetting + 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" }) { } }; diff --git a/DDrawCompat/Config/Settings/SpriteDetection.cpp b/DDrawCompat/Config/Settings/SpriteDetection.cpp index 9d091fc..059a0ac 100644 --- a/DDrawCompat/Config/Settings/SpriteDetection.cpp +++ b/DDrawCompat/Config/Settings/SpriteDetection.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/SpriteDetection.h b/DDrawCompat/Config/Settings/SpriteDetection.h index ccb72c1..5042ba9 100644 --- a/DDrawCompat/Config/Settings/SpriteDetection.h +++ b/DDrawCompat/Config/Settings/SpriteDetection.h @@ -1,18 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class SpriteDetection : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/SpriteTexCoord.cpp b/DDrawCompat/Config/Settings/SpriteTexCoord.cpp index 4e2e974..35244d6 100644 --- a/DDrawCompat/Config/Settings/SpriteTexCoord.cpp +++ b/DDrawCompat/Config/Settings/SpriteTexCoord.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/SpriteTexCoord.h b/DDrawCompat/Config/Settings/SpriteTexCoord.h index 5142c8a..7bea41d 100644 --- a/DDrawCompat/Config/Settings/SpriteTexCoord.h +++ b/DDrawCompat/Config/Settings/SpriteTexCoord.h @@ -1,18 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class SpriteTexCoord : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/StatsColumns.h b/DDrawCompat/Config/Settings/StatsColumns.h index 436d8ef..f407c7f 100644 --- a/DDrawCompat/Config/Settings/StatsColumns.h +++ b/DDrawCompat/Config/Settings/StatsColumns.h @@ -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" }) { } }; diff --git a/DDrawCompat/Config/Settings/VSync.cpp b/DDrawCompat/Config/Settings/VSync.cpp index f3f3777..418adce 100644 --- a/DDrawCompat/Config/Settings/VSync.cpp +++ b/DDrawCompat/Config/Settings/VSync.cpp @@ -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 {}; } diff --git a/DDrawCompat/Config/Settings/VSync.h b/DDrawCompat/Config/Settings/VSync.h index 787e4be..10e235f 100644 --- a/DDrawCompat/Config/Settings/VSync.h +++ b/DDrawCompat/Config/Settings/VSync.h @@ -1,17 +1,15 @@ #pragma once -#include +#include namespace Config { namespace Settings { - class VSync : public MappedSetting + 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(); diff --git a/DDrawCompat/Config/Settings/WinVersionLie.cpp b/DDrawCompat/Config/Settings/WinVersionLie.cpp index eaac0c8..1bb60bd 100644 --- a/DDrawCompat/Config/Settings/WinVersionLie.cpp +++ b/DDrawCompat/Config/Settings/WinVersionLie.cpp @@ -27,7 +27,7 @@ namespace Config { if (0 != m_value.version) { - return { "SP", 0, 5, 0, m_param }; + return { "SP", 0, 5, 0 }; } return {}; } diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 55bea6f..a964bc4 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -153,6 +153,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index c649937..0963d13 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -672,6 +672,9 @@ Header Files\Config + + Header Files\Config +