Skip to content

Commit

Permalink
Flagrum 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kizari committed Dec 21, 2022
1 parent 1823e87 commit 19c3f86
Show file tree
Hide file tree
Showing 49 changed files with 436 additions and 145 deletions.
13 changes: 10 additions & 3 deletions Flagrum.Core/Archive/ArchiveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ public class ArchiveFile

public ArchiveFile() { }

public ArchiveFile(string uri)
public ArchiveFile(string uri, string relativePathOverride = null)
{
RelativePath = uri.Replace("data://", "");
FixRelativePath();
if (relativePathOverride == null)
{
RelativePath = uri.Replace("data://", "");
FixRelativePath();
}
else
{
RelativePath = relativePathOverride;
}

var newUri = uri
.Replace(".gmdl.gfxbin", ".gmdl")
Expand Down
17 changes: 12 additions & 5 deletions Flagrum.Core/Archive/Packer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ public void AddCompressedFile(string uri, byte[] data, bool autoload = false)
Files.Add(file);
}

public void AddProcessedFile(string uri, ArchiveFileFlag flags, byte[] data, uint size, ushort key)
public void AddProcessedFile(string uri, ArchiveFileFlag flags, byte[] data, uint size, ushort key, string relativePathOverride)
{
var file = new ArchiveFile(uri);
file.Flags = flags;
file.Size = size;
file.Key = key;
if (string.IsNullOrWhiteSpace(relativePathOverride))
{
relativePathOverride = null;
}

var file = new ArchiveFile(uri, relativePathOverride)
{
Flags = flags,
Size = size,
Key = key
};

if (data != null)
{
Expand Down
5 changes: 3 additions & 2 deletions Flagrum.Desktop/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ private void DumpCrash(Exception? exception)

private void SetFileTypeAssociation()
{
var flagrumPath = $"{IOHelper.GetExecutingDirectory()}\\Flagrum.exe \"%1\"";
if (Registry.GetValue("HKEY_CLASSES_ROOT\\Flagrum", string.Empty, string.Empty) == null)
var flagrumPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Flagrum\\Flagrum.exe \"%1\"";
//var flagrumPath = $"{IOHelper.GetExecutingDirectory()}\\Flagrum.exe \"%1\"";
if ((string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Classes\\.fmod", "", "Flagrum")! != flagrumPath)
{
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Classes\\Flagrum", "", "FMOD");
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Classes\\Flagrum", "FriendlyTypeName", "Flagrum Mod");
Expand Down
19 changes: 13 additions & 6 deletions Flagrum.Desktop/Architecture/ViewportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ public async Task ChangeModel(byte[] gmdl, byte[] gpubin, AssetExplorerView view
for (var j = 0; j < 3; j++)
{
var index = (int)mesh.FaceIndices[i, j];

if (index < mesh.VertexCount)
{
triangle.Add(index);
}
}

if (triangle.Count == 3)
{
faceIndices.AddRange(triangle);
}
}

var textureCoordinates = mesh.UVMaps.Count > 0
? mesh.UVMaps[0].UVs.Select(uv => new Vector2((float)uv.U, (float)uv.V)).ToList()
: mesh.VertexPositions.Select(uv => new Vector2(0f, 0f)).ToList();
Expand Down Expand Up @@ -215,7 +215,7 @@ public async Task ChangeModel(byte[] gmdl, byte[] gpubin, AssetExplorerView view
{
if (normal is {Length: > 0})
{
var tag = Encoding.UTF8.GetString(diffuse[..8]);
var tag = Encoding.UTF8.GetString(normal[..8]);

if (tag == "SEDBbtex")
{
Expand All @@ -228,8 +228,15 @@ public async Task ChangeModel(byte[] gmdl, byte[] gpubin, AssetExplorerView view
}
});

material.AlbedoMap = albedoMap;
material.NormalMap = normalMap;
if (albedoMap != null)
{
material.AlbedoMap = albedoMap;
}

if (normalMap != null)
{
material.NormalMap = normalMap;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Flagrum.Desktop/Logo_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Flagrum.Desktop/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Image Source="/flagrum-titlebar.png" Grid.Column="0" Margin="15, 0, 0, 0" />
<Image Source="/flagrum-titlebar.png" Grid.Column="0" Margin="5, 0, 0, 3" Width="20" Height="20" />
<Label Grid.Column="1" Content="{x:Static resources:Localisation.WindowTitle}"
Foreground="#E7E5E4" FontSize="14"
VerticalAlignment="Center"
Padding="10, 5, 15, 8" />
Padding="0, 5, 15, 8" />
<Button Grid.Column="2" WindowChrome.IsHitTestVisibleInChrome="True" Click="Minimize_Click"
Content="&#xE949;" FontFamily="Segoe MDL2 Assets" FontSize="10"
BorderBrush="Transparent"
Expand Down
Binary file modified Flagrum.Desktop/Resources/flagrum.ico
Binary file not shown.
Binary file modified Flagrum.Desktop/flagrum-titlebar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions Flagrum.Web/Components/Controls/Textbox.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
readonly="@IsReadOnly"
placeholder="@Placeholder"
@bind-value="@CurrentValueAsString"
@bind-value:event="oninput">
@bind-value:event="oninput"
@attributes="AdditionalAttributes">
</textarea>
}
else
Expand All @@ -20,7 +21,8 @@ else
placeholder="@Placeholder"
@bind-value="@CurrentValueAsString"
@bind-value:event="oninput"
@onkeyup="KeyUp"/>
@onkeyup="KeyUp"
@attributes="AdditionalAttributes"/>
}

@code
Expand Down
2 changes: 1 addition & 1 deletion Flagrum.Web/Features/AssetExplorer/Base/AddressBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
<div class="flex-grow pr-3">
<EditForm Model="this">
<Textbox @bind-Value="CurrentPath" Size="Textbox.Variant.Stretch" OnKeyUp="CheckEnter" IsReadOnly="IsDisabled"/>
<Textbox @bind-Value="CurrentPath" Size="Textbox.Variant.Stretch" OnKeyUp="CheckEnter" IsReadOnly="IsDisabled" onClick="this.select();"/>
</EditForm>
</div>
@if (AssetExplorer.ItemSelectedOverride == null)
Expand Down
4 changes: 2 additions & 2 deletions Flagrum.Web/Features/AssetExplorer/Base/AssetExplorer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
}
<span class="material-icons select-none cursor-pointer mr-6" style="font-size: 1rem" @onclick="() => Parent.RegenerateModal?.Open()">settings</span>
}
<span class="material-icons select-none cursor-pointer mr-3 @(CurrentLayout == FileListLayout.ListView ? "text-accent1-200" : "text-grey-400")" style="font-size: 1rem" @onclick="() => SetCurrentLayout(FileListLayout.ListView)">list</span>
<span class="material-icons select-none cursor-pointer @(CurrentLayout == FileListLayout.TreeView ? "text-accent1-200" : "text-grey-400")" style="font-size: 1rem" @onclick="() => SetCurrentLayout(FileListLayout.TreeView)">account_tree</span>
<span class="material-icons select-none cursor-pointer mr-3 @(CurrentLayout == FileListLayout.ListView ? "text-accent1-100" : "text-grey-500")" style="font-size: 1rem" @onclick="() => SetCurrentLayout(FileListLayout.ListView)">list</span>
<span class="material-icons select-none cursor-pointer @(CurrentLayout == FileListLayout.TreeView ? "text-accent1-100" : "text-grey-500")" style="font-size: 1rem" @onclick="() => SetCurrentLayout(FileListLayout.TreeView)">account_tree</span>
</div>
</div>
<!-- File List Header 2 -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Flagrum.Web.Features.AssetExplorer.Data;
using Flagrum.Web.Features.AssetExplorer.Export;
using Flagrum.Web.Persistence;
using Flagrum.Web.Persistence.Entities;
using Microsoft.AspNetCore.Components;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@onkeydown:preventDefault="true">
<CascadingValue Value="this">
<Virtualize Items="Children" ItemSize="28" Context="node">
<ContextMenuTrigger MenuId="assetExplorerMenu" @onmouseup="() => SetContextNode(node)">
<ContextMenuTrigger MenuId="assetExplorerMenu" @onmouseup="e => ContextMenuMouseUp(e, node)">
<ExplorerRow Node="node"/>
</ContextMenuTrigger>
</Virtualize>
Expand Down
83 changes: 35 additions & 48 deletions Flagrum.Web/Features/AssetExplorer/Base/ExplorerListView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,45 @@ private void OnKeyDown(KeyboardEventArgs e)

private void ShiftNode(bool up)
{
// var currentNode = Parent.FileList.CurrentNode;
// if (currentNode != null)
// {
// var children = currentNode.Parent.Children.ToList();
// var index = children.IndexOf(currentNode);
// if (up)
// {
// index--;
// if (index >= 0)
// {
// Parent.FileList.SetCurrentNode(children[index]);
// }
// }
// else
// {
// index++;
// if (index < children.Count)
// {
// Parent.FileList.SetCurrentNode(children[index]);
// }
// }
// }
// var currentNode = Nodes.FirstOrDefault(n => n.GetUri(Context) == Parent.SelectedItem?.Uri);
// if (currentNode == null && Nodes.Any())
// {
// currentNode = up ? Nodes[Nodes.Count > 1 ? 1 : 0] : Nodes[0];
// }
//
// if (currentNode != null)
// {
// var index = Nodes.IndexOf(currentNode);
// if (up)
// {
// index--;
// if (index >= 0)
// {
// Parent.SetSelectedItem(AssetExplorerItem.FromNode(Nodes[index], Context));
// }
// }
// else
// {
// index++;
// if (index < Nodes.Count)
// {
// Parent.SetSelectedItem(AssetExplorerItem.FromNode(Nodes[index], Context));
// }
// }
// }
var currentItem = Parent.Preview.Item;
if (currentItem != null)
{
var currentNode = currentItem.Parent;
var children = currentNode.Children.ToList();
var index = children.IndexOf(currentItem);
if (up)
{
index--;
if (index >= 0)
{
var item = children[index];
Parent.AddressBar.SetCurrentPath(item.Path);
Parent.Preview.SetItem(item);
}
}
else
{
index++;
if (index < children.Count)
{
var item = children[index];
Parent.AddressBar.SetCurrentPath(item.Path);
Parent.Preview.SetItem(item);
}
}
}
}

private void SetContextNode(IAssetExplorerNode node)
{
Parent.ContextNode = node;
}

private void ContextMenuMouseUp(MouseEventArgs e, IAssetExplorerNode node)
{
if (e.Button == 2)
{
SetContextNode(node);
}
}
}
3 changes: 2 additions & 1 deletion Flagrum.Web/Features/AssetExplorer/Base/ExplorerRow.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@inject FlagrumDbContext Context
@inject SettingsService Settings

<div class="py-1 px-4 transition-colors hover:bg-grey-700 select-none cursor-pointer @(AssetExplorer.FileList?.CurrentNode.Path == Node.Path || AssetExplorer.ContextNode == Node ? "bg-grey-700" : "")"
@*AssetExplorer.FileList?.CurrentNode.Path == Node.Path*@
<div class="py-1 px-4 transition-colors hover:bg-grey-700 select-none cursor-pointer @(AssetExplorer.AddressBar?.CurrentPath == Node.Path || AssetExplorer.ContextNode == Node ? "bg-grey-700" : "")"
@onclick="() => OnClick(Node)">
<div class="row">
<span class="material-icons text-sm">@Node.Icon</span>
Expand Down
13 changes: 10 additions & 3 deletions Flagrum.Web/Features/AssetExplorer/Base/ExplorerTreeView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
@inject JSInterop Interop

<CascadingValue Value="this">
<Virtualize Items="RootNode.Children" ItemSize="28" Context="node">
<ContextMenuTrigger MenuId="assetExplorerMenu" @onmouseup="() => AssetExplorer.ContextNode = node">
<Virtualize Items="RootNode.Children.Where(n => n.Type == ExplorerItemType.Directory).ToList()" ItemSize="28" Context="node">
<ContextMenuTrigger MenuId="assetExplorerMenu" @onmouseup="e => ContextMenuMouseUp(e, node)">
<ExplorerTreeRow Node="node" Indent="2"/>
</ContextMenuTrigger>
</Virtualize>
Expand All @@ -25,7 +25,6 @@
{
var current = AssetExplorer.FileList.CurrentNode;
var root = current.GetRoot();
root.SetChildrenDirectoriesOnly();
RootNode = root;

if (AssetExplorer.AddressBar.CurrentPath.Trim() is not "data://" or "")
Expand Down Expand Up @@ -68,4 +67,12 @@
}
}
}

private void ContextMenuMouseUp(MouseEventArgs e, IAssetExplorerNode node)
{
if (e.Button == 2)
{
AssetExplorer.ContextNode = node;
}
}
}
38 changes: 18 additions & 20 deletions Flagrum.Web/Features/AssetExplorer/Data/IAssetExplorerNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using Flagrum.Core.Archive;
using Flagrum.Web.Persistence.Entities;

namespace Flagrum.Web.Features.AssetExplorer.Data;
Expand Down Expand Up @@ -38,18 +39,23 @@ public string DisplayName
}
else
{
var extension = Name[Name.LastIndexOf('.')..].ToLower();
var trueExtension = extension switch
{
".tif" or ".tga" or ".png" or ".dds" or ".exr" => ".btex",
".gmtl" => ".gmtl.gfxbin",
".gmdl" => ".gmdl.gfxbin",
".prefab" or ".ebex" => ".exml",
".autoext" => ".txt",
_ => extension
};

return Name[..Name.LastIndexOf('.')] + trueExtension;
var map = new RelativeExtensionMap();
var tokens = Name.Split('.');
var extension = string.Join('.', tokens[^(tokens.Length > 2 ? 2 : 1)..]).Trim();

// var extension = Name[Name.LastIndexOf('.')..].ToLower();
// var trueExtension = extension switch
// {
// ".tif" or ".tga" or ".png" or ".dds" or ".exr" => ".btex",
// ".gmtl" => ".gmtl.gfxbin",
// ".gmdl" => ".gmdl.gfxbin",
// ".prefab" or ".ebex" => ".exml",
// ".autoext" => ".txt",
// _ => extension
// };

return Name[..Name.LastIndexOf('.')] + '.' + map[extension];
//return Name[..Name.LastIndexOf('.')] + trueExtension;
}
}

Expand Down Expand Up @@ -120,12 +126,4 @@ public IAssetExplorerNode GetRoot()
{
return Parent == null ? this : Parent.GetRoot();
}

public void SetChildrenDirectoriesOnly()
{
if (this is AssetExplorerNode node)
{
node.ChildNodes = node.Children.Where(n => n.HasChildren).Cast<AssetExplorerNode>().ToList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@
<data name="ExportWithDependencies" xml:space="preserve">
<value>依存関係を含むエクスポート</value>
</data>
<data name="ConvertFolder" xml:space="preserve">
<value>フォルダで変換する</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@
<data name="ExportWithDependencies" xml:space="preserve">
<value>导出文件及相关素材文件</value>
</data>
<data name="ConvertFolder" xml:space="preserve">
<value>转换文件夹</value>
</data>
</root>
Loading

0 comments on commit 19c3f86

Please sign in to comment.