From da1517879a569ebac5e2d0300617fb727861571d Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Mar 2022 00:11:13 -0500 Subject: [PATCH] Cleanup --- core/assets-raw/sprites/units/mega.png | Bin 1408 -> 1006 bytes core/assets-raw/sprites/units/poly.png | Bin 630 -> 483 bytes core/src/mindustry/core/Renderer.java | 4 +- core/src/mindustry/core/UI.java | 4 +- .../mindustry/entities/comp/BuildingComp.java | 15 ++++-- .../mindustry/graphics/OverlayRenderer.java | 4 +- core/src/mindustry/input/DesktopInput.java | 2 +- core/src/mindustry/input/InputHandler.java | 48 ++++++++++++------ core/src/mindustry/input/MobileInput.java | 5 +- .../ui/fragments/BlockConfigFragment.java | 46 +++++++---------- .../ui/fragments/BlockInventoryFragment.java | 3 +- .../mindustry/ui/fragments/ChatFragment.java | 10 +--- .../ui/fragments/FadeInFragment.java | 3 +- core/src/mindustry/ui/fragments/Fragment.java | 7 --- .../mindustry/ui/fragments/HintsFragment.java | 3 +- .../mindustry/ui/fragments/HudFragment.java | 3 +- .../ui/fragments/LoadingFragment.java | 3 +- .../mindustry/ui/fragments/MenuFragment.java | 3 +- .../ui/fragments/MinimapFragment.java | 3 +- .../ui/fragments/OverlayFragment.java | 32 ------------ .../ui/fragments/PlacementFragment.java | 3 +- .../ui/fragments/PlayerListFragment.java | 3 +- .../ui/fragments/ScriptConsoleFragment.java | 10 +--- .../mindustry/world/blocks/ItemSelection.java | 2 +- .../world/blocks/distribution/ItemBridge.java | 2 +- .../world/blocks/distribution/MassDriver.java | 6 +-- .../world/blocks/logic/LogicBlock.java | 4 +- .../blocks/payloads/PayloadMassDriver.java | 6 +-- .../world/blocks/power/PowerNode.java | 2 +- 29 files changed, 96 insertions(+), 140 deletions(-) delete mode 100644 core/src/mindustry/ui/fragments/Fragment.java delete mode 100644 core/src/mindustry/ui/fragments/OverlayFragment.java diff --git a/core/assets-raw/sprites/units/mega.png b/core/assets-raw/sprites/units/mega.png index 878dba26d04ff0a066b3c8ade17545483b791839..0c3ff432a0470da01c6a7aada1734ab186e7fe7a 100644 GIT binary patch delta 923 zcmZqRe#bt+aH6AeJ#&eti(^PeHumK%RsyjtS3 zrufmz*MG}Tx!!DZqS>ZHccp0kd%Y#;zB}JP{W4X^MM%l_WCzPs38!NVW&YPKZ4t;z z`03WEaB0E)4MGlEKJFEAuSi>Xr{l!x=hfd8Z#sYa-|gV_G&rbfzB5DptdD^V?_5{Z zGA!s}isk(FN7HF8gHYoS1v}>z%N>;k=Jl&{q^%UyVcL3ZibT-s0G6UF_u8*mO=TUHolUc;BwNUe$tXcNyeaC`saGN7VTn>bLq1@cl!CpOT9^a2SS(F zE=XBrXMAh3x7?36@lG<%HVRvdBrkRz367B6)0M$oWd2LqM|NL_1arYo-o7HvL}Arb z`I9;+lTWx$(lTD_aw99>duK;-&z?p8M`jf*ujt6$;k{_VBL(heU4=|e$zUC$=K4f2 zFL!-iQQ;Pp>RFnmQ=nq;cWo8TB_brcCeHZ}d&z^T%uRg7%6T%T=$9Qs~y_WS=RY&vtOv#PbTP{q_64h^_Tzxh)W# z)_CRKYCERSeXl)q1Or@^lB?qs!sAXc$T+fHJXUd9V~GHh7^Bk%m7I0EoIeP23aGG{ zal}b}tM|OCJoTB-vH8jszi)gDRjgUfZ}p}kXIC-HZI0jU>MZBaY+o(gThNzcxt&dE z-MsgOENRkn6!!jiP`vcuH&dfwlApjtX8G48(<8NiG=}f}EZ%XZVSS%&5Q~!0j}FfT zRhL}v%rISa?z`{_#D^=c4SpCgK-OYKEE+<`*Xp!HS)?s|#E-7gJD`ms?qMzc9>gttAF1CAh^--Rv zdiMFGFYlaQtxVNMF^sU&QwcF$O*Tt-le>->1>zd=gpC9k4fA{{^ l{~zp?6WD*={KS6BXQSX@w#SYi85kHCJYD@<);T3K0RTm8q-p>F delta 1326 zcmaFI-oQP+uoCO|{#S9F5he4R}c>anM1_qXgo-U3d z8P0E~U!1nsg2%;t;pPATPijwHmm}Guc+;}_nc~+A5k)KWm|7D5{roHcrFG9z{U^G$ ziuo_!H`%Ck#g;DJJ;9^aW^q-JTj|Q#0#5S&f%7fGalgsCz&u9|5oOoc zV)ak?S}Y{~N*vm9iI*c$b@%$18)CcoSDq~WtFGw$E+8@bg`P@K`2>xPx?jYdwjF-s$aW*1kQyTUwq}oRZT%xZyaLuDIDT zwJ1l4yiLaItFP(p({l=zker>t*m+TpTTX7mme@^3W*1po1g1al^G`I3`OoUq;=NIN zyYYVeZ87tmISO2}?p#vyGK-aW`f=RlREWgdl-oxy_!M&#`_}842`oKy!R5dT&6dVx z^Q>cpw{A2MG|XT-sFynJWO1`#xp?mTcOqkc9da=}tME4D zcZ2qIh9$Skf8JVh*(>BS%cb?pe~Lz2`_&$}UWetk(RH=E3NEIyicgoFJb&-{L65HQ zwNtYv`^P)oxuQ5xKp?)spfXfpquEiL#FertHk^tF6svwK&1>FU*efT_c%*)zVAE5M zjdA?vTYHRVNL<{}dEf%W!G!$%h6n%jyNS;2uL|6=yLkq)pypYHc?$%eOha?&ztb31;<4CA zVUv`~de69?#)}#+zq_q@=WuA{b~)WQlU-xp+;;A9E%`jV+L?QH$6r>J^Aq)T9fD?= z%{2_#ps}OJ%f(;eW5|_Bm5x_9jyW6@njg1#=kA6G7b7hdDFZE5?&T*WbH9rir5N1b zU;n0lS4M=6+Ns3pFKkmjFuYW^yce#xZ9{M{VX#&`Y5|Fqa+ zM-4ng7$r6Ko!Ysj@@uec7&nlxY{7ovn_va4pH( z?BT1Vu6uckp~JU}XU%z+bUrP)X6jJpH%sm4Ry}T0!x=A>W-SynvdHwD8mM{8r9?F< zgI&{4YK4)N>MD^~;od89m*!0IO)g&(bkX)3|AfguUu-s+Tdnq2`AN#ZdCxWrpO}AL p{L{336SjY8-LvrieX)ARviyx#4>N9^%D}+D;OXk;vd$@?2>?Q+TC)HE diff --git a/core/assets-raw/sprites/units/poly.png b/core/assets-raw/sprites/units/poly.png index 7ba17b21456cc30da4ff9021493c9b5272b1cea6..dd3c76e96ffe9df07fa6a0f18abb915f0d7886a0 100644 GIT binary patch delta 420 zcmeyy@|byoxVR+;GXn!d2#Z7~0|NtNage(c!@6@aFDKfW)iY*#x;Tb-bY8u7aZ6vE~<38A%k*}=;2xJ>)Q9EZFr`*KPWWY0JD= zzir~84}Hr{y}s9@JWJ+YLVP-#(X2V%pV&%Mqffjj>?w8*>09eG_s3^u=ZyjT9D^(q z-~X-TPMDq@ec7!2^Oogjd#~-xjXb+Hr}&mt`~Bi;d{X9*$~kVcSL|x+^p0n`{Ee}0 dwR}_kWFIqL@BD{R3=9kmp00i_>ztSpngGhyxTOF9 delta 568 zcmaFN{EcOTxVi-gGXn#|{D{*!3=9m6#X;^)4C~IxykuZtU`coMb!1@J*w6hZk#(Y; zSv>=1fk$L90|Vb-5N14{zaoW!f$_Shi(`m~_tnd%iw+y`IA1(g`04-r7=b<0R_#NZ?N9ks3mv&;Ip+)!`2zZwnp!C zxWiCh#2hQTQ04YC(X`^GM#Jg%%$sr6iPzD&%*I`+$N zRlZ7B?Cf2#ul?@YNxyg=3(8y+t9sk@4hCz z4lHE#5;J$MKmADSi|X=ihbA254agT=`i{->tfb=9SF4shiMc0yNAtx%zsv{Mg zV?}=H?(^acUFz&sc<{ycC#oeH;wKJ>Pp<3klPIfn?0dT-cm3mp!aS7;&bCFC33sN( z%$@XiwU?peUB10udF{@xJhpe8;+U9q%(~slCj=z`)??%I4>?&MBb@04RI{^Z)<= diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index e035c57af6..aca5112fa8 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -635,8 +635,8 @@ public class Renderer implements ApplicationListener{ public void showLaunch(CoreBlock coreType){ Vars.ui.hudfrag.showLaunch(); - Vars.control.input.frag.config.hideConfig(); - Vars.control.input.frag.inv.hide(); + Vars.control.input.config.hideConfig(); + Vars.control.input.inv.hide(); launchCoreType = coreType; launching = true; landCore = player.team().core(); diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index a8cbc7b3fe..a4e0392698 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -212,10 +212,10 @@ public class UI implements ApplicationListener, Loadable{ hudfrag.build(hudGroup); menufrag.build(menuGroup); - chatfrag.container().build(hudGroup); + chatfrag.build(hudGroup); minimapfrag.build(hudGroup); listfrag.build(hudGroup); - scriptfrag.container().build(hudGroup); + scriptfrag.build(hudGroup); loadfrag.build(group); new FadeInFragment().build(group); } diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 82c86223c7..7175e0a909 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -323,8 +323,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, /** Deselect this tile from configuration. */ public void deselect(){ - if(!headless && control.input.frag.config.getSelectedTile() == self()){ - control.input.frag.config.hideConfig(); + if(!headless && control.input.config.getSelected() == self()){ + control.input.config.hideConfig(); } } @@ -1470,7 +1470,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, * Called when another tile is tapped while this block is selected. * @return whether this block should be deselected. */ - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ if(block.clearOnDoubleTap){ if(self() == other){ deselect(); @@ -1482,6 +1482,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, return self() != other; } + /** + * Called when a position is tapped when this building is selected. + * + * @return whether the tap event is consumed - if true, the player will not start shooting or interact with things under the cursor. + * */ + public boolean onConfigureTapped(float x, float y){ + return false; + } + /** * Called when this block's config menu is closed */ diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index 69434a5e46..1a778fdf3f 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -144,8 +144,8 @@ public class OverlayRenderer{ } //draw config selected block - if(input.frag.config.isShown()){ - Building tile = input.frag.config.getSelectedTile(); + if(input.config.isShown()){ + Building tile = input.config.getSelected(); tile.drawConfigure(); } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index e3fb74c35c..3721717b18 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -613,7 +613,7 @@ public class DesktopInput extends InputHandler{ commandRect = true; commandRectX = input.mouseWorldX(); commandRectY = input.mouseWorldY(); - }else if(selected != null){ + }else if(!checkConfigTap() && selected != null){ //only begin shooting if there's no cursor event if(!tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !tileTapped(selected.build) && !player.unit().activelyBuilding() && !droppingItem && !(tryStopMine(selected) || (!settings.getBool("doubletapmine") || selected == prevSelected && Time.timeSinceMillis(selectMillis) < 500) && tryBeginMine(selected)) && !Core.scene.hasKeyboard()){ diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 9e9c990c8f..c122876d72 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -13,6 +13,7 @@ import arc.scene.event.*; import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; +import mindustry.*; import mindustry.ai.types.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; @@ -39,6 +40,7 @@ import mindustry.world.meta.*; import java.util.*; +import static arc.Core.*; import static mindustry.Vars.*; public abstract class InputHandler implements InputProcessor, GestureListener{ @@ -50,8 +52,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ final static Rect r1 = new Rect(), r2 = new Rect(); final static Seq tmpUnits = new Seq<>(false); - public final OverlayFragment frag = new OverlayFragment(); - /** If true, there is a cutscene currently occurring in logic. */ public boolean logicCutscene; public Vec2 logicCamPan = new Vec2(); @@ -89,6 +89,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ private Seq plansOut = new Seq<>(BuildPlan.class); private QuadTree playerPlanTree = new QuadTree<>(new Rect()); + public final BlockInventoryFragment inv; + public final BlockConfigFragment config; + + private WidgetGroup group = new WidgetGroup(); + private final Eachable allPlans = cons -> { player.unit().plans().each(cons); selectPlans.each(cons); @@ -101,6 +106,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ }; public InputHandler(){ + group.touchable = Touchable.childrenOnly; + inv = new BlockInventoryFragment(); + config = new BlockConfigFragment(); + Events.on(UnitDestroyEvent.class, e -> { if(e.unit != null && e.unit.isPlayer() && e.unit.getPlayer().isLocal() && e.unit.type.weapons.contains(w -> w.bullet.killShooter)){ player.shooting = false; @@ -673,6 +682,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(state.isMenu()){ controlledType = null; logicCutscene = false; + config.forceHide(); } } @@ -1092,11 +1102,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ updateLine(x1, y1, tileX(getMouseX()), tileY(getMouseY())); } + boolean checkConfigTap(){ + return config.isShown() && config.getSelected().onConfigureTapped(input.mouseWorldX(), input.mouseWorldY()); + } + /** Handles tile tap events that are not platform specific. */ boolean tileTapped(@Nullable Building build){ if(build == null){ - frag.inv.hide(); - frag.config.hideConfig(); + inv.hide(); + config.hideConfig(); commandBuild = null; return false; } @@ -1108,21 +1122,21 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ consumed = true; }else if(build.block.configurable && build.interactable(player.team())){ //check if tapped block is configurable consumed = true; - if((!frag.config.isShown() && build.shouldShowConfigure(player)) //if the config fragment is hidden, show + if((!config.isShown() && build.shouldShowConfigure(player)) //if the config fragment is hidden, show //alternatively, the current selected block can 'agree' to switch config tiles - || (frag.config.isShown() && frag.config.getSelectedTile().onConfigureTileTapped(build))){ + || (config.isShown() && config.getSelected().onConfigureBuildTapped(build))){ Sounds.click.at(build); - frag.config.showConfig(build); + config.showConfig(build); } //otherwise... - }else if(!frag.config.hasConfigMouse()){ //make sure a configuration fragment isn't on the cursor + }else if(!config.hasConfigMouse()){ //make sure a configuration fragment isn't on the cursor //then, if it's shown and the current block 'agrees' to hide, hide it. - if(frag.config.isShown() && frag.config.getSelectedTile().onConfigureTileTapped(build)){ + if(config.isShown() && config.getSelected().onConfigureBuildTapped(build)){ consumed = true; - frag.config.hideConfig(); + config.hideConfig(); } - if(frag.config.isShown()){ + if(config.isShown()){ consumed = true; } } @@ -1137,14 +1151,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ consumed = true; }else if(build.interactable(player.team()) && build.block.synthetic() && (!consumed || build.block.allowConfigInventory)){ if(build.block.hasItems && build.items.total() > 0){ - frag.inv.showFor(build); + inv.showFor(build); consumed = true; showedInventory = true; } } if(!showedInventory){ - frag.inv.hide(); + inv.hide(); } return consumed; @@ -1300,7 +1314,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public void remove(){ Core.input.removeProcessor(this); - frag.remove(); + group.remove(); if(Core.scene != null){ Table table = (Table)Core.scene.find("inputTable"); if(table != null){ @@ -1334,7 +1348,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ uiGroup.toBack(); buildUI(uiGroup); - frag.add(); + group.setFillParent(true); + Vars.ui.hudGroup.addChildBefore(Core.scene.find("overlaymarker"), group); + + inv.build(group); + config.build(group); } } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index fbc4bf2f7a..a69794d890 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -628,7 +628,7 @@ public class MobileInput extends InputHandler implements GestureListener{ }else if(buildingTapped != null){ Call.buildingControlSelect(player, buildingTapped); recentRespawnTimer = 1f; - }else if(!tryBeginMine(cursor)){ + }else if(!checkConfigTap() && !tryBeginMine(cursor)){ tileTapped(linked.build); } return false; @@ -636,8 +636,9 @@ public class MobileInput extends InputHandler implements GestureListener{ unitTapped = selectedUnit(); buildingTapped = selectedControlBuild(); + //prevent mining if placing/breaking blocks - if(!tryStopMine() && !canTapPlayer(worldx, worldy) && !tileTapped(linked.build) && mode == none && !Core.settings.getBool("doubletapmine")){ + if(!tryStopMine() && !canTapPlayer(worldx, worldy) && !checkConfigTap() && !tileTapped(linked.build) && mode == none && !Core.settings.getBool("doubletapmine")){ tryBeginMine(cursor); } } diff --git a/core/src/mindustry/ui/fragments/BlockConfigFragment.java b/core/src/mindustry/ui/fragments/BlockConfigFragment.java index 10cd46f6ef..144bfeb8d6 100644 --- a/core/src/mindustry/ui/fragments/BlockConfigFragment.java +++ b/core/src/mindustry/ui/fragments/BlockConfigFragment.java @@ -12,46 +12,34 @@ import mindustry.gen.*; import static mindustry.Vars.*; -public class BlockConfigFragment extends Fragment{ +public class BlockConfigFragment{ Table table = new Table(); - Building configTile; + Building selected; - @Override public void build(Group parent){ table.visible = false; parent.addChild(table); - //hacky way to hide block config when in menu - //TODO remove? - Core.scene.add(new Element(){ - @Override - public void act(float delta){ - super.act(delta); - if(state.isMenu()){ - table.visible = false; - configTile = null; - } - } - }); + Events.on(ResetEvent.class, e -> forceHide()); + } - Events.on(ResetEvent.class, e -> { - table.visible = false; - configTile = null; - }); + public void forceHide(){ + table.visible = false; + selected = null; } public boolean isShown(){ - return table.visible && configTile != null; + return table.visible && selected != null; } - public Building getSelectedTile(){ - return configTile; + public Building getSelected(){ + return selected; } public void showConfig(Building tile){ - if(configTile != null) configTile.onConfigureClosed(); + if(selected != null) selected.onConfigureClosed(); if(tile.configTapped()){ - configTile = tile; + selected = tile; table.visible = true; table.clear(); @@ -62,16 +50,16 @@ public class BlockConfigFragment extends Fragment{ Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out)); table.update(() -> { - if(configTile != null && configTile.shouldHideConfigure(player)){ + if(selected != null && selected.shouldHideConfigure(player)){ hideConfig(); return; } table.setOrigin(Align.center); - if(configTile == null || configTile.block == Blocks.air || !configTile.isValid()){ + if(selected == null || selected.block == Blocks.air || !selected.isValid()){ hideConfig(); }else{ - configTile.updateTableAlign(table); + selected.updateTableAlign(table); } }); } @@ -83,8 +71,8 @@ public class BlockConfigFragment extends Fragment{ } public void hideConfig(){ - if(configTile != null) configTile.onConfigureClosed(); - configTile = null; + if(selected != null) selected.onConfigureClosed(); + selected = null; table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false)); } } diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index 23ee7842d9..d67403ca61 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -23,7 +23,7 @@ import java.util.*; import static mindustry.Vars.*; -public class BlockInventoryFragment extends Fragment{ +public class BlockInventoryFragment{ private static final float holdWithdraw = 20f; private static final float holdShrink = 120f; @@ -38,7 +38,6 @@ public class BlockInventoryFragment extends Fragment{ Events.on(WorldLoadEvent.class, e -> hide()); } - @Override public void build(Group parent){ table.name = "inventory"; table.setTransform(true); diff --git a/core/src/mindustry/ui/fragments/ChatFragment.java b/core/src/mindustry/ui/fragments/ChatFragment.java index 889264fd64..ee3e1f0dc2 100644 --- a/core/src/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/mindustry/ui/fragments/ChatFragment.java @@ -37,12 +37,6 @@ public class ChatFragment extends Table{ private Seq history = new Seq<>(); private int historyPos = 0; private int scrollPos = 0; - private Fragment container = new Fragment(){ - @Override - public void build(Group parent){ - scene.add(ChatFragment.this); - } - }; public ChatFragment(){ super(); @@ -89,8 +83,8 @@ public class ChatFragment extends Table{ setup(); } - public Fragment container(){ - return container; + public void build(Group parent){ + scene.add(this); } public void clearMessages(){ diff --git a/core/src/mindustry/ui/fragments/FadeInFragment.java b/core/src/mindustry/ui/fragments/FadeInFragment.java index e82bc75c68..1a87c34336 100644 --- a/core/src/mindustry/ui/fragments/FadeInFragment.java +++ b/core/src/mindustry/ui/fragments/FadeInFragment.java @@ -7,11 +7,10 @@ import arc.scene.*; import arc.scene.event.*; /** Fades in a black overlay.*/ -public class FadeInFragment extends Fragment{ +public class FadeInFragment{ private static final float duration = 40f; float time = 0f; - @Override public void build(Group parent){ parent.addChild(new Element(){ { diff --git a/core/src/mindustry/ui/fragments/Fragment.java b/core/src/mindustry/ui/fragments/Fragment.java deleted file mode 100644 index 367b6f0cfa..0000000000 --- a/core/src/mindustry/ui/fragments/Fragment.java +++ /dev/null @@ -1,7 +0,0 @@ -package mindustry.ui.fragments; - -import arc.scene.*; - -public abstract class Fragment{ - public abstract void build(Group parent); -} diff --git a/core/src/mindustry/ui/fragments/HintsFragment.java b/core/src/mindustry/ui/fragments/HintsFragment.java index b310cbf066..9b7198fee3 100644 --- a/core/src/mindustry/ui/fragments/HintsFragment.java +++ b/core/src/mindustry/ui/fragments/HintsFragment.java @@ -22,7 +22,7 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; -public class HintsFragment extends Fragment{ +public class HintsFragment{ private static final Boolp isTutorial = () -> Vars.state.rules.sector == SectorPresets.groundZero.sector; private static final float foutTime = 0.6f; @@ -35,7 +35,6 @@ public class HintsFragment extends Fragment{ ObjectSet placedBlocks = new ObjectSet<>(); Table last; - @Override public void build(Group parent){ group.setFillParent(true); group.touchable = Touchable.childrenOnly; diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index bf4b5a3dad..be9b9e9181 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -31,7 +31,7 @@ import mindustry.ui.*; import static mindustry.Vars.*; import static mindustry.gen.Tex.*; -public class HudFragment extends Fragment{ +public class HudFragment{ private static final float dsize = 65f, pauseHeight = 36f; public final PlacementFragment blockfrag = new PlacementFragment(); @@ -47,7 +47,6 @@ public class HudFragment extends Fragment{ private Table lastUnlockLayout; private long lastToast; - @Override public void build(Group parent){ //warn about guardian/boss waves diff --git a/core/src/mindustry/ui/fragments/LoadingFragment.java b/core/src/mindustry/ui/fragments/LoadingFragment.java index 41e3ca537d..0b26286018 100644 --- a/core/src/mindustry/ui/fragments/LoadingFragment.java +++ b/core/src/mindustry/ui/fragments/LoadingFragment.java @@ -12,14 +12,13 @@ import arc.scene.ui.layout.*; import mindustry.graphics.*; import mindustry.ui.*; -public class LoadingFragment extends Fragment{ +public class LoadingFragment{ private Table table; private TextButton button; private Bar bar; private Label nameLabel; private float progValue; - @Override public void build(Group parent){ parent.fill(t -> { //rect must fill screen completely. diff --git a/core/src/mindustry/ui/fragments/MenuFragment.java b/core/src/mindustry/ui/fragments/MenuFragment.java index 0c959eedaf..f92d2f01f5 100644 --- a/core/src/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/mindustry/ui/fragments/MenuFragment.java @@ -21,12 +21,11 @@ import mindustry.ui.*; import static mindustry.Vars.*; import static mindustry.gen.Tex.*; -public class MenuFragment extends Fragment{ +public class MenuFragment{ private Table container, submenu; private Button currentMenu; private MenuRenderer renderer; - @Override public void build(Group parent){ renderer = new MenuRenderer(); diff --git a/core/src/mindustry/ui/fragments/MinimapFragment.java b/core/src/mindustry/ui/fragments/MinimapFragment.java index 8259a8232e..200aea77be 100644 --- a/core/src/mindustry/ui/fragments/MinimapFragment.java +++ b/core/src/mindustry/ui/fragments/MinimapFragment.java @@ -14,13 +14,12 @@ import mindustry.ui.*; import static mindustry.Vars.*; -public class MinimapFragment extends Fragment{ +public class MinimapFragment{ private boolean shown; float panx, pany, zoom = 1f, lastZoom = -1; private float baseSize = Scl.scl(5f); public Element elem; - @Override public void build(Group parent){ elem = parent.fill((x, y, w, h) -> { w = Core.graphics.getWidth(); diff --git a/core/src/mindustry/ui/fragments/OverlayFragment.java b/core/src/mindustry/ui/fragments/OverlayFragment.java deleted file mode 100644 index 72dd3c223d..0000000000 --- a/core/src/mindustry/ui/fragments/OverlayFragment.java +++ /dev/null @@ -1,32 +0,0 @@ -package mindustry.ui.fragments; - -import arc.*; -import arc.scene.event.*; -import arc.scene.ui.layout.*; -import mindustry.*; - -/** Fragment for displaying overlays such as block inventories. */ -public class OverlayFragment{ - public final BlockInventoryFragment inv; - public final BlockConfigFragment config; - - private WidgetGroup group = new WidgetGroup(); - - public OverlayFragment(){ - group.touchable = Touchable.childrenOnly; - inv = new BlockInventoryFragment(); - config = new BlockConfigFragment(); - } - - public void add(){ - group.setFillParent(true); - Vars.ui.hudGroup.addChildBefore(Core.scene.find("overlaymarker"), group); - - inv.build(group); - config.build(group); - } - - public void remove(){ - group.remove(); - } -} diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 70d4db7dda..4027d7ff6f 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -27,7 +27,7 @@ import mindustry.world.blocks.ConstructBlock.*; import static mindustry.Vars.*; -public class PlacementFragment extends Fragment{ +public class PlacementFragment{ final int rowWidth = 4; public Category currentCategory = Category.distribution; @@ -229,7 +229,6 @@ public class PlacementFragment extends Fragment{ return false; } - @Override public void build(Group parent){ parent.fill(full -> { toggler = full; diff --git a/core/src/mindustry/ui/fragments/PlayerListFragment.java b/core/src/mindustry/ui/fragments/PlayerListFragment.java index 1a701571ab..1b749004f3 100644 --- a/core/src/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/mindustry/ui/fragments/PlayerListFragment.java @@ -18,14 +18,13 @@ import mindustry.ui.*; import static mindustry.Vars.*; -public class PlayerListFragment extends Fragment{ +public class PlayerListFragment{ public Table content = new Table().marginRight(13f).marginLeft(13f); private boolean visible = false; private Interval timer = new Interval(); private TextField search; private Seq players = new Seq<>(); - @Override public void build(Group parent){ content.name = "players"; parent.fill(cont -> { diff --git a/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java b/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java index 0bcc11edb6..d4698bac1b 100644 --- a/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java +++ b/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java @@ -32,12 +32,6 @@ public class ScriptConsoleFragment extends Table{ private Seq history = new Seq<>(); private int historyPos = 0; private int scrollPos = 0; - private Fragment container = new Fragment(){ - @Override - public void build(Group parent){ - scene.add(ScriptConsoleFragment.this); - } - }; public ScriptConsoleFragment(){ setFillParent(true); @@ -82,8 +76,8 @@ public class ScriptConsoleFragment extends Table{ setup(); } - public Fragment container(){ - return container; + public void build(Group parent){ + scene.add(this); } public void clearMessages(){ diff --git a/core/src/mindustry/world/blocks/ItemSelection.java b/core/src/mindustry/world/blocks/ItemSelection.java index 0421ef90a8..d4eeadaf12 100644 --- a/core/src/mindustry/world/blocks/ItemSelection.java +++ b/core/src/mindustry/world/blocks/ItemSelection.java @@ -41,7 +41,7 @@ public class ItemSelection{ if(!item.unlockedNow() || (item instanceof Item checkVisible && state.rules.hiddenBuildItems.contains(checkVisible))) continue; ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> { - if(closeSelect) control.input.frag.config.hideConfig(); + if(closeSelect) control.input.config.hideConfig(); }).group(group).tooltip(item.localizedName).get(); button.changed(() -> consumer.get(button.isChecked() ? item : null)); button.getStyle().imageUp = new TextureRegionDrawable(item.uiIcon); diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 884cc301da..d78e2537b9 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -263,7 +263,7 @@ public class ItemBridge extends Block{ } @Override - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ //reverse connection if(other instanceof ItemBridgeBuild b && b.link == pos()){ configure(other.pos()); diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 3e784b7d9f..105d78203f 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -75,8 +75,8 @@ public class MassDriver extends Block{ Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent); //check if a mass driver is selected while placing this driver - if(!control.input.frag.config.isShown()) return; - Building selected = control.input.frag.config.getSelectedTile(); + if(!control.input.config.isShown()) return; + Building selected = control.input.config.getSelected(); if(selected == null || selected.block != this || !selected.within(x * tilesize, y * tilesize, range)) return; //if so, draw a dotted line towards it while it is in range @@ -250,7 +250,7 @@ public class MassDriver extends Block{ } @Override - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ if(this == other){ if(link == -1) deselect(); configure(-1); diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index 62dc305fbb..38993c9ceb 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -571,7 +571,7 @@ public class LogicBlock extends Block{ } @Override - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ if(this == other || !accessible()){ deselect(); return false; @@ -582,7 +582,7 @@ public class LogicBlock extends Block{ return false; } - return super.onConfigureTileTapped(other); + return super.onConfigureBuildTapped(other); } @Override diff --git a/core/src/mindustry/world/blocks/payloads/PayloadMassDriver.java b/core/src/mindustry/world/blocks/payloads/PayloadMassDriver.java index 56694def25..d804e90805 100644 --- a/core/src/mindustry/world/blocks/payloads/PayloadMassDriver.java +++ b/core/src/mindustry/world/blocks/payloads/PayloadMassDriver.java @@ -102,8 +102,8 @@ public class PayloadMassDriver extends PayloadBlock{ Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent); //check if a mass driver is selected while placing this driver - if(!control.input.frag.config.isShown()) return; - Building selected = control.input.frag.config.getSelectedTile(); + if(!control.input.config.isShown()) return; + Building selected = control.input.config.getSelected(); if(selected == null || selected.block != this || !selected.within(x * tilesize, y * tilesize, range)) return; //if so, draw a dotted line towards it while it is in range @@ -431,7 +431,7 @@ public class PayloadMassDriver extends PayloadBlock{ } @Override - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ if(this == other){ if(link == -1) deselect(); configure(-1); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index ac20b77c5e..e6181aefee 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -384,7 +384,7 @@ public class PowerNode extends PowerBlock{ } @Override - public boolean onConfigureTileTapped(Building other){ + public boolean onConfigureBuildTapped(Building other){ if(linkValid(this, other)){ configure(other.pos()); return false;