diff --git a/README.md b/README.md index 5d53d84..21eeaf7 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ variables: powerProduction: n - AccelTurret - turret which have acceleration variables: speedUpPerShoot: n, maxAccel: n, cooldownSpeed: n - DrawTeam - drawer class. Draws -team sprite - -- ## NEW! - ColliderCrafter - basic GenericCrafter but it outputs items/liquids with specific chance. variables: produceChance: n (1=100%) - OverHeatTurret - Turret which overheats after some shoots. @@ -32,6 +30,9 @@ variables: effects: [], effectInterval: n, effectX: n, effectY: n variables: tilingVariants: n, tilingSize: n - AdjustableBeamNode - you can create infity nodes from beam node and change it angle variables: beamDirections: [[n,n]] + +- ## NEW! +- added cutscene thing world processor check examples folder for more information diff --git a/mod.hjson b/mod.hjson index 37e68e7..faa90c7 100644 --- a/mod.hjson +++ b/mod.hjson @@ -1,13 +1,10 @@ name: "hjsonpp" displayName: "hjson++" repo: "ItzCraft/hjsonpp" - -version: "1.12" -minGameVersion: 154 - +author: "ItzCraft +helpers: Photon_gravity, Sputnuc" main: "hjsonpp.HjsonPlusPlusMod" -java: true - -author: "Main author: ItzCraft. \nHelpers: Photon_gravity, Sputnuc, AnDashik." -description: "Adds some new additional classes to help hjson modders. \nNote: this a library. Not a playable mod." -subtitle: "Goodluck with modding!" +description: "Adds some new additional classes to help hjson modders. \nNote: this a library. Not playable mod." +version: 1.14 +subtitle: goodluck with modding! +minGameVersion: 157 \ No newline at end of file diff --git a/src/hjsonpp/HjsonPlusPlusMod.java b/src/hjsonpp/HjsonPlusPlusMod.java index 5cdd209..a3ba35b 100644 --- a/src/hjsonpp/HjsonPlusPlusMod.java +++ b/src/hjsonpp/HjsonPlusPlusMod.java @@ -1,5 +1,6 @@ package hjsonpp; +import hjsonpp.expand.wproc.*; import mindustry.mod.*; public class HjsonPlusPlusMod extends Mod{ @@ -21,4 +22,15 @@ public HjsonPlusPlusMod(){ ClassMap.classes.put("EffectWeapon", hjsonpp.expand.EffectWeapon.class); ClassMap.classes.put("CustomEffects", hjsonpp.expand.CustomEffects.class); } + + @Override + public void init(){ + super.init(); + CustomStyles.load(); + } + + @Override + public void loadContent(){ + HjsonppLogic.init(); + } } diff --git a/src/hjsonpp/expand/wproc/CustomStyles.java b/src/hjsonpp/expand/wproc/CustomStyles.java new file mode 100644 index 0000000..967c2ed --- /dev/null +++ b/src/hjsonpp/expand/wproc/CustomStyles.java @@ -0,0 +1,16 @@ +package hjsonpp.expand.wproc; + +import arc.scene.style.Drawable; +import arc.scene.style.TextureRegionDrawable; +import mindustry.gen.Tex; + +public class CustomStyles { + public static Drawable blackBackground; + + public CustomStyles(){} + + public static void load() { + final TextureRegionDrawable whiteui = (TextureRegionDrawable) Tex.whiteui; + blackBackground = whiteui.tint(0.0F, 0.0F, 0.0F, 1F); + } +} \ No newline at end of file diff --git a/src/hjsonpp/expand/wproc/CustomUI.java b/src/hjsonpp/expand/wproc/CustomUI.java new file mode 100644 index 0000000..bb0e007 --- /dev/null +++ b/src/hjsonpp/expand/wproc/CustomUI.java @@ -0,0 +1,84 @@ +package hjsonpp.expand.wproc; +import arc.Core; +import arc.graphics.Color; +import arc.scene.ui.layout.Table; +import arc.scene.actions.*; +import arc.scene.event.Touchable; +import arc.math.*; +import mindustry.core.UI; +import mindustry.gen.Tex; +import mindustry.ui.Styles; + +public class CustomUI extends UI{ + protected static void bordlessTextDialog(String text, String unitIcon, float duration, boolean useBundle){ + Table table = new Table(); + table.touchable = Touchable.disabled; + table.setFillParent(true); + table.actions(Actions.delay(duration * 0.8f), Actions.fadeOut(duration * 0.3f, Interp.fade), Actions.remove()); + table.bottom().table(Styles.black5, t -> t.margin(1).image(Core.atlas.find(unitIcon)).style(Styles.outlineLabel)).padLeft(-15f).padBottom(70f).size(65f, 80f); + if(useBundle){ + table.bottom().table(Styles.black5, t -> t.margin(10f).add(Core.bundle.get(text)).style(Styles.outlineLabel)).padRight(65f).padBottom(70f).size(Core.bundle.get(text).length() * 11.5f, 60f); + } + else{ + table.bottom().table(Styles.black5, t -> t.margin(10f).add(text).style(Styles.outlineLabel)).padRight(65f).padBottom(70f).size(text.length() * 11.5f, 60f); + } + Core.scene.add(table); + } + protected static void borderTextDialog(String text, String unitIcon, float duration, boolean useBundle){ + Table table = new Table(); + table.touchable = Touchable.disabled; + table.setFillParent(true); + table.actions( + Actions.delay(duration * 0.8f), + Actions.fadeOut(duration * 0.3f, Interp.fade), + Actions.remove() + ); + table.bottom().table(t -> { + t.background(Tex.whiteui); + t.setColor(Color.gray); + t.margin(1f); + + t.table(Styles.grayPanel, inner -> { + inner.margin(1f); + inner.image(Core.atlas.find(unitIcon)) + .style(Styles.outlineLabel); + }).size(63f, 78f); + }) + .padLeft(-15f) + .padBottom(70f); + String displayText = useBundle ? Core.bundle.get(text) : text; + float width = displayText.length() * 11.5f; + + table.bottom().table(t -> { + t.background(Tex.whiteui); + t.setColor(Color.gray); + t.margin(1f); + + t.table(Styles.grayPanel, inner -> { + inner.margin(10f); + inner.add(displayText).style(Styles.outlineLabel); + }).size(width - 2f, 58f); + }) + .padRight(65f) + .padBottom(70f); + + Core.scene.add(table); + } + public static void textDialog(String text, String unitIcon, float duration, boolean useBundle, String uiStyle, String nametag){ + switch (uiStyle){ + case "bordless" -> bordlessTextDialog(text, unitIcon, duration, useBundle); + + case "border" -> borderTextDialog(text, unitIcon, duration, useBundle); + + //case "nametag" -> nametagTextDialog(text, unitIcon, duration, useBundle, nametag); + }; + } + public static void blackScreen(float duration){ + Table table = new Table(); + table.touchable = Touchable.disabled; + table.setFillParent(true); + table.actions(Actions.delay(duration * 0.8f), Actions.fadeOut(duration * 0.3f, Interp.fade), Actions.remove()); + table.bottom().table(CustomStyles.blackBackground, t -> t.margin(1).image(Core.atlas.find("epsilon-black-screen")).style(Styles.outlineLabel)).size(2500f, 2500f); + Core.scene.add(table); + } +} diff --git a/src/hjsonpp/expand/wproc/DialogueStyles.java b/src/hjsonpp/expand/wproc/DialogueStyles.java new file mode 100644 index 0000000..cb4da21 --- /dev/null +++ b/src/hjsonpp/expand/wproc/DialogueStyles.java @@ -0,0 +1,21 @@ +package hjsonpp.expand.wproc; + +import arc.struct.ObjectMap; + +public enum DialogueStyles{ + bordless, + border; + //nametag + //unitless + + public static ObjectMap stylesMap = new ObjectMap<>(); + + static{ + stylesMap.put(bordless,"bordless"); + stylesMap.put(border, "border"); + /*stylesMap.put(nametag, "nametag"); + stylesMap.put(unitless, "unitless");*/ + } + + public static final DialogueStyles[] all = values(); +} \ No newline at end of file diff --git a/src/hjsonpp/expand/wproc/HjsonppLogic.java b/src/hjsonpp/expand/wproc/HjsonppLogic.java new file mode 100644 index 0000000..6748700 --- /dev/null +++ b/src/hjsonpp/expand/wproc/HjsonppLogic.java @@ -0,0 +1,17 @@ +package hjsonpp.expand.wproc; + +import arc.graphics.Color; +import hjsonpp.expand.wproc.statements.*; +import mindustry.gen.LogicIO; +import mindustry.logic.*; + +public class HjsonppLogic { + public static LCategory Hjsonpp; + + public static void init(){ + Hjsonpp = new LCategory("hjsonpp-category", Color.valueOf("5edb80")); + + LAssembler.customParsers.put("textdialog", TextDialog::new); + LogicIO.allStatements.addUnique(TextDialog::new); + } +} \ No newline at end of file diff --git a/src/hjsonpp/expand/wproc/instructions/TextDialogI.java b/src/hjsonpp/expand/wproc/instructions/TextDialogI.java new file mode 100644 index 0000000..9360dba --- /dev/null +++ b/src/hjsonpp/expand/wproc/instructions/TextDialogI.java @@ -0,0 +1,30 @@ +package hjsonpp.expand.wproc.instructions; + +import arc.util.Log; +import hjsonpp.expand.wproc.CustomUI; +import hjsonpp.expand.wproc.DialogueStyles; +import mindustry.logic.*; +import mindustry.type.UnitType; + +public class TextDialogI implements LExecutor.LInstruction{ + public LVar text, unitIconName, duration, useBundle, uiTemplate, nametag; + + public TextDialogI(LVar text, LVar unitIconName, LVar duration, LVar useBundle, LVar uiTemplate, LVar nametag){ + this.text = text; + this.unitIconName = unitIconName; + this.duration = duration; + this.useBundle = useBundle; + this.uiTemplate = uiTemplate; + this.nametag = nametag; + } + + public TextDialogI(){} + + @Override + public void run(LExecutor exec){ + Log.info(uiTemplate.obj()); + if(unitIconName.obj() instanceof UnitType icon && text.obj() instanceof String t){ + CustomUI.textDialog(t, icon.name, duration.numf(), useBundle.bool(), uiTemplate.obj().toString(), nametag.obj().toString()); + } + } +} \ No newline at end of file diff --git a/src/hjsonpp/expand/wproc/statements/TextDialog.java b/src/hjsonpp/expand/wproc/statements/TextDialog.java new file mode 100644 index 0000000..a08b9c8 --- /dev/null +++ b/src/hjsonpp/expand/wproc/statements/TextDialog.java @@ -0,0 +1,167 @@ +package hjsonpp.expand.wproc.statements; + +import arc.scene.style.TextureRegionDrawable; +import arc.scene.ui.TextField; +import arc.scene.ui.layout.Table; +import arc.util.Align; +import hjsonpp.expand.wproc.DialogueStyles; +import hjsonpp.expand.wproc.HjsonppLogic; +import hjsonpp.expand.wproc.instructions.TextDialogI; +import mindustry.Vars; +import mindustry.gen.Icon; +import mindustry.logic.*; +import mindustry.type.UnitType; +import mindustry.ui.Styles; + +import static mindustry.Vars.iconSmall; +import static mindustry.Vars.ui; + +public class TextDialog extends LStatement{ + public String text = ":3", unit = "@dagger"; + public String duration = "5"; + public String useBundles = "true"; + public String uiTemplate = "borderless"; + public String nametag = "dagger"; + + public TextDialog(String[] tokens){ + text = tokens[1]; + unit = tokens[2]; + duration = tokens[3]; + useBundles = tokens[4]; + uiTemplate = tokens[5]; + nametag = tokens[6]; + } + public TextDialog(){} + + @Override + public void build(Table table){ + table.add(" text "); + + fields(table, text, v -> text = v); + + table.add(" duration "); + + fields(table, duration, c -> duration = c); + + table.add(" use Bundles "); + + fields(table, useBundles, g -> useBundles = g); + + table.add(" UI template "); + + table.button(b -> { + b.label(() -> uiTemplate) + .growX() + .wrap() + .labelAlign(Align.center); + b.clicked(() -> showSelectTable(b, (t, hide) -> { + t.background(Styles.black6); + t.table(i -> { + i.left(); + int c = 0; + for(DialogueStyles style : DialogueStyles.values()){ + i.button(DialogueStyles.stylesMap.get(style), Styles.flatt, () -> { + uiTemplate = DialogueStyles.stylesMap.get(style); + hide.run(); + }).width(110f).height(40f); + if(++c % 2 == 0) i.row(); + } + }).pad(6f); + })); + }, Styles.logict, () -> {}).size(120f, 40f).padLeft(2).color(table.color); + switch (uiTemplate) { + case "bordless", "border" -> { + table.row(); + table.add(" unit ").marginBottom(5f); + + TextField field = field(table, unit, str -> unit = str).get(); + + table.button(b -> { + b.image(Icon.pencilSmall); + b.clicked(() -> showSelectTable(b, (t, hide) -> { + t.row(); + t.table(i -> { + i.left(); + int c = 0; + for (UnitType item : Vars.content.units()) { + if (!item.unlockedNow() || item.isHidden() || !item.logicControllable) continue; + i.button(new TextureRegionDrawable(item.uiIcon), Styles.flati, iconSmall, () -> { + unit = "@" + item.name; + field.setText(unit); + hide.run(); + }).size(40f); + + if (++c % 6 == 0) i.row(); + } + }).colspan(3).width(240f).left(); + })); + }, Styles.logict, () -> { + }).size(40f).padLeft(-1).color(table.color).marginBottom(5f); + } + + /*case "nametag" -> { + table.row(); + table.add(" unit ").marginBottom(5f); + + TextField field = field(table, unit, str -> unit = str).get(); + + table.button(b -> { + b.image(Icon.pencilSmall); + b.clicked(() -> showSelectTable(b, (t, hide) -> { + t.row(); + t.table(i -> { + i.left(); + int c = 0; + for (UnitType item : Vars.content.units()) { + if (!item.unlockedNow() || item.isHidden() || !item.logicControllable) continue; + i.button(new TextureRegionDrawable(item.uiIcon), Styles.flati, iconSmall, () -> { + unit = "@" + item.name; + field.setText(unit); + hide.run(); + }).size(40f); + + if (++c % 6 == 0) i.row(); + } + }).colspan(3).width(240f).left(); + })); + }, Styles.logict, () -> { + }).size(40f).padLeft(-1).color(table.color).marginBottom(5f); + + table.add(" name "); + + fields(table, nametag, h -> nametag = h); + }*/ + } + } + + @Override + public boolean privileged() { + return true; + } + + @Override + public LExecutor.LInstruction build(LAssembler builder) { + return new TextDialogI(builder.var(text), builder.var(unit), builder.var(duration), builder.var(useBundles), builder.var("\"" + uiTemplate + "\""), builder.var("\"" + nametag + "\"")); + } + + @Override + public LCategory category() { + return HjsonppLogic.Hjsonpp; + } + + public void write(StringBuilder builder){ + builder.append("textdialog"); + builder.append(" "); + builder.append(text); + builder.append(" "); + builder.append(unit); + builder.append(" "); + builder.append(duration); + builder.append(" "); + builder.append(useBundles); + builder.append(" "); + builder.append(uiTemplate); + builder.append(" "); + builder.append(nametag); + } +} \ No newline at end of file