1 registered members (AndrewAMD),
1,225
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Automatic resizing panels function
[Re: Orange Brat]
#44451
03/19/06 22:09
03/19/06 22:09
|
Joined: Jul 2005
Posts: 366
eleroux
Senior Member
|
Senior Member
Joined: Jul 2005
Posts: 366
|
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); }
|
|
|
Re: Automatic resizing panels function
[Re: eleroux]
#44452
08/29/06 07:55
08/29/06 07:55
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
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
|
|
|
Re: Automatic resizing panels function
[Re: sheefo]
#44454
08/29/06 17:52
08/29/06 17:52
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
I always carry an umbrella. I'm guessing you're using pan_create for this? Care to share(via here or PM if you want). If not, no biggy. I'm trying to use pan_create to overhaul my save/load system. As is, it's based off of George's old Save/load from one of the early AUMs. It uses one function per slot, and there are 8 slots. It also saves a thumbnail of the screen and time/date stamps it. It's a messy, huge lot of code, and I'm trying to use pan_create and a while loop so I can use only 2 functions(or however few it takes) to do the same thing that 16-20 functions do. I don't want to have to create a separate panel for each slot(what if I wanted 800 slots(100 pages with 8 slots each)?
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Automatic resizing panels function
[Re: Orange Brat]
#44455
08/29/06 19:02
08/29/06 19:02
|
Joined: Jul 2006
Posts: 783 London, UK
sheefo
User
|
User
Joined: Jul 2006
Posts: 783
London, UK
|
Well actually my code resizes things to fullscreen and places them in the middle of the screen. Here's my code: Code:
loading_screen.scale_x = screen_size.x / bmap_width(loading_screen.bmap); loading_screen.scale_y = screen_size.y / bmap_height(loading_screen.bmap); loading_screen.pos_x = (screen_size.x / 2) - ((bmap_width(loading_screen.bmap) * loading_screen.scale_x) / 2); loading_screen.pos_y = (screen_size.y / 2) - ((bmap_height(loading_screen.bmap) * loading_screen.scale_y) / 2);
I was hoping to make a DLL that scales images without them looking crappy afterwards like in Photoshop. But I need to know how, like with DirectX. If there was a way of making custom flags for panels and an 'ent_next' for panels then I could make this the best solution. Any idea?
|
|
|
|