yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.58k stars 1.58k forks source link

Regression in WorldScreenTopBar portrait mode #9341

Closed SomeTroglodyte closed 1 year ago

SomeTroglodyte commented 1 year ago

image Compare to #7749 "Now" Debug lines show that the calculations are correct, it's the background that no longer fills what it should: image (10 padding, 50 menu icon, 10 pad, 99.5 Label, 10 pad = 180)

I've tried reinstating the pre-#7714 backgroundactor and ninepatch code, or using the -mid or -small variants, nothing helped so far. (Though it's astonishing how assymmetrical roundedEdgeRectangle has become without toppling the entire UI - leftWidth 19, rightWidth 20, middleWidth 13, middle Height 10, bottomHeight 21, topHeight 19, padLeft 12, padRight 13, padBottom 7, padTop 7? All over the place - compare with roundedEdgeRectangle-small, that one's perfectly symmetrical...)

SomeTroglodyte commented 1 year ago

I ascertained BackgroundActor is working as intended with a little tester:

```kotlin package com.unciv.ui.screens.mainmenuscreen import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Stage import com.badlogic.gdx.scenes.scene2d.ui.Window import com.badlogic.gdx.utils.Align import com.unciv.Constants import com.unciv.ui.components.Fonts import com.unciv.ui.components.KeyCharAndCode import com.unciv.ui.components.extensions.keyShortcuts import com.unciv.ui.components.extensions.onActivation import com.unciv.ui.components.extensions.toTextButton import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.worldscreen.BackgroundActor class TestDialog( stage: Stage ) : Window("Testing", Style() ) { init { skin = BaseScreen.skin val bg = BaseScreen.skinStrings.getUiBackground("General/Border", BaseScreen.skinStrings.roundedEdgeRectangleShape, tintColor = Color.FIREBRICK) defaults().size(stage.width / 8).space(1f) add(BackgroundActor(bg, Align.topLeft)) add(BackgroundActor(bg, Align.top)) add(BackgroundActor(bg, Align.topRight)) row() add(BackgroundActor(bg, Align.left)) add(BackgroundActor(bg, Align.center)) add(BackgroundActor(bg, Align.right)) row() add(BackgroundActor(bg, Align.bottomLeft)) add(BackgroundActor(bg, Align.bottom)) add(BackgroundActor(bg, Align.bottomRight)) row() val closeButton = Constants.close.toTextButton() add(closeButton).colspan(3).height(50f).center().row() closeButton.onActivation { this.remove() } closeButton.keyShortcuts.add(KeyCharAndCode.BACK) pack() setPosition(stage.width / 2, stage.height / 2, Align.center) stage.addActor(this) } private class Style : WindowStyle(Fonts.font, Color.GOLD, getBackground()) { companion object { fun getBackground() = BaseScreen.skinStrings.getUiBackground( "General/Popup/Background", tintColor = Color.GRAY.cpy().apply { a = 0.8f }) } } } ```

... so still no progress in understanding the cause

SomeTroglodyte commented 1 year ago

I'm getting closer to understanding this - but the best I can say so far is - Gdx is !("/&§/&!%"§/&%$"/%

Or - the top row with the stats gets packed, then it has a minWidth, and if that exceeds the stage, the WorldScreenTopBar will layout with a mix of that minWidth and the width it was told to use, and end up placing the filler cell actors outside the filler cell bounds. I can fix this, but I doubt I can do so without harmful injury to someone.

If only the Gdx way of scaling made some sense.. But no, a scaled container doesn't translate coordinate systems automatically so it talks to descendants in the inner, scaled coordinates, while projecting sizes reported by descendants to the outside coordinate system for ascendants - as I vaguely remember the archaic Windows Forms do. So - forget about centering or aligning, let alone a Table cell knowing how big a scaled actor actually is. Infuriating.