Jump to content

[Heelp !!] I have probleme with dx


Recommended Posts

i have a probleme im working on NativeUI Plugin but whene i adjust the start row

Code



 
local screenX, screenY = guiGetScreenSize()
local x, y = 1366768
local relX, relY = screenX/x, screenY/y
local panelX, panelY, panelWidth, rowHeight = 32*relX, 32*relY, 325*relX, 30*relY
local chaletlondon = dxCreateFont("fonts/chaletlondon.ttf"24*relY, false"antialiased")
local signpainter = dxCreateFont("fonts/signpainter.ttf"24*relY, false"antialiased")
local currentY = panelY+80*relY+rowHeight
addEvent("NativeUI.onTabEnter"true)
 
addEvent("NativeUI.onCheckChange"true)
 
addEvent("NativeUI.onTabChange"true)
 
addEvent("NativeUI.onWindowClose"true)
 
addEvent("NativeUI.onSelectChange"true)
 
addEvent("NativeUI.onButtonEnter"true)
 
addEvent("NativeUI.onCheckEnter"true)
 
addEvent("NativeUI.onSelectEnter"true)
 
local iVisibleRow = 6
local currentUse = 1
 
local windows = {
 --[[  {
      title = "Title";
      title_image = "NORMALE.png";
      title_2 = "Title 2";
      isVisible = true;
      useBackSpace = true;
      Tabs = {
         -- evnt or false or true ( check bool)
      --  {"type","text","event",currentUse,{useses Tab}}
      {"select","Tab 1","",1,{"Ali", "Othamne"}}
 
      };
  };--]]
  
};
 
