Added inter script compunication, and iptimised some stuff.
This commit is contained in:
parent
3ab114208b
commit
f419430bac
38
imgui.ini
38
imgui.ini
@ -21,13 +21,13 @@ DockId=0x00000018,0
|
||||
|
||||
[Window][Scene Tree]
|
||||
Pos=0,19
|
||||
Size=335,461
|
||||
Size=388,461
|
||||
Collapsed=0
|
||||
DockId=0x0000001B,0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=337,19
|
||||
Size=1214,659
|
||||
Pos=390,19
|
||||
Size=1161,659
|
||||
Collapsed=0
|
||||
DockId=0x00000017,0
|
||||
|
||||
@ -42,8 +42,8 @@ Collapsed=0
|
||||
DockId=0x00000019,0
|
||||
|
||||
[Window][Console]
|
||||
Pos=337,680
|
||||
Size=1238,273
|
||||
Pos=390,680
|
||||
Size=1185,273
|
||||
Collapsed=0
|
||||
DockId=0x00000013,0
|
||||
|
||||
@ -54,8 +54,8 @@ Collapsed=0
|
||||
DockId=0x00000017,1
|
||||
|
||||
[Window][Profiler]
|
||||
Pos=337,955
|
||||
Size=1238,222
|
||||
Pos=390,955
|
||||
Size=1185,222
|
||||
Collapsed=0
|
||||
DockId=0x00000014,0
|
||||
|
||||
@ -126,7 +126,7 @@ DockId=0x0000000D,0
|
||||
|
||||
[Window][Resources]
|
||||
Pos=0,600
|
||||
Size=335,577
|
||||
Size=388,577
|
||||
Collapsed=0
|
||||
DockId=0x00000010,0
|
||||
|
||||
@ -137,7 +137,7 @@ Collapsed=0
|
||||
|
||||
[Window][Lua Globals]
|
||||
Pos=0,482
|
||||
Size=335,116
|
||||
Size=388,116
|
||||
Collapsed=0
|
||||
DockId=0x0000001C,0
|
||||
|
||||
@ -146,27 +146,33 @@ RefScale=13
|
||||
Column 0 Weight=1.0000
|
||||
Column 1 Width=120
|
||||
|
||||
[Table][0x4F4AE173,3]
|
||||
RefScale=13
|
||||
Column 0 Width=102
|
||||
Column 1 Width=50
|
||||
Column 2 Weight=1.0000
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x11111111 Window=0x1BBC0F80 Pos=0,19 Size=1920,1158 Split=X
|
||||
DockNode ID=0x00000005 Parent=0x11111111 SizeRef=989,1158 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=335,701 Split=Y Selected=0x12EF0F59
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=388,701 Split=Y Selected=0x12EF0F59
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=342,637 Split=Y Selected=0x12EF0F59
|
||||
DockNode ID=0x0000000F Parent=0x00000003 SizeRef=342,579 Split=Y Selected=0x12EF0F59
|
||||
DockNode ID=0x0000001B Parent=0x0000000F SizeRef=335,461 HiddenTabBar=1 Selected=0x12EF0F59
|
||||
DockNode ID=0x0000001C Parent=0x0000000F SizeRef=335,116 HiddenTabBar=1 Selected=0x8CFF897F
|
||||
DockNode ID=0x00000010 Parent=0x00000003 SizeRef=342,577 HiddenTabBar=1 Selected=0x30401527
|
||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=342,519 HiddenTabBar=1 Selected=0x36AF052B
|
||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=943,701 Split=Y Selected=0xC450F867
|
||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1530,701 Split=Y Selected=0xC450F867
|
||||
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=606,659 Split=X Selected=0xC450F867
|
||||
DockNode ID=0x00000017 Parent=0x00000007 SizeRef=574,860 CentralNode=1 HiddenTabBar=1 Selected=0xC450F867
|
||||
DockNode ID=0x00000017 Parent=0x00000007 SizeRef=1161,860 CentralNode=1 HiddenTabBar=1 Selected=0xC450F867
|
||||
DockNode ID=0x00000018 Parent=0x00000007 SizeRef=367,860 HiddenTabBar=1 Selected=0x36DC96AB
|
||||
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=606,497 Split=X Selected=0xEA83D666
|
||||
DockNode ID=0x00000015 Parent=0x00000008 SizeRef=767,172 Split=X Selected=0xEA83D666
|
||||
DockNode ID=0x00000011 Parent=0x00000015 SizeRef=736,168 Split=Y Selected=0x9B5D3198
|
||||
DockNode ID=0x00000015 Parent=0x00000008 SizeRef=1236,172 Split=X Selected=0xEA83D666
|
||||
DockNode ID=0x00000011 Parent=0x00000015 SizeRef=1185,168 Split=Y Selected=0x9B5D3198
|
||||
DockNode ID=0x00000013 Parent=0x00000011 SizeRef=1449,273 HiddenTabBar=1 Selected=0xEA83D666
|
||||
DockNode ID=0x00000014 Parent=0x00000011 SizeRef=1449,222 HiddenTabBar=1 Selected=0x9B5D3198
|
||||
DockNode ID=0x00000012 Parent=0x00000015 SizeRef=29,168 HiddenTabBar=1 Selected=0x56009A08
|
||||
DockNode ID=0x00000016 Parent=0x00000008 SizeRef=174,172 Split=Y Selected=0x3FC1A724
|
||||
DockNode ID=0x00000012 Parent=0x00000015 SizeRef=49,168 HiddenTabBar=1 Selected=0x56009A08
|
||||
DockNode ID=0x00000016 Parent=0x00000008 SizeRef=292,172 Split=Y Selected=0x3FC1A724
|
||||
DockNode ID=0x00000019 Parent=0x00000016 SizeRef=314,268 HiddenTabBar=1 Selected=0x3FC1A724
|
||||
DockNode ID=0x0000001A Parent=0x00000016 SizeRef=314,227 HiddenTabBar=1 Selected=0xA873C17F
|
||||
DockNode ID=0x00000006 Parent=0x11111111 SizeRef=289,1158 Split=Y Selected=0x36DC96AB
|
||||
|
@ -1,5 +1,3 @@
|
||||
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -Isrc/vendor/xxhash -Isrc/vendor/miniaudio -Isrc/vendor/imguizmo -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\core\scripts\ScriptCore.cpp -o src\build\core\scripts\ScriptCore.o
|
||||
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -Isrc/vendor/xxhash -Isrc/vendor/miniaudio -Isrc/vendor/imguizmo -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\Engine.cpp -o src\build\Engine.o
|
||||
[LINK] g++ src\build\Engine.o src\build\main.o src\build\Renderer.o src\build\Components\AnimationComponent.o src\build\Components\AudioPlayerComponent.o src\build\Components\CameraComponent.o src\build\Components\LightComponent.o src\build\Components\ParticleComponent.o src\build\Components\PhysicsComponent.o src\build\Components\ScriptComponent.o src\build\Components\SpriteComponent.o src\build\Components\TextComonent.o src\build\Components\TilemapComponent.o src\build\core\audio\AudioEngine.o src\build\core\functions\Prefab.o src\build\core\functions\ScenePacker.o src\build\core\scripts\LuaGlobalBridge.o src\build\core\scripts\ScriptCore.o src\build\core\utils\AssetManager.o src\build\core\utils\EngineConfig.o src\build\core\utils\ExceptionHandler.o src\build\core\utils\FileDialog.o src\build\core\utils\input.o src\build\core\utils\LoadingWindow.o src\build\core\utils\Logging.o src\build\core\utils\Popup.o src\build\core\utils\Profiler.o src\build\core\utils\Texture.o src\build\core\utils\utils.o src\build\editor\windows\AssetBrowser.o src\build\editor\windows\AudioInfo.o src\build\editor\windows\Inspector.o src\build\editor\windows\LuaGlobals.o src\build\Entitys\Object.o src\build\utils\GameObjectsList.o src\build\utils\Shader.o src\build\utils\UID.o src\build\lapi.o src\build\lauxlib.o src\build\lbaselib.o src\build\lcode.o src\build\lcorolib.o src\build\lctype.o src\build\ldblib.o src\build\ldebug.o src\build\ldo.o src\build\ldump.o src\build\lfunc.o src\build\lgc.o src\build\linit.o src\build\liolib.o src\build\llex.o src\build\lmathlib.o src\build\lmem.o src\build\loadlib.o src\build\lobject.o src\build\lopcodes.o src\build\loslib.o src\build\lparser.o src\build\lstate.o src\build\lstring.o src\build\lstrlib.o src\build\ltable.o src\build\ltablib.o src\build\ltm.o src\build\lua.o src\build\luac.o src\build\lundump.o src\build\lutf8lib.o src\build\lvm.o src\build\lzio.o src\build\imgui.o src\build\imgui_demo.o src\build\imgui_draw.o src\build\imgui_impl_glfw.o src\build\imgui_impl_opengl3.o src\build\imgui_tables.o src\build\imgui_widgets.o src\build\aabb.o src\build\arena_allocator.o src\build\array.o src\build\bitset.o src\build\body.o src\build\broad_phase.o src\build\constraint_graph.o src\build\contact.o src\build\contact_solver.o src\build\core.o src\build\distance.o src\build\distance_joint.o src\build\dynamic_tree.o src\build\geometry.o src\build\hull.o src\build\id_pool.o src\build\island.o src\build\joint.o src\build\manifold.o src\build\math_functions.o src\build\motor_joint.o src\build\mouse_joint.o src\build\mover.o src\build\prismatic_joint.o src\build\revolute_joint.o src\build\sensor.o src\build\shape.o src\build\solver.o src\build\solver_set.o src\build\table.o src\build\timer.o src\build\types.o src\build\weld_joint.o src\build\wheel_joint.o src\build\world.o src\build\xxhash.o src\build\miniaudio.o src\build\ImGuizmo.o -o src\build\app.exe -LC:\msys64\mingw64\lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto -ldbghelp -lz
|
||||
[ERROR] Runtime crash
|
||||
Command 'src\build\app.exe' returned non-zero exit status 3221225477.
|
||||
|
@ -1,4 +1,6 @@
|
||||
-- Called once on load
|
||||
|
||||
|
||||
|
||||
function OnInit()
|
||||
player = Engine.GetObjectByTag("PlayerRoot")
|
||||
if not player then
|
||||
@ -28,11 +30,15 @@ function OnUpdate(dt)
|
||||
pos.y = pos.y + move.y * speed * dt
|
||||
player:SetPosition(pos)
|
||||
|
||||
Engine.SetGlobal("player_pos.x", pos.x)
|
||||
Engine.SetGlobal("player_pos.y", pos.y)
|
||||
|
||||
|
||||
|
||||
-- Simulate damage each second
|
||||
local hp = Engine.GetGlobal("player_health") or 100
|
||||
hp = hp - dt * 5
|
||||
Engine.SetGlobal("player_health", hp)
|
||||
|
||||
-- Debug print
|
||||
Engine.LogDebug(string.format("HP: %.1f", hp))
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,11 @@
|
||||
#include "AnimationComponent.h"
|
||||
|
||||
AnimationComponent::AnimationComponent(Object *owner)
|
||||
: Component(owner) {}
|
||||
: Component(owner)
|
||||
{
|
||||
|
||||
renderType = RenderType::Unlit;
|
||||
}
|
||||
|
||||
void AnimationComponent::SetTextureAtlasPath(const std::string &path, int texelWidth, int texelHeight, float duration, int start, int end)
|
||||
{
|
||||
@ -65,7 +69,7 @@ void AnimationComponent::SetTextureAtlas(uint64_t uaid, int texelWidth, int texe
|
||||
frameDuration = duration;
|
||||
currentFrame = startFrame;
|
||||
|
||||
renderType = RenderType::Unlit;
|
||||
|
||||
}
|
||||
|
||||
void AnimationComponent::Play() { playing = true; }
|
||||
@ -141,7 +145,6 @@ void AnimationComponent::Save(YAML::Emitter &out) const
|
||||
out << YAML::Key << "EndFrame" << YAML::Value << endFrame;
|
||||
out << YAML::Key << "renderType" << YAML::Value << (renderType == RenderType::Lit ? "Lit" : "Unlit");
|
||||
out << YAML::EndMap;
|
||||
|
||||
}
|
||||
|
||||
void AnimationComponent::Load(const YAML::Node &node)
|
||||
@ -154,7 +157,7 @@ void AnimationComponent::Load(const YAML::Node &node)
|
||||
int start = node["StartFrame"] ? node["StartFrame"].as<int>() : 0;
|
||||
int end = node["EndFrame"] ? node["EndFrame"].as<int>() : 0;
|
||||
|
||||
if (node["renderType"] && node["renderType"].IsScalar())
|
||||
if (node["renderType"])
|
||||
{
|
||||
std::string typeStr = node["renderType"].as<std::string>();
|
||||
if (typeStr == "Lit")
|
||||
@ -166,6 +169,10 @@ void AnimationComponent::Load(const YAML::Node &node)
|
||||
Create::Exceptions::InvalidFormat)
|
||||
.Handle();
|
||||
}
|
||||
else
|
||||
{
|
||||
renderType = RenderType::Unlit;
|
||||
}
|
||||
|
||||
SetTextureAtlas(uaid, texelWidth, texelHeight, duration, start, end);
|
||||
}
|
||||
|
@ -599,7 +599,6 @@ core::types::Vec2 ScreenToWorld(const core::types::Vec2 &screenPos, const core::
|
||||
|
||||
void Engine::collectObjects(bool playing, const glm::vec2 &camPos, float camZoom)
|
||||
{
|
||||
|
||||
m_activeCamera = nullptr;
|
||||
|
||||
m_toDraw.clear();
|
||||
@ -610,9 +609,12 @@ void Engine::collectObjects(bool playing, const glm::vec2 &camPos, float camZoom
|
||||
|
||||
const glm::vec2 screenSize = glm::vec2(Renderer::GetSize());
|
||||
|
||||
for (auto &root : objects)
|
||||
// Seed the collection stack with all root objects
|
||||
for (const auto &root : objects)
|
||||
{
|
||||
if (root && !root->GetParent())
|
||||
m_collectStack.push_back(root);
|
||||
}
|
||||
|
||||
while (!m_collectStack.empty())
|
||||
{
|
||||
@ -622,12 +624,14 @@ void Engine::collectObjects(bool playing, const glm::vec2 &camPos, float camZoom
|
||||
if (!obj->GetVisable())
|
||||
continue;
|
||||
|
||||
m_toDraw.push_back(obj.get());
|
||||
Object *raw = obj.get();
|
||||
m_toDraw.push_back(raw);
|
||||
|
||||
if (auto light = obj->GetComponent<LightComponent>())
|
||||
// Light rendering
|
||||
if (auto *light = raw->GetComponent<LightComponent>().get())
|
||||
{
|
||||
glm::vec2 world = obj->GetWorldPosition();
|
||||
glm::vec2 screen = (world - camPos) * camZoom + screenSize * 0.5f;
|
||||
const glm::vec2 world = raw->GetWorldPosition();
|
||||
const glm::vec2 screen = (world - camPos) * camZoom + screenSize * 0.5f;
|
||||
Renderer::AddLight(screen, light->GetColor(), light->GetIntensity(), light->GetRadius() * camZoom);
|
||||
}
|
||||
|
||||
@ -640,20 +644,22 @@ void Engine::collectObjects(bool playing, const glm::vec2 &camPos, float camZoom
|
||||
}
|
||||
}
|
||||
|
||||
if (auto particles = obj->GetComponent<ParticleComponent>())
|
||||
m_particleUpdates.push_back(particles.get());
|
||||
if (auto animator = obj->GetComponent<AnimationComponent>())
|
||||
m_animationsUpdates.push_back(animator.get());
|
||||
// Component collection
|
||||
if (auto *particle = raw->GetComponent<ParticleComponent>().get())
|
||||
m_particleUpdates.push_back(particle);
|
||||
|
||||
if (auto *animator = raw->GetComponent<AnimationComponent>().get())
|
||||
m_animationsUpdates.push_back(animator);
|
||||
|
||||
if (playing)
|
||||
{
|
||||
|
||||
if (auto physics = obj->GetComponent<PhysicsComponent>())
|
||||
m_physicsUpdates.push_back(physics.get());
|
||||
if (auto *physics = raw->GetComponent<PhysicsComponent>().get())
|
||||
m_physicsUpdates.push_back(physics);
|
||||
}
|
||||
|
||||
for (auto &child : obj->GetChildren())
|
||||
m_collectStack.push_back(child);
|
||||
// Push children to the stack
|
||||
const auto &children = raw->GetChildren();
|
||||
m_collectStack.insert(m_collectStack.end(), children.begin(), children.end());
|
||||
}
|
||||
}
|
||||
|
||||
@ -979,16 +985,38 @@ void Engine::Run()
|
||||
profiler.EndEngineSection();
|
||||
|
||||
profiler.BeginEngineSection("Sort Objects");
|
||||
|
||||
if (m_toDraw.size() > 1)
|
||||
{
|
||||
std::sort(m_toDraw.begin(), m_toDraw.end(),
|
||||
[](auto const &a, auto const &b)
|
||||
struct SortKey
|
||||
{
|
||||
if (a->layer != b->layer)
|
||||
return a->layer < b->layer;
|
||||
return a->GetWorldPosition().y < b->GetWorldPosition().y;
|
||||
});
|
||||
int layer;
|
||||
float y;
|
||||
Object *obj;
|
||||
};
|
||||
|
||||
std::vector<SortKey> keys;
|
||||
keys.reserve(m_toDraw.size());
|
||||
|
||||
for (Object *obj : m_toDraw)
|
||||
{
|
||||
keys.push_back({obj->layer, obj->GetWorldPosition().y, obj});
|
||||
}
|
||||
|
||||
std::sort(keys.begin(), keys.end(),
|
||||
[](const SortKey &a, const SortKey &b)
|
||||
{
|
||||
if (a.layer != b.layer)
|
||||
return a.layer < b.layer;
|
||||
return a.y < b.y;
|
||||
});
|
||||
|
||||
for (size_t i = 0; i < keys.size(); ++i)
|
||||
{
|
||||
m_toDraw[i] = keys[i].obj;
|
||||
}
|
||||
}
|
||||
|
||||
profiler.EndEngineSection();
|
||||
|
||||
m_OnUpdateCalls = 0;
|
||||
@ -1389,16 +1417,22 @@ void Engine::DrawObjectNode(const std::shared_ptr<Object> &obj)
|
||||
|
||||
PROFILE_ENGINE_SCOPE("Engine::DrawObjectNode");
|
||||
|
||||
const bool isSelected = (obj == selected);
|
||||
const bool hasChildren = !obj->GetChildren().empty();
|
||||
const char *name = obj->GetName().c_str();
|
||||
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow |
|
||||
ImGuiTreeNodeFlags_SpanAvailWidth |
|
||||
ImGuiTreeNodeFlags_DefaultOpen |
|
||||
(obj == selected ? ImGuiTreeNodeFlags_Selected : 0);
|
||||
(isSelected ? ImGuiTreeNodeFlags_Selected : 0) |
|
||||
(!hasChildren ? ImGuiTreeNodeFlags_Leaf : 0);
|
||||
|
||||
bool open = ImGui::TreeNodeEx((void *)(intptr_t)obj->uid.id, flags, "%s", obj->GetName().c_str());
|
||||
bool open = ImGui::TreeNodeEx((void *)(intptr_t)obj->uid.id, flags, "%s", name);
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
selected = obj;
|
||||
|
||||
// --- Right-click context menu ---
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
if (ImGui::MenuItem("Delete"))
|
||||
@ -1415,15 +1449,10 @@ void Engine::DrawObjectNode(const std::shared_ptr<Object> &obj)
|
||||
if (ImGui::MenuItem("Duplicate"))
|
||||
{
|
||||
auto clone = std::make_shared<Object>(*obj);
|
||||
|
||||
if (auto parent = obj->GetParent())
|
||||
{
|
||||
parent->AddChild(clone);
|
||||
}
|
||||
else
|
||||
{
|
||||
objects.push_back(clone);
|
||||
}
|
||||
|
||||
selected = clone;
|
||||
ImGui::OpenPopup("RenameObject");
|
||||
@ -1431,43 +1460,40 @@ void Engine::DrawObjectNode(const std::shared_ptr<Object> &obj)
|
||||
|
||||
if (ImGui::MenuItem("Convert to Prefab"))
|
||||
{
|
||||
std::string path = Prefab::CreatePrefab(obj, "C:/Users/spenc/OneDrive/Desktop");
|
||||
std::string path = Prefab::CreatePrefab(obj);
|
||||
if (!path.empty())
|
||||
{
|
||||
Logger::LogInfo("[Prefab] Saved prefab to: %s", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::LogError("[Prefab] Failed to create prefab.");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// --- Drag source ---
|
||||
if (ImGui::BeginDragDropSource())
|
||||
{
|
||||
auto dragRef = obj;
|
||||
ImGui::SetDragDropPayload("OBJECT", &dragRef, sizeof(dragRef));
|
||||
ImGui::Text("%s", obj->GetName().c_str());
|
||||
ImGui::SetDragDropPayload("OBJECT", &obj, sizeof(obj));
|
||||
ImGui::Text("%s", name);
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (auto payload = ImGui::AcceptDragDropPayload("OBJECT"))
|
||||
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("OBJECT"))
|
||||
{
|
||||
auto dragged = *static_cast<std::shared_ptr<Object> *>(payload->Data);
|
||||
|
||||
if (dragged && dragged != obj)
|
||||
{
|
||||
bool valid = true;
|
||||
for (Object *a = obj.get(); a; a = a->GetParent())
|
||||
{
|
||||
if (a == dragged.get())
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
@ -1487,9 +1513,12 @@ void Engine::DrawObjectNode(const std::shared_ptr<Object> &obj)
|
||||
|
||||
if (open)
|
||||
{
|
||||
for (auto &child : obj->GetChildren())
|
||||
if (hasChildren)
|
||||
{
|
||||
for (const auto &child : obj->GetChildren())
|
||||
if (child)
|
||||
DrawObjectNode(child);
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <sstream>
|
||||
|
||||
|
||||
std::string Prefab::CreatePrefab(const std::shared_ptr<Object>& obj, const std::string& outputDir)
|
||||
std::string Prefab::CreatePrefab(const std::shared_ptr<Object>& obj)
|
||||
{
|
||||
if (!obj)
|
||||
return "";
|
||||
@ -23,7 +23,7 @@ std::string Prefab::CreatePrefab(const std::shared_ptr<Object>& obj, const std::
|
||||
if (ch == '/' || ch == '\\' || ch == ':' || ch == '*' || ch == '?' || ch == '\"' || ch == '<' || ch == '>' || ch == '|')
|
||||
ch = '_';
|
||||
|
||||
std::string path = outputDir + "/" + filename + ".cpfb";
|
||||
std::string path = "C:/Users/spenc/OneDrive/Desktop/" + filename + ".cpfb";
|
||||
|
||||
// Serialize Object to string
|
||||
YAML::Emitter objectOut;
|
||||
|
@ -9,5 +9,5 @@ namespace Prefab
|
||||
{
|
||||
// Saves the object as a .cpfb prefab file
|
||||
// Returns the full path it saved to (empty string on failure)
|
||||
std::string CreatePrefab(const std::shared_ptr<Object>& obj, const std::string& outputDir);
|
||||
std::string CreatePrefab(const std::shared_ptr<Object>& obj);
|
||||
}
|
||||
|
@ -6,11 +6,13 @@
|
||||
void ScriptCore::Init()
|
||||
{
|
||||
s_LuaStates.clear();
|
||||
Logger::LogOk("Script Core");
|
||||
}
|
||||
|
||||
void ScriptCore::RegisterState(lua_State* L, const std::string& scriptPath, const std::string& name)
|
||||
{
|
||||
s_LuaStates.push_back({ L, scriptPath, name });
|
||||
Logger::LogVerbose("[ScriptCore] Registered Script Instace '%s'", name.c_str());
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,12 @@
|
||||
#include "../../core/utils/EngineConfig.h"
|
||||
#include <imgui.h>
|
||||
|
||||
#include "LuaGlobals.h"
|
||||
#include "../../core/scripts/LuaGlobalBridge.h"
|
||||
#include "../../core/utils/Logging.h"
|
||||
#include "../../core/utils/EngineConfig.h"
|
||||
#include <imgui.h>
|
||||
|
||||
void DrawImGuiWindow()
|
||||
{
|
||||
if (!g_engineConfig.settings.show_lua_globals_window)
|
||||
@ -11,7 +17,7 @@ void DrawImGuiWindow()
|
||||
|
||||
auto allGlobals = LuaGlobalBridge::GetAll();
|
||||
|
||||
ImGui::Begin("Lua Globals");
|
||||
ImGui::Begin("Lua Globals", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
|
||||
if (allGlobals.empty())
|
||||
{
|
||||
@ -22,25 +28,24 @@ void DrawImGuiWindow()
|
||||
ImGui::Text("Active Globals");
|
||||
ImGui::Separator();
|
||||
|
||||
// 3 columns: Key | Type | Value
|
||||
ImGui::Columns(3, nullptr, false);
|
||||
ImGui::SetColumnWidth(0, 180);
|
||||
ImGui::SetColumnWidth(1, 80);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(6, 4));
|
||||
ImGui::PushStyleColor(ImGuiCol_TableHeaderBg, ImVec4(0.15f, 0.18f, 0.22f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_TableBorderStrong, ImVec4(0.3f, 0.3f, 0.3f, 0.5f));
|
||||
|
||||
ImGui::TextColored(ImVec4(1, 1, 0.4f, 1), "Key");
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextColored(ImVec4(0.7f, 1, 0.7f, 1), "Type");
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextColored(ImVec4(1, 1, 0.4f, 1), "Value");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("GlobalsTable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable))
|
||||
{
|
||||
ImGui::TableSetupColumn("Key", ImGuiTableColumnFlags_WidthFixed, 180.0f);
|
||||
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, 80.0f);
|
||||
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for (const auto &[key, value] : allGlobals)
|
||||
{
|
||||
std::string typeStr;
|
||||
std::string valueStr;
|
||||
|
||||
std::visit([&](auto&& val) {
|
||||
std::visit([&](auto &&val)
|
||||
{
|
||||
using T = std::decay_t<decltype(val)>;
|
||||
if constexpr (std::is_same_v<T, double>) {
|
||||
typeStr = "number";
|
||||
@ -53,20 +58,25 @@ void DrawImGuiWindow()
|
||||
else if constexpr (std::is_same_v<T, std::string>) {
|
||||
typeStr = "string";
|
||||
valueStr = val;
|
||||
}
|
||||
}, value);
|
||||
} }, value);
|
||||
|
||||
ImGui::TextUnformatted(key.c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TextColored(ImVec4(0.7f, 0.9f, 1.0f, 1.0f), typeStr.c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("%s", key.c_str());
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextColored(ImVec4(0.7f, 0.9f, 1.0f, 1.0f), "%s", typeStr.c_str());
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
ImGui::TextWrapped("%s", valueStr.c_str());
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
Loading…
Reference in New Issue
Block a user