mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
impr: Various rendering performance improvements
This commit is contained in:
@@ -276,7 +276,7 @@ EXPORT_MODULE namespace hex {
|
||||
* @brief Gets the current ImHex version
|
||||
* @return ImHex version
|
||||
*/
|
||||
SemanticVersion getImHexVersion();
|
||||
const SemanticVersion& getImHexVersion();
|
||||
|
||||
/**
|
||||
* @brief Gets the current git commit hash
|
||||
|
||||
@@ -59,7 +59,6 @@ EXPORT_MODULE namespace hex {
|
||||
|
||||
private:
|
||||
std::size_t m_entryHash;
|
||||
std::string m_unlocalizedString;
|
||||
};
|
||||
|
||||
class LangConst {
|
||||
|
||||
@@ -899,12 +899,13 @@ namespace hex {
|
||||
return { { name, version } };
|
||||
}
|
||||
|
||||
SemanticVersion getImHexVersion() {
|
||||
const SemanticVersion& getImHexVersion() {
|
||||
#if defined(IMHEX_VERSION)
|
||||
static auto version = SemanticVersion(IMHEX_VERSION);
|
||||
return version;
|
||||
#else
|
||||
return {};
|
||||
static auto version = SemanticVersion();
|
||||
return version;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -946,7 +947,9 @@ namespace hex {
|
||||
}
|
||||
|
||||
bool isNightlyBuild() {
|
||||
return getImHexVersion().nightly();
|
||||
const static bool isNightly = getImHexVersion().nightly();
|
||||
|
||||
return isNightly;
|
||||
}
|
||||
|
||||
std::optional<std::string> checkForUpdate() {
|
||||
|
||||
@@ -171,11 +171,21 @@ namespace hex {
|
||||
|
||||
}
|
||||
|
||||
Lang::Lang(const char *unlocalizedString) : m_entryHash(LangConst::hash(unlocalizedString)), m_unlocalizedString(unlocalizedString) { }
|
||||
Lang::Lang(const std::string &unlocalizedString) : m_entryHash(LangConst::hash(unlocalizedString)), m_unlocalizedString(unlocalizedString) { }
|
||||
Lang::Lang(const LangConst &localizedString) : m_entryHash(localizedString.m_entryHash), m_unlocalizedString(localizedString.m_unlocalizedString) { }
|
||||
Lang::Lang(const UnlocalizedString &unlocalizedString) : m_entryHash(LangConst::hash(unlocalizedString.get())), m_unlocalizedString(unlocalizedString.get()) { }
|
||||
Lang::Lang(std::string_view unlocalizedString) : m_entryHash(LangConst::hash(unlocalizedString)), m_unlocalizedString(unlocalizedString) { }
|
||||
static AutoReset<std::map<std::size_t, std::string>> s_unlocalizedNames;
|
||||
|
||||
Lang::Lang(std::string_view unlocalizedString) : m_entryHash(LangConst::hash(unlocalizedString)) {
|
||||
if (!s_unlocalizedNames->contains(m_entryHash)) [[unlikely]] {
|
||||
s_unlocalizedNames->emplace(m_entryHash, unlocalizedString);
|
||||
}
|
||||
}
|
||||
Lang::Lang(const char *unlocalizedString) : Lang(std::string_view(unlocalizedString)) { }
|
||||
Lang::Lang(const std::string &unlocalizedString) : Lang(std::string_view(unlocalizedString)) { }
|
||||
Lang::Lang(const LangConst &localizedString) : m_entryHash(localizedString.m_entryHash) {
|
||||
if (!s_unlocalizedNames->contains(m_entryHash)) [[unlikely]] {
|
||||
s_unlocalizedNames->emplace(m_entryHash, localizedString.m_unlocalizedString);
|
||||
}
|
||||
}
|
||||
Lang::Lang(const UnlocalizedString &unlocalizedString) : Lang(unlocalizedString.get()) { }
|
||||
|
||||
Lang::operator std::string() const {
|
||||
return get();
|
||||
@@ -194,7 +204,11 @@ namespace hex {
|
||||
|
||||
const auto it = lang.find(m_entryHash);
|
||||
if (it == lang.end()) {
|
||||
return m_unlocalizedString.c_str();
|
||||
if (auto unlocalizedIt = s_unlocalizedNames->find(m_entryHash); unlocalizedIt != s_unlocalizedNames->end()) {
|
||||
return unlocalizedIt->second.c_str();
|
||||
} else {
|
||||
return "<unlocalized>";
|
||||
}
|
||||
} else {
|
||||
return it->second.c_str();
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ namespace ImGuiExt {
|
||||
ImGuiContext &g = *GImGui;
|
||||
const ImGuiStyle &style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 text_size = CalcTextSize((std::string(label) + "\n " + std::string(description)).c_str(), nullptr, true);
|
||||
const ImVec2 text_size = CalcTextSize(fmt::format("{}\n{}", label, description).c_str(), nullptr, true);
|
||||
const ImVec2 label_size = CalcTextSize(label, nullptr, true);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
@@ -1296,7 +1296,8 @@ namespace ImGuiExt {
|
||||
|
||||
bool result = false;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0F);
|
||||
if (ImGui::BeginChild(fmt::format("{}##SubWindow", label).c_str(), size, ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) {
|
||||
ImGui::PushID("SubWindow");
|
||||
if (ImGui::BeginChild(label, size, ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) {
|
||||
result = true;
|
||||
|
||||
if (hasMenuBar && ImGui::BeginMenuBar()) {
|
||||
@@ -1329,6 +1330,7 @@ namespace ImGuiExt {
|
||||
|
||||
void EndSubWindow() {
|
||||
ImGui::EndChild();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
bool VSliderAngle(const char* label, const ImVec2& size, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format, ImGuiSliderFlags flags) {
|
||||
|
||||
Reference in New Issue
Block a user