Unciv
Unciv copied to clipboard
Spy Icon disabled when not on turn
This PR is a small fix of #11584 and #11587
Basically, the spy icon could be clicked from a spectator or when it isn't the active player's turn. I simply added an extra if statement since the icon can't be disabled.
since the icon can't be disabled
Why not? Anything can... What would the desired effect be?
Why not? Anything can... What would the desired effect be?
That the onClick() doesn't trigger. The way I have here works as well.
Well yes the other place is a Button and we're using our extension .disable() that does style manipulation the hard way but also sets the Gdx flag so that clicks are discarded... But giving a Table+Images based element a visual clue isn't out of the question...
Interestingly, changing the container's (the Table getSpyIcon returns) color tint has no effect, but setting alpha (else this.color.a = 0.5f) does show... Gdx and its premultiplied alpha handling isn't always intuitive.
An aside - Actor.color = Color.GRAY looks like it assigns the static but mutable instance's reference to the Actor's field... But it doesn't, it mutates the Actor's own private Color instance and copies rgba into it. There's counter-examples which will get you psychedelic effects from opening up one of the predefined statics to mutation - with exactly the same syntax...
All that said, dimmed Spy icons don't really look that good. Do it only if you want to hammer home the Spectator has not have power over them.
Looking at the code - dunno why I didn't notice earlier.
-
getImage("OtherIcons/Spy_White").apply { color = Color.WHITE }- the entire apply is redundant, doesn't change anything. Any Actor's default color field is already white. Same forarrow.color = Color.WHITEin MoveToCityButton. -
And we could probably get away with something like
private fun Table.addActivationHandlers(spy: Spy) {
onClick {
onSpyClicked(moveSpyButtons[spy]!!, spy)
}
onRightClick {
onSpyRightClicked(spy)
}
}
... to merge the two cases of onClick+onRightClick, but likely could be prettier in how/where access to the button where the feedback should happen is done...
@SomeTroglodyte is there anything here that's a no-go, or are these meant to be comments and hints?
no-go
Nope far from it, all lint-level