Dope88 Posted March 20, 2022 Share Posted March 20, 2022 Hello I'am working on a gui system with absolute values: customKnopfErstellen = function(x, y, breite, laenge, ueberschrift, relative, parent) local knopfUntergrundOben = guiCreateStaticImage(x, y, breite, 1, "images/pixel_weiss.png", relative, parent) local knopfUntergrundRechts = guiCreateStaticImage(x+breite-1, y, 1, laenge, "images/pixel_weiss.png", relative, parent) local knopfUntergrundUnten = guiCreateStaticImage(x, y+laenge-1, breite, 1, "images/pixel_weiss.png", relative, parent) local knopfUntergrundLinks = guiCreateStaticImage(x, y, 1, laenge, "images/pixel_weiss.png", relative, parent) local knopfObergrund = guiCreateStaticImage(x+1, y+1, breite-2, laenge-2, "images/pixel_weiss.png", relative, parent) local label = guiCreateLabel(0, 0, breite-2, laenge-2, ueberschrift, relative, knopfObergrund) guiSetFont(label, "default-bold-small") guiLabelSetHorizontalAlign(label, "center", false) guiLabelSetVerticalAlign(label, "center", false) guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfObergrund, "ImageColours", "tl:"..knopfFarbe.." tr:"..knopfFarbe.." bl:"..knopfFarbe.." br:"..knopfFarbe) addEventHandler("onClientMouseEnter", label, function(mx, my) guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiLabelSetColor(label, 135, 135, 135) end, false) addEventHandler("onClientMouseLeave", label, function() guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiLabelSetColor(label, 255, 255, 255) end, false) return label end standartKnopfErstellen = guiCreateButton guiCreateButton = customKnopfErstellen But how to make it when the values from guiCreateButton are relative values? How to convert them to absolute values that this script works? thank you Link to comment
Spakye Posted March 20, 2022 Share Posted March 20, 2022 Hello, GUI buttons can also use absolutes values ( according to the wiki, i didnt test it ). 1 Link to comment
Dope88 Posted March 20, 2022 Author Share Posted March 20, 2022 Hello, yes I know but i want to convert them in this script to absolute values Link to comment
Spakye Posted March 20, 2022 Share Posted March 20, 2022 hmm im not sure if i understand your issue. So you create a button with relative values and then you want to retrieve his absolute position ? Anyway, you can use guiGetPosition() to retrieve the absolute position of your button but care the position will be relative to his parent. Link to comment
Scripting Moderators thisdp Posted March 21, 2022 Scripting Moderators Share Posted March 21, 2022 13 hours ago, Dope88 said: Hello, yes I know but i want to convert them in this script to absolute values The "relative" is calculated according to "parent". For example local labelA = guiCreateLabel(100,100,400,200,"",false) local labelB = guiCreateLabel(0.1,0.2,0.5,0.5,"",true,labelB) for labelB, it's x = 0.1 * 400 y = 0.2 * 200 width = 0.5 * 400 height = 0.5 * 200 In this way, we can know that: x = relativeX * parentWidth y = relativeY * parentHeight width = relativeWidth * parentWidth height = relativeHeight * parentHeight If there's no parent, parentWidth and parentHeight will be screenWidth and screenHeight. 1 Link to comment
Dope88 Posted March 21, 2022 Author Share Posted March 21, 2022 14 hours ago, thisdp said: The "relative" is calculated according to "parent". For example local labelA = guiCreateLabel(100,100,400,200,"",false) local labelB = guiCreateLabel(0.1,0.2,0.5,0.5,"",true,labelB) for labelB, it's x = 0.1 * 400 y = 0.2 * 200 width = 0.5 * 400 height = 0.5 * 200 In this way, we can know that: x = relativeX * parentWidth y = relativeY * parentHeight width = relativeWidth * parentWidth height = relativeHeight * parentHeight If there's no parent, parentWidth and parentHeight will be screenWidth and screenHeight. Thank you that helped a lot Is there any function like guiGetSize() to get the Width and Height of an gui Element? Link to comment
Scripting Moderators thisdp Posted March 22, 2022 Scripting Moderators Share Posted March 22, 2022 21 hours ago, Dope88 said: Thank you that helped a lot Is there any function like guiGetSize() to get the Width and Height of an gui Element? that is the exactly function Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now