From a7cddf97b8ecd7bf43bd2843a168212db9f74028 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 8 Jan 2020 16:16:19 -0500 Subject: [PATCH] Implemented bridge opacity from #1006 --- core/assets/bundles/bundle.properties | 3 ++- .../mindustry/ui/dialogs/SettingsMenuDialog.java | 1 + .../blocks/distribution/ExtendingItemBridge.java | 13 +++++++++---- .../world/blocks/distribution/ItemBridge.java | 7 +++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c4faf1ed35..a035c45c6a 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -667,6 +667,7 @@ setting.savecreate.name = Auto-Create Saves setting.publichost.name = Public Game Visibility setting.chatopacity.name = Chat Opacity setting.lasersopacity.name = Power Laser Opacity +setting.bridgeopacity.name = Bridge Opacity setting.playerchat.name = Display Player Bubble Chat public.confirm = Do you want to make your game public?\n[accent]Anyone will be able to join your games.\n[lightgray]This can be changed later in Settings->Game->Public Game Visibility. public.beta = Note that beta versions of the game cannot make public lobbies. @@ -1212,7 +1213,7 @@ block.core-nucleus.description = The third and final iteration of the core capsu block.vault.description = Stores a large amount of items of each type. An unloader block can be used to retrieve items from the vault. block.container.description = Stores a small amount of items of each type. An unloader block can be used to retrieve items from the container. block.unloader.description = Unloads items from any nearby non-transportation block. The type of item to be unloaded can be changed by tapping. -block.launch-pad.description = Launches batches of items without any need for a core launch. +block.launch-pad.description = Launches batfches of items without any need for a core launch. block.launch-pad-large.description = An improved version of the launch pad. Stores more items. Launches more frequently. block.duo.description = A small, cheap turret. Useful against ground units. block.scatter.description = An essential anti-air turret. Sprays clumps of lead or scrap flak at enemy units. diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 3ce8457ec1..ea9210f695 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -268,6 +268,7 @@ public class SettingsMenuDialog extends SettingsDialog{ } return s + "%"; }); + graphics.sliderPref("bridgeopacity", 75, 0, 100, 5, s -> s + "%"); if(!mobile){ graphics.checkPref("vsync", true, b -> Core.graphics.setVSync(b)); diff --git a/core/src/mindustry/world/blocks/distribution/ExtendingItemBridge.java b/core/src/mindustry/world/blocks/distribution/ExtendingItemBridge.java index d5aa4494a7..6fe691d117 100644 --- a/core/src/mindustry/world/blocks/distribution/ExtendingItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ExtendingItemBridge.java @@ -1,9 +1,10 @@ package mindustry.world.blocks.distribution; +import arc.*; import arc.graphics.g2d.*; -import arc.math.Mathf; -import arc.math.geom.Geometry; -import mindustry.world.Tile; +import arc.math.*; +import arc.math.geom.*; +import mindustry.world.*; import static mindustry.Vars.*; @@ -31,6 +32,10 @@ public class ExtendingItemBridge extends ItemBridge{ ex *= uptime; ey *= uptime; + float opacity = Core.settings.getInt("bridgeopacity") / 100f; + if(Mathf.zero(opacity)) return; + Draw.alpha(opacity); + Lines.stroke(8f); Lines.line(bridgeRegion, tile.worldx() + Geometry.d4[i].x * tilesize / 2f, @@ -50,7 +55,7 @@ public class ExtendingItemBridge extends ItemBridge{ Draw.color(); for(int a = 0; a < arrows; a++){ - Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * uptime); + Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * uptime * opacity); Draw.rect(arrowRegion, tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 6f + 2) * uptime, tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 6f + 2) * uptime, i * 90f); diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 0dd4320e7d..5d16ec69ee 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -219,10 +219,13 @@ public class ItemBridge extends Block{ Tile other = world.tile(entity.link); if(!linkValid(tile, other)) return; + float opacity = Core.settings.getInt("bridgeopacity") / 100f; + if(Mathf.zero(opacity)) return; + int i = tile.absoluteRelativeTo(other.x, other.y); Draw.color(Color.white, Color.black, Mathf.absin(Time.time(), 6f, 0.07f)); - Draw.alpha(Math.max(entity.uptime, 0.25f)); + Draw.alpha(Math.max(entity.uptime, 0.25f) * opacity); Draw.rect(endRegion, tile.drawx(), tile.drawy(), i * 90 + 90); Draw.rect(endRegion, other.drawx(), other.drawy(), i * 90 + 270); @@ -242,7 +245,7 @@ public class ItemBridge extends Block{ Draw.color(); for(int a = 0; a < arrows; a++){ - Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); + Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime * opacity); Draw.rect(arrowRegion, tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 4f + time % 4f), tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 4f + time % 4f), i * 90f);