mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
wtf
This commit is contained in:
@@ -3,6 +3,9 @@ package informatis.core;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.TextureRegion;
|
import arc.graphics.g2d.TextureRegion;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.math.geom.Rect;
|
||||||
|
import arc.scene.style.Drawable;
|
||||||
|
import arc.scene.style.TextureRegionDrawable;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
@@ -37,10 +40,8 @@ public class BarInfo {
|
|||||||
public static <T extends Teamc> void getInfo(T target) throws IllegalAccessException, NoSuchFieldException {
|
public static <T extends Teamc> void getInfo(T target) throws IllegalAccessException, NoSuchFieldException {
|
||||||
data.clear();
|
data.clear();
|
||||||
|
|
||||||
if(target instanceof Healthc){
|
if(target instanceof Healthc healthc){
|
||||||
Healthc healthc = (Healthc) target;
|
data.add(new BarData(bundle.format("shar-stat.health", formatNumber(healthc.health())), Pal.health, healthc.healthf(), health));
|
||||||
float pro = healthc.health();
|
|
||||||
data.add(new BarData(bundle.format("shar-stat.health", formatNumber(pro)), Pal.health, pro, health));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target instanceof Unit unit){
|
if(target instanceof Unit unit){
|
||||||
@@ -212,7 +213,7 @@ public class BarInfo {
|
|||||||
public String name;
|
public String name;
|
||||||
public Color color;
|
public Color color;
|
||||||
public float number;
|
public float number;
|
||||||
public TextureRegion icon = clear;
|
public Drawable icon = new TextureRegionDrawable(clear);
|
||||||
|
|
||||||
BarData(String name, Color color, float number) {
|
BarData(String name, Color color, float number) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -222,7 +223,7 @@ public class BarInfo {
|
|||||||
|
|
||||||
BarData(String name, Color color, float number, TextureRegion icon) {
|
BarData(String name, Color color, float number, TextureRegion icon) {
|
||||||
this(name, color, number);
|
this(name, color, number);
|
||||||
this.icon = icon;
|
this.icon = new TextureRegionDrawable(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,18 +35,18 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
class UnitWindow extends Window {
|
class UnitWindow extends Window {
|
||||||
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||||
final Rect scissor = new Rect();
|
|
||||||
Seq<Table> bars = new Seq<>(); //temp
|
Seq<Table> bars = new Seq<>(); //temp
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
Teamc latestTarget = getTarget();
|
Teamc latestTarget = getTarget();
|
||||||
int barSize = 6;
|
int barSize = 6;
|
||||||
ScrollPane barPane;
|
ScrollPane barPane;
|
||||||
|
Table window;
|
||||||
|
|
||||||
private float barScrollPos;
|
private float barScrollPos;
|
||||||
|
|
||||||
public UnitWindow() {
|
public UnitWindow() {
|
||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
for(int i = 0; i < 6; i++) addBar();
|
window = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
||||||
@@ -98,6 +98,7 @@ class UnitWindow extends Window {
|
|||||||
if(latestTarget != target) {
|
if(latestTarget != target) {
|
||||||
latestTarget = target;
|
latestTarget = target;
|
||||||
barPane.setWidget(buildBarList());
|
barPane.setWidget(buildBarList());
|
||||||
|
Log.info("updated");
|
||||||
}
|
}
|
||||||
if(barPane.hasScroll()){
|
if(barPane.hasScroll()){
|
||||||
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||||
@@ -115,15 +116,10 @@ class UnitWindow extends Window {
|
|||||||
Table buildBarList() {
|
Table buildBarList() {
|
||||||
return new Table(table -> {
|
return new Table(table -> {
|
||||||
table.top();
|
table.top();
|
||||||
bars.clear();
|
for (int i = 0; i < barSize; i++) {
|
||||||
for(int i = 0; i < barSize; i++) addBar();
|
table.add(addBar(i)).growX().get();
|
||||||
bars.each(bar -> {
|
|
||||||
table.add(bar).growX().get().clicked(()->{
|
|
||||||
if(barSize>0) barSize--;
|
|
||||||
barPane.setWidget(buildBarList());
|
|
||||||
});
|
|
||||||
table.row();
|
table.row();
|
||||||
});
|
}
|
||||||
table.add(new SBar(() -> "+", () -> Color.clear, () -> 0)).height(4 * 8f).growX().get().clicked(()->{
|
table.add(new SBar(() -> "+", () -> Color.clear, () -> 0)).height(4 * 8f).growX().get().clicked(()->{
|
||||||
barSize++;
|
barSize++;
|
||||||
barPane.setWidget(buildBarList());
|
barPane.setWidget(buildBarList());
|
||||||
@@ -131,9 +127,8 @@ class UnitWindow extends Window {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBar() {
|
Table addBar(int index) {
|
||||||
int index = this.bars.size;
|
return new Table(bar -> {
|
||||||
bars.add(new Table(bar -> {
|
|
||||||
bar.add(new SBar(
|
bar.add(new SBar(
|
||||||
() -> {
|
() -> {
|
||||||
BarInfo.BarData data = index >= BarInfo.data.size || index >= barSize ? null : BarInfo.data.get(index);
|
BarInfo.BarData data = index >= BarInfo.data.size || index >= barSize ? null : BarInfo.data.get(index);
|
||||||
@@ -151,28 +146,42 @@ class UnitWindow extends Window {
|
|||||||
return data == null ? 0 : data.number;
|
return data == null ? 0 : data.number;
|
||||||
}
|
}
|
||||||
)).height(4 * 8f).growX();
|
)).height(4 * 8f).growX();
|
||||||
bar.add(new Image(){
|
Image icon = new Image(){
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
BarInfo.BarData data = index >= BarInfo.data.size || index >= barSize ? null : BarInfo.data.get(index);
|
float x = this.x;
|
||||||
|
float y = this.y;
|
||||||
|
float scaleX = this.scaleX;
|
||||||
|
float scaleY = this.scaleY;
|
||||||
Draw.color(Color.white);
|
Draw.color(Color.white);
|
||||||
Draw.alpha(parentAlpha * color.a);
|
Draw.alpha(parentAlpha * color.a);
|
||||||
if(data == null) {
|
if(index >= BarInfo.data.size || index >= barSize) {
|
||||||
new TextureRegionDrawable(clear).draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TextureRegionDrawable region = new TextureRegionDrawable(data.icon);
|
if(hasMouse()) {
|
||||||
region.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
Icon.cancel.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
Draw.color(data.color);
|
return;
|
||||||
if(ScissorStack.push(scissor.set(x, y, imageWidth * scaleX, imageHeight * scaleY * data.number))){
|
}
|
||||||
region.draw(x, y, imageWidth * scaleX, imageHeight * scaleY);
|
|
||||||
|
BarInfo.BarData data = BarInfo.data.get(index);
|
||||||
|
data.icon.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
|
if(ScissorStack.push(Tmp.r1.set(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY * data.number))){
|
||||||
|
Draw.color(data.color);
|
||||||
|
data.icon.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
|
Log.info(Tmp.r1);
|
||||||
ScissorStack.pop();
|
ScissorStack.pop();
|
||||||
}
|
}
|
||||||
|
Draw.reset();
|
||||||
}
|
}
|
||||||
}).size(iconMed * 0.75f).padLeft(8f);
|
};
|
||||||
}));
|
icon.clicked(()->{
|
||||||
|
if(barSize > 0) barSize--;
|
||||||
|
barPane.setWidget(buildBarList());
|
||||||
|
});
|
||||||
|
bar.add(icon).size(iconMed * 0.75f).padLeft(8f);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static class WeaponDisplay extends Table {
|
static class WeaponDisplay extends Table {
|
||||||
|
|||||||
Reference in New Issue
Block a user