Skip to content

Commit

Permalink
Massdriver distance, Schem prune tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sbxte committed Jan 12, 2024
1 parent 19d4df3 commit ec9f45d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ client.claj.wrongkeylength = CLaJ link is wrong length
client.claj.missingprefix = CLaJ link missing prefix

client.schematic.cleartags = Clear tags
client.schematic.prunetags = Prune tags
client.schematic.browser = Schematic Browser
client.schematic.browser.repo = Schematic Repositories
client.schematic.browser.add = Add Repo
Expand Down Expand Up @@ -1521,6 +1522,8 @@ setting.useblockicon.name = Use block icon in logs
setting.useblockicon.description = Use icon instead of text
setting.colorizelogs.name = Colorize logs
setting.colorizelogs.description = Add some color to your log events
setting.showmassdriverdistance.name = Show mass driver distance
setting.showmassdriverdistance.description = Shows distance between two linked mass drivers

setting.misc.category = Miscellaneous
setting.keybind1shiftcommand.name = Keybind+Shift Command
Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustry/ui/dialogs/SchematicsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ void showAllTags(){
p.table(t -> {
t.left().defaults().fillX().height(tagh).pad(2);
t.button("@client.schematic.cleartags", Icon.refresh, selectedTags::clear).wrapLabel(false).get().getLabelCell().padLeft(5);
t.button("@client.schematic.prunetags", Icon.trash, this::pruneTags).wrapLabel(false).get().getLabelCell().padLeft(5);
t.button("@schematic.texttag", Icon.add, () -> showNewTag(res -> rebuild[0].run())).wrapLabel(false).get().getLabelCell().padLeft(5);
t.button("@schematic.icontag", Icon.add, () -> showNewIconTag(res -> rebuild[0].run())).wrapLabel(false).get().getLabelCell().padLeft(5);
});
Expand Down Expand Up @@ -631,6 +632,10 @@ void showAllTags(){
dialog.show();
}

public void pruneTags() {
tags.removeAll(t -> schematics.all().find(s -> s.labels.contains(t)) == null);
}

void deleteTag(String tag) {
for(Schematic s : schematics.all()){
if(s.labels.any()){
Expand Down
1 change: 1 addition & 0 deletions core/src/mindustry/ui/dialogs/SettingsMenuDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ void addSettings(){
client.checkPref("activemodesdisplay", true);
client.checkPref("useblockicon", false);
client.checkPref("colorizelogs", false);
client.checkPref("showmassdriverdistance", false);

client.category("misc");
client.updatePref();
Expand Down
32 changes: 32 additions & 0 deletions core/src/mindustry/world/blocks/distribution/MassDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import arc.*;
import arc.audio.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
Expand All @@ -19,6 +20,7 @@
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.meta.*;

Expand Down Expand Up @@ -93,6 +95,21 @@ public void drawPlace(int x, int y, int rotation, boolean valid){
Lines.dashLine(x1, y1, x2, y2, segs);
Lines.stroke(2f, Pal.placing);
Lines.dashLine(x1, y1, x2, y2, segs);

if (Core.settings.getBool("showmassdriverdistance")) {
Font font = Fonts.outline;
font.setColor(player.team().color);
var ints = font.usesIntegerPositions();
font.setUseIntegerPositions(false);
var z = Draw.z();
Draw.z(Layer.endPixeled);
font.getData().setScale(1 / renderer.camerascale);
font.draw(String.valueOf((int)(selected.dst(x * tilesize, y * tilesize) / tilesize)), (x - (size + sizeOffset - 1)) * tilesize, (y - (size + sizeOffset)) * tilesize);
font.getData().setScale(1);
font.setUseIntegerPositions(ints);
Draw.z(z);
}

Draw.reset();
}

Expand Down Expand Up @@ -260,6 +277,21 @@ public void drawConfigure(){
Building target = world.build(link);
Drawf.circles(target.x, target.y, (target.block().size / 2f + 1) * tilesize + sin - 2f, Pal.place);
Drawf.arrow(x, y, target.x, target.y, size * tilesize + sin, 4f + sin);

if (Core.settings.getBool("showmassdriverdistance")) {
Font font = Fonts.outline;
font.setColor(player.team().color);
var ints = font.usesIntegerPositions();
font.setUseIntegerPositions(false);
var z = Draw.z();
Draw.z(Layer.endPixeled);
font.getData().setScale(1 / renderer.camerascale);
font.draw(String.valueOf((int)(target.dst(x, y) / tilesize)), x - (size + sizeOffset - 1) * tilesize, y - (size + sizeOffset) * tilesize);
font.setColor(Color.white);
font.getData().setScale(1);
font.setUseIntegerPositions(ints);
Draw.z(z);
}
}

Drawf.dashCircle(x, y, range, Pal.accent);
Expand Down

0 comments on commit ec9f45d

Please sign in to comment.