impr: Add warning about using fractional scaling with default font
This commit is contained in:
parent
125d6a3e2a
commit
f0e135530a
@ -131,7 +131,7 @@ namespace ImGuiExt {
|
|||||||
bool DescriptionButton(const char *label, const char *description, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
bool DescriptionButton(const char *label, const char *description, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||||
bool DescriptionButtonProgress(const char *label, const char *description, float fraction, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
bool DescriptionButtonProgress(const char *label, const char *description, float fraction, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||||
|
|
||||||
void HelpHover(const char *text);
|
void HelpHover(const char *text, const char *icon = "(?)", ImU32 iconColor = ImGui::GetColorU32(ImGuiCol_ButtonActive));
|
||||||
|
|
||||||
void UnderlinedText(const char *label, ImColor color = ImGui::GetStyleColorVec4(ImGuiCol_Text), const ImVec2 &size_arg = ImVec2(0, 0));
|
void UnderlinedText(const char *label, ImColor color = ImGui::GetStyleColorVec4(ImGuiCol_Text), const ImVec2 &size_arg = ImVec2(0, 0));
|
||||||
|
|
||||||
|
@ -503,9 +503,7 @@ namespace ImGuiExt {
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpHover(const char *text) {
|
void HelpHover(const char *text, const char *icon, ImU32 iconColor) {
|
||||||
const auto iconColor = GetStyleColorVec4(ImGuiCol_ButtonActive);
|
|
||||||
|
|
||||||
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||||
PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
|
||||||
PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||||
@ -513,7 +511,7 @@ namespace ImGuiExt {
|
|||||||
PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
|
PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
|
||||||
|
|
||||||
PushStyleColor(ImGuiCol_Text, iconColor);
|
PushStyleColor(ImGuiCol_Text, iconColor);
|
||||||
Button("(?)");
|
Button(icon);
|
||||||
PopStyleColor();
|
PopStyleColor();
|
||||||
|
|
||||||
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||||
|
@ -486,6 +486,7 @@
|
|||||||
"hex.builtin.setting.interface.multi_windows": "Enable Multi Window support",
|
"hex.builtin.setting.interface.multi_windows": "Enable Multi Window support",
|
||||||
"hex.builtin.setting.interface.scaling_factor": "Scaling",
|
"hex.builtin.setting.interface.scaling_factor": "Scaling",
|
||||||
"hex.builtin.setting.interface.scaling.native": "Native",
|
"hex.builtin.setting.interface.scaling.native": "Native",
|
||||||
|
"hex.builtin.setting.interface.scaling.fractional_warning": "The default font does not support fractional scaling. For better results, select a custom font in the 'Font' tab.",
|
||||||
"hex.builtin.setting.interface.show_header_command_palette": "Show Command Palette in Window Header",
|
"hex.builtin.setting.interface.show_header_command_palette": "Show Command Palette in Window Header",
|
||||||
"hex.builtin.setting.interface.style": "Styling",
|
"hex.builtin.setting.interface.style": "Styling",
|
||||||
"hex.builtin.setting.interface.window": "Window",
|
"hex.builtin.setting.interface.window": "Window",
|
||||||
|
@ -229,9 +229,8 @@ namespace hex::plugin::builtin {
|
|||||||
std::strncpy(defaultConfig.Name, fontName, sizeof(defaultConfig.Name) - 1);
|
std::strncpy(defaultConfig.Name, fontName, sizeof(defaultConfig.Name) - 1);
|
||||||
|
|
||||||
if (fontFile.empty()) {
|
if (fontFile.empty()) {
|
||||||
fontSize = std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize) * ImHexApi::Fonts::DefaultFontSize;
|
|
||||||
defaultConfig.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Monochrome | ImGuiFreeTypeBuilderFlags_MonoHinting;
|
defaultConfig.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Monochrome | ImGuiFreeTypeBuilderFlags_MonoHinting;
|
||||||
defaultConfig.SizePixels = fontSize;
|
defaultConfig.SizePixels = std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize) * ImHexApi::Fonts::DefaultFontSize;
|
||||||
defaultFont = fonts->AddFontDefault(&defaultConfig);
|
defaultFont = fonts->AddFontDefault(&defaultConfig);
|
||||||
} else {
|
} else {
|
||||||
defaultFont = fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &defaultConfig, defaultGlyphRanges.Data);
|
defaultFont = fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &defaultConfig, defaultGlyphRanges.Data);
|
||||||
@ -284,6 +283,8 @@ namespace hex::plugin::builtin {
|
|||||||
if (font.defaultSize.has_value())
|
if (font.defaultSize.has_value())
|
||||||
size = font.defaultSize.value() * std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize);
|
size = font.defaultSize.value() * std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize);
|
||||||
|
|
||||||
|
size = std::max(1.0F, std::floor(size / ImHexApi::Fonts::DefaultFontSize)) * ImHexApi::Fonts::DefaultFontSize;
|
||||||
|
|
||||||
cfg.SizePixels = size;
|
cfg.SizePixels = size;
|
||||||
|
|
||||||
ON_SCOPE_EXIT { cfg.MergeMode = true; };
|
ON_SCOPE_EXIT { cfg.MergeMode = true; };
|
||||||
|
@ -173,11 +173,14 @@ namespace hex::plugin::builtin {
|
|||||||
return "x%.1f";
|
return "x%.1f";
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (ImGui::SliderFloat(name.data(), &m_value, 0, 10, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) {
|
bool changed = ImGui::SliderFloat(name.data(), &m_value, 0, 10, format.c_str(), ImGuiSliderFlags_AlwaysClamp);
|
||||||
return true;
|
|
||||||
|
if (ImHexApi::Fonts::getCustomFontPath().empty() && (u32(m_value * 10) % 10) != 0) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGuiExt::HelpHover("hex.builtin.setting.interface.scaling.fractional_warning"_lang, ICON_VS_WARNING, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_ToolbarRed));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(const nlohmann::json &data) override {
|
void load(const nlohmann::json &data) override {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user