Skip to content

Commit

Permalink
changed input shortcut to the ImGuiEx (modern) one
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxfighter committed Sep 20, 2021
1 parent 074bfbb commit bf47f49
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Settings {

public:
struct SettingsObject {
int killproofKey;
WPARAM killproofKey;
bool hidePrivateAccount;
bool showKillproof;
std::string blockedDataText;
Expand Down
41 changes: 8 additions & 33 deletions SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions SettingsUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
class SettingsUI
{
char shortcut[64]{};
char shortCutRealName[32]{};
int cofferValue = settings.settings.cofferValue;

public:
SettingsUI();
SettingsUI() = default;

void draw();
};
Expand Down
8 changes: 4 additions & 4 deletions killproof_me.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit bf47f49

Please sign in to comment.