Fixed many placement mode bugs

This commit is contained in:
Anuken
2018-03-15 14:25:45 -04:00
parent ae89a004a6
commit 2037ebaaba
6 changed files with 28 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Thu Mar 15 12:52:13 EDT 2018 #Thu Mar 15 14:23:19 EDT 2018
version=release version=release
androidBuildCode=388 androidBuildCode=412
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=custom build build=custom build

View File

@@ -408,7 +408,8 @@ public class Renderer extends RendererModule{
if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android) if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android)
&& control.input().drawPlace())){ && control.input().drawPlace())){
input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), control.input().getBlockEndX(), control.input().getBlockEndY()); input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(),
control.input().getBlockEndX(), control.input().getBlockEndY());
Lines.stroke(1f); Lines.stroke(1f);
Draw.color(Color.SCARLET); Draw.color(Color.SCARLET);
@@ -424,9 +425,15 @@ public class Renderer extends RendererModule{
if(input.breakMode == PlaceMode.holdDelete) if(input.breakMode == PlaceMode.holdDelete)
input.breakMode.draw(tilex, tiley, 0, 0); input.breakMode.draw(tilex, tiley, 0, 0);
}else if(input.breakMode.delete && control.input().drawPlace() && input.recipe == null){ }else if(input.breakMode.delete && control.input().drawPlace()
input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(), && (input.recipe == null || !state.inventory.hasItems(input.recipe.requirements))
control.input().getBlockEndX(), control.input().getBlockEndY()); && (input.placeMode.delete || input.breakMode.both)){
if(input.breakMode == PlaceMode.holdDelete)
input.breakMode.draw(tilex, tiley, 0, 0);
else
input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(),
control.input().getBlockEndX(), control.input().getBlockEndY());
} }
if(ui.toolfrag.confirming){ if(ui.toolfrag.confirming){

View File

@@ -20,9 +20,9 @@ public class AndroidInput extends InputHandler{
public float lmousex, lmousey; public float lmousex, lmousey;
public float mousex, mousey; public float mousex, mousey;
public boolean brokeBlock = false; public boolean brokeBlock = false;
public boolean placing = false;
private boolean enableHold = false; private boolean enableHold = false;
private boolean placing = false;
private float warmup; private float warmup;
private float warmupDelay = 20; private float warmupDelay = 20;
@@ -48,6 +48,7 @@ public class AndroidInput extends InputHandler{
}else if(pointer == 0 && !breakMode.pan && breaking() && drawPlace()){ }else if(pointer == 0 && !breakMode.pan && breaking() && drawPlace()){
breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
} }
placing = false; placing = false;
return false; return false;
} }

View File

@@ -47,7 +47,7 @@ public class GestureHandler extends GestureAdapter{
if(control.showCursor() && !Inputs.keyDown("select")) return false; if(control.showCursor() && !Inputs.keyDown("select")) return false;
if(!control.showCursor() && !(control.input().recipe != null if(!control.showCursor() && !(control.input().recipe != null
&& state.inventory.hasItems(control.input().recipe.requirements) && control.input().placeMode.lockCamera) && && control.input().placeMode.lockCamera) &&
!(control.input().recipe == null && control.input().breakMode.lockCamera)){ !(control.input().recipe == null && control.input().breakMode.lockCamera)){
float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale; float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale;
player.x -= dx; player.x -= dx;

View File

@@ -164,7 +164,6 @@ public enum PlaceMode{
} }
public void released(int tilex, int tiley, int endx, int endy){ public void released(int tilex, int tiley, int endx, int endy){
process(tilex, tiley, endx, endy); process(tilex, tiley, endx, endy);
tilex = this.tilex; tiley = this.tiley; tilex = this.tilex; tiley = this.tiley;
endx = this.endx; endy = this.endy; endx = this.endx; endy = this.endy;

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.AndroidInput;
import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.input.PlaceMode; import io.anuke.mindustry.input.PlaceMode;
import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Core;
@@ -128,7 +129,7 @@ public class PlacementFragment implements Fragment{
defaults().padBottom(-5.5f); defaults().padBottom(-5.5f);
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { ImageButton button = new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
control.input().resetCursor(); control.input().resetCursor();
input.breakMode = mode; input.breakMode = mode;
input.lastBreakMode = mode; input.lastBreakMode = mode;
@@ -138,7 +139,15 @@ public class PlacementFragment implements Fragment{
input.placeMode = input.lastPlaceMode; input.placeMode = input.lastPlaceMode;
} }
modeText(Bundles.format("text.mode.break", mode.toString())); modeText(Bundles.format("text.mode.break", mode.toString()));
}).group(breakGroup).get().setName(mode.name()); }).group(breakGroup).get();
button.setName(mode.name());
button.released(() -> {
//TODO hack
if(mode == PlaceMode.areaDelete){
((AndroidInput)input).placing = false;
}
});
} }
}}.end().get(); }}.end().get();
@@ -215,6 +224,7 @@ public class PlacementFragment implements Fragment{
if(!show){ if(!show){
control.input().breakMode = PlaceMode.none; control.input().breakMode = PlaceMode.none;
if(control.input().placeMode.delete) control.input().placeMode = PlaceMode.none;
breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false)); breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false));
}else{ }else{
shown = true; shown = true;