mouamle Posted April 28, 2016 Share Posted April 28, 2016 (edited) نشرت موضوع قبل يوم عن الفنكشنات اللي سويتها كانت مجرد تجربه وشفتها نجحت *-* ف عدلت عليها وظفت فنكشنات أكثر الأحداث "onMButtonClicked" -- من تضغط على زر "onMFrameClicked" -- من تضغط على شريط العنوان للنافذه "onMTextBoxClicked" -- واضح من أسمه "onKeyTyped" -- من ينكتب الحرف داخل ال textBox "onKeyPressed" -- من تظغط على الحرف سواء تمت كتابته أو لا Frame --[[ createFrame( x - أحداثي x للأطار y - أحداثي y للأطار w - عرض الأطار h - أرتفاع الأطار Title - عنوان الأطار Color - لون الأطار TitleBarColor - لون شريط العنوان withX - أذا تريد يحط علامة أكس لأخفاء الاطار ) ]] function createFrame( x, y, w, h, Title, Color, TitleBarColor, withX ) local isVisableX = true; local isMouseInsideX = false; local FrameTrigger = 0; local TempComponents = {}; MFrame = { x = 0, y = 0, w = 400, h = 250, Title = "Frame", Color = tocolor( 120, 120, 120, 150 ), Color = tocolor( 120, 120, 120, 255 ), type = "Frame", isX = false, components = { }, isMouseOnTitleBar = function () mouseX, mouseY = getCursorPosition(); if ( not isCursorShowing ( ) ) then return false; end local Sx, Sy = guiGetScreenSize( ) mx = mouseX * Sx; my = mouseY * Sy; --outputChatBox( y .. " : " .. h + .. ", " .. mx ) if ( mx > x and mx <= x + w + 10 and my > y and my <= y + 15 ) then return true; end return false; end, clear = function () for k,v in pairs(MFrame.components) do if ( v.getText() ~= "X" ) then v.setVisable(false) end end end, setTitle = function ( newTitle ) Title = newTitle; end, setX = function ( newX ) x = newX; end, setY = function ( newY ) y = newY; end, setVisable = function ( visable ) isVisableX = visable; end, render = function () if ( isVisableX ) then dxDrawRectangle( x, y, w, h, Color, false) dxDrawRectangle( x, y, w, 30, TitleBarColor, false) dxDrawText( Title, x + 5, y + 7) for k,v in pairs(MFrame.components) do v.setOfset(x, y) if ( v.type ~= "TextBox" ) then if ( v.isMouseInside() ) then v.highlight(30); else v.dehighlight(); end end v.render(); end end end, add = function ( comp ) comp.setOfset(x, y) table.insert(MFrame.components, comp); TempComponents = MFrame.components; end, click = function ( button, state ) if ( not isMouseInsideX ) then return; end if ( FrameTrigger == 0 ) then triggerEvent( "onMFrameClicked", getRootElement(), button, state ) FrameTrigger = 1; setTimer( function ( ) FrameTrigger = 0; end, 150, 1 ) end end } function close( button, state, text ) if ( text == "X" and button == "left" and state == "down" ) then isVisableX = false; showCursor( false ) end end function createX( x, y, w, h) if ( withX ) then Color = TitleBarColor + 10; TextColor = TitleBarColor - 10; x = createButton( w - 30, 0, 30, 30, "X", Color, textColor ) MFrame.add(x); addEventHandler( "onMButtonClicked", getRootElement( ), close ) end end function Cliced( button, state ) end function updae() isMouseInsideX = MFrame.isMouseOnTitleBar(); end function create() addEvent( "onMButtonClicked", true ) addEvent( "onMFrameClicked" ) MFrame.x = x; MFrame.y = y; MFrame.w = w; MFrame.h = h; MFrame.Title = Title; MFrame.Color = Color; MFrame.TitleBarColor = TitleBarColor; createX(x, y, w, h); addEventHandler( "onClientClick", getRootElement(), MFrame.click ) addEventHandler( "onClientRender", getRootElement(), updae ) addEventHandler( "onMFrameClicked", getRootElement( ), Cliced ) return MFrame; end return create(); end Button --[[ createButton( x - أحداثي x للزر y - أحداثي y للزر w - عرض الزر h - أرتفاع الزر text - النص اللي يضهر داخله Color - لون مربع الزر textColor - لون النص ) ]] 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 Label --[[ text - النص x - أحداثي x y - أحداثي y Color - اللون ]] function createLabel( text, x, y, Color) local xOfset = 0; local yOfset = 0; local isVisable = true; MLabel = { x = 0, y = 0, text = "Label", Color = tocolor( 120, 21, 0, 255 ), type = "Label", render = function () if ( isVisable ) then dxDrawText( text, x + xOfset, y + yOfset, 0, 0, Color ) end end, setVisable = function( visable ) isVisable = visable; end, setOfset = function ( ofx, ofy ) xOfset = ofx; yOfset = ofy; end, setText = function ( Text ) text = Text; end, getText = function () return text; end, setX = function ( newX ) x = newX; end, getX = function ( ) return x; end, setY = function ( newY ) y = newY; end, getY = function ( ) return y; end, isMouseInside = function ( ) end, dehighlight = function ( ) end } function create() MLabel.x = x; MLabel.y = y; MLabel.text = text; MLabel.Color = Color; return MLabel; end return create(); end راح تفهم تقريباً نص الفنكشنات من المثال Example local fps = false function getCurrentFPS() return fps end local function updateFPS(msSinceLastFrame) fps = (1 / msSinceLastFrame) * 1000 end addEventHandler("onClientPreRender", root, updateFPS) local Frame; local b1; local b2; local b3; local l1; function renderer ( ) Frame.render(); end function init() showCursor(true) ButtonColor = tocolor( 255, 76, 60, 255 ) textColor = tocolor( 236, 240, 241, 255 ) b1 = createButton( 10, 40, 80, 40, "Button1", ButtonColor, textColor ) b2 = createButton( 200, 40, 80, 40, "Button2", ButtonColor, textColor ) b3 = createButton( 300, 200, 80, 40, "Button3", ButtonColor, textColor ) l1 = createLabel( "Hello", 20, 200, tocolor( 0, 0, 0, 255) ) FrameColor = tocolor( 231, 76, 60, 120 ) Frame = createFrame( 250, 250, 450, 250, "Frame", FrameColor, FrameColor, true ); Frame.add(b1) Frame.add(b2) Frame.add(b3) Frame.add(l1) addEventHandler ( "onClientRender", root, renderer ) setTimer( function () Frame.setTitle( "FPS : " .. math.floor(getCurrentFPS())) end, 250, 0 ) bindKey ( "F5", "down", function ( ) Frame.setVisable(true) showCursor( true ) end ) end addEventHandler ( "onClientResourceStart", resourceRoot, init ) ClickedX = 0; function Move( ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local x, y = guiGetScreenSize( ) x2 = screenx * x; y2 = screeny * y; if ( Frame.isMouseOnTitleBar() ) then Frame.setX(x2 -10); Frame.setY(y2 -10); end end function ClickHandler( button, state, text, x, y, w, h) if ( text == "Button3" ) then Frame.clear(); elseif ( text == "Button1" ) then if ( button == "left" ) then l1.setText(text) l1.setX( l1.getX() + 10 ) else l1.setText(text) l1.setX( l1.getX() - 10 ) end end end addEvent( "onMButtonClicked" ) addEventHandler("onMButtonClicked", getRootElement(), ClickHandler) Result وهذي محاولتي ب TextBox اللي فشلت أذا عندك أمكانيه تصلحها صلحها : ) function createTextBox( text, x, y, w, h, frame) local xOfset = 0; local yOfset = 0; local isVisableX = true; local isFocused = false; local isMouseInsideX = false; local caps = false; local Color = tocolor( 0, 0, 0, 255 ) local HText = ""; MTextBox = { x = 0, y = 0, w = 80, h = 24, text = "Text Box", type = "TextBox", render = function () if ( isVisableX ) then dxDrawRectangle( x + xOfset, y + yOfset, w, h ) dxDrawText( text, (x + xOfset + 1), y + yOfset + 2, 0, 0, Color ) 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, setVisable = function( visable ) isVisable = visable; end, setOfset = function ( ofx, ofy ) xOfset = ofx; yOfset = ofy; end, dehighlight = function ( ) end, keysHandler = function ( key, state ) if ( not frame.isVisable() ) then return; end if ( state == "down" ) then if ( key == "lshift" ) then caps = true; return; end if ( key == "backspace" ) then text = string.sub(text, 1, #text - 1) HText = text return; end if ( (string.len(text)*7.5) > w + 10) then if ( key == "space" ) then HText = HText .. " " return; end if ( caps ) then HText = HText .. string.upper(key); caps = false; else HText = HText .. string.lower(key); end outputChatBox(HText) return; end if ( key == "space" ) then text = text .. " " triggerEvent( "onKeyTyped", getRootElement(), " " ) HText = text; return; end if ( caps ) then text = text .. string.upper(key); triggerEvent( "onKeyTyped", getRootElement(), string.upper(key) ) HText = text; caps = false; else text = text .. string.lower(key); triggerEvent( "onKeyTyped", getRootElement(), string.lower(key) ) HText = text; end end triggerEvent( "onKeyPressed", getRootElement(), key, state ) end, setFocus = function ( Focus ) if ( Focus ) then bindKey ( "lshift", "down", MTextBox.keysHandler) for k,v in pairs(keyTable) do bindKey ( v, "down", MTextBox.keysHandler) end showChat( false ) else unbindKey ( "lshift", "down", MTextBox.keysHandler) for k,v in pairs(keyTable) do unbindKey ( v, "down", MTextBox.keysHandler) end showChat( true ) end end, click = function ( button, text ) triggerEvent( "onMTextBoxClicked", getRootElement(), button, state ) end, getText = function() return HText; end, setText = function ( newText ) if ( (string.len(newText)*7.5) > w + 10) then HText = newText; else text = newText; HText = newText; end end } function clicked( button, state ) if ( button == "left" and state == "down" ) then if ( MTextBox.isMouseInside() ) then MTextBox.click(button, state) MTextBox.setFocus(true) else MTextBox.setFocus(false) end end end function update() isMouseInsideX = MTextBox.isMouseInside() end function create() addEvent( "onMTextBoxClicked" ) addEvent( "onKeyTyped" ) addEvent( "onKeyPressed" ) MTextBox.x = x; MTextBox.y = y; MTextBox.w = w; MTextBox.h = h; MTextBox.text = text; addEventHandler( "onClientRender", getRootElement( ), update ) addEventHandler( "onClientClick" , getRootElement( ), clicked ) return MTextBox; end return create(); end Edited May 1, 2016 by Guest Link to comment
Ja[B]er[X]Pro Posted April 28, 2016 Share Posted April 28, 2016 نشرت موضوع قبل يوم عن الفنكشنات اللي سويتها كانت مجرد تجربه وشفتها نجحت *-* ف عدلت عليها وظفت فنكشنات أكثر الأحداث "onMButtonClicked" -- من تضغط على زر "onMFrameClicked" -- من تضغط على شريط العنوان للنافذه Frame --[[ createFrame( x - أحداثي x للأطار y - أحداثي y للأطار w - عرض الأطار h - أرتفاع الأطار Title - عنوان الأطار Color - لون الأطار TitleBarColor - لون شريط العنوان withX - أذا تريد يحط علامة أكس لأخفاء الاطار ) ]] function createFrame( x, y, w, h, Title, Color, TitleBarColor, withX ) local isVisableX = true; local isMouseInsideX = false; local FrameTrigger = 0; local TempComponents = {}; MFrame = { x = 0, y = 0, w = 400, h = 250, Title = "Frame", Color = tocolor( 120, 120, 120, 150 ), Color = tocolor( 120, 120, 120, 255 ), type = "Frame", isX = false, components = { }, isMouseOnTitleBar = function () mouseX, mouseY = getCursorPosition(); if ( not isCursorShowing ( ) ) then return false; end local Sx, Sy = guiGetScreenSize( ) mx = mouseX * Sx; my = mouseY * Sy; --outputChatBox( y .. " : " .. h + .. ", " .. mx ) if ( mx > x and mx <= x + w + 10 and my > y and my <= y + 15 ) then return true; end return false; end, clear = function () for k,v in pairs(MFrame.components) do if ( v.getText() ~= "X" ) then v.setVisable(false) end end end, setTitle = function ( newTitle ) Title = newTitle; end, setX = function ( newX ) x = newX; end, setY = function ( newY ) y = newY; end, setVisable = function ( visable ) isVisableX = visable; end, render = function () if ( isVisableX ) then dxDrawRectangle( x, y, w, h, Color, false) dxDrawRectangle( x, y, w, 30, TitleBarColor, false) dxDrawText( Title, x + 5, y + 7) for k,v in pairs(MFrame.components) do v.setOfset(x, y) if ( v.type ~= "TextBox" ) then if ( v.isMouseInside() ) then v.highlight(30); else v.dehighlight(); end end v.render(); end end end, add = function ( comp ) comp.setOfset(x, y) table.insert(MFrame.components, comp); TempComponents = MFrame.components; end, click = function ( button, state ) if ( not isMouseInsideX ) then return; end if ( FrameTrigger == 0 ) then triggerEvent( "onMFrameClicked", getRootElement(), button, state ) FrameTrigger = 1; setTimer( function ( ) FrameTrigger = 0; end, 150, 1 ) end end } function close( button, state, text ) if ( text == "X" and button == "left" and state == "down" ) then isVisableX = false; showCursor( false ) end end function createX( x, y, w, h) if ( withX ) then Color = TitleBarColor + 10; TextColor = TitleBarColor - 10; x = createButton( w - 30, 0, 30, 30, "X", Color, textColor ) MFrame.add(x); addEventHandler( "onMButtonClicked", getRootElement( ), close ) end end function Cliced( button, state ) end function updae() isMouseInsideX = MFrame.isMouseOnTitleBar(); end function create() addEvent( "onMButtonClicked", true ) addEvent( "onMFrameClicked" ) MFrame.x = x; MFrame.y = y; MFrame.w = w; MFrame.h = h; MFrame.Title = Title; MFrame.Color = Color; MFrame.TitleBarColor = TitleBarColor; createX(x, y, w, h); addEventHandler( "onClientClick", getRootElement(), MFrame.click ) addEventHandler( "onClientRender", getRootElement(), updae ) addEventHandler( "onMFrameClicked", getRootElement( ), Cliced ) return MFrame; end return create(); end Button --[[ createButton( x - أحداثي x للزر y - أحداثي y للزر w - عرض الزر h - أرتفاع الزر text - النص اللي يضهر داخله Color - لون مربع الزر textColor - لون النص ) ]] 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 Label --[[ text - النص x - أحداثي x y - أحداثي y Color - اللون ]] function createLabel( text, x, y, Color) local xOfset = 0; local yOfset = 0; local isVisable = true; MLabel = { x = 0, y = 0, text = "Label", Color = tocolor( 120, 21, 0, 255 ), type = "Label", render = function () if ( isVisable ) then dxDrawText( text, x + xOfset, y + yOfset, 0, 0, Color ) end end, setVisable = function( visable ) isVisable = visable; end, setOfset = function ( ofx, ofy ) xOfset = ofx; yOfset = ofy; end, setText = function ( Text ) text = Text; end, getText = function () return text; end, setX = function ( newX ) x = newX; end, getX = function ( ) return x; end, setY = function ( newY ) y = newY; end, getY = function ( ) return y; end, isMouseInside = function ( ) end, dehighlight = function ( ) end } function create() MLabel.x = x; MLabel.y = y; MLabel.text = text; MLabel.Color = Color; return MLabel; end return create(); end راح تفهم تقريباً نص الفنكشنات من المثال Example local fps = false function getCurrentFPS() return fps end local function updateFPS(msSinceLastFrame) fps = (1 / msSinceLastFrame) * 1000 end addEventHandler("onClientPreRender", root, updateFPS) local Frame; local b1; local b2; local b3; local l1; function renderer ( ) Frame.render(); end function init() showCursor(true) ButtonColor = tocolor( 255, 76, 60, 255 ) textColor = tocolor( 236, 240, 241, 255 ) b1 = createButton( 10, 40, 80, 40, "Button1", ButtonColor, textColor ) b2 = createButton( 200, 40, 80, 40, "Button2", ButtonColor, textColor ) b3 = createButton( 300, 200, 80, 40, "Button3", ButtonColor, textColor ) l1 = createLabel( "Hello", 20, 200, tocolor( 0, 0, 0, 255) ) FrameColor = tocolor( 231, 76, 60, 120 ) Frame = createFrame( 250, 250, 450, 250, "Frame", FrameColor, FrameColor, true ); Frame.add(b1) Frame.add(b2) Frame.add(b3) Frame.add(l1) addEventHandler ( "onClientRender", root, renderer ) setTimer( function () Frame.setTitle( "FPS : " .. math.floor(getCurrentFPS())) end, 250, 0 ) bindKey ( "F5", "down", function ( ) Frame.setVisable(true) showCursor( true ) end ) end addEventHandler ( "onClientResourceStart", resourceRoot, init ) ClickedX = 0; function Move( ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local x, y = guiGetScreenSize( ) x2 = screenx * x; y2 = screeny * y; if ( Frame.isMouseOnTitleBar() ) then Frame.setX(x2 -10); Frame.setY(y2 -10); end end function ClickHandler( button, state, text, x, y, w, h) if ( text == "Button3" ) then Frame.clear(); elseif ( text == "Button1" ) then if ( button == "left" ) then l1.setText(text) l1.setX( l1.getX() + 10 ) else l1.setText(text) l1.setX( l1.getX() - 10 ) end end end addEvent( "onMButtonClicked" ) addEventHandler("onMButtonClicked", getRootElement(), ClickHandler) Result وهذي محاولتي ب TextBox اللي فشلت أذا عندك أمكانيه تصلحها صلحها : ) function createTextBox( text, x, y, w, h) local keyTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "[", "]", ";", ",", "-", ".", "/", "#", "\\", "=", "backspace", "space" } local xOfset = 0; local yOfset = 0; local isVisableX = true; local isFocused = false; local isMouseInsideX = false; local caps = false; local Color = tocolor( 0, 0, 0, 255 ) local HText = ""; MTextBox = { x = 0, y = 0, w = 80, h = 24, text = "Text Box", type = "TextBox", render = function () if ( isVisableX ) then dxDrawRectangle( x + xOfset, y + yOfset, w, h ) dxDrawText( text, (x + xOfset + 1), y + yOfset + 2, 0, 0, Color ) 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, setVisable = function( visable ) isVisable = visable; end, setOfset = function ( ofx, ofy ) xOfset = ofx; yOfset = ofy; end, dehighlight = function ( ) end, keysHandler = function ( key, state ) if ( state == "down" ) then if ( key == "lshift" ) then caps = true; return; end if ( key == "backspace" ) then text = string.sub(text, 1, #text - 1) HText = text return; end if ( (string.len(text)*7.5) > w + 10) then if ( key == "space" ) then HText = HText .. " " return; end if ( caps ) then HText = HText .. string.upper(key); caps = false; else HText = HText .. string.lower(key); end outputChatBox(HText) return; end if ( key == "space" ) then text = text .. " " HText = text; return; end if ( caps ) then text = text .. string.upper(key); HText = text; caps = false; else text = text .. string.lower(key); HText = text; end end end, setFocus = function ( Focus ) if ( Focus ) then outputChatBox("bind") bindKey ( "lshift", "down", MTextBox.keysHandler) for k,v in pairs(keyTable) do bindKey ( v, "down", MTextBox.keysHandler) end --showChat( false ) else outputChatBox("unbind") unbindKey ( "lshift", "down", MTextBox.keysHandler) for k,v in pairs(keyTable) do unbindKey ( v, "down", MTextBox.keysHandler) end showChat( true ) end end, click = function ( button, text ) triggerEvent( "onMTextBoxClicked", getRootElement(), button, state ) end, getText = function() return HText; end, setText = function ( newText ) if ( (string.len(newText)*7.5) > w + 10) then HText = newText; else text = newText; HText = newText; end end } function clicked( button, state ) if ( button == "left" and state == "down" ) then if ( MTextBox.isMouseInside() ) then MTextBox.click(button, state) MTextBox.setFocus(true) else MTextBox.setFocus(false) end end end function update() isMouseInsideX = MTextBox.isMouseInside() end function create() addEvent( "onMTextBoxClicked", true ) MTextBox.x = x; MTextBox.y = y; MTextBox.w = w; MTextBox.h = h; MTextBox.text = text; addEventHandler( "onClientRender", getRootElement( ), update ) addEventHandler( "onClientClick" , getRootElement( ), clicked ) return MTextBox; end return create(); end كفووووووو يا بطل ابدااااااااااع Link to comment
Me[Z]oO Posted April 28, 2016 Share Posted April 28, 2016 قسم بالله كفوو استمر ي وحش ولا توقف لا هان تعبك Link to comment
#|_oskar_|# Posted April 28, 2016 Share Posted April 28, 2016 عمل جميل بس مافهمت ايش فايدته يعني ماشفت غير انك تضغط البوتون والنص يتحرك Link to comment
Jupi Posted April 28, 2016 Share Posted April 28, 2016 عمل جميلبس مافهمت ايش فايدته يعني ماشفت غير انك تضغط البوتون والنص يتحرك عناصر جديدة خذ الاكواد واستعملها مثل الgui Link to comment
mouamle Posted April 29, 2016 Author Share Posted April 29, 2016 قسم بالله كفوواستمر ي وحش ولا توقف لا هان تعبك شكراً Link to comment
mouamle Posted April 29, 2016 Author Share Posted April 29, 2016 عمل جميلبس مافهمت ايش فايدته يعني ماشفت غير انك تضغط البوتون والنص يتحرك in programming : { the sky is your limit } but in your case the sky is too low ;-; Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now