Skip to content

Commit

Permalink
setting for bpname expanded, filtering matches link name, copying com…
Browse files Browse the repository at this point in the history
…ponent defaults to name (and no typeid)
  • Loading branch information
factubsio committed Apr 30, 2022
1 parent 886f0df commit c4f92f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
37 changes: 25 additions & 12 deletions BlueprintExplorer/BlueprintControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public class RowElement
private string _Path;
public string Type;
internal string Default;
public string Extra = "";
internal bool LinkStale;

internal void AllChildren(Action<RowElement> p)
{
Expand Down Expand Up @@ -232,7 +234,7 @@ private string PathKey
public bool HasChildren => Children.Count > 0;
public bool HasLink => link != null;

public string SearchableValue => value ?? ValueStyled?.Raw ?? "";
public string SearchableValue => (value ?? ValueStyled?.Raw ?? "") + Extra;

private string CalculatePath()
{
Expand Down Expand Up @@ -395,7 +397,7 @@ private void ValidateBlueprint(bool scroll)
Parent = null,
String = null,
RowCount = 1,
Collapsed = true,
Collapsed = !BubblePrints.Settings.BlueprintNameExpanded,
});
Elements.Add(new ()
{
Expand Down Expand Up @@ -459,6 +461,20 @@ private void ValidateBlueprint(bool scroll)
Collapsed = totalRows != 0 && !BubblePrints.Settings.EagerExpand && currentLevel > 0,
};

if (row.HasLink)
{
if (BlueprintDB.Instance.Blueprints.TryGetValue(Guid.Parse(row.link), out var target))
{
row.LinkStale = false;
row.Extra = " -> " + target.Name + " :" + target.TypeName;
}
else
{
row.LinkStale = true;
row.Extra = " -> STALE";
}
}

if (e.isObj && e.HasType)
{
List<StyledString.StyleSpan> spans = new();
Expand Down Expand Up @@ -627,23 +643,16 @@ private void DrawElement(int row, DrawParams render)

float xOffset = 48 + elem.level * LevelIndent;

var extra = "";
if (elem.HasLink)
{
if (BackColor.GetBrightness() < 0.5f)
valueColor = Color.LightGreen;
else
valueColor = Color.DarkGreen;

if (BlueprintDB.Instance.Blueprints.TryGetValue(Guid.Parse(elem.link), out var target))
{
extra = " -> " + target.Name + " :" + target.TypeName;
}
else
{
if (elem.LinkStale)
valueColor = Color.Gray;
extra = " -> STALE";
}

valueFont = LinkFont;
}
else if (elem.value is "null" or "NULL" or "[0]")
Expand Down Expand Up @@ -690,7 +699,7 @@ private void DrawElement(int row, DrawParams render)
var brush = new SolidBrush(valueColor);
if (elem.ValueStyled == null)
{
var str = elem.value + extra;
var str = elem.value + elem.Extra;
if (str.Length > 0)
{
right += render.Graphics.MeasureString(str, valueFont).Width;
Expand Down Expand Up @@ -843,6 +852,10 @@ protected override void OnMouseClick(MouseEventArgs e)
if (jbpCompatible && elem.key == "Blueprint ID") {
value = "!bp_" + value;
}

if (elem.IsObj && elem.Type != null && !jbpCompatible)
value = elem.Type;

if (string.IsNullOrWhiteSpace(value))
return;
Clipboard.SetText(value);
Expand Down
5 changes: 5 additions & 0 deletions BlueprintExplorer/BubblePrints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public SettingsProxy(SettingsProxy settings)
[Description("Column widths for search results (only takes effect when BubblePrints loads, automatically updated if you resize the columns)")]
[DisplayName("Search column widths")]
public int[] SearchColumnSizes { get; set; } = new int[]{-1, -1, -1};

[Description("If true, the first item in the blueprint view (name, id, type) will be expanded by default")]
[DisplayName("Expand blueprint name")]
public bool BlueprintNameExpanded { get; set; } = false;

private readonly static int[] SearchColumnSizesDefault = new int[]{800, 600, 450};
}

Expand Down

0 comments on commit c4f92f5

Please sign in to comment.