[API] Memory editor extension (#110)

* Working on memory editor bindings for SpaiR/imgui-java#109

* Initial working implementation

* Add mising entry for imgui_club in .gitmodules

* Sorry, fixing readme link type and description for memory editor.

* Rename .club package to .memedit

* Rename _club.h to _memedit.h
This commit is contained in:
Trevor Flynn authored and GitHub committed 2022-02-02 13:17:07 +02:00
1 parent 9a5a1d2757
commit fefac80157
9 files changed
+251 -1

No files matched your search

@@ -0,0 +1,48 @@
import imgui.extension.memedit.MemoryEditor;
import imgui.flag.ImGuiCond;
import imgui.internal.ImGui;
import imgui.type.ImBoolean;
import org.lwjgl.system.MemoryUtil;
import java.awt.*;
import java.net.URI;
import java.nio.ByteBuffer;
public class ExampleImGuiMemoryEditor {
private static final String URL = "https://github.com/ocornut/imgui_club";
private static ByteBuffer demoData;
private static MemoryEditor memoryEditor;
private static ImBoolean showingMemoryEditor = new ImBoolean(false);
static {
demoData = MemoryUtil.memASCII("Welcome to the demo for Dear ImGui Memory Editor." +
"\n The git repo is located at " + URL + "." +
"You can use this memory editor to view the raw memory values at some pointer location.");
memoryEditor = new MemoryEditor();
}
public static void show(ImBoolean showImGuiMemoryEditor) {
ImGui.setNextWindowSize(400, 200, ImGuiCond.Once);
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once);
if (ImGui.begin("ImGuiMemoryEditor Demo", showImGuiMemoryEditor)) {
ImGui.text("This a demo for ImGui MemoryEditor");
ImGui.alignTextToFramePadding();
ImGui.text("Repo:");
ImGui.sameLine();
if (ImGui.button(URL)) {
try {
Desktop.getDesktop().browse(new URI(URL));
} catch (Exception e) {
e.printStackTrace();
}
}
ImGui.checkbox("Memory Editor", showingMemoryEditor);
if (showingMemoryEditor.get()) {
memoryEditor.drawWindow("Example Data", MemoryUtil.memAddress(demoData), demoData.capacity());
}
}
ImGui.end();
}
}
+6
View File
@@ -11,6 +11,7 @@ public class Extra {
private static final ImBoolean SHOW_IMGUIZMO_DEMO = new ImBoolean(false);
private static final ImBoolean SHOW_IMGUI_COLOR_TEXT_EDIT_WINDOW = new ImBoolean(false);
private static final ImBoolean SHOW_IMGUI_FILE_DIALOG_WINDOW = new ImBoolean(false);
private static final ImBoolean SHOW_IMGUI_MEMORY_EDITOR_WINDOW = new ImBoolean(false);
private static final Graph GRAPH = new Graph();
@@ -24,6 +25,7 @@ public class Extra {
ImGui.checkbox("Show ImGuizmo Demo Window", SHOW_IMGUIZMO_DEMO);
ImGui.checkbox("Show ImGuiColorTextEdit Demo Window", SHOW_IMGUI_COLOR_TEXT_EDIT_WINDOW);
ImGui.checkbox("Show ImGuiFileDialog Demo Window", SHOW_IMGUI_FILE_DIALOG_WINDOW);
ImGui.checkbox("Show ImGui MemoryEditor Demo Window", SHOW_IMGUI_MEMORY_EDITOR_WINDOW);
if (SHOW_DEMO_WINDOW.get()) {
ImGui.showDemoWindow(SHOW_DEMO_WINDOW);
@@ -56,5 +58,9 @@ public class Extra {
if (SHOW_IMGUI_FILE_DIALOG_WINDOW.get()) {
ExampleImGuiFileDialog.show(SHOW_IMGUI_FILE_DIALOG_WINDOW);
}
if (SHOW_IMGUI_MEMORY_EDITOR_WINDOW.get()) {
ExampleImGuiMemoryEditor.show(SHOW_IMGUI_MEMORY_EDITOR_WINDOW);
}
}
}