Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions FrostyEditor/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,42 @@
<ctrl2:FrostyWindow.Resources>
<conv:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
<cmd:ExportModMenuItemCommand x:Key="exportModMenuItemCommand"/>
<cmd:ExportModMenuItemCommand x:Key="exportModMenuItemCommand_dos" />
<ContextMenu x:Key="bookmarksContextMenu">
<MenuItem Header="Open asset" Click="contextMenuBookmarkItemOpen_Click">
<MenuItem.Icon>
<Image Source="/FrostyEditor;component/Images/OpenAsset.png" Opacity="0.5"/>
<Image Source="/FrostyEditor;component/Images/OpenAsset.png" RenderOptions.BitmapScalingMode="Fant"
Opacity="0.5" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Find in explorer" Click="contextMenuBookmarkItemFind_Click">
<MenuItem.Icon>
<Image Source="/FrostyEditor;component/Images/Open.png"
RenderOptions.BitmapScalingMode="Fant"
Opacity="0.5" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Open in Blueprint Editor" Click="contextMenuBookmarkItemOpenBlueprintEditor_Click">
<MenuItem.Icon>
<Image Source="/FrostyCore;component/Images/Assets/BlueprintFileType.png"
RenderOptions.BitmapScalingMode="Fant"
Opacity="0.5" />
</MenuItem.Icon>
</MenuItem>
<!-- <MenuItem Header="Copy file GUID" Click="contextMenuBookmarkItemCopyGUID_Click">
<MenuItem.Icon>
<Image Source="/FrostyCore;component/Images/Copy.png"
RenderOptions.BitmapScalingMode="Fant"
Opacity="0.5" />
</MenuItem.Icon>
</MenuItem> -->
<MenuItem Header="Copy file path" Click="contextMenuBookmarkItemCopyPath_Click">
<MenuItem.Icon>
<Image Source="/FrostyCore;component/Images/Copy.png"
RenderOptions.BitmapScalingMode="Fant"
Opacity="0.5" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Find in explorer" Click="contextMenuBookmarkItemFind_Click"/>
</ContextMenu>
</ctrl2:FrostyWindow.Resources>

Expand Down Expand Up @@ -67,7 +96,7 @@
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem x:Name="ExportModMenuItem" Header="Export to Mod" Height="22" Command="{StaticResource exportModMenuItemCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">
<MenuItem x:Name="ExportModMenuItem" Header="Export to Mod" Height="22" Command="{StaticResource exportModMenuItemCommand_dos}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">
<MenuItem.Icon>
<Image Source="/FrostyEditor;component/Images/Compile.png"/>
</MenuItem.Icon>
Expand Down
60 changes: 58 additions & 2 deletions FrostyEditor/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
using FrostyCore;
using FrostySdk;
using FrostySdk.IO;
using FrostySdk.Managers;
using FrostySdk.Managers.Entries;
using Microsoft.Win32;
using Bookmarks = Frosty.Core.Bookmarks;
using Frosty.Core.Attributes;
using Frosty.Core.Misc;

namespace FrostyEditor.Windows
{
Expand Down Expand Up @@ -1142,7 +1143,62 @@ private void contextMenuBookmarkItemFind_Click(object sender, RoutedEventArgs e)
target.Target.NavigateTo(false);
}

#endregion
private IBlueprintEditorHandler blueprintEditorHandler = App.PluginManager.BlueprintEditorOpenAction.Count() == 0 ? new DefaultBlueprintEditorHandler() : App.PluginManager.BlueprintEditorOpenAction.First();

private void contextMenuBookmarkItemOpenBlueprintEditor_Click(object sender, RoutedEventArgs e)
{
if (BookmarkTreeView.SelectedItem == null)
return;
Bookmarks.BookmarkItem target = BookmarkTreeView.SelectedItem as Bookmarks.BookmarkItem;
if (target.Target is Bookmarks.AssetBookmarkTarget assetTarget)
{
if (assetTarget.Asset is EbxAssetEntry entry)
{
if (entry != null)
{
blueprintEditorHandler.OpenAssetAsGraph(entry);
}
}
}
}

private void contextMenuBookmarkItemCopyGUID_Click(object sender, RoutedEventArgs e)
{
if (BookmarkTreeView.SelectedItem == null)
return;
Bookmarks.BookmarkItem target = BookmarkTreeView.SelectedItem as Bookmarks.BookmarkItem;
if (target.Target is Bookmarks.AssetBookmarkTarget assetTarget)
{
if (assetTarget.Asset is EbxAssetEntry entry)
{
if (entry != null)
{
EbxAsset asset = App.AssetManager.GetEbx(entry.Name);
App.Logger.Log(asset.FileGuid.ToString());
Clipboard.SetText(asset.FileGuid.ToString());
}
}
}
}

private void contextMenuBookmarkItemCopyPath_Click(object sender, RoutedEventArgs e)
{
if (BookmarkTreeView.SelectedItem == null)
return;
Bookmarks.BookmarkItem target = BookmarkTreeView.SelectedItem as Bookmarks.BookmarkItem;
if (target.Target is Bookmarks.AssetBookmarkTarget assetTarget)
{
if (assetTarget.Asset is EbxAssetEntry entry)
{
if (entry != null)
{
Clipboard.SetText(entry.Name);
}
}
}
}

#endregion

#region -- Bookmarks --

Expand Down
27 changes: 27 additions & 0 deletions FrostyPlugin/Attributes/RegisterBlueprintEditorHandlerAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using FrostySdk.Ebx;
using FrostySdk.Managers.Entries;
using System;
using System.Windows.Controls;
using System.Windows.Media;

namespace Frosty.Core.Attributes
{
/// <summary>
/// This attribute registers the method for opening files in the Blueprint Editor.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
public class RegisterBlueprintEditorHandlerAttribute : Attribute
{
public Type classToHandle { get; set; }

public RegisterBlueprintEditorHandlerAttribute(Type type)
{
classToHandle = type;
}
}

public interface IBlueprintEditorHandler
{
void OpenAssetAsGraph(EbxAssetEntry asset);
}
}
24 changes: 24 additions & 0 deletions FrostyPlugin/Controls/Editors/FrostyPointerRefEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
using System.Windows.Input;
using FrostySdk.Managers.Entries;

using Frosty.Core.Attributes;
using Frosty.Core.Misc;

//using System.IO;

namespace Frosty.Core.Controls.Editors
Expand Down Expand Up @@ -270,6 +273,7 @@ private void Popup_DropDownOpened(object sender, EventArgs e)
Button clearButton = (popupMenu.FindName("PART_ClearButton") as Button);
Button openButton = (popupMenu.FindName("PART_OpenButton") as Button);
Button findButton = (popupMenu.FindName("PART_FindButton") as Button);
Button blueprintEditorButton = (popupMenu.FindName("PART_BlueprintEditorButton") as Button);
Button createButton = (popupMenu.FindName("PART_CreateButton") as Button);
TextBlock textBlock = (popupMenu.FindName("PART_TextBlock") as TextBlock);
Border separator = (popupMenu.FindName("PART_Separator") as Border);
Expand All @@ -278,18 +282,21 @@ private void Popup_DropDownOpened(object sender, EventArgs e)

clearButton.Click -= ClearButton_Click;
findButton.Click -= FindButton_Click;
blueprintEditorButton.Click -= BlueprintEditorButton_Click;
openButton.Click -= OpenButton_Click;
createButton.Click -= CreateButton_Click;

clearButton.Click += ClearButton_Click;
findButton.Click += FindButton_Click;
blueprintEditorButton.Click += BlueprintEditorButton_Click;
openButton.Click += OpenButton_Click;
createButton.Click += CreateButton_Click;
filter.TextChanged += Filter_TextChanged;

PointerRef ptrRef = (PointerRef)Value;
clearButton.IsEnabled = ptrRef.Type != PointerRefType.Null;
findButton.IsEnabled = !(ptrRef.Type == PointerRefType.Internal || ptrRef.Type == PointerRefType.Null);
blueprintEditorButton.IsEnabled = !(ptrRef.Type == PointerRefType.Internal || ptrRef.Type == PointerRefType.Null);
openButton.IsEnabled = !(ptrRef.Type == PointerRefType.Internal || ptrRef.Type == PointerRefType.Null);
createButton.IsEnabled = canCreate;
textBlock.Text = "Assign from " + ((isInternal) ? "self" : App.AssetManager.GetEbxEntry(assignFileGuid).Name);
Expand Down Expand Up @@ -383,6 +390,23 @@ private void FindButton_Click(object sender, RoutedEventArgs e)
popup.IsDropDownOpen = false;
}

private void BlueprintEditorButton_Click(object sender, RoutedEventArgs e)
{
IEnumerable<IBlueprintEditorHandler> handlerEnumerable = App.PluginManager.BlueprintEditorOpenAction;
IBlueprintEditorHandler handlerClass = handlerEnumerable.Count() == 0 ? new DefaultBlueprintEditorHandler() : handlerEnumerable.First();
PointerRef ptr = (PointerRef)Value;
if (ptr.Type == PointerRefType.External)
{
EbxAssetEntry asset = App.AssetManager.GetEbxEntry(ptr.External.FileGuid);
if (asset == null)
{
return;
}
handlerClass.OpenAssetAsGraph(asset);
}
popup.IsDropDownOpen = false;
}

/// <summary>
/// Performs the actual assinging for either internal or external selection
/// </summary>
Expand Down
16 changes: 14 additions & 2 deletions FrostyPlugin/Controls/FrostyAssetEditor.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using Frosty.Core.Windows;
using Frosty.Core.Attributes;
using Frosty.Core.Misc;
using Frosty.Core.Windows;
using FrostySdk;
using FrostySdk.Ebx;
using FrostySdk.Interfaces;
using FrostySdk.IO;
using FrostySdk.Managers;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using FrostySdk.Managers.Entries;
using Frosty.Controls;
Expand Down Expand Up @@ -199,7 +204,14 @@ public virtual void Closed()

public virtual List<ToolbarItem> RegisterToolbarItems()
{
return new List<ToolbarItem>() { new ToolbarItem("View Instances", "View class instances", null, new RelayCommand(ViewInstances_Click, ViewInstances_CanClick)) };
return new List<ToolbarItem>() {
new ToolbarItem($"View Instances ({asset.RootObjects.Count()})", "View class instances", "Images/Database.png", new RelayCommand(ViewInstances_Click, ViewInstances_CanClick)),
new ToolbarItem("Open in Blueprint Editor", "Open this file in the graph editor (if available)", "Images/Grid.png", new RelayCommand((_) => {
IEnumerable<IBlueprintEditorHandler> handlerEnumerable = App.PluginManager.BlueprintEditorOpenAction;
IBlueprintEditorHandler handlerClass = handlerEnumerable.Count() == 0 ? new DefaultBlueprintEditorHandler() : handlerEnumerable.First();
handlerClass.OpenAssetAsGraph(AssetEntry as EbxAssetEntry);
}, (_) => AssetEntry is EbxAssetEntry))
};
}

private void ViewInstances_Click(object state)
Expand Down
2 changes: 2 additions & 0 deletions FrostyPlugin/FrostyCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<Compile Include="Attributes\RegisterExecutionAction.cs" />
<Compile Include="Attributes\RegisterCustomHandlerAttribute.cs" />
<Compile Include="Attributes\RegisterDataExplorerContextMenuAttribute.cs" />
<Compile Include="Attributes\RegisterBlueprintEditorHandlerAttribute.cs" />
<Compile Include="Attributes\RegisterGlobalTypeEditorAttribute.cs" />
<Compile Include="Attributes\RegisterLocalizedStringDatabaseAttribute.cs" />
<Compile Include="Attributes\RegisterMenuExtensionAttribute.cs" />
Expand Down Expand Up @@ -150,6 +151,7 @@
<Compile Include="FrostyLogger.cs" />
<Compile Include="FrostyProfileTaskWindowLogger.cs" />
<Compile Include="FrostyTaskLogger.cs" />
<Compile Include="Misc\DefaultBlueprintEditorHandler.cs" />
<Compile Include="Legacy\LegacyFileManagerV2.cs" />
<Compile Include="Managers\NotificationManager.cs" />
<Compile Include="Managers\UndoManager.cs" />
Expand Down
9 changes: 9 additions & 0 deletions FrostyPlugin/Managers/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ public sealed class PluginManager
public PluginManagerType ManagerType => m_managerType;

public IEnumerable<string> CustomAssetHandlers => m_customAssetHandlers.Keys;

private List<IBlueprintEditorHandler> m_blueprintEditorOpenAction = new List<IBlueprintEditorHandler>();

