Save Raw Texture Data Button

* Resolves #1298
This commit is contained in:
ds5678 2024-05-21 13:55:22 -04:00
parent 9d1a3a190d
commit 5c782a2f9a
4 changed files with 20 additions and 7 deletions

View File

@ -151,6 +151,7 @@
"replace": "Replace",
"resources": "Resources",
"save": "Save",
"save_raw_data": "Save Raw Data",
"save_settings_to_disk": "Save Settings to Disk",
"scene": "Scene",
"script": "Script",

View File

@ -770,6 +770,11 @@ partial class Localization
/// </summary>
public static string Save => Get("save");
/// <summary>
/// Save Raw Data
/// </summary>
public static string SaveRawData => Get("save_raw_data");
/// <summary>
/// Save Settings to Disk
/// </summary>

View File

@ -1,5 +1,6 @@
using AssetRipper.Assets;
using AssetRipper.GUI.Web.Paths;
using AssetRipper.IO.Files.Utils;
namespace AssetRipper.GUI.Web.Pages.Assets;
@ -20,15 +21,21 @@ internal sealed class ImageTab : HtmlTab
public override void Write(TextWriter writer)
{
string sourcePath = AssetAPI.GetImageUrl(Asset.GetPath(), "png");
AssetPath assetPath = Asset.GetPath();
string pngUrl = AssetAPI.GetImageUrl(assetPath, "png");
string rawUrl = AssetAPI.GetImageUrl(assetPath);
string fileName = FileUtils.FixInvalidNameCharacters(Asset.GetBestName());
// Click on image to save
using (new A(writer).WithHref(sourcePath).WithDownload("extracted_image").End())
using (new A(writer).WithHref(pngUrl).WithDownload(fileName).End())
{
new Img(writer).WithSrc(sourcePath).WithStyle("object-fit:contain; width:100%; height:100%").Close();
new Img(writer).WithSrc(pngUrl).WithStyle("object-fit:contain; width:100%; height:100%").Close();
}
// Todo: add a button beneath the image to download its raw data
// https://github.com/AssetRipper/AssetRipper/issues/1298
// Click a button beneath the image to download its raw data
using (new Div(writer).WithTextCenter().End())
{
DataSaveButton.Write(writer, rawUrl, fileName, Localization.SaveRawData);
}
}
}

View File

@ -9,8 +9,8 @@ internal static class DataSaveButton
new A(writer).WithHref(sourcePath).WithDownload(fileName).WithClass("btn btn-primary").Close(Localization.Save);
}
public static void Write(TextWriter writer, string url, string? fileName = null)
public static void Write(TextWriter writer, string url, string? fileName = null, string? text = null)
{
new A(writer).WithHref(url).WithDownload(fileName).WithClass("btn btn-primary").Close(Localization.Save);
new A(writer).WithHref(url).WithDownload(fileName).WithClass("btn btn-primary").Close(text ?? Localization.Save);
}
}