LimparInventario = {} LimparInventario_WaitConfirmation = false LimparInventario_Buttons = {} -- S3: o pack varria flags de janela (window*2, S6). Aqui: alguma janela de -- painel aberta alem do inventario/personagem -> nao mostra o botao. function LimparInventario.OutraJanelaAberta() for _, id in ipairs(UIPanelWindows) do if id ~= UIInventory and id ~= UICharacter and CheckWindowOpen(id) == 1 then return true end end return false end -- Posicao do botao no inventario nativo (x=450): os botoes nativos ficam em -- y=395 nos x 473/503/533 (sair/reparar/loja) -> o nosso vai em x=566. local LI_BTN_X, LI_BTN_Y = 566, 395 local LI_POP_X, LI_POP_Y = 215, 125 LimparInventario_BtnText = { ["Eng"] = { "Yes", "No" }, ["Por"] = { "Sim", "Nao" }, ["Spn"] = { "Si", "No" }, } function LI_TextButton(id, x, y, w, h, label) LimparInventario.CreateButton(id, x, y, w, h) if LimparInventario.CheckButton(id, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) end CreateInterface(IMG_BTN, x, y, w, h, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) -- rotulo escuro sobre a placa clara, centralizado (~6px por caractere) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) local tw = string.len(label or "") * 6 SetText(math.floor(x + (w - tw) / 2), math.floor(y + (h - 10) / 2), label or "") SetFont(0) end function LimparInventario.Init() if LimparInventario_Ativado then InterfaceController.MainProcInterface(LimparInventario.Interface) InterfaceController.MainProcWorldKey(LimparInventario.KeyListener) InterfaceController.InterfaceClickEvent(LimparInventario.ClickEvent) end end function LimparInventario.CreateButton(IdBotao, X, Y, W, H) if LimparInventario_Buttons[IdBotao] == nil then table.insert(LimparInventario_Buttons, IdBotao) end LimparInventario_Buttons[IdBotao] = {X1 = X, X2 = X+W, Y1 = Y, Y2 = Y+H} end function LimparInventario.CheckButton(IdBotao, X, Y) if LimparInventario_Buttons[IdBotao] == nil then return false end if X >= LimparInventario_Buttons[IdBotao].X1 and X <= LimparInventario_Buttons[IdBotao].X2 and Y >= LimparInventario_Buttons[IdBotao].Y1 and Y <= LimparInventario_Buttons[IdBotao].Y2 then return true end return false end function LimparInventario.Interface() if CheckWindowOpen(UIInventory) == 1 then if UICustomInterface == 0 then EnableAlphaTest(1) if LimparInventario.OutraJanelaAberta() then goto fim end -- (sem 'local' aqui: o goto fim acima nao pode pular para dentro do escopo de um local) CreateInterface(LimparInventario_Images[1], LI_BTN_X, LI_BTN_Y, 23, 23, 0, 0, 0.75, 0.75, 1, 1) LimparInventario.CreateButton(1, LI_BTN_X, LI_BTN_Y, 23, 23) if LimparInventario.CheckButton(1, MousePosX(), MousePosY()) then SetFont(0) SetTextBackColor(0, 0, 0, 235) SetTextColor(255, 255, 255, 255) SetText(LI_BTN_X - 60, LI_BTN_Y - 14, LimparInventario_Texts[getLanguage()][1]) end if LimparInventario_WaitConfirmation then local btxt = LimparInventario_BtnText[getLanguage()] or LimparInventario_BtnText["Eng"] CreateInterface(IMG_PANEL, LI_POP_X, LI_POP_Y, 225, 78, 0, 0, 0.83203125, 1.0, 1, 1) SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) SetText2(LI_POP_X + 112, LI_POP_Y + 22, LimparInventario_Texts[getLanguage()][2]) LI_TextButton(2, LI_POP_X + 52, LI_POP_Y + 46, 47, 20, btxt[1]) LI_TextButton(3, LI_POP_X + 130, LI_POP_Y + 46, 47, 20, btxt[2]) end ::fim:: DisableAlphaBlend() end end end function LimparInventario.SendClearInventory() CreatePacket("ClearInv", LimparInventario_Packet) SendPacket("ClearInv") ClearPacket("ClearInv") end function LimparInventario.KeyListener(key) if LimparInventario_WaitConfirmation then if key == 27 then LimparInventario_WaitConfirmation = false SetUnlockInterfaces() return end end end function LimparInventario.ClickEvent() if CheckWindowOpen(UIInventory) == 1 then if UICustomInterface == 0 then if LimparInventario.OutraJanelaAberta() then goto fim end if LimparInventario.CheckButton(1, MousePosX(), MousePosY()) then LimparInventario_WaitConfirmation = true SetLockInterfaces() end if LimparInventario_WaitConfirmation then if LimparInventario.CheckButton(2, MousePosX(), MousePosY()) then LimparInventario.SendClearInventory() SetUnlockInterfaces() LimparInventario_WaitConfirmation = false end if LimparInventario.CheckButton(3, MousePosX(), MousePosY()) then SetUnlockInterfaces() LimparInventario_WaitConfirmation = false end end ::fim:: end end end LimparInventario.Init() return LimparInventario