mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 21:24:18 +01:00
ImUtf8 and null-check cleanup.
This commit is contained in:
parent
70844610d8
commit
9b25193d4e
1 changed files with 14 additions and 14 deletions
|
|
@ -1,8 +1,7 @@
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Data;
|
using Lumina.Data;
|
||||||
using OtterGui;
|
using OtterGui.Text;
|
||||||
using OtterGui.Raii;
|
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.GameData.Files;
|
using Penumbra.GameData.Files;
|
||||||
using Penumbra.Interop.ResourceTree;
|
using Penumbra.Interop.ResourceTree;
|
||||||
|
|
@ -43,7 +42,7 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
private void DrawQuickImportTab()
|
private void DrawQuickImportTab()
|
||||||
{
|
{
|
||||||
using var tab = ImRaii.TabItem("Import from Screen");
|
using var tab = ImUtf8.TabItem("Import from Screen"u8);
|
||||||
if (!tab)
|
if (!tab)
|
||||||
{
|
{
|
||||||
_quickImportActions.Clear();
|
_quickImportActions.Clear();
|
||||||
|
|
@ -73,14 +72,14 @@ public partial class ModEditWindow
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var file = _gameData.GetFile(path);
|
var file = _gameData.GetFile(path);
|
||||||
writable = file == null ? null : new RawGameFileWritable(file);
|
writable = file is null ? null : new RawGameFileWritable(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
_quickImportWritables.Add(resourceNode.FullPath, writable);
|
_quickImportWritables.Add(resourceNode.FullPath, writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Save.ToIconString(), buttonSize, "Export this file.",
|
if (ImUtf8.IconButton(FontAwesomeIcon.Save, "Export this file."u8, buttonSize,
|
||||||
resourceNode.FullPath.FullName.Length == 0 || writable == null, true))
|
resourceNode.FullPath.FullName.Length is 0 || writable is null))
|
||||||
{
|
{
|
||||||
var fullPathStr = resourceNode.FullPath.FullName;
|
var fullPathStr = resourceNode.FullPath.FullName;
|
||||||
var ext = resourceNode.PossibleGamePaths.Length == 1
|
var ext = resourceNode.PossibleGamePaths.Length == 1
|
||||||
|
|
@ -112,16 +111,17 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
var canQuickImport = quickImport.CanExecute;
|
var canQuickImport = quickImport.CanExecute;
|
||||||
var quickImportEnabled = canQuickImport && (!resourceNode.Protected || _config.DeleteModModifier.IsActive());
|
var quickImportEnabled = canQuickImport && (!resourceNode.Protected || _config.DeleteModModifier.IsActive());
|
||||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileImport.ToIconString(), buttonSize,
|
if (ImUtf8.IconButton(FontAwesomeIcon.FileImport,
|
||||||
$"Add a copy of this file to {quickImport.OptionName}.{(canQuickImport && !quickImportEnabled ? $"\nHold {_config.DeleteModModifier} while clicking to add." : string.Empty)}",
|
$"Add a copy of this file to {quickImport.OptionName}.{(canQuickImport && !quickImportEnabled ? $"\nHold {_config.DeleteModModifier} while clicking to add." : string.Empty)}",
|
||||||
!quickImportEnabled, true))
|
buttonSize,
|
||||||
|
!quickImportEnabled))
|
||||||
{
|
{
|
||||||
quickImport.Execute();
|
quickImport.Execute();
|
||||||
_quickImportActions.Remove((resourceNode.GamePath, writable));
|
_quickImportActions.Remove((resourceNode.GamePath, writable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record class RawFileWritable(string Path) : IWritable
|
private record RawFileWritable(string Path) : IWritable
|
||||||
{
|
{
|
||||||
public bool Valid
|
public bool Valid
|
||||||
=> true;
|
=> true;
|
||||||
|
|
@ -130,7 +130,7 @@ public partial class ModEditWindow
|
||||||
=> File.ReadAllBytes(Path);
|
=> File.ReadAllBytes(Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private record class RawGameFileWritable(FileResource FileResource) : IWritable
|
private record RawGameFileWritable(FileResource FileResource) : IWritable
|
||||||
{
|
{
|
||||||
public bool Valid
|
public bool Valid
|
||||||
=> true;
|
=> true;
|
||||||
|
|
@ -188,19 +188,19 @@ public partial class ModEditWindow
|
||||||
public static QuickImportAction Prepare(ModEditWindow owner, Utf8GamePath gamePath, IWritable? file)
|
public static QuickImportAction Prepare(ModEditWindow owner, Utf8GamePath gamePath, IWritable? file)
|
||||||
{
|
{
|
||||||
var editor = owner._editor;
|
var editor = owner._editor;
|
||||||
if (editor == null)
|
if (editor is null)
|
||||||
return new QuickImportAction(owner._editor, FallbackOptionName, gamePath);
|
return new QuickImportAction(owner._editor, FallbackOptionName, gamePath);
|
||||||
|
|
||||||
var subMod = editor.Option!;
|
var subMod = editor.Option!;
|
||||||
var optionName = subMod is IModOption o ? o.FullName : FallbackOptionName;
|
var optionName = subMod is IModOption o ? o.FullName : FallbackOptionName;
|
||||||
if (gamePath.IsEmpty || file == null || editor.FileEditor.Changes)
|
if (gamePath.IsEmpty || file is null || editor.FileEditor.Changes)
|
||||||
return new QuickImportAction(editor, optionName, gamePath);
|
return new QuickImportAction(editor, optionName, gamePath);
|
||||||
|
|
||||||
if (subMod.Files.ContainsKey(gamePath) || subMod.FileSwaps.ContainsKey(gamePath))
|
if (subMod.Files.ContainsKey(gamePath) || subMod.FileSwaps.ContainsKey(gamePath))
|
||||||
return new QuickImportAction(editor, optionName, gamePath);
|
return new QuickImportAction(editor, optionName, gamePath);
|
||||||
|
|
||||||
var mod = owner.Mod;
|
var mod = owner.Mod;
|
||||||
if (mod == null)
|
if (mod is null)
|
||||||
return new QuickImportAction(editor, optionName, gamePath);
|
return new QuickImportAction(editor, optionName, gamePath);
|
||||||
|
|
||||||
var (preferredPath, subDirs) = GetPreferredPath(mod, subMod as IModOption, owner._config.ReplaceNonAsciiOnImport);
|
var (preferredPath, subDirs) = GetPreferredPath(mod, subMod as IModOption, owner._config.ReplaceNonAsciiOnImport);
|
||||||
|
|
@ -235,7 +235,7 @@ public partial class ModEditWindow
|
||||||
{
|
{
|
||||||
var path = mod.ModPath;
|
var path = mod.ModPath;
|
||||||
var subDirs = 0;
|
var subDirs = 0;
|
||||||
if (subMod == null)
|
if (subMod is null)
|
||||||
return (path, subDirs);
|
return (path, subDirs);
|
||||||
|
|
||||||
var name = subMod.Name;
|
var name = subMod.Name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue