PrismLauncher / PrismLauncher

A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)
https://prismlauncher.org
GNU General Public License v3.0
5.93k stars 663 forks source link

Make one folder for all screenshots / screenshot browser #1027

Open SuperFredi opened 1 year ago

SuperFredi commented 1 year ago

Role

I have many different instances that I use regularly and I take many screenshots.

Suggestion

I want a central screenshot folder, where all screenshots of each instance are stored.

Benefit

Searching every instance for "that one screenshot" is tedious and time consuming.

This suggestion is unique

You may use the editor below to elaborate further.

By having a central screenshots folder it is easier to browse all of your screenshots. You also don't need to worry that when you delete an instance, that you forgot to backup your screenshots.

If that is not possible because Minecraft's programming prevents it, an alternative could be a 'browse screenshots' button / window, where you can browse all of your screenshots from all of your instances, in the top bar.

Something like this, for example: grafik

maxashen commented 1 year ago

The screenshot directory appears to be hardcoded by the Minecraft: Java Edition executable relative to the working directory (.minecraft directory). However, in theory you could work around this limitation by using Prism Launcher's existing custom commands feature. You'll have to write a short program that takes the absolute path of the instance as a command line option and moves all screenshots to the desired folder. Then simply have Prism call that program whenever you exit the game, from Settings->Custom Commands->Post-exit commands.

I successfully tested this work around on Windows 10 with the following program (Java; you could write a shell script instead):

package moveall;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import static java.nio.file.FileVisitResult.CONTINUE;
import static java.nio.file.StandardCopyOption.*;

public class MoveAll
{
    public static class MoveAllFileVisitor extends SimpleFileVisitor<Path>
    {
        private final Path dst;

        public MoveAllFileVisitor(Path path)
        {
            this.dst = path;
        }

        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attr)
        {
            if(attr.isRegularFile())
            {
                try
                {
                    Files.move
                    (
                        file,
                        this.dst.resolve(file.getFileName()),
                        REPLACE_EXISTING
                    );
                }
                catch(IOException e)
                {
                }
            }

            return CONTINUE;
        }
    }

    public static void main(String[] args)
    {
        if(args.length == 2)
        {
            File dst = new File(args[1]);
            dst.mkdirs();

            MoveAllFileVisitor fv = new MoveAllFileVisitor(dst.toPath());
            try
            {
                Files.walkFileTree(Paths.get(args[0]), fv);
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
    }
}

I compiled with Java 17, but it should work with Java 7+ or whenever NIO was added.

javac -d out\ MoveAll.java jar cfe MoveAll.jar moveall.MoveAll -C out\ moveall

And I used this option in the Prism Launcher, Settings->Custom Commands->Post-exit:

java -jar "C:/path/to/MoveAll.jar" "$INST_MC_DIR/screenshots/" "C:/path/to/pictures/folder/$INST_NAME/"

DeveloperBlue commented 11 months ago

Would it be possible to have Prism create a symlink/junction to a folder? And we can set a global default folder directory in settings?

Aces-and-Jacks commented 10 months ago

I'm gonna express @Hexasan 's idea from #2080 but I think it's a great idea and would help with instance deleting.

When deleting an old instance, It should ask you if you want to save screenshots in the instance, if checked the screenshots would be moved to a seperate folder(possibly selected by the user).

Then from what I added on to it.

Ohh, like maybe have a central screenshots folder (similar to the central mods folder) and move screenshots to there, if a location hasn't been set by the user. Maybe even generate another folder in that folder per instance name, if possible.

I know it's similar to what @SuperFredi said but I'm mainly just adding onto it

Riva3000 commented 7 months ago

Would it be possible to have Prism create a symlink/junction to a folder? And we can set a global default folder directory in settings?

I can confirm that at least Minecraft ver 1.20.1 and 1.20.4 are able to save screenshot files into manually created junction named "screenshots" that replaces the original screenshots folder in .minecraft root dir. So that can be a route forward, at least for Windows / NTFS.