Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createButton( x, y, w, h, text, Color, textColor )
- xOfset = 0;
- yOfset = 0;
- isVisableX = true;
- 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 ),
- 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( )
- if ( mouseX * Sx >= x + xOfset and mouseX * Sx <= w + xOfset + 10 and mouseY * Sy >= y + yOfset and mouseY * Sy <= h + yOfset + 20) then
- return true;
- end
- return false;
- end,
- setVisable = function ( visable )
- isVisableX = visable;
- 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
- }
- local create = function ()
- MButton.x = x; MButton.y = y;
- MButton.w = w; MButton.h = h;
- MButton.text = text; MButton.Color = Color;
- MButton.textColor = textColor;
- return MButton;
- end
- return create()
- end
- function createFrame( x, y, w, h, Title, Color, TitleBarColor )
- MFrame = {
- x = 0, y = 0,
- w = 400, h = 250,
- Title = "Frame",
- Color = tocolor( 120, 120, 120, 150 ),
- Color = tocolor( 120, 120, 120, 255 ),
- components = {
- },
- render = function ()
- dxDrawRectangle( x, y, w, h, Color, false)
- dxDrawRectangle( x, y, w, 15, TitleBarColor, false)
- dxDrawText( Title, x + 5, y )
- for k,v in pairs(MFrame.components) do
- v.render();
- end
- end,
- add = function ( comp )
- comp.setOfset(x, y)
- table.insert(MFrame.components, comp);
- end
- }
- function create()
- MFrame.x = x; MFrame.y = y;
- MFrame.w = w; MFrame.h = h;
- MFrame.Title = Title;
- MFrame.Color = Color; MFrame.TitleBarColor = TitleBarColor;
- return MFrame;
- end
- return create();
- end
- local Frame;
- local b1;
- function renderer ( )
- Frame.render();
- local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
- local x, y = guiGetScreenSize( )
- x2 = screenx * x;
- y2 = screeny * y;
- if ( b1.isMouseInside() ) then
- ButtonColor = tocolor( 200, 76, 60, 200 )
- b1.setColor(ButtonColor)
- else
- ButtonColor = tocolor( 231, 76, 60, 255 )
- b1.setColor(ButtonColor)
- end
- end
- function init()
- showCursor(true)
- ButtonColor = tocolor( 231, 76, 60, 255 )
- textColor = tocolor( 236, 240, 241, 255 )
- b1 = createButton( 10, 20, 80, 40, "Test Test", ButtonColor, textColor )
- FrameColor = tocolor( 231, 76, 60, 120 )
- Frame = createFrame( 400, 400, 450, 250, "Frame", FrameColor, FrameColor );
- Frame.add(b1)
- addEventHandler ( "onClientRender", root, renderer )
- end
- addEventHandler ( "onClientResourceStart", resourceRoot, init )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement