Jump to content

GUI bring to back?


Karuzo

Recommended Posts

Hey guys,

i have a small problem,

i'm usin' GUI interpolate effects, just to try out, ok.

So what's the problem ?

If i let my Login-Panel open, the Login_wnd shows up, but the buttons and so on are at the back, so I just can see the Login_Wnd , but i want to see the buttons.

Tried with guiBringtoFront, but didn't worked.

Here's the part which matters:

function OpenLogin() 
    exports.gie:guiAddInterpolateEffect(Login_wnd, X, Y-150, 0, 0,X, Y, Width,Height,2, "InElastic", "OutElastic", true) 
    playername = string.gsub ( getPlayerName ( player ), '#%x%x%x%x%x%x', '' ) 
    guiSetText(Username_edit, playername) 
    showPlayerHudComponent("all", false) 
    setCameraMatrix(1291,-1208,94, 1503,-1453,63, 0, 70) 
    showCursor(true) 
    guiSetVisible(Regbtn, true) 
    guiSetVisible(Eyebtn, true) 
    guiSetVisible(Logo, true) 
    guiSetVisible(Loginbtn, true) 
    guiSetVisible(Passwort_edit, true) 
    guiSetVisible(Username_edit,true) 
    guiBringToFront(Eyebtn) 
    guiBringToFront(Passwort_edit) 
    guiBringToFront(Loginbtn) 
    guiBringToFront(Logo) 
    guiBringToFront(Regbtn) 
end 
addEventHandler("onClientResourceStart", resourceRoot, OpenLogin) 

Link to comment

Oh Sorry, forgetted that completely:

DKPfLD4.png

This is how it looks now,

and this is my code at this moment :

  
  
Login_wnd=guiCreateStaticImage(X, Y, Width,Height, "login/images/login_wnd.png",false) 
guiSetVisible(Login_wnd, false) 
guiMoveToBack(Login_wnd) 
Loginbtn = guiCreateStaticImage(X+5, Y+300, 290, 65, "login/images/login_btn.png", false,Login_wnd) 
guiSetVisible(Loginbtn, false) 
Regbtn = guiCreateStaticImage(X+5, Y+370, 290, 65, "login/images/reg_btn.png", false,Login_wnd) 
guiSetVisible(Regbtn, false) 
Eyebtn = guiCreateStaticImage(X+262, Y+245, 32,32, "login/images/eye_btn.png", false,Login_wnd) 
guiSetVisible(Eyebtn, false) 
Logo = guiCreateStaticImage(X+65, Y, 179, 62, "login/images/logo_h.png" , false,Login_wnd) 
guiSetVisible(Logo, false) 
Username_edit = guiCreateEdit(X+10, Y+130, 250, 50, "", false,Login_wnd) 
guiEditSetMaxLength(Username_edit, 25) 
guiSetVisible(Username_edit,false) 
guiEditSetReadOnly(Username_edit, true) 
Passwort_edit = guiCreateEdit(X+10,Y+235, 250, 50, "", false,Login_wnd) 
guiEditSetMasked(Passwort_edit, true) 
guiEditSetMaxLength(Passwort_edit, 25) 
guiSetVisible(Passwort_edit,false) 
--didn't wrote the full code, cause it's useless. 
function OpenLogin() 
    exports.gie:guiAddInterpolateEffect(Login_wnd, X, Y-150, 0, 0,X, Y, Width,Height,2, "InElastic", "OutElastic", true) 
    playername = string.gsub ( getPlayerName ( player ), '#%x%x%x%x%x%x', '' ) 
    guiSetText(Username_edit, playername) 
    showPlayerHudComponent("all", false) 
    setCameraMatrix(1291,-1208,94, 1503,-1453,63, 0, 70) 
    showCursor(true) 
    guiSetVisible(Regbtn, true) 
    guiSetVisible(Eyebtn, true) 
    guiSetVisible(Logo, true) 
    guiSetVisible(Loginbtn, true) 
    guiSetVisible(Passwort_edit, true) 
    guiSetVisible(Username_edit,true) 
