Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,225 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 5 1 2 3 4 5
Re: Automatic resizing panels function [Re: eleroux] #44450
03/15/06 10:22
03/15/06 10:22
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
You're right, but I mentioned that in the first post. This is mainly for non-detailed panels like generic single color or filmgrain/noise panels. You can still use it for detailed ones, but you'd have to eliminate the scaling portion and replace it with code to change the bitmap to the appropriate one for the current resolution.


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] #44451
03/19/06 22:09
03/19/06 22:09
Joined: Jul 2005
Posts: 366
eleroux Offline
Senior Member
eleroux  Offline
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
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

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: Orange Brat] #44453
08/29/06 12:44
08/29/06 12:44
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
Sorry to rain on your parade but mine is better
Everything is done in four lines of code!

Re: Automatic resizing panels function [Re: sheefo] #44454
08/29/06 17:52
08/29/06 17:52
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

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 Offline
User
sheefo  Offline
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?

Re: Automatic resizing panels function [Re: sheefo] #44456
08/30/06 03:46
08/30/06 03:46
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Your 4 lines only center the panels. The code that eleroux came up with resizes and repositions every panel no matter where it's at on the screen(so theoretically no matter what resolution you are in, each panel will be the same size and in the same position). However, if you're using a single, large panel with buttons then the center only solution should work if you design all of your panels that way.

Scaling down an image should lead to a good result, but Photoshop is probably using special filters whereas 3DGS probably doesn't(maybe it does...I haven't inspected the manual for newer panel features/flags). If it scaling down doesn't look good, then the only other alternative is to create a set of panels for each supported resolution and swap out art on the fly. You can still use the code, above, though(albeit modified) for positioning).


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] #44457
08/30/06 11:26
08/30/06 11:26
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
I see, good job

I wish there was a way to make custom flags for panels... then I could make some really cool stuff. Maybe through DLL...?

Re: Automatic resizing panels function [Re: sheefo] #44458
08/30/06 20:07
08/30/06 20:07
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
Quote:

Sorry to rain on your parade but mine is better
Everything is done in four lines of code!



short, and to the point, although it is very brave of you to say so, although OB has some of the best contributions in this forum.


- aka Manslayer101
Re: Automatic resizing panels function [Re: mpdeveloper_B] #44459
08/30/06 21:13
08/30/06 21:13
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
I know, and I admire him. I didn't mean it bad, you know.
I was just... I thought I'd show off my version which doesn't uses any variables.

Page 2 of 5 1 2 3 4 5

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1