Jump to content

Login panel problem


R.y.c.k

Recommended Posts

client

Xg,Yg =625,299 
local scrX,scrY = guiGetScreenSize() 
local x = scrX/2-Xg/2 
local y = scrY/2-Yg/2 
local x2 = x+388 
image1=0-389 
image2=Xg+237 
local infoTable = {} 
  
function onresourceStart () 
if image1 < x then 
image1 = image1+10 
guiSetPosition ( left, image1, y, false ) 
guiSetPosition ( name, image1+162, y+96, false ) 
guiSetPosition ( pass, image1+162, y+140, false ) 
guiSetPosition ( login, image1+235, y+175, false ) 
--guiSetPosition ( label, image1+220, y+214, false ) 
end 
    if image1 > x+1 then 
    image1 = 199 
    --outputChatBox(""..image1) 
    end 
if image2 >= x2 then 
guiSetPosition ( right, image2, y, false ) 
  
guiSetPosition ( register, image2+130, y+220, false ) 
  
image2 = image2-5 
end 
    if image2 < x2-1 then 
    image2 = image2+1 
    end 
dxDrawImage ( 0 , 0, scrX, scrY, 'img/Back.png', 0, 0, 0) 
  
end 
    xmlFileName = tostring("jsnl.xml") 
  
function HandleTheRendering ( ) 
    confFile = xmlLoadFile("preferences.xml") 
    if (confFile) then 
        infoTable["account"] = xmlNodeGetAttribute(confFile,"username") 
        infoTable["pass"] = xmlNodeGetAttribute(confFile,"pass") 
    else 
        confFile = xmlCreateFile("preferences.xml","user") 
        xmlNodeSetAttribute(confFile,"username","") 
        xmlNodeSetAttribute(confFile,"pass","") 
         
        infoTable["account"] = getPlayerName(localPlayer) 
        infoTable["pass"] = "" 
    end 
    xmlSaveFile(confFile) 
  
            guiSetInputEnabled(true) 
            showCursor(true) 
    left = guiCreateStaticImage( image1 , y, 389, Yg, 'img/LLeft.png', false)  
    right = guiCreateStaticImage( image2, y, 237, Yg, 'img/Right.png', false)  
     
    XxX = guiCreateButton(210,10,20,20,'X',false,right) 
    addEventHandler("onClientGUIClick",XxX,hideLoginWindow2) 
    guiSetAlpha(XxX,0) 
    if (infoTable["account"]) then 
        name = guiCreateEdit( image1, y, 150, 25, infoTable["account"], false)  
    else 
        name = guiCreateEdit( image1, y, 150, 25, '', false)  
    end 
     
    if (infoTable["pass"]) then 
        pass = guiCreateEdit( image1, y, 150, 25, infoTable["pass"], false)  
    else 
        pass = guiCreateEdit( image1, y, 150, 25, '', false)  
    end 
  
    login = guiCreateStaticImage( image1, y, 79, 32, 'img/login.png', false)  
     
    register = guiCreateStaticImage( image1, y, 75, 26, 'img/SignUp.png', false)  
     
    registerWindow = guiCreateStaticImage( scrX/2-545/2, scrY/2-425/2, 545, 425, 'img/win.png', false) 
    guiSetVisible(registerWindow, false) 
    nameReG = guiCreateEdit( 200, 150, 200, 50, '', false,registerWindow)  
    passReG = guiCreateEdit( 200, 220, 200, 50, '', false,registerWindow)  
  
    btnConfirmRegistration = guiCreateStaticImage( 200, 300, 168, 71, 'img/sin.png', false,registerWindow)  
     
    addEventHandler ( "onClientRender", root, onresourceStart ) -- keep the text visible with onClientRender.    
    addEventHandler("onClientGUIClick",login,onClickLogin) 
    addEventHandler("onClientGUIClick",register,onClickRegisterToggle) 
    addEventHandler("onClientGUIClick",btnConfirmRegistration,onClickRegisterConfirm) 
     
    for i,k in ipairs(getElementsByType("gui-staticimage")) do 
    if k ~= registerWindow then 
    guiSetProperty(k,'RiseOnClick','False') 
    else 
    end 
    end 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 
function hideLoginWindow2(button,state) 
    if(button == "left" and state == "up") then 
        if (source == XxX) then 
            guiSetVisible(registerWindow, false) 
  
    guiSetInputEnabled(false) 
    guiSetVisible(left, false) 
    guiSetVisible(name, false) 
    guiSetVisible(right, false) 
    guiSetVisible(pass, false) 
    guiSetVisible(login, false) 
    guiSetVisible(register, false) 
    showCursor(false) 
    removeEventHandler   ( "onClientRender", root, onresourceStart ) -- keep the text visible with onClientRender.   
        end 
    end 
end 
  
function hideRegisterWindow() 
    guiSetInputEnabled(true) 
    guiSetVisible(registerWindow, false) 
    showCursor(true) 
end 
addEvent("hideRegisterWindow", true) 
addEventHandler("hideRegisterWindow", getRootElement(), hideRegisterWindow) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(left, false) 
    guiSetVisible(name, false) 
    guiSetVisible(right, false) 
    guiSetVisible(pass, false) 
    guiSetVisible(login, false) 
    guiSetVisible(register, false) 
    showCursor(false) 
    removeEventHandler   ( "onClientRender", root, onresourceStart ) -- keep the text visible with onClientRender.   
  
    end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 
  
  
  
function onClickRegisterConfirm(button,state) 
    if(button == "left" and state == "up") then 
        if (source == btnConfirmRegistration) then 
            username = guiGetText(nameReG) 
            password = guiGetText(passReG) 
            passwordConfirm = guiGetText(passReG) 
            triggerServerEvent("onRequestRegister",getLocalPlayer(),username,password,passwordConfirm) 
        end 
    end 
end 
  
  
function onClickLogin(button,state) 
    if(button == "left" and state == "up") then 
        if (source == login) then 
            username = guiGetText(name) 
            password = guiGetText(pass) 
            triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password) 
            toggleSavePassword(true, username, password) 
        end 
    end 
end 
function toggleSavePassword(save, name, pass) 
    confFile = xmlLoadFile("preferences.xml") 
        xmlNodeSetAttribute(confFile, "username", name) 
        xmlNodeSetAttribute(confFile, "pass", pass) 
    xmlSaveFile(confFile) 
end 
  
function onClickRegisterToggle(button,state) 
    if(button == "left" and state == "up") then 
        if (source == register) then 
            guiSetVisible(registerWindow, true) 
            guiBringToFront(registerWindow) 
            guiSetInputEnabled(true) 
            showCursor(true) 
        end 
    end 
end 
  
  
addEventHandler( "onClientMouseEnter", getRootElement(),  
function () 
if (source == login) then 
guiStaticImageLoadImage ( login, "img/login2.png" ) 
elseif (source == register) then 
guiStaticImageLoadImage ( register, "img/SignUp2.png" ) 
end 
end 
) 
  
addEventHandler("onClientMouseLeave", getRootElement(),function () 
if (source == login ) then 
guiStaticImageLoadImage ( source, "img/login.png" ) 
elseif (source == register ) then 
guiStaticImageLoadImage ( source, "img/SignUp.png" ) 
end 
end 
) 
  
  
  
  

Link to comment
  • 2 weeks later...

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