Possible research dialog deselect fix

This commit is contained in:
Anuken
2025-04-11 20:57:30 -04:00
parent 0b9564abd5
commit c096c5858e
2 changed files with 14 additions and 6 deletions
@@ -65,10 +65,13 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
return team.core(); return team.core();
} }
/** @return largest/closest core, with largest cores getting priority */ /** @return largest/closest core, with the largest cores getting priority */
@Nullable @Nullable
public CoreBuild bestCore(){ public CoreBuild bestCore(){
return team.cores().min(Structs.comps(Structs.comparingInt(c -> -c.block.size), Structs.comparingFloat(c -> c.dst(x, y)))); var cores = team.cores();
//if someone screws up the map and adds an invalid core, prioritize the core that's supported
//if there's only one core, there are no other options
return cores.min(b -> cores.size == 1 || ((CoreBlock)b.block).unitType.supportsEnv(state.rules.env), Structs.comps(Structs.comparingInt(c -> -c.block.size), Structs.comparingFloat(c -> c.dst2(x, y))));
} }
public TextureRegion icon(){ public TextureRegion icon(){
@@ -606,10 +606,15 @@ public class ResearchDialog extends BaseDialog{
TechNode node = (TechNode)button.userObject; TechNode node = (TechNode)button.userObject;
infoTable.exited(() -> { infoTable.addListener(new InputListener(){
if(hoverNode == button && !infoTable.hasMouse() && !hoverNode.hasMouse()){ @Override
hoverNode = null; public void exit(InputEvent event, float x, float y, int pointer, Element fromActor){
rebuild(); Element e = Core.scene.hit(x, y, true);
if(hoverNode == button && !(e != null && (e.isDescendantOf(infoTable) || e.isDescendantOf(hoverNode))) && (Core.app.isDesktop() || pointer == 0)){
hoverNode = null;
rebuild();
}
} }
}); });