end 
addEventHandler("onClientResourceStart", resourceRoot, OpenLogin) 

@Ciber: tried that, didn't worked.

Link to comment
  • Moderators

Ok so first, you are using absolute positions and sizes which is bad because it won't be the same for all resolutions. It will only be good at the current resolution which is 1366*768.

Try setting the parent of the buttons to the static image.

@KRZO: by doing that you should remove X+ and Y+ since it's relative to the parent.

I also need to know what are the value of these variables:

X, Y, Width and Height

Link to comment
  • Moderators
The problem is : I can press the buttons, but i don't see them.

You really can press them ?! Can you post the addEventHandlers ?

As you now put Login_wnd as parent, you can just hide (guiSetVisible) the Login_wnd and all childs will be hidden too. So when you want to show them, just show (guiSetVisible) the Login_wnd.

Link to comment
  • Moderators

Your window was still in absolute ! And the sizes of the childs was still in absolute:

local sWidth, sHeight = guiGetScreenSize() 
local Width, Height = 0.22, 0.59 
local X = 0.5 - Width 
local Y = 0.5 - Height 
local gRoot = getRootElement() 
  
local player = getLocalPlayer() 
local lx, ly, lz = 1177.51917, -1324, 14.07470 
  
function Camera() 
    fadeCamera(true) 
    setWeather ( 17 ) 
    showPlayerHudComponent("all", false) 
    showPlayerHudComponent("radar", false) 
    showChat(false) 
    setElementPosition(player, lx, ly, lz) 
    setCameraMatrix(1177.51917, -1324, 450, lx, ly, lz, 270, 100) 
    setTimer(setCameraMatrix, 2500, 1, 1177.51917, -1324, 350, lx, ly, lz, 270, 100) 
    setTimer(setCameraMatrix, 5000, 1, 1177.51917, -1324, 250, lx, ly, lz, 270, 100) 
    setTimer(setCameraMatrix, 10000, 1, 1177.51917, -1324, 150, lx, ly, lz, 270, 100) 
    setTimer(setCameraMatrix, 15000, 1, 1177.51917, -1324, 50, lx, ly, lz, 270, 100) 
    setTimer(setCameraTarget, 20000, 1, player) 
    setWeather(0) 
end 
addEvent("Camera", true) 
addEventHandler("Camera", root, Camera) 
  
Login_wnd=guiCreateStaticImage(X, Y, Width, Height, "login/images/login_wnd.png", true) 
Logo = guiCreateStaticImage(0.65, 0.150, 0.13, 0.08, "login/images/logo_h.png" , true, Login_wnd) 
  
Loginbtn = guiCreateStaticImage(0.5, 0.3, 0.212, 0.084, "login/images/login_btn.png", true, Login_wnd) 
Regbtn = guiCreateStaticImage(0.5, 0.37, 0.212, 0.084, "login/images/reg_btn.png", true, Login_wnd) 
Eyebtn = guiCreateStaticImage(0.262, 0.245, 0.023, 0.042, "login/images/eye_btn.png", true, Login_wnd) 
  
Username_edit = guiCreateEdit(0.10, 0.130, 0.183, 0.065, "", true, Login_wnd) 
guiEditSetMaxLength(Username_edit, 25) 
guiEditSetReadOnly(Username_edit, true) 
  
Passwort_edit = guiCreateEdit(0.10,0.235, 0.183, 0.065, "", true, Login_wnd) 
guiEditSetMasked(Passwort_edit, true) 
guiEditSetMaxLength(Passwort_edit, 25) 
  
guiSetVisible(Login_wnd, false) 
  
function LoginH () 
    guiStaticImageLoadImage(Loginbtn, "login/images/login_h.png" ) 
    playSound("hover.mp3", false) 
end 
  
function EyeH () 
    guiStaticImageLoadImage(Eyebtn, "login/images/eye_h.png" ) 
    guiEditSetMasked(Passwort_edit, false) 
    playSound("hover.mp3", false) 
