From 0265bde60c7efa7ce33be150d8e2ea257bfa8e19 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Tue, 19 Nov 2024 12:42:01 +0200 Subject: [PATCH] add ldm object count --- changelog.md | 3 +++ mod.json | 4 ++-- src/features/LDMObjectCount.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/features/LDMObjectCount.cpp diff --git a/changelog.md b/changelog.md index 933d4fa..544fb8d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # BetterEdit 6 +## v6.9.0-alpha.2 + * Add LDM Object Count to the pause menu + ## v6.9.0-alpha.1 * Support for GD 2.2704 and Geode 4.0.0-beta.1 diff --git a/mod.json b/mod.json index 809a331..ff30068 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { - "geode": "4.0.0-beta.1", - "version": "6.9.0-alpha.1", + "geode": "4.0.0-beta.2", + "version": "6.9.0-alpha.2", "gd": { "win": "2.2074", "mac": "2.2074", diff --git a/src/features/LDMObjectCount.cpp b/src/features/LDMObjectCount.cpp new file mode 100644 index 0000000..4efa663 --- /dev/null +++ b/src/features/LDMObjectCount.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +using namespace geode::prelude; + +class $modify(EditorPauseLayer) { + bool init(LevelEditorLayer* lel) { + if (!EditorPauseLayer::init(lel)) + return false; + + if (auto label = static_cast(this->querySelector("object-count-label"))) { + size_t ldmCount = 0; + for (auto obj : CCArrayExt(lel->m_objects)) { + ldmCount += obj->m_isHighDetail; + } + label->setString(fmt::format( + "{} | LDM: {} ({}%)", + label->getString(), ldmCount, + lel->m_objects->count() ? static_cast(100.f * ldmCount / lel->m_objects->count()) : 0 + ).c_str()); + } + + return true; + } +};