Skip to content

Commit 6c311da

Browse files
committed
Update
1 parent 9502425 commit 6c311da

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ECommons/ImGuiMethods/ImGuiEx/Checkbox.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,21 @@ public static bool Checkbox(FontAwesomeIcon icon, Vector4? selectedCheckboxIconC
147147
return enabled && ret;
148148
}
149149

150+
public static bool Checkbox(string label, ref bool? value) => Checkbox(label, ref value, true, false);
151+
150152
/// <summary>
151153
/// Tri-way <see cref="ImGui.Checkbox"/>. Null will be displayed as a bullet. Switching order: false -> null -> true.
152154
/// </summary>
153155
/// <param name="label"></param>
154156
/// <param name="value"></param>
155157
/// <returns></returns>
156-
public static bool Checkbox(string label, ref bool? value)
158+
public static bool Checkbox(string label, ref bool? value, bool enabled, bool inverted)
157159
{
160+
if(!enabled) ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.6f);
161+
bool ret = false;
158162
if(value != null)
159163
{
160-
var b = value.Value;
164+
var b = inverted?!value.Value:value.Value;
161165
if(ImGui.Checkbox(label, ref b))
162166
{
163167
if(b)
@@ -166,21 +170,21 @@ public static bool Checkbox(string label, ref bool? value)
166170
}
167171
else
168172
{
169-
value = false;
173+
value = inverted;
170174
}
171-
return true;
175+
ret = true;
172176
}
173177
}
174178
else
175179
{
176180
var b = true;
177181
if(ImGuiEx.CheckboxBullet(label, ref b))
178182
{
179-
value = true;
180-
return true;
183+
value = !inverted;
184+
ret = true;
181185
}
182186
}
183-
return false;
187+
return ret;
184188
}
185189

186190
/// <summary>

ECommons/Reflection/ReflectionHelper/ReflectionHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static partial class ReflectionHelper
1919
/// <returns>Value of a field/property</returns>
2020
public static object GetFoP(this object obj, string name)
2121
{
22+
if(obj == null || name == null) return null;
2223
var type = obj.GetType();
2324
while(type != null)
2425
{

0 commit comments

Comments
 (0)