Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local super = Class("LoginGui", Container3D, function()
- static.getInstance = function()
- return LuaObject.getSingleton(static)
- end
- end).getSuperclass()
- -- Login..
- function LoginGui:init()
- super.init(self)
- sx,sy = guiGetScreenSize()
- x,y = (sx/1920), (sy/1080)
- self:setBounds(0, 0, sx, sy)
- self.hudComponents = {"weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "radar", "area_name"}
- for _,component in pairs (self.hudComponents) do
- showPlayerHudComponent(component,false)
- end
- setWindowFlashing(true)
- self:css([[
- button {
- color: #FFFFFF;
- background-color: #3582FD;
- cursor: pointer;
- border-radius: 25px;
- }
- button:hover {
- color: #FFFFFF;
- background-color: #5D35FD;
- cursor: pointer;
- }
- button:active{
- color: #FFFFFF;
- background-color: #FF8100;
- cursor: pointer;
- }
- button:focus {
- color: #FFFFFF;
- background-color: #6E35FD;
- cursor: pointer;
- }
- button:disabled {
- background-color: #eaeaea;
- color: #bebebe;
- cursor: not-allowed;
- }
- label {
- background-color: #000000;
- cursor: pointer;
- }
- ]])
- --=====================================================================--
- -- Login Panel component
- --=====================================================================--
- self.loginPanel = Panel ()
- self.loginPanel:setBorder(LineBorder(tocolor(0,0,0), 1))
- self.loginPanel:setBackground(tocolor(0,0,0,160))
- self.loginPanel:setBounds((sx-x*700) / 2, (sy-y*800) / 2, x*700, y*800)
- self:add(self.loginPanel)
- --=====================================================================--
- -- Welcome text
- --=====================================================================--
- self.welcomeLabel = Label("Balkan-Gaming")
- self.welcomeLabel:setForeground(tocolor(255,255,255))
- self.welcomeLabel:setBackground(tocolor(0,0,0))
- self.welcomeLabel:setScale(y*7.5)
- self.welcomeLabel:setBounds(x*5, y*70, x*100, y*5)
- self.welcomeLabel:setFont('clear-normal')
- self.loginPanel:add(self.welcomeLabel)
- --=====================================================================--
- -- Username Lable
- --=====================================================================--
- self.user = TextField ()
- self.user:setBackground(tocolor(255,255,255,240))
- self.user:setBounds(x*200, y*168, x*300, y*50)
- self.loginPanel:add(self.user)
- self.logo = Image()
- self.logo:setSource("images/user.png")
- self.logo:setBounds(x*140, y*170, x*50, y*50)
- self.loginPanel:add(self.logo)
- --=====================================================================--
- -- PAssword Lable
- --=====================================================================--
- self.pass = PasswordField ()
- self.pass:setBackground(tocolor(255,255,255,240))
- self.pass:setBounds(x*200, y*240, x*300, y*50)
- self.loginPanel:add(self.pass)
- self.logo = Image()
- self.logo:setSource("images/lock.png")
- self.logo:setBounds(x*140, y*242, x*50, y*46)
- self.loginPanel:add(self.logo)
- --=====================================================================--
- -- Remember me
- --=====================================================================--
- self.rememberMe = Label("Remember me")
- self.rememberMe:setForeground(tocolor(255,255,255))
- self.rememberMe:setBackground(tocolor(0,0,0))
- self.rememberMe:setScale(y*1.5)
- self.rememberMe:setBounds(x*135, y*310, x*100, y*5)
- self.rememberMe:setFont('clear-normal')
- self.loginPanel:add(self.rememberMe)
- self.checkBox = Checkbox('')
- self.checkBox:setBounds(x*295, y*302, x*25, y*25)
- self.checkBox:setLabelColor(tocolor( 255, 255,255,255))
- self.loginPanel:add(self.checkBox)
- --=====================================================================--
- -- Login button
- --=====================================================================--
- self.loginButton = Button("Login")
- self.loginButton:addActionListener(self)
- self.loginButton:addMouseListener(self)
- self.loginButton:setBounds(x*140, y*340, x*360, y*50)
- --self.loginButton:setBorder(LineBorder(tocolor(255,0,0), 3)
- self.loginButton:addMouseListener({
- mousePressed = function()
- outputDebugString("login is pressed")
- username = self.user:getText()
- password = self.pass:getText()
- triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,self.rememberMe:getState())
- end
- end
- })
- self.loginPanel:add(self.loginButton)
- --=====================================================================--
- -- Error message
- --=====================================================================--
- self.ErrorMsg = Label("")
- self.ErrorMsg:setForeground(tocolor(255,255,255))
- self.ErrorMsg:setBackground(tocolor(0,0,0))
- self.ErrorMsg:setScale(y*2)
- self.ErrorMsg:setBounds(x*140, y*400, x*100, y*5)
- self.ErrorMsg:setFont('clear-normal')
- self.loginPanel:add(self.ErrorMsg)
- --=====================================================================--
- -- Dont have account panel
- --=====================================================================--
- self.subPanel = Panel ()
- self.subPanel:setBackground(tocolor(0,0,0,150))
- self.subPanel:setBounds(x*0, y*430, x*700, y*50)
- self.subPanel:setBorder(LineBorder(tocolor(0,0,0), 1))
- self.subPanel:addMouseListener({
- mousePressed = function()
- RegisterGui.getInstance():setVisible(true)
- LoginGui.getInstance():setVisible(false)
- end
- })
- self.loginPanel:add(self.subPanel)
- self.userLabel = Label("Do not have account?")
- self.userLabel:setForeground(tocolor(53,130,253))
- self.userLabel:setBackground(tocolor(0,0,0,255))
- self.userLabel:setScale(y*3.5)
- self.userLabel:setBounds(x*140, y*450, x*100, y*5)
- self.userLabel:setFont('clear-normal')
- self.loginPanel:add(self.userLabel)
- --=====================================================================--
- -- News
- --=====================================================================--
- self.newsLabel = Label("NEWS:")
- self.newsLabel:setForeground(tocolor(255,255,255))
- self.newsLabel:setBackground(tocolor(0,0,0,255))
- self.newsLabel:setScale(y*3.5)
- self.newsLabel:setBounds(x*40, y*500, x*100, y*5)
- self.newsLabel:setFont('clear-normal')
- self.loginPanel:add(self.newsLabel)
- self.subPanel = Panel ()
- self.subPanel:setBackground(tocolor(255,255,255))
- self.subPanel:setBounds(x*40, y*530, x*620, y*250)
- self.subPanel:setBorder(LineBorder(tocolor(0,0,0), 1))
- self.loginPanel:add(self.subPanel)
- self.newsText = Label("-Login system is 20% done \n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd\n-asdfjasdfsdafasd")
- self.newsText:setForeground(tocolor(0,0,0))
- self.newsText:setBackground(tocolor(0,0,0,255))
- self.newsText:setScale(y*1.5)
- self.newsText:setBounds(x*50, y*550, x*5, y*5)
- self.newsText:setFont('default-normal')
- self.loginPanel:add(self.newsText)
- --[[ self.userLabel = Label("Username:")
- self.userLabel:setForeground(tocolor(255,255,255))
- self.userLabel:setBackground(tocolor(0,0,0))
- self.userLabel:setScale(y*2)
- self.userLabel:setBounds(x*4, y*160, x*100, y*5)
- self.userLabel:setFont('clear-normal')
- self.userLabel:addMouseListener({
- mousePressed = function()
- outputChatBox("pressed")
- end
- })
- self.loginPanel:add(self.userLabel)]]--
- local username, password = loadLoginFromXML()
- if not( username == "" or password == "") then
- self.rememberMe:setSelected(true)
- self.user:setText(username)
- self.pass:setText(password)
- else
- self.rememberMe:setSelected(false)
- self.user:setText(username)
- self.pass:setText(password)
- end
- --self:setRotationY(45)
- --self:setRotationX(80)
- self.loginPanel:add(self.loginButton)
- function self:mouseEntered (e)
- if (e.source == self.loginButton) then
- outputConsole("hover")
- end
- end
- showCursor ( true )
- return self
- end
- --Register..
- local super = Class("RegisterGui", Container3D, function()
- static.getInstance = function()
- return LuaObject.getSingleton(static)
- end
- end).getSuperclass()
- function RegisterGui:init()
- super.init(self)
- sx,sy = guiGetScreenSize()
- x,y = (sx/1920), (sy/1080)
- self:setBounds(0, 0, sx, sy)
- self:setVisible(false)
- self:css([[
- button {
- color: #FFFFFF;
- background-color: #3582FD;
- cursor: pointer;
- border-radius: 25px;
- }
- button:hover {
- color: #FFFFFF;
- background-color: #5D35FD;
- cursor: pointer;
- }
- button:active{
- color: #FFFFFF;
- background-color: #FF8100;
- cursor: pointer;
- }
- button:focus {
- color: #FFFFFF;
- background-color: #6E35FD;
- cursor: pointer;
- }
- button:disabled {
- background-color: #eaeaea;
- color: #bebebe;
- cursor: not-allowed;
- }
- label {
- background-color: #000000;
- cursor: pointer;
- }
- ]])
- self.loginPanel = Panel ()
- self.loginPanel:setBorder(LineBorder(tocolor(0,0,0), 1))
- self.loginPanel:setBackground(tocolor(0,0,0,160))
- self.loginPanel:setBounds((sx-x*700) / 2, (sy-y*450) / 2, x*700, y*450)
- self:add(self.loginPanel)
- --=====================================================================--
- -- Welcome to balkan Gaming text
- --=====================================================================--
- self.welcomeLabel = Label("Balkan-Gaming")
- self.welcomeLabel:setForeground(tocolor(255,255,255))
- self.welcomeLabel:setBackground(tocolor(0,0,0))
- self.welcomeLabel:setScale(y*7.5)
- self.welcomeLabel:setBounds(x*5, y*70, x*100, y*5)
- self.welcomeLabel:setFont('clear-normal')
- self.loginPanel:add(self.welcomeLabel)
- --=====================================================================--
- -- User register text & image
- --=====================================================================--
- self.userRegister = TextField ()
- self.userRegister:setBackground(tocolor(255,255,255,240))
- self.userRegister:setBounds(x*200, y*168, x*300, y*50)
- self.loginPanel:add(self.userRegister)
- self.logo = Image()
- self.logo:setSource("images/user.png")
- self.logo:setBounds(x*140, y*170, x*50, y*50)
- self.loginPanel:add(self.logo)
- --=====================================================================--
- -- Password register text & image
- --=====================================================================--
- self.passRegister = PasswordField ()
- self.passRegister:setBackground(tocolor(255,255,255,240))
- self.passRegister:setBounds(x*200, y*240, x*300, y*50)
- self.loginPanel:add(self.passRegister)
- self.logo = Image()
- self.logo:setSource("images/lock.png")
- self.logo:setBounds(x*140, y*242, x*50, y*46)
- self.loginPanel:add(self.logo)
- --=====================================================================--
- -- Register button
- --=====================================================================--
- self.registerButton = Button("Register")
- self.registerButton:addActionListener(self)
- self.registerButton:addMouseListener(self)
- self.registerButton:setBounds(x*140, y*300, x*360, y*50)
- --self.registerButton:setBorder(LineBorder(tocolor(255,0,0), 3)
- self.registerButton:addMouseListener({
- mousePressed = function()
- outputDebugString("register is pressed")
- username = self.userRegister:getText()
- password = self.passRegister:getText()
- triggerServerEvent("onRequestRegister",getLocalPlayer(),username,password)
- end
- })
- self.loginPanel:add(self.registerButton)
- --=====================================================================--
- -- Error message
- --=====================================================================--
- self.ErrorMsg = Label("")
- self.ErrorMsg:setForeground(tocolor(255,255,255))
- self.ErrorMsg:setBackground(tocolor(0,0,0))
- self.ErrorMsg:setScale(y*2)
- self.ErrorMsg:setBounds(x*30, y*370, x*100, y*5)
- self.ErrorMsg:setFont('clear-normal')
- self.loginPanel:add(self.ErrorMsg)
- --=====================================================================--
- -- Return to login-panel
- --=====================================================================--
- self.subPanel = Panel ()
- self.subPanel:setBackground(tocolor(0,0,0,150))
- self.subPanel:setBounds(x*0, y*400, x*700, y*50)
- self.subPanel:setBorder(LineBorder(tocolor(0,0,0), 1))
- self.subPanel:addMouseListener({
- mousePressed = function()
- RegisterGui.getInstance():setVisible(false)
- LoginGui.getInstance():setVisible(true)
- end
- })
- self.loginPanel:add(self.subPanel)
- self.userLabel = Label("Go back to login")
- self.userLabel:setForeground(tocolor(53,130,253))
- self.userLabel:setBackground(tocolor(0,0,0,255))
- self.userLabel:setScale(y*3.5)
- self.userLabel:setBounds(x*170, y*420, x*100, y*5)
- self.userLabel:setFont('clear-normal')
- self.loginPanel:add(self.userLabel)
- --self:setRotationY(45)
- --self:setRotationX(80)
- function self:mouseEntered (e)
- if (e.source == self.loginButton) then
- outputConsole("hover")
- end
- end
- showCursor ( true )
- return self
- end
- addEventHandler("onClientResourceStart", resourceRoot,
- function ()
- Toolkit.getInstance():add(LoginGui.getInstance())
- Toolkit.getInstance():add(RegisterGui.getInstance())
- end)
- -- camera matrix
- local sm = {}
- sm.moov = 0
- sm.object1, sm.object2 = nil, nil
- function removeCamHandler ()
- if(sm.moov == 1) then
- sm.moov = 0
- removeEventHandler ( "onClientPreRender", getRootElement(), camRender )
- end
- end
- function camRender ()
- local x1, y1, z1 = getElementPosition ( sm.object1 )
- local x2, y2, z2 = getElementPosition ( sm.object2 )
- setCameraMatrix ( x1, y1, z1, x2, y2, z2 )
- end
- function smoothMoveCamera ( x1, y1, z1, x1t, y1t, z1t, x2, y2, z2, x2t, y2t, z2t, time )
- if(sm.moov == 1) then return false end
- sm.object1 = createObject ( 1337, x1, y1, z1 )
- sm.object2 = createObject ( 1337, x1t, y1t, z1t )
- setElementAlpha ( sm.object1, 0 )
- setElementAlpha ( sm.object2, 0 )
- setObjectScale(sm.object1, 0.01)
- setObjectScale(sm.object2, 0.01)
- moveObject ( sm.object1, time, x2, y2, z2, 0, 0, 0, "InOutQuad" )
- moveObject ( sm.object2, time, x2t, y2t, z2t, 0, 0, 0, "InOutQuad" )
- addEventHandler ( "onClientPreRender", getRootElement(), camRender )
- sm.moov = 1
- setTimer ( removeCamHandler, time, 1 )
- setTimer ( destroyElement, time, 1, sm.object1 )
- setTimer ( destroyElement, time, 1, sm.object2 )
- return true
- end
- addEventHandler( "onClientResourceStart", resourceRoot, function ()
- smoothMoveCamera (347.81658935547, -2080.3334960938, 39.87149810791, 348.34210205078, -2079.5559082031, 39.526397705078, 370.61679077148,-1815.0050048828,21.591299057007,370.6340637207,-1814.0289306641,21.37428855896,60000)
- fadeCamera(true)
- introMusic = playSound("sounds/intro.mp3") --Play wasted.mp3 from the sounds folder
- setSoundVolume(introMusic, 0.5) -- set the sound volume to 50%
- end
- );
- function Error_msg(Tab, Text)
- if Tab == "Login" then
- local login =LoginGui.getInstance();
- --guiSetText(login_tab_error_msg, tostring(Text))
- login.ErrorMsg:setText(tostring(Text))
- --LoginGui.getInstance():setText("OPA")
- setTimer(function() login.ErrorMsg:setText("") end,6000,1)
- elseif Tab == "Register" then
- local register = RegisterGui.getInstance();
- register.ErrorMsg:setText(tostring(Text))
- setTimer(function() register.ErrorMsg:setText("") end,6000,1)
- end
- end
- addEvent("set_warning_text",true)
- addEventHandler("set_warning_text",getRootElement(),Error_msg)
- function hideLoginWindow()
- toggleAllControls(true)
- if isElement(introMusic)then stopSound(introMusic) introMusic = nil end
- Toolkit.getInstance():remove(LoginGui.getInstance())
- fadeCamera(true,1)
- outputDebugString("xd")
- setCameraTarget(localPlayer)
- showCursor(false)
- removeCamHandler()
- end
- addEvent("hideLoginWindow", true)
- addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
- function checkPlayerAlive()
- triggerServerEvent("wasPlayerAliveEvent", getLocalPlayer())
- end
- addEvent("onPlayerLoginSuccess", true)
- addEventHandler("onPlayerLoginSuccess", getRootElement(), checkPlayerAlive)
- function saveLoginToXML(username, password)
- local xml_save_log_File = xmlLoadFile ("@userdata.xml")
- if not xml_save_log_File then
- xml_save_log_File = xmlCreateFile("@userdata.xml", "login")
- end
- if (username ~= "") then
- local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
- if not usernameNode then
- usernameNode = xmlCreateChild(xml_save_log_File, "username")
- end
- xmlNodeSetValue (usernameNode, tostring(username))
- end
- if (password ~= "") then
- local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
- if not passwordNode then
- passwordNode = xmlCreateChild(xml_save_log_File, "password")
- end
- xmlNodeSetValue (passwordNode, tostring(password))
- end
- xmlSaveFile(xml_save_log_File)
- xmlUnloadFile (xml_save_log_File)
- end
- addEvent("saveLoginToXML", true)
- addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML)
- function resetSaveXML()
- local xml_save_log_File = xmlLoadFile ("@userdata.xml")
- if not xml_save_log_File then
- xml_save_log_File = xmlCreateFile("@userdata.xml", "login")
- end
- if (username ~= "") then
- local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
- if not usernameNode then
- usernameNode = xmlCreateChild(xml_save_log_File, "username")
- end
- end
- if (password ~= "") then
- local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
- if not passwordNode then
- passwordNode = xmlCreateChild(xml_save_log_File, "password")
- end
- xmlNodeSetValue (passwordNode, "")
- end
- xmlSaveFile(xml_save_log_File)
- xmlUnloadFile (xml_save_log_File)
- end
- addEvent("resetSaveXML", true)
- addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement