Added C-style versions of SHLog functions and P/Invoke versions in SHADE_CSharp
This commit is contained in:
parent
10a945a35d
commit
51c79d33d6
|
@ -35,6 +35,10 @@ project "SHADE_CSharp"
|
||||||
optimize "On"
|
optimize "On"
|
||||||
defines{"_RELEASE"}
|
defines{"_RELEASE"}
|
||||||
|
|
||||||
|
filter "configurations:Publish"
|
||||||
|
optimize "On"
|
||||||
|
defines{"_RELEASE"}
|
||||||
|
|
||||||
require "vstudio"
|
require "vstudio"
|
||||||
|
|
||||||
function platformsElement(cfg)
|
function platformsElement(cfg)
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
internal static class Debug
|
||||||
|
{
|
||||||
|
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Info")]
|
||||||
|
public static extern void LogInfo([MarshalAs(UnmanagedType.LPStr)] string str);
|
||||||
|
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Warning")]
|
||||||
|
public static extern void LogWarning([MarshalAs(UnmanagedType.LPStr)] string str);
|
||||||
|
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Error")]
|
||||||
|
public static extern void LogError([MarshalAs(UnmanagedType.LPStr)] string str);
|
||||||
|
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Critical")]
|
||||||
|
public static extern void LogCritical([MarshalAs(UnmanagedType.LPStr)] string str);
|
||||||
|
public static void LogInfo(string msg, Object thrower)
|
||||||
|
{
|
||||||
|
LogInfo($"[{thrower.GetType().Name}] {msg}");
|
||||||
|
}
|
||||||
|
public static void LogWarning(string msg, Object thrower)
|
||||||
|
{
|
||||||
|
LogWarning($"[{thrower.GetType().Name}] {msg}");
|
||||||
|
}
|
||||||
|
public static void LogError(string msg, Object thrower)
|
||||||
|
{
|
||||||
|
LogError($"[{thrower.GetType().Name}] {msg}");
|
||||||
|
}
|
||||||
|
public static void LogCritical(string msg, Object thrower)
|
||||||
|
{
|
||||||
|
LogCritical($"[{thrower.GetType().Name}] {msg}");
|
||||||
|
}
|
||||||
|
public static void LogException(Exception exception, Object thrower)
|
||||||
|
{
|
||||||
|
LogError($"[{ thrower.GetType().Name }] Unhandled exception: { exception.ToString() }");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,4 +51,24 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void SHLog_Info(const char* msg) noexcept
|
||||||
|
{
|
||||||
|
SHLOG_INFO(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHLog_Warning(const char* msg) noexcept
|
||||||
|
{
|
||||||
|
SHLOG_WARNING(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHLog_Error(const char* msg) noexcept
|
||||||
|
{
|
||||||
|
SHLOG_ERROR(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHLog_Critical(const char* msg) noexcept
|
||||||
|
{
|
||||||
|
SHLOG_CRITICAL(msg)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,12 @@ namespace SHADE
|
||||||
static void Trace(const std::string& msg) noexcept;
|
static void Trace(const std::string& msg) noexcept;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
static void SHLog_Info(const char* msg) noexcept;
|
||||||
|
static void SHLog_Warning(const char* msg) noexcept;
|
||||||
|
static void SHLog_Error(const char* msg) noexcept;
|
||||||
|
static void SHLog_Critical(const char* msg) noexcept;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ project "SHADE_Managed"
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
"imgui",
|
"imgui",
|
||||||
"SHADE_Engine"
|
"SHADE_Engine",
|
||||||
|
"SHADE_CSharp"
|
||||||
}
|
}
|
||||||
|
|
||||||
disablewarnings
|
disablewarnings
|
||||||
|
|
|
@ -68,36 +68,36 @@ using namespace System::Collections::Generic;
|
||||||
/// <param name="MANAGED_TYPE">The managed type of the object to edit.</param>
|
/// <param name="MANAGED_TYPE">The managed type of the object to edit.</param>
|
||||||
/// <param name="NATIVE_TYPE">The native type of the object to edit.</param>
|
/// <param name="NATIVE_TYPE">The native type of the object to edit.</param>
|
||||||
/// <param name="FUNC">The SHEditorUI:: function to use for editing.</param>
|
/// <param name="FUNC">The SHEditorUI:: function to use for editing.</param>
|
||||||
#define RENDER_FIELD_RANGE(MANAGED_TYPE, NATIVE_TYPE, FUNC) \
|
#define RENDER_FIELD_RANGE(MANAGED_TYPE, NATIVE_TYPE, FUNC) \
|
||||||
(field->FieldType == MANAGED_TYPE::typeid) \
|
(field->FieldType == MANAGED_TYPE::typeid) \
|
||||||
{ \
|
{ \
|
||||||
NATIVE_TYPE val = safe_cast<NATIVE_TYPE>(field->GetValue(object)); \
|
NATIVE_TYPE val = safe_cast<NATIVE_TYPE>(field->GetValue(object)); \
|
||||||
NATIVE_TYPE oldVal = val; \
|
NATIVE_TYPE oldVal = val; \
|
||||||
\
|
\
|
||||||
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field); \
|
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);\
|
||||||
const std::string FIELD_NAME = Convert::ToNative(field->Name); \
|
const std::string FIELD_NAME = Convert::ToNative(field->Name); \
|
||||||
bool changed = false; \
|
bool changed = false; \
|
||||||
if (rangeAttrib) \
|
if (rangeAttrib) \
|
||||||
{ \
|
{ \
|
||||||
changed = SHEditorUI::InputSlider \
|
changed = SHEditorUI::InputSlider \
|
||||||
( \
|
( \
|
||||||
FIELD_NAME, \
|
FIELD_NAME, \
|
||||||
static_cast<NATIVE_TYPE>(rangeAttrib->Min), \
|
static_cast<NATIVE_TYPE>(rangeAttrib->Min), \
|
||||||
static_cast<NATIVE_TYPE>(rangeAttrib->Max), \
|
static_cast<NATIVE_TYPE>(rangeAttrib->Max), \
|
||||||
val, &isHovered \
|
val, &isHovered \
|
||||||
); \
|
); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
changed = SHEditorUI::FUNC(FIELD_NAME, val, &isHovered); \
|
changed = SHEditorUI::FUNC(FIELD_NAME, val, &isHovered); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
if (changed) \
|
if (changed) \
|
||||||
{ \
|
{ \
|
||||||
field->SetValue(object, val); \
|
field->SetValue(object, val); \
|
||||||
registerUndoAction(object, field, val, oldVal); \
|
registerUndoAction(object, field, val, oldVal); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Macro expansion that is used in renderFieldInInspector() to check the type of a field
|
/// Macro expansion that is used in renderFieldInInspector() to check the type of a field
|
||||||
/// named "field" against the specified type and if it matches, retrieves the value of
|
/// named "field" against the specified type and if it matches, retrieves the value of
|
||||||
|
@ -286,6 +286,18 @@ namespace SHADE
|
||||||
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
|
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (field->FieldType->BaseType == ICallbackEvent::typeid)
|
||||||
|
{
|
||||||
|
// Needs to present
|
||||||
|
// - name and param list
|
||||||
|
// Needs to present for each callbackaction
|
||||||
|
// - object, methodinfo OR action
|
||||||
|
// - Ways to add or remove items
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the field has a specific attribute
|
// Check if the field has a specific attribute
|
||||||
TooltipAttribute^ toolTip = hasAttribute<TooltipAttribute^>(field);
|
TooltipAttribute^ toolTip = hasAttribute<TooltipAttribute^>(field);
|
||||||
|
|
Loading…
Reference in New Issue