Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createLayOut(x, y, w, h)
- local ofset = Vector2(0, 0);
- local visable = true;
- Panel = {
- x = 25, y = 25,
- w = 350, h = 600,
- comps = {},
- render = function ( )
- dxDrawRectangle( Panel.x+ ofset:getX(), Panel.y + ofset:getY(), Panel.w, Panel.h, tocolor( 0, 0, 0, 180 ) )
- for k,v in pairs(Panel.comps) do
- if ( v.getVisable() ) then
- v.setOfset(ofset:getX() + Panel.x, ofset:getY() + Panel.y)
- v.render();
- end
- end
- end,
- setVisable = function ( bool )
- visable = bool;
- end,
- getVisable = function ( )
- return visable
- end,
- setOfset = function ( x, y )
- ofset:setX(x)
- ofset:setY(y)
- end,
- isMouseInside = function ( )
- return false;
- end,
- add = function ( comp )
- comp.setOfset(Panel.x, Panel.y)
- table.insert(Panel.comps, comp)
- end
- }
- Panel.x = x; Panel.y = y; Panel.w = w; Panel.h = h;
- return Panel;
- end
- function CreateListView(x, y, w, h)
- local ofset = Vector2(0, 0);
- local visable = true;
- List = {
- x = 30, y = 30,
- w = 345, h = 595,
- Color = tocolor( 0, 0, 0, 255 ),
- items = {},
- render = function ( )
- local x = List.x + ofset:getX()
- local y = List.y + ofset:getY()
- local w = List.w + ofset:getX()
- local h = List.h + ofset:getY()
- dxDrawLine( x + 3, y + 5, w - 3, y + 5, List.Color, 3) -- top
- dxDrawLine( x + 3, h - 5, w - 3, h - 5, List.Color, 3) -- bottom
- dxDrawLine( x+3 , y+5, x+3, h-5 , List.Color, 3) -- left
- dxDrawLine( w-5 , h-5, w-5, y+5 , List.Color, 3) -- right
- for k,v in pairs(List.items) do
- if ( v ~= nil ) then
- if ( v.getY() + y > y and v.getY() + y + v.getH() < h ) then
- v.setOfset(x, y)
- v.render()
- dxDrawLine(x+2, v.getH() + v.getY() + 5 + y,
- w-3, v.getH() + 5 + v.getY() + y,
- List.Color, 2)
- end
- end
- end
- end,
- addItem = function (item)
- table.insert(List.items, item)
- end,
- setOfset = function ( x, y )
- ofset:setX(x)
- ofset:setY(y)
- end,
- setVisable = function ( bool )
- visable = bool;
- end,
- getVisable = function ( )
- return visable
- end,
- move = function ( state )
- for k,v in pairs(List.items) do
- if ( v ~= nil ) then
- if ( state == "up" ) then
- v.setY(v.getY() - List.items[1].getH())
- elseif ( state == "down" ) then
- v.setY(v.getY() + List.items[1].getH())
- end
- end
- end
- end
- }
- List.x = x; List.y = y; List.w = w; List.h = h;
- return List;
- end
- function createThePhone( x, y, width, height )
- local renderBG = true;
- local BGColor = tocolor( 255, 255, 255, 255 )
- local Visable = true;
- local TitleBarClicked = false;
- local LastClick = Vector2(0, 0);
- -- color = {99, 137, 168}
- local TitleBarColor = tocolor( 99, 137, 168, 255 )
- local function createTextButtons(x, y, w, h, text)
- local visable = true;
- local ofset = Vector2(0, 0)
- local Color = tocolor( 0, 0, 0, 10 )
- local ColorSpeare = Color;
- local HoverColor = tocolor( 0, 0, 0, 100 )
- Button = {
- text = "Button",
- x = 0, y = 0,
- w = 0, h = 0,
- render = function ( )
- dxDrawRectangle( Button.x + ofset:getX(), Button.y + ofset:getY(), w, h, Color )
- dxDrawText( Button.text, ( (Button.x + ofset:getX()) + (w/2) ) - (string.len(text)*3), ((Button.y + ofset:getY()) - 7) + (h/2) )
- --dxDrawText(Button.text, Button.x + ofset:getX(), Button.y + ofset:getY())
- end,
- getText = function ( )
- return Button.text;
- end,
- setOfset = function ( x, y )
- ofset = Vector2(x, y)
- end,
- hover = function ( hover )
- if ( hover ) then
- Color = HoverColor;
- else
- Color = ColorSpeare;
- end
- end,
- setVisable = function ( bool )
- visable = bool;
- end,
- getVisable = function ( )
- return visable
- end,
- isMouseInside = function ()
- if ( not isCursorShowing() ) then return false; end
- SX, SY = guiGetScreenSize(); MX, MY = getCursorPosition();
- NX = MX * SX; NY = MY * SY;
- if ( NX > x + ofset:getX() and NX <= w + ofset:getX() + x and NY > y + ofset:getY() and NY <= h + ofset:getY() + y ) then
- return true;
- end
- return false;
- end,
- onClick = function (b, state, x, y)
- if ( Button.isMouseInside() ) then
- if ( state == "down" ) then
- triggerEvent( "ButtonClicked", getRootElement(), b, Button )
- end
- end
- end
- }
- Button.x = x; Button.y = y; Button.text = text;
- addEventHandler( "onClientClick", getRootElement(), Button.onClick )
- return Button;
- end
- Phone = {
- x = 0, y = 0,
- -- 450, 750,
- width = 500, height = 800,
- comps = {},
- renderComps = function ()
- for k,v in pairs(Phone.comps) do
- if ( v ~= nil ) then
- if ( v.getVisable() ) then
- v.setOfset(Phone.x, Phone.y)
- v.render()
- if ( v.isMouseInside() ) then
- v.hover(true);
- else
- v.hover(false);
- end
- end
- end
- end
- end,
- renderBGImage = function ()
- if ( renderBG ) then
- dxDrawImage( Phone.x + 25, Phone.y + 30, 350, 600, "/res/bgs/MainBG.png" )
- end
- end,
- renderTitleBar = function ()
- dxDrawRectangle( Phone.x, Phone.y, Phone.width, 25, TitleBarColor )
- dxDrawText("Mta sa Telegram : " .. getPlayerName(getLocalPlayer()), Phone.x + 5, Phone.y + 5)
- end,
- render = function ()
- if ( Visable ) then
- local MX, MY = getCursorPosition();
- local SX, SY = guiGetScreenSize();
- local nx, ny = MX * SX, SY * MY
- if ( TitleBarClicked ) then
- Phone.x = nx;
- Phone.y = ny;
- end
- dxDrawRectangle( Phone.x, Phone.y, Phone.width, Phone.height, BGColor )
- Phone.renderBGImage()
- Phone.renderTitleBar();
- Phone.renderComps()
- end
- end,
- onTitleBarClick = function ( b, s, x, y )
- if ( b == "left" ) then
- if ( s == "down" ) then
- if ( x > Phone.x and x <= Phone.width + x and y > Phone.y and y <= Phone.y + 25 ) then
- TitleBarClicked = true;
- end
- else
- TitleBarClicked = false;
- end
- end
- end,
- add = function (comp)
- table.insert(Phone.comps, comp)
- end,
- rem = function (comp)
- for k, v in pairs(Phone.comps) do
- if ( v.getName() == comp.getName() ) then
- table.remove(Phone.comps, k)
- end
- end
- end,
- xClicked = function ( b, the )
- Visable = false;
- for k,v in pairs(Phone.comps) do
- v.setVisable(false)
- end
- showCursor(false)
- bindKey ( "F5", "down",
- function ()
- Visable = true;
- for k,v in pairs(Phone.comps) do
- v.setVisable(true)
- end
- showCursor(true)
- end
- )
- end,
- }
- Phone.x = x; Phone.y = y; Phone.width = width; Phone.height = height;
- b1 = createTextButtons(375, 0, 25, 25, "X")
- Phone.add(b1)
- addEvent( "ButtonClicked", false )
- addEventHandler( "onClientClick", getRootElement(), Phone.onTitleBarClick )
- addEventHandler( "ButtonClicked", getRootElement(), Phone.xClicked )
- return Phone;
- end
- function createButton( x, y, w, h, text, Color, textColor )
- local xOfset = 0;
- local yOfset = 0;
- local isVisableX = true;
- local mouseInside = false;
- local swap = Color;
- local swapCheck = 0;
- local test = 0;
- local MButton = {
- x = 0, y = 0,
- w = 80, h = 20,
- text = "Button",
- isVisable = isVisableX,
- textColor = tocolor( 236, 240, 241, 255 ),
- Color = tocolor( 231, 76, 60, 150 ),
- type = "Button",
- render = function ()
- if ( isVisableX == true ) then
- dxDrawRectangle( x + xOfset, y + yOfset, w, h, Color )
- dxDrawText( text, ( (x + xOfset) + (w/2) ) - (string.len(text)*3), ((y + yOfset) - 7) + (h/2) )
- end
- end,
- isMouseInside = function ()
- mouseX, mouseY = getCursorPosition();
- if ( not isCursorShowing ( ) ) then
- return false
- end
- local Sx, Sy = guiGetScreenSize( )
- x2 = Sx * mouseX;
- y2 = Sy * mouseY;
- --outputChatBox(y + yOfset .. " : " .. h + yOfset + 40 .. ", " .. math.floor(y2))
- --outputChatBox(x + xOfset .. " : " .. w + xOfset + x .. ", " .. math.floor(x2))
- if ( x2 >= x + xOfset and x2 <= w + xOfset + x and y2 >= y + yOfset and y2 <= h + yOfset + y) then
- return true;
- end
- return false;
- end,
- highlight = function ( value )
- if ( swapCheck == 0 ) then
- swap = Color;
- swapCheck = 1;
- Color = Color + value
- end
- end,
- dehighlight = function ()
- Color = swap;
- swapCheck = 0;
- end,
- setVisable = function ( visable )
- isVisableX = visable;
- end,
- getVisable = function ( )
- return isVisableX;
- end,
- setTextColor = function ( color )
- textColor = color;
- end,
- setTextColorRGBA = function ( r, g, b, a )
- textColor = tocolor( r, g, b, a )
- end,
- getText = function ( )
- return text;
- end,
- setText = function ( text2 )
- text = text2;
- end,
- setColor = function ( Color2 )
- Color = Color2;
- end,
- setColorRGBA = function ( r, g, b, a )
- Color = tocolor( r, g, b, a )
- end,
- getColorRGBA = function ( )
- end,
- setOfset = function ( ofx, ofy )
- xOfset = ofx;
- yOfset = ofy;
- end,
- setX = function (x2) x = x2 end,
- getX = function () return x; end,
- setY = function (y2) y = y2 end,
- getY = function () return y; end,
- setW = function (w2) w = w2 end,
- getW = function () return w; end,
- setH = function (h2) h = h2 end,
- getH = function () return h; end,
- Click = function ( button, state )
- if ( not mouseInside ) then
- return;
- end
- if ( test == 0 ) then
- triggerEvent( "onMButtonClicked", getRootElement(), button, state, text, x, y, w, h )
- test = 1;
- Color = Color + 30;
- setTimer( function ()
- test = 0;
- Color = Color - 30;
- end, 150, 1 )
- end
- end,
- }
- local update = function ()
- mouseInside = MButton.isMouseInside();
- end
- local create = function ()
- MButton.x = x; MButton.y = y;
- MButton.w = w; MButton.h = h;
- MButton.text = text; MButton.Color = Color;
- MButton.textColor = textColor;
- addEventHandler( "onClientClick", getRootElement(), MButton.Click )
- addEventHandler( "onClientRender", getRootElement(), update )
- return MButton;
- end
- return create()
- end
- local phone;
- local panel;
- local list;
- local button1;
- local button2;
- local up, down;
- local buttons = { }
- function render()
- phone.render();
- panel.add(up)
- panel.add(down)
- panel.add(list)
- --panel.add(button1)
- for k,v in pairs(buttons) do
- list.addItem(v)
- end
- --list.addItem(button1)
- --list.addItem(button2)
- phone.add(panel)
- end
- function init( )
- phone = createThePhone(0, 0, 400, 650 );
- list = CreateListView(0, 30, 350, 600)
- panel = createLayOut(25, 30, 350, 600)
- up = createButton(260, 6, 80, 20, "UP", tocolor( 0, 0, 0, 120 ), tocolor( 255, 255, 255, 255 ))
- down = createButton(10, 6, 80, 20, "DOWN", tocolor( 0, 0, 0, 120 ), tocolor( 255, 255, 255, 255 ))
- i = 1;
- -- getElementsByType( "player" )
- tempT = {"Mouamle_",}
- for i = 0, 30 do
- table.insert(tempT, "User"..i )
- end
- for k,v in pairs(tempT) do
- buttons[#buttons+1] = createButton(10, 10 + i, 330, 20, v, tocolor( 0, 0, 0, 120 ), tocolor( 255, 255, 255, 200 ) )
- i = i + 30
- end
- --button1 = createButton(10, 10, 80, 20, "Fuck", tocolor( 0, 0, 0, 120 ), tocolor( 255, 255, 255, 200 ) )
- --button2 = createButton(10, 40, 80, 20, "Fuck 2", tocolor( 0, 0, 0, 120 ), tocolor( 255, 255, 255, 200 ) )
- addEventHandler( "onClientRender", getRootElement( ), render )
- showChat( true )
- showCursor( true )
- end
- addEventHandler ( "onClientResourceStart", resourceRoot, init )
- function handleButtons( button, state, text )
- if ( button == "left" and state == "down" ) then
- if ( text == up.getText() ) then
- list.move("up")
- elseif ( text == down.getText()) then
- list.move("down")
- end
- end
- end
- addEvent( "onMButtonClicked" )
- addEventHandler( "onMButtonClicked", getRootElement( ), handleButtons )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement