I've modified that code a bit to also include the Y when considering scale and position. This is only useful for oddball video_modes like 9 and 10(1280x1024 and 1400x1050). I also included common panel names in the scaleAllPanels function. Just change them to whatever you're naming convention happens to be.

I haven't tested it, so I'm assuming your version works. You'd only have to create one set of panels at your largest resolution, and it should scale down and reposition everything in one swoop. I wonder how bad the artwork is pixelated, though? If you do this in a package like Photoshop, it's not a problem, but I'm not so sure how well this looks in a 3D engine?

I prefer this to my original version. Much easier to read and expand, smaller, and it does it all. Now, we just need this for text.

Code:

PANEL* pnl;
var maxResX = 1600;
var maxResY = 1200;
var scaleFactorX;
var scaleFactorY;

function scalePanel(panel, scaleFactorX, scaleFactorY)
{
pnl = panel; //hold pointer for panel

var tempScaleX;
var tempScaleY;

tempScaleX = pnl.scale_x; //store current panel scale, to restore its position
tempScaleY = pnl.scale_y; //store current panel scale, to restore its position

//Modify scale: just assign new scale factor
pnl.scale_x = scaleFactorX;
pnl.scale_y = scaleFactorY;

//Modify position:
tempScaleX = scaleFactorX / tempScaleX; //This creates a new position factor by removing previous scale and applying new
tempScaleY = scaleFactorY / tempScaleY; //This creates a new position factor by removing previous scale and applying new

pnl.pos_x *= tempScaleX; //apply position scalefactor
pnl.pos_y *= tempScaleY;
}

function scaleAllPanels(scaleFactorX, scaleFactorY)
{
scalePanel(pause, scaleFactorX, scaleFactorY);
scalePanel(loadmenu, scaleFactorX, scaleFactorY);
scalePanel(savemenu, scaleFactorX, scaleFactorY);
scalePanel(gameSavingScreen, scaleFactorX, scaleFactorY);
scalePanel(mainmenu, scaleFactorX, scaleFactorY);
scalePanel(credits, scaleFactorX, scaleFactorY);
scalePanel(filmgrain, scaleFactorX, scaleFactorY);
scalePanel(blackPanel, scaleFactorX, scaleFactorY);
}

.
.
.
scaleFactorX = screen_size.x / maxResX;
scaleFactorY = screen_size.y / maxResY;
scaleAllPanels(scaleFactorX, scaleFactorY);
.
.
.




My User Contributions master list - my initial post links are down but scroll down page to find list to active links