public IEnumerable<IBlueprintEditorHandler> BlueprintEditorOpenAction => m_blueprintEditorOpenAction;

private readonly Dictionary<string, AssetDefinition> m_definitions = new Dictionary<string, AssetDefinition>();
private readonly List<MenuExtension> m_menuExtensions = new List<MenuExtension>();
Expand Down Expand Up @@ -670,6 +674,11 @@ private void LoadDefinitionsFromAssembly(PluginLoadType loadType, Assembly assem
{
App.AssetManager.RegisterCustomAssetManager(attr12.CustomAssetManagerType, attr12.CustomAssetManagerClassType);
}

else if (tmpAttr is RegisterBlueprintEditorHandlerAttribute attr13)
{
m_blueprintEditorOpenAction.Add((IBlueprintEditorHandler)Activator.CreateInstance(attr13.classToHandle));
}
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions FrostyPlugin/Misc/DefaultBlueprintEditorHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Frosty.Controls;
using Frosty.Core.Attributes;
using FrostySdk.Managers.Entries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Frosty.Core.Misc
{
public class DefaultBlueprintEditorHandler : IBlueprintEditorHandler
{
public void OpenAssetAsGraph(EbxAssetEntry asset)
{
FrostyMessageBox.Show("Missing valid handler for opening blueprint editor. Please make sure you have a version of the blueprint editor that supports this feature.", "Open in Blueprint Editor");
}
}
}
1 change: 1 addition & 0 deletions FrostyPlugin/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@
<Button x:Name="PART_ClearButton" Content="Clear assigned object" Style="{StaticResource MenuButtonStyle}" FontFamily="MS Reference Sans Serif" Height="22"/>
<Button x:Name="PART_OpenButton" Content="Open asset" Style="{StaticResource MenuButtonStyle}" FontFamily="MS Reference Sans Serif" Height="22"/>
<Button x:Name="PART_FindButton" Content="Find in data explorer" Style="{StaticResource MenuButtonStyle}" FontFamily="MS Reference Sans Serif" Height="22"/>
<Button x:Name="PART_BlueprintEditorButton" Content="Open in Blueprint Editor" Style="{StaticResource MenuButtonStyle}" FontFamily="MS Reference Sans Serif" Height="22"/>
<Button x:Name="PART_CreateButton" Content="Create new ..." Style="{StaticResource MenuButtonStyle}" FontFamily="MS Reference Sans Serif" Height="22"/>

<Border x:Name="PART_Separator" Height="22">
Expand Down
6 changes: 3 additions & 3 deletions FrostySdk/Managers/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ public void DoEbxIndexing()

public uint GetModifiedCount()
{
uint modifiedEbx = (uint)m_ebxList.Values.Count((EbxAssetEntry entry) => entry.IsModified);
uint modifiedRes = (uint)m_resList.Values.Count((ResAssetEntry entry) => entry.IsModified);
uint modifiedChunks = (uint)m_chunkList.Values.Count((ChunkAssetEntry entry) => entry.IsModified);
uint modifiedEbx = (uint)m_ebxList.Values.ToList().Count((EbxAssetEntry entry) => entry.IsModified);
uint modifiedRes = (uint)m_resList.Values.ToList().Count((ResAssetEntry entry) => entry.IsModified);
uint modifiedChunks = (uint)m_chunkList.Values.ToList().Count((ChunkAssetEntry entry) => entry.IsModified);
uint modifiedCustom = 0;
foreach (ICustomAssetManager mgr in m_customAssetManagers.Values)
{
Expand Down
12 changes: 12 additions & 0 deletions Plugins/BundleEditorPlugin/BundleTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ public void RefreshBundles(EbxAssetEntry entry)
bundlesListTextBox.Text = sb1.ToString();
if (sb2.Length > 0)
bundlesListTextBox.Text += "\r\nAdded to bundles:\r\n" + sb2.ToString();

foreach (var item in App.EditorWindow.MiscTabControl.Items)
{
if (item is FrostyTabItem)
{
FrostyTabItem tab = item as FrostyTabItem;
if (tab.Header.ToString().Contains("Bundles"))
{
tab.Header = $"Bundles ({sb1.ToString().Split("\n".ToCharArray()).Length - 1} + {sb2.ToString().Split("\n".ToCharArray()).Length - 1})";
}
}
}
}
}
}
Loading