[MousePointerCrosshairs]Added a fixed length option (#27471)

* #19638 Added the option to Mouse Crosshairs to fix the lengths of the crosshairs. Some discussion about design in the issue but currently implemented as a configuration toggle and separate length input.

* Fixed crosshairs fixed lengthed enabled not being read on view model initialization
This commit is contained in:
Epp-code
2023-07-19 07:24:47 -07:00
committed by GitHub
parent e44d63451f
commit 1f44085e41
7 changed files with 149 additions and 17 deletions

View File

@@ -18,6 +18,8 @@ namespace
const wchar_t JSON_KEY_CROSSHAIRS_BORDER_COLOR[] = L"crosshairs_border_color";
const wchar_t JSON_KEY_CROSSHAIRS_BORDER_SIZE[] = L"crosshairs_border_size";
const wchar_t JSON_KEY_CROSSHAIRS_AUTO_HIDE[] = L"crosshairs_auto_hide";
const wchar_t JSON_KEY_CROSSHAIRS_IS_FIXED_LENGTH_ENABLED[] = L"crosshairs_is_fixed_length_enabled";
const wchar_t JSON_KEY_CROSSHAIRS_FIXED_LENGTH[] = L"crosshairs_fixed_length";
}
extern "C" IMAGE_DOS_HEADER __ImageBase;
@@ -341,6 +343,35 @@ public:
{
Logger::warn("Failed to initialize auto hide from settings. Will use default value");
}
try
{
// Parse whether the fixed length is enabled
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_IS_FIXED_LENGTH_ENABLED);
bool value = jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
inclusiveCrosshairsSettings.crosshairsIsFixedLengthEnabled = value;
}
catch (...)
{
Logger::warn("Failed to initialize fixed length enabled from settings. Will use default value");
}
try
{
// Parse fixed length
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_FIXED_LENGTH);
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
if (value >= 0)
{
inclusiveCrosshairsSettings.crosshairsFixedLength = value;
}
else
{
throw;
}
}
catch (...)
{
Logger::warn("Failed to initialize fixed length from settings. Will use default value");
}
}
else
{