Cleanup
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1006 B |
Binary file not shown.
|
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 483 B |
@@ -635,8 +635,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
public void showLaunch(CoreBlock coreType){
|
public void showLaunch(CoreBlock coreType){
|
||||||
Vars.ui.hudfrag.showLaunch();
|
Vars.ui.hudfrag.showLaunch();
|
||||||
Vars.control.input.frag.config.hideConfig();
|
Vars.control.input.config.hideConfig();
|
||||||
Vars.control.input.frag.inv.hide();
|
Vars.control.input.inv.hide();
|
||||||
launchCoreType = coreType;
|
launchCoreType = coreType;
|
||||||
launching = true;
|
launching = true;
|
||||||
landCore = player.team().core();
|
landCore = player.team().core();
|
||||||
|
|||||||
@@ -212,10 +212,10 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
|
|
||||||
hudfrag.build(hudGroup);
|
hudfrag.build(hudGroup);
|
||||||
menufrag.build(menuGroup);
|
menufrag.build(menuGroup);
|
||||||
chatfrag.container().build(hudGroup);
|
chatfrag.build(hudGroup);
|
||||||
minimapfrag.build(hudGroup);
|
minimapfrag.build(hudGroup);
|
||||||
listfrag.build(hudGroup);
|
listfrag.build(hudGroup);
|
||||||
scriptfrag.container().build(hudGroup);
|
scriptfrag.build(hudGroup);
|
||||||
loadfrag.build(group);
|
loadfrag.build(group);
|
||||||
new FadeInFragment().build(group);
|
new FadeInFragment().build(group);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,8 +323,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
|
|
||||||
/** Deselect this tile from configuration. */
|
/** Deselect this tile from configuration. */
|
||||||
public void deselect(){
|
public void deselect(){
|
||||||
if(!headless && control.input.frag.config.getSelectedTile() == self()){
|
if(!headless && control.input.config.getSelected() == self()){
|
||||||
control.input.frag.config.hideConfig();
|
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.
|
* Called when another tile is tapped while this block is selected.
|
||||||
* @return whether this block should be deselected.
|
* @return whether this block should be deselected.
|
||||||
*/
|
*/
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
if(block.clearOnDoubleTap){
|
if(block.clearOnDoubleTap){
|
||||||
if(self() == other){
|
if(self() == other){
|
||||||
deselect();
|
deselect();
|
||||||
@@ -1482,6 +1482,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
return self() != other;
|
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
|
* Called when this block's config menu is closed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -144,8 +144,8 @@ public class OverlayRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//draw config selected block
|
//draw config selected block
|
||||||
if(input.frag.config.isShown()){
|
if(input.config.isShown()){
|
||||||
Building tile = input.frag.config.getSelectedTile();
|
Building tile = input.config.getSelected();
|
||||||
tile.drawConfigure();
|
tile.drawConfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
commandRect = true;
|
commandRect = true;
|
||||||
commandRectX = input.mouseWorldX();
|
commandRectX = input.mouseWorldX();
|
||||||
commandRectY = input.mouseWorldY();
|
commandRectY = input.mouseWorldY();
|
||||||
}else if(selected != null){
|
}else if(!checkConfigTap() && selected != null){
|
||||||
//only begin shooting if there's no cursor event
|
//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
|
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()){
|
&& !(tryStopMine(selected) || (!settings.getBool("doubletapmine") || selected == prevSelected && Time.timeSinceMillis(selectMillis) < 500) && tryBeginMine(selected)) && !Core.scene.hasKeyboard()){
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import arc.scene.event.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
@@ -39,6 +40,7 @@ import mindustry.world.meta.*;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public abstract class InputHandler implements InputProcessor, GestureListener{
|
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 Rect r1 = new Rect(), r2 = new Rect();
|
||||||
final static Seq<Unit> tmpUnits = new Seq<>(false);
|
final static Seq<Unit> tmpUnits = new Seq<>(false);
|
||||||
|
|
||||||
public final OverlayFragment frag = new OverlayFragment();
|
|
||||||
|
|
||||||
/** If true, there is a cutscene currently occurring in logic. */
|
/** If true, there is a cutscene currently occurring in logic. */
|
||||||
public boolean logicCutscene;
|
public boolean logicCutscene;
|
||||||
public Vec2 logicCamPan = new Vec2();
|
public Vec2 logicCamPan = new Vec2();
|
||||||
@@ -89,6 +89,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
private Seq<BuildPlan> plansOut = new Seq<>(BuildPlan.class);
|
private Seq<BuildPlan> plansOut = new Seq<>(BuildPlan.class);
|
||||||
private QuadTree<BuildPlan> playerPlanTree = new QuadTree<>(new Rect());
|
private QuadTree<BuildPlan> playerPlanTree = new QuadTree<>(new Rect());
|
||||||
|
|
||||||
|
public final BlockInventoryFragment inv;
|
||||||
|
public final BlockConfigFragment config;
|
||||||
|
|
||||||
|
private WidgetGroup group = new WidgetGroup();
|
||||||
|
|
||||||
private final Eachable<BuildPlan> allPlans = cons -> {
|
private final Eachable<BuildPlan> allPlans = cons -> {
|
||||||
player.unit().plans().each(cons);
|
player.unit().plans().each(cons);
|
||||||
selectPlans.each(cons);
|
selectPlans.each(cons);
|
||||||
@@ -101,6 +106,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
};
|
};
|
||||||
|
|
||||||
public InputHandler(){
|
public InputHandler(){
|
||||||
|
group.touchable = Touchable.childrenOnly;
|
||||||
|
inv = new BlockInventoryFragment();
|
||||||
|
config = new BlockConfigFragment();
|
||||||
|
|
||||||
Events.on(UnitDestroyEvent.class, e -> {
|
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)){
|
if(e.unit != null && e.unit.isPlayer() && e.unit.getPlayer().isLocal() && e.unit.type.weapons.contains(w -> w.bullet.killShooter)){
|
||||||
player.shooting = false;
|
player.shooting = false;
|
||||||
@@ -673,6 +682,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
if(state.isMenu()){
|
if(state.isMenu()){
|
||||||
controlledType = null;
|
controlledType = null;
|
||||||
logicCutscene = false;
|
logicCutscene = false;
|
||||||
|
config.forceHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1092,11 +1102,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
updateLine(x1, y1, tileX(getMouseX()), tileY(getMouseY()));
|
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. */
|
/** Handles tile tap events that are not platform specific. */
|
||||||
boolean tileTapped(@Nullable Building build){
|
boolean tileTapped(@Nullable Building build){
|
||||||
if(build == null){
|
if(build == null){
|
||||||
frag.inv.hide();
|
inv.hide();
|
||||||
frag.config.hideConfig();
|
config.hideConfig();
|
||||||
commandBuild = null;
|
commandBuild = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1108,21 +1122,21 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
}else if(build.block.configurable && build.interactable(player.team())){ //check if tapped block is configurable
|
}else if(build.block.configurable && build.interactable(player.team())){ //check if tapped block is configurable
|
||||||
consumed = true;
|
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
|
//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);
|
Sounds.click.at(build);
|
||||||
frag.config.showConfig(build);
|
config.showConfig(build);
|
||||||
}
|
}
|
||||||
//otherwise...
|
//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.
|
//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;
|
consumed = true;
|
||||||
frag.config.hideConfig();
|
config.hideConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frag.config.isShown()){
|
if(config.isShown()){
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1137,14 +1151,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
}else if(build.interactable(player.team()) && build.block.synthetic() && (!consumed || build.block.allowConfigInventory)){
|
}else if(build.interactable(player.team()) && build.block.synthetic() && (!consumed || build.block.allowConfigInventory)){
|
||||||
if(build.block.hasItems && build.items.total() > 0){
|
if(build.block.hasItems && build.items.total() > 0){
|
||||||
frag.inv.showFor(build);
|
inv.showFor(build);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
showedInventory = true;
|
showedInventory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!showedInventory){
|
if(!showedInventory){
|
||||||
frag.inv.hide();
|
inv.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
@@ -1300,7 +1314,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
public void remove(){
|
public void remove(){
|
||||||
Core.input.removeProcessor(this);
|
Core.input.removeProcessor(this);
|
||||||
frag.remove();
|
group.remove();
|
||||||
if(Core.scene != null){
|
if(Core.scene != null){
|
||||||
Table table = (Table)Core.scene.find("inputTable");
|
Table table = (Table)Core.scene.find("inputTable");
|
||||||
if(table != null){
|
if(table != null){
|
||||||
@@ -1334,7 +1348,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
uiGroup.toBack();
|
uiGroup.toBack();
|
||||||
buildUI(uiGroup);
|
buildUI(uiGroup);
|
||||||
|
|
||||||
frag.add();
|
group.setFillParent(true);
|
||||||
|
Vars.ui.hudGroup.addChildBefore(Core.scene.find("overlaymarker"), group);
|
||||||
|
|
||||||
|
inv.build(group);
|
||||||
|
config.build(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}else if(buildingTapped != null){
|
}else if(buildingTapped != null){
|
||||||
Call.buildingControlSelect(player, buildingTapped);
|
Call.buildingControlSelect(player, buildingTapped);
|
||||||
recentRespawnTimer = 1f;
|
recentRespawnTimer = 1f;
|
||||||
}else if(!tryBeginMine(cursor)){
|
}else if(!checkConfigTap() && !tryBeginMine(cursor)){
|
||||||
tileTapped(linked.build);
|
tileTapped(linked.build);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -636,8 +636,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
unitTapped = selectedUnit();
|
unitTapped = selectedUnit();
|
||||||
buildingTapped = selectedControlBuild();
|
buildingTapped = selectedControlBuild();
|
||||||
|
|
||||||
//prevent mining if placing/breaking blocks
|
//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);
|
tryBeginMine(cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,46 +12,34 @@ import mindustry.gen.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlockConfigFragment extends Fragment{
|
public class BlockConfigFragment{
|
||||||
Table table = new Table();
|
Table table = new Table();
|
||||||
Building configTile;
|
Building selected;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
table.visible = false;
|
table.visible = false;
|
||||||
parent.addChild(table);
|
parent.addChild(table);
|
||||||
|
|
||||||
//hacky way to hide block config when in menu
|
Events.on(ResetEvent.class, e -> forceHide());
|
||||||
//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 -> {
|
public void forceHide(){
|
||||||
table.visible = false;
|
table.visible = false;
|
||||||
configTile = null;
|
selected = null;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShown(){
|
public boolean isShown(){
|
||||||
return table.visible && configTile != null;
|
return table.visible && selected != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Building getSelectedTile(){
|
public Building getSelected(){
|
||||||
return configTile;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showConfig(Building tile){
|
public void showConfig(Building tile){
|
||||||
if(configTile != null) configTile.onConfigureClosed();
|
if(selected != null) selected.onConfigureClosed();
|
||||||
if(tile.configTapped()){
|
if(tile.configTapped()){
|
||||||
configTile = tile;
|
selected = tile;
|
||||||
|
|
||||||
table.visible = true;
|
table.visible = true;
|
||||||
table.clear();
|
table.clear();
|
||||||
@@ -62,16 +50,16 @@ public class BlockConfigFragment extends Fragment{
|
|||||||
Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out));
|
Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out));
|
||||||
|
|
||||||
table.update(() -> {
|
table.update(() -> {
|
||||||
if(configTile != null && configTile.shouldHideConfigure(player)){
|
if(selected != null && selected.shouldHideConfigure(player)){
|
||||||
hideConfig();
|
hideConfig();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.setOrigin(Align.center);
|
table.setOrigin(Align.center);
|
||||||
if(configTile == null || configTile.block == Blocks.air || !configTile.isValid()){
|
if(selected == null || selected.block == Blocks.air || !selected.isValid()){
|
||||||
hideConfig();
|
hideConfig();
|
||||||
}else{
|
}else{
|
||||||
configTile.updateTableAlign(table);
|
selected.updateTableAlign(table);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -83,8 +71,8 @@ public class BlockConfigFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hideConfig(){
|
public void hideConfig(){
|
||||||
if(configTile != null) configTile.onConfigureClosed();
|
if(selected != null) selected.onConfigureClosed();
|
||||||
configTile = null;
|
selected = null;
|
||||||
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false));
|
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlockInventoryFragment extends Fragment{
|
public class BlockInventoryFragment{
|
||||||
private static final float holdWithdraw = 20f;
|
private static final float holdWithdraw = 20f;
|
||||||
private static final float holdShrink = 120f;
|
private static final float holdShrink = 120f;
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
Events.on(WorldLoadEvent.class, e -> hide());
|
Events.on(WorldLoadEvent.class, e -> hide());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
table.name = "inventory";
|
table.name = "inventory";
|
||||||
table.setTransform(true);
|
table.setTransform(true);
|
||||||
|
|||||||
@@ -37,12 +37,6 @@ public class ChatFragment extends Table{
|
|||||||
private Seq<String> history = new Seq<>();
|
private Seq<String> history = new Seq<>();
|
||||||
private int historyPos = 0;
|
private int historyPos = 0;
|
||||||
private int scrollPos = 0;
|
private int scrollPos = 0;
|
||||||
private Fragment container = new Fragment(){
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
|
||||||
scene.add(ChatFragment.this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ChatFragment(){
|
public ChatFragment(){
|
||||||
super();
|
super();
|
||||||
@@ -89,8 +83,8 @@ public class ChatFragment extends Table{
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fragment container(){
|
public void build(Group parent){
|
||||||
return container;
|
scene.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMessages(){
|
public void clearMessages(){
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import arc.scene.*;
|
|||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
|
|
||||||
/** Fades in a black overlay.*/
|
/** Fades in a black overlay.*/
|
||||||
public class FadeInFragment extends Fragment{
|
public class FadeInFragment{
|
||||||
private static final float duration = 40f;
|
private static final float duration = 40f;
|
||||||
float time = 0f;
|
float time = 0f;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
parent.addChild(new Element(){
|
parent.addChild(new Element(){
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package mindustry.ui.fragments;
|
|
||||||
|
|
||||||
import arc.scene.*;
|
|
||||||
|
|
||||||
public abstract class Fragment{
|
|
||||||
public abstract void build(Group parent);
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,7 @@ import mindustry.world.meta.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
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 Boolp isTutorial = () -> Vars.state.rules.sector == SectorPresets.groundZero.sector;
|
||||||
private static final float foutTime = 0.6f;
|
private static final float foutTime = 0.6f;
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ public class HintsFragment extends Fragment{
|
|||||||
ObjectSet<Block> placedBlocks = new ObjectSet<>();
|
ObjectSet<Block> placedBlocks = new ObjectSet<>();
|
||||||
Table last;
|
Table last;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
group.setFillParent(true);
|
group.setFillParent(true);
|
||||||
group.touchable = Touchable.childrenOnly;
|
group.touchable = Touchable.childrenOnly;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import mindustry.ui.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.gen.Tex.*;
|
import static mindustry.gen.Tex.*;
|
||||||
|
|
||||||
public class HudFragment extends Fragment{
|
public class HudFragment{
|
||||||
private static final float dsize = 65f, pauseHeight = 36f;
|
private static final float dsize = 65f, pauseHeight = 36f;
|
||||||
|
|
||||||
public final PlacementFragment blockfrag = new PlacementFragment();
|
public final PlacementFragment blockfrag = new PlacementFragment();
|
||||||
@@ -47,7 +47,6 @@ public class HudFragment extends Fragment{
|
|||||||
private Table lastUnlockLayout;
|
private Table lastUnlockLayout;
|
||||||
private long lastToast;
|
private long lastToast;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
|
|
||||||
//warn about guardian/boss waves
|
//warn about guardian/boss waves
|
||||||
|
|||||||
@@ -12,14 +12,13 @@ import arc.scene.ui.layout.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
|
||||||
public class LoadingFragment extends Fragment{
|
public class LoadingFragment{
|
||||||
private Table table;
|
private Table table;
|
||||||
private TextButton button;
|
private TextButton button;
|
||||||
private Bar bar;
|
private Bar bar;
|
||||||
private Label nameLabel;
|
private Label nameLabel;
|
||||||
private float progValue;
|
private float progValue;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
parent.fill(t -> {
|
parent.fill(t -> {
|
||||||
//rect must fill screen completely.
|
//rect must fill screen completely.
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ import mindustry.ui.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.gen.Tex.*;
|
import static mindustry.gen.Tex.*;
|
||||||
|
|
||||||
public class MenuFragment extends Fragment{
|
public class MenuFragment{
|
||||||
private Table container, submenu;
|
private Table container, submenu;
|
||||||
private Button currentMenu;
|
private Button currentMenu;
|
||||||
private MenuRenderer renderer;
|
private MenuRenderer renderer;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
renderer = new MenuRenderer();
|
renderer = new MenuRenderer();
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ import mindustry.ui.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MinimapFragment extends Fragment{
|
public class MinimapFragment{
|
||||||
private boolean shown;
|
private boolean shown;
|
||||||
float panx, pany, zoom = 1f, lastZoom = -1;
|
float panx, pany, zoom = 1f, lastZoom = -1;
|
||||||
private float baseSize = Scl.scl(5f);
|
private float baseSize = Scl.scl(5f);
|
||||||
public Element elem;
|
public Element elem;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
elem = parent.fill((x, y, w, h) -> {
|
elem = parent.fill((x, y, w, h) -> {
|
||||||
w = Core.graphics.getWidth();
|
w = Core.graphics.getWidth();
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@ import mindustry.world.blocks.ConstructBlock.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class PlacementFragment extends Fragment{
|
public class PlacementFragment{
|
||||||
final int rowWidth = 4;
|
final int rowWidth = 4;
|
||||||
|
|
||||||
public Category currentCategory = Category.distribution;
|
public Category currentCategory = Category.distribution;
|
||||||
@@ -229,7 +229,6 @@ public class PlacementFragment extends Fragment{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
parent.fill(full -> {
|
parent.fill(full -> {
|
||||||
toggler = full;
|
toggler = full;
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ import mindustry.ui.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class PlayerListFragment extends Fragment{
|
public class PlayerListFragment{
|
||||||
public Table content = new Table().marginRight(13f).marginLeft(13f);
|
public Table content = new Table().marginRight(13f).marginLeft(13f);
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
private Interval timer = new Interval();
|
private Interval timer = new Interval();
|
||||||
private TextField search;
|
private TextField search;
|
||||||
private Seq<Player> players = new Seq<>();
|
private Seq<Player> players = new Seq<>();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
content.name = "players";
|
content.name = "players";
|
||||||
parent.fill(cont -> {
|
parent.fill(cont -> {
|
||||||
|
|||||||
@@ -32,12 +32,6 @@ public class ScriptConsoleFragment extends Table{
|
|||||||
private Seq<String> history = new Seq<>();
|
private Seq<String> history = new Seq<>();
|
||||||
private int historyPos = 0;
|
private int historyPos = 0;
|
||||||
private int scrollPos = 0;
|
private int scrollPos = 0;
|
||||||
private Fragment container = new Fragment(){
|
|
||||||
@Override
|
|
||||||
public void build(Group parent){
|
|
||||||
scene.add(ScriptConsoleFragment.this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public ScriptConsoleFragment(){
|
public ScriptConsoleFragment(){
|
||||||
setFillParent(true);
|
setFillParent(true);
|
||||||
@@ -82,8 +76,8 @@ public class ScriptConsoleFragment extends Table{
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fragment container(){
|
public void build(Group parent){
|
||||||
return container;
|
scene.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMessages(){
|
public void clearMessages(){
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ItemSelection{
|
|||||||
if(!item.unlockedNow() || (item instanceof Item checkVisible && state.rules.hiddenBuildItems.contains(checkVisible))) continue;
|
if(!item.unlockedNow() || (item instanceof Item checkVisible && state.rules.hiddenBuildItems.contains(checkVisible))) continue;
|
||||||
|
|
||||||
ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> {
|
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();
|
}).group(group).tooltip(item.localizedName).get();
|
||||||
button.changed(() -> consumer.get(button.isChecked() ? item : null));
|
button.changed(() -> consumer.get(button.isChecked() ? item : null));
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(item.uiIcon);
|
button.getStyle().imageUp = new TextureRegionDrawable(item.uiIcon);
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
//reverse connection
|
//reverse connection
|
||||||
if(other instanceof ItemBridgeBuild b && b.link == pos()){
|
if(other instanceof ItemBridgeBuild b && b.link == pos()){
|
||||||
configure(other.pos());
|
configure(other.pos());
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ public class MassDriver extends Block{
|
|||||||
Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent);
|
Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent);
|
||||||
|
|
||||||
//check if a mass driver is selected while placing this driver
|
//check if a mass driver is selected while placing this driver
|
||||||
if(!control.input.frag.config.isShown()) return;
|
if(!control.input.config.isShown()) return;
|
||||||
Building selected = control.input.frag.config.getSelectedTile();
|
Building selected = control.input.config.getSelected();
|
||||||
if(selected == null || selected.block != this || !selected.within(x * tilesize, y * tilesize, range)) return;
|
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
|
//if so, draw a dotted line towards it while it is in range
|
||||||
@@ -250,7 +250,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
if(link == -1) deselect();
|
if(link == -1) deselect();
|
||||||
configure(-1);
|
configure(-1);
|
||||||
|
|||||||
@@ -571,7 +571,7 @@ public class LogicBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
if(this == other || !accessible()){
|
if(this == other || !accessible()){
|
||||||
deselect();
|
deselect();
|
||||||
return false;
|
return false;
|
||||||
@@ -582,7 +582,7 @@ public class LogicBlock extends Block{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onConfigureTileTapped(other);
|
return super.onConfigureBuildTapped(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||||||
Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent);
|
Drawf.dashCircle(x * tilesize, y * tilesize, range, Pal.accent);
|
||||||
|
|
||||||
//check if a mass driver is selected while placing this driver
|
//check if a mass driver is selected while placing this driver
|
||||||
if(!control.input.frag.config.isShown()) return;
|
if(!control.input.config.isShown()) return;
|
||||||
Building selected = control.input.frag.config.getSelectedTile();
|
Building selected = control.input.config.getSelected();
|
||||||
if(selected == null || selected.block != this || !selected.within(x * tilesize, y * tilesize, range)) return;
|
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
|
//if so, draw a dotted line towards it while it is in range
|
||||||
@@ -431,7 +431,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
if(link == -1) deselect();
|
if(link == -1) deselect();
|
||||||
configure(-1);
|
configure(-1);
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Building other){
|
public boolean onConfigureBuildTapped(Building other){
|
||||||
if(linkValid(this, other)){
|
if(linkValid(this, other)){
|
||||||
configure(other.pos());
|
configure(other.pos());
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user