Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ author: '''
Port: 00SunRay00 & RE2b2m22
'''
minGameVersion: 157
version: 2.0.5
version: 2.0.6
hidden: true
main: scheme.Main
5 changes: 4 additions & 1 deletion src/java/scheme/SchemeVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public static void load() {
Log.err("Failed to create invincible outlined icon", ex);
}
});
Events.on(EventType.WorldLoadEndEvent.class,event ->updateContent());
Events.on(EventType.WorldLoadEndEvent.class, event -> {
updateContent();
if (settings.getInt("adminsway", 0) == 3) admins = AdminsConfigDialog.detectTools();
});
Events.on(EventType.ClientCreateEvent.class,event ->updateContent());
// m_schematics is created in Main to prevent dual loading
m_input = mobile ? new ModedMobileInput() : new ModedDesktopInput();
Expand Down
5 changes: 4 additions & 1 deletion src/java/scheme/ServerIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ServerIntegration {
/** Whether the player received subtitles from the server. */
public static boolean hasData;

public static boolean schemeAvailable;

public static void load() {
// region Server

Expand Down Expand Up @@ -68,7 +70,7 @@ public static void load() {
});

netClient.addBinaryPacketHandler("schemesize.available", (data) -> {

schemeAvailable = true;
});
Events.on(WorldLoadEndEvent.class, e -> {

Expand Down Expand Up @@ -99,6 +101,7 @@ public static void clear() {
SSUsers.clear();
hostID = -1;
hasData = false;
schemeAvailable = false;

// put the host's subtitle so that you do not copy the int map later
SSUsers.put(player.id, settings.getString("subtitle"));
Expand Down
2 changes: 2 additions & 0 deletions src/java/scheme/tools/admins/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class Internal implements AdminsTools {

public void manageRuleBool(boolean value, String name) {
if (unusable()) return;
try {
Field fiel = Rules.class.getField(name);
fiel.setBoolean(Vars.state.rules, value);
Expand All @@ -39,6 +40,7 @@ public void manageRuleBool(boolean value, String name) {
}

public void manageRuleStr(String value, String name) {
if (unusable()) return;
try {
Field fiel = Rules.class.getField(name);
fiel.set(Vars.state.rules, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
import scheme.tools.MessageQueue;
import scheme.tools.RainbowTeam;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static arc.Core.*;
import static mindustry.Vars.*;
import static scheme.SchemeVars.*;

public class Darkdustry implements AdminsTools {
public class Mindurka implements AdminsTools {

public void manageRuleBool(boolean value, String name) {
if (unusable()) return;
Expand Down
8 changes: 6 additions & 2 deletions src/java/scheme/tools/admins/SlashJs.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scheme.tools.admins;

import arc.math.Mathf;
import arc.math.geom.Position;
import arc.struct.Seq;
import arc.util.Strings;
Expand All @@ -20,10 +21,12 @@
public class SlashJs implements AdminsTools {

public void manageRuleBool(boolean value, String name) {
if (unusable()) return;
send("Vars.state.rules." + name + " = " + value + "; Call.setRules(Vars.state.rules);");
}

public void manageRuleStr(String value, String name) {
if (unusable()) return;
send("Vars.state.rules." + name + " = " + value + "; Call.setRules(Vars.state.rules);");
}

Expand Down Expand Up @@ -107,10 +110,11 @@ public void despawn(Player target) {

public void teleport(Position pos) {
if (unusable()) return;
String conpos = "(player.con, " + pos.toString().replace("(", ""); // Vec2 and Point2 returns (x, y)
float x = Mathf.round(pos.getX()), y = Mathf.round(pos.getY());
getPlayer(player);
send("var spawned = player.unit().spawnedByCore; var unit = player.unit(); unit.spawnedByCore = false; player.clearUnit()");
send("unit.set@; Call.setPosition@; Call.setCameraPosition@", pos, conpos, conpos);
send("unit.set(@, @); Call.setPosition(player.con, @, @)", x, y, x, y);
send("Call.setCameraPosition(player.con, @, @)", x, y);
send("player.unit(unit); unit.spawnedByCore = spawned");
}

Expand Down
2 changes: 1 addition & 1 deletion src/java/scheme/ui/HudFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void build(Group parent) {
setAction(mode, "blasted", () -> admins.despawn());
setAction(mode, "overdrive", () -> admins.teleport());
setAction(mode, Icon.lock, () -> m_input.lockMovement());
setAction(mode, Icon.fileText, () -> rulesetter.show());
setAction(mode, Icon.fileText, () -> { if (!admins.unusable()) rulesetter.show(); });
}).visible(() -> true).update(mode -> mode.setTranslation(0f, Scl.scl(mobiles.fliped ? 0f : -63.2f))).row();

partitionmb(pad, mode -> {
Expand Down
34 changes: 29 additions & 5 deletions src/java/scheme/ui/dialogs/AdminsConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import mindustry.gen.Call;
import mindustry.gen.ClientSnapshotCallPacket;
import mindustry.ui.dialogs.BaseDialog;
import scheme.ServerIntegration;
import scheme.tools.admins.*;
import scheme.ui.TextSlider;

Expand All @@ -14,9 +15,9 @@

public class AdminsConfigDialog extends BaseDialog {

public boolean enabled = settings.getBool("adminsenabled", false);
public boolean always = settings.getBool("adminsalways", false);
public boolean strict = settings.getBool("adminsstrict", false);
public static boolean enabled = settings.getBool("adminsenabled", false);
public static boolean always = settings.getBool("adminsalways", false);
public static boolean strict = settings.getBool("adminsstrict", false);
public int way = settings.getInt("adminsway", 0);

public AdminsConfigDialog() {
Expand All @@ -35,6 +36,10 @@ public AdminsConfigDialog() {

cont.labelWrap("@admins.way").padTop(16f).width(320f).row();
cont.table(table -> {
var auto = table.check(bundle.format("admins.way.auto.name", detectToolsName()), value -> this.way = 3)
.checked(t -> this.way == 3).disabled(t -> !enabled).tooltip("@admins.way.auto.desc").left().get();
shown(() -> auto.setText(bundle.format("admins.way.auto.name", detectToolsName())));
table.row();
addCheck(table, "@admins.way.internal", 0);
addCheck(table, "@admins.way.slashjs", 1);
addCheck(table, "@admins.way.darkdustry", 2);
Expand Down Expand Up @@ -66,8 +71,27 @@ private void addCheck(Table table, String text, int way) {

/** Made static so that it can be accessed before the dialog is created. */
public static AdminsTools getTools() {
int way = settings.getInt("adminsway", 0);
if (way == 3) return detectTools();
return new AdminsTools[] {
new Internal(), new SlashJs(), new Darkdustry()
}[settings.getInt("adminsway", 0)];
new Internal(), new SlashJs(), new Mindurka()
}[way];
}

public static String detectToolsName() {
AdminsTools tools = detectTools();
if (tools instanceof Mindurka) return bundle.get("admins.way.darkdustry.name");
if (tools instanceof SlashJs) return bundle.get("admins.way.slashjs.name ");
return bundle.get("admins.way.internal.name");
}

public static AdminsTools detectTools() {
if (!net.client() || !ServerIntegration.schemeAvailable || (!player.admin && !always)) return new Internal();

for (var entry : state.rules.tags.entries()) {
if (entry.key.startsWith("mdrk.")) return new Mindurka();
}

return new Internal();
}
}
2 changes: 2 additions & 0 deletions src/resources/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ admins.lever = Admins Features {0}
admins.enabled = Enabled
admins.disabled = Disabled
admins.way = Which path do you want to use to interact with the game?
admins.way.auto.name = Auto ({0})
admins.way.auto.desc = Automatically detect the best method based on game context.
admins.way.internal.name = Internal
admins.way.internal.desc = Use it if you are a host or playing a local game.
admins.way.slashjs.name = Slash Js
Expand Down
Loading
Loading