mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Added EditorFlags: Hide entities in hierarchy and editor scene
- Also some Style changes
This commit is contained in:
@@ -3,7 +3,7 @@ Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", FreeType = "*", cg
|
||||
|
||||
[Project]
|
||||
Name = "GlitchyEngine"
|
||||
ProcessorMacros = ["GE_GRAPHICS_DX11", "GE_SHADER_MATRIX_MISMATCH_IS_ERROR", "GE_SHADER_VAR_TYPE_MISMATCH_IS_ERROR", "GE_SHADER_UNUSED_VARIABLE_IS_WARNING", "GE_WINDOWS"]
|
||||
ProcessorMacros = ["GE_GRAPHICS_DX11", "GE_SHADER_MATRIX_MISMATCH_IS_ERROR", "GE_SHADER_VAR_TYPE_MISMATCH_IS_ERROR", "GE_SHADER_UNUSED_VARIABLE_IS_WARNING", "GE_WINDOWS", "GE_EDITOR"]
|
||||
|
||||
[Configs.Paranoid.Win32]
|
||||
PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GlitchyEngine.Editor;
|
||||
|
||||
enum EditorFlags
|
||||
{
|
||||
Default = 0,
|
||||
HideInHierarchy = 1,
|
||||
HideInScene = 2,
|
||||
}
|
||||
@@ -138,7 +138,9 @@ namespace ImGui
|
||||
public static void TextUnformatted(StringView text) => TextUnformattedImpl(text.Ptr, text.Ptr + text.Length);
|
||||
|
||||
public static void PushID(StringView id) => PushID(id.Ptr, id.Ptr + id.Length);
|
||||
|
||||
|
||||
public static void PushID(int id) => PushID((void*)id);
|
||||
|
||||
/// Releases references that accumulated calls like ImGui::Image
|
||||
protected internal static extern void CleanupFrame();
|
||||
|
||||
|
||||
@@ -136,6 +136,8 @@ namespace GlitchyEngine.ImGui
|
||||
colors[(.)ImGui.Col.Tab] = ImGui.Vec4(0.473f, 0.519f, 0.580f, 1.00f);
|
||||
colors[(.)ImGui.Col.TabUnfocused] = ImGui.Vec4(0.255f, 0.255f, 0.255f, 1.00f);
|
||||
colors[(.)ImGui.Col.CheckMark] = ImGui.Vec4(0.851f, 0.863f, 0.900f, 1.00f);
|
||||
colors[(.)ImGui.Col.TitleBg] = ImGui.Vec4(0.406f, 0.401f, 0.390f, 1.000f);
|
||||
colors[(.)ImGui.Col.TitleBgActive] = ImGui.Vec4(0.196f, 0.192f, 0.182f, 1.000f);
|
||||
|
||||
/*colors[(.)ImGui.Col.Text] = ImGui.Vec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
colors[(.)ImGui.Col.TextDisabled] = ImGui.Vec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||
|
||||
@@ -10,6 +10,8 @@ using System.Collections;
|
||||
using Box2D;
|
||||
using GlitchyEngine.Scripting;
|
||||
using GlitchyEngine.Serialization;
|
||||
using GlitchyEngine.Editor;
|
||||
using GlitchyEngine.World.Components;
|
||||
|
||||
namespace GlitchyEngine.Scripting;
|
||||
|
||||
@@ -187,6 +189,23 @@ static class ScriptGlue
|
||||
component = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Gets the entity. Returns true, if the entity was found.
|
||||
static bool TryGetEntitySafe(UUID entityId, out Entity entity)
|
||||
{
|
||||
entity = default;
|
||||
|
||||
Result<Entity> foundEntity = ScriptEngine.Context.GetEntityByID(entityId);
|
||||
|
||||
if (foundEntity case .Ok(out entity))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.ClientLogger.Error($"No entity with ID {entityId} found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#region Exception Helpers
|
||||
|
||||
@@ -461,6 +480,25 @@ static class ScriptGlue
|
||||
|
||||
Mono.mono_free(rawName);
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Entity_GetEditorFlags")]
|
||||
static void Entity_GetEditorFlags(UUID entityId, out EditorFlags editorFlags)
|
||||
{
|
||||
editorFlags = .Default;
|
||||
#if GE_EDITOR
|
||||
if (TryGetEntitySafe(entityId, let entity))
|
||||
editorFlags = entity.EditorFlags;
|
||||
#endif
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Entity_SetEditorFlags")]
|
||||
static void Entity_SetEditorFlags(UUID entityId, EditorFlags editorFlags)
|
||||
{
|
||||
#if GE_EDITOR
|
||||
if (TryGetEntitySafe(entityId, let entity))
|
||||
entity.EditorFlags = editorFlags;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
using GlitchyEngine.Editor;
|
||||
namespace GlitchyEngine.World.Components;
|
||||
|
||||
struct EditorFlagsComponent
|
||||
{
|
||||
public EditorFlags Flags;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using GlitchyEngine.Core;
|
||||
using GlitchyEngine.Editor;
|
||||
using GlitchyEngine.World.Components;
|
||||
|
||||
using internal GlitchyEngine.World;
|
||||
|
||||
@@ -74,6 +76,22 @@ namespace GlitchyEngine.World
|
||||
|
||||
public TransformComponent* Transform => GetComponent<TransformComponent>();
|
||||
|
||||
public EditorFlags EditorFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TryGetComponent<EditorFlagsComponent>(let flagsComponent))
|
||||
return flagsComponent.Flags;
|
||||
|
||||
return .Default;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (TryGetComponent<EditorFlagsComponent>(let flagsComponent))
|
||||
flagsComponent.Flags = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T* AddComponent<T>(T value = T()) where T: struct, new
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(!HasComponent<T>(), scope $"Entity already has component.");
|
||||
|
||||
Reference in New Issue
Block a user