Bugfixes / Sorter item memory
This commit is contained in:
@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.game.EventType.WorldLoadGraphicsEvent;
|
import io.anuke.mindustry.game.EventType.WorldLoadGraphicsEvent;
|
||||||
@@ -33,7 +34,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Category currentCategory = Category.turret;
|
Category currentCategory = Category.turret;
|
||||||
Block hovered, lastDisplay;
|
Block hovered, lastDisplay;
|
||||||
Tile hoverTile;
|
Tile hoverTile;
|
||||||
Table blockTable, toggler;
|
Table blockTable, toggler, topTable;
|
||||||
boolean shown = true;
|
boolean shown = true;
|
||||||
|
|
||||||
public PlacementFragment(){
|
public PlacementFragment(){
|
||||||
@@ -106,6 +107,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
|
|
||||||
//top table with hover info
|
//top table with hover info
|
||||||
frame.table("clear", top -> {
|
frame.table("clear", top -> {
|
||||||
|
topTable = top;
|
||||||
top.add(new Table()).growX().update(topTable -> {
|
top.add(new Table()).growX().update(topTable -> {
|
||||||
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
|
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
|
||||||
(tileDisplayBlock() != null && lastDisplay == tileDisplayBlock())) return;
|
(tileDisplayBlock() != null && lastDisplay == tileDisplayBlock())) return;
|
||||||
@@ -194,8 +196,10 @@ public class PlacementFragment extends Fragment{
|
|||||||
Block getSelected(){
|
Block getSelected(){
|
||||||
Block toDisplay = null;
|
Block toDisplay = null;
|
||||||
|
|
||||||
|
Vector2 v = topTable.stageToLocalCoordinates(Graphics.mouse());
|
||||||
|
|
||||||
//setup hovering tile
|
//setup hovering tile
|
||||||
if(!ui.hasMouse()){
|
if(!ui.hasMouse() && topTable.hit(v.x, v.y, false) == null){
|
||||||
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
hoverTile = tile.target();
|
hoverTile = tile.target();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import io.anuke.annotations.Annotations.Loc;
|
|||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.gen.Call;
|
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -13,13 +12,17 @@ import io.anuke.mindustry.world.meta.BlockGroup;
|
|||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.mindustry.gen.Call;
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
import static io.anuke.mindustry.Vars.threads;
|
||||||
|
|
||||||
public class Sorter extends Block implements SelectionTrait{
|
public class Sorter extends Block implements SelectionTrait{
|
||||||
|
private static Item lastItem;
|
||||||
|
|
||||||
public Sorter(String name){
|
public Sorter(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -35,6 +38,13 @@ public class Sorter extends Block implements SelectionTrait{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playerPlaced(Tile tile){
|
||||||
|
if(lastItem != null){
|
||||||
|
threads.runDelay(() -> Call.setSorterItem(null, tile, lastItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||||
public static void setSorterItem(Player player, Tile tile, Item item){
|
public static void setSorterItem(Player player, Tile tile, Item item){
|
||||||
SorterEntity entity = tile.entity();
|
SorterEntity entity = tile.entity();
|
||||||
@@ -108,7 +118,10 @@ public class Sorter extends Block implements SelectionTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void buildTable(Tile tile, Table table){
|
public void buildTable(Tile tile, Table table){
|
||||||
SorterEntity entity = tile.entity();
|
SorterEntity entity = tile.entity();
|
||||||
buildItemTable(table, () -> entity.sortItem, item -> Call.setSorterItem(null, tile, item));
|
buildItemTable(table, () -> entity.sortItem, item -> {
|
||||||
|
lastItem = item;
|
||||||
|
Call.setSorterItem(null, tile, item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user