Jump to content

Couple of questions


Recommended Posts

Hi,

I have a couple of questions that I still have been confused about for a while.

1) When creating GUI's and DX stuff, whats the correct way to have it aligned and "all good" for all resolutions? I have seen people do it multiple ways and it just makes me confused. So if anyone has a fully working solution, please let me know :)

2) When creating GUI's, if I create it using absolute values, do I have to calculate all the GUI elements with the screenHeight, screenWidth solution? Or do I just have to do it for the window?

3) Is it best to just create GUIs with relative values or is doing it with absolute and calculating it better? Or is it just preference?

4) Whats the best way to store lots of data? I am wanting to create an inventory system and I'm wanting to know how to store data in the most effiecient way. Would SQLite or MySQL be the best option? And is there a way to put all the players items into one 'value' or 'table' and store it as a one line in the SQL database? Or is that not the best way to do it and just have each item from each player as a row in the database? Anything at all that is better is appreciated.

Thats all I really have to ask, thanks for reading!

Link to comment

1) You just have to use basic math for all resolutions, use the following format:

local screenWidth, screenHeight = guiGetScreenSize ( ); 
local screenWidth, screenHeight = screenWidth/YOUR_RESOLUTION_X, screenHeight/YOUR_RESOLUTION_Y 
  
dxDrawRectangle ( screenWidth*POS_X, screenHeight*POS_Y, screenWidth*WIDTH, screenHeight*HEIGHT, ... ); 

(Example, if my resolution was 1280x800)

local screenWidth, screenHeight = guiGetScreenSize ( ); 
local screenWidth, screenHeight = screenWidth/1280, screenHeight/800 
  
dxDrawRectangle ( screenWidth*1000, screenHeight*200, screenWidth*200, screenHeight*400 ); 

2) You have to use the ratio numbers for everything

3) It really depends. If the window is always going to be constant, at the same place, and same size, then you could use relative. If you're going to have moving/resizing elements, it would be easier to do it with absolute values, just to make the math a little bit easier

4) SQLite is better for performance, and MySQL is better for accessibility. I'd recommend that you store all the items in a table, and only load the items when the resource starts or save them when the resource stops.

Edited by Guest
Link to comment
1) You just have to use basic math for all resolutions, use the following format:
local screenWidth, screenHeight = guiGetScreenSize ( ); 
local screenWidth, screenHeight = screenWidth/YOUR_RESOLUTION_X, screenHeight/YOUR_RESOLUTION_Y 
  
dxDrawRectangle ( screenWidth*POS_X, screenHeight*POS_Y, screenWidth*WIDTH, screenHeight*HEIGHT, ... ); 

(Example, if my resolution was 1280x800)

local screenWidth, screenHeight = guiGetScreenSize ( ); 
local screenWidth, screenHeight = screenWidth/1200, screenHeight/800 
  
dxDrawRectangle ( screenWidth*1000, screenHeight*200, screenWidth*200, screenHeight*400 ); 

2) You have to use the ratio numbers for everything

3) It really depends. If the window is always going to be constant, at the same place, and same size, then you could use relative. If you're going to have moving/resizing elements, it would be easier to do it with absolute values, just to make the math a little bit easier

4) SQLite is better for performance, and MySQL is better for accessibility. I'd recommend that you store all the items in a table, and only load the items when the resource starts or save them when the resource stops.

Thanks for the answers. Really has helped!

One question though about your answer to my second question, by ratio numbers, you mean like what you did with the dxDrawRectangle on every element right? I have seen some people do it on GUIs and only do it for the window.

I understand you have to do it for all DX elements, but do you have to do it also for all GUI elements?

Link to comment

Thanks for the answers. Really has helped!

One question though about your answer to my second question, by ratio numbers, you mean like what you did with the dxDrawRectangle on every element right?

Well, you could do it like that, but I was referfering to just using the relative ratios, like:

0 = 0% of screen

0.5 = 50% of screen

1 = 100% of screen

So, something like this:

guiCreateWindow ( 0.3, 0.3, 0.6, 0.6, "Relative Window", true ) 

Link to comment

Thanks for the answers. Really has helped!

One question though about your answer to my second question, by ratio numbers, you mean like what you did with the dxDrawRectangle on every element right?

Well, you could do it like that, but I was referfering to just using the relative ratios, like:

0 = 0% of screen

0.5 = 50% of screen

1 = 100% of screen

So, something like this:

guiCreateWindow ( 0.3, 0.3, 0.6, 0.6, "Relative Window", true ) 

I see. Thats how I normally create my GUIs atm.

I have also noticed that if I create a relative GUI's in a resolution like 1920x1080 and then someone views it with a smaller resolution, the scale of the elements is really weird and they look funny. But when people use absolute values and calculate them, it doesnt seem to do that.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...