Mod content lists
This commit is contained in:
@@ -119,6 +119,7 @@ mods.none = [lightgray]No mods found!
|
|||||||
mods.guide = Modding Guide
|
mods.guide = Modding Guide
|
||||||
mods.report = Report Bug
|
mods.report = Report Bug
|
||||||
mods.openfolder = Open Folder
|
mods.openfolder = Open Folder
|
||||||
|
mods.viewcontent = View Content
|
||||||
mods.reload = Reload
|
mods.reload = Reload
|
||||||
mods.reloadexit = The game will now exit, to reload mods.
|
mods.reloadexit = The game will now exit, to reload mods.
|
||||||
mod.display = [gray]Mod:[orange] {0}
|
mod.display = [gray]Mod:[orange] {0}
|
||||||
|
|||||||
@@ -645,6 +645,7 @@ public class Mods implements Loadable{
|
|||||||
var other = mods.find(m -> m.name.equals(baseName));
|
var other = mods.find(m -> m.name.equals(baseName));
|
||||||
|
|
||||||
if(other != null){
|
if(other != null){
|
||||||
|
//steam mods can't really be deleted, they need to be unsubscribed
|
||||||
if(overwrite && !other.hasSteamID()){
|
if(overwrite && !other.hasSteamID()){
|
||||||
//close zip file
|
//close zip file
|
||||||
if(other.root instanceof ZipFi){
|
if(other.root instanceof ZipFi){
|
||||||
@@ -674,7 +675,7 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//make sure the main class exists before loading it; if it doesn't just don't put it there
|
//make sure the main class exists before loading it; if it doesn't just don't put it there
|
||||||
if(mainFile.exists() && Core.settings.getBool("mod-" + baseName + "-enabled", true)){
|
if(mainFile.exists() && Core.settings.getBool("mod-" + baseName + "-enabled", true) && Version.isAtLeast(meta.minGameVersion) && meta.getMinMajor() >= 105){
|
||||||
//mobile versions don't support class mods
|
//mobile versions don't support class mods
|
||||||
if(ios){
|
if(ios){
|
||||||
throw new IllegalArgumentException("Java class mods are not supported on iOS.");
|
throw new IllegalArgumentException("Java class mods are not supported on iOS.");
|
||||||
@@ -784,9 +785,7 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getMinMajor(){
|
public int getMinMajor(){
|
||||||
String ver = meta.minGameVersion == null ? "0" : meta.minGameVersion;
|
return meta.getMinMajor();
|
||||||
int dot = ver.indexOf(".");
|
|
||||||
return dot != -1 ? Strings.parseInt(ver.substring(0, dot), 0) : Strings.parseInt(ver, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -870,7 +869,7 @@ public class Mods implements Loadable{
|
|||||||
public boolean hidden;
|
public boolean hidden;
|
||||||
|
|
||||||
public String displayName(){
|
public String displayName(){
|
||||||
return displayName == null ? name : displayName;
|
return displayName == null ? Strings.stripColors(name) : displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//removes all colors
|
//removes all colors
|
||||||
@@ -880,6 +879,12 @@ public class Mods implements Loadable{
|
|||||||
if(description != null) description = Strings.stripColors(description);
|
if(description != null) description = Strings.stripColors(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinMajor(){
|
||||||
|
String ver = minGameVersion == null ? "0" : minGameVersion;
|
||||||
|
int dot = ver.indexOf(".");
|
||||||
|
return dot != -1 ? Strings.parseInt(ver.substring(0, dot), 0) : Strings.parseInt(ver, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ModMeta{" +
|
return "ModMeta{" +
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.*;
|
|
||||||
import arc.scene.ui.TextButton.*;
|
import arc.scene.ui.TextButton.*;
|
||||||
|
import arc.scene.ui.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
@@ -17,6 +17,7 @@ import arc.util.serialization.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.mod.*;
|
import mindustry.mod.*;
|
||||||
@@ -33,6 +34,7 @@ public class ModsDialog extends BaseDialog{
|
|||||||
private String searchtxt = "";
|
private String searchtxt = "";
|
||||||
private @Nullable Seq<ModListing> modList;
|
private @Nullable Seq<ModListing> modList;
|
||||||
private boolean orderDate = true;
|
private boolean orderDate = true;
|
||||||
|
private BaseDialog currentContent;
|
||||||
|
|
||||||
public ModsDialog(){
|
public ModsDialog(){
|
||||||
super("@mods");
|
super("@mods");
|
||||||
@@ -45,6 +47,13 @@ public class ModsDialog extends BaseDialog{
|
|||||||
onResize(this::setup);
|
onResize(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.on(ResizeEvent.class, event -> {
|
||||||
|
if(currentContent != null){
|
||||||
|
currentContent.hide();
|
||||||
|
currentContent = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
hidden(() -> {
|
hidden(() -> {
|
||||||
if(mods.requiresReload()){
|
if(mods.requiresReload()){
|
||||||
reload();
|
reload();
|
||||||
@@ -162,7 +171,6 @@ public class ModsDialog extends BaseDialog{
|
|||||||
ui.showTextInput("@mod.import.github", "", 64, Core.settings.getString("lastmod", ""), text -> {
|
ui.showTextInput("@mod.import.github", "", 64, Core.settings.getString("lastmod", ""), text -> {
|
||||||
Core.settings.put("lastmod", text);
|
Core.settings.put("lastmod", text);
|
||||||
|
|
||||||
ui.loadfrag.show();
|
|
||||||
githubImportMod(text);
|
githubImportMod(text);
|
||||||
});
|
});
|
||||||
}).margin(12f);
|
}).margin(12f);
|
||||||
@@ -205,7 +213,7 @@ public class ModsDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(ModListing mod : listings){
|
for(ModListing mod : listings){
|
||||||
if(mod.hasJava || !searchtxt.isEmpty() && !mod.repo.toLowerCase().contains(searchtxt.toLowerCase()) || (Vars.ios && mod.hasScripts)) continue;
|
if((mod.hasJava && Vars.ios) || !searchtxt.isEmpty() && !mod.repo.toLowerCase().contains(searchtxt.toLowerCase()) || (Vars.ios && mod.hasScripts)) continue;
|
||||||
|
|
||||||
tablebrow.button(btn -> {
|
tablebrow.button(btn -> {
|
||||||
btn.top().left();
|
btn.top().left();
|
||||||
@@ -366,7 +374,10 @@ public class ModsDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(mod.getRepo() != null){
|
if(mod.getRepo() != null){
|
||||||
|
boolean showImport = !mod.hasSteamID();
|
||||||
dialog.buttons.button("@mods.github.open", Icon.link, () -> Core.app.openURI("https://github.com/" + mod.getRepo()));
|
dialog.buttons.button("@mods.github.open", Icon.link, () -> Core.app.openURI("https://github.com/" + mod.getRepo()));
|
||||||
|
if(mobile && showImport) dialog.buttons.row();
|
||||||
|
if(showImport) dialog.buttons.button("@mods.browser.reinstall", Icon.download, () -> githubImportMod(mod.getRepo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO improve this menu later
|
//TODO improve this menu later
|
||||||
@@ -393,12 +404,12 @@ public class ModsDialog extends BaseDialog{
|
|||||||
|
|
||||||
}).width(400f);
|
}).width(400f);
|
||||||
|
|
||||||
//TODO maybe enable later
|
Seq<UnlockableContent> all = Seq.with(content.getContentMap()).<Content>flatten().select(c -> c.minfo.mod == mod && c instanceof UnlockableContent).as();
|
||||||
if(false){
|
if(all.any()){
|
||||||
Seq<UnlockableContent> all = Seq.with(content.getContentMap()).<Content>flatten().select(c -> c.minfo.mod == mod && c instanceof UnlockableContent).as();
|
dialog.cont.row();
|
||||||
if(all.any()){
|
dialog.cont.button( "@mods.viewcontent", Icon.book, () -> {
|
||||||
dialog.cont.row();
|
BaseDialog d = new BaseDialog(mod.meta.displayName());
|
||||||
dialog.cont.pane(cs -> {
|
d.cont.pane(cs -> {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(UnlockableContent c : all){
|
for(UnlockableContent c : all){
|
||||||
cs.button(new TextureRegionDrawable(c.icon(Cicon.medium)), Styles.cleari, Cicon.medium.size, () -> {
|
cs.button(new TextureRegionDrawable(c.icon(Cicon.medium)), Styles.cleari, Cicon.medium.size, () -> {
|
||||||
@@ -406,12 +417,16 @@ public class ModsDialog extends BaseDialog{
|
|||||||
}).size(50f).with(im -> {
|
}).size(50f).with(im -> {
|
||||||
var click = im.getClickListener();
|
var click = im.getClickListener();
|
||||||
im.update(() -> im.getImage().color.lerp(!click.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta));
|
im.update(() -> im.getImage().color.lerp(!click.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta));
|
||||||
});
|
|
||||||
|
|
||||||
if(++i % 8 == 0) cs.row();
|
}).tooltip(c.localizedName);
|
||||||
|
|
||||||
|
if(++i % Math.min(Core.graphics.getWidth() / 70, 14) == 0) cs.row();
|
||||||
}
|
}
|
||||||
}).growX().minHeight(60f);
|
}).grow();
|
||||||
}
|
d.addCloseButton();
|
||||||
|
d.show();
|
||||||
|
currentContent = d;
|
||||||
|
}).size(300, 50).pad(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
@@ -438,6 +453,7 @@ public class ModsDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void githubImportMod(String name){
|
private void githubImportMod(String name){
|
||||||
|
ui.loadfrag.show();
|
||||||
Core.net.httpGet("https://api.github.com/repos/" + name, res -> {
|
Core.net.httpGet("https://api.github.com/repos/" + name, res -> {
|
||||||
if(checkError(res)){
|
if(checkError(res)){
|
||||||
String mainBranch = Jval.read(res.getResultAsString()).getString("default_branch");
|
String mainBranch = Jval.read(res.getResultAsString()).getString("default_branch");
|
||||||
|
|||||||
Reference in New Issue
Block a user