Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/krzys-h/UndertaleModTool
Browse files Browse the repository at this point in the history
…into tile-editor
  • Loading branch information
CST1229 committed Oct 17, 2024
2 parents 51d4ec7 + caf0412 commit 181f601
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore UndertaleModCli
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_gui_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore UndertaleModCli
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_gui_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore UndertaleModCli
- name: Build
Expand Down
16 changes: 14 additions & 2 deletions UndertaleModLib/Models/UndertaleEmbeddedTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,33 @@ public GMImage Image
/// <summary>
/// The width of the texture.
/// </summary>
public int Width => _image.Width;
/// <remarks>
/// In the case of an invalid or missing image, this will always be <c>-1</c>.
/// </remarks>
public int Width => _image?.Width ?? -1;

/// <summary>
/// The height of the texture.
/// </summary>
public int Height => _image.Height;
/// <remarks>
/// In the case of an invalid or missing image, this will always be <c>-1</c>.
/// </remarks>
public int Height => _image?.Height ?? -1;

/// <summary>
/// Whether this texture uses the QOI format.
/// </summary>
/// <remarks>
/// In the case of an invalid or missing image, this will always be <see langword="false" />.
/// </remarks>
public bool FormatQOI => _image.Format is GMImage.ImageFormat.Qoi or GMImage.ImageFormat.Bz2Qoi;

/// <summary>
/// Whether this texture uses the BZ2 format. (Always used in combination with QOI.)
/// </summary>
/// <remarks>
/// In the case of an invalid or missing image, this will always be <see langword="false" />.
/// </remarks>
public bool FormatBZ2 => _image.Format is GMImage.ImageFormat.Bz2Qoi;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLibTests/UndertaleModLibTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="xunit" Version="2.9.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
13 changes: 12 additions & 1 deletion UndertaleModTool/Editors/UndertaleEmbeddedTextureEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public UndertaleEmbeddedTextureEditor()

private void UpdateImage(UndertaleEmbeddedTexture texture)
{
if (texture.TextureData?.Image is null)
{
TexturePageImage.Source = null;
return;
}

GMImage image = texture.TextureData.Image;
BitmapSource bitmap = mainWindow.GetBitmapSourceForImage(image);
TexturePageImage.Source = bitmap;
Expand All @@ -88,8 +94,13 @@ private void SwitchDataContext(object sender, DependencyPropertyChangedEventArgs
{
_textureDataContext.PropertyChanged -= ReloadTextureImage;
}

_textureDataContext = texture.TextureData;
_textureDataContext.PropertyChanged += ReloadTextureImage;

if (_textureDataContext is not null)
{
_textureDataContext.PropertyChanged += ReloadTextureImage;
}
}

private void ReloadTextureImage(object sender, PropertyChangedEventArgs e)
Expand Down
15 changes: 13 additions & 2 deletions UndertaleModTool/Editors/UndertaleTexturePageItemEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public UndertaleTexturePageItemEditor()

private void UpdateImages(UndertaleTexturePageItem item)
{
if (item.TexturePage?.TextureData?.Image is null)
{
ItemTextureBGImage.Source = null;
ItemTextureImage.Source = null;
return;
}

GMImage image = item.TexturePage.TextureData.Image;
BitmapSource bitmap = mainWindow.GetBitmapSourceForImage(image);
ItemTextureBGImage.Source = bitmap;
Expand Down Expand Up @@ -68,8 +75,12 @@ private void SwitchDataContext(object sender, DependencyPropertyChangedEventArgs
{
_textureDataContext.PropertyChanged -= ReloadTextureImage;
}
_textureDataContext = item.TexturePage.TextureData;
_textureDataContext.PropertyChanged += ReloadTextureImage;

if (item.TexturePage?.TextureData is not null)
{
_textureDataContext = item.TexturePage.TextureData;
_textureDataContext.PropertyChanged += ReloadTextureImage;
}
}

private void ReloadTexturePage(object sender, PropertyChangedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModTool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<Grid DockPanel.Dock="Bottom">
<local:TextBoxDark x:Name="CommandBox" AcceptsReturn="True" PreviewKeyDown="CommandBox_PreviewKeyDown" Margin="0,0,35,0"/>
<Label Content="None" HorizontalAlignment="Right" VerticalAlignment="Top" VerticalContentAlignment="Top" Name="ObjectLabel"
ToolTip="This is an ID (index) of the currently open object. It starts from 0."
ToolTip="This is an ID (index) of the currently open asset, item, or object. It starts from 0."
ToolTipService.InitialShowDelay="200"/>
</Grid>
<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,39 +1498,42 @@ public static async Task<Dictionary<string, List<object>>> GetUnreferencedObject
mainWindow.SetProgressBar(null, "Assets", 0, assets.Count);
mainWindow.StartProgressBarUpdater();

var assetsPart = Partitioner.Create(0, assets.Count);

List<Dictionary<string, List<object>>> dicts = new();

await Task.Run(() =>
if (assets.Count > 0) // A Partitioner can't be created on an empty list.
{
Parallel.ForEach(assetsPart, (range) =>
{
var resultDict = new Dictionary<string, List<object>>();
var assetsPart = Partitioner.Create(0, assets.Count);

for (int i = range.Item1; i < range.Item2; i++)
await Task.Run(() =>
{
Parallel.ForEach(assetsPart, (range) =>
{
var asset = assets[i];
var assetReferences = GetReferencesOfObject(asset.Item1, data,
new HashSetTypesOverride(true, data.Code is null), true);
if (assetReferences is null)
var resultDict = new Dictionary<string, List<object>>();

for (int i = range.Item1; i < range.Item2; i++)
{
if (resultDict.TryGetValue(asset.Item2, out var list))
var asset = assets[i];
var assetReferences = GetReferencesOfObject(asset.Item1, data,
new HashSetTypesOverride(true, data.Code is null), true);
if (assetReferences is null)
{
list.Add(asset.Item1);
}
else
{
resultDict[asset.Item2] = new() { asset.Item1 };
if (resultDict.TryGetValue(asset.Item2, out var list))
{
list.Add(asset.Item1);
}
else
{
resultDict[asset.Item2] = new() { asset.Item1 };
}
}
}

mainWindow.IncrementProgressParallel();
}
mainWindow.IncrementProgressParallel();
}

dicts.Add(resultDict);
dicts.Add(resultDict);
});
});
});
}

Dictionary<string, int> outArrSizes = new();
foreach (var dict in dicts)
Expand Down
Binary file modified images/ribbit-dr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 181f601

Please sign in to comment.