This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
59 changed files
with
9,914 additions
and
971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#include "pch.h" | ||
#include "Config.h" | ||
#include "Util.h" | ||
|
||
Config::Config(std::string fileName) | ||
{ | ||
absoluteFileName = Util::DllPath().parent_path() / fileName; | ||
|
||
Reload(); | ||
} | ||
|
||
void Config::Reload() | ||
{ | ||
if (ini.LoadFile(absoluteFileName.c_str()) == SI_OK) | ||
{ | ||
// Depth | ||
DepthInverted = readBool("Depth", "DepthInverted"); | ||
|
||
// Color | ||
AutoExposure = readBool("Color", "AutoExposure"); | ||
HDR = readBool("Color", "HDR"); | ||
|
||
// MotionVectors | ||
JitterCancellation = readBool("MotionVectors", "JitterCancellation"); | ||
DisplayResolution = readBool("MotionVectors", "DisplayResolution"); | ||
|
||
// Sharpening | ||
EnableSharpening = readBool("Sharpening", "EnableSharpening"); | ||
Sharpness = readFloat("Sharpening", "Sharpness"); | ||
SharpnessRange = readSharpnessRange("Sharpening", "SharpnessRange"); | ||
|
||
//Upscale Ratio Override | ||
UpscaleRatioOverrideEnabled = readBool("UpscaleRatio", "UpscaleRatioOverrideEnabled"); | ||
UpscaleRatioOverrideValue = readFloat("UpscaleRatio", "UpscaleRatioOverrideValue"); | ||
|
||
// View | ||
Method = readViewMethod("View", "Method"); | ||
VerticalFOV = readFloat("View", "VerticalFOV"); | ||
NearPlane = readFloat("View", "NearPlane"); | ||
FarPlane = readFloat("View", "FarPlane"); | ||
} | ||
|
||
auto exeName = Util::ExePath().filename(); | ||
|
||
if (exeName == "Cyberpunk2077.exe") | ||
{ | ||
Method = Method.value_or(ViewMethod::Cyberpunk2077); | ||
} | ||
else if (exeName == "DyingLightGame_x64_rwdi.exe") | ||
{ | ||
SharpnessRange = SharpnessRange.value_or(SharpnessRangeModifier::Extended); | ||
} | ||
else if (exeName == "RDR2.exe") | ||
{ | ||
Method = Method.value_or(ViewMethod::RDR2); | ||
} | ||
} | ||
|
||
std::optional<std::string> Config::readString(std::string section, std::string key, bool lowercase) | ||
{ | ||
std::string value = ini.GetValue(section.c_str(), key.c_str(), "auto"); | ||
|
||
std::string lower = value; | ||
std::transform( | ||
lower.begin(), lower.end(), | ||
lower.begin(), | ||
[](unsigned char c) | ||
{ | ||
return std::tolower(c); | ||
} | ||
); | ||
|
||
if (lower == "auto") | ||
{ | ||
return std::nullopt; | ||
} | ||
return lowercase ? lower : value; | ||
} | ||
|
||
std::optional<float> Config::readFloat(std::string section, std::string key) | ||
{ | ||
auto value = readString(section, key); | ||
try | ||
{ | ||
return std::stof(value.value()); | ||
} | ||
catch (const std::bad_optional_access&) // missing or auto value | ||
{ | ||
return std::nullopt; | ||
} | ||
catch (const std::invalid_argument&) // invalid float string for std::stof | ||
{ | ||
return std::nullopt; | ||
} | ||
catch (const std::out_of_range&) // out of range for 32 bit float | ||
{ | ||
return std::nullopt; | ||
} | ||
} | ||
|
||
std::optional<bool> Config::readBool(std::string section, std::string key) | ||
{ | ||
auto value = readString(section, key, true); | ||
if (value == "true") | ||
{ | ||
return true; | ||
} | ||
else if (value == "false") | ||
{ | ||
return false; | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
|
||
std::optional<SharpnessRangeModifier> Config::readSharpnessRange(std::string section, std::string key) | ||
{ | ||
auto value = readString(section, key, true); | ||
if (value == "normal") | ||
{ | ||
return SharpnessRangeModifier::Normal; | ||
} | ||
else if (value == "extended") | ||
{ | ||
return SharpnessRangeModifier::Extended; | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
|
||
std::optional<ViewMethod> Config::readViewMethod(std::string section, std::string key) | ||
{ | ||
auto value = readString(section, key, true); | ||
if (value == "config") | ||
{ | ||
return ViewMethod::Config; | ||
} | ||
else if (value == "cyberpunk2077") | ||
{ | ||
return ViewMethod::Cyberpunk2077; | ||
} | ||
else if (value == "rdr2") | ||
{ | ||
return ViewMethod::RDR2; | ||
} | ||
|
||
return std::nullopt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
#include "pch.h" | ||
|
||
enum class SharpnessRangeModifier | ||
{ | ||
Normal, | ||
Extended, | ||
}; | ||
|
||
enum class ViewMethod | ||
{ | ||
Config, | ||
Cyberpunk2077, | ||
RDR2, | ||
}; | ||
|
||
class Config | ||
{ | ||
public: | ||
Config(std::string fileName); | ||
|
||
// Depth | ||
std::optional<bool> DepthInverted; | ||
|
||
// Color | ||
std::optional<bool> AutoExposure; | ||
std::optional<bool> HDR; | ||
|
||
// Motion | ||
std::optional<bool> JitterCancellation; | ||
std::optional<bool> DisplayResolution; | ||
|
||
// Sharpening | ||
std::optional<bool> EnableSharpening; | ||
std::optional<float> Sharpness; | ||
std::optional<SharpnessRangeModifier> SharpnessRange; | ||
|
||
// Upscale Ratio Override | ||
std::optional<bool> UpscaleRatioOverrideEnabled; | ||
std::optional<float> UpscaleRatioOverrideValue; | ||
|
||
// View | ||
std::optional<ViewMethod> Method; | ||
std::optional<float> VerticalFOV; | ||
std::optional<float> NearPlane; | ||
std::optional<float> FarPlane; | ||
|
||
void Reload(); | ||
|
||
private: | ||
CSimpleIniA ini; | ||
|
||
std::filesystem::path absoluteFileName; | ||
|
||
std::optional<std::string> readString(std::string section, std::string key, bool lowercase = false); | ||
std::optional<float> readFloat(std::string section, std::string key); | ||
std::optional<bool> readBool(std::string section, std::string key); | ||
std::optional<SharpnessRangeModifier> readSharpnessRange(std::string section, std::string key); | ||
std::optional<ViewMethod> readViewMethod(std::string section, std::string key); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.