by Spike » Sat Feb 01, 2014 6:58 am
the width-320 is halved then added. this is the amount of space at the side, which is chopped in two (for each side) then added to the left coord to center on the x axis.
width-320 is correct for a centered sbar region which is 320 (virtual) pixels wide.
-24 is the main sbar, and does not include the ibar. note that quake's sbar uses the same logic, with the ibar elements using a negative y offset above the sbar.
if the virtual screen size is smaller than 320,24, then your sbar will poke off the sides/top. the maths still works even if you get negatives appearing, but you're likely to want to clamp to at least 0, so the right goes offscreen instead of the left, or something, at least if you care to allow for virtual resolutions smaller than 320... its more of an issue if the sbar is made for a larger base size.
.