Added rebuild region key on desktop
This commit is contained in:
@@ -1114,6 +1114,7 @@ keybind.mouse_move.name = Follow Mouse
|
|||||||
keybind.pan.name = Pan View
|
keybind.pan.name = Pan View
|
||||||
keybind.boost.name = Boost
|
keybind.boost.name = Boost
|
||||||
keybind.command_mode.name = Command Mode
|
keybind.command_mode.name = Command Mode
|
||||||
|
keybind.rebuild_select.name = Rebuild Region
|
||||||
keybind.schematic_select.name = Select Region
|
keybind.schematic_select.name = Select Region
|
||||||
keybind.schematic_menu.name = Schematic Menu
|
keybind.schematic_menu.name = Schematic Menu
|
||||||
keybind.schematic_flip_x.name = Flip Schematic X
|
keybind.schematic_flip_x.name = Flip Schematic X
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public class BlockRenderer{
|
|||||||
public void drawDestroyed(){
|
public void drawDestroyed(){
|
||||||
if(!Core.settings.getBool("destroyedblocks")) return;
|
if(!Core.settings.getBool("destroyedblocks")) return;
|
||||||
|
|
||||||
if(control.input.isPlacing() || control.input.isBreaking()){
|
if(control.input.isPlacing() || control.input.isBreaking() || control.input.isRebuildSelecting()){
|
||||||
brokenFade = Mathf.lerpDelta(brokenFade, 1f, 0.1f);
|
brokenFade = Mathf.lerpDelta(brokenFade, 1f, 0.1f);
|
||||||
}else{
|
}else{
|
||||||
brokenFade = Mathf.lerpDelta(brokenFade, 0f, 0.1f);
|
brokenFade = Mathf.lerpDelta(brokenFade, 0f, 0.1f);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public enum Binding implements KeyBind{
|
|||||||
diagonal_placement(KeyCode.controlLeft),
|
diagonal_placement(KeyCode.controlLeft),
|
||||||
pick(KeyCode.mouseMiddle),
|
pick(KeyCode.mouseMiddle),
|
||||||
|
|
||||||
|
rebuild_select(KeyCode.b),
|
||||||
schematic_select(KeyCode.f),
|
schematic_select(KeyCode.f),
|
||||||
schematic_flip_x(KeyCode.z),
|
schematic_flip_x(KeyCode.z),
|
||||||
schematic_flip_y(KeyCode.x),
|
schematic_flip_y(KeyCode.x),
|
||||||
|
|||||||
@@ -12,15 +12,20 @@ import arc.scene.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
|
import mindustry.content.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.input.Placement.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.input.PlaceMode.*;
|
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);
|
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){
|
if(!Core.scene.hasKeyboard() && mode != breaking){
|
||||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
|
||||||
|
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();
|
drawCommanded();
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -467,7 +490,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
player.unit().clearBuilding();
|
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;
|
schemX = rawCursorX;
|
||||||
schemY = rawCursorY;
|
schemY = rawCursorY;
|
||||||
}
|
}
|
||||||
@@ -485,14 +508,33 @@ public class DesktopInput extends InputHandler{
|
|||||||
selectPlans.clear();
|
selectPlans.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyRelease(Binding.schematic_select) && !Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
if( !Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
||||||
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
if(Core.input.keyRelease(Binding.schematic_select)){
|
||||||
useSchematic(lastSchematic);
|
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
||||||
if(selectPlans.isEmpty()){
|
useSchematic(lastSchematic);
|
||||||
lastSchematic = null;
|
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()){
|
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){
|
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);
|
NormalizeDrawResult result = Placement.normalizeDrawArea(Blocks.air, x1, y1, x2, y2, false, maxLength, 1f);
|
||||||
|
|
||||||
Lines.stroke(2f);
|
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);
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRebuildSelecting(){
|
||||||
|
return input.keyDown(Binding.rebuild_select);
|
||||||
|
}
|
||||||
|
|
||||||
public float mouseAngle(float x, float y){
|
public float mouseAngle(float x, float y){
|
||||||
return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle();
|
return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package mindustry.input;
|
package mindustry.input;
|
||||||
|
|
||||||
public enum PlaceMode{
|
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){
|
if(maxLength > 0){
|
||||||
endx = Mathf.sign(endx - tilex) * maxLength + tilex;
|
if(Math.abs(endx - tilex) > maxLength){
|
||||||
}
|
endx = Mathf.sign(endx - tilex) * maxLength + tilex;
|
||||||
|
}
|
||||||
|
|
||||||
if(Math.abs(endy - tiley) > maxLength){
|
if(Math.abs(endy - tiley) > maxLength){
|
||||||
endy = Mathf.sign(endy - tiley) * maxLength + tiley;
|
endy = Mathf.sign(endy - tiley) * maxLength + tiley;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dx = endx - tilex, dy = endy - tiley;
|
int dx = endx - tilex, dy = endy - tiley;
|
||||||
|
|||||||
Reference in New Issue
Block a user