Many bugfixes

This commit is contained in:
Anuken
2022-03-02 21:03:45 -05:00
parent 315c273de3
commit 7865950ec8
18 changed files with 102 additions and 53 deletions

View File

@@ -667,7 +667,12 @@ public class DesktopInput extends InputHandler{
if(Core.input.keyRelease(Binding.break_block) || Core.input.keyRelease(Binding.select)){
if(mode == placing && block != null){ //touch up while placing, place everything in selection
flushPlans(linePlans);
if(input.keyDown(Binding.boost)){
flushPlansReverse(linePlans);
}else{
flushPlans(linePlans);
}
linePlans.clear();
Events.fire(new LineConfirmEvent());
}else if(mode == breaking){ //touch up while breaking, break everything in selection

View File

@@ -736,21 +736,23 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
protected void showSchematicSave(){
if(lastSchematic == null) return;
var last = lastSchematic;
ui.showTextInput("@schematic.add", "@name", "", text -> {
Schematic replacement = schematics.all().find(s -> s.name().equals(text));
if(replacement != null){
ui.showConfirm("@confirm", "@schematic.replace", () -> {
schematics.overwrite(replacement, lastSchematic);
schematics.overwrite(replacement, last);
ui.showInfoFade("@schematic.saved");
ui.schematics.showInfo(replacement);
});
}else{
lastSchematic.tags.put("name", text);
lastSchematic.tags.put("description", "");
schematics.add(lastSchematic);
last.tags.put("name", text);
last.tags.put("description", "");
schematics.add(last);
ui.showInfoFade("@schematic.saved");
ui.schematics.showInfo(lastSchematic);
Events.fire(new SchematicCreateEvent(lastSchematic));
ui.schematics.showInfo(last);
Events.fire(new SchematicCreateEvent(last));
}
});
}
@@ -942,6 +944,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
}
protected void flushPlansReverse(Seq<BuildPlan> plans){
//reversed iteration.
for(int i = plans.size - 1; i >= 0; i--){
var plan = plans.get(i);
if(plan.block != null && validPlace(plan.x, plan.y, plan.block, plan.rotation)){
BuildPlan copy = plan.copy();
plan.block.onNewPlan(copy);
player.unit().addBuild(copy, false);
}
}
}
protected void flushPlans(Seq<BuildPlan> plans){
for(var plan : plans){
if(plan.block != null && validPlace(plan.x, plan.y, plan.block, plan.rotation)){