Jump to content

Please help to revive it.


Kirillrelax

Recommended Posts

Hello! Help me to revive the authorization to dxlib

 

This is on my client side,

exports.dxlib:dxEdit(24, 44, 175, 32, "")
exports.dxlib:dxEdit(24, 104, 175, 32, "")
exports.dxlib:dxButton ( "Авторизация", 23, 635, 178, 32, textura, fuente, color_enfasis )

DxButton

    -- ****************************************************************************
    --
    -- RECURSO: dxLib
    -- ARCHIVO: dxButton.lua
    -- PROPOSITO: Libreria de Botones
    -- CREADORES: Stefano Aguilera Humeney < Gothem >
    --
    -- ****************************************************************************

    Button = {}

    function dxButton ( text, x, y, w, h, textura, fuente, color_enfasis )

      -- Revisa que las funciones requeridas se hayan entregado correctamente
      assert( type( text ) == "string", "Mal argumento @ dxButton" );
    	assert( type( x ) == "number", "Mal argumento @ dxButton" );
    	assert( type( y ) == "number", "Mal argumento @ dxButton" );
      assert( type( w ) == "number", "Mal argumento @ dxButton" );
    	assert( type( h ) == "number", "Mal argumento @ dxButton" );
    	
      -- Crea el elemento de texto
      local self = Element ( 'dxButton' )
      
      if not self then return false end
      
      -- Agrega los datos requeridos al elemento
      self:setData ( 'text', text )
      self:setData ( 'x', x )
      self:setData ( 'y', y )
      self:setData ( 'w', w )
      self:setData ( 'h', h )
      self:setData ( 'visible', true )
      self:setData ( 'textura', textura )
      self:setData ( 'font', fuente or 'default' )
      self:setData ( 'font_size', 1 )
      self:setData ( 'color', (textura) and 0xBBAAAAAA or 0xAA000000 )
      self:setData ( 'colorEnfasis', color_enfasis or (textura) and 0xBBFFFFFF or 0xAA444444 )
      self:setData ( 'source', sourceResourceRoot )
      
      return self
      
    end

    function Button.render ( v, x, y, w, h )

      local text = v:getData ( 'text' )
      local textura = v:getData('textura')
      local fuente = v:getData('font')
      local color = v:getData('color')
      local color_enfasis = v:getData('colorEnfasis')
      local font_size = v:getData('font_size')
      local text_offset = v:getData('text_offset') or 0
      
      
      if textura then
        local color = ( isCursorInPosition ( x, y, w, h ) and not v:getData( 'disabled' ) ) and color_enfasis or color 
        dxDrawImage ( x, y, w, h, textura,0,0,0,color )
      else
        local color = ( isCursorInPosition ( x, y, w, h ) and not v:getData( 'disabled' ) ) and color_enfasis or color 
        dxDrawRectangle ( x, y, w, h, color )
      end
      dxDrawText ( text, x, y, w + x + text_offset, h + y, nil, font_size, fuente, 'center', 'center' )
      
    end

DxEdit

    -- ****************************************************************************
    --
    -- RECURSO: dxLib
    -- ARCHIVO: dxEdit.lua
    -- PROPOSITO: Libreria de Campo de edición
    -- CREADORES: Stefano Aguilera Humeney < Gothem >
    --            Federico Romero < TheCrazy >
    --
    -- ****************************************************************************

    addEvent ( 'dxEditChange' )

    Edit = {}

    -- element/dxEdit dxEdit ( int x, int y, int w, int h, string text )
    -- Crea una caja de edición de texto bajo los argumentos dados
    function dxEdit ( x, y, w, h, text )

      -- Revisa que las funciones requeridas se hayan entregado correctamente
    	assert( type( x ) == "number", "Mal argumento @ dxEdit" );
    	assert( type( y ) == "number", "Mal argumento @ dxEdit" );
      assert( type( w ) == "number", "Mal argumento @ dxEdit" );
    	assert( type( h ) == "number", "Mal argumento @ dxEdit" );
    	
      -- Crea el elemento de texto
      local self = Element ( 'dxEdit' )
      
      -- Si es que no se logro crear el elemento, devolver 'false' por el fallo e informar.
      if not self then
      
        outputDebugString( 'No se pudo crear el elemento de dxEdit', 2 )
        return false
      
      end
      
      if text then

        -- Revisa si el valor 'text' fue entregado correctamente
        if type( text ) ~= 'string' then
      
          outputDebugString ( "Mal argumento 'text' @ dxText", 2 )
      
        end
      
      else
      
        text = ''
        
      end
      
      -- Agrega los datos requeridos al elemento}
      self:setData ( 'source', sourceResourceRoot )
      self:setData ( 'visible', true )
      self:setData ( 'text', text )
      self:setData ( 'x', x )
      self:setData ( 'y', y )
      self:setData ( 'w', w )
      self:setData ( 'h', h )
      
      -- Devuelve el elemento ya codificado.
      return self
      
    end

    lastCaret = 0 -- Ultimo caret
    caretPos = 0 -- Posición del caret
    lastKey = 0 -- Tiempo de la ultima llave presionada

    -- void dxEditCharacter ( string key )
    -- Función que se llama cada vez que una tecla se presione
    function dxEditCharacter ( key )

      if not isElement( e_enfoque ) or e_enfoque.type ~= 'dxEdit'  then return end
      
      local text = e_enfoque:getData ( 'text' ) -- Se obtiene el texto.
      
      local new_text = utf8.sub ( text, 1, caretPos ) .. key .. utf8.sub ( text, caretPos + 1 ) -- Se codifica el texto con el nuevo caracter.
      
      triggerEvent ( 'dxEditChange', e_enfoque, new_text )
      
      -- Si es que el evento no fue cancelado, entonces procede a mostrar los cambios.
      if not wasEventCancelled () then
      
        e_enfoque:setData ( 'text', new_text )
        caretPos = caretPos + 1
      
      end

    end
    addEventHandler ( 'onClientCharacter', root, dxEditCharacter )

    -- bool setFocusedEdit ( element/dxEdit elemento )
    -- Pone en enfoque el dxEdit entregado.
    function setFocusedEdit ( elemento, bool )

      if not isElement( elemento ) or elemento.type ~= 'dxEdit' then
      
        outputDebugString ( "Mal argumento @ setFocusedEdit", 2 )
        return false
      
      end
    	if bool then
    		e_enfoque = elemento
    	else
    		e_enfoque = nil
    	end
      return true

    end

    -- bool Edit.render ( element/dxEdit self, int x, int y, int w, int h )
    -- Renderiza la caja de edición de texto
    function Edit.render ( self, x, y, w, h )

      local tick = getTickCount ()
      local text = self:getData ( 'text' )
      local mask = self:getData ( 'mask' )
      
      if mask then
      
        text = text:gsub('.','*')
      
      end
      
      dxDrawRectangle ( x, y, w, h, '0x99EEEEEE' )
      dxDrawRectangle ( x+2, y+2, w-4, h-4, '0xBB000000' )
      dxDrawText ( text, x + 6, y, w + x - 12, h + y, nil, 1, 'default', 'left', 'center' )
      
      
      
      if e_enfoque == self then
      
        if tick - lastKey > 100 then
      
          if getKeyState ( 'arrow_r' ) then
      
            caretPos = caretPos + 1
            lastKey = tick
            lastCaret = tick - 500
      
          elseif getKeyState ( 'arrow_l' ) and caretPos > 0 then
      
            caretPos = caretPos - 1
            lastKey = tick
            lastCaret = tick - 500
      
          elseif getKeyState ( 'backspace' ) and caretPos > 0 then
          
            caretPos = caretPos - 1
            lastKey = tick
            lastCaret = tick - 500
            
            local new_text = utf8.sub( text, 1, caretPos ) .. utf8.sub( text, caretPos + 2 )
            self:setData ( 'text' , new_text )
            
            triggerEvent ( 'dxEditChange', e_enfoque, new_text )
            
          elseif getKeyState ( 'delete' ) and caretPos < utf8.len ( text ) then
          
            lastKey = tick
            lastCaret = tick - 500
            
            local new_text = utf8.sub( text, 1, caretPos ) .. utf8.sub( text, caretPos + 2 )
            self:setData ( 'text' , new_text )
            
            triggerEvent ( 'dxEditChange', e_enfoque, new_text )
          
          end
      
        end
        
        if tick - lastCaret > 500 then
        
          if tick - lastCaret > 1000 then
          
            lastCaret = tick
          
          end
          
          if caretPos > utf8.len( text ) then caretPos = utf8.len( text ) end
        
          local fontHeight = dxGetFontHeight ()
          local caretOffset = dxGetTextWidth ( utf8.sub( text, 1, caretPos ) )
          dxDrawRectangle ( x + 5 + caretOffset, y + h/2 - fontHeight/2, 1, fontHeight, '0xFF6666FF' )
      
        end
      
      end

    end

Here who can write me an example that would be when pressing autoresize, was authorization?

Link to comment
exports.dxlib:dxEdit(24, 44, 175, 32, "")
exports.dxlib:dxEdit(24, 104, 175, 32, "")
button = exports.dxlib:dxButton ( "Авторизация", 23, 635, 178, 32, textura, fuente, color_enfasis )

addEventHandler('dxClick',button,function(clicked_button)
    --authorize player
end,false)

 

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