end 
  
function RegH () 
    guiStaticImageLoadImage(Regbtn, "login/images/reg_h.png" ) 
    playSound("hover.mp3", false) 
end 
  
function BackN () 
    guiStaticImageLoadImage(Eyebtn, "login/images/eye_btn.png" ) 
    guiEditSetMasked(Passwort_edit, true) 
    guiStaticImageLoadImage(Loginbtn, "login/images/login_btn.png" ) 
    guiStaticImageLoadImage(Regbtn, "login/images/reg_btn.png" ) 
end 
  
function Regklick() 
    playSound("click.mp3", false) 
    local username = guiGetText(Username_edit) 
    local password = guiGetText(Passwort_edit) 
    if username ~= "" and password ~= "" then 
        triggerServerEvent("RegRequest", getLocalPlayer(), getLocalPlayer(), username, password) 
        triggerServerEvent("Spawn", localPlayer) 
    elseif username == "" and password == "" then 
        outputChatBox("Bitte trage dein Passwort und dein Benutzernamen ein!", 125, 0, 0, false) 
    elseif username == "" then 
        outputChatBox("Bitte trage deinen Benutzernamen ein!", 125, 0, 0, false) 
    elseif password == "" then 
        outputChatBox("Bitte trage dein Passwort ein!", 125, 0, 0, false) 
    end 
end 
addEventHandler("onClientGUIClick", Regbtn, Regklick, false) 
  
function Loginklick() 
    playSound("click.mp3", false) 
    local username = guiGetText(Username_edit) 
    local password = guiGetText(Passwort_edit) 
    if username ~= "" and password ~= "" then 
        triggerServerEvent("LoginRequest",getLocalPlayer(),getLocalPlayer(),username,password) 
        showPlayerHudComponent("all", true) 
    elseif username == "" and password == "" then 
        outputChatBox("Bitte trage dein Passwort und dein Benutzernamen ein!", 125, 0, 0, false) 
    elseif username == "" then 
        outputChatBox("Bitte trage deinen Benutzernamen ein!", 125, 0, 0, false) 
    elseif password == "" then 
        outputChatBox("Bitte trage dein Passwort ein!", 125, 0, 0, false) 
    end 
end 
addEventHandler("onClientGUIClick", Loginbtn, Loginklick, false) 
  
function OpenLogin() 
    playername = string.gsub ( getPlayerName ( player ), '#%x%x%x%x%x%x', '') 
    guiSetText(Username_edit, playername) 
    showPlayerHudComponent("all", false) 
    setCameraMatrix(1291, -1208, 94, 1503, -1453, 63, 0, 70) 
    showCursor(true) 
    local sx, sy, sw, sh = X*sWidth, (0-Height)*sHeight, 0, 0 
    local ex, ey, ew, eh = sx, Y, Width, Height 
    exports.gie:guiAddInterpolateEffect(Login_wnd, sx, sy, sw, sh, ex, ey, ew, eh, 2, "InElastic", "OutElastic", true) 
end 
addEventHandler("onClientResourceStart", resourceRoot, OpenLogin) 
  
function TestCloseLogin() 
    setCameraTarget(player) 
    showPlayerHudComponent("all", true) 
    showCursor(false) 
    guiSetVisible(Login_wnd, false) 
end 
addEvent("closeLoginPanel", true) 
addEventHandler("closeLoginPanel", gRoot, TestCloseLogin) 
  
addEventHandler("onClientMouseEnter", Eyebtn, EyeH, false) 
addEventHandler("onClientMouseLeave", Eyebtn, BackN) 
addEventHandler("onClientMouseEnter", Loginbtn, LoginH, false) 
addEventHandler("onClientMouseLeave", Loginbtn, BackN) 
addEventHandler("onClientMouseEnter", Regbtn, RegH, false) 
addEventHandler("onClientMouseLeave", Regbtn, BackN) 

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