add name declaration to the dependency section
This commit is contained in:
parent
5a312eaba3
commit
b82e6bceae
|
@ -12,7 +12,7 @@ credits = [
|
||||||
|
|
||||||
[frog.dependencies]
|
[frog.dependencies]
|
||||||
depends = [
|
depends = [
|
||||||
{ id = "other_mod", versions = ">=0.2.0 <0.5.2 || 0.1.1 || 1.x || 3 || ~5 || ^6.x", link = "https://example.com" }
|
{ id = "other_mod", name = "Other Mod", versions = ">=0.2.0 <0.5.2 || 0.1.1 || 1.x || 3 || ~5 || ^6.x", link = "https://example.com" }
|
||||||
]
|
]
|
||||||
breaks = [
|
breaks = [
|
||||||
{ id = "old_mod", versions = "*" }
|
{ id = "old_mod", versions = "*" }
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class ModDependencies {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Entry(String id, String range, String link) {
|
public record Entry(String id, String range, String link, String name) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,27 +122,46 @@ public class LoaderGui {
|
||||||
public static final ContentType<ModDependencyResolver.UnfulfilledDependencyException> INFO_UNFULFILLED_DEP = new ContentType<>((frame, ex) -> {
|
public static final ContentType<ModDependencyResolver.UnfulfilledDependencyException> INFO_UNFULFILLED_DEP = new ContentType<>((frame, ex) -> {
|
||||||
JPanel pane = new JPanel(new BorderLayout());
|
JPanel pane = new JPanel(new BorderLayout());
|
||||||
JTextPane title = new JTextPane();
|
JTextPane title = new JTextPane();
|
||||||
title.setContentType("text/html");
|
//title.setContentType("text/html");
|
||||||
title.setBackground(pane.getBackground());
|
title.setBackground(pane.getBackground());
|
||||||
title.setEditable(false);
|
title.setEditable(false);
|
||||||
int size = ex.getDependencies().size();
|
int size = ex.getDependencies().size();
|
||||||
title.setText("<html><h3>Found "+size+" Error"+(size > 1 ? "s:":":")+"</h3></html>");
|
//title.setText("<html><h3>Found "+size+" Error"+(size > 1 ? "s:":":")+"</h3></html>");
|
||||||
|
title.setText("Found "+size+" Error"+(size > 1 ? "s:":":"));
|
||||||
|
title.setFont(title.getFont().deriveFont(Font.BOLD, 16f));
|
||||||
|
title.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0));
|
||||||
pane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
pane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||||
pane.add(title, BorderLayout.NORTH);
|
pane.add(title, BorderLayout.NORTH);
|
||||||
|
|
||||||
JPanel list = new JPanel();
|
Box list = Box.createVerticalBox();
|
||||||
list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
|
|
||||||
ex.getDependencies().forEach(e -> {
|
ex.getDependencies().forEach(e -> {
|
||||||
StringBuilder description = new StringBuilder();
|
StringBuilder description = new StringBuilder();
|
||||||
if (e.presentVersion() != null){
|
if (e.presentVersion() != null){
|
||||||
description.append("Mod %s (%s) depends on a Mod with id %s with a version matching %s, but a different version is present or provided: %s".formatted(e.source().id(), e.source().name(), e.dependency(), printVersionRange(e.range()), e.presentVersion()));
|
description.append("Mod ").append(e.source().id()).append(" (").append(e.source().name()).append(") depends on ");
|
||||||
|
if (e.dependencyName() != null){
|
||||||
|
description.append(e.dependencyName()).append(" (").append(e.dependency()).append(") ");
|
||||||
} else {
|
} else {
|
||||||
description.append(String.format("Mod %s (%s) depends on a Mod with id %s with a version matching %s. \nNo version is currently available.", e.source().id(), e.source().name(), e.dependency(), printVersionRange(e.range())));
|
description.append("a Mod with id ").append(e.dependency());
|
||||||
|
}
|
||||||
|
description.append(" with a version matching ").append(printVersionRange(e.range())).append(", but a different version is present or provided: ").append(e.presentVersion());
|
||||||
|
} else {
|
||||||
|
description.append("Mod ").append(e.source().id()).append(" (").append(e.source().name()).append(") depends on ");
|
||||||
|
if (e.dependencyName() != null){
|
||||||
|
description.append(e.dependencyName()).append(" (").append(e.dependency()).append(") ");
|
||||||
|
} else {
|
||||||
|
description.append("a Mod with id ").append(e.dependency());
|
||||||
|
}
|
||||||
|
description.append(" with a version matching ").append(printVersionRange(e.range())).append(". \nNo version is currently available.");
|
||||||
}
|
}
|
||||||
description.append("\nSuggested Solution: Install ")
|
description.append("\nSuggested Solution: Install ")
|
||||||
.append(e.range().maxCompatible().or(e.range()::minCompatible).map(Objects::toString)
|
.append(e.range().maxCompatible().or(e.range()::minCompatible).map(Objects::toString)
|
||||||
.map(s -> "0.0.0".equals(s) ? "any version" : "version " + s).orElse("<unknown>"))
|
.map(s -> "0.0.0".equals(s) ? "any version" : "version " + s).orElse("<unknown>"))
|
||||||
.append(" of Mod with id ").append(e.dependency());
|
.append(" of ");
|
||||||
|
if (e.dependencyName() != null){
|
||||||
|
description.append(e.dependencyName()).append(" (").append(e.dependency()).append(") ");
|
||||||
|
} else {
|
||||||
|
description.append("Mod with id ").append(e.dependency());
|
||||||
|
}
|
||||||
List<JButton> actions = new ArrayList<>();
|
List<JButton> actions = new ArrayList<>();
|
||||||
if (e.link() != null) {
|
if (e.link() != null) {
|
||||||
boolean install = e.link().endsWith(FrogLoaderImpl.MOD_FILE_EXTENSION);
|
boolean install = e.link().endsWith(FrogLoaderImpl.MOD_FILE_EXTENSION);
|
||||||
|
@ -176,8 +195,7 @@ public class LoaderGui {
|
||||||
pane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
pane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||||
pane.add(title, BorderLayout.NORTH);
|
pane.add(title, BorderLayout.NORTH);
|
||||||
|
|
||||||
JPanel list = new JPanel();
|
Box list = Box.createVerticalBox();
|
||||||
list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
|
|
||||||
ex.getBreaks().forEach(e -> {
|
ex.getBreaks().forEach(e -> {
|
||||||
String description = "Mod %s (%s) breaks with mod %s (%s) for versions matching %s \n(present: %s)".formatted(e.source().id(), e.source().name(), e.broken().id(), e.broken().name(), printVersionRange(e.range()), e.broken().version()) +
|
String description = "Mod %s (%s) breaks with mod %s (%s) for versions matching %s \n(present: %s)".formatted(e.source().id(), e.source().name(), e.broken().id(), e.broken().name(), printVersionRange(e.range()), e.broken().version()) +
|
||||||
"\nSuggested Solution: Install " +
|
"\nSuggested Solution: Install " +
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class ModDependencyResolver {
|
||||||
private void load() throws ResolverException {
|
private void load() throws ResolverException {
|
||||||
for (ModProperties props : original) {
|
for (ModProperties props : original) {
|
||||||
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.DEPEND)) {
|
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.DEPEND)) {
|
||||||
dependencies.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link()));
|
dependencies.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link(), entry.name()));
|
||||||
}
|
}
|
||||||
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.BREAK)) {
|
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.BREAK)) {
|
||||||
breakings.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link()));
|
breakings.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link(), entry.name()));
|
||||||
}
|
}
|
||||||
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.SUGGEST)) {
|
for (ModDependencies.Entry entry : props.dependencies().getForType(ModDependencies.Type.SUGGEST)) {
|
||||||
suggests.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link()));
|
suggests.put(entry.id(), new DependencyEntry(entry.range(), props, entry.link(), entry.name()));
|
||||||
}
|
}
|
||||||
props.dependencies().getForType(ModDependencies.Type.PROVIDE).forEach(e -> {
|
props.dependencies().getForType(ModDependencies.Type.PROVIDE).forEach(e -> {
|
||||||
try {
|
try {
|
||||||
|
@ -115,7 +115,7 @@ public class ModDependencyResolver {
|
||||||
if (!(presentMods.containsKey(s) && value.range.versionMatches(presentOrProvided.get(s)))) { // The dependency isn't fulfilled by any present mods
|
if (!(presentMods.containsKey(s) && value.range.versionMatches(presentOrProvided.get(s)))) { // The dependency isn't fulfilled by any present mods
|
||||||
if (!(provides.containsKey(s) && value.range.versionMatches(provides.get(s).version()))) { // The dependency also isn't fulfilled by any provided mods
|
if (!(provides.containsKey(s) && value.range.versionMatches(provides.get(s).version()))) { // The dependency also isn't fulfilled by any provided mods
|
||||||
if (value.origin.extensions().getOrDefault(BuiltinExtensions.LOADING_TYPE, "required").equals("required")) {
|
if (value.origin.extensions().getOrDefault(BuiltinExtensions.LOADING_TYPE, "required").equals("required")) {
|
||||||
unfulfilled.add(new UnfulfilledDependencyException.Entry(value.origin, s, value.range, presentOrProvided.get(s), value.link()));
|
unfulfilled.add(new UnfulfilledDependencyException.Entry(value.origin, s, value.range, presentOrProvided.get(s), value.link(), value.name()));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ public class ModDependencyResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Entry(ModProperties source, String dependency, VersionRange range, SemVer presentVersion,
|
public record Entry(ModProperties source, String dependency, VersionRange range, SemVer presentVersion,
|
||||||
@Nullable String link) {
|
@Nullable String link, String dependencyName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,10 +207,10 @@ public class ModDependencyResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record DependencyEntry(VersionRange range, ModProperties origin, String link) {
|
private record DependencyEntry(VersionRange range, ModProperties origin, String link, String name) {
|
||||||
|
|
||||||
public DependencyEntry(String range, ModProperties origin, @Nullable String link) throws ResolverException {
|
public DependencyEntry(String range, ModProperties origin, @Nullable String link, @Nullable String name) throws ResolverException {
|
||||||
this(VersionRange.parse(range), origin, link);
|
this(VersionRange.parse(range), origin, link, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,25 +76,25 @@ public class ModPropertiesReader {
|
||||||
Collection<ModDependencies.Entry> depends = new HashSet<>();
|
Collection<ModDependencies.Entry> depends = new HashSet<>();
|
||||||
List<UnmodifiableConfig> dependsConfig = config.get("frog.dependencies.depends");
|
List<UnmodifiableConfig> dependsConfig = config.get("frog.dependencies.depends");
|
||||||
if (dependsConfig != null) {
|
if (dependsConfig != null) {
|
||||||
dependsConfig.forEach(entry -> depends.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"))));
|
dependsConfig.forEach(entry -> depends.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"), entry.get("name"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ModDependencies.Entry> breaks = new HashSet<>();
|
Collection<ModDependencies.Entry> breaks = new HashSet<>();
|
||||||
List<UnmodifiableConfig> breaksConfig = config.get("frog.dependencies.breaks");
|
List<UnmodifiableConfig> breaksConfig = config.get("frog.dependencies.breaks");
|
||||||
if (breaksConfig != null) {
|
if (breaksConfig != null) {
|
||||||
breaksConfig.forEach(entry -> breaks.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"))));
|
breaksConfig.forEach(entry -> breaks.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"), entry.get("name"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ModDependencies.Entry> suggests = new HashSet<>();
|
Collection<ModDependencies.Entry> suggests = new HashSet<>();
|
||||||
List<UnmodifiableConfig> suggestsConfig = config.get("frog.dependencies.suggests");
|
List<UnmodifiableConfig> suggestsConfig = config.get("frog.dependencies.suggests");
|
||||||
if (suggestsConfig != null) {
|
if (suggestsConfig != null) {
|
||||||
suggestsConfig.forEach(entry -> suggests.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"))));
|
suggestsConfig.forEach(entry -> suggests.add(new ModDependencies.Entry(entry.get("id"), entry.get("versions"), entry.get("link"), entry.get("name"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ModDependencies.Entry> provides = new HashSet<>();
|
Collection<ModDependencies.Entry> provides = new HashSet<>();
|
||||||
List<UnmodifiableConfig> providesConfig = config.get("frog.dependencies.provides");
|
List<UnmodifiableConfig> providesConfig = config.get("frog.dependencies.provides");
|
||||||
if (providesConfig != null) {
|
if (providesConfig != null) {
|
||||||
providesConfig.forEach(entry -> provides.add(new ModDependencies.Entry(entry.get("id"), entry.get("version"), entry.get("link"))));
|
providesConfig.forEach(entry -> provides.add(new ModDependencies.Entry(entry.get("id"), entry.get("version"), entry.get("link"), entry.get("name"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
UnmodifiableConfig extensionsConfig = config.get("frog.extensions");
|
UnmodifiableConfig extensionsConfig = config.get("frog.extensions");
|
||||||
|
|
Loading…
Reference in a new issue