Stat info entry (#11674)

* Stat info entry

* oop cleanup imports
This commit is contained in:
EggleEgg 2026-02-19 04:40:44 +01:00 committed by GitHub
parent b72031e62f
commit 061b12ed80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View file

@ -1045,6 +1045,7 @@ stat.boosteffect = Boost Effect
stat.maxunits = Max Active Units
stat.health = Health
stat.armor = Armor
stat.armor.info = Applied damage = incoming damage - armor.\nUp to 90% maximum damage reduction.
stat.buildtime = Build Time
stat.maxconsecutive = Max Consecutive
stat.buildcost = Build Cost

View file

@ -88,7 +88,7 @@ public class ContentInfoDialog extends BaseDialog{
for(Stat stat : map.keys()){
table.table(inset -> {
inset.left();
inset.add("[lightgray]" + stat.localized() + ":[] ").left().top();
stats.statInfo(inset.add("[lightgray]" + stat.localized() + ":[] ").left().top(), stat);
Seq<StatValue> arr = map.get(stat);
for(StatValue value : arr){
value.display(inset);

View file

@ -1,11 +1,17 @@
package mindustry.world.meta;
import arc.*;
import arc.scene.ui.layout.*;
import arc.struct.ObjectMap.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.gen.*;
import mindustry.mod.*;
import mindustry.type.*;
import java.util.*;
/** Hold and organizes a list of block stats. */
@NoPatch
public class Stats{
@ -131,4 +137,21 @@ public class Stats{
}
return map;
}
public void statInfo(Cell<?> cell, Stat stat){
if(cell == null || stat == null) return;
String key = "stat." + stat.name.toLowerCase(Locale.ROOT);
if(Core.bundle.has(key + ".info")){
if(Vars.mobile && !Core.graphics.isPortrait()){ //disabled in portrait - broken and goes offscreen
Table table = new Table();
table.add(cell.get()).left().expandX().fillX();
cell.clearElement();
table.button(Icon.infoSmall, () -> Vars.ui.showInfo("@" + key + ".info")).size(32f).right();
cell.setElement(table).left().expandX().fillX();
}else{
cell.tooltip("@" + key + ".info");
}
}
}
}