Skip to content

Commit

Permalink
a few visual improvements for empty fields
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed May 10, 2024
1 parent 0672abf commit fdb23b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Murder.Editor/CustomComponents/CustomComponent.cs
Expand Up @@ -259,9 +259,13 @@ public static bool DrawMemberForTarget(object target, string memberName, EditorM
else
{
// Draw Label
ImGui.PushStyleColor(ImGuiCol.Text, member.GetValue(target) == null ? Game.Profile.Theme.Faded : Game.Profile.Theme.White);

ImGui.Text($"{Prettify.FormatName(memberName)}:");

ImGui.PopStyleColor();
}


if (AttributeExtensions.IsDefined(member, typeof(TooltipAttribute)))
{
Expand Down
9 changes: 8 additions & 1 deletion src/Murder.Editor/CustomFields/CustomField.cs
Expand Up @@ -158,7 +158,7 @@ public static (bool Modified, object? Result) DrawValue(EditorMember member, /*
break;

case null:
string text = "Create Default";
string text = "";
if (AttributeExtensions.TryGetAttribute(member, out DefaultAttribute? defaultAttribute))
{
text = defaultAttribute.Text;
Expand All @@ -167,8 +167,10 @@ public static (bool Modified, object? Result) DrawValue(EditorMember member, /*
// Check for nullable types. If so, return the default value of it.
Type targetType = Nullable.GetUnderlyingType(member.Type) ?? member.Type;

ImGui.PushStyleColor(ImGuiCol.Button, Game.Profile.Theme.BgFaded);
if (ImGui.Button(text))
{
ImGui.PopStyleColor();
if (member.Type == typeof(string))
{
return (true, string.Empty);
Expand Down Expand Up @@ -198,6 +200,11 @@ public static (bool Modified, object? Result) DrawValue(EditorMember member, /*
$"Unable to find default constructor for type: {member.Type.Name}.");
}
}
else
{
ImGui.PopStyleColor();
}
ImGui.SetItemTooltip("Create with default value");

// When this is an interface, select the most appropriate instance.
(bool modified, object? result)? selectedType = DrawCreateDefaultValue(targetType);
Expand Down
1 change: 1 addition & 0 deletions src/Murder/Core/Geometry/IntRectangle.cs
Expand Up @@ -47,6 +47,7 @@ public Point Size
public static implicit operator IntRectangle(Microsoft.Xna.Framework.Rectangle p) => new(p.X, p.Y, p.Width, p.Height);
public static implicit operator Microsoft.Xna.Framework.Rectangle(IntRectangle p) => new(p.X, p.Y, p.Width, p.Height);

public static Rectangle operator +(IntRectangle p, IntRectangle v) => new(p.X + v.X, p.Y + v.Y, p.Width + v.Width, p.Height + v.Height);
public static Rectangle operator +(IntRectangle p, Point v) => new(p.X + v.X, p.Y + v.Y, p.Width, p.Height);
public static Rectangle operator -(IntRectangle p, Point v) => new(p.X - v.X, p.Y - v.Y, p.Width, p.Height);
public static IntRectangle operator *(IntRectangle p, float v) => new(p.X * v, p.Y * v, p.Width * v, p.Height * v);
Expand Down

0 comments on commit fdb23b6

Please sign in to comment.