summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-21 17:44:03 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-23 11:42:23 -0500
commitfa7fc343a0e444da72938fad58d219cf52228976 (patch)
tree24630be0c54f9768a13f32c5970558768e343543 /editor
parent6fa3b137c74536d2bab77f3309ca5b4c60953fe0 (diff)
plugin checkpoint - multiple plugins and collision callbacks
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp53
-rw-r--r--editor/main.cpp10
2 files changed, 59 insertions, 4 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 5016070..db97802 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -696,6 +696,23 @@ void RecordImGuiUBO() {
ImGui::End();
}
+bool RecordImGui_CallbackSelectModal(long &selectedIndex) {
+ bool returnValue = false;
+ if (ImGui::BeginPopupModal("CallbackSelect", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
+ long count = 0;
+ auto *signatures = PkePlugin_GetSortedSignatures(count);
+ for (long i = 0; i < count; ++i) {
+ const CallbackSignature &sig = signatures[i];
+ if (ImGui::Selectable(sig, selectedIndex == i)) {
+ returnValue = true;
+ selectedIndex = i;
+ }
+ }
+ ImGui::EndPopup();
+ }
+ return returnValue;
+}
+
void RecordImGuiModalCreateEntityType() {
if (ImGui::BeginPopupModal("CreateEntityType", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
static char modelsDir[64];
@@ -835,6 +852,24 @@ void RecordImGui_CompGrBinds(bool readonly, CompGrBinds *component) {
ImGui::InputScalar("InstanceBufferMaxCount", ImGuiDataType_U32, &component->instanceBufferMaxCount, nullptr, nullptr, nullptr, ImGuiInputTextFlags_ReadOnly);
ImGui::InputScalar("Instance Count", ImGuiDataType_U32, &component->instanceCounter, nullptr, nullptr, nullptr, ImGuiInputTextFlags_ReadOnly);
+ static long index = -1;
+ if (ImGui::Button("Clear")) {
+ index = -1;
+ component->collisionCallback.name[0] = '\0';
+ }
+ ImGui::SameLine();
+ if (ImGui::Button("Change")) {
+ index = -1;
+ ImGui::OpenPopup("CallbackSelect");
+ }
+ ImGui::SameLine();
+ ImGui::Text("Collision Callback: '%s'", component->collisionCallback.name);
+ if (RecordImGui_CallbackSelectModal(index)) {
+ long x = 0;
+ memcpy(component->collisionCallback.name, PkePlugin_GetSortedSignatures(x)[index], 16);
+ PkePlugin_SetSignatureFunc(&component->collisionCallback);
+ }
+
ImGui::Spacing();
}
@@ -868,6 +903,24 @@ void RecordImGui_CompInstPos(bool readonly, CompInstance *component) {
changed = ImGui::InputScalar("Phys - Collision Layer", ImGuiDataType_U16, &component->physicsLayer, nullptr, nullptr, nullptr, inputTextFlags) || changed;
changed = ImGui::InputScalar("Phys - Collision Mask", ImGuiDataType_U16, &component->physicsMask, nullptr, nullptr, nullptr, inputTextFlags) || changed;
+ static long index = -1;
+ if (ImGui::Button("Clear")) {
+ index = -1;
+ component->collisionCallback.name[0] = '\0';
+ }
+ ImGui::SameLine();
+ if (ImGui::Button("Change")) {
+ index = -1;
+ ImGui::OpenPopup("CallbackSelect");
+ }
+ ImGui::SameLine();
+ ImGui::Text("Collision Callback: '%s'", component->collisionCallback.name);
+ if (RecordImGui_CallbackSelectModal(index)) {
+ long x = 0;
+ memcpy(component->collisionCallback.name, PkePlugin_GetSortedSignatures(x)[index], 16);
+ PkePlugin_SetSignatureFunc(&component->collisionCallback);
+ }
+
ImGui::InputScalar("Phys - Rigid Body", ImGuiDataType_U64, &component->bt.rigidBody, nullptr, nullptr, "0x%016lX", ImGuiInputTextFlags_ReadOnly);
ImGui::InputScalar("Phys - Motion State", ImGuiDataType_U64, &component->bt.motionState, nullptr, nullptr, "0x%016lX", ImGuiInputTextFlags_ReadOnly);
diff --git a/editor/main.cpp b/editor/main.cpp
index af0e66a..2dee016 100644
--- a/editor/main.cpp
+++ b/editor/main.cpp
@@ -23,10 +23,12 @@ int main(int argc, char *argv[]) {
{
pkeSettings.isSimulationPaused = true;
pkeSettings.isShowingEditor = true;
- pkePlugin.OnInit = PkeEditor_Init;
- pkePlugin.OnTick = PkeEditor_Tick;
- pkePlugin.OnTeardown = PkeEditor_Teardown;
- pkePlugin.OnImGuiRender = PkeEditor_RecordImGui;
+ LoadedPkePlugins.Push({
+ .OnInit = PkeEditor_Init,
+ .OnTick = PkeEditor_Tick,
+ .OnTeardown = PkeEditor_Teardown,
+ .OnImGuiRender = PkeEditor_RecordImGui,
+ });
}
// run
PkeArgs_Parse(argc, argv);