Jump to content
2 votes
Guests cannot vote

Request for a client-side LuaUI API to read the actual game viewport size

  • Views: 30
  • Submitted:

Hello IGC team,

We are developing a custom menu using LuaUI. The UI is designed on the 640×480 canvas, but its background images and icons become horizontally stretched when the game runs in different aspect ratios, such as 4:3, 16:10, and 16:9. We need to preserve their proportions while keeping the visual positions and mouse hitboxes aligned.

UI.ScreenWidth() and UI.ScreenHeight() return the LuaUI canvas size (640×480), not the actual game viewport size. In our tests, UI.Scale() also returned 0.50 at all three aspect ratios. Client-side Lua cannot use io.open to read the launcher’s LauncherOption.if file.

Could you provide a read-only client-side API such as UI.GetViewportSize(), returning the width and height of the actual game rendering area? An API returning the viewport aspect ratio would also work. The name is only a suggestion.

The returned dimensions should exclude the Windows title bar and window borders. If DPI scaling affects the values, it is fine to return logical dimensions, provided the width and height use the same units and their ratio is correct. Please document the units and when the API becomes available to LuaUI.

For example, the API should let Lua distinguish 1024×768 (4:3), 1280×800 (16:10), and 1280×720 (16:9). We can then adjust the background, icons, button positions, and mouse hitboxes together in Lua.

Our launcher sets the window size before the game starts, and the window cannot be resized while running. Therefore, being able to read the viewport size once after LuaUI initializes is sufficient for us. A resolution-change callback would be useful, but is not required for this request.

Does the current client already have an equivalent API? If not, would you consider adding one and providing a short Lua usage example? We only need to read the viewport dimensions; we are not requesting file-system access.

Thank you!

User Feedback

Recommended Comments

xxcaozxx

Posted

Interesting. I have several custom LuaUI modules and I haven't encountered this issue.

I keep the whole layout, images and button hitboxes in the native 640x480 LuaUI canvas, using window-relative coordinates/anchors, without trying to detect the real game resolution. They stay correctly aligned for me across 4:3, 16:10 and 16:9.

Maybe the difference is how the images are being rendered/scaled? Are you using UI.RenderImage directly on screen coordinates, or the LuaUI window/control system?

mantianfei

Posted

You can try using the demo files provided by IGC at 1024x768 and 1280x720 resolutions; you will notice that the UI becomes severely distorted.

×
×
  • Create New...

Important Information


We use technologies, such as cookies, to customize content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy.