diff --git a/Settings.h b/Settings.h index 53381c5..8f5cc5f 100644 --- a/Settings.h +++ b/Settings.h @@ -28,7 +28,7 @@ class Settings { public: struct SettingsObject { - int killproofKey; + WPARAM killproofKey; bool hidePrivateAccount; bool showKillproof; std::string blockedDataText; diff --git a/SettingsUI.cpp b/SettingsUI.cpp index 7315792..ca3aec3 100644 --- a/SettingsUI.cpp +++ b/SettingsUI.cpp @@ -11,42 +11,17 @@ SettingsUI settingsUI; -SettingsUI::SettingsUI() { - // set all buffer to the values from Settings - - int killProofKey = settings.getKillProofKey(); - // copy in the string represantation of the key ID - strcpy_s(shortcut, std::to_string(killProofKey).c_str()); - // convert virtual key to vsc key - UINT vscKey = MapVirtualKeyA(killProofKey, MAPVK_VK_TO_VSC); - // get the name representation of the key - GetKeyNameTextA((vscKey << 16), shortCutRealName, 32); -} - void SettingsUI::draw() { - // Setting to select, which key is used to open the killproofs menu (will also close it) - ImGui::Text(lang.translate(LangKey::SettingsShortcutText).c_str()); - ImGui::SameLine(); - ImGui::PushItemWidth(30); - if (ImGui::InputText("##shortcut", shortcut, 64)) { - try { - const int keyId = std::stoi(shortcut); - settings.settings.killproofKey = keyId; - // convert virtual key to vsc key - UINT vscKey = MapVirtualKeyA(keyId, MAPVK_VK_TO_VSC); - // get the name representation of the key - GetKeyNameTextA((vscKey << 16), shortCutRealName, 32); - } - catch ([[maybe_unused]] const std::invalid_argument& e) { + if (ImGui::IsWindowAppearing()) { + std::string killproofKey = std::to_string(settings.getKillProofKey()); + memset(shortcut, 0, sizeof(shortcut)); + killproofKey.copy(shortcut, killproofKey.size()); - } - catch ([[maybe_unused]] const std::out_of_range& e) { - - } + cofferValue = settings.settings.cofferValue; } - ImGui::PopItemWidth(); - ImGui::SameLine(); - ImGui::TextUnformatted(shortCutRealName); + + // Setting to select, which key is used to open the killproofs menu (will also close it) + ImGuiEx::KeyInput(lang.translate(LangKey::SettingsShortcutText).c_str(), "##shortcut", shortcut, sizeof(shortcut), settings.settings.killproofKey); ImGui::Checkbox(lang.translate(LangKey::SettingsDisableESCText).c_str(), &settings.settings.disableEscClose); if (ImGui::InputInt(lang.translate(LangKey::SettingsCofferValue).c_str(), &cofferValue)) { diff --git a/SettingsUI.h b/SettingsUI.h index 1acd566..cfdd501 100644 --- a/SettingsUI.h +++ b/SettingsUI.h @@ -4,11 +4,10 @@ class SettingsUI { char shortcut[64]{}; - char shortCutRealName[32]{}; int cofferValue = settings.settings.cofferValue; public: - SettingsUI(); + SettingsUI() = default; void draw(); }; diff --git a/killproof_me.rc b/killproof_me.rc index bf8f6bb..a269c7e 100644 --- a/killproof_me.rc +++ b/killproof_me.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,6,1,12 - PRODUCTVERSION 2,6,1,12 + FILEVERSION 2,6,1,14 + PRODUCTVERSION 2,6,1,14 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -41,12 +41,12 @@ BEGIN BEGIN BLOCK "000004b0" BEGIN - VALUE "FileVersion", "2.6.1.12" + VALUE "FileVersion", "2.6.1.14" VALUE "InternalName", "d3d9_arcdps_killproof_me.dll" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "d3d9_arcdps_killproof_me.dll" VALUE "ProductName", "killproof.me-plugin" - VALUE "ProductVersion", "2.6.1.12" + VALUE "ProductVersion", "2.6.1.14" END END BLOCK "VarFileInfo"