Page MenuHomeFeedback Tracker

ctrlMapSetPosition breaks interaction with RscMapControl in RscControlsGroup if the Groups X/Y is not 0
Feedback, NormalPublic

Description

The command ctrlMapSetPosition correctly updates the visual position of the map control inside a controls group after it has moved. However, the interactive area for interacting with the map no longer aligns with its new visual position. Based on my observations, the X and Y positions of the interactive area used for moving the map are offset by the X and Y values of the parent controls group.

This issue only occurs when the X and Y values of the controls group are not set to 0.

I have tested this in the 2.18 stable, profiling and development branches.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Operating System Version
23H2
Category
Scripting
Steps To Reproduce

Working Code from https://community.bistudio.com/wiki/ctrlMapSetPosition

safeZoneX and safeZoneY was replaced with 0,0

with localNamespace do 
{ 
 private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; 
 private _ctrlGroup = _display ctrlCreate ["RscControlsGroup", -1]; 
 private _ctrlText = _display ctrlCreate ["RscText", -1, _ctrlGroup]; 
 _ctrltext ctrlSetPosition [0, 0, 1, 1]; 
 _ctrlText ctrlSetBackgroundColor [1, 0, 0, 0.5]; 
 _ctrlText ctrlCommit 0; 
 private _ctrlMap = _display ctrlCreate ["RscMapControl", -1, _ctrlGroup]; 
 _ctrlMap ctrlMapSetPosition [0, 0, 0.5, 0.5]; // effect is immediate 
 _ctrlMap ctrlMapAnimAdd [0, ctrlMapScale _ctrlMap, player]; 
 ctrlMapAnimCommit _ctrlMap; 
 _ctrlGroup ctrlSetPosition [0, 0, 1, 1]; 
 _ctrlGroup ctrlCommit 0.3; // non instant transition 
 _ctrlMap ctrlMapSetPosition []; // instant sync to new _ctrlGroup position 
};

Bugged code:

  • Replaced _ctrlGroup ctrlSetPosition [0, 0, 1, 1];
  • With _ctrlGroup ctrlSetPosition [0.2, 0.2, 1, 1];
with localNamespace do 
{ 
 private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; 
 private _ctrlGroup = _display ctrlCreate ["RscControlsGroup", -1]; 
 private _ctrlText = _display ctrlCreate ["RscText", -1, _ctrlGroup]; 
 _ctrltext ctrlSetPosition [0, 0, 1, 1]; 
 _ctrlText ctrlSetBackgroundColor [1, 0, 0, 0.5]; 
 _ctrlText ctrlCommit 0; 
 private _ctrlMap = _display ctrlCreate ["RscMapControl", -1, _ctrlGroup]; 
 _ctrlMap ctrlMapSetPosition [0, 0, 0.5, 0.5]; // effect is immediate 
 _ctrlMap ctrlMapAnimAdd [0, ctrlMapScale _ctrlMap, player]; 
 ctrlMapAnimCommit _ctrlMap; 
 _ctrlGroup ctrlSetPosition [0.2, 0.2, 1, 1]; 
 _ctrlGroup ctrlCommit 0.3; // non instant transition 
 _ctrlMap ctrlMapSetPosition []; // instant sync to new _ctrlGroup position 
};

Event Timeline

Larry created this task.Feb 5 2025, 7:25 AM
This comment was removed by LouMontana.
This comment was removed by LouMontana.
dedmen added a subscriber: dedmen.EditedFeb 13 2025, 3:16 PM

ctrlMapSetPosition, ADDS the position of the controls group, to the position of the map.

The underlying bug is that map rendering ignores the X/Y position of the controls group telling it where its supposed to render.

ctrlMapSetPosition is a hotfix that just fake moves the map's global position, to be in the same place as where the controls group was.
But the interactions, properly respect the position of the controls group.

The controls group is at 0.2/0.2 and the map at 0/0 inside it.
ctrlMapSetPosition, tries to fix the issue of the map ignoring the render offset, by moving the whole map to 0.2/0.2

Now you have a controls group at 0.2/0.2, with a map at 0.2/0.2
So the final position of the map should be 0.4/0.4. Which is what you see with the interactive area.
But because the original bug was never fixed, the map is still ignoring the render position of the controls group. The map is now supposed to render at 0.4/0.4, but because it ignores the controls group it renders at 0.2/0.2

ctrlMapSetPosition was added to fix that issue, but in reality it just shifted it over a bit without fixing the underlying cause.

dedmen added a comment.EditedFeb 14 2025, 11:34 AM

Okey.
Due to backwards compatibility, we need to mess around a bit.

_map ctrlMapSetPosition []
or ctrlMapSetPosition ctrlPosition _map
will flip a switch and enable the map to render in fixed mode.
You just need to do it once, you can do it when you create the map control.
The map will render and interact correctly according to its parents controls group.
You can even animate the controls group (like in your script) and the map will smoothly, correctly animate with it.
Also ctrlSetPosition will work as with any other control, once you switched it to fixed mode.

Technically, you can now also render the map in 3D Viewports via ControlObjectContainer, but that is not tested and 3D rendering might not behave correctly (You're welcome to try for us and make a repro if it doesn't)

dedmen changed the task status from New to Feedback.Feb 14 2025, 2:46 PM
dedmen set Ref Ticket to AIII-56783.

2.20 also adds config entry for map controls
useRealViewport = 1 to enable it by default, then you don't need to use script command