Jump to content

[HELP] Gui on different resolutions


..:D&G:..

Recommended Posts

Posted

Hello guys, I am trying to make a GUI that works on different resolutions, but player with smaller resolutions than mine don't see the bottom buttons as the GUI is still too big...

function showVehiclesWindow(vehiclesInGarage) 
    local Width = 567 
    local Height = 740 
    local screenwidth, screenheight = guiGetScreenSize() 
    local X = (screenwidth - Width)/2 
    local Y = (screenheight - Height)/2 
     
    if not (wVehicles) then 
        wVehicles = guiCreateWindow(X, Y, Width, Height, "Vehicles", false) 
        guiWindowSetSizable(wVehicles, false) 
  
        gList = guiCreateGridList(33, 82, 496, 490, false, wVehicles) 
        lVehID = guiGridListAddColumn(gList, "ID", 0.15) 
        lVehName = guiGridListAddColumn(gList, "Name", 0.2) 
        lVehOwner = guiGridListAddColumn(gList, "Owner", 0.3) 
        lVehInsured = guiGridListAddColumn(gList, "Insured", 0.1) 
         
        for i,theVehicle in ipairs(vehiclesInGarage) do 
            local row = guiGridListAddRow(gList) 
            local vid = getElementData(theVehicle, "dbid") 
            local ownerName = getElementData(theVehicle, "ownerName") 
            local insuredState = getElementData(theVehicle, "insured") or 0 
            guiGridListSetItemText(gList, row, lVehID, tostring(vid), false, false) 
            guiGridListSetItemText(gList, row, lVehName, getVehicleName(theVehicle) , false, false) 
            guiGridListSetItemText(gList, row, lVehOwner, ownerName, false, false) 
            guiGridListSetItemData(gList, row, lVehID, theVehicle) 
            if insuredState == 0 then 
                guiGridListSetItemText(gList, row, lVehInsured, "No", false, false) 
            else 
                guiGridListSetItemText(gList, row, lVehInsured, "Yes", false, false) 
            end 
        end 
         
        bTunning = guiCreateButton(33, 593, 186, 74, "Ailable Tunning", false, wVehicles) 
        addEventHandler( "onClientGUIClick", bTunning, showVehiclesUpgrades, false ) 
        bClose = guiCreateButton(343, 593, 186, 74, "Close", false, wVehicles) 
        addEventHandler( "onClientGUIClick", bClose, closeTunningWindow, false ) 
         
        tTitlu = guiCreateLabel(38, 26, 485, 42, "Vehicles from the tunning garage!", false, wVehicles) 
        local tFont = guiCreateFont(":guieditor/fonts/EmblemaOne.ttf", 10) 
        guiSetFont(tTitlu, tFont) 
        guiLabelSetHorizontalAlign(tTitlu, "center", false) 
        guiLabelSetVerticalAlign(tTitlu, "center")   
        showCursor(true) 
    end 
end 

Any ideas?

Thanks.

Posted

You could either make the GUI smaller, or you could make it relative.

wVehicles = guiCreateWindow(X, Y, Width, Height, "Vehicles", true) 

But then you should divide every element's X and Y with the targeted perfect resolution's width and height, so you can get a value between 0 and 1 (example if your target resolution is 1366x768, and the element's location is 683, 384, then use 0.5, 0.5)

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...