Cleanup & Padding changes

This commit is contained in:
Summet-V
2020-11-06 14:28:08 +03:00
parent c3a57a744c
commit 275395b553
+15 -16
View File
@@ -666,7 +666,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
ui.showConfirm("@confirm", "@editor.unsaved", this::hide); ui.showConfirm("@confirm", "@editor.unsaved", this::hide);
} }
private void addBlockSelection(Table table){ private void addBlockSelection(Table cont){
blockSelection = new Table(); blockSelection = new Table();
pane = new ScrollPane(blockSelection); pane = new ScrollPane(blockSelection);
pane.setFadeScrollBars(false); pane.setFadeScrollBars(false);
@@ -677,16 +677,15 @@ public class MapEditorDialog extends Dialog implements Disposable{
} }
}); });
Table searchBar = new Table(); cont.table(search -> {
searchBar.image(Icon.zoom); search.image(Icon.zoom).padRight(8);
searchBar.field("", this::rebuildBlockSelection) search.field("", this::rebuildBlockSelection)
.name("editor/search").maxTextLength(maxNameLength).get().setMessageText("@players.search"); .name("editor/search").maxTextLength(maxNameLength).get().setMessageText("@players.search");
}).pad(5);
table.add(searchBar).pad(10); cont.row();
table.row(); cont.table(Tex.underline, extra -> extra.labelWrap(() -> editor.drawBlock.localizedName).width(200f).center()).growX();
table.table(Tex.underline, extra -> extra.labelWrap(() -> editor.drawBlock.localizedName).width(200f).center()).growX(); cont.row();
table.row(); cont.add(pane).expandY().top().left();
table.add(pane).expandY().top().left();
rebuildBlockSelection(""); rebuildBlockSelection("");
} }
@@ -694,7 +693,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
private void rebuildBlockSelection(String searchText){ private void rebuildBlockSelection(String searchText){
blockSelection.clear(); blockSelection.clear();
ButtonGroup<ImageButton> group = new ButtonGroup<>(); Seq<Block> filteredBlocks = new Seq<>();
blocksOut.clear(); blocksOut.clear();
blocksOut.addAll(Vars.content.blocks()); blocksOut.addAll(Vars.content.blocks());
@@ -718,22 +717,22 @@ public class MapEditorDialog extends Dialog implements Disposable{
|| (!block.localizedName.toLowerCase().contains(searchText.toLowerCase()) && !searchText.isEmpty()) || (!block.localizedName.toLowerCase().contains(searchText.toLowerCase()) && !searchText.isEmpty())
) continue; ) continue;
filteredBlocks.add(block);
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearTogglei); ImageButton button = new ImageButton(Tex.whiteui, Styles.clearTogglei);
button.getStyle().imageUp = new TextureRegionDrawable(region); button.getStyle().imageUp = new TextureRegionDrawable(region);
button.clicked(() -> editor.drawBlock = block); button.clicked(() -> editor.drawBlock = block);
button.resizeImage(8 * 4f); button.resizeImage(8 * 4f);
button.update(() -> button.setChecked(editor.drawBlock == block)); button.update(() -> button.setChecked(editor.drawBlock == block));
group.add(button);
blockSelection.add(button).size(50f).tooltip(block.localizedName); blockSelection.add(button).size(50f).tooltip(block.localizedName);
if(++i % 4 == 0) blockSelection.row(); if(++i % 4 == 0) blockSelection.row();
} }
if(group.getButtons().isEmpty()){ if(filteredBlocks.isEmpty()){
blockSelection.add("@none").padLeft(80f).padTop(10f); blockSelection.add("@none").padLeft(80f).padTop(10f);
}else{ }else{
// Select first block editor.drawBlock = filteredBlocks.first();
group.getButtons().first().fireClick();
} }
} }
} }