Skip to content

Commit 00a069c

Browse files
authored
Merge branch 'main' into Relative-Mouse-Pos
2 parents 444d522 + 5ee027a commit 00a069c

9 files changed

Lines changed: 40 additions & 26 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build Geode Mod
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- '**'

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ target_sources(${PROJECT_NAME} PRIVATE
3434
${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
3535
)
3636

37+
# Love you imgui
38+
include(CheckCXXCompilerFlag)
39+
check_cxx_compiler_flag(-Wnontrivial-memcall HAVE_NONTRIVIAL_MEMCALL)
40+
if (HAVE_NONTRIVIAL_MEMCALL)
41+
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-nontrivial-memcall)
42+
endif()
43+
3744
# i still dont like this (alk)
3845
target_compile_definitions(geode-sdk INTERFACE GEODE_EXPOSE_SECRET_INTERNALS_IN_HEADERS_DO_NOT_DEFINE_PLEASE)
3946

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.0.0-beta.1",
2+
"geode": "4.3.1",
33
"version": "v1.8.0",
44
"gd": {
55
"win": "*",

src/DevTools.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include <imgui_internal.h>
32
#include "DevTools.hpp"
43
#include "fonts/FeatherIcons.hpp"
@@ -189,11 +188,15 @@ void DevTools::setupFonts() {
189188
void* font, size_t realSize, float size, const ImWchar* range
190189
) {
191190
auto& io = ImGui::GetIO();
191+
// AddFontFromMemoryTTF assumes ownership of the passed data unless you configure it not to.
192+
// Our font data has static lifetime, so we're handling the ownership.
193+
192194
ImFontConfig config;
193-
config.MergeMode = true;
195+
config.FontDataOwnedByAtlas = false;
194196
auto* result = io.Fonts->AddFontFromMemoryTTF(
195-
font, realSize, size, nullptr, range
197+
font, realSize, size, &config, range
196198
);
199+
config.MergeMode = true;
197200
io.Fonts->AddFontFromMemoryTTF(
198201
Font_FeatherIcons, sizeof(Font_FeatherIcons), size - 4.f, &config, icon_ranges
199202
);
@@ -213,7 +216,7 @@ void DevTools::setup() {
213216

214217
IMGUI_CHECKVERSION();
215218

216-
auto ctx = ImGui::CreateContext();
219+
ImGui::CreateContext();
217220

218221
auto& io = ImGui::GetIO();
219222
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
@@ -234,23 +237,27 @@ void DevTools::setup() {
234237

235238
void DevTools::destroy() {
236239
if (!m_setup) return;
237-
m_setup = false;
238-
m_visible = false;
240+
this->show(false);
241+
auto& io = ImGui::GetIO();
242+
io.BackendPlatformUserData = nullptr;
243+
m_fontTexture->release();
244+
m_fontTexture = nullptr;
239245

240-
// crashes :(
241-
// ImGui::DestroyContext();
246+
ImGui::DestroyContext();
247+
m_setup = false;
248+
m_reloadTheme = true;
242249
}
243250

244251
void DevTools::show(bool visible) {
245252
m_visible = visible;
253+
254+
auto& io = ImGui::GetIO();
255+
io.WantCaptureMouse = visible;
256+
io.WantCaptureKeyboard = visible;
246257
}
247258

248259
void DevTools::toggle() {
249260
this->show(!m_visible);
250-
if (!m_visible) {
251-
ImGui::GetIO().WantCaptureMouse = false;
252-
ImGui::GetIO().WantCaptureKeyboard = false;
253-
}
254261
}
255262

256263
void DevTools::sceneChanged() {

src/DevTools.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <Geode/utils/addresser.hpp>
99
#include <Geode/loader/Loader.hpp>
1010
#include <Geode/loader/ModMetadata.hpp>
11-
#include <unordered_map>
1211

1312
using namespace geode::prelude;
1413

@@ -44,6 +43,7 @@ class DevTools {
4443
ImFont* m_smallFont = nullptr;
4544
ImFont* m_monoFont = nullptr;
4645
ImFont* m_boxFont = nullptr;
46+
CCTexture2D* m_fontTexture = nullptr;
4747
Ref<CCNode> m_selectedNode;
4848
std::vector<std::pair<CCNode*, HighlightMode>> m_toHighlight;
4949

src/backend.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ CCPoint getMousePos_H() {
3535
}
3636

3737
void DevTools::setupPlatform() {
38-
ImGui::CreateContext();
39-
4038
auto& io = ImGui::GetIO();
4139

4240
io.BackendPlatformUserData = this;
@@ -52,13 +50,11 @@ void DevTools::setupPlatform() {
5250
int width, height;
5351
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
5452

55-
auto* tex2d = new CCTexture2D;
56-
tex2d->initWithData(pixels, kCCTexture2DPixelFormat_RGBA8888, width, height, CCSize(width, height));
57-
58-
// TODO: not leak this :-)
59-
tex2d->retain();
53+
m_fontTexture = new CCTexture2D;
54+
m_fontTexture->initWithData(pixels, kCCTexture2DPixelFormat_RGBA8888, width, height, CCSize(width, height));
55+
m_fontTexture->retain();
6056

61-
io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(static_cast<intptr_t>(tex2d->getName())));
57+
io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(static_cast<intptr_t>(m_fontTexture->getName())));
6258

6359
// fixes getMousePos to be relative to the GD view
6460
#ifndef GEODE_IS_MOBILE
@@ -68,7 +64,6 @@ void DevTools::setupPlatform() {
6864
"geode::cocos::getMousePos"
6965
);
7066
#endif
71-
}
7267

7368
void DevTools::newFrame() {
7469
auto& io = ImGui::GetIO();

src/pages/Attributes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <misc/cpp/imgui_stdlib.h>
55
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
66
#include "../platform/utils.hpp"
7+
#include <ccTypes.h>
8+
#include <Geode/ui/Layout.hpp>
79

810
using namespace geode::prelude;
911

@@ -132,7 +134,7 @@ void DevTools::drawNodeAttributes(CCNode* node) {
132134
auto color = rgbaNode->getColor();
133135
float _color[4] = { color.r / 255.f, color.g / 255.f, color.b / 255.f, rgbaNode->getOpacity() / 255.f };
134136
if (ImGui::ColorEdit4("Color", _color)) {
135-
rgbaNode->setColor({
137+
rgbaNode->setColor(ccColor3B {
136138
static_cast<GLubyte>(_color[0] * 255),
137139
static_cast<GLubyte>(_color[1] * 255),
138140
static_cast<GLubyte>(_color[2] * 255)

src/pages/GeometryDash.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Geode/utils/ranges.hpp>
55
#include <Geode/binding/FLAlertLayer.hpp>
66
#include <Geode/binding/GJDropDownLayer.hpp>
7+
#include <Geode/ui/Layout.hpp>
78

89
void drawRowAxisArrow(
910
ImDrawList& foreground,
@@ -285,8 +286,8 @@ void DevTools::drawGD(GLRenderCtx* gdCtx) {
285286

286287
auto pad = ImGui::GetStyle().FramePadding.x;
287288

288-
auto winPos = ImGui::GetCursorScreenPos();
289-
auto winSize = ImGui::GetContentRegionAvail();
289+
auto winPos = ImGui::GetCursorScreenPos();
290+
auto winSize = ImGui::GetContentRegionAvail();
290291

291292
ImVec2 imgSize = {
292293
(winSize.y - pad * 2) * ratio,

src/pages/Settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <Geode/modify/AppDelegate.hpp>
77
#include <fmod.hpp>
88
#include <numeric>
9+
#include <Geode/binding/GameManager.hpp>
910

1011
using namespace geode::prelude;
1112

0 commit comments

Comments
 (0)