-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small fixes #17
Merged
Merged
Small fixes #17
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f9402a
Make import of files with erroneous extension a bit more robust.
Ottermandias f3857e0
Allow disabling the debug bar in debug mode.
Ottermandias fc2a18e
Tiny improvement to importing progress bar. Not sane, but at least no…
Ottermandias 374b652
Fix crash on Delete Mod Button with no mod selected or already delete…
Ottermandias 817c3a2
Silence warning about different system dlls
Ottermandias 82dff6b
Removed Regions.
Ottermandias de8930c
All Linebreaks to LF.
Ottermandias 20cb3fb
Usings cleanup.
Ottermandias e1d2b8e
Some readonly and private cleanup.
Ottermandias a4d36d7
Made gamePaths editable directly in the window.
Ottermandias b9a9e30
Added Filter to Installed Mod List.
Ottermandias 5f92813
Bug fixes for group selection in installed mods tab.
Ottermandias b307a78
Removed extension check switch.
Ottermandias 801d9e2
Applied a slightly expanded .editorconfig to all files, checked the c…
Ottermandias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
using System.Runtime.InteropServices; | ||
using Dalamud.Game.ClientState.Actors; | ||
using Dalamud.Game.ClientState.Actors.Types; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using Dalamud.Game.ClientState.Actors; | ||
using Dalamud.Game.ClientState.Actors.Types; | ||
|
||
namespace Penumbra | ||
{ | ||
public static class RefreshActors | ||
{ | ||
private const int RenderModeOffset = 0x0104; | ||
private const int RenderTaskPlayerDelay = 75; | ||
private const int RenderTaskOtherDelay = 25; | ||
private const int ModelInvisibilityFlag = 0b10; | ||
private static async void Redraw(Actor actor) | ||
{ | ||
var ptr = actor.Address; | ||
var renderModePtr = ptr + RenderModeOffset; | ||
var renderStatus = Marshal.ReadInt32(renderModePtr); | ||
async void DrawObject(int delay) | ||
{ | ||
Marshal.WriteInt32(renderModePtr, renderStatus | ModelInvisibilityFlag); | ||
await Task.Delay(delay); | ||
Marshal.WriteInt32(renderModePtr, renderStatus & ~ModelInvisibilityFlag); | ||
} | ||
if (actor.ObjectKind == Dalamud.Game.ClientState.Actors.ObjectKind.Player) | ||
{ | ||
DrawObject(RenderTaskPlayerDelay); | ||
await Task.Delay(RenderTaskPlayerDelay); | ||
} | ||
else | ||
DrawObject(RenderTaskOtherDelay); | ||
} | ||
public static void RedrawSpecific(ActorTable actors, string name) | ||
{ | ||
if (name?.Length == 0) | ||
RedrawAll(actors); | ||
foreach (var actor in actors) | ||
if (actor.Name == name) | ||
Redraw(actor); | ||
} | ||
public static void RedrawAll(ActorTable actors) | ||
{ | ||
foreach (var actor in actors) | ||
Redraw(actor); | ||
} | ||
public static class RefreshActors | ||
{ | ||
private const int RenderModeOffset = 0x0104; | ||
private const int RenderTaskPlayerDelay = 75; | ||
private const int RenderTaskOtherDelay = 25; | ||
private const int ModelInvisibilityFlag = 0b10; | ||
|
||
private static async void Redraw(Actor actor) | ||
{ | ||
var ptr = actor.Address; | ||
var renderModePtr = ptr + RenderModeOffset; | ||
var renderStatus = Marshal.ReadInt32(renderModePtr); | ||
|
||
async void DrawObject(int delay) | ||
{ | ||
Marshal.WriteInt32(renderModePtr, renderStatus | ModelInvisibilityFlag); | ||
await Task.Delay(delay); | ||
Marshal.WriteInt32(renderModePtr, renderStatus & ~ModelInvisibilityFlag); | ||
} | ||
|
||
if (actor.ObjectKind == Dalamud.Game.ClientState.Actors.ObjectKind.Player) | ||
{ | ||
DrawObject(RenderTaskPlayerDelay); | ||
await Task.Delay(RenderTaskPlayerDelay); | ||
} | ||
else | ||
DrawObject(RenderTaskOtherDelay); | ||
|
||
} | ||
|
||
public static void RedrawSpecific(ActorTable actors, string name) | ||
{ | ||
if (name?.Length == 0) | ||
RedrawAll(actors); | ||
|
||
foreach (var actor in actors) | ||
if (actor.Name == name) | ||
Redraw(actor); | ||
} | ||
|
||
public static void RedrawAll(ActorTable actors) | ||
{ | ||
foreach (var actor in actors) | ||
Redraw(actor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ internal class TexToolsImport | |
|
||
public ImporterState State { get; private set; } | ||
|
||
public long TotalProgress { get; private set; } | ||
public long TotalProgress { get; private set; } = 0; | ||
public long CurrentProgress { get; private set; } | ||
|
||
public float Progress | ||
|
@@ -53,11 +53,8 @@ public void ImportModPack( FileInfo modPackFile ) | |
switch( modPackFile.Extension ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why even really have this switch anymore if the version is used to check if its valid or not and what it is? |
||
{ | ||
case ".ttmp": | ||
ImportV1ModPack( modPackFile ); | ||
break; | ||
|
||
case ".ttmp2": | ||
ImportV2ModPack( modPackFile ); | ||
VerifyVersionAndImport(modPackFile); | ||
break; | ||
|
||
default: | ||
|
@@ -88,15 +85,33 @@ private SqPackStream GetMagicSqPackDeleterStream( ZipFile file, string entryName | |
return new MagicTempFileStreamManagerAndDeleterFuckery( fs ); | ||
} | ||
|
||
private void ImportV1ModPack( FileInfo modPackFile ) | ||
private void VerifyVersionAndImport(FileInfo modPackFile) | ||
{ | ||
PluginLog.Log( " -> Importing V1 ModPack" ); | ||
|
||
using var zfs = modPackFile.OpenRead(); | ||
using var extractedModPack = new ZipFile( zfs ); | ||
|
||
var mpl = extractedModPack.GetEntry( "TTMPL.mpl" ); | ||
var modListRaw = GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 ).Split( | ||
var modRaw = GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 ); | ||
|
||
// At least a better validation than going by the extension. | ||
if (modRaw.Contains("\"TTMPVersion\":")) | ||
{ | ||
if (modPackFile.Extension != ".ttmp2") | ||
PluginLog.Warning($"File {modPackFile.FullName} seems to be a V2 TTMP, but has the wrong extension."); | ||
ImportV2ModPack(modPackFile, extractedModPack, modRaw); | ||
} | ||
else | ||
{ | ||
if (modPackFile.Extension != ".ttmp") | ||
PluginLog.Warning($"File {modPackFile.FullName} seems to be a V1 TTMP, but has the wrong extension."); | ||
ImportV1ModPack(modPackFile, extractedModPack, modRaw); | ||
} | ||
} | ||
|
||
private void ImportV1ModPack( FileInfo modPackFile, ZipFile extractedModPack, string modRaw ) | ||
{ | ||
PluginLog.Log( " -> Importing V1 ModPack" ); | ||
|
||
var modListRaw = modRaw.Split( | ||
new[] { "\r\n", "\r", "\n" }, | ||
StringSplitOptions.None | ||
); | ||
|
@@ -129,33 +144,26 @@ private void ImportV1ModPack( FileInfo modPackFile ) | |
ExtractSimpleModList( newModFolder, modList, modData ); | ||
} | ||
|
||
private void ImportV2ModPack( FileInfo modPackFile ) | ||
private void ImportV2ModPack( FileInfo modPackFile, ZipFile extractedModPack, string modRaw ) | ||
{ | ||
using var zfs = modPackFile.OpenRead(); | ||
using var extractedModPack = new ZipFile( zfs ); | ||
|
||
var mpl = extractedModPack.GetEntry( "TTMPL.mpl" ); | ||
var modList = JsonConvert.DeserializeObject< SimpleModPack >( GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 ) ); | ||
var modList = JsonConvert.DeserializeObject< SimpleModPack >( modRaw ); | ||
|
||
if( modList.TTMPVersion.EndsWith( "s" ) ) | ||
{ | ||
ImportSimpleV2ModPack( extractedModPack ); | ||
ImportSimpleV2ModPack( extractedModPack, modList ); | ||
return; | ||
} | ||
|
||
if( modList.TTMPVersion.EndsWith( "w" ) ) | ||
{ | ||
ImportExtendedV2ModPack( extractedModPack ); | ||
ImportExtendedV2ModPack( extractedModPack, modRaw ); | ||
} | ||
} | ||
|
||
private void ImportSimpleV2ModPack( ZipFile extractedModPack ) | ||
private void ImportSimpleV2ModPack( ZipFile extractedModPack, SimpleModPack modList ) | ||
{ | ||
PluginLog.Log( " -> Importing Simple V2 ModPack" ); | ||
|
||
var mpl = extractedModPack.GetEntry( "TTMPL.mpl" ); | ||
var modList = JsonConvert.DeserializeObject< SimpleModPack >( GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 ) ); | ||
|
||
// Create a new ModMeta from the TTMP modlist info | ||
var modMeta = new ModMeta | ||
{ | ||
|
@@ -179,12 +187,11 @@ private void ImportSimpleV2ModPack( ZipFile extractedModPack ) | |
ExtractSimpleModList( newModFolder, modList.SimpleModsList, modData ); | ||
} | ||
|
||
private void ImportExtendedV2ModPack( ZipFile extractedModPack ) | ||
private void ImportExtendedV2ModPack( ZipFile extractedModPack, string modRaw ) | ||
{ | ||
PluginLog.Log( " -> Importing Extended V2 ModPack" ); | ||
|
||
var mpl = extractedModPack.GetEntry( "TTMPL.mpl" ); | ||
var modList = JsonConvert.DeserializeObject< ExtendedModPack >( GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 ) ); | ||
var modList = JsonConvert.DeserializeObject< ExtendedModPack >( modRaw ); | ||
|
||
// Create a new ModMeta from the TTMP modlist info | ||
var modMeta = new ModMeta | ||
|
@@ -202,7 +209,7 @@ private void ImportExtendedV2ModPack( ZipFile extractedModPack ) | |
|
||
var newModFolder = new DirectoryInfo( | ||
Path.Combine( _outDirectory.FullName, | ||
Path.GetFileNameWithoutExtension( modList.Name ) | ||
Path.GetFileNameWithoutExtension( modList.Name ).ReplaceInvalidPathSymbols() | ||
) | ||
); | ||
newModFolder.Create(); | ||
|
@@ -216,10 +223,12 @@ private void ImportExtendedV2ModPack( ZipFile extractedModPack ) | |
// Iterate through all pages | ||
foreach( var page in modList.ModPackPages) | ||
{ | ||
foreach(var group in page.ModGroups) { | ||
var groupFolder = new DirectoryInfo(Path.Combine(newModFolder.FullName, group.GroupName)); | ||
foreach(var option in group.OptionList) { | ||
var optionFolder = new DirectoryInfo( Path.Combine( groupFolder.FullName, option.Name ) ); | ||
foreach(var group in page.ModGroups) | ||
{ | ||
var groupFolder = new DirectoryInfo(Path.Combine(newModFolder.FullName, group.GroupName.ReplaceInvalidPathSymbols())); | ||
foreach(var option in group.OptionList) | ||
{ | ||
var optionFolder = new DirectoryInfo( Path.Combine( groupFolder.FullName, option.Name.ReplaceInvalidPathSymbols()) ); | ||
ExtractSimpleModList( optionFolder, option.ModsJsons, modData ); | ||
} | ||
AddMeta(newModFolder, groupFolder, group, modMeta); | ||
|
@@ -240,18 +249,18 @@ private void AddMeta( DirectoryInfo baseFolder, DirectoryInfo groupFolder,ModGro | |
GroupName = group.GroupName, | ||
Options = new List<Option>(), | ||
}; | ||
foreach( var opt in group.OptionList ) | ||
foreach( var opt in group.OptionList ) | ||
{ | ||
var optio = new Option | ||
{ | ||
OptionName = opt.Name, | ||
OptionDesc = String.IsNullOrEmpty(opt.Description) ? "" : opt.Description, | ||
OptionFiles = new Dictionary<string, HashSet<string>>() | ||
}; | ||
var optDir = new DirectoryInfo(Path.Combine( groupFolder.FullName, opt.Name)); | ||
var optDir = new DirectoryInfo(Path.Combine( groupFolder.FullName, opt.Name.ReplaceInvalidPathSymbols())); | ||
if (optDir.Exists) | ||
{ | ||
foreach ( var file in optDir.EnumerateFiles("*.*", SearchOption.AllDirectories) ) | ||
foreach ( var file in optDir.EnumerateFiles("*.*", SearchOption.AllDirectories) ) | ||
{ | ||
optio.AddFile(file.FullName.Substring(baseFolder.FullName.Length).TrimStart('\\'), file.FullName.Substring(optDir.FullName.Length).TrimStart('\\').Replace('\\','/')); | ||
} | ||
|
@@ -273,7 +282,7 @@ private void ExtractSimpleModList( DirectoryInfo outDirectory, IEnumerable< Simp | |
// haha allocation go brr | ||
var wtf = mods.ToList(); | ||
|
||
TotalProgress = wtf.LongCount(); | ||
TotalProgress += wtf.LongCount(); | ||
|
||
// Extract each SimpleMod into the new mod folder | ||
foreach( var simpleMod in wtf ) | ||
|
@@ -307,7 +316,7 @@ private void ExtractMod( DirectoryInfo outDirectory, SimpleMod mod, SqPackStream | |
} | ||
catch( Exception ex ) | ||
{ | ||
PluginLog.LogError( ex, "Could not export mod." ); | ||
PluginLog.LogError( ex, "Could not extract mod." ); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in editorconfig but always have braces