1
0
mirror of synced 2025-01-18 09:04:52 +01:00

ui: Added some hint text for in/out variable tab, improved centered hints

This commit is contained in:
WerWolv 2022-01-24 00:46:19 +01:00
parent 65212f22a6
commit a66fec489c
7 changed files with 19 additions and 8 deletions

View File

@ -2,7 +2,9 @@
#include <functional> #include <functional>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h> #include <imgui.h>
#include <imgui_internal.h>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>
@ -105,4 +107,16 @@ namespace ImGui {
void TextFormattedWrapped(const std::string &fmt, auto&& ... args) { void TextFormattedWrapped(const std::string &fmt, auto&& ... args) {
ImGui::TextWrapped("%s", hex::format(fmt, std::forward<decltype(args)>(args)...).c_str()); ImGui::TextWrapped("%s", hex::format(fmt, std::forward<decltype(args)>(args)...).c_str());
} }
void TextFormattedCentered(const std::string &fmt, auto&& ... args) {
auto text = hex::format(fmt);
auto availableSpace = ImGui::GetContentRegionAvail();
auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false, availableSpace.x * 0.75F);
ImGui::SetCursorPos(((availableSpace - textSize) / 2.0F));
ImGui::PushTextWrapPos(availableSpace.x * 0.75F);
ImGui::TextFormattedWrapped("{}", text);
ImGui::PopTextWrapPos();
}
} }

View File

@ -1,7 +1,5 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <imgui.h>
#include <imgui_internal.h>
#include <hex/views/view.hpp> #include <hex/views/view.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {

View File

@ -57,12 +57,7 @@ namespace hex::plugin::builtin {
auto &bookmarks = ImHexApi::Bookmarks::getEntries(); auto &bookmarks = ImHexApi::Bookmarks::getEntries();
if (bookmarks.empty()) { if (bookmarks.empty()) {
std::string text = "hex.builtin.view.bookmarks.no_bookmarks"_lang; ImGui::TextFormattedCentered("hex.builtin.view.bookmarks.no_bookmarks"_lang);
auto textSize = ImGui::CalcTextSize(text.c_str());
auto availableSpace = ImGui::GetContentRegionAvail();
ImGui::SetCursorPos((availableSpace - textSize) / 2.0F);
ImGui::TextUnformatted(text.c_str());
} }
u32 id = 1; u32 id = 1;

View File

@ -290,6 +290,7 @@ namespace hex::plugin::builtin {
{ "hex.builtin.view.pattern_editor.settings", "Einstellungen" }, { "hex.builtin.view.pattern_editor.settings", "Einstellungen" },
{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Gefährliche funktion erlauben?" }, { "hex.builtin.view.pattern_editor.dangerous_function.name", "Gefährliche funktion erlauben?" },
{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "Dieses Pattern hat versucht eine gefährliche Funktion aufzurufen.\nBist du sicher, dass du diesem Pattern vertraust?" }, { "hex.builtin.view.pattern_editor.dangerous_function.desc", "Dieses Pattern hat versucht eine gefährliche Funktion aufzurufen.\nBist du sicher, dass du diesem Pattern vertraust?" },
{ "hex.builtin.view.pattern_editor.no_in_out_vars", "Definiere einige globale Variablen mit dem 'in' oder 'out' specifier damit diese hier auftauchen." },
{ "hex.builtin.view.pattern_data.name", "Pattern Daten" }, { "hex.builtin.view.pattern_data.name", "Pattern Daten" },
{ "hex.builtin.view.pattern_data.var_name", "Name" }, { "hex.builtin.view.pattern_data.var_name", "Name" },

View File

@ -293,6 +293,7 @@ namespace hex::plugin::builtin {
{ "hex.builtin.view.pattern_editor.settings", "Settings" }, { "hex.builtin.view.pattern_editor.settings", "Settings" },
{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" }, { "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" },
{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" }, { "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" },
{ "hex.builtin.view.pattern_editor.no_in_out_vars", "Define some global variables with the 'in' or 'out' specifier for them to appear here." },
{ "hex.builtin.view.pattern_data.name", "Pattern Data" }, { "hex.builtin.view.pattern_data.name", "Pattern Data" },
{ "hex.builtin.view.pattern_data.var_name", "Name" }, { "hex.builtin.view.pattern_data.var_name", "Name" },

View File

@ -290,6 +290,7 @@ namespace hex::plugin::builtin {
//{ "hex.builtin.view.pattern_editor.settings", "Settings" }, //{ "hex.builtin.view.pattern_editor.settings", "Settings" },
//{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" }, //{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" },
//{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" }, //{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" },
//{ "hex.builtin.view.pattern_editor.no_in_out_vars", "Define some global variables with the 'in' or 'out' specifier for them to appear here." },
{ "hex.builtin.view.pattern_data.name", "Dati dei Pattern" }, { "hex.builtin.view.pattern_data.name", "Dati dei Pattern" },
{ "hex.builtin.view.pattern_data.var_name", "Nome" }, { "hex.builtin.view.pattern_data.var_name", "Nome" },

View File

@ -289,6 +289,7 @@ namespace hex::plugin::builtin {
//{ "hex.builtin.view.pattern_editor.settings", "Settings" }, //{ "hex.builtin.view.pattern_editor.settings", "Settings" },
//{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" }, //{ "hex.builtin.view.pattern_editor.dangerous_function.name", "Allow dangerous function?" },
//{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" }, //{ "hex.builtin.view.pattern_editor.dangerous_function.desc", "This pattern tried to call a dangerous function.\nAre you sure you want to trust this pattern?" },
//{ "hex.builtin.view.pattern_editor.no_in_out_vars", "Define some global variables with the 'in' or 'out' specifier for them to appear here." },
{ "hex.builtin.view.pattern_data.name", "模式数据" }, { "hex.builtin.view.pattern_data.name", "模式数据" },
{ "hex.builtin.view.pattern_data.var_name", "名称" }, { "hex.builtin.view.pattern_data.var_name", "名称" },