mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 11:29:48 +07:00
Schematic search button
This commit is contained in:
parent
6a12effd6a
commit
142e93f3e9
@ -223,6 +223,7 @@ loading = [accent]Loading...
|
||||
reloading = [accent]Reloading Mods...
|
||||
saving = [accent]Saving...
|
||||
cancelbuilding = [accent][[{0}][] to clear plan
|
||||
selectschematic = [accent][[{0}][] to select+copy
|
||||
pausebuilding = [accent][[{0}][] to pause building
|
||||
resumebuilding = [scarlet][[{0}][] to resume building
|
||||
wave = [accent]Wave {0}
|
||||
@ -632,6 +633,7 @@ keybind.press.axis = Press an axis or key...
|
||||
keybind.screenshot.name = Map Screenshot
|
||||
keybind.move_x.name = Move x
|
||||
keybind.move_y.name = Move y
|
||||
keybind.schematic.name = Select Region
|
||||
keybind.schematic_flip_x.name = Flip Schematic X
|
||||
keybind.schematic_flip_y.name = Flip Schematic Y
|
||||
keybind.fullscreen.name = Toggle Fullscreen
|
||||
|
@ -50,6 +50,8 @@ public class DesktopInput extends InputHandler{
|
||||
b.label(() -> Core.bundle.format(!player.isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.name())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
b.add(Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic).key.name())).style(Styles.outlineLabel);
|
||||
}).margin(10f);
|
||||
});
|
||||
|
||||
@ -69,6 +71,7 @@ public class DesktopInput extends InputHandler{
|
||||
lastSchematic.tags.put("name", text);
|
||||
schematics.add(lastSchematic);
|
||||
ui.showInfoFade("$schematic.saved");
|
||||
ui.schematics.showInfo(lastSchematic);
|
||||
});
|
||||
}).colspan(2).size(250f, 50f);
|
||||
});
|
||||
|
@ -210,7 +210,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(request.breaking){
|
||||
drawBreaking(request.x, request.y);
|
||||
}else{
|
||||
drawSelected(request.x, request.y, request.tile().block(), Pal.remove);
|
||||
drawSelected(request.x, request.y, request.block, Pal.remove);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,15 @@ import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.Schematics.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SchematicsDialog extends FloatingDialog{
|
||||
private SchematicInfoDialog info = new SchematicInfoDialog();
|
||||
private String search = "";
|
||||
|
||||
public SchematicsDialog(){
|
||||
super("$schematics");
|
||||
@ -20,37 +23,82 @@ public class SchematicsDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
search = "";
|
||||
Runnable[] rebuildPane = {null};
|
||||
|
||||
cont.top();
|
||||
cont.clear();
|
||||
|
||||
cont.table(s -> {
|
||||
s.left();
|
||||
s.addImage(Icon.zoom).color(Pal.gray);
|
||||
s.addField(search, res -> {
|
||||
search = res;
|
||||
rebuildPane[0].run();
|
||||
}).growX();
|
||||
}).fillX().padBottom(4);
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.pane(t -> {
|
||||
t.top();
|
||||
t.margin(20f);
|
||||
int i = 0;
|
||||
for(Schematic s : schematics.all()){
|
||||
Button sel = t.addButton(b -> {
|
||||
Texture tex = schematics.getPreview(s, PreviewRes.high);
|
||||
b.add(s.name()).center().color(Color.lightGray).fillY().get().setEllipsis(true);
|
||||
b.row();
|
||||
b.add(new BorderImage(tex){
|
||||
@Override
|
||||
public void draw(){
|
||||
//Draw.blend(Blending.disabled);
|
||||
super.draw();
|
||||
//Draw.blend();
|
||||
}
|
||||
}.setScaling(Scaling.fit).setName("border"));
|
||||
}, () -> {
|
||||
control.input.useSchematic(s);
|
||||
hide();
|
||||
}).size(200f, 230f).pad(2).style(Styles.clearPartiali).get();
|
||||
rebuildPane[0] = () -> {
|
||||
t.clear();
|
||||
int i = 0;
|
||||
for(Schematic s : schematics.all()){
|
||||
if(!search.isEmpty() && !s.name().contains(search)) continue;
|
||||
|
||||
BorderImage image = sel.find("border");
|
||||
image.update(() -> image.borderColor = (sel.isOver() ? Pal.accent : Pal.gray));
|
||||
Button sel = t.addButton(b -> {
|
||||
Texture tex = schematics.getPreview(s, PreviewRes.high);
|
||||
b.add(s.name()).center().color(Color.lightGray).fillY().get().setEllipsis(true);
|
||||
b.row();
|
||||
b.add(new BorderImage(tex){
|
||||
@Override
|
||||
public void draw(){
|
||||
//Draw.blend(Blending.disabled);
|
||||
super.draw();
|
||||
//Draw.blend();
|
||||
}
|
||||
}.setScaling(Scaling.fit).setName("border"));
|
||||
}, () -> {
|
||||
control.input.useSchematic(s);
|
||||
hide();
|
||||
}).size(200f, 230f).pad(2).style(Styles.clearPartiali).get();
|
||||
|
||||
if(++i % 4 == 0){
|
||||
t.row();
|
||||
BorderImage image = sel.find("border");
|
||||
image.update(() -> image.borderColor = (sel.isOver() ? Pal.accent : Pal.gray));
|
||||
|
||||
if(++i % 4 == 0){
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
rebuildPane[0].run();
|
||||
}).get().setScrollingDisabled(true, false);
|
||||
}
|
||||
|
||||
public void showInfo(Schematic schematic){
|
||||
info.show(schematic);
|
||||
}
|
||||
|
||||
public static class SchematicInfoDialog extends FloatingDialog{
|
||||
|
||||
SchematicInfoDialog(){
|
||||
super("");
|
||||
setFillParent(false);
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Schematic schem){
|
||||
cont.clear();
|
||||
title.setText(schem.name());
|
||||
|
||||
cont.add(new BorderImage(schematics.getPreview(schem, PreviewRes.high))).maxSize(400f);
|
||||
cont.row();
|
||||
|
||||
show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=795ded7ccae9aeb15ee480e3b9f6d6af57148ea0
|
||||
archash=3bd01eb4c67d11e36be2bd56f71e6928bf291345
|
||||
|
Loading…
Reference in New Issue
Block a user