From 55bc0846aee0ff018fcb87ef4802f2767dba9d49 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 20 Oct 2022 20:01:43 -0400 Subject: [PATCH] Better mod state errors --- core/assets/bundles/bundle.properties | 14 +++- core/src/mindustry/ui/dialogs/ModsDialog.java | 67 +++++++++++++------ gradle.properties | 2 +- 3 files changed, 59 insertions(+), 24 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 833c4707f7..0e62dbfd4c 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -144,11 +144,19 @@ mod.multiplayer.compatible = [gray]Multiplayer Compatible mod.disable = Disable mod.content = Content: mod.delete.error = Unable to delete mod. File may be in use. -mod.requiresversion = [red]Requires min game version: [accent]{0} -mod.outdatedv7 = [red]Incompatible with V7 (no minGameVersion: 136) + +mod.incompatiblegame = [red]Outdated Game +mod.incompatiblemod = [red]Incompatible mod.blacklisted = [red]Unsupported -mod.missingdependencies = [red]Missing dependencies: {0} +mod.unmetdependencies = [red]Unmet Dependencies mod.erroredcontent = [red]Content Errors + +mod.requiresversion.details = Requires game version: [accent]{0}[]\nYour game is outdated. This mod requires a newer version of the game (possibly a beta/alpha release) to function. +mod.outdatedv7.details = This mod is incompatible with the latest version of the game. The author must update it, and add [accent]minGameVersion: 136[] to its [accent]mod.json[] file. +mod.blacklisted.details = This mod has been manually blacklisted for causing crashes or other issues with this version of the game. Do not use it. +mod.missingdependencies.details = This mod is missing dependencies: {0} +mod.erroredcontent.details = This game caused errors when loading. Ask the mod author to fix them. + mod.errors = Errors have occurred loading content. mod.noerrorplay = [red]You have mods with errors.[] Either disable the affected mods or fix the errors before playing. mod.nowdisabled = [red]Mod '{0}' is missing dependencies:[accent] {1}\n[lightgray]These mods need to be downloaded first.\nThis mod will be automatically disabled. diff --git a/core/src/mindustry/ui/dialogs/ModsDialog.java b/core/src/mindustry/ui/dialogs/ModsDialog.java index d504281dca..f692da9d02 100644 --- a/core/src/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/mindustry/ui/dialogs/ModsDialog.java @@ -228,6 +228,11 @@ public class ModsDialog extends BaseDialog{ t.top().left(); t.margin(12f); + String stateDetails = getStateDetails(item); + if(stateDetails != null){ + t.addListener(new Tooltip(f -> f.background(Styles.black8).margin(4f).add(stateDetails).growX().width(400f).wrap())); + } + t.defaults().left().top(); t.table(title1 -> { title1.left(); @@ -254,26 +259,9 @@ public class ModsDialog extends BaseDialog{ text.row(); - String tooltip = null; - - if(item.isOutdated()){ - text.labelWrap("@mod.outdatedv7").growX(); - text.row(); - }else if(item.isBlacklisted()){ - text.labelWrap("@mod.blacklisted").growX(); - text.row(); - }else if(!item.isSupported()){ - text.labelWrap(Core.bundle.format("mod.requiresversion", item.meta.minGameVersion)).growX(); - text.row(); - }else if(item.hasUnmetDependencies()){ - text.labelWrap(Core.bundle.format("mod.missingdependencies", item.missingDependencies.toString(", "))).growX(); - t.row(); - }else if(item.hasContentErrors()){ - text.labelWrap("@mod.erroredcontent").growX(); - text.row(); - }else if(item.meta.hidden){ - text.labelWrap("@mod.multiplayer.compatible").growX(); - text.row(); + String state = getStateText(item); + if(state != null){ + text.labelWrap(state).growX().row(); } }).top().growX(); @@ -334,6 +322,38 @@ public class ModsDialog extends BaseDialog{ cont.row(); } + private @Nullable String getStateText(LoadedMod item){ + if(item.isOutdated()){ + return "@mod.incompatiblemod"; + }else if(item.isBlacklisted()){ + return "@mod.blacklisted"; + }else if(!item.isSupported()){ + return "@mod.incompatiblegame"; + }else if(item.hasUnmetDependencies()){ + return "@mod.unmetdependencies"; + }else if(item.hasContentErrors()){ + return "@mod.erroredcontent"; + }else if(item.meta.hidden){ + return "@mod.multiplayer.compatible"; + } + return null; + } + + private @Nullable String getStateDetails(LoadedMod item){ + if(item.isOutdated()){ + return "@mod.outdatedv7.details"; + }else if(item.isBlacklisted()){ + return "@mod.blacklisted.details"; + }else if(!item.isSupported()){ + return Core.bundle.format("mod.requiresversion.details", item.meta.minGameVersion); + }else if(item.hasUnmetDependencies()){ + return Core.bundle.format("mod.missingdependencies.details", item.missingDependencies.toString(", ")); + }else if(item.hasContentErrors()){ + return "@mod.erroredcontent.details"; + } + return null; + } + private void reload(){ ui.showInfoOnHidden("@mods.reloadexit", () -> { Log.info("Exiting to reload mods."); @@ -378,6 +398,13 @@ public class ModsDialog extends BaseDialog{ desc.row(); } + String state = getStateDetails(mod); + + if(state != null){ + desc.add("@mod.disabled").padTop(13f).padBottom(-6f).row(); + desc.add(state).growX().wrap().row(); + } + }).width(400f); Seq all = Seq.with(content.getContentMap()).flatten().select(c -> c.minfo.mod == mod && c instanceof UnlockableContent).as(); diff --git a/gradle.properties b/gradle.properties index 2c5768409d..443cbf281e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=8793e01874 +archash=5a1cbb8b59