Added rebuild region key on desktop
This commit is contained in:
@@ -31,6 +31,7 @@ public enum Binding implements KeyBind{
|
||||
diagonal_placement(KeyCode.controlLeft),
|
||||
pick(KeyCode.mouseMiddle),
|
||||
|
||||
rebuild_select(KeyCode.b),
|
||||
schematic_select(KeyCode.f),
|
||||
schematic_flip_x(KeyCode.z),
|
||||
schematic_flip_y(KeyCode.x),
|
||||
|
||||
@@ -12,15 +12,20 @@ import arc.scene.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.Placement.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.input.PlaceMode.*;
|
||||
@@ -109,10 +114,28 @@ public class DesktopInput extends InputHandler{
|
||||
drawBreakSelection(selectX, selectY, cursorX, cursorY, !Core.input.keyDown(Binding.schematic_select) ? maxLength : Vars.maxSchematicSize);
|
||||
}
|
||||
|
||||
if(Core.input.keyDown(Binding.schematic_select) && !Core.scene.hasKeyboard() && mode != breaking){
|
||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
||||
if(!Core.scene.hasKeyboard() && mode != breaking){
|
||||
|
||||
if(Core.input.keyDown(Binding.schematic_select)){
|
||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
||||
}else if(Core.input.keyDown(Binding.rebuild_select)){
|
||||
//TODO color?
|
||||
drawSelection(schemX, schemY, cursorX, cursorY, 0, Pal.sapBulletBack, Pal.sapBullet);
|
||||
|
||||
NormalizeDrawResult result = Placement.normalizeDrawArea(Blocks.air, schemX, schemY, cursorX, cursorY, false, 0, 1f);
|
||||
|
||||
Tmp.r1.set(result.x, result.y, result.x2 - result.x, result.y2 - result.y);
|
||||
|
||||
for(BlockPlan plan : player.team().data().plans){
|
||||
Block block = content.block(plan.block);
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
drawSelected(plan.x, plan.y, content.block(plan.block), Pal.sapBullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
drawCommanded();
|
||||
|
||||
Draw.reset();
|
||||
@@ -467,7 +490,7 @@ public class DesktopInput extends InputHandler{
|
||||
player.unit().clearBuilding();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.schematic_select) && !Core.scene.hasKeyboard() && mode != breaking){
|
||||
if((Core.input.keyTap(Binding.schematic_select) || Core.input.keyTap(Binding.rebuild_select)) && !Core.scene.hasKeyboard() && mode != breaking){
|
||||
schemX = rawCursorX;
|
||||
schemY = rawCursorY;
|
||||
}
|
||||
@@ -485,14 +508,33 @@ public class DesktopInput extends InputHandler{
|
||||
selectPlans.clear();
|
||||
}
|
||||
|
||||
if(Core.input.keyRelease(Binding.schematic_select) && !Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
||||
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
||||
useSchematic(lastSchematic);
|
||||
if(selectPlans.isEmpty()){
|
||||
lastSchematic = null;
|
||||
if( !Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
||||
if(Core.input.keyRelease(Binding.schematic_select)){
|
||||
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
||||
useSchematic(lastSchematic);
|
||||
if(selectPlans.isEmpty()){
|
||||
lastSchematic = null;
|
||||
}
|
||||
schemX = -1;
|
||||
schemY = -1;
|
||||
}else if(input.keyRelease(Binding.rebuild_select)){
|
||||
//TODO rebuild!!!
|
||||
|
||||
NormalizeResult result = Placement.normalizeArea(schemX, schemY, rawCursorX, rawCursorY, rotation, false, 999999999);
|
||||
Tmp.r1.set(result.x * tilesize, result.y * tilesize, (result.x2 - result.x) * tilesize, (result.y2 - result.y) * tilesize);
|
||||
|
||||
Iterator<BlockPlan> broken = player.team().data().plans.iterator();
|
||||
while(broken.hasNext()){
|
||||
BlockPlan plan = broken.next();
|
||||
Block block = content.block(plan.block);
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
player.unit().addBuild(new BuildPlan(plan.x, plan.y, plan.rotation, content.block(plan.block), plan.config));
|
||||
}
|
||||
}
|
||||
|
||||
schemX = -1;
|
||||
schemY = -1;
|
||||
}
|
||||
schemX = -1;
|
||||
schemY = -1;
|
||||
}
|
||||
|
||||
if(!selectPlans.isEmpty()){
|
||||
|
||||
@@ -1165,13 +1165,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
protected void drawSelection(int x1, int y1, int x2, int y2, int maxLength){
|
||||
drawSelection(x1, y1, x2, y2, maxLength, Pal.accentBack, Pal.accent);
|
||||
}
|
||||
|
||||
protected void drawSelection(int x1, int y1, int x2, int y2, int maxLength, Color col1, Color col2){
|
||||
NormalizeDrawResult result = Placement.normalizeDrawArea(Blocks.air, x1, y1, x2, y2, false, maxLength, 1f);
|
||||
|
||||
Lines.stroke(2f);
|
||||
|
||||
Draw.color(Pal.accentBack);
|
||||
Draw.color(col1);
|
||||
Lines.rect(result.x, result.y - 1, result.x2 - result.x, result.y2 - result.y);
|
||||
Draw.color(Pal.accent);
|
||||
Draw.color(col2);
|
||||
Lines.rect(result.x, result.y, result.x2 - result.x, result.y2 - result.y);
|
||||
}
|
||||
|
||||
@@ -1486,6 +1490,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRebuildSelecting(){
|
||||
return input.keyDown(Binding.rebuild_select);
|
||||
}
|
||||
|
||||
public float mouseAngle(float x, float y){
|
||||
return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package mindustry.input;
|
||||
|
||||
public enum PlaceMode{
|
||||
none, breaking, placing, schematicSelect
|
||||
none, breaking, placing, schematicSelect, rebuildSelect
|
||||
}
|
||||
|
||||
@@ -376,12 +376,14 @@ public class Placement{
|
||||
}
|
||||
}
|
||||
|
||||
if(Math.abs(endx - tilex) > maxLength){
|
||||
endx = Mathf.sign(endx - tilex) * maxLength + tilex;
|
||||
}
|
||||
if(maxLength > 0){
|
||||
if(Math.abs(endx - tilex) > maxLength){
|
||||
endx = Mathf.sign(endx - tilex) * maxLength + tilex;
|
||||
}
|
||||
|
||||
if(Math.abs(endy - tiley) > maxLength){
|
||||
endy = Mathf.sign(endy - tiley) * maxLength + tiley;
|
||||
if(Math.abs(endy - tiley) > maxLength){
|
||||
endy = Mathf.sign(endy - tiley) * maxLength + tiley;
|
||||
}
|
||||
}
|
||||
|
||||
int dx = endx - tilex, dy = endy - tiley;
|
||||
|
||||
Reference in New Issue
Block a user