-fixed sp,e demos issues and crashes
This commit is contained in:
parent
fa0c196c60
commit
2107f3908c
9 changed files with 100 additions and 42 deletions
|
|
@ -4,17 +4,20 @@ enum GUIColor = "GUIColor";
|
|||
|
||||
struct GUIRange
|
||||
{
|
||||
union
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
int min;
|
||||
int max;
|
||||
}
|
||||
struct
|
||||
{
|
||||
float minf;
|
||||
float maxf;
|
||||
}
|
||||
int min;
|
||||
int max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GUIRangeF
|
||||
{
|
||||
struct
|
||||
{
|
||||
float minf;
|
||||
float maxf;
|
||||
}
|
||||
}
|
||||
|
||||
enum GUIDisabled = "GUIDisabled";
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct VariableGUI
|
|||
Type type;
|
||||
const (char)* name;
|
||||
ushort offset;
|
||||
bool disabled = false;
|
||||
union
|
||||
{
|
||||
Int int_;
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ struct GUIManager
|
|||
//pragma(msg,member_type);
|
||||
//pragma(msg,__traits(getMember, T, member).offsetof);
|
||||
ushort offset = member.offsetof;//cast(ushort)__traits(getMember, T, member).offsetof;
|
||||
|
||||
static if(is(member_type == vec2))
|
||||
{
|
||||
comp_edit.variables[comp_edit.used++] = VariableGUI(VariableGUI.Type.vec2,member_str,offset);
|
||||
|
|
@ -236,14 +237,20 @@ struct GUIManager
|
|||
}
|
||||
static if(hasUDA!(member,GUIRange))
|
||||
{
|
||||
comp_edit.variables[comp_edit.used-1].float_.min = getUDAs!(member,GUIRange)[0].minf;
|
||||
comp_edit.variables[comp_edit.used-1].float_.max = getUDAs!(member,GUIRange)[1].maxf;
|
||||
comp_edit.variables[comp_edit.used-1].float_.min = getUDAs!(member,GUIRange)[0].min;
|
||||
comp_edit.variables[comp_edit.used-1].float_.max = getUDAs!(member,GUIRange)[0].max;
|
||||
}
|
||||
else static if(hasUDA!(member,GUIRangeF))
|
||||
{
|
||||
comp_edit.variables[comp_edit.used-1].float_.min = getUDAs!(member,GUIRangeF)[0].minf;
|
||||
comp_edit.variables[comp_edit.used-1].float_.max = getUDAs!(member,GUIRangeF)[0].maxf;
|
||||
}
|
||||
else {
|
||||
comp_edit.variables[comp_edit.used-1].float_.min = -float.max;
|
||||
comp_edit.variables[comp_edit.used-1].float_.max = float.max;
|
||||
}
|
||||
}
|
||||
static if(hasUDA!(member,GUIDisabled))comp_edit.variables[comp_edit.used - 1].disabled = true;
|
||||
}
|
||||
edit_components[becsID(comp)] = comp_edit;
|
||||
}
|
||||
|
|
@ -256,12 +263,14 @@ struct GUIManager
|
|||
igIndent(8);
|
||||
foreach(ref SystemGUI system;systems)
|
||||
{
|
||||
igPushIDPtr(&system);
|
||||
if(igCheckbox(system.name,&system.enabled))
|
||||
{
|
||||
System* sys = gEntityManager.getSystem(system.id);
|
||||
if(system.enabled)sys.enable();
|
||||
else sys.disable();
|
||||
}
|
||||
igPopID();
|
||||
}
|
||||
igUnindent(8);
|
||||
}
|
||||
|
|
@ -337,13 +346,15 @@ struct GUIManager
|
|||
{
|
||||
vec4 color;
|
||||
if(comp_id >= edit_components.length)return;
|
||||
if(edit_components[comp_id].used)
|
||||
//if(edit_components[comp_id].used)
|
||||
if(edit_components[comp_id].name)
|
||||
{
|
||||
if(igCollapsingHeader(edit_components[comp_id].name, ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
igIndent(8);
|
||||
foreach(ref VariableGUI var;edit_components[comp_id].variables[0 .. edit_components[comp_id].used])
|
||||
{
|
||||
|
||||
igPushIDPtr(&var);
|
||||
switch(var.type)
|
||||
{
|
||||
|
|
@ -351,7 +362,12 @@ struct GUIManager
|
|||
igDragScalarClamp(var.name, ImGuiDataType_S8, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
break;
|
||||
case VariableGUI.Type.ubyte_:
|
||||
igDragScalarClamp(var.name, ImGuiDataType_U8, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
if(var.disabled)
|
||||
{
|
||||
ubyte v = *cast(ubyte*)(data_ptr+var.offset);
|
||||
igDragScalarClamp(var.name, ImGuiDataType_U8, &v, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
}
|
||||
else igDragScalarClamp(var.name, ImGuiDataType_U8, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
break;
|
||||
case VariableGUI.Type.short_:
|
||||
igDragScalarClamp(var.name, ImGuiDataType_S16, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
|
|
@ -363,7 +379,12 @@ struct GUIManager
|
|||
igDragScalarClamp(var.name, ImGuiDataType_S32, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
break;
|
||||
case VariableGUI.Type.uint_:
|
||||
igDragScalarClamp(var.name, ImGuiDataType_U32, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
if(var.disabled)
|
||||
{
|
||||
uint v = *cast(uint*)(data_ptr+var.offset);
|
||||
igDragScalarClamp(var.name, ImGuiDataType_U32, &v, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
}
|
||||
else igDragScalarClamp(var.name, ImGuiDataType_U32, data_ptr+var.offset, 0.1, cast(void*)&var.int_.min, cast(void*)&var.int_.max, null, 1);
|
||||
break;
|
||||
case VariableGUI.Type.float_:
|
||||
igDragScalarClamp(var.name, ImGuiDataType_Float, data_ptr+var.offset, 0.1, cast(void*)&var.float_.min, cast(void*)&var.float_.max, "%2.2f", 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue