Bugfixes for reconstructor config

This commit is contained in:
Anuken
2023-05-30 20:15:44 -04:00
parent b97e6ef84c
commit 1a0edf80f1

View File

@@ -41,6 +41,8 @@ public class Reconstructor extends UnitBlock{
commandable = true; commandable = true;
ambientSound = Sounds.respawning; ambientSound = Sounds.respawning;
configurable = true; configurable = true;
config(UnitCommand.class, (ReconstructorBuild build, UnitCommand command) -> build.command = command);
configClear((ReconstructorBuild build) -> build.command = null);
} }
@Override @Override
@@ -197,11 +199,11 @@ public class Reconstructor extends UnitBlock{
var list = unit().commands; var list = unit().commands;
for(var item : list){ for(var item : list){
ImageButton button = table.button(item.getIcon(), Styles.clearNoneTogglei, 40f, () -> { ImageButton button = table.button(item.getIcon(), Styles.clearNoneTogglei, 40f, () -> {
command = (command == item ? null : item); configure(item);
deselect(); deselect();
}).tooltip(item.localized()).group(group).get(); }).tooltip(item.localized()).group(group).get();
button.update(() -> button.setChecked(command == item)); button.update(() -> button.setChecked(command == item || (command == null && unit.defaultCommand == item)));
if(++i % columns == 0){ if(++i % columns == 0){
table.row(); table.row();
@@ -340,6 +342,11 @@ public class Reconstructor extends UnitBlock{
return constructing() && enabled; return constructing() && enabled;
} }
@Override
public Object config(){
return command;
}
public UnitType unit(){ public UnitType unit(){
if(payload == null) return null; if(payload == null) return null;