naotriix Posted October 6, 2015 Share Posted October 6, 2015 Bonjour, voila depuis quelque temps j'utilise un userpanel très bien, mais un bug résiste, si j'ai bien compris cela viendrait du fait qu'a chaque fois que le curseur est visible et que l'on clique n'importe ou, le dernier boutton utilisé dans l'userpanel sa réactive. Par exemple; dans l'onglet settings de mon userpanel il y a un shader que l'on peut activé ou désactivé, si je l'active et que ensuite je lance l'adminpanel et que je clique nimporte ou, puisque le curseur est visible, le button de l'userpanel se déclenche sans qu'il soit ouvert, après quelques recherches je pense que le soucis viens de cette endroit: function onDxLibPlayerClick(button,state) if isCursorShowing() then if button == "left" and state == "down" then for i,dxButton in pairs(getElementsByType("dxButton")) do if getElementData(dxButton,"dxButtonHover") then setElementData(dxButton,"dxButtonClick",true,false) triggerEvent("onDxLibButtonClick",getRootElement(),dxButton) outputDebugString("Triggering event: \"onDxLibButtonClick\"",0,100,100,100) setElementData(dxButton,"dxButtonHover",false,false) end end for i,dxGridlist in pairs(getElementsByType("dxGridlist")) do if getElementData(dxGridlist,"dxGridlistHover") then if getElementData(dxGridlist,"dxGridlistDataHover") then setElementData(dxGridlist,"dxGridlistSelected",tonumber(getElementData(dxGridlist,"dxGridlistDataHover")),false) triggerEvent("onDxLibGridlistClick",getRootElement(),dxGridlist) end elseif getElementData(dxGridlist,"dxGridlistScrollHover") then setElementData(dxGridlist,"dxGridlistScrollClicked",true,false) end end for i,dxEdit in pairs(getElementsByType("dxEdit")) do if getElementData(dxEdit,"dxEditHover") then setElementData(dxEdit,"dxEditActive",true,false) setElementData(dxEdit,"dxEditSelected",false,false) elseif getElementData(dxEdit,"dxEditActive") and not getElementData(dxEdit,"dxEditHover") then setElementData(dxEdit,"dxEditActive",false,false) end end end end end addEventHandler("onClientClick",getRootElement(),onDxLibPlayerClick) Je voudrais que lorsque l'on clique ailleur de sur le bouton ca ne l'active/désactive plus. Si quelqu'un peut m'aider, j'ai beau chercher je n'arrive pas a régler ce soucis assez génant. Link to comment
Moderators Citizen Posted October 6, 2015 Moderators Share Posted October 6, 2015 D'après ce que j'ai compris, il y a un onClientRender ou onClientMouseMove qui se charge de "getter" la position de la souris et de parcourir tous ces "dx elements" (dxButton, dxGridlist, dxEdit etc) et si la position de la souris est détecté au-dessus de l'un d'entre heu, il lui "set" un element data à true pour signaler que la souris est actuellement au-dessus. Par exemple pour le bouton, il doit faire quelque chose comme ça: setElementData(dxButton, "dxButtonHover", true, false) Il s'occupe également de le remettre à false s'il la souris en ait sortie. Ailleurs dans le code, on s'occupe de gérer le clic de la souris (c'est le code que tu nous à collé) et va parcourir tous les "dx elements" qui sont cliquables. Pour chaque "dx elements" cliquables, il va "get" l'element data qui précise si la souris est au-dessus, si c'est le cas, il va "trigger" le "onDxLibButtonClick". Ton problème est donc que l'element data "dxButtonHover" reste à true même lorsque le bouton n'est plus visible. Il te faut donc trouver le bon endroit pour remettre cet element data à false: setElementData(dxButton, "dxButtonHover", false, false) Peux-tu nous montrer une partie du onClientRender qui se charge d'afficher tous les dxElements à l'écran ? (ou du moins celui du bouton) Je pense qu'il doit y avoir un "check" (un if blabla then) qui doit vérifier si l'élément est visible (car si on dit que cet element n'est pas visible, il ne faut pas le montrer comme un guiSetVisible(gui, false) ferait.) Link to comment
naotriix Posted October 7, 2015 Author Share Posted October 7, 2015 function dxLibCreateButton(buttonElement,positionX,positionY,sizeX,sizeY,buttonLabel,labelSize,red,green,blue,lR,lG,lB,alpha,postGUI,coloredLabel) if not getElementData(buttonElement,"dxButtonCreate") then setElementData(buttonElement,"dxButtonCreate",true,false) setElementData(buttonElement,"dxButtonHover",false,false) setElementData(buttonElement,"dxButtonClick",false,false) return end setElementData(buttonElement,"dxButtonLabel",tostring(buttonLabel),false) setElementData(buttonElement,"dxButtonHover",false,false) local scaleX = sizeX/932 if isCursorHover(positionX,positionY,sizeX,sizeY) and not getElementData(buttonElement,"dxButtonClick") then setElementData(buttonElement,"dxButtonHover",true,false) dxDrawImageSection(positionX-25*scaleX+sizeX,positionY,25*scaleX,sizeY,0,0,25,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX,positionY,25*scaleX,sizeY,907,0,25,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX+25*scaleX,positionY,sizeX-50*scaleX,sizeY,26,0,1,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) else dxDrawImageSection(positionX,positionY,25*scaleX,sizeY,0,0,25,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX-25*scaleX+sizeX,positionY,25*scaleX,sizeY,907,0,25,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX+25*scaleX,positionY,sizeX-50*scaleX,sizeY,26,0,1,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) if not getElementData(buttonElement,"dxButtonClick") then dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) else dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha/1.2*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha/1.2*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) end end setElementData(buttonElement,"dxButtonClick",false,false) end Je pense que ca ce situe ici, j'ai changer a la ligne 12. setElementData(buttonElement,"dxButtonHover",true,false) en setElementData(buttonElement,"dxButtonHover",false,false) et plus aucuns boutons ne fonctionnaient, je te met le code entier pour que tu es un meilleur aperçu. --#################################################################### --## ## --## ## --## Xiti's directX library V2.0 Stable ## --## ## --## This resource can only be used with ## --## scripts made by Xiti. ## --## People who bought this resource also ## --## have rights to use it. ## --## ## --## For any help with the resource ## --## Please contact the author: ## --## ## --## Skype: mateusz331169 ## --## InGame(MTA): ~X!ti# ## --## ## --## This resource is at creative common license: ## --## [url=http://creativecommons.org/licenses/by-nc-nd/3.0/ ]http://creativecommons.org/licenses/by-nc-nd/3.0/ [/url] ## --## ## --## ## --#################################################################### --#################################################################### --## Configuration ## --#################################################################### dxLib = { imageURL = "data/img/dxInterface/", globalAlpha = 1, font = "default-bold" } --#################################################################### --## dxLib Events ## --#################################################################### addEvent("onDxLibButtonClick",true) addEvent("onDxLibEditChange",true) addEvent("onDxLibGridlistClick",true) addEvent("onDxLibScrollMouse",true) --#################################################################### --## Main Functions ## --#################################################################### local sX,sY = guiGetScreenSize() function dxLibCreateButton(buttonElement,positionX,positionY,sizeX,sizeY,buttonLabel,labelSize,red,green,blue,lR,lG,lB,alpha,postGUI,coloredLabel) if not getElementData(buttonElement,"dxButtonCreate") then setElementData(buttonElement,"dxButtonCreate",true,false) setElementData(buttonElement,"dxButtonHover",false,false) setElementData(buttonElement,"dxButtonClick",false,false) return end setElementData(buttonElement,"dxButtonLabel",tostring(buttonLabel),false) setElementData(buttonElement,"dxButtonHover",false,false) local scaleX = sizeX/932 if isCursorHover(positionX,positionY,sizeX,sizeY) and not getElementData(buttonElement,"dxButtonClick") then setElementData(buttonElement,"dxButtonHover",true,false) dxDrawImageSection(positionX-25*scaleX+sizeX,positionY,25*scaleX,sizeY,0,0,25,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX,positionY,25*scaleX,sizeY,907,0,25,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX+25*scaleX,positionY,sizeX-50*scaleX,sizeY,26,0,1,174,dxLib.imageURL.."button.png",180,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) else dxDrawImageSection(positionX,positionY,25*scaleX,sizeY,0,0,25,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX-25*scaleX+sizeX,positionY,25*scaleX,sizeY,907,0,25,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) dxDrawImageSection(positionX+25*scaleX,positionY,sizeX-50*scaleX,sizeY,26,0,1,174,dxLib.imageURL.."button.png",0,0,0,tocolor(70,70,70,255*dxLib.globalAlpha),postGUI) if not getElementData(buttonElement,"dxButtonClick") then dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) else dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX+1,positionY+sizeY+2,tocolor(0,0,0,alpha/1.2*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) dxDrawText(buttonLabel,positionX,positionY,positionX+sizeX,positionY+sizeY,tocolor(lR,lG,lB,alpha/1.2*dxLib.globalAlpha),labelSize,dxLib.font,"center","center",true,false,postGUI,coloredLabel or false) end end setElementData(buttonElement,"dxButtonClick",false,false) end function dxLibCreateGridlist(gridlistElement,gridlistData,positionX,positionY,sizeX,sizeY,fontSize,emptyString,colorRed,colorGreen,colorBlue,alphaGridlist,coloredLabels,postGUI) if not getElementData(gridlistElement,"dxGridlistCreate") then setElementData(gridlistElement,"dxGridlistCreate",true,false) setElementData(gridlistElement,"dxGridlistScroll",0,false) setElementData(gridlistElement,"dxGridlistScrollTo",0,false) setElementData(gridlistElement,"dxGridlistSelected",0,false) setElementData(gridlistElement,"dxGridlistDataCount",1,false) setElementData(gridlistElement,"dxGridlistHover",false,false) setElementData(gridlistElement,"dxGridlistDataHover",false,false) setElementData(gridlistElement,"dxGridlistTick",getTickCount(),false) setElementData(gridlistElement,"dxGridlistScrollHover",false,false) setElementData(gridlistElement,"dxGridlistScrollClicked",false,false) setElementData(gridlistElement,"dxGridlistDatatable",gridlistData,false) local renderTarget = dxCreateRenderTarget(sizeX,sizeY,true) setElementData(gridlistElement,"dxGridlistRenderTarget",renderTarget,false) return end if type(gridlistData) == "table" then local dataCount = getElementData(gridlistElement,"dxGridlistDataCount") if dataCount ~= #gridlistData then setElementData(gridlistElement,"dxGridlistDataCount",#gridlistData,false) setElementData(gridlistElement,"dxGridlistDatatable",gridlistData,false) end if getElementData(gridlistElement,"dxGridlistSelected") > #gridlistData then setElementData(gridlistElement,"dxGridlistSelected",0,false) end else outputDebugString("dxLib: Data for gridlist must be a table value!") return end setElementData(gridlistElement,"dxGridlistHover",false,false) if isCursorHover(positionX,positionY,sizeX,sizeY) then setElementData(gridlistElement,"dxGridlistHover",true,false) end local renderTarget = getElementData(gridlistElement,"dxGridlistRenderTarget") if renderTarget then local rowSize = dxGetFontHeight(fontSize,dxLib.font)+10 local gridlistTick = getElementData(gridlistElement,"dxGridlistTick") local scroll = getElementData(gridlistElement,"dxGridlistScroll") local scrollTo = getElementData(gridlistElement,"dxGridlistScrollTo") local visibleRows = sizeY/rowSize if #gridlistData*rowSize > sizeY then if scrollTo < 0 then scrollTo = 0 setElementData(gridlistElement,"dxGridlistScrollTo",0,false) elseif scrollTo > #gridlistData-visibleRows then scrollTo = #gridlistData-visibleRows setElementData(gridlistElement,"dxGridlistScrollTo",#gridlistData-visibleRows,false) end if scroll ~= scrollTo then local tick = getTickCount() - gridlistTick local progress = tick/500 if progress >= 1 then progress = 1 end scroll = interpolateBetween(scroll,0,0,scrollTo,0,0,progress,"Linear") setElementData(gridlistElement,"dxGridlistScroll",scroll,false) end else scroll = 0 setElementData(gridlistElement,"dxGridlistScroll",0,false) setElementData(gridlistElement,"dxGridlistScrollTo",0,false) end local scrollPosition = rowSize*scroll dxSetRenderTarget(renderTarget) dxDrawRectangle(0,0,sizeX,sizeY,tocolor(15,15,15,160)) setElementData(gridlistElement,"dxGridlistDataHover",false,false) local selectedRow = getElementData(gridlistElement,"dxGridlistSelected") if #gridlistData ~= 0 then for id,dataPart in pairs(gridlistData) do if (positionY+(rowSize*(id-1))-scrollPosition)>=positionY-rowSize and (positionY+(rowSize*(id-1))-scrollPosition)<=positionY+sizeY+rowSize then if isCursorHover(positionX,positionY+(rowSize*(id-1))-scrollPosition,sizeX,rowSize) and getElementData(gridlistElement,"dxGridlistHover") then setElementData(gridlistElement,"dxGridlistDataHover",id,false) if selectedRow == id then dxDrawRectangle(0,rowSize*(id-1)-scrollPosition,sizeX,rowSize,tocolor(colorRed,colorGreen,colorBlue,220),false) dxDrawText(tostring(dataPart),5,rowSize*(id-1)+5-scrollPosition,sizeX,rowSize*id-5-scrollPosition,tocolor(255,255,255,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) else dxDrawRectangle(0,rowSize*(id-1)-scrollPosition,sizeX,rowSize,tocolor(50,50,50,200),false) dxDrawText(tostring(dataPart),5,rowSize*(id-1)+5-scrollPosition,sizeX,rowSize*id-5-scrollPosition,tocolor(255,255,255,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) end else if selectedRow == id then dxDrawRectangle(0,rowSize*(id-1)-scrollPosition,sizeX,rowSize,tocolor(colorRed,colorGreen,colorBlue,200),false) dxDrawText(tostring(dataPart),5,rowSize*(id-1)+5-scrollPosition,sizeX,rowSize*id-5-scrollPosition,tocolor(255,255,255,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) else dxDrawRectangle(0,rowSize*(id-1)-scrollPosition,sizeX,rowSize,tocolor(20,20,20,150),false) dxDrawText(tostring(dataPart),5,rowSize*(id-1)+5-scrollPosition,sizeX,rowSize*id-5-scrollPosition,tocolor(255,255,255,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) end end end end else dxDrawText(tostring(emptyString),6,4,sizeX,rowSize-5,tocolor(0,0,0,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) dxDrawText(tostring(emptyString),5,5,sizeX,rowSize-5,tocolor(200,15,15,255),fontSize,dxLib.font,"left","center",true,false,false,coloredLabels or false) end dxSetRenderTarget() dxDrawImage(positionX,positionY,sizeX,sizeY,renderTarget,0,0,0,tocolor(255,255,255,alphaGridlist or 255),postGUI or false) dxDrawLine(positionX,positionY,positionX+sizeX,positionY,tocolor(0,0,0,alphaGridlist or 255),1,postGUI or false) dxDrawLine(positionX,positionY+sizeY,positionX+sizeX,positionY+sizeY,tocolor(0,0,0,alphaGridlist or 255),1,postGUI or false) dxDrawLine(positionX+sizeX,positionY,positionX+sizeX,positionY+sizeY,tocolor(0,0,0,alphaGridlist or 255),1,postGUI or false) dxDrawLine(positionX,positionY,positionX,positionY+sizeY,tocolor(0,0,0,alphaGridlist or 255),1,postGUI or false) local scrollBar = {} if #gridlistData*rowSize > sizeY then scrollBar.size = (sizeY-(sizeY/3))/(#gridlistData-visibleRows) if scrollBar.size<=sizeY/8 then scrollBar.size = sizeY/8 end scrollBar.position = ((sizeY-scrollBar.size)/(#gridlistData-visibleRows))*scroll dxDrawRectangle(positionX+sizeX+1,positionY,sX*0.02,sizeY,tocolor(40,40,40,100*((alphaGridlist or 255)/255)),postGUI) dxDrawRectangle(positionX+sizeX+1,positionY+scrollBar.position,sX*0.02,scrollBar.size,tocolor(colorRed,colorGreen,colorBlue,255*((alphaGridlist or 255)/255)),postGUI) if getElementData(gridlistElement,"dxGridlistScrollClicked") then if getKeyState("mouse1") then local x,y = getCursorPosition() local x,y = x*sX,y*sY local newPos = y-positionY local barSize = (((#gridlistData-visibleRows)*rowSize)*(newPos/sizeY))/rowSize setElementData(gridlistElement,"dxGridlistScroll",barSize,false) setElementData(gridlistElement,"dxGridlistScrollTo",barSize,false) else setElementData(gridlistElement,"dxGridlistScrollClicked",false,false) end else if isCursorHover(positionX+sizeX,positionY+scrollBar.position,sX*0.02,scrollBar.size) then setElementData(gridlistElement,"dxGridlistScrollHover",true,false) else setElementData(gridlistElement,"dxGridlistScrollHover",false,false) end end end else outputDebugString("dxLib: Cant find a render target") end end function dxLibCreateEdit(editElement,positionX,positionY,sizeX,sizeY,defaultText,iconImage,colorRed,colorGreen,colorBlue,editAlpha,postGUI,maskedText) if not getElementData(editElement,"dxEditCreated") then setElementData(editElement,"dxEditCreated",true,false) setElementData(editElement,"dxEditTextCache","",false) setElementData(editElement,"dxEditHover",false,false) setElementData(editElement,"dxEditActive",false,false) setElementData(editElement,"dxEditSelected",false,false) local fontSize = 0 local findedSize = false local i = 0 local fontSizeCache = 0 repeat i = i+0.1 fontSizeCache = fontSize fontSize = dxGetFontHeight(i,dxLib.font) if fontSize>=(sizeY-(sY*0.01)) then findedSize = true end until findedSize setElementData(editElement,"dxEditTextSize",i,false) return end local fontSize = getElementData(editElement,"dxEditTextSize") local postGUI = postGUI or false if isCursorHover(positionX,positionY,sizeX,sizeY) then setElementData(editElement,"dxEditHover",true,false) else setElementData(editElement,"dxEditHover",false,false) end if getElementData(editElement,"dxEditActive") or getElementData(editElement,"dxEditHover") then dxDrawRectangle(positionX,positionY,sizeX,sizeY,tocolor(255,255,255,255*(editAlpha/255)),postGUI) dxDrawLine(positionX,positionY,positionX,positionY+sizeY,tocolor(0,0,0,255*(editAlpha/255)),1,postGUI) dxDrawLine(positionX+sizeX,positionY,positionX+sizeX,positionY+sizeY,tocolor(0,0,0,255*(editAlpha/255)),1,postGUI) dxDrawLine(positionX,positionY,positionX+sizeX,positionY,tocolor(0,0,0,255*(editAlpha/255)),1,postGUI) dxDrawLine(positionX,positionY+sizeY,positionX+sizeX,positionY+sizeY,tocolor(0,0,0,255*(editAlpha/255)),1,postGUI) Link to comment
Moderators Citizen Posted October 7, 2015 Moderators Share Posted October 7, 2015 Mouai, ça a été codé de façon un peu bizarre, je ne m'attendais pas à une telle gestion. Donc de ce que j'ai compris, si tu veux créer un bouton, il te faut d'abord créer un élément de type dxButton et ensuite te mettre dans un "onClientRender" pour appeler un dxLibCreateButton avec l'élément de type dxButton que tu as créé. Exemple: local button1 = createElement("dxButton") function renderTest() dxLibCreateButton(button1,350,760,400,50,"test",3,255,0,120,0,255,0,255,false) end addEventHandler("onClientRender", root, renderTest) Avec ce code là, si tu veux ne plus afficher un élément, il te faut stopper le "onClientRender" mais aussi supprimer l'élément avec la fonction destroyElement. Exemple: removeEventHandler("onClientRender", root, renderTest) destroyElement(button1) Link to comment
naotriix Posted October 7, 2015 Author Share Posted October 7, 2015 Merci pour le code mais je ne comprend pas tellement comment m'y prendre pour l'utiliser Le button est crée avec ca si j'ai bien compris: dxLibCreateButton(cInterface.tab_3.dxElements.buttons[3],positionX+sX*0.6,positionY+sY*0.37,sX*0.3,sY*0.06,"Buy selected color as #1 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[4],positionX+sX*0.6,positionY+sY*0.74,sX*0.3,sY*0.06,"Buy selected color as #2 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) Si je suis ton code cela donnerais: local cInterface.tab_3.dxElements.buttons[3] = createElement("dxButton") function renderTest() dxLibCreateButton(cInterface.tab_3.dxElements.buttons[3],positionX+sX*0.6,positionY+sY*0.37,sX*0.3,sY*0.06,"Buy selected color as #1 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) end addEventHandler("onClientRender", root, renderTest) Mais ou dois-je place le remove ensuite ? Pourrais tu me faire un exemple complet pour que je puisse mieux comprendre --<<<<< Vehicle colors drawColorPickerInterface(positionX+sX*0.1,positionY+sY*0.3) dxDrawText("Pick your new vehicle color!",positionX+sX*0.1,positionY+sY*0.1,positionX+sX*0.55+2,positionY+sY*0.25+2,tocolor(0,0,0,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxDrawText("Pick your new vehicle color!",positionX+sX*0.1,positionY+sY*0.1,positionX+sX*0.55,positionY+sY*0.25,tocolor(220,220,220,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[3],positionX+sX*0.6,positionY+sY*0.37,sX*0.3,sY*0.06,"Buy selected color as #1 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[4],positionX+sX*0.6,positionY+sY*0.74,sX*0.3,sY*0.06,"Buy selected color as #2 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxDrawText("First vehicle color",positionX+sX*0.6,positionY+sY*0.1,positionX+sX*0.9+2,positionY+sY*0.25+2,tocolor(0,0,0,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxDrawText("First vehicle color",positionX+sX*0.6,positionY+sY*0.1,positionX+sX*0.9,positionY+sY*0.25,tocolor(220,220,220,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxDrawText("Second vehicle color",positionX+sX*0.6,positionY+sY*0.52,positionX+sX*0.9+2,positionY+sY*0.57+2,tocolor(0,0,0,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxDrawText("Second vehicle color",positionX+sX*0.6,positionY+sY*0.52,positionX+sX*0.9,positionY+sY*0.57,tocolor(220,220,220,255*menu.alpha),s(0.3),menu.font,"center","center",true,false,menu.postGUI) dxDrawRectangle(positionX+sX*0.6,positionY+sY*0.3,sX*0.14,sY*0.06,tocolor(cInterface.tab_3.vehicleColors.data[1][1],cInterface.tab_3.vehicleColors.data[1][2],cInterface.tab_3.vehicleColors.data[1][3],255*menu.alpha),menu.postGUI) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[5],positionX+sX*0.75,positionY+sY*0.3,sX*0.15,sY*0.06,"Sell color +$5000",sY/550,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxDrawText("State: "..cInterface.tab_3.vehicleColors.state[1],positionX+sX*0.6,positionY+sY*0.25,positionX+sX*0.9+2,positionY+sY*0.3+2,tocolor(0,0,0,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("State: "..cInterface.tab_3.vehicleColors.state[1],positionX+sX*0.6,positionY+sY*0.25,positionX+sX*0.9,positionY+sY*0.3,tocolor(220,220,220,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("Price: $"..cInterface.tab_3.vehicleColors.price[1],positionX+sX*0.6,positionY+sY*0.22,positionX+sX*0.9+2,positionY+sY*0.27+2,tocolor(0,0,0,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("Price: $"..cInterface.tab_3.vehicleColors.price[1],positionX+sX*0.6,positionY+sY*0.22,positionX+sX*0.9,positionY+sY*0.27,tocolor(220,220,220,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawRectangle(positionX+sX*0.6,positionY+sY*0.67,sX*0.14,sY*0.06,tocolor(cInterface.tab_3.vehicleColors.data[2][1],cInterface.tab_3.vehicleColors.data[2][2],cInterface.tab_3.vehicleColors.data[2][3],255*menu.alpha),menu.postGUI) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[6],positionX+sX*0.75,positionY+sY*0.67,sX*0.15,sY*0.06,"Sell color +$5000",sY/550,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxDrawText("State: "..cInterface.tab_3.vehicleColors.state[2],positionX+sX*0.6,positionY+sY*0.62,positionX+sX*0.9+2,positionY+sY*0.67+2,tocolor(0,0,0,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("State: "..cInterface.tab_3.vehicleColors.state[2],positionX+sX*0.6,positionY+sY*0.62,positionX+sX*0.9,positionY+sY*0.67,tocolor(220,220,220,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("Price: $"..cInterface.tab_3.vehicleColors.price[2],positionX+sX*0.6,positionY+sY*0.59,positionX+sX*0.9+2,positionY+sY*0.64+2,tocolor(0,0,0,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) dxDrawText("Price: $"..cInterface.tab_3.vehicleColors.price[2],positionX+sX*0.6,positionY+sY*0.59,positionX+sX*0.9,positionY+sY*0.64,tocolor(220,220,220,255*menu.alpha),s(0.2),menu.font,"left","center",true,false,menu.postGUI) end Link to comment
Moderators Citizen Posted October 7, 2015 Moderators Share Posted October 7, 2015 Le button est crée avec ca si j'ai bien compris: dxLibCreateButton(cInterface.tab_3.dxElements.buttons[3],positionX+sX*0.6,positionY+sY*0.37,sX*0.3,sY*0.06,"Buy selected color as #1 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) dxLibCreateButton(cInterface.tab_3.dxElements.buttons[4],positionX+sX*0.6,positionY+sY*0.74,sX*0.3,sY*0.06,"Buy selected color as #2 vehicle color",sY/500,136,0,0,220,220,220,menu.alpha*255,menu.postGUI,false) Nan il n'est pas créé mais affiché avec ça. Ce qui crée le bouton, c'est ça: cInterface.tab_3.dxElements.buttons[3] = createElement("dxButton") Mais il a sûrement déjà été créé ailleurs et donc il n'est pas nécessaire de le recréer. Par contre ce code me fait peur, pourrais-tu me montrer comment est créer ce cInterface ? Parce que s'il est créé une seule fois au démarrage de la ressource, on ne devra pas supprimer l'élément. Moi ce qui m’intéresse c'est de voir le code responsable du changement d'onglet et celui responsable d'afficher ou de cacher le userpanel car ça sera sûrement à ces niveaux là que l'on va devoir agir. Link to comment
naotriix Posted October 7, 2015 Author Share Posted October 7, 2015 Je crois que le mieux serait que je te file l'userpanel pour que tu m'explique car c'est le bordel, y a plusieurs fichiers avec des buttons dedans etc. 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