Hey! I was working on panel resizing, starting from your post. It was real helpful.
I came to a solution for adjusting also the panels position after a screen adjustment. This code doesn't use different bitmaps for diff. resolutions - but also I structured it in functions to avoid the most manual job.
It goes as this:
Code:
PANEL* mPan_pTempPanel; //temporary panel pointer for use in function
//resizes a panel to specified scalefactor i.e. 1.25
function scalePanel(pan,scalefactor)
{
mPan_pTempPanel = pan; //hold pointer for panel
var tempscale;
tempscale = mPan_pTempPanel.scale_x; //store current panel scale, to restore its position
//Modify scale: just assign new scale factor
mPan_pTempPanel.scale_x = scalefactor;
mPan_pTempPanel.scale_y = scalefactor;
//Modify position:
tempscale = scalefactor/tempscale; //This creates a new position factor by removing previous scale and applying new
mPan_pTempPanel.pos_x *= tempscale; //apply position scalefactor
mPan_pTempPanel.pos_y *= tempscale;
}
The position part may be a little confusing, but by that division operation I am 'reverting' the position from any previous modification and applying the new factor.
This way you can add another function like
function ScaleAllPanels(scalefactor)
{
scalePanel (panelMenu,scalefactor);
scalePanel (panelInventory,scalefactor);
scalePanel (panel3,scalefactor);
scalePanel (panel4,scalefactor);
....
}
then in the main code:
Code:
if (video has changed?)
{
scalefactor = current_resolution_X_value/1024; //say your panels were made for 1024x768
scaleAllPanels (scalefactor);
}