Think of this as the bare minimum for what you'll ultimately need. This is an intentional thing, since most of us will need it for different reasons.
The scale_x and scale_y values will accurately scale up a fullscreen, 640x480 panel across the 5 most common resolutions. I don't recommend rescaling panels with burned in text, small details, or gradients. An example of what you can add to this would be pos_x/pos_y changes for strings, panels, etc when switching resolutions. Just place what you need in the appropriate if block and call the function when you switch resolutions.
You'd probably want to add some more ifs to handle specific needs or to only use certain blocks for certain actions, since there's no need to change every single element every time you call it. Adding a parameter to the function would help with this. Just pass the current panel to it and create an if for that panel. You'd need to define the panel name to make it easier to track(but that's optional). I used a panel pointer since this will make the function appear less cluttered/busy when it grows in size. The panel declaration is included for consistency.
This probably seems like a simple contribution, but think about a project with large amounts of text, panels, and multiple resolutions and it isn't so simple, anymore. I feel it's best to keep it all in a single function instead of spreading it around amongst various functions.
Code:
panel* pnl;
bmap bmap_name = <bmap_file.bmp>;
panel panel_name
{
bmap = bmap_name;
layer = 1;
pos_x = 0;
pos_y = 0;
flags = overlay;
}
function resize()
{
if(video_mode == 6) //640x480
{
pnl = panel_name; //assign panel names as you go
pnl.scale_x = 1;
pnl.scale_y = 1;
return;
}
if(video_mode == 7) //800x600
{
pnl = panel_name; //assign panel names as you go
pnl.scale_x = 1.25;
pnl.scale_y = 1.25;
return;
}
if(video_mode == 8) //1024x768
{
pnl = panel_name; //assign panel names as you go
pnl.scale_x = 1.6;
pnl.scale_y = 1.6;
return;
}
if(video_mode == 9) //1280x1024
{
pnl = panel_name; //assign panel names as you go
pnl.scale_x = 2;
pnl.scale_y = 2.134;
return;
}
if(video_mode == 11) //1600x1200
{
pnl = panel_name; //assign panel names as you go
pnl.scale_x = 2.5;
pnl.scale_y = 2.5;
return;
}
}