Skip to content

Commit

Permalink
Convert file browser widget system to Path
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Feb 8, 2025
1 parent 69636b9 commit 6361178
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 70 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod_version = 0.23.999-dev
# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 25w06a
minecraft_version = 25w06a
mappings_version = 25w06a+build.2
mappings_version = 25w06a+build.4

fabric_loader_version = 0.16.10
mod_menu_version = 13.0.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package fi.dy.masa.malilib.gui.interfaces;

import java.io.File;
import java.nio.file.Path;
import javax.annotation.Nullable;

public interface IDirectoryCache
{
// TODO -- Remove the file system; needs to deal with the FileFilter mechanism to make it compat with Path
@Nullable
File getCurrentDirectoryForContext(String context);
Path getCurrentDirectoryForContext(String context);

void setCurrentDirectoryForContext(String context, File dir);
void setCurrentDirectoryForContext(String context, Path dir);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package fi.dy.masa.malilib.gui.interfaces;

import java.io.File;
import java.nio.file.Path;

public interface IDirectoryNavigator
{
// TODO -- Remove the file system; needs to deal with the FileFilter mechanism to make it compat with Path
File getCurrentDirectory();
Path getCurrentDirectory();

void switchToDirectory(File dir);
void switchToDirectory(Path dir);

void switchToParentDirectory();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fi.dy.masa.malilib.gui.interfaces;

import java.io.File;
import java.nio.file.Path;
import javax.annotation.Nullable;

public interface IFileBrowserIconProvider
Expand All @@ -16,5 +16,5 @@ public interface IFileBrowserIconProvider
IGuiIcon getIconDirectory();

@Nullable
IGuiIcon getIconForFile(File file);
IGuiIcon getIconForFile(Path file);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fi.dy.masa.malilib.gui.widgets;

import java.io.File;

import net.minecraft.client.gui.DrawContext;

import fi.dy.masa.malilib.gui.interfaces.IDirectoryNavigator;
Expand Down Expand Up @@ -40,7 +38,7 @@ protected boolean onMouseClickedImpl(int mouseX, int mouseY, int mouseButton)
{
if (this.entry.getType() == DirectoryEntryType.DIRECTORY)
{
this.navigator.switchToDirectory(new File(this.entry.getDirectory(), this.entry.getName()));
this.navigator.switchToDirectory(this.entry.getDirectory().resolve(this.entry.getName()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fi.dy.masa.malilib.gui.widgets;

import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import javax.annotation.Nullable;

Expand All @@ -19,16 +19,17 @@

public class WidgetDirectoryNavigation extends WidgetSearchBar
{
// TODO -- Remove the file system; needs to deal with the FileFilter mechanism to make it compat with Path
protected final File currentDir;
protected final File rootDir;
//protected final File currentDir;
//protected final File rootDir;
protected final Path currentDir;
protected final Path rootDir;
protected final IDirectoryNavigator navigator;
protected final WidgetIcon iconRoot;
protected final WidgetIcon iconUp;
protected final WidgetIcon iconCreateDir;

public WidgetDirectoryNavigation(int x, int y, int width, int height,
File currentDir, File rootDir, IDirectoryNavigator navigator, IFileBrowserIconProvider iconProvider)
Path currentDir, Path rootDir, IDirectoryNavigator navigator, IFileBrowserIconProvider iconProvider)
{
super(x, y, width, height, 0, iconProvider.getIconSearch(), LeftRight.RIGHT);

Expand Down
Loading

0 comments on commit 6361178

Please sign in to comment.