Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v6' into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Nov 16, 2021
2 parents 7d75214 + 610658e commit cf1f7bf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 2 additions & 0 deletions core/src/mindustry/Vars.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public class Vars implements Loadable{
public static NetClient netClient;

public static Player player;
public static boolean drawCursors, wasDrawingCursors; // Client debug magic

@Override
public void loadAsync(){
Expand Down Expand Up @@ -279,6 +280,7 @@ public static void init(){
clientThread = new ClientThread();
bases = new BaseRegistry();
constants = new GlobalConstants();
drawCursors = settings.getBool("drawcursors");

state = new GameState();

Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/client/ClientLogic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class ClientLogic {
Events.on(EventType.PlayerJoin::class.java) { e -> // Run when a player joins the server
if (e.player == null) return@on

if (Core.settings.getBool("clientjoinleave") && (Vars.ui.chatfrag.messages.isEmpty || !Strings.stripColors(Vars.ui.chatfrag.messages.first().message).equals("${Strings.stripColors(e.player.name)} has connected.")) && Time.timeSinceMillis(ClientVars.lastJoinTime) > 10000)
if (Core.settings.getBool("clientjoinleave") && (Vars.ui.chatfrag.messages.isEmpty || !Strings.stripColors(Vars.ui.chatfrag.messages.first().message).contains("${Strings.stripColors(e.player.name)}.*connected".toRegex())) && Time.timeSinceMillis(ClientVars.lastJoinTime) > 10000)
Vars.player.sendMessage(Core.bundle.format("client.connected", e.player.name))
}

Events.on(EventType.PlayerLeave::class.java) { e -> // Run when a player leaves the server
if (e.player == null) return@on

if (Core.settings.getBool("clientjoinleave") && (Vars.ui.chatfrag.messages.isEmpty || !Strings.stripColors(Vars.ui.chatfrag.messages.first().message).equals("${Strings.stripColors(e.player.name)} has disconnected.")))
if (Core.settings.getBool("clientjoinleave") && (Vars.ui.chatfrag.messages.isEmpty || !Strings.stripColors(Vars.ui.chatfrag.messages.first().message).contains("${Strings.stripColors(e.player.name)}.*disconnected".toRegex())))
Vars.player.sendMessage(Core.bundle.format("client.disconnected", e.player.name))
}
}
Expand Down
35 changes: 31 additions & 4 deletions core/src/mindustry/graphics/BlockRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
import arc.graphics.g2d.*;
import arc.graphics.gl.*;
import arc.math.*;
import arc.math.geom.Rect;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.client.*;
import mindustry.content.*;
import mindustry.game.EventType.*;
import mindustry.game.Team;
import mindustry.game.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.power.*;

import static arc.Core.*;
import static mindustry.Vars.state;
import static mindustry.Vars.*;
import static mindustry.client.navigation.Navigation.obstacles;
import static mindustry.client.navigation.Navigation.*;

public class BlockRenderer{
public static final int crackRegions = 8, maxCrackSize = 9;
Expand Down Expand Up @@ -303,15 +304,41 @@ public void drawBlocks(){
}
}


var bounds = camera.bounds(Tmp.r3).grow(tilesize);

if (drawCursors) {
Draw.z(Layer.space);
Draw.color(Color.red);
Draw.alpha(.3f);
boolean ints = Fonts.def.usesIntegerPositions();
Fonts.def.setUseIntegerPositions(false);
Fonts.def.getData().setScale(0.25f / Scl.scl(1f));
for (Player player : Groups.player) {
if (player.isLocal() || player.assisting) continue;

Fill.circle(player.mouseX, player.mouseY, tilesize * .5f);
if (input.mouseWorld().dst(player.mouseX, player.mouseY) < 20 * tilesize) {
Fonts.def.draw("[#" + player.color + "]" + player.name, player.mouseX, player.mouseY, Align.center);
}
}
Fonts.def.getData().setScale(1f);
Fonts.def.setUseIntegerPositions(ints);
}

if (ClientVars.showingTurrets) {
Draw.z(Layer.space);
Rect bounds = new Rect();
Core.camera.bounds(bounds);
obstacles.forEach(t -> {
if (!t.canShoot || !(settings.getBool("unitranges") || t.turret) || !bounds.overlaps(t.x - t.radius, t.y - t.radius, t.radius*2, t.radius*2)) return;
Drawf.dashCircle(t.x, t.y, t.radius, t.canHitPlayer ? t.team.color : Team.derelict.color);
});
}

if (wasDrawingCursors != drawCursors) {
wasDrawingCursors = drawCursors;
settings.put("drawcursors", drawCursors);
}
}

}

0 comments on commit cf1f7bf

Please sign in to comment.