Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a global effect hotkey #136

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package/SKSE/Plugins/CommunityShaders.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
},
"Menu": {
"Font Scale": 0.0,
"Toggle Key": 35
"Toggle Key": 35,
"Effects Toggle Key": 106
},
"Replace Original Shaders": {
"BloodSplatter": false,
Expand Down
26 changes: 26 additions & 0 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define SETTING_MENU_TOGGLEKEY "Toggle Key"
#define SETTING_MENU_SKIPKEY "Skip Compilation Key"
#define SETTING_MENU_FONTSCALE "Font Scale"
#define SETTING_MENU_TOGGLE_SHADERS_KEY "Toggle Effects Key"

void SetupImGuiStyle()
{
Expand Down Expand Up @@ -82,6 +83,9 @@ void Menu::Load(json& o_json)
if (o_json[SETTING_MENU_FONTSCALE].is_number_float()) {
fontScale = o_json[SETTING_MENU_FONTSCALE];
}
if (o_json[SETTING_MENU_TOGGLE_SHADERS_KEY].is_number_unsigned()) {
effectToggleKey = o_json[SETTING_MENU_TOGGLE_SHADERS_KEY];
}
}

void Menu::Save(json& o_json)
Expand All @@ -90,6 +94,7 @@ void Menu::Save(json& o_json)
menu[SETTING_MENU_TOGGLEKEY] = toggleKey;
menu[SETTING_MENU_SKIPKEY] = skipCompilationKey;
menu[SETTING_MENU_FONTSCALE] = fontScale;
menu[SETTING_MENU_TOGGLE_SHADERS_KEY] = effectToggleKey;

o_json["Menu"] = menu;
}
Expand Down Expand Up @@ -221,11 +226,17 @@ RE::BSEventNotifyControl Menu::ProcessEvent(RE::InputEvent* const* a_event, RE::
} else if (settingSkipCompilationKey) {
skipCompilationKey = key;
settingSkipCompilationKey = false;
} else if (settingsEffectsToggle) {
effectToggleKey = key;
settingsEffectsToggle = false;
} else if (key == toggleKey) {
IsEnabled = !IsEnabled;
} else if (key == skipCompilationKey) {
auto& shaderCache = SIE::ShaderCache::Instance();
shaderCache.backgroundCompilation = true;
} else if (key == effectToggleKey) {
auto& shaderCache = SIE::ShaderCache::Instance();
shaderCache.SetEnabled(!shaderCache.IsEnabled());
}
}

Expand Down Expand Up @@ -432,6 +443,21 @@ void Menu::DrawSettings()
settingToggleKey = true;
}
}
if (settingsEffectsToggle) {
ImGui::Text("Press any key to set as a toggle key for all effects...");
} else {
ImGui::AlignTextToFramePadding();
ImGui::Text("Effect Toggle Key:");
ImGui::SameLine();
ImGui::AlignTextToFramePadding();
ImGui::TextColored(ImVec4(1, 1, 0, 1), "%s", KeyIdToString(effectToggleKey));

ImGui::AlignTextToFramePadding();
ImGui::SameLine();
if (ImGui::Button("Change##toggle")) {
settingsEffectsToggle = true;
}
}
if (settingSkipCompilationKey) {
ImGui::Text("Press any key to set as Skip Compilation Key...");
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class Menu : public RE::BSTEventSink<RE::InputEvent*>

private:
uint32_t toggleKey = VK_END;
uint32_t effectToggleKey = VK_MULTIPLY; //toggle all effects
uint32_t skipCompilationKey = VK_ESCAPE;
bool settingToggleKey = false;
bool settingSkipCompilationKey = false;
bool settingsEffectsToggle = false;
float fontScale = 0.f; // exponential
uint32_t testInterval = 0; // Seconds to wait before toggling user/test settings
bool inTestMode = false; // Whether we're in test mode
Expand Down