Fixed database opening when selecting commanded units

This commit is contained in:
Anuken 2024-09-21 09:00:24 -04:00
parent 63c90968c7
commit 830fcb6360
2 changed files with 5 additions and 44 deletions

View File

@ -8,6 +8,7 @@ import arc.scene.*;
import arc.scene.event.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.scene.ui.Tooltip.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
@ -466,7 +467,10 @@ public class PlacementFragment{
for(int i = 0; i < counts.length; i++){
if(counts[i] > 0){
var type = content.unit(i);
unitlist.add(StatValues.stack(type, counts[i])).tooltip(type.localizedName).pad(4).with(b -> {
unitlist.add(StatValues.stack(type, counts[i])).pad(4).with(b -> {
b.clearListeners();
b.addListener(Tooltips.getInstance().create(type.localizedName, false));
var listener = new ClickListener();
//left click -> select

View File

@ -1,43 +0,0 @@
import arc.util.*;
import mindustry.*;
import mindustry.gen.*;
import mindustry.type.*;
import org.junit.jupiter.api.*;
import static mindustry.Vars.*;
import static org.junit.jupiter.api.Assertions.*;
//grabs a version-locked Heavy Armaments Industries commit and makes sure it initializes correctly
//this mod was chosen because:
//- it is one of the top JS mods, based on stars
//- it contains both JS and JSON, which can be used to test compatibility of the two
//- it can be used server-side (unlike FactoryDustry, which is a client-side texture pack that cannot be tested here)
public class ModTestHAI extends GenericModTest{
@Test
public void begin(){
//TODO broken as of 136+
if(true) return;
grabMod("https://github.com/Eschatologue/Heavy-Armaments-Industries/archive/d996e92dcf9a30a6acb7b3bfdfb6522dddc3804c.zip");
checkExistence("heavy-armaments");
UnitType type = Vars.content.units().find(u -> u.name.equals("heavy-armaments-t3A_copter"));
assertNotNull(type, "A mod unit must be loaded.");
assertTrue(type.weapons.size > 0, "A mod unit must have a weapon.");
Vars.world.loadMap(maps.loadInternalMap("groundZero"));
Unit unit = type.spawn(0, 0);
//check for crash
unit.update();
assertTrue(unit.health > 0, "Unit must be spawned and alive.");
assertTrue(Groups.unit.size() > 0, "Unit must be spawned and alive.");
//just an extra sanity check
Log.info("Modded units: @", Vars.content.units().select(u -> u.minfo.mod != null));
}
}