function render ()
    for _, window in pairs(windows) do 
        if window then 
        if window.isVisible then 
        if window.title_image ~= 0 and window.title_image ~= "none" then 
    dxDrawImage(panelX, panelY, panelWidth, 80*relY,"images/"..window.title_image or "images/NORMALE.png")
    dxDrawText(window.title,panelX+10*relX, panelY, panelWidth+panelX-10*relX, 80*relY+panelY, tocolor(255255255255), 1.5, signpainter, "center""center")
    end
    dxDrawRectangle(panelX, panelY+80*relY, panelWidth, rowHeight, tocolor(101010255))
    
   -- dxDrawRectangle(panelX, panelY, panelWidth, notificationData["height"], tocolor(0, 0, 0, 210))
 
    dxDrawText(utf8.upper(window.title_2), panelX+10*relX, panelY+80*relY, panelWidth+panelX+10*relX, rowHeight+panelY+80*relY, tocolor(5376115255), 0.5, chaletlondon, "left""center")
    dxDrawText(""..currentUse.."/"..#window.Tabs.."", panelX+10*relX, panelY+80*relY, panelWidth+panelX-10*relX, rowHeight+panelY+80*relY, tocolor(5376115255), 0.5, chaletlondon, "right""center")
 
    
    --dxDrawRectangle(panelX, currentY+33*relY, panelWidth, rowHeight, tocolor(0, 0, 0, 210))
    --dxDrawImage(panelX, currentY+33*relY, panelWidth, rowHeight, "images/menunav.png")
    
    for k = window.startRow, window.startRow + iVisibleRow - 11 do
        local v = window.Tabs[k]
        if not v[6then
        bgColor = tocolor(000210)
        textColor = tocolor(255255255220)
        if (k ~= currentUse) then
            bgColor = tocolor(000210)
            textColor = tocolor(255255255220)
        else
            bgColor = tocolor(255255255255)
            textColor = tocolor(000255)
        end
        dxDrawRectangle(panelX, currentY+(rowHeight*(k-1)), panelWidth, rowHeight, bgColor)
        dxDrawText(v[2], panelX+10*relX, currentY+(rowHeight*(k-1)), panelWidth+panelX+10*relX, rowHeight+currentY+(rowHeight*(k-1)), textColor, 0.45, chaletlondon, "left""center")
        local state = "□"
        if (v[1== "check"then
        textColor = tocolor(255255255255)
        if (k ~= currentUse) then
            textColor = tocolor(255255255255)
        else
            textColor = tocolor(000255)
        end
        if (v[3]) then
            state = "▣"
        else
            state = "□"
        end
        dxDrawText(state, panelX+10*relX, currentY+(rowHeight*(k-1)), panelWidth-20*relX+panelX+10*relX, rowHeight+currentY+(rowHeight*(k-1)), textColor, 1.0, chaletlondon, "right""center")
       -- dxDrawText("□", panelX+13*relX, currentY+(rowHeight*(k-1)), panelWidth-20*relX+panelX+10*relX, rowHeight+currentY+(rowHeight*(k-1)), textColor, 1.0, chaletlondon, "right", "center")
    elseif (v[1== "select"then 
        local currentUseText = v[5][v[4]] or ""
        if currentUseText then 
            dxDrawText("< "..currentUseText.." >", panelX+10*relX, currentY+(rowHeight*(k-1)), panelWidth-20*relX+panelX+10*relX, rowHeight+currentY+(rowHeight*(k-1)), textColor, 0.55, chaletlondon, "right""center")
        end
    end
end
end
end
end
end 
--end 
end 
 
addEventHandler("onClientRender", root, render)


 
function key (key, state)
    for _, window in pairs(windows) do 
    if (window.isVisiblethen
        if (state) then
         local v = window.Tabs[currentUse]
            if (v) then
                
                if (v[1== "button"then
                    if (key == "enter"then
                        playSound("sounds/menunavigate.mp3")
                        enterFunction()
                        triggerEvent("NativeUI.onTabEnter",localPlayer,currentUse, window.Tabs[currentUse][3])
                    end
                elseif (v[1== "check"then
                    if (key == "enter"then
                        playSound("sounds/buttonpressed.mp3")
                        enterFunction()
                        triggerEvent("NativeUI.onCheckChange",localPlayer,currentUse, window.Tabs[currentUse][3])
                    end
                end
            end
 
            if (key == "arrow_d"then
                if (currentUse < #window.Tabsthen
                    currentUse = currentUse + 1
                    local tab = window.Tabs[currentUse]
                    triggerEvent("NativeUI.onTabChange",localPlayer,currentUse, window.Tabs[currentUse][3])
                    adjustStartRow(window)
                else
                    currentUse = 1
                    adjustStartRow(window)
                    triggerEvent("NativeUI.onTabChange",localPlayer,currentUse, window.Tabs[currentUse][3])
                end
                playSound("sounds/menunavigate.mp3")
            elseif (key == "arrow_u"then
                if (currentUse > 1then
                    currentUse = currentUse - 1
                    triggerEvent("NativeUI.onTabChange",localPlayer,currentUse, window.Tabs[currentUse][3])
                    adjustStartRow(window)
                else
                    currentUse = #window.Tabs
                    triggerEvent("NativeUI.onTabChange",localPlayer,currentUse, window.Tabs[currentUse][3])
                    adjustStartRow(window)
                end
                playSound("sounds/menunavigate.mp3")
            elseif (key == "backspace"then
                --v = window.Tabs[currentUse]
                --if (v[1] ~= "input") then
                    
                    playSound("sounds/menuenter.mp3")
                    if window.useBackSpace then 
                        triggerEvent("NativeUI.onWindowClose",localPlayer,window)
                    DeletePool(_)
                    end 
                    
            --  end
            
                elseif(key == "arrow_l"then
                    if  v[1== "select" then 
                   
                    if (v[4> 1then
                        v[4= v[4- 1
                        playSound("sounds/menunavigate.mp3")
                        triggerEvent("NativeUI.onSelectChange",localPlayer,currentUse, window.Tabs[currentUse][5][window.Tabs[currentUse][4]])
                    else
                        v[4= #v[5]
                        playSound("sounds/menunavigate.mp3")
                        triggerEvent("NativeUI.onSelectChange",localPlayer,currentUse, window.Tabs[currentUse][5][window.Tabs[currentUse][4]])
                    end
                end
                elseif (key == "arrow_r"then 
                   if  v[1== "select" then 
                   
                    if (v[4< #v[5]) then
                    v[4= v[4+ 1
                    playSound("sounds/menunavigate.mp3")
                    triggerEvent("NativeUI.onSelectChange",localPlayer,currentUse, window.Tabs[currentUse][5][window.Tabs[currentUse][4]])
                else
                    v[4= 1
                    playSound("sounds/menunavigate.mp3")
                    triggerEvent("NativeUI.onSelectChange",localPlayer,currentUse, window.Tabs[currentUse][5][window.Tabs[currentUse][4]])
                end
            end
                --playSound("sounds/menunavigate.mp3")
 
            end
        end
    end
end
end 
addEventHandler("onClientKey", root, key)




 
addEventHandler("onClientKey"getRootElement(), function(btn, state)
    for _, window in pairs(windows) do  
    if  window.isVisible then 
    if btn == "arrow_d" and state == true then
        cancelEvent()
    end
    if btn == "arrow_u" and state == true then
        cancelEvent()
    end
    if btn == "arrow_r" and state == true then
        cancelEvent()
    end
    if btn == "arrow_l" and state == true then
        cancelEvent()
    end
    if btn == "enter" and state == true then
        cancelEvent()
    end
end
end 
end)




 
function CreatePool(_title,_stitle,_image,useBackSpace)
    currentUse = 1
    if not _title then return outputDebugString("unable to get menu title"end 
    local id = 1 
     _image = _image or "NORMALE.png"
     _stitle = _stitle or ""
     _useBackSpace = _useBackSpace or true 
 
     table.insert(windows,{
 
      title = _title;
      title_image = _image;
      title_2 = _stitle;
      isVisible = true;
      useBackSpace = _useBackSpace;
      Tabs = {};
      startRow = 1;
 
     }
    )
 
    for _, window in ipairs(windows) do 
        if window.title == _title and window.title_image == _image and window.title_2 == _stitle and window.isVisible == true and window.useBackSpace == window._useBackSpace and window.Tabs == {} then 
            id = _ 
        end
    end
 
  return id
 
end
 
function setVisible(windowID,bool)
    windows[tonumber(windowID)].isVisible = bool
end
 
function addTab(windowID,tabType, tabText,tabEvent,selectTable)
local id
    local w = windows[tonumber(windowID)].Tabs
    if w then 
        table.insert( w,{tabType, tabText, tabEvent,1,selectTable} )
    end
    
     for _, window in ipairs(windows) do 
       for id, tab in ipairs(window.Tabsdo 
          if tab[1== tabType and tab[2== tabText then 
           _id = id 
           end
        end
    end
    return _id 
    
end



 
function DeletePool (id)
     windows[id] = nil 
end
 
    
function DeleteTab (wind,id)
    return table.remove(windows[tonumber(wind)].Tabs[tonumber(id)])
end
 
function GetShowingPools()
    local tableOBJ = {}
 for _, wind in ipairs(windows) do 
    if wind.isVisible then 
        table.insert(tableOBJ, wind)
    end
 end
   return tableOBJ
end


 
function GetMenuID(_wind)
   local id
    for _, wind in ipairs(windows) do 
        if wind == _wind or wind.title == _wind then 
            id = _ 
        end
    end
   return id
end




 
function GetCurrentTab()
 
    return currentUse
 
end



 
function GetCurrentSelect(window,tab)
 
    return windows[tonumber(window)].Tabs[tonumber(tab)][4]
 
end



 
function enterFunction ()
    --if not cursorUsed then cursorUsed = false end
    for _ , window in ipairs(windows) do 
    v = window.Tabs[currentUse]
    if (v[1== "button"then
        triggerEvent("NativeUI.onButtonEnter", localPlayer,window,v)
    elseif (v[1== "check"then
        
            v[3= not v[3]
            triggerEvent("NativeUI.onCheckEnter", localPlayer,window,v)
            
    elseif (v[1== "select"then 
        triggerEvent("NativeUI.onSelectEnter", localPlayer,window,v)
    end
    end
end


 
local wind = CreatePool("Test""tt",false,true)
 
for i=1,10 do
    addTab(wind , "button""test "..i,"btn."..i)
end


 
function adjustStartRow(window)
    if (currentUse > (window.startRow + iVisibleRow- 1)) then
        window.startRow = currentUse - iVisibleRow + 1
  
    elseif (currentUse < window.startRowthen
        window.startRow = currentUse
        
        
    end
end

spacer.png

Edited by Scooma Dev
add img
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...