Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeFromTable( t, item )
- for k,v in pairs(t) do
- if ( v.getID() == item.getID() ) then
- table.remove(t, k);
- end
- end
- return t;
- end
- function Frame( Title, x, y, w, h, color )
- local visable = true;
- local comps = {};
- if ( not color ) then
- color = tocolor( 0, 0, 0, 120 )
- end
- local Frame = {
- draw = function ( )
- if ( visable ) then
- dxDrawRectangle( x, y, w, h, color ) -- the frame
- dxDrawRectangle( x, y, w - 20, 20, color + 20 ) -- titleBar
- dxDrawText( Title, x+ 5, y +2 ) -- titleBar text
- dxDrawRectangle( x + w - 20, y, 20, 20, color) -- x
- dxDrawText("X", x + w - 12, y + 2)
- end
- end,
- clicked = function ( button, state, nx, ny )
- if ( nx > x + w -20 and nx <= x + w and ny > y and ny < y + 20 ) then
- if ( button == "left" and state == "down" ) then
- visable = false;
- showCursor( false )
- for k,v in pairs(comps) do
- v.setVisable(false)
- end
- end
- end
- end,
- setVisable = function ( v )
- if ( v == true ) then
- visable = true;
- showCursor( true )
- for k,v in pairs(comps) do
- v.setVisable(true)
- end
- else
- visable = false;
- showCursor( false )
- for k,v in pairs(comps) do
- v.setVisable(false)
- end
- end
- end,
- getVisable = function ( )
- return visable;
- end,
- add = function ( comp )
- table.insert(comps, comp)
- comp.setOfset(x, y)
- addEventHandler( "onClientRender", getRootElement(), comp.draw )
- end,
- rem = function ( comp )
- removeFromTable(comps, comp)
- removeEventHandler( "onClientRender", getRootElement( ), comp.draw )
- end,
- center = function ( )
- local screenW, screenH = guiGetScreenSize();
- local windowW, windowH = w, h;
- local newX, newY = (screenW - windowW) /2,(screenH - windowH) /2;
- x = newX; y = newY
- end
- }
- function create( )
- addEventHandler( "onClientRender", getRootElement(), Frame.draw )
- addEventHandler( "onClientClick", getRootElement(), Frame.clicked )
- return Frame;
- end
- return create();
- end
- function drawToolTip( x, y, w, text )
- local h = 0;
- for i = 1, #text do
- h = h + 15
- end
- dxDrawRectangle( x, y, w, h, tocolor( 0, 0, 0, 255 ) )
- local nh = 0;
- for i = 1, #text do
- dxDrawText(text[i], x + 10, nh + y, 0, 0, tocolor( 255, 255, 255, 255 ), 1)
- nh = nh + 15
- end
- end
- function channel( name, id, x, y, w, h, color )
- local visable = true;
- local data = {};
- local players = {};
- local ofSet = Vector2(0, 0)
- if ( not color ) then
- color = tocolor( 0, 0, 0, 120 )
- end
- local channel = {
- draw = function ( )
- if ( visable ) then
- dxDrawRectangle( x + ofSet:getX(), y + ofSet:getY(), w, h, color )
- dxDrawText( name, ( (x + ofSet:getX()) + (w/2) ) - (string.len(name)*3), ((y + ofSet:getY()) - 7) + (h/2), 0, 0, tocolor( 255, 255, 255, 255 ), 1 )
- local sx, sy = guiGetScreenSize()
- local cx, cy = getCursorPosition()
- local nx, ny = (sx * cx), (sy * cy)
- if ( nx > x + ofSet:getX() and nx <= x + ofSet:getX() + w and ny > y + ofSet:getY() and ny <= y + ofSet:getY() + h ) then
- --dxDrawRectangle( nx, ny, 100, 20 )
- drawToolTip(nx+3, ny, 190, {"Mouamle", "Ali", "Mouamle2"})
- end
- end
- end,
- setOfset = function ( x, y )
- ofSet:setX(x)
- ofSet:setY(y)
- end,
- setVisable = function ( v )
- visable = v;
- end
- }
- function create( )
- return channel
- end
- return create();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement