The API exposes System.getDeviceSettings(); to get the screen's width and height, which can be used to position graphical elements on-screen.
The resource compiler, however, does this statically at build time. It converts XML into MonkeyC math expressions. When compiling for a device that's 208 pixels wide, x="50%" compiles into the expression 208/2. The optimizer's constant folding pre-computes it to 104.
When we write graphics code manually to avoid the overhead of xml layouts, is there a way to access device width and height as constants? So the optimizer can do the same constant folding as it does for .mcgen from the resource compiler?
Hopefully something built-in. I know you can conditionally include per-device .mc source files, but I'd rather not generate a boatload of conditional <device_name>/constants.mc for each device.