fa icon indicating copy to clipboard operation
fa copied to clipboard

Sync playable area in `UIScenarioInfo` table

Open lL1l1 opened this issue 1 year ago • 1 comments

Description of the proposed changes

Fixes #6019. Also fixes the UIReticle class calculating on-map status out from the top left corner instead of inside the actual map rectangle. Instead of having the scoreboard write the playable area info to the UI scenario info table, this is done in userSync.lua, making that playable area information easily available for anything to use.

Testing done on the proposed changes

Turned off all UI mods. Checked the scoreboard for the correct map size and then upgraded teleport and checked the map boundaries on the following maps:

Map Prefix _Scenario.lua size = _Save.lua 'AREA_1' Rectangle Notes
astrogap_fixed {1024,1024} (0,0,1024,1024) Typical setup for modern user-made maps because the map editor puts in the area rectangle
Abrogation {1024,1024} (128, 128, 896, 896) This map's playable area is offset from the top left corner, showing how the Reticle's on-map status used to be broken if you mouse over the bottom right part of the map. Typical setup for mapgen maps and other maps that don't have 20x20/10x10/5x5 sizes.
scmp_025 {512, 512} nil Map name is "Saltrock Colony", map_version 2. This older setup without a playable area is the reason for the SimInit.lua changes where we make sure to sync a new playable area at the start of the game.

After that, turned back on my UI mods and checked that my scoreboard was still displaying the correct map size; old UI mods using the old score.lua's method of setting the PlayableAreaWidth/Height should still work.

Checklist

  • [x] Changes are annotated, including comments where useful
  • [x] Changes are documented in the changelog for the next game version

lL1l1 avatar Mar 27 '24 01:03 lL1l1

That is interesting, usually these engine calls return a unique table on each call. But for this call the table is re-used

Garanas avatar Mar 27 '24 17:03 Garanas