Fix bug when checking profiles are loaded
bug: loading profiles do not check if other profiles are loaded which will result in every load button to become disabled
This commit is contained in:
parent
f43edf9bbd
commit
e7d9ee1a21
2 changed files with 15 additions and 9 deletions
|
|
@ -48,6 +48,12 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
} catch (Exception e) {
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when listing profiles", e);
|
||||
}
|
||||
|
||||
checkEntriesLoaded();
|
||||
}
|
||||
|
||||
public void checkEntriesLoaded() {
|
||||
this.children().forEach(Entry::checkLoaded);
|
||||
}
|
||||
|
||||
protected int getScrollbarPosition() {
|
||||
|
|
@ -86,12 +92,11 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
|
||||
minecraft.options.save();
|
||||
|
||||
ProfilesList.this.checkEntriesLoaded();
|
||||
button.active = false;
|
||||
})
|
||||
.size(75, 20)
|
||||
.build();
|
||||
|
||||
this.loadButton.active = !Profiles.isProfileLoaded(profileName.getString());
|
||||
}
|
||||
|
||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
|
|
@ -117,10 +122,16 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
public List<? extends NarratableEntry> narratables() {
|
||||
return ImmutableList.of(this.editButton, this.loadButton);
|
||||
}
|
||||
|
||||
protected void checkLoaded() {
|
||||
this.loadButton.active = !Profiles.isProfileLoaded(profileName.getString());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Entry extends ContainerObjectSelectionList.Entry<ProfilesList.Entry> {
|
||||
public Entry() {
|
||||
}
|
||||
|
||||
abstract void checkLoaded();
|
||||
}
|
||||
}
|
||||
|
|
@ -129,8 +129,6 @@ public class Profiles {
|
|||
}
|
||||
|
||||
public static boolean isProfileLoaded(String profileName) {
|
||||
boolean profileLoaded = false;
|
||||
|
||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||
|
||||
List<Path> optionFiles = new ArrayList<>();
|
||||
|
|
@ -145,10 +143,7 @@ public class Profiles {
|
|||
try {
|
||||
for (Path optionFile : optionFiles) {
|
||||
Path profileOptions = profile.resolve(optionFile.getFileName());
|
||||
|
||||
if (FileUtils.contentEquals(optionFile.toFile(), profileOptions.toFile())) {
|
||||
profileLoaded = true;
|
||||
} else {
|
||||
if (!FileUtils.contentEquals(optionFile.toFile(), profileOptions.toFile())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +152,7 @@ public class Profiles {
|
|||
return false;
|
||||
}
|
||||
|
||||
return profileLoaded;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void loadOptionFile(String profileName, Path options) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue