diff --git a/src/Menu.cpp b/src/Menu.cpp index be37944e8..91c1f546a 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -12,83 +12,148 @@ #include "Features/WaterBlending.h" #define SETTING_MENU_TOGGLEKEY "Toggle Key" +#define SETTING_MENU_FONTSCALE "Font Scale" void SetupImGuiStyle() { constexpr auto bg_alpha = 0.68f; constexpr auto disabled_alpha = 0.30f; - constexpr auto background = ImVec4(0.0f, 0.0f, 0.0f, bg_alpha); - constexpr auto border = ImVec4(0.396f, 0.404f, 0.412f, bg_alpha); + // constexpr auto background = ImVec4(0.0f, 0.0f, 0.0f, bg_alpha); + // constexpr auto border = ImVec4(0.396f, 0.404f, 0.412f, bg_alpha); auto& style = ImGui::GetStyle(); auto& colors = style.Colors; - colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); - colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); - colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); - colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.08f, 0.50f, 0.72f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); - colors[ImGuiCol_Header] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); - colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.41f, 0.42f, 0.44f, 1.00f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.29f, 0.30f, 0.31f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_Tab] = ImVec4(0.23f, 0.23f, 0.24f, 0.25f); - colors[ImGuiCol_TabHovered] = ImVec4(0.23f, 0.23f, 0.24f, 1.0f); - colors[ImGuiCol_TabActive] = ImVec4(0.23f, 0.23f, 0.24f, 0.75f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); - colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); - colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - - colors[ImGuiCol_WindowBg] = background; - colors[ImGuiCol_ChildBg] = background; - - colors[ImGuiCol_Border] = border; - colors[ImGuiCol_Separator] = border; - - colors[ImGuiCol_TextDisabled] = ImVec4(1.0f, 1.0f, 1.0f, disabled_alpha); - - colors[ImGuiCol_FrameBg] = ImVec4(0.2f, 0.2f, 0.2f, bg_alpha); - colors[ImGuiCol_FrameBgHovered] = colors[ImGuiCol_FrameBg]; - colors[ImGuiCol_FrameBgActive] = colors[ImGuiCol_FrameBg]; - - colors[ImGuiCol_SliderGrab] = ImVec4(1.0f, 1.0f, 1.0f, 0.245f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(1.0f, 1.0f, 1.0f, 0.531f); - - colors[ImGuiCol_CheckMark] = ImVec4(1.0f, 1.0f, 1.0f, 0.9f); + // colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + // colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + // colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); + // colors[ImGuiCol_ChildBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); + // colors[ImGuiCol_PopupBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); + // colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + // colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + // colors[ImGuiCol_FrameBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + // colors[ImGuiCol_FrameBgHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); + // colors[ImGuiCol_FrameBgActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); + // colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); + // colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); + // colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + // colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); + // colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); + // colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); + // colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); + // colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); + // colors[ImGuiCol_CheckMark] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); + // colors[ImGuiCol_SliderGrab] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); + // colors[ImGuiCol_SliderGrabActive] = ImVec4(0.08f, 0.50f, 0.72f, 1.00f); + // colors[ImGuiCol_Button] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + // colors[ImGuiCol_ButtonHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); + // colors[ImGuiCol_ButtonActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); + // colors[ImGuiCol_Header] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f); + // colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + // colors[ImGuiCol_HeaderActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f); + // colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; + // colors[ImGuiCol_SeparatorHovered] = ImVec4(0.41f, 0.42f, 0.44f, 1.00f); + // colors[ImGuiCol_SeparatorActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + // colors[ImGuiCol_ResizeGrip] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + // colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.29f, 0.30f, 0.31f, 0.67f); + // colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + // colors[ImGuiCol_Tab] = ImVec4(0.23f, 0.23f, 0.24f, 0.25f); + // colors[ImGuiCol_TabHovered] = ImVec4(0.23f, 0.23f, 0.24f, 1.0f); + // colors[ImGuiCol_TabActive] = ImVec4(0.23f, 0.23f, 0.24f, 0.75f); + // colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f); + // colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f); + // colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + // colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + // colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + // colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + // colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + // colors[ImGuiCol_DragDropTarget] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f); + // colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + // colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + // colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + // colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + + // colors[ImGuiCol_WindowBg] = background; + // colors[ImGuiCol_ChildBg] = background; + + // colors[ImGuiCol_Border] = border; + // colors[ImGuiCol_Separator] = border; + + // colors[ImGuiCol_TextDisabled] = ImVec4(1.0f, 1.0f, 1.0f, disabled_alpha); + + // colors[ImGuiCol_FrameBg] = ImVec4(0.2f, 0.2f, 0.2f, bg_alpha); + // colors[ImGuiCol_FrameBgHovered] = colors[ImGuiCol_FrameBg]; + // colors[ImGuiCol_FrameBgActive] = colors[ImGuiCol_FrameBg]; + + // colors[ImGuiCol_SliderGrab] = ImVec4(1.0f, 1.0f, 1.0f, 0.245f); + // colors[ImGuiCol_SliderGrabActive] = ImVec4(1.0f, 1.0f, 1.0f, 0.531f); + + // colors[ImGuiCol_CheckMark] = ImVec4(1.0f, 1.0f, 1.0f, 0.9f); + + // Dark Ruda by Raikiri via ImThemes + colors[ImGuiCol_Text] = ImVec4(0.9490196108818054f, 0.95686274766922f, 0.9764705896377563f, 1.0f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.3568627536296844f, 0.4196078479290009f, 0.4666666686534882f, 1.0f); + colors[ImGuiCol_WindowBg] = ImVec4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f); + colors[ImGuiCol_ChildBg] = ImVec4(0.1490196138620377f, 0.1764705926179886f, 0.2196078449487686f, 1.0f); + colors[ImGuiCol_PopupBg] = ImVec4(0.0784313753247261f, 0.0784313753247261f, 0.0784313753247261f, 0.9399999976158142f); + colors[ImGuiCol_Border] = ImVec4(0.0784313753247261f, 0.09803921729326248f, 0.1176470592617989f, 1.0f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); + colors[ImGuiCol_FrameBg] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.1176470592617989f, 0.2000000029802322f, 0.2784313857555389f, 1.0f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.08627451211214066f, 0.1176470592617989f, 0.1372549086809158f, 1.0f); + colors[ImGuiCol_TitleBg] = ImVec4(0.08627451211214066f, 0.1176470592617989f, 0.1372549086809158f, 0.6499999761581421f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.0784313753247261f, 0.09803921729326248f, 0.1176470592617989f, 1.0f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.0f, 0.0f, 0.0f, 0.5099999904632568f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.1490196138620377f, 0.1764705926179886f, 0.2196078449487686f, 1.0f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.01960784383118153f, 0.01960784383118153f, 0.01960784383118153f, 0.3899999856948853f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.1764705926179886f, 0.2196078449487686f, 0.2470588237047195f, 1.0f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.08627451211214066f, 0.2078431397676468f, 0.3098039329051971f, 1.0f); + colors[ImGuiCol_CheckMark] = ImVec4(0.2784313857555389f, 0.5568627715110779f, 1.0f, 1.0f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.2784313857555389f, 0.5568627715110779f, 1.0f, 1.0f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.3686274588108063f, 0.6078431606292725f, 1.0f, 1.0f); + colors[ImGuiCol_Button] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.2784313857555389f, 0.5568627715110779f, 1.0f, 1.0f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.05882352963089943f, 0.529411792755127f, 0.9764705896377563f, 1.0f); + colors[ImGuiCol_Header] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 0.550000011920929f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.800000011920929f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 1.0f); + colors[ImGuiCol_Separator] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.09803921729326248f, 0.4000000059604645f, 0.7490196228027344f, 0.7799999713897705f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.09803921729326248f, 0.4000000059604645f, 0.7490196228027344f, 1.0f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.25f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.6700000166893005f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.949999988079071f); + colors[ImGuiCol_Tab] = ImVec4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f); + colors[ImGuiCol_TabHovered] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.800000011920929f); + colors[ImGuiCol_TabActive] = ImVec4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f); + colors[ImGuiCol_TabUnfocused] = ImVec4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f); + colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f); + colors[ImGuiCol_PlotLines] = ImVec4(0.6078431606292725f, 0.6078431606292725f, 0.6078431606292725f, 1.0f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.0f, 0.4274509847164154f, 0.3490196168422699f, 1.0f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.8980392217636108f, 0.6980392336845398f, 0.0f, 1.0f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.0f, 0.6000000238418579f, 0.0f, 1.0f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.1882352977991104f, 0.1882352977991104f, 0.2000000029802322f, 1.0f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.3098039329051971f, 0.3098039329051971f, 0.3490196168422699f, 1.0f); + colors[ImGuiCol_TableBorderLight] = ImVec4(0.2274509817361832f, 0.2274509817361832f, 0.2470588237047195f, 1.0f); + colors[ImGuiCol_TableRowBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.0f, 1.0f, 1.0f, 0.05999999865889549f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.3499999940395355f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.0f, 1.0f, 0.0f, 0.8999999761581421f); + colors[ImGuiCol_NavHighlight] = ImVec4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 1.0f); + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.0f, 1.0f, 1.0f, 0.699999988079071f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.800000011920929f, 0.800000011920929f, 0.800000011920929f, 0.2000000029802322f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.800000011920929f, 0.800000011920929f, 0.800000011920929f, 0.3499999940395355f); + + colors[ImGuiCol_WindowBg].w = bg_alpha; + colors[ImGuiCol_ChildBg].w = bg_alpha; + + colors[ImGuiCol_TextDisabled].w = disabled_alpha; + + colors[ImGuiCol_FrameBg].w = bg_alpha; + colors[ImGuiCol_FrameBgHovered].w = bg_alpha; + colors[ImGuiCol_FrameBgActive].w = bg_alpha; style.WindowBorderSize = 3.0f; style.TabRounding = 0.0f; @@ -108,23 +173,37 @@ void Menu::Load(json& o_json) if (o_json[SETTING_MENU_TOGGLEKEY].is_number_unsigned()) { toggleKey = o_json[SETTING_MENU_TOGGLEKEY]; } + if (o_json[SETTING_MENU_FONTSCALE].is_number_float()) { + o_json[SETTING_MENU_FONTSCALE].get_to(fontScale); + + auto trueScale = exp2(fontScale); + auto& style = ImGui::GetStyle(); + style.ScaleAllSizes(trueScale); + auto& io = ImGui::GetIO(); + io.FontGlobalScale = trueScale; + } } void Menu::Save(json& o_json) { json menu; menu[SETTING_MENU_TOGGLEKEY] = toggleKey; + menu[SETTING_MENU_FONTSCALE] = fontScale; o_json["Menu"] = menu; } +#define IM_VK_KEYPAD_ENTER (VK_RETURN + 256) RE::BSEventNotifyControl Menu::ProcessEvent(RE::InputEvent* const* a_event, RE::BSTEventSource* a_eventSource) { if (!a_event || !a_eventSource) return RE::BSEventNotifyControl::kContinue; + auto& io = ImGui::GetIO(); + for (auto event = *a_event; event; event = event->next) { if (event->eventType == RE::INPUT_EVENT_TYPE::kChar) { + io.AddInputCharacter(event->AsCharEvent()->keycode); } else if (event->eventType == RE::INPUT_EVENT_TYPE::kButton) { const auto button = static_cast(event); if (!button || (button->IsPressed() && !button->IsDown())) @@ -197,12 +276,27 @@ RE::BSEventNotifyControl Menu::ProcessEvent(RE::InputEvent* const* a_event, RE:: case DIK_DECIMAL: key = VK_DECIMAL; break; + case DIK_NUMPADENTER: + key = IM_VK_KEYPAD_ENTER; + break; + case DIK_LMENU: + key = VK_LMENU; + break; // left alt + case DIK_LCONTROL: + key = VK_LCONTROL; + break; // left control + case DIK_LSHIFT: + key = VK_LSHIFT; + break; // left shift case DIK_RMENU: key = VK_RMENU; break; // right alt case DIK_RCONTROL: key = VK_RCONTROL; break; // right control + case DIK_RSHIFT: + key = VK_RSHIFT; + break; // right shift case DIK_LWIN: key = VK_LWIN; break; // left win @@ -216,7 +310,6 @@ RE::BSEventNotifyControl Menu::ProcessEvent(RE::InputEvent* const* a_event, RE:: break; } - auto& io = ImGui::GetIO(); switch (button->device.get()) { case RE::INPUT_DEVICE::kKeyboard: if (!button->IsPressed()) { @@ -228,10 +321,17 @@ RE::BSEventNotifyControl Menu::ProcessEvent(RE::InputEvent* const* a_event, RE:: if (const auto controlMap = RE::ControlMap::GetSingleton()) { controlMap->GetRuntimeData().ignoreKeyboardMouse = IsEnabled; } - } else { - io.AddKeyEvent(VirtualKeyToImGuiKey(key), button->IsPressed()); } } + + io.AddKeyEvent(VirtualKeyToImGuiKey(key), button->IsPressed()); + + if (key == VK_LCONTROL || key == VK_RCONTROL) + io.AddKeyEvent(ImGuiMod_Ctrl, button->IsPressed()); + else if (key == VK_LSHIFT || key == VK_RSHIFT) + io.AddKeyEvent(ImGuiMod_Shift, button->IsPressed()); + else if (key == VK_LMENU || key == VK_RMENU) + io.AddKeyEvent(ImGuiMod_Alt, button->IsPressed()); break; case RE::INPUT_DEVICE::kMouse: logger::trace("Detect mouse scan code {} value {} pressed: {}", scan_code, button->Value(), button->IsPressed()); @@ -262,7 +362,7 @@ void Menu::Init(IDXGISwapChain* swapchain, ID3D11Device* device, ID3D11DeviceCon imgui_io.ConfigFlags = ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_DockingEnable; imgui_io.BackendFlags = ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_RendererHasVtxOffset; - imgui_io.Fonts->AddFontFromFileTTF("Data\\Interface\\CommunityShaders\\Fonts\\Atkinson-Hyperlegible-Regular-102.ttf", 18); + imgui_io.Fonts->AddFontFromFileTTF("Data\\Interface\\CommunityShaders\\Fonts\\Atkinson-Hyperlegible-Regular-102.ttf", 24); DXGI_SWAP_CHAIN_DESC desc; swapchain->GetDesc(&desc); @@ -347,6 +447,14 @@ void Menu::DrawSettings() settingToggleKey = true; } } + + if (ImGui::SliderFloat("Font Scale", &fontScale, -2.f, 2.f, "%.2f")) { + float trueScale = exp2(fontScale); + auto& style = ImGui::GetStyle(); + style.ScaleAllSizes(trueScale); + auto& io = ImGui::GetIO(); + io.FontGlobalScale = trueScale; + } } if (ImGui::CollapsingHeader("Advanced", ImGuiTreeNodeFlags_DefaultOpen)) { @@ -564,7 +672,6 @@ const char* Menu::KeyIdToString(uint32_t key) return keyboard_keys_international[key]; } -#define IM_VK_KEYPAD_ENTER (VK_RETURN + 256) const ImGuiKey Menu::VirtualKeyToImGuiKey(WPARAM vkKey) { switch (vkKey) { diff --git a/src/Menu.h b/src/Menu.h index dd5ab876d..15a353933 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -21,17 +21,17 @@ class Menu : public RE::BSTEventSink RE::BSEventNotifyControl ProcessEvent(RE::InputEvent* const* a_event, RE::BSTEventSource* a_eventSource) override; - void Init(IDXGISwapChain* swapchain, ID3D11Device* device, ID3D11DeviceContext* context); void DrawSettings(); void DrawOverlay(); private: - uint32_t toggleKey = VK_END; bool settingToggleKey = false; - Menu() { } + float fontScale = 0.f; // exponential + + Menu() {} const char* KeyIdToString(uint32_t key); const ImGuiKey VirtualKeyToImGuiKey(WPARAM vkKey); }; \ No newline at end of file