I've spent a few more hours into this problem... It's really hard to understand what's going on there. The following code should fix it for both of our setups.
The file you need to edit is the following one: *InstallPath*\DCSWorld\Mods\aircraft\AH-64D\Cockpit\Scripts\AI\PrestonAI_page_common.lua
The changes are multiplayer compatible. You have to replace the entire part between "--viewports stuff" and "--end viewports stuff":
--viewports stuff
local v = find_viewport("GU_MAIN_VIEWPORT", "CENTER")
if v ~= nil then
if v.width ~= total_w or v.height ~= total_h then
ULX = v.x
ULY = v.y
SZX = v.width
SZY = v.height
local aspect = SZX/SZY
local offsetX = (ULX + SZX / 2 - total_w / 2) / total_w * total_aspect * 2
local offsetY = -(ULY + SZY / 2 - total_h / 2) / total_h * 2
local padding = math.min(total_aspect, aspect) * 0.2
compass_pos = { -math.min(total_aspect, aspect) + offsetX + padding, -1 + offsetY * 2 + padding}
weap_control_pos = { math.min(total_aspect, aspect) + offsetX - padding, -1 + offsetY * 2 + padding }
compass_size = compass_size * v.height / total_h
weap_control_size = weap_control_size * v.height / total_h
end
end
--end viewports stuff
But I didn't test it with monitor setups where the center viewport is in the middle or other special setups. I bet this is even far from perfect, but could work for the most setups for now.
@MatveyTsivinyuk you (ED) have some serious issues there regarding the positioning of UI elements, as it seems. The behaviour is totally counterintuitive. You should always place those UI elements based on the center of the main / center-view and not based on the total center of the selected resolution when you support multi-monitor setups. This makes it way too complicated and explains why it is broken so often and why the kneeboard spawns on the MPDs etc... That makes no sense, at least to me.
The other weird thing is the grid you guys & girls have created there:
The center is [0, 0]
The y-axis always reaches from [0, 1] (top) to [0, -1] (bottom)
And now the x-axis behaves really weird: Its from [-total_aspect_ratio, 0] to [total_aspect_ratio, 0]
This creates multiple problems when positioning UI elements:
When I'm using a total resolution of 4240x1440 (MPDs horizontal), the total_aspect_ratio is about 2.94
When using a total resolution of 3440x2040 (MPDs vertical), the total aspect_ratio is about 1.69
The consequence: Every used relative value behaves totally different for each total resolution. You've used 0.8 and 0.82 as an example, but that is always another position on the screen. And when applying proper offsets. That's why I had to add math.min(), because normally the aspect ratio of the center view would in both cases be the same. But using the total_aspect_ratios makes this weird.
Another hint from one software dev to another: I would recommend structuring the code in smaller pieces / objects and functions as far as LUA can handle it. This makes it easier to maintain and understand. And you could use automatic tools to clean your files from trailing whitespaces, since they are "useless". Even most IDEs should support that, maybe even with an .editorconfig file for the entire team
If this works, you owe me a beer
@Deezle If this still doesn't work for you, could you send me screenshots where those elements are placed, if visible?