hexabits / nifskope

Other
245 stars 54 forks source link

Texture path selection in texture sets defaults to last file selected instead of location of current texture #56

Open MadCat221 opened 11 months ago

MadCat221 commented 11 months ago

At some point since the fork from Jon's, something was altered to make texture path selection start in the location of the last file selected for such file paths in nifskope instead of the location of the current file. This complicates switching to alternate textures in the same directory as it is possible the last file pathed to may not even be close to the same directory.

hexabits commented 11 months ago

Do you mean the multiple forks from my dev8? This is the "Jon" fork, it's unclear from the phrasing if you know that.

I've been slowly merging features from them when I'm not implementing more urgent things for Starfield, I assume I'll come across it then. If you mean between my dev7 and my dev8 or my dev8 and my dev9 then I don't know, I'll have to look as I didn't intentionally change anything there.

GammaMetroid commented 11 months ago

I find the existing behavior, starting from the last file selected, is helpful. When I'm changing textures, I often have to change at least the diffuse and normal map, so if they are both in the same directory, this way I don't have to start from the old directory and navigate to the new one both times. Maybe this behavior can be limited to the same session? Then in a new nifskope session it can default to wherever the current specified file is.

ja231c commented 11 months ago

I think it worked properly (properly as in, the location of the currently set texture opens) back in Dev 7 (or maybe before Dev 7?), somewhen in Dev 8 it was changed to this annoying "location of the last chosen texture", which generally ends up being some random folder that the user completely forgot about.

That being said, I think if the current texture file wasn't present it used to default to the NifSkope directory back then, or something, that too is annoying; could be remembering it wrong though.

Anyway, I would much prefer if it was "if exists location of currently set texture else if exists location of last chosen texture else whatever".

fo76utils commented 5 months ago

The issue is probably related to this code in src/spells/texture.cpp at line 215:

        QString file = TexCache::find( nif->get<QString>( iFile ), nif->getFolder() );

        QSettings settings;
        QString key = QString( "%1/%2/%3/Last Texture Path" ).arg( "Spells", page(), name() );

        if ( !QFile::exists( file ) ) {
            // if file not found in cache, use last texture path

            QString defaulttexpath( settings.value( key, QVariant( QDir::homePath() ) ).toString() );
            //file = QDir(defaulttexpath).filePath(file);
            file = defaulttexpath;
        }

If the file does not exist, it falls back to using the location of the last chosen texture. There were no updates to this code in the last 10 years, but possibly the game manager rework around dev8 made changes elsewhere that now cause the check to always fail.

I do have a fix to this in my fork, although it might not be really helpful here since it depends on other changes.