mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 02:37:12 +07:00
Added mod displayName property [for color tags, etc]
This commit is contained in:
parent
6588fc6581
commit
803719b216
@ -118,6 +118,8 @@ public class Vars implements Loadable{
|
||||
public static boolean headless;
|
||||
/** whether steam is enabled for this game */
|
||||
public static boolean steam;
|
||||
/** whether typing into the console is enabled - developers only */
|
||||
public static boolean enableConsole = false;
|
||||
/** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */
|
||||
public static FileHandle dataDirectory;
|
||||
/** data subdirectory used for screenshots */
|
||||
|
@ -738,10 +738,14 @@ public class Mods implements Loadable{
|
||||
|
||||
/** Plugin metadata information.*/
|
||||
public static class ModMeta{
|
||||
public String name, author, description, version, main, minGameVersion;
|
||||
public String name, displayName, author, description, version, main, minGameVersion;
|
||||
public Array<String> dependencies = Array.with();
|
||||
/** Hidden mods are only server-side or client-side, and do not support adding new content. */
|
||||
public boolean hidden;
|
||||
|
||||
public String displayName(){
|
||||
return displayName == null ? name : displayName;
|
||||
}
|
||||
}
|
||||
|
||||
/** Thrown when an error occurs while loading a mod.*/
|
||||
|
@ -143,7 +143,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
button.row();
|
||||
button.stack(new Image(map.safeTexture()).setScaling(Scaling.fit), new BorderImage(map.safeTexture()).setScaling(Scaling.fit)).size(mapsize - 20f);
|
||||
button.row();
|
||||
button.add(map.custom ? "$custom" : map.workshop ? "$workshop" : map.mod != null ? "[lightgray]" + map.mod.meta.name : "$builtin").color(Color.gray).padTop(3);
|
||||
button.add(map.custom ? "$custom" : map.workshop ? "$workshop" : map.mod != null ? "[lightgray]" + map.mod.meta.displayName() : "$builtin").color(Color.gray).padTop(3);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class ModsDialog extends FloatingDialog{
|
||||
t.margin(14f).left();
|
||||
t.table(title -> {
|
||||
title.left();
|
||||
title.add("[accent]" + mod.meta.name + "[lightgray] v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + "")).width(200f).wrap();
|
||||
title.add("[accent]" + mod.meta.displayName() + "[lightgray] v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + "")).width(200f).wrap();
|
||||
title.add().growX();
|
||||
|
||||
title.addImageTextButton(mod.enabled() ? "$mod.disable" : "$mod.enable", mod.enabled() ? Icon.arrowDownSmall : Icon.arrowUpSmall, Styles.cleart, () -> {
|
||||
|
@ -100,7 +100,7 @@ public class SchematicsDialog extends FloatingDialog{
|
||||
}else{
|
||||
buttons.addImageButton(Icon.trash16Small, style, () -> {
|
||||
if(s.mod != null){
|
||||
ui.showInfo(Core.bundle.format("mod.item.remove", s.mod.meta.name));
|
||||
ui.showInfo(Core.bundle.format("mod.item.remove", s.mod.meta.displayName()));
|
||||
}else{
|
||||
ui.showConfirm("$confirm", "$schematic.delete.confirm", () -> {
|
||||
schematics.remove(s);
|
||||
|
@ -47,7 +47,7 @@ public class ScriptConsoleFragment extends Table{
|
||||
visible(() -> {
|
||||
if(input.keyTap(Binding.console) && !Vars.net.client() && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null)){
|
||||
shown = !shown;
|
||||
if(shown && !open){
|
||||
if(shown && !open && enableConsole){
|
||||
toggle();
|
||||
}
|
||||
clearChatInput();
|
||||
@ -57,7 +57,7 @@ public class ScriptConsoleFragment extends Table{
|
||||
});
|
||||
|
||||
update(() -> {
|
||||
if(input.keyTap(Binding.chat) && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null)){
|
||||
if(input.keyTap(Binding.chat) && enableConsole && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null)){
|
||||
toggle();
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MindustryServer implements ApplicationListener{
|
||||
private String[] args;
|
||||
|
||||
public MindustryServer(String[] args){
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
Core.settings.setDataDirectory(Core.files.local("config"));
|
||||
loadLocales = false;
|
||||
headless = true;
|
||||
|
||||
FileHandle plugins = Core.settings.getDataDirectory().child("plugins");
|
||||
if(plugins.isDirectory() && plugins.list().length > 0 && !plugins.sibling("mods").exists()){
|
||||
Log.warn("[IMPORTANT NOTICE] &lrPlugins have been detected.&ly Automatically moving all contents of the plugin folder into the 'mods' folder. The original folder will not be removed; please do so manually.");
|
||||
plugins.sibling("mods").mkdirs();
|
||||
for(FileHandle file : plugins.list()){
|
||||
file.copyTo(plugins.sibling("mods"));
|
||||
}
|
||||
}
|
||||
|
||||
Vars.loadSettings();
|
||||
Vars.init();
|
||||
content.createBaseContent();
|
||||
mods.loadScripts();
|
||||
content.createModContent();
|
||||
content.init();
|
||||
|
||||
Core.app.addListener(logic = new Logic());
|
||||
Core.app.addListener(netServer = new NetServer());
|
||||
Core.app.addListener(new ServerControl(args));
|
||||
|
||||
mods.each(Mod::init);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -336,7 +336,7 @@ public class ServerControl implements ApplicationListener{
|
||||
if(!mods.all().isEmpty()){
|
||||
info("Mods:");
|
||||
for(LoadedMod mod : mods.all()){
|
||||
info(" &ly{0} &lcv{1}", mod.meta.name, mod.meta.version);
|
||||
info(" &ly{0} &lcv{1}", mod.meta.displayName(), mod.meta.version);
|
||||
}
|
||||
}else{
|
||||
info("No mods found.");
|
||||
@ -347,7 +347,8 @@ public class ServerControl implements ApplicationListener{
|
||||
handler.register("mod", "<name...>", "Display information about a loaded plugin.", arg -> {
|
||||
LoadedMod mod = mods.all().find(p -> p.meta.name.equalsIgnoreCase(arg[0]));
|
||||
if(mod != null){
|
||||
info("Name: &ly{0}", mod.meta.name);
|
||||
info("Name: &ly{0}", mod.meta.displayName());
|
||||
info("Internal Name: &ly{0}", mod.name);
|
||||
info("Version: &ly{0}", mod.meta.version);
|
||||
info("Author: &ly{0}", mod.meta.author);
|
||||
info("Path: &ly{0}", mod.file.path());
|
||||
|
@ -1,22 +1,58 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.backends.headless.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.platform;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ServerLauncher{
|
||||
public class ServerLauncher implements ApplicationListener{
|
||||
static String[] args;
|
||||
|
||||
public static void main(String[] args){
|
||||
try{
|
||||
ServerLauncher.args = args;
|
||||
Vars.platform = new Platform(){};
|
||||
Vars.net = new Net(platform.getNet());
|
||||
new HeadlessApplication(new MindustryServer(args), null, throwable -> CrashSender.send(throwable, f -> {}));
|
||||
new HeadlessApplication(new ServerLauncher(), null, throwable -> CrashSender.send(throwable, f -> {}));
|
||||
}catch(Throwable t){
|
||||
CrashSender.send(t, f -> {});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
Core.settings.setDataDirectory(Core.files.local("config"));
|
||||
loadLocales = false;
|
||||
headless = true;
|
||||
|
||||
FileHandle plugins = Core.settings.getDataDirectory().child("plugins");
|
||||
if(plugins.isDirectory() && plugins.list().length > 0 && !plugins.sibling("mods").exists()){
|
||||
Log.warn("[IMPORTANT NOTICE] &lrPlugins have been detected.&ly Automatically moving all contents of the plugin folder into the 'mods' folder. The original folder will not be removed; please do so manually.");
|
||||
plugins.sibling("mods").mkdirs();
|
||||
for(FileHandle file : plugins.list()){
|
||||
file.copyTo(plugins.sibling("mods"));
|
||||
}
|
||||
}
|
||||
|
||||
Vars.loadSettings();
|
||||
Vars.init();
|
||||
content.createBaseContent();
|
||||
mods.loadScripts();
|
||||
content.createModContent();
|
||||
content.init();
|
||||
|
||||
Core.app.addListener(logic = new Logic());
|
||||
Core.app.addListener(netServer = new NetServer());
|
||||
Core.app.addListener(new ServerControl(args));
|
||||
|
||||
mods.each(Mod::init);
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ public class ScriptStubGenerator{
|
||||
Array<String> nameBlacklist = Array.with("ClientLauncher", "NetClient", "NetServer", "ClassAccess");
|
||||
Array<Class<?>> whitelist = Array.with(Draw.class, Fill.class, Lines.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class, System.class, PrintStream.class, AtlasRegion.class, String.class, Mathf.class, Angles.class, Color.class);
|
||||
Array<String> nopackage = Array.with("io.anuke.arc.func", "java.lang", "java");
|
||||
Array<String> imported = Array.with("io.anuke.mindustry.type", "io.anuke.mindustry.world");
|
||||
|
||||
String fileTemplate = "package io.anuke.mindustry.mod;\n" +
|
||||
"\n" +
|
||||
|
Loading…
Reference in New Issue
Block a user