Skip to content

Commit

Permalink
LibraryWindow improvements
Browse files Browse the repository at this point in the history
- Fix an ImGUI assertion failure
- Fix SearchSuggest closing when it shouldn't

- Added you can now double-click items in Library to apply them
- Change MinimumSize 850, 500 -> 785, 435
- Changed MinEntrySize 100 -> 85
  • Loading branch information
Minmoose committed Jan 3, 2025
1 parent 0f051e7 commit 1195759
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 170 deletions.
14 changes: 14 additions & 0 deletions Brio/Files/AppliableActorFileInfoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ public AppliableActorFileInfoBase(EntityManager entityManager)
_entityManager = entityManager;
}

public override bool InvokeDefaultAction(FileEntry fileEntry, object? args)
{
if(args is not null and ActorEntity actor)
{
if(Load(fileEntry.FilePath) is T file)
{
Apply(file, actor, false);
return true;
}
}

return false;
}

public override void DrawActions(FileEntry fileEntry, bool isModal)
{
base.DrawActions(fileEntry, isModal);
Expand Down
5 changes: 5 additions & 0 deletions Brio/Files/FileTypeInfoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public virtual bool IsFile(string path)
public virtual void DrawActions(FileEntry fileEntry, bool isModal)
{
}

public virtual bool InvokeDefaultAction(FileEntry fileEntry, object? args)
{
return false;
}
}

internal abstract class FileTypeInfoBase<T> : FileTypeInfoBase
Expand Down
8 changes: 7 additions & 1 deletion Brio/Library/EntryBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Brio.Library.Filters;
using Brio.Capabilities.Core;
using Brio.Library.Filters;
using Brio.Library.Sources;
using Brio.Library.Tags;
using Brio.UI.Controls.Stateless;
Expand Down Expand Up @@ -80,5 +81,10 @@ public virtual void DrawActions(bool isModal)
{
}

public virtual bool InvokeDefaultAction(object? args)
{
return false;
}

protected abstract string GetInternalId();
}
10 changes: 6 additions & 4 deletions Brio/Library/Sources/FileSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ protected override string GetInternalId()
return FileTypeInfo.Load(this.FilePath);
}

public override bool InvokeDefaultAction(object? args)
{
return FileTypeInfo?.InvokeDefaultAction(this, args) ?? false;
}

public override void DrawActions(bool isModal)
{
base.DrawActions(isModal);
Expand All @@ -310,9 +315,6 @@ public override void DrawActions(bool isModal)
}
}

if(FileTypeInfo != null)
{
FileTypeInfo.DrawActions(this, isModal);
}
FileTypeInfo?.DrawActions(this, isModal);
}
}
30 changes: 24 additions & 6 deletions Brio/Library/Sources/GameDataAppearanceEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Brio.Capabilities.Actor;
using Brio.Capabilities.Core;
using Brio.Entities;
using Brio.Entities.Actor;
using Brio.Game.Actor.Appearance;
using Brio.Game.Types;
using Brio.Resources;
Expand Down Expand Up @@ -92,16 +94,32 @@ public override bool Search(string[] query)

protected override string GetInternalId() => _id;

public override bool InvokeDefaultAction(object? args)
{
if(args is not null and ActorEntity actor)
{
SetAppearance(actor);
Brio.Log.Warning("SetAppearance");
return true;
}

return false;
}

public override void DrawActions(bool isModal)
{
base.DrawActions(isModal);

ImBrio.DrawApplyToActor(_entityManager, (actor) =>
ImBrio.DrawApplyToActor(_entityManager, SetAppearance);
}

void SetAppearance(ActorEntity actorEntity)
{
if(actorEntity.TryGetCapability<ActorAppearanceCapability>(out var capability) && capability != null)
{
if(actor.TryGetCapability<ActorAppearanceCapability>(out var capability) && capability != null)
{
_ = capability.SetAppearance(Appearance, AppearanceImportOptions.All);
}
});
_ = capability.SetAppearance(Appearance, AppearanceImportOptions.All);
Brio.Log.Warning("TryGetCapability SetAppearance");
}
}

}
Loading

0 comments on commit 1195759

Please sign in to comment.