Skip to content
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

Pakfile Explorer fixes #130

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Pakfile Explorer fixes #130

wants to merge 11 commits into from

Conversation

tsa96
Copy link
Member

@tsa96 tsa96 commented Mar 13, 2025

Fixes Panzer's issue with surf_arcade
Closes #49

tsa96 added 2 commits March 13, 2025 02:02
…e explorer

Pakfile explorer drag-drop wasn't working, where the OnDrop event
wasn't getting raised.

I have no idea why this fixes it, but it does, and Avalonia seems to
automatically be doing the DragDropEffects.Link icon behaviour already,
so removing this code doesn't affect the application in any negative way.
Idk why I was doing this, more complex and not going to be a major perf
benefit unless getting used a lot.
@tsa96 tsa96 added Type: Bug Something that should work/look one way isn't quite doing that. Where: UI Something that primarily affects the Lumper.UI codebase. Where: Pakfile Explorer labels Mar 13, 2025
tsa96 added 3 commits March 13, 2025 08:30
Fixes two bugs:
- Could get stuck in an infinite loop when moving from a directory whose
path is a substring of the new directory
- Would change "foo/barbaz.vtf" when moving "foo/bar.vtf"
@tsa96 tsa96 force-pushed the fix/pakfile-fixes branch from e10a394 to f51ca0a Compare March 13, 2025 08:30
@@ -291,6 +291,22 @@ out string[]? opNoExtension
if (changes > 0)
Logger.Info($"Replaced {changes} instances of {updatedOp} with {updatedNp} in file {entry.Key}");
}

// TexData - doesn't have viewmodels (yay!)
if (oldPath.EndsWith(".vmt", cmp) && opPrefix.Equals("materials", cmp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Path.GetExtension instead.

string[] npSplit = newPath.Split(separator);

// VMTs can reference VTFs ignoring the root directory and without the extension
oldPath = string.Join(separator, opSplit[1..]);
Copy link
Member

@GordiNoki GordiNoki Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes oldPath and newPath empty, making line 247 throw an error on string replace. If current path doesn't use specified separator, opSplit and npSplit would become one-element arrays, and both of them are sliced off here

// fucked.
if (directoryMatch is not null)
{
op = string.Join("/", op.Split('/')[1..]);
Copy link
Member

@Panzerhandschuh Panzerhandschuh Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more efficient to use substrings:
op = op.Substring(op.IndexOf('/') + 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something that should work/look one way isn't quite doing that. Where: Pakfile Explorer Where: UI Something that primarily affects the Lumper.UI codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor texdata when moving/renaming VMTs
3 participants