Cleanup / Added server support for scripting

This commit is contained in:
Anuken
2019-12-08 11:00:59 -05:00
parent 07fb5aa88e
commit 9f4d44f0f3
22 changed files with 32 additions and 64 deletions

View File

@@ -42,11 +42,6 @@ public abstract class UnlockableContent extends MappableContent{
return cicons[icon.ordinal()];
}
/** Returns the localized name of this content. */
public abstract String localizedName();
//public abstract TextureRegion getContentIcon();
/** This should show all necessary info about this content in the specified table. */
public abstract void displayInfo(Table table);

View File

@@ -392,7 +392,7 @@ public class Mods implements Loadable{
if(mod.root.child("scripts").exists()){
content.setCurrentMod(mod);
mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js"));
Log.info("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
for(FileHandle file : mod.scripts){
try{
@@ -415,7 +415,7 @@ public class Mods implements Loadable{
content.setCurrentMod(null);
}
Log.info("Time to initialize modded scripts: {0}", Time.elapsed());
Log.debug("Time to initialize modded scripts: {0}", Time.elapsed());
}
/** Creates all the content found in mod files. */

View File

@@ -26,7 +26,7 @@ public class Scripts implements Disposable{
wrapper = Core.files.internal("scripts/wrapper.js").readString();
run(Core.files.internal("scripts/global.js").readString(), "global.js");
Log.info("Time to load script engine: {0}", Time.elapsed());
Log.debug("Time to load script engine: {0}", Time.elapsed());
}
public String runConsole(String text){
@@ -52,7 +52,7 @@ public class Scripts implements Disposable{
public void log(String source, String message){
Log.info("[{0}]: {1}", source, message);
logBuffer.add("[accent][" + source + "]:[] " + message);
if(!headless & ui.scriptfrag != null){
if(!headless && ui.scriptfrag != null){
onLoad();
}
}

View File

@@ -1,10 +1,9 @@
package io.anuke.mindustry.type;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.ctype.UnlockableContent;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.world.blocks.*;
@@ -50,14 +49,9 @@ public class Item extends UnlockableContent{
ContentDisplay.displayItem(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("item." + this.name + ".name");
}
@Override
public String toString(){
return localizedName();
return localizedName;
}
@Override

View File

@@ -1,11 +1,10 @@
package io.anuke.mindustry.type;
import io.anuke.arc.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.ArcAnnotate.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.ctype.UnlockableContent;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.ui.*;
public class Liquid extends UnlockableContent{
@@ -51,14 +50,9 @@ public class Liquid extends UnlockableContent{
ContentDisplay.displayLiquid(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("liquid." + this.name + ".name");
}
@Override
public String toString(){
return localizedName();
return localizedName;
}
@Override

View File

@@ -45,10 +45,6 @@ public class Mech extends UnlockableContent{
this(name, false);
}
public String localizedName(){
return Core.bundle.get("mech." + name + ".name");
}
public void updateAlt(Player player){
}
@@ -112,6 +108,6 @@ public class Mech extends UnlockableContent{
@Override
public String toString(){
return localizedName();
return localizedName;
}
}

View File

@@ -64,11 +64,6 @@ public class UnitType extends UnlockableContent{
ContentDisplay.displayUnit(table, this);
}
@Override
public String localizedName(){
return Core.bundle.get("unit." + name + ".name");
}
@Override
public void load(){
weapon.load();

View File

@@ -205,11 +205,6 @@ public class Zone extends UnlockableContent{
public void displayInfo(Table table){
}
@Override
public String localizedName(){
return Core.bundle.get("zone." + name + ".name");
}
@Override
public ContentType getContentType(){
return ContentType.zone;

View File

@@ -66,7 +66,7 @@ public class ContentDisplay{
table.table(title -> {
title.addImage(item.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + item.localizedName()).padLeft(5);
title.add("[accent]" + item.localizedName).padLeft(5);
});
table.row();
@@ -100,7 +100,7 @@ public class ContentDisplay{
table.table(title -> {
title.addImage(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + liquid.localizedName()).padLeft(5);
title.add("[accent]" + liquid.localizedName).padLeft(5);
});
table.row();
@@ -134,7 +134,7 @@ public class ContentDisplay{
public static void displayMech(Table table, Mech mech){
table.table(title -> {
title.addImage(mech.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + mech.localizedName()).padLeft(5);
title.add("[accent]" + mech.localizedName).padLeft(5);
});
table.left().defaults().left();
@@ -182,7 +182,7 @@ public class ContentDisplay{
public static void displayUnit(Table table, UnitType unit){
table.table(title -> {
title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + unit.localizedName()).padLeft(5);
title.add("[accent]" + unit.localizedName).padLeft(5);
});
table.row();

View File

@@ -15,7 +15,7 @@ public class ItemDisplay extends Table{
public ItemDisplay(Item item, int amount, boolean showName){
add(new ItemImage(new ItemStack(item, amount))).size(8 * 4).padRight(amount > 99 ? 12 : 0);
if(showName) add(item.localizedName()).padLeft(4 + amount > 99 ? 4 : 0);
if(showName) add(item.localizedName).padLeft(4 + amount > 99 ? 4 : 0);
this.item = item;
this.amount = amount;

View File

@@ -29,7 +29,7 @@ public class ItemsDisplay extends Table{
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format(item)).left();
t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName()).color(Color.lightGray).left();
t.add(item.localizedName).color(Color.lightGray).left();
t.row();
}
}

View File

@@ -33,6 +33,6 @@ public class LiquidDisplay extends Table{
add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.lightGray);
}
add(liquid.localizedName());
add(liquid.localizedName);
}
}

View File

@@ -66,7 +66,7 @@ public class DatabaseDialog extends FloatingDialog{
if(unlocked(unlock)){
image.clicked(() -> Vars.ui.content.show(unlock));
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName())));
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName)));
}
if((++count) % maxWidth == 0){

View File

@@ -155,7 +155,7 @@ public class DeployDialog extends FloatingDialog{
}).color(Color.darkGray).grow()));
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName), Styles.squaret, () -> {
control.saves.getZoneSlot().cautiousLoad(() -> {
hide();
ui.loadAnd(() -> {
@@ -232,7 +232,7 @@ public class DeployDialog extends FloatingDialog{
});
if(zone.unlocked() && !hidden(zone)){
button.labelWrap(zone.localizedName()).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center);
button.labelWrap(zone.localizedName).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center);
}else{
Cons<Element> flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {};
flasher.get(button.addImage(Icon.locked).get());

View File

@@ -337,7 +337,7 @@ public class TechTreeDialog extends FloatingDialog{
t.table(list -> {
list.left();
list.addImage(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
list.add(req.item.localizedName()).color(Color.lightGray);
list.add(req.item.localizedName).color(Color.lightGray);
list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount)
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet));
}).fillX().left();

View File

@@ -96,7 +96,7 @@ public class ZoneInfoDialog extends FloatingDialog{
}).growX();
}else{
cont.add(zone.localizedName()).color(Pal.accent).growX().center();
cont.add(zone.localizedName).color(Pal.accent).growX().center();
cont.row();
cont.addImage().color(Pal.accent).height(3).pad(6).growX();
cont.row();

View File

@@ -395,11 +395,6 @@ public class Block extends BlockStorage{
return sum / size / size;
}
@Override
public String localizedName(){
return localizedName;
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayBlock(table, this);
@@ -552,7 +547,7 @@ public class Block extends BlockStorage{
}else{
current = entity -> entity.liquids.current();
}
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName(),
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
() -> current.get(entity).barColor(), () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
}

View File

@@ -16,7 +16,7 @@ public class OreBlock extends OverlayFloor{
public OreBlock(Item ore){
super("ore-" + ore.name);
this.localizedName = ore.localizedName();
this.localizedName = ore.localizedName;
this.itemDrop = ore;
this.variants = 3;
this.color.set(ore.color);
@@ -29,7 +29,7 @@ public class OreBlock extends OverlayFloor{
}
public void setup(Item ore){
this.localizedName = ore.localizedName();
this.localizedName = ore.localizedName;
this.itemDrop = ore;
this.color.set(ore.color);
}
@@ -80,6 +80,6 @@ public class OreBlock extends OverlayFloor{
@Override
public String getDisplayName(Tile tile){
return itemDrop.localizedName();
return itemDrop.localizedName;
}
}

View File

@@ -191,7 +191,7 @@ public class Drill extends Block{
Item item = list.get(i);
table.addImage(Core.atlas.find(item.name + "1")).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
table.add(item.localizedName());
table.add(item.localizedName);
if(i != list.size - 1){
table.add("/").padLeft(5).padRight(5);
}

View File

@@ -29,7 +29,7 @@ public class AmmoListValue<T extends UnlockableContent> implements StatValue{
for(T t : map.keys()){
BulletType type = map.get(t);
table.addImage(icon(t)).size(3 * 8).padRight(4).right().top();
table.add(t.localizedName()).padRight(10).left().top();
table.add(t.localizedName).padRight(10).left().top();
table.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();

View File

@@ -33,7 +33,7 @@ public class BoosterListValue implements StatValue{
if(!filter.get(liquid)) continue;
c.addImage(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top();
c.add(liquid.localizedName()).padRight(10).left().top();
c.add(liquid.localizedName).padRight(10).left().top();
c.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();