BancoDeJoias = {} --#region REGISTRA FUN��ES DO SISTEMA function BancoDeJoias.Init() if BancoDeJoias_Define.Ativado then InterfaceController.MainProcInterface(BancoDeJoias.Interface) InterfaceController.InterfaceClickEvent(BancoDeJoias.ClickEvent) InterfaceController.InterfaceClickRightEvent(BancoDeJoias.ClickRightEvent) InterfaceController.MainProcWorldKey(BancoDeJoias.KeyListener) InterfaceController.ScrollMouse(BancoDeJoias.Scroll) InterfaceController.ClientProtocol(BancoDeJoias.Protocol) BancoDeJoias.Define() end end --#endregion --#region DEFINE VARIAVEIS DO SISTEMA function BancoDeJoias.Define() BancoDeJoias_Define.Buttons = {} BancoDeJoias_Define.Lista = {} BancoDeJoias_Define.Quantidades = {} BancoDeJoias_Define.Selected = {} BancoDeJoias_Define.SelectedBundle = -1 BancoDeJoias_Define.SelectedLevel = -1 BancoDeJoias_Define.ListOffset = 0 BancoDeJoias_Define.ScrollBar = {Offset = 0, InitSize = 154, Size = 0, MaxOffset = 0, Pos = 0, InitEsp = 154, Esp = 0, Multiplier = 0} BancoDeJoias_Define.ScrollButton = {Up = {State = false, Timer = 0}, Down = {State = false, Timer = 0}} BancoDeJoias_Define.WithdrawButton = {State = false, Timer = 0} end --#endregion --#region GERA LISTA DE ITENS VISIVEIS NA LISTA function BancoDeJoias.GerarLista() BancoDeJoias_Define.Lista = {} local count = 1 for i in ipairs(BancoDeJoias_Define.Config) do if i > BancoDeJoias_Define.ListOffset then if count <= 5 then table.insert(BancoDeJoias_Define.Lista, BancoDeJoias_Define.Config[i]) count = count + 1 end end end end --#endregion --#region CONTROLE BARRA DE ROLAGEM function BancoDeJoias.GerarBarra(Table, Bar, Lines) if Bar.Offset > 0 then Bar.Offset = Bar.Offset - 1 Bar.Pos = Bar.Pos - Bar.Multiplier end Bar.MaxOffset = #Table-Lines if #Table > Lines then Bar.Size = (Bar.InitSize - ((#Table-Lines)*10)) if Bar.Size < 10 then Bar.Size = 10 end else Bar.Size = Bar.InitSize end Bar.Esp = Bar.InitEsp - Bar.Size Bar.Multiplier = Bar.Esp/(#Table-Lines) end function BancoDeJoias.MoveBarDown(Bar) if Bar.Offset < Bar.MaxOffset then Bar.Offset = Bar.Offset + 1 Bar.Pos = Bar.Pos + Bar.Multiplier end end function BancoDeJoias.MoveBarUp(Bar) if Bar.Offset > 0 then Bar.Offset = Bar.Offset - 1 Bar.Pos = Bar.Pos - Bar.Multiplier end end --#endregion --#region ABRE/FECHA INTERFACE function BancoDeJoias.Open() CreatePacket("BJ_Open", BancoDeJoias_Define.Packet) SendPacket("BJ_Open") ClearPacket("BJ_Open") return end function BancoDeJoias.OpenWindow() BancoDeJoias.GerarLista() BancoDeJoias.GerarBarra(BancoDeJoias_Define.Config, BancoDeJoias_Define.ScrollBar, 5) CloseAllWindowsExcept(-1) OpenWindow(UIInventory) UICustomInterface = BancoDeJoias_Define.WindowID end function BancoDeJoias.Close() UICustomInterface = 0 CloseWindow(UIInventory) SetUnlockInterfaces() BancoDeJoias.Define() end --#endregion --#region CRIA/CHECA BOT�ES function BancoDeJoias.CreateButton(IdBotao, X, Y, W, H) if BancoDeJoias_Define.Buttons[IdBotao] == nil then table.insert(BancoDeJoias_Define.Buttons, IdBotao) end BancoDeJoias_Define.Buttons[IdBotao] = {X1 = X, X2 = X+W, Y1 = Y, Y2 = Y+H} end function BancoDeJoias.CheckButton(IdBotao, X, Y) if BancoDeJoias_Define.Buttons[IdBotao] == nil then return false end if X >= BancoDeJoias_Define.Buttons[IdBotao].X1 and X <= BancoDeJoias_Define.Buttons[IdBotao].X2 and Y >= BancoDeJoias_Define.Buttons[IdBotao].Y1 and Y <= BancoDeJoias_Define.Buttons[IdBotao].Y2 then return true end return false end --#endregion --#region INTERFACE function BancoDeJoias.Interface() --#region VERIFICA SE A JANELA DO SISTEMA ESTA ABERTA if UICustomInterface ~= BancoDeJoias_Define.WindowID then return end --#endregion --#region INICIO DA JANELA EnableAlphaTest() --#endregion --#region CRIA JANELA SetUnlockInterfaces() BancoDeJoias.CreateButton(1, 470, 395, 23, 23) if MousePosX() >= 260 and MousePosX() <= 450 and MousePosY() >= 0 and MousePosY() <= 433 then SetLockInterfaces() end if MousePosX() >= 466 and MousePosX() <= 581 and MousePosY() >= 393 and MousePosY() <= 419 then SetLockInterfaces() end CreateInterface(BancoDeJoias_Define.Images[1], 260, 0, 190, 256, 0, 0, 0.7424124, 1, 1,1) CreateInterface(BancoDeJoias_Define.Images[2], 260, 256, 190, 177, 0, 0, 0.7424124, 0.6918124, 1,1) --#endregion --#region ESCREVE TITULO DA JANELA NO CABE�ALHO SetFont(0) SetTextBackColor(0, 0, 0, 255) SetTextColor(255, 255, 255, 255) SetText2(355, 15, BancoDeJoias_Define.Texts[getLanguage()][1]) --#endregion --#region INICIO DESENHO DisableAlphaBlend() SetBlend() --#endregion --#region DESENHA BARRA DE ROLAGEM glColor4f(0.37, 0.3317, 0.2849, 1.0) DrawBar(411, 221, 14, 182) glColor4f(0.91, 0.875, 0.8099, 1.0) DrawBar(412, 235+BancoDeJoias_Define.ScrollBar.Pos, 12, BancoDeJoias_Define.ScrollBar.Size) glColor4f(0.39, 0.3504, 0.3081, 0.6) DrawBar(413, 236+BancoDeJoias_Define.ScrollBar.Pos, 10, BancoDeJoias_Define.ScrollBar.Size-2) --#endregion --#region DESENHA EFEITO HOVER SOBRE A LISTA local linha = 222 glColor4f(0.5, 0.5, 0.5, 0.2) for l = 1, 5 do if MousePosX() >= 290 and MousePosX() <= 405 then if MousePosY() >= linha and MousePosY() <= linha+35 then DrawBar(290, linha, 115, 33) end end linha = linha + 36 end --#endregion --#region DESENHA LINHAS SEPARATORIAS linha = 256 glColor4f(0.3, 0.3, 0.3, 0.5) for i = 1, 4 do DrawBar(290, linha, 115, 1) linha = linha + 36 end --#endregion --#region RENDERIZA ITENS NA LISTA linha = 230 for i in ipairs(BancoDeJoias_Define.Lista) do -- joia 3D a esquerda da linha (caixa 30x30), centrada na altura da linha (36px) CreateItem(300+BancoDeJoias_Define.Lista[i].Position.X, linha+2+BancoDeJoias_Define.Lista[i].Position.Y, BancoDeJoias_Define.Lista[i].Position.W,BancoDeJoias_Define.Lista[i].Position.H, BancoDeJoias_Define.Lista[i].Index) linha = linha + 36 end --#endregion --#region FIM DESENHO GLSwitchBlend() glColor3f(1.0, 1.0, 1.0) GLSwitch() EnableAlphaTest(1) --#endregion --#region RENDERIZA BOT�ES DA BARRA DE ROLAGEM BancoDeJoias.CreateButton(2, 412, 222, 13, 12) BancoDeJoias.CreateButton(3, 412, 391, 13, 12) if BancoDeJoias_Define.ScrollButton.Up.State then if BancoDeJoias_Define.ScrollButton.Up.Timer >= 2 then BancoDeJoias_Define.ScrollButton.Up.Timer = 0 BancoDeJoias_Define.ScrollButton.Up.State = false else CreateInterface(BancoDeJoias_Define.Images[4], 412, 222, 13, 12, 0, 0, 0.687676, 0.687676, 1,1) BancoDeJoias_Define.ScrollButton.Up.Timer = BancoDeJoias_Define.ScrollButton.Up.Timer + 1 end else CreateInterface(BancoDeJoias_Define.Images[3], 412, 222, 13, 12, 0, 0, 0.687676, 0.687676, 1,1) end if BancoDeJoias_Define.ScrollButton.Down.State then if BancoDeJoias_Define.ScrollButton.Down.Timer >= 2 then BancoDeJoias_Define.ScrollButton.Down.Timer = 0 BancoDeJoias_Define.ScrollButton.Down.State = false else CreateInterface(BancoDeJoias_Define.Images[6], 412, 391, 13, 12, 0, 0, 0.687676, 0.687676, 1,1) BancoDeJoias_Define.ScrollButton.Down.Timer = BancoDeJoias_Define.ScrollButton.Down.Timer + 1 end else CreateInterface(BancoDeJoias_Define.Images[5], 412, 391, 13, 12, 0, 0, 0.687676, 0.687676, 1,1) end --#endregion --#region ESCREVE NOME DA JOIA E SALDO NA LISTA linha = 245 for i in ipairs(BancoDeJoias_Define.Lista) do SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 208, 0, 255) SetText2(372, linha-12, string.format(BancoDeJoias_Define.Lista[i].Nome)) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 235) SetText2(372, linha+2, string.format("x%d", BancoDeJoias_Define.Quantidades[BancoDeJoias_Define.Lista[i].ListID] or 0)) linha = linha + 36 end --#endregion --#region JOIA SELECIONADA + QUANTIDADE + RETIRAR/DEPOSITAR if BancoDeJoias_Define.Selected.ListID ~= nil then local sel = BancoDeJoias_Define.Selected local saldo = BancoDeJoias_Define.Quantidades[sel.ListID] or 0 local livres = GetInventoryEmptySlots() local noInv = GetInventoryItemCount(sel.Index) SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 208, 0, 255) SetText2(355, 60, string.format(sel.Nome)) SetTextColor(255, 255, 255, 235) SetText2(410, 60, string.format("%d", saldo)) CreateItem(292+sel.Position.X, 60+sel.Position.Y, sel.Position.W, sel.Position.H, sel.Index) -- quantidade: 1 5 10 20 / 30 50 100 Max (Max = ate o espaco livre ao retirar, ate o que tem no inventario ao depositar) SetTextColor(0, 221, 255, 255) SetText(282, 82, BancoDeJoias_Define.Texts[getLanguage()][4]) local idx = 5 for q = 1, #BancoDeJoias_Define.Quantias do local x = 279 + ((q - 1) % 4) * 40 local y = 94 + math.floor((q - 1) / 4) * 22 BancoDeJoias.CreateButton(idx, x, y, 35, 16) if BancoDeJoias_Define.SelectedQty == q then glColor4f(0.7, 0.7, 0.7, 1.0) CreateInterface(IMG_BTN, x, y, 35, 16, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetTextColor(255, 208, 0, 255) else CreateInterface(IMG_BTN, x, y, 35, 16, 0, 0, 0.875, 0.75, 1, 1) SetTextColor(30, 30, 30, 255) end SetTextBackColor(0, 0, 0, 0) local v = BancoDeJoias_Define.Quantias[q] SetText2(x + 17, y + 4, (v == 0) and "Max" or tostring(v)) idx = idx + 1 end -- acoes: [13] Retirar [14] Depositar local function acao(id, x, label) BancoDeJoias.CreateButton(id, x, 148, 72, 22) if BancoDeJoias.CheckButton(id, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) end CreateInterface(IMG_BTN, x, 148, 72, 22, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText2(x + 36, 154, label) SetFont(0) end acao(13, 283, BancoDeJoias_Define.Texts[getLanguage()][2]) acao(14, 361, BancoDeJoias_Define.Texts[getLanguage()][5]) -- info: slots livres / quantidade dessa joia no inventario SetTextBackColor(0, 0, 0, 0) SetTextColor(200, 200, 200, 255) SetText2(355, 178, string.format(BancoDeJoias_Define.Texts[getLanguage()][6], livres, noInv)) else SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 208, 0, 255) SetText2(355, 60, string.format(BancoDeJoias_Define.Texts[getLanguage()][3])) end --#endregion --#region FIM DA JANELA DisableAlphaBlend() --#endregion end --#endregion --#region DETEC��O TECLADO function BancoDeJoias.KeyListener(key) if key == BancoDeJoias_Define.Shortcut then if GetChatPlayerOpen() ~= 1 then if CheckWindowOpen(UIStore) == 0 then if UICustomInterface == 0 or UICustomInterface == BancoDeJoias_Define.WindowID then if UICustomInterface == 0 then BancoDeJoias.Open() return true else BancoDeJoias.Close() return true end end end end end if key == Keys.Escape then if UICustomInterface == BancoDeJoias_Define.WindowID then BancoDeJoias.Close() return true end end end --#endregion --#region DETEC��O BOT�O ESQUERDO DO MOUSE function BancoDeJoias.ClickEvent() if UICustomInterface == BancoDeJoias_Define.WindowID then if BancoDeJoias.CheckButton(1, MousePosX(), MousePosY()) then BancoDeJoias.Close() return true end if BancoDeJoias.CheckButton(3, MousePosX(), MousePosY()) then if #BancoDeJoias_Define.Config > 5 then if #BancoDeJoias_Define.Config-BancoDeJoias_Define.ListOffset > 5 then BancoDeJoias_Define.ListOffset = BancoDeJoias_Define.ListOffset + 1 BancoDeJoias.GerarLista() BancoDeJoias.MoveBarDown(BancoDeJoias_Define.ScrollBar) end end BancoDeJoias_Define.ScrollButton.Down.State = true return true end if BancoDeJoias.CheckButton(2, MousePosX(), MousePosY()) then if BancoDeJoias_Define.ListOffset > 0 then BancoDeJoias_Define.ListOffset = BancoDeJoias_Define.ListOffset - 1 BancoDeJoias.GerarLista() BancoDeJoias.MoveBarUp(BancoDeJoias_Define.ScrollBar) end BancoDeJoias_Define.ScrollButton.Up.State = true return true end local linha = 222 for x = 1, 5 do if MousePosX() >= 290 and MousePosX()<= 405 then if MousePosY() >= linha and MousePosY() <= linha+33 then BancoDeJoias_Define.Selected = BancoDeJoias_Define.Lista[x] BancoDeJoias_Define.SelectedQty = 1 return true end end linha = linha + 36 end if BancoDeJoias_Define.Selected.ListID ~= nil then for q = 1, #BancoDeJoias_Define.Quantias do if BancoDeJoias.CheckButton(4 + q, MousePosX(), MousePosY()) then BancoDeJoias_Define.SelectedQty = q return true end end if BancoDeJoias.CheckButton(13, MousePosX(), MousePosY()) then BancoDeJoias.Withdraw() return true end if BancoDeJoias.CheckButton(14, MousePosX(), MousePosY()) then BancoDeJoias.DepositQty() return true end end end end --#endregion --#region SACA/DEPOSITA JOIA -- quantidade escolhida (0 = Max) limitada ao saldo/inventario function BancoDeJoias.QtdEscolhida(maximo) local v = BancoDeJoias_Define.Quantias[BancoDeJoias_Define.SelectedQty or 1] or 1 if v == 0 or v > maximo then v = maximo end return v end function BancoDeJoias.Withdraw() local sel = BancoDeJoias_Define.Selected if sel.ListID == nil then return end local saldo = BancoDeJoias_Define.Quantidades[sel.ListID] or 0 local qtd = BancoDeJoias.QtdEscolhida(math.min(saldo, GetInventoryEmptySlots())) if qtd <= 0 then return end CreatePacket("BJ_Withdraw", BancoDeJoias_Define.Packet) SetBytePacket("BJ_Withdraw", sel.ListID) SetWordPacket("BJ_Withdraw", qtd) SendPacket("BJ_Withdraw") ClearPacket("BJ_Withdraw") end -- deposita N joias (nivel 0) desse tipo que estao no inventario function BancoDeJoias.DepositQty() local sel = BancoDeJoias_Define.Selected if sel.ListID == nil then return end local qtd = BancoDeJoias.QtdEscolhida(GetInventoryItemCount(sel.Index)) if qtd <= 0 then return end CreatePacket("BJ_DepositQ", BancoDeJoias_Define.Packet) SetBytePacket("BJ_DepositQ", sel.ListID) SetWordPacket("BJ_DepositQ", qtd) SendPacket("BJ_DepositQ") ClearPacket("BJ_DepositQ") end function BancoDeJoias.Deposit(slot) if slot ~= -1 then CreatePacket("BJ_Deposit", BancoDeJoias_Define.Packet) SetBytePacket("BJ_Deposit", slot) SendPacket("BJ_Deposit") ClearPacket("BJ_Deposit") return end end --#endregion --#region DETEC��O BOTAO DIREITO DO MOUSE function BancoDeJoias.ClickRightEvent() local x = MousePosX() local y = MousePosY() if GetKeyboardRepeat(Keys.ControlKey) ~= 0 then if x >= 465 and x <= 624 and y >= 200 and y <= 359 then local slot = GetSlotItemInventory() if slot ~= -1 then BancoDeJoias.Deposit(slot) return true end end end end --#endregion --#region DETEC��O SCROLL DO MOUSE function BancoDeJoias.Scroll(Direction) local x = MousePosX() local y = MousePosY() if UICustomInterface == BancoDeJoias_Define.WindowID then if x >= 283 and x <= 428 and y >= 202 and y <= 409 then if Direction > 0 then if BancoDeJoias_Define.ListOffset > 0 then BancoDeJoias_Define.ListOffset = BancoDeJoias_Define.ListOffset - 1 BancoDeJoias.GerarLista() BancoDeJoias.MoveBarUp(BancoDeJoias_Define.ScrollBar) end return true else if #BancoDeJoias_Define.Config > 5 then if #BancoDeJoias_Define.Config-BancoDeJoias_Define.ListOffset > 5 then BancoDeJoias_Define.ListOffset = BancoDeJoias_Define.ListOffset + 1 BancoDeJoias.GerarLista() BancoDeJoias.MoveBarDown(BancoDeJoias_Define.ScrollBar) end end return true end return true end end end --#endregion --#region RECEBE PACKET DO SERVIDOR function BancoDeJoias.Protocol(Packet, PacketName) if Packet == BancoDeJoias_Define.Packet then if PacketName == "BJ_OpenW" then for l = 1, #BancoDeJoias_Define.Config do local valor = GetDwordPacket(PacketName, -1) if BancoDeJoias_Define.Quantidades[l] == nil then table.insert(BancoDeJoias_Define.Quantidades, l) end BancoDeJoias_Define.Quantidades[l] = valor end ClearPacket(PacketName) BancoDeJoias.OpenWindow() return true end if PacketName == "BJ_Update" then if UICustomInterface == BancoDeJoias_Define.WindowID then local id = GetBytePacket(PacketName, -1) local valor = GetDwordPacket(PacketName, -1) if BancoDeJoias_Define.Quantidades[id] == nil then table.insert(BancoDeJoias_Define.Quantidades, id) end BancoDeJoias_Define.Quantidades[id] = valor end ClearPacket(PacketName) return true end end return false end --#endregion --#region INCIALIZA O SISTEMA BancoDeJoias.Init() --#endregion return BancoDeJoias