Skip to content

Commit

Permalink
Use Mile.Json utility functions to simplify ConfigurationManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Apr 26, 2024
1 parent 57897ba commit f4fa476
Showing 1 changed file with 48 additions and 99 deletions.
147 changes: 48 additions & 99 deletions NanaBox/ConfigurationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,105 +810,54 @@ void NanaBox::DeserializeKeyboardConfiguration(
nlohmann::json const& Input,
NanaBox::KeyboardConfiguration& Output)
{
try
{
Output.RedirectKeyCombinations =
Input.at("RedirectKeyCombinations").get<bool>();
}
catch (...)
{

}

try
{
Output.FullScreenHotkey =
Input.at("FullScreenHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.CtrlEscHotkey =
Input.at("CtrlEscHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.AltEscHotkey =
Input.at("AltEscHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.AltTabHotkey =
Input.at("AltTabHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.AltShiftTabHotkey =
Input.at("AltShiftTabHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.AltSpaceHotkey =
Input.at("AltSpaceHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.CtrlAltDelHotkey =
Input.at("CtrlAltDelHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.FocusReleaseLeftHotkey =
Input.at("FocusReleaseLeftHotkey").get<std::int32_t>();
}
catch (...)
{

}

try
{
Output.FocusReleaseRightHotkey =
Input.at("FocusReleaseRightHotkey").get<std::int32_t>();
}
catch (...)
{

}
Output.RedirectKeyCombinations = Mile::Json::ToBoolean(
Mile::Json::GetSubKey(Input, "RedirectKeyCombinations"),
Output.RedirectKeyCombinations);

Output.FullScreenHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "FullScreenHotkey"),
Output.FullScreenHotkey));

Output.CtrlEscHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "CtrlEscHotkey"),
Output.CtrlEscHotkey));

Output.AltEscHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "AltEscHotkey"),
Output.AltEscHotkey));

Output.AltTabHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "AltTabHotkey"),
Output.AltTabHotkey));

Output.AltShiftTabHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "AltShiftTabHotkey"),
Output.AltShiftTabHotkey));

Output.AltSpaceHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "AltSpaceHotkey"),
Output.AltSpaceHotkey));

Output.CtrlAltDelHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "CtrlAltDelHotkey"),
Output.CtrlAltDelHotkey));

Output.FocusReleaseLeftHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "FocusReleaseLeftHotkey"),
Output.FocusReleaseLeftHotkey));

Output.FocusReleaseRightHotkey =
static_cast<std::int32_t>(Mile::Json::ToInt64(
Mile::Json::GetSubKey(Input, "FocusReleaseRightHotkey"),
Output.FocusReleaseRightHotkey));
}

nlohmann::json NanaBox::SerializeKeyboardConfiguration(
Expand Down

0 comments on commit f4fa476

Please sign in to comment.