to the left

This commit is contained in:
sharlottes
2022-04-12 00:38:53 +09:00
parent f500819d8f
commit 149cdba83a
5 changed files with 12 additions and 70 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 252 B

View File

@@ -17,21 +17,17 @@ import mindustry.*;
import mindustry.entities.Units;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.Ranged;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.defense.turrets.*;
import mindustry.world.blocks.storage.*;
import static UnitInfo.SVars.*;
import static arc.Core.*;
import static mindustry.Vars.*;
public class HudUi {
public Table mainTable = new Table();
public Table baseTable = new Table();
public Table waveInfoTable = new Table();
public SchemDisplay schemTable;
@@ -42,7 +38,6 @@ public class HudUi {
public boolean waveShown;
public float a;
public int uiIndex = 3;
@SuppressWarnings("unchecked")
public <T extends Teamc> T getTarget(){
@@ -89,8 +84,6 @@ public class HudUi {
Log.warn("ui scaling reached zero");
modUiScale = 0.25f;
}
mainTable.clearChildren();
addTable();
}
if(settings.getBool("autoShooting")) {
@@ -208,9 +201,8 @@ public class HudUi {
}
public void addSchemTable() {
Table table = (Table) scene.find("minimap/position");
table.row();
schemTable=new SchemDisplay();
Table table = ((Table) scene.find("minimap/position")).row();
schemTable = new SchemDisplay();
table.add(schemTable);
}
@@ -266,51 +258,4 @@ public class HudUi {
return waveShown;
})).left().top()).fillX();
}
public void reset(int index, Seq<Button> buttons, Label label, Table table, Table labelTable, String hud){
uiIndex = index;
buttons.each(b -> b.setChecked(buttons.indexOf(b) == index));
label.setText(bundle.get(hud));
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).left().get();
a = 1f;
}
public void addTable(){
mainTable = new Table(table -> {
table.left();
Label label = new Label("");
label.setColor(Pal.stat);
label.update(() -> {
a = Mathf.lerpDelta(a, 0f, 0.025f);
label.color.a = a;
});
label.setStyle(new Label.LabelStyle(){{
font = Fonts.outline;
fontColor = Color.white;
background = Styles.black8;
}});
label.setFontScale(Scl.scl(modUiScale));
Table labelTable = new Table(t -> t.add(label).left().padRight(Scl.scl(modUiScale) * 40 * 8f));
table.table(t -> {
Seq<Button> buttons = Seq.with(null, null, null, null);
Seq<String> strs = Seq.with("hud.unit", "hud.wave", "hud.item", "hud.cancel");
Seq<TextureRegionDrawable> icons = Seq.with(Icon.units, Icon.fileText, Icon.copy, Icon.cancel);
for(int i = 0; i < buttons.size; i++){
int finalI = i;
buttons.set(i, t.button(new ScaledNinePatchDrawable(new NinePatch(icons.get(i).getRegion()), modUiScale), Styles.clearToggleTransi, () ->
reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(Scl.scl(modUiScale) * 5 * 8f).get());
t.row();
}
});
baseTable = table.table(tt -> tt.stack(labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).left().get();
table.fillParent = true;
table.visibility = () -> ui.hudfrag.shown && !ui.minimapfrag.shown();
});
ui.hudGroup.addChild(mainTable);
}
}

View File

@@ -43,7 +43,6 @@ public class Main extends Mod {
WindowTables.init();
new HUDFragment().build(Vars.ui.hudGroup);
hud = new HudUi();
hud.addTable();
hud.addWaveInfoTable();
hud.addSchemTable();
hud.setEvents();

View File

@@ -12,12 +12,7 @@ public class HUDFragment extends Fragment{
t.name = "Windows";
t.visible(() -> parent.visible);
// windows (totally not a copyright violation)
t.center().right();
t.add(unitTable).size(250f).visible(false);
t.add(waveTable).size(250f).visible(false);
t.add(coreTable).size(250f).visible(false);
t.center().left();
// sidebar
t.add(new TaskbarTable(
unitTable,
@@ -25,6 +20,11 @@ public class HUDFragment extends Fragment{
coreTable
)).visible(TaskbarTable.visibility);
// windows (totally not a copyright violation)
t.add(unitTable).size(250f).visible(false);
t.add(waveTable).size(250f).visible(false);
t.add(coreTable).size(250f).visible(false);
t.update(()->{
for (Element child : t.getChildren()) {
if(child instanceof Updatable u) u.update();

View File

@@ -11,16 +11,14 @@ public class TaskbarTable extends Table{
public TaskbarTable(WindowTable... items){
visible = true;
table(MindowsTex.sidebar,t -> {
table(MindowsTex.sidebar, t -> {
t.top().center();
for(WindowTable w : items){
t.button(w.icon, Styles.emptyi, () -> {
w.visible(visibility);
}).disabled(b -> w.visible)
.size(40f)
.padLeft(5f);
}).disabled(b -> w.visible).size(40f).padRight(5f);
t.row();
}
}).right().center().width(40f);
}).left().center().width(40f);
}
}