mirror of
https://github.com/yawaflua/Informatis.git
synced 2026-02-04 10:24:21 +02:00
tmp
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
package informatis.ui;
|
||||
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Lines;
|
||||
import arc.scene.ui.Image;
|
||||
import arc.scene.ui.Label;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.scene.ui.layout.Stack;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.struct.IntSeq;
|
||||
import arc.struct.IntSet;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Log;
|
||||
import mindustry.Vars;
|
||||
import mindustry.entities.units.BuildPlan;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.units.*;
|
||||
|
||||
import arc.struct.Queue;
|
||||
import mindustry.gen.Icon;
|
||||
@@ -21,7 +16,7 @@ import mindustry.world.Block;
|
||||
|
||||
public class BuildNoteManager {
|
||||
public static Table body;
|
||||
private static Seq<Queue<BuildPlan>> plans = new Seq<>(10);
|
||||
private static final Seq<Queue<BuildPlan>> plans = new Seq<>(10);
|
||||
|
||||
public static void init() {
|
||||
for(int i = 0; i < 10; i++) plans.add(new Queue<>());
|
||||
@@ -29,46 +24,64 @@ public class BuildNoteManager {
|
||||
t.defaults().growX();
|
||||
|
||||
t.table(list -> {
|
||||
for(int i = 0; i < 10; i++) {
|
||||
final int finalI = i;
|
||||
Table listItem = new Table();
|
||||
listItem.left();
|
||||
listItem.add(String.valueOf(i)).fontScale(0.75f).width(15).padRight(30);
|
||||
listItem.clicked(() -> selectBuildPlan(finalI));
|
||||
listItem.table(stack -> stack.add(buildListItem(finalI))).marginLeft(20).marginRight(20).name("listItem-"+i).grow();
|
||||
listItem.table(icons -> {
|
||||
icons.image(Icon.cancelSmall).size(20).color(Pal.health).padLeft(10).grow().get().clicked(() -> {
|
||||
list.defaults().grow();
|
||||
|
||||
for(int i = 1; i <= 10; i++) {
|
||||
final int finalI = i % 10;
|
||||
Table ltable = new Table(listItem -> {
|
||||
listItem.left().defaults().grow();
|
||||
listItem.add(String.valueOf(finalI))
|
||||
.fontScale(0.75f)
|
||||
.width(15).padRight(30);
|
||||
listItem.table(stack -> stack.add(buildListItem(finalI)))
|
||||
.padLeft(10)
|
||||
.name("listItem-"+finalI);
|
||||
listItem.image(Icon.cancelSmall)
|
||||
.color(Pal.health)
|
||||
.size(20).padRight(10)
|
||||
.get().clicked(() -> {
|
||||
plans.get(finalI).clear();
|
||||
rerenderListItem(finalI);
|
||||
rerenderListItem();
|
||||
});
|
||||
icons.image(Icon.upSmall).size(20).color(Pal.heal).padLeft(10).grow().get().clicked(() -> {
|
||||
plans.set(finalI, Vars.player.unit().plans());
|
||||
rerenderListItem(finalI);
|
||||
listItem.image(Icon.upSmall)
|
||||
.color(Pal.heal)
|
||||
.size(20).padRight(10)
|
||||
.get().clicked(() -> {
|
||||
plans.set(finalI, copyPlan(Vars.player.unit().plans()));
|
||||
rerenderListItem();
|
||||
});
|
||||
}).padLeft(10).width(80).grow();
|
||||
list.add(listItem).pad(10).grow().row();
|
||||
list.image().height(2f).color(Pal.gray).grow().row();
|
||||
}
|
||||
});
|
||||
ltable.touchable = Touchable.enabled;
|
||||
ltable.clicked(() -> selectBuildPlan(finalI));
|
||||
|
||||
list.add(ltable).pad(10).minWidth(200).row();
|
||||
list.image().height(2f).color(Pal.gray).row();
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static Queue<BuildPlan> copyPlan(Queue<BuildPlan> target) {
|
||||
Queue<BuildPlan> copied = new Queue<>(target.size);
|
||||
for(BuildPlan plan : target) copied.add(plan.copy());
|
||||
return copied;
|
||||
}
|
||||
|
||||
public static void selectBuildPlan(int index) {
|
||||
Vars.player.unit().plans(plans.get(index));
|
||||
Vars.player.unit().plans(copyPlan(plans.get(index)));
|
||||
}
|
||||
private static Stack buildListItem(int index) {
|
||||
return new Stack() {{
|
||||
IntSet cache = new IntSet();
|
||||
for(int i = 0; i < plans.get(index).size && cache.size < 5; i++) {
|
||||
final int fianlI = i;
|
||||
Block block = plans.get(index).get(i).block;
|
||||
int i = 0;
|
||||
for(BuildPlan plan : plans.get(index)) {
|
||||
Block block = plan.block;
|
||||
if(cache.contains(block.id)) continue;
|
||||
cache.add(block.id);
|
||||
Log.info(cache);
|
||||
|
||||
add(new Table(icon -> {
|
||||
icon.right();
|
||||
icon.add(new Image() {
|
||||
Table iconTable = new Table();
|
||||
iconTable.right();
|
||||
iconTable.add(new Image() {
|
||||
{
|
||||
setDrawable(block.uiIcon);
|
||||
}
|
||||
@@ -82,14 +95,18 @@ public class BuildNoteManager {
|
||||
Lines.rect(x - size / 2f, y - size / 2f, width + size, height + size);
|
||||
Draw.reset();
|
||||
}
|
||||
}).size(16).padRight(fianlI * 4);
|
||||
}));
|
||||
}).size(16).padRight(i * 4);
|
||||
add(iconTable);
|
||||
i++;
|
||||
if(cache.size > 5) break;
|
||||
}
|
||||
}};
|
||||
}
|
||||
private static void rerenderListItem(int index) {
|
||||
Table table = body.find("listItem-"+index);
|
||||
private static void rerenderListItem() {
|
||||
for(int i = 0; i < 10; i++) {
|
||||
Table table = body.find("listItem-"+i);
|
||||
table.clear();
|
||||
table.add(buildListItem(index));
|
||||
table.add(buildListItem(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user