mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
fix utf16 paths (se why???) and probably make ttmp importing more better
This commit is contained in:
parent
748c45a461
commit
055399a7e7
2 changed files with 20 additions and 17 deletions
|
|
@ -162,27 +162,27 @@ namespace Penumbra
|
||||||
var candidate = Plugin.ModManager.GetCandidateForGameFile( gameFsPath );
|
var candidate = Plugin.ModManager.GetCandidateForGameFile( gameFsPath );
|
||||||
var swappedFilePath = Plugin.ModManager.GetSwappedFilePath( gameFsPath );
|
var swappedFilePath = Plugin.ModManager.GetSwappedFilePath( gameFsPath );
|
||||||
|
|
||||||
var path = candidate?.FullName ?? swappedFilePath;
|
var fsPath = candidate?.FullName ?? swappedFilePath;
|
||||||
|
|
||||||
// path must be < 260 because statically defined array length :(
|
// path must be < 260 because statically defined array length :(
|
||||||
if( path == null || path.Length >= 260 )
|
if( fsPath == null || fsPath.Length >= 260 )
|
||||||
{
|
{
|
||||||
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
|
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
|
||||||
}
|
}
|
||||||
|
|
||||||
var cleanPath = path.Replace( '\\', '/' );
|
var cleanPath = fsPath.Replace( '\\', '/' );
|
||||||
var utfPath = Encoding.UTF8.GetBytes( cleanPath );
|
var path = Encoding.ASCII.GetBytes( cleanPath );
|
||||||
|
|
||||||
var bPath = stackalloc byte[utfPath.Length + 1];
|
var bPath = stackalloc byte[path.Length + 1];
|
||||||
Marshal.Copy( utfPath, 0, new IntPtr( bPath ), utfPath.Length );
|
Marshal.Copy( path, 0, new IntPtr( bPath ), path.Length );
|
||||||
pPath = ( char* )bPath;
|
pPath = ( char* )bPath;
|
||||||
|
|
||||||
Crc32.Init();
|
Crc32.Init();
|
||||||
Crc32.Update( utfPath );
|
Crc32.Update( path );
|
||||||
*pResourceHash = Crc32.Checksum;
|
*pResourceHash = Crc32.Checksum;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, path );
|
PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, fsPath );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
|
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
|
||||||
|
|
@ -206,7 +206,8 @@ namespace Penumbra
|
||||||
|
|
||||||
pFileDesc->FileMode = FileMode.LoadUnpackedResource;
|
pFileDesc->FileMode = FileMode.LoadUnpackedResource;
|
||||||
|
|
||||||
var utfPath = Encoding.UTF8.GetBytes( gameFsPath );
|
// note: must be utf16
|
||||||
|
var utfPath = Encoding.Unicode.GetBytes( gameFsPath );
|
||||||
|
|
||||||
Marshal.Copy( utfPath, 0, new IntPtr( &pFileDesc->UtfFileName ), utfPath.Length );
|
Marshal.Copy( utfPath, 0, new IntPtr( &pFileDesc->UtfFileName ), utfPath.Length );
|
||||||
|
|
||||||
|
|
@ -215,7 +216,6 @@ namespace Penumbra
|
||||||
|
|
||||||
pFileDesc->FileDescriptor = fd;
|
pFileDesc->FileDescriptor = fd;
|
||||||
|
|
||||||
|
|
||||||
return ReadFile( pFileHandler, pFileDesc, priority, isSync );
|
return ReadFile( pFileHandler, pFileDesc, priority, isSync );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
@ -18,7 +17,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
private readonly Plugin _plugin;
|
private readonly Plugin _plugin;
|
||||||
|
|
||||||
public bool Visible { get; set; } = true;
|
public bool Visible = false;
|
||||||
|
|
||||||
private static readonly Vector2 AutoFillSize = new Vector2( -1, -1 );
|
private static readonly Vector2 AutoFillSize = new Vector2( -1, -1 );
|
||||||
private static readonly Vector2 ModListSize = new Vector2( 200, -1 );
|
private static readonly Vector2 ModListSize = new Vector2( 200, -1 );
|
||||||
|
|
@ -43,9 +42,9 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
ImGui.SetNextWindowSizeConstraints( MinSettingsSize, MaxSettingsSize );
|
ImGui.SetNextWindowSizeConstraints( MinSettingsSize, MaxSettingsSize );
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var ret = ImGui.Begin( _plugin.PluginDebugTitleStr );
|
var ret = ImGui.Begin( _plugin.PluginDebugTitleStr, ref Visible );
|
||||||
#else
|
#else
|
||||||
var ret = ImGui.Begin( _plugin.Name );
|
var ret = ImGui.Begin( _plugin.Name, ref Visible );
|
||||||
#endif
|
#endif
|
||||||
if( !ret )
|
if( !ret )
|
||||||
{
|
{
|
||||||
|
|
@ -55,10 +54,14 @@ namespace Penumbra.UI
|
||||||
ImGui.BeginTabBar( "PenumbraSettings" );
|
ImGui.BeginTabBar( "PenumbraSettings" );
|
||||||
|
|
||||||
DrawSettingsTab();
|
DrawSettingsTab();
|
||||||
DrawResourceMods();
|
|
||||||
DrawEffectiveFileList();
|
|
||||||
|
|
||||||
DrawDeleteModal();
|
if( !_isImportRunning )
|
||||||
|
{
|
||||||
|
DrawResourceMods();
|
||||||
|
DrawEffectiveFileList();
|
||||||
|
|
||||||
|
DrawDeleteModal();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndTabBar();
|
ImGui.EndTabBar();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue