mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
make wave, core icon clickable
This commit is contained in:
@@ -8,6 +8,8 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.input.KeyCode;
|
import arc.input.KeyCode;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.scene.*;
|
import arc.scene.*;
|
||||||
|
import arc.scene.event.ClickListener;
|
||||||
|
import arc.scene.event.HandCursorListener;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
@@ -55,9 +57,12 @@ public class HudUi {
|
|||||||
float heat;
|
float heat;
|
||||||
float heat2;
|
float heat2;
|
||||||
float a;
|
float a;
|
||||||
int maxwave;
|
|
||||||
int uiIndex = 0;
|
int uiIndex = 0;
|
||||||
|
|
||||||
|
//to update wave, core table
|
||||||
|
int maxwave;
|
||||||
|
int coreamount;
|
||||||
|
|
||||||
public Unit getUnit(){
|
public Unit getUnit(){
|
||||||
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
||||||
if(units.size <= 0) return player.unit();
|
if(units.size <= 0) return player.unit();
|
||||||
@@ -489,15 +494,11 @@ public class HudUi {
|
|||||||
|
|
||||||
public void addWeapon(){
|
public void addWeapon(){
|
||||||
weapon = new Table(tx -> {
|
weapon = new Table(tx -> {
|
||||||
tx.defaults().minSize(Scl.scl(12 * 8f));
|
tx.left().defaults().minSize(Scl.scl(12 * 8f));
|
||||||
tx.left();
|
|
||||||
|
|
||||||
if(settings.getBool("commandedunitui") && Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) != 0)
|
if(settings.getBool("commandedunitui") && Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) != 0)
|
||||||
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t1 -> t1.table(tt -> {
|
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t1 -> t1.table(tt -> {
|
||||||
tt.defaults().width(Scl.scl(24/3f * 8f));
|
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
|
||||||
tt.defaults().minHeight(Scl.scl(12/3f * 8f));
|
|
||||||
tt.left();
|
|
||||||
tt.top();
|
|
||||||
|
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||||
@@ -519,8 +520,7 @@ public class HudUi {
|
|||||||
add(new Table(h -> {
|
add(new Table(h -> {
|
||||||
h.add(new Stack(){{
|
h.add(new Stack(){{
|
||||||
add(new Table(e -> {
|
add(new Table(e -> {
|
||||||
e.defaults().growX().height(Scl.scl(9)).width(Scl.scl(42f)).padRight(Scl.scl(2*8)).padTop(Scl.scl(8*2f));
|
e.left().defaults().growX().height(Scl.scl(9)).width(Scl.scl(42f)).padRight(Scl.scl(2*8)).padTop(Scl.scl(8*2f));
|
||||||
e.left();
|
|
||||||
Bar healthBar = new Bar(
|
Bar healthBar = new Bar(
|
||||||
() -> "",
|
() -> "",
|
||||||
() -> Pal.health,
|
() -> Pal.health,
|
||||||
@@ -528,38 +528,38 @@ public class HudUi {
|
|||||||
e.add(healthBar).left();
|
e.add(healthBar).left();
|
||||||
e.pack();
|
e.pack();
|
||||||
}));
|
}));
|
||||||
add(new Table(e -> e.add(new Stack(){{
|
add(new Table(e -> {
|
||||||
add(new Table(t -> {
|
e.add(new Stack(){{
|
||||||
t.defaults().growX().height(Scl.scl(9)).width(Scl.scl(42f)).padRight(Scl.scl(2*8)).padTop(Scl.scl(8*5f));
|
add(new Table(t -> {
|
||||||
t.left();
|
t.left().defaults().growX().height(Scl.scl(9)).width(Scl.scl(42f)).padRight(Scl.scl(2*8)).padTop(Scl.scl(8*5f));
|
||||||
t.add(new Bar(
|
t.add(new Bar(
|
||||||
() -> "",
|
() -> "",
|
||||||
() -> unit.stack.item == null || unit.stack.amount <= 0 ? Pal.items : unit.stack.item.color.cpy().lerp(Color.white, 0.15f),
|
() -> unit.stack.item == null || unit.stack.amount <= 0 ? Pal.items : unit.stack.item.color.cpy().lerp(Color.white, 0.15f),
|
||||||
() -> Mathf.clamp(unit.stack.amount / (unit.type.itemCapacity * 1f))
|
() -> Mathf.clamp(unit.stack.amount / (unit.type.itemCapacity * 1f))
|
||||||
)).growX().left();
|
)).growX().left();
|
||||||
}));
|
}));
|
||||||
add(new Table(t -> {
|
add(new Table(t -> {
|
||||||
t.left();
|
t.left();
|
||||||
t.add(new Stack(){{
|
t.add(new Stack(){{
|
||||||
add(new Table(tt ->
|
add(new Table(tt ->
|
||||||
tt.add(new Image(){{
|
tt.add(new Image(){{
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(!Core.settings.getBool("weaponui")) return;
|
if(!Core.settings.getBool("weaponui")) return;
|
||||||
setDrawable(unit.stack.item == null || unit.stack.amount <= 0 ? Core.atlas.find("clear") : unit.stack.item.uiIcon);
|
setDrawable(unit.stack.item == null || unit.stack.amount <= 0 ? Core.atlas.find("clear") : unit.stack.item.uiIcon);
|
||||||
});
|
});
|
||||||
}}.setScaling(Scaling.fit)).size(Scl.scl(2.5f * 8f)).scaling(Scaling.fit).padBottom(Scl.scl(4 * 8f)).padLeft(Scl.scl(2 * 8f))
|
}}.setScaling(Scaling.fit)).size(Scl.scl(2.5f * 8f)).scaling(Scaling.fit).padBottom(Scl.scl(4 * 8f)).padLeft(Scl.scl(2 * 8f))
|
||||||
));
|
));
|
||||||
Table table = new Table(tt -> {
|
add(new Table(tt -> {
|
||||||
Label label = new Label(() -> unit.stack.item == null || unit.stack.amount <= 0 ? "" : unit.stack.amount + "");
|
Label label = new Label(() -> unit.stack.item == null || unit.stack.amount <= 0 ? "" : unit.stack.amount + "");
|
||||||
label.setFontScale(Scl.scl());
|
label.setFontScale(Scl.scl());
|
||||||
tt.add(label).padBottom(Scl.scl(1 * 8f)).padLeft(Scl.scl(2 * 8f));
|
tt.add(label).padBottom(Scl.scl(1 * 8f)).padLeft(Scl.scl(2 * 8f));
|
||||||
tt.pack();
|
tt.pack();
|
||||||
});
|
}));
|
||||||
add(table);
|
}});
|
||||||
}});
|
t.pack();
|
||||||
t.pack();
|
}));
|
||||||
}));
|
}});
|
||||||
}})));
|
}));
|
||||||
}}).padTop(Scl.scl(2*8)).padRight(Scl.scl(2*8));
|
}}).padTop(Scl.scl(2*8)).padRight(Scl.scl(2*8));
|
||||||
h.pack();
|
h.pack();
|
||||||
}));
|
}));
|
||||||
@@ -825,10 +825,11 @@ public class HudUi {
|
|||||||
|
|
||||||
tx.table(tt -> {
|
tx.table(tt -> {
|
||||||
tt.right();
|
tt.right();
|
||||||
|
Image image = new Image(group.type.uiIcon).setScaling(Scaling.fit);
|
||||||
tt.add(new Stack(){{
|
tt.add(new Stack(){{
|
||||||
add(new Table(ttt -> {
|
add(new Table(ttt -> {
|
||||||
ttt.center();
|
ttt.center();
|
||||||
ttt.add(new Image(group.type.uiIcon).setScaling(Scaling.fit)).size(iconLarge);
|
ttt.add(image).size(iconLarge);
|
||||||
ttt.pack();
|
ttt.pack();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -857,6 +858,11 @@ public class HudUi {
|
|||||||
ui.content.show(group.type);
|
ui.content.show(group.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if(!mobile){
|
||||||
|
HandCursorListener listener1 = new HandCursorListener();
|
||||||
|
tt.addListener(listener1);
|
||||||
|
tt.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
|
||||||
|
}
|
||||||
tt.addListener(new Tooltip(t -> t.background(Tex.button).add(group.type.localizedName)));
|
tt.addListener(new Tooltip(t -> t.background(Tex.button).add(group.type.localizedName)));
|
||||||
});
|
});
|
||||||
if(row % 4 == 0) tx.row();
|
if(row % 4 == 0) tx.row();
|
||||||
@@ -879,10 +885,11 @@ public class HudUi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
waveScrollPos = wavePane.getScrollY();
|
waveScrollPos = wavePane.getScrollY();
|
||||||
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
|
if(maxwave != settings.getInt("wavemax"))
|
||||||
|
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
|
||||||
});
|
});
|
||||||
|
|
||||||
wavePane.setOverscroll(false, false);
|
wavePane.setOverscroll(false, false);
|
||||||
|
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
|
||||||
waveTable = new Table(table -> {
|
waveTable = new Table(table -> {
|
||||||
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
||||||
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
|
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
|
||||||
@@ -905,23 +912,32 @@ public class HudUi {
|
|||||||
public void setCore(Table table){
|
public void setCore(Table table){
|
||||||
table.add(new Table(t -> {
|
table.add(new Table(t -> {
|
||||||
if(Vars.player.unit() == null) return;
|
if(Vars.player.unit() == null) return;
|
||||||
|
coreamount = Vars.player.unit().team().cores().size;
|
||||||
for(int r = 0; r < Vars.player.unit().team().cores().size; r++){
|
for(int r = 0; r < coreamount; r++){
|
||||||
CoreBlock.CoreBuild core = Vars.player.unit().team().cores().get(r);
|
CoreBlock.CoreBuild core = Vars.player.unit().team().cores().get(r);
|
||||||
|
|
||||||
if(Vars.player.unit().team().cores().size > 1 && r % 3 == 0) t.row();
|
if(coreamount > 1 && r % 3 == 0) t.row();
|
||||||
else if(r % 3 == 0) t.row();
|
else if(r % 3 == 0) t.row();
|
||||||
|
|
||||||
t.table(tt -> {
|
t.table(tt -> {
|
||||||
tt.add(new Stack(){{
|
tt.add(new Stack(){{
|
||||||
add(new Table(s -> {
|
add(new Table(s -> {
|
||||||
s.left();
|
s.left();
|
||||||
Image image = new Image(core.block.uiIcon).setScaling(Scaling.fit);
|
Image image = new Image(core.block.uiIcon);
|
||||||
image.clicked(() -> {
|
image.clicked(() -> {
|
||||||
if(control.input instanceof DesktopInput) ((DesktopInput) control.input).panning = true;
|
if(control.input instanceof DesktopInput) ((DesktopInput) control.input).panning = true;
|
||||||
Core.camera.position.set(core.x, core.y);
|
Core.camera.position.set(core.x, core.y);
|
||||||
});
|
});
|
||||||
s.add(image).size(Scl.scl(6 * 8f)).scaling(Scaling.fit);
|
if(!mobile){
|
||||||
|
HandCursorListener listener1 = new HandCursorListener();
|
||||||
|
image.addListener(listener1);
|
||||||
|
image.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
|
||||||
|
}
|
||||||
|
image.addListener(new Tooltip(t -> t.background(Tex.button).add(new Label(() -> {
|
||||||
|
String color = Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString();
|
||||||
|
return "([#" + color + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")";
|
||||||
|
}))));
|
||||||
|
s.add(image).size(iconLarge).scaling(Scaling.fit);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
add(new Table(s -> {
|
add(new Table(s -> {
|
||||||
@@ -951,12 +967,11 @@ public class HudUi {
|
|||||||
Core.scene.setScrollFocus(null);
|
Core.scene.setScrollFocus(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coreScrollPos = corePane.getScrollY();
|
coreScrollPos = corePane.getScrollY();
|
||||||
if(Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
|
if(coreamount != Vars.player.unit().team().cores().size && Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
|
||||||
});
|
});
|
||||||
corePane.setOverscroll(false, false);
|
corePane.setOverscroll(false, false);
|
||||||
|
if(Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
|
||||||
coreTable = new Table(table -> {
|
coreTable = new Table(table -> {
|
||||||
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
||||||
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
|
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
|
||||||
|
|||||||
Reference in New Issue
Block a user