Massive amount of refactoring for local multiplayer, annotations
This commit is contained in:
@@ -7,8 +7,8 @@ import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.player;
|
||||
import static io.anuke.mindustry.Vars.playerColors;
|
||||
import static io.anuke.mindustry.Vars.players;
|
||||
|
||||
public class ColorPickDialog extends Dialog{
|
||||
private Consumer<Color> cons;
|
||||
@@ -29,7 +29,7 @@ public class ColorPickDialog extends Dialog{
|
||||
cons.accept(color);
|
||||
hide();
|
||||
}).size(44, 48).pad(0).padBottom(-5.1f).get();
|
||||
button.setChecked(player.getColor().equals(color));
|
||||
button.setChecked(players[0].getColor().equals(color));
|
||||
button.getStyle().imageUpColor = color;
|
||||
|
||||
if(i%4 == 3){
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -11,7 +12,7 @@ import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.player;
|
||||
import static io.anuke.mindustry.Vars.players;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class HostDialog extends FloatingDialog{
|
||||
@@ -20,13 +21,15 @@ public class HostDialog extends FloatingDialog{
|
||||
public HostDialog(){
|
||||
super("$text.hostserver");
|
||||
|
||||
Player player = players[0];
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().table(t -> {
|
||||
t.add("$text.name").padRight(10);
|
||||
t.addField(Settings.getString("name"), text -> {
|
||||
if(text.isEmpty()) return;
|
||||
Vars.player.name = text;
|
||||
player.name = text;
|
||||
Settings.put("name", text);
|
||||
Settings.save();
|
||||
ui.listfrag.rebuild();
|
||||
|
||||
@@ -3,7 +3,9 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.net.Host;
|
||||
@@ -21,7 +23,7 @@ import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.player;
|
||||
import static io.anuke.mindustry.Vars.players;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class JoinDialog extends FloatingDialog {
|
||||
@@ -31,6 +33,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
Table local = new Table();
|
||||
Table remote = new Table();
|
||||
Table hosts = new Table();
|
||||
Json json = new Json();
|
||||
float w = 500;
|
||||
|
||||
public JoinDialog(){
|
||||
@@ -187,6 +190,8 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
|
||||
void setup(){
|
||||
Player player = players[0];
|
||||
|
||||
hosts.clear();
|
||||
|
||||
hosts.add(remote).growX();
|
||||
@@ -205,7 +210,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
t.add("$text.name").padRight(10);
|
||||
t.addField(Settings.getString("name"), text -> {
|
||||
if(text.isEmpty()) return;
|
||||
Vars.player.name = text;
|
||||
player.name = text;
|
||||
Settings.put("name", text);
|
||||
Settings.save();
|
||||
}).grow().pad(8).get().setMaxLength(40);
|
||||
@@ -304,39 +309,27 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
|
||||
private void loadServers(){
|
||||
String h = Settings.getString("servers");
|
||||
String[] list = h.split("\\|\\|\\|");
|
||||
for(String fname : list){
|
||||
if(fname.isEmpty()) continue;
|
||||
String[] split = fname.split(":");
|
||||
String host = split[0];
|
||||
int port = Strings.parseInt(split[1]);
|
||||
|
||||
if(port != Integer.MIN_VALUE) servers.add(new Server(host, port));
|
||||
}
|
||||
String h = Settings.getString("serverlist","{}");
|
||||
servers = json.fromJson(Array.class, h);
|
||||
}
|
||||
|
||||
private void saveServers(){
|
||||
StringBuilder out = new StringBuilder();
|
||||
for(Server server : servers){
|
||||
out.append(server.ip);
|
||||
out.append(":");
|
||||
out.append(server.port);
|
||||
out.append("|||");
|
||||
}
|
||||
Settings.putString("servers", out.toString());
|
||||
Settings.putString("serverlist", json.toJson(servers));
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
private class Server{
|
||||
public String ip;
|
||||
public int port;
|
||||
public Host host;
|
||||
public Table content;
|
||||
static class Server{
|
||||
String ip;
|
||||
int port;
|
||||
|
||||
public Server(String ip, int port){
|
||||
transient Host host;
|
||||
transient Table content;
|
||||
|
||||
Server(String ip, int port){
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
Server(){}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
if(control.getSaves().getCurrent() == null ||
|
||||
!control.getSaves().getCurrent().isAutosave()){
|
||||
state.set(State.menu);
|
||||
control.tutorial().reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
@@ -12,7 +13,7 @@ import static io.anuke.mindustry.Vars.state;
|
||||
public class BackgroundFragment implements Fragment {
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
Draw.color();
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
@@ -17,9 +18,9 @@ public class BlockConfigFragment implements Fragment {
|
||||
private Tile configTile;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
table = new Table();
|
||||
Core.scene.add(table);
|
||||
parent.addChild(table);
|
||||
}
|
||||
|
||||
public boolean isShown(){
|
||||
@@ -41,7 +42,7 @@ public class BlockConfigFragment implements Fragment {
|
||||
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
table.update(()->{
|
||||
table.update(() -> {
|
||||
table.setOrigin(Align.center);
|
||||
Vector2 pos = Graphics.screen(tile.drawx(), tile.drawy());
|
||||
table.setPosition(pos.x, pos.y, Align.center);
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.IntSet;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -16,6 +18,7 @@ import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.function.BooleanProvider;
|
||||
import io.anuke.ucore.function.Callable;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.event.HandCursorListener;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
@@ -29,12 +32,20 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class BlockInventoryFragment implements Fragment {
|
||||
private Table table;
|
||||
private boolean shown;
|
||||
private Tile tile;
|
||||
private InputHandler input;
|
||||
|
||||
public BlockInventoryFragment(InputHandler input){
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
table = new Table();
|
||||
table.setVisible(() -> !state.is(State.menu));
|
||||
table.setVisible(() -> !state.is(State.menu) && shown);
|
||||
parent.addChild(table);
|
||||
}
|
||||
|
||||
public void showFor(Tile t){
|
||||
@@ -44,18 +55,20 @@ public class BlockInventoryFragment implements Fragment {
|
||||
}
|
||||
|
||||
public void hide(){
|
||||
shown = false;
|
||||
table.clear();
|
||||
table.remove();
|
||||
table.setTouchable(Touchable.disabled);
|
||||
table.update(() -> {});
|
||||
tile = null;
|
||||
}
|
||||
|
||||
private void rebuild(){
|
||||
Player player = input.player;
|
||||
|
||||
shown = true;
|
||||
IntSet container = new IntSet();
|
||||
|
||||
table.clear();
|
||||
if(table.getParent() == null) Core.scene.add(table);
|
||||
table.background("clear");
|
||||
table.setTouchable(Touchable.enabled);
|
||||
table.update(() -> {
|
||||
@@ -137,6 +150,8 @@ public class BlockInventoryFragment implements Fragment {
|
||||
}
|
||||
|
||||
private void move(TextureRegion region, Vector2 v, Callable c, Color color){
|
||||
Player player = input.player;
|
||||
|
||||
Vector2 tv = Graphics.screen(player.x + Angles.trnsx(player.rotation + 180f, 5f), player.y + Angles.trnsy(player.rotation + 180f, 5f));
|
||||
float tx = tv.x, ty = tv.y;
|
||||
float dur = 40f / 60f;
|
||||
|
||||
@@ -19,6 +19,7 @@ import io.anuke.mindustry.world.BlockStats;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
@@ -40,8 +41,8 @@ public class BlocksFragment implements Fragment{
|
||||
private Recipe hoveredDescriptionRecipe;
|
||||
private IntSet itemset = new IntSet();
|
||||
|
||||
public void build(){
|
||||
InputHandler input = control.input();
|
||||
public void build(Group parent){
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
new table(){{
|
||||
abottom();
|
||||
@@ -180,10 +181,9 @@ public class BlocksFragment implements Fragment{
|
||||
table.add(image).size(size + 8);
|
||||
|
||||
image.update(() -> {
|
||||
boolean canPlace = !control.tutorial().active() || control.tutorial().canPlace();
|
||||
boolean has = (state.inventory.hasItems(r.requirements)) && canPlace;
|
||||
boolean has = (state.inventory.hasItems(r.requirements));
|
||||
image.setChecked(input.recipe == r);
|
||||
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
||||
image.setTouchable(Touchable.enabled);
|
||||
for(Element e : istack.getChildren()) e.setColor(has ? Color.WHITE : Hue.lightness(0.33f));
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.Label.LabelStyle;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
@@ -21,13 +22,13 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.players;
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.ucore.core.Core.scene;
|
||||
import static io.anuke.ucore.core.Core.skin;
|
||||
|
||||
public class ChatFragment extends Table implements Fragment{
|
||||
private final static int messagesShown = 10;
|
||||
private final static int maxLength = 150;
|
||||
private Array<ChatMessage> messages = new Array<>();
|
||||
private float fadetime;
|
||||
private boolean chatOpen = false;
|
||||
@@ -79,7 +80,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
scene.add(this);
|
||||
}
|
||||
|
||||
@@ -95,12 +96,12 @@ public class ChatFragment extends Table implements Fragment{
|
||||
fieldlabel.setStyle(fieldlabel.getStyle());
|
||||
|
||||
chatfield = new TextField("", new TextField.TextFieldStyle(skin.get(TextField.TextFieldStyle.class)));
|
||||
chatfield.setTextFieldFilter((field, c) -> field.getText().length() < maxLength);
|
||||
chatfield.setTextFieldFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
|
||||
chatfield.getStyle().background = null;
|
||||
chatfield.getStyle().fontColor = Color.WHITE;
|
||||
chatfield.getStyle().font = skin.getFont("default-font-chat");
|
||||
chatfield.setStyle(chatfield.getStyle());
|
||||
Platform.instance.addDialog(chatfield, maxLength);
|
||||
Platform.instance.addDialog(chatfield, Vars.maxTextLength);
|
||||
|
||||
bottom().left().marginBottom(offsety).marginLeft(offsetx*2).add(fieldlabel).padBottom(4f);
|
||||
|
||||
@@ -167,7 +168,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
if(message.replaceAll(" ", "").isEmpty()) return;
|
||||
|
||||
history.insert(1, message);
|
||||
NetEvents.handleSendMessage(message);
|
||||
NetEvents.handleSendMessage(players[0], message);
|
||||
}
|
||||
|
||||
public void toggle(){
|
||||
|
||||
@@ -9,9 +9,9 @@ import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
@@ -41,7 +41,10 @@ public class DebugFragment implements Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(){
|
||||
public void build(Group parent){
|
||||
|
||||
Player player = players[0];
|
||||
|
||||
new table(){{
|
||||
visible(() -> debug);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.ucore.scene.Group;
|
||||
|
||||
public interface Fragment{
|
||||
public void build();
|
||||
public void build(Group parent);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
@@ -36,7 +37,7 @@ public class HudFragment implements Fragment{
|
||||
private float dsize = 58;
|
||||
private float isize = 40;
|
||||
|
||||
public void build(){
|
||||
public void build(Group parent){
|
||||
|
||||
//menu at top left
|
||||
new table(){{
|
||||
@@ -116,13 +117,6 @@ public class HudFragment implements Fragment{
|
||||
|
||||
}}.end();
|
||||
|
||||
//tutorial ui table
|
||||
new table(){{
|
||||
control.tutorial().buildUI(this);
|
||||
|
||||
visible(() -> control.tutorial().active());
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
visible(() -> !state.is(State.menu));
|
||||
atop();
|
||||
@@ -174,17 +168,6 @@ public class HudFragment implements Fragment{
|
||||
});
|
||||
}}.end();
|
||||
|
||||
//respawn table
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
|
||||
new label(()->"[orange]"+Bundles.get("text.respawn")+" " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
|
||||
|
||||
visible(()->false);
|
||||
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
abottom();
|
||||
visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||
@@ -193,7 +176,7 @@ public class HudFragment implements Fragment{
|
||||
|
||||
}}.end();
|
||||
|
||||
blockfrag.build();
|
||||
blockfrag.build(Core.scene.getRoot());
|
||||
}
|
||||
|
||||
private void toggleMenus(){
|
||||
@@ -236,7 +219,7 @@ public class HudFragment implements Fragment{
|
||||
|
||||
new label(()-> state.enemies > 0 ?
|
||||
getEnemiesRemaining() :
|
||||
(control.tutorial().active() || state.mode.disableWaveTimer) ? "$text.waiting"
|
||||
(state.mode.disableWaveTimer) ? "$text.waiting"
|
||||
: Bundles.format("text.wave.waiting", (int) (state.wavetime / 60f)))
|
||||
.minWidth(126).padLeft(-6).left();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
@@ -11,7 +12,7 @@ public class LoadingFragment implements Fragment {
|
||||
private Table table;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
|
||||
table = new table("loadDim"){{
|
||||
touchable(Touchable.enabled);
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.ui.MenuButton;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
@@ -14,7 +15,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment implements Fragment{
|
||||
|
||||
public void build(){
|
||||
public void build(Group parent){
|
||||
new table(){{
|
||||
visible(() -> state.is(State.menu));
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
|
||||
public class OverlayFragment implements Fragment{
|
||||
public final BlockInventoryFragment inv;
|
||||
public final ToolFragment tool;
|
||||
public final BlockConfigFragment config;
|
||||
|
||||
private Group group = new Group();
|
||||
|
||||
public OverlayFragment(InputHandler input){
|
||||
tool = new ToolFragment(input);
|
||||
inv = new BlockInventoryFragment(input);
|
||||
config = new BlockConfigFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
group.setFillParent(true);
|
||||
parent.addChild(group);
|
||||
|
||||
inv.build(group);
|
||||
tool.build(group);
|
||||
config.build(group);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
group.remove();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
@@ -28,10 +29,10 @@ public class PlacementFragment implements Fragment{
|
||||
Table breaktable, next, container;
|
||||
Label modelabel;
|
||||
|
||||
public void build(){
|
||||
public void build(Group parent){
|
||||
if(!mobile) return;
|
||||
|
||||
InputHandler input = control.input();
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
float s = 50f;
|
||||
float translation = Unit.dp.scl(58f);
|
||||
@@ -130,7 +131,7 @@ public class PlacementFragment implements Fragment{
|
||||
defaults().padBottom(-5.5f);
|
||||
|
||||
ImageButton button = new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
|
||||
control.input().resetCursor();
|
||||
input.resetCursor();
|
||||
input.breakMode = mode;
|
||||
input.lastBreakMode = mode;
|
||||
if (!mode.both){
|
||||
@@ -183,7 +184,7 @@ public class PlacementFragment implements Fragment{
|
||||
if (!mode.shown || mode.delete) continue;
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
|
||||
control.input().resetCursor();
|
||||
input.resetCursor();
|
||||
input.placeMode = mode;
|
||||
input.lastPlaceMode = mode;
|
||||
modeText(Bundles.format("text.mode.place", mode.toString()));
|
||||
@@ -215,6 +216,8 @@ public class PlacementFragment implements Fragment{
|
||||
}
|
||||
|
||||
private void toggle(boolean show){
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
float dur = 0.3f;
|
||||
Interpolation in = Interpolation.pow3Out;
|
||||
|
||||
@@ -223,8 +226,8 @@ public class PlacementFragment implements Fragment{
|
||||
breaktable.getParent().swapActor(breaktable, next);
|
||||
|
||||
if(!show){
|
||||
control.input().breakMode = PlaceMode.none;
|
||||
if(control.input().placeMode.delete) control.input().placeMode = PlaceMode.none;
|
||||
input.breakMode = PlaceMode.none;
|
||||
if(input.placeMode.delete) input.placeMode = PlaceMode.none;
|
||||
breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false));
|
||||
}else{
|
||||
shown = true;
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
@@ -32,7 +33,7 @@ public class PlayerListFragment implements Fragment{
|
||||
ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
||||
|
||||
@Override
|
||||
public void build(){
|
||||
public void build(Group parent){
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
margin(14f);
|
||||
@@ -124,7 +125,7 @@ public class PlayerListFragment implements Fragment{
|
||||
|
||||
button.addImage("icon-admin").size(14*2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5);
|
||||
|
||||
if((Net.server() || Vars.player.isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
|
||||
if((Net.server() || players[0].isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
|
||||
button.add().growY();
|
||||
|
||||
float bs = (h + 14)/2f;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class PlayerMenuFragment implements Fragment {
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
public void build(Group parent) {
|
||||
/*
|
||||
new table(){{
|
||||
new table("clear"){{
|
||||
|
||||
@@ -9,16 +9,22 @@ import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ToolFragment implements Fragment{
|
||||
private Table tools;
|
||||
private InputHandler input;
|
||||
|
||||
public int px, py, px2, py2;
|
||||
public boolean confirming;
|
||||
|
||||
public void build(){
|
||||
InputHandler input = control.input();
|
||||
|
||||
|
||||
public ToolFragment(InputHandler input){
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
float isize = 14*3;
|
||||
|
||||
tools = new Table();
|
||||
@@ -38,15 +44,13 @@ public class ToolFragment implements Fragment{
|
||||
|
||||
tools.addImageButton("icon-check", isize, () -> {
|
||||
if(input.placeMode == PlaceMode.areaDelete && confirming){
|
||||
input.placeMode.released(px, py, px2, py2);
|
||||
input.placeMode.released(input, px, py, px2, py2);
|
||||
confirming = false;
|
||||
}else{
|
||||
input.placeMode.tapped(control.input().getBlockX(), control.input().getBlockY());
|
||||
input.placeMode.tapped(input, input.getBlockX(), input.getBlockY());
|
||||
}
|
||||
});
|
||||
|
||||
Core.scene.add(tools);
|
||||
|
||||
tools.setVisible(() ->
|
||||
!state.is(State.menu) && mobile && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) &&
|
||||
input.placeMode == PlaceMode.cursor) || confirming)
|
||||
@@ -58,13 +62,16 @@ public class ToolFragment implements Fragment{
|
||||
tools.setPosition(v.x, v.y, Align.top);
|
||||
|
||||
}else{
|
||||
tools.setPosition(control.input().getCursorX(),
|
||||
Gdx.graphics.getHeight() - control.input().getCursorY() - 15*Core.cameraScale, Align.top);
|
||||
tools.setPosition(input.getCursorX(),
|
||||
Gdx.graphics.getHeight() - input.getCursorY() - 15*Core.cameraScale, Align.top);
|
||||
}
|
||||
|
||||
if(input.placeMode != PlaceMode.areaDelete){
|
||||
confirming = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
parent.addChild(tools);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user