diff --git a/.travis.yml b/.travis.yml index 20251cf..54842d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,27 @@ -language: minimal -before_deploy: -- mkdir -p /tmp/addon/Banker -- cp -R . /tmp/addon/Banker -- rm -rf /tmp/addon/Banker/.git /tmp/addon/Banker/.travis /tmp/addon/Banker/*.md -- pushd /tmp/addon && zip -r /tmp/Banker.zip Banker && popd -addons: - apt: - packages: - - zip -deploy: - - provider: script - script: sh .travis/deploy.sh 362 $TRAVIS_TAG 4.2 /tmp/Banker.zip - on: - repo: Nols1000/Banker - tags: true - - provider: releases - api_key: - secure: L2YZPuVaxqKsgWjmOvg/+XmX+RXg45aCKp4uOrpFoef5LWHusiaSmaDsSWsIF7vdg/wGKcdDHgapqyawS7vlr3Y7IT7widvlgPIhQGKMb5FWoTMOfay1jBO3GGJyXY+pNM75bozJJZPaCftKWWg9ljBAt53QzoEOZo83o2TDbfTbYmfz2JkufSwcB113PR8/F3IIgym/8UcbgPiwIH6S8YTY2iDVkL1u6DExuzvF4+oB7p/rYokwXj49FvzQzSe8WaPzmsVK7Tjuz0c53+BKF4Vsx0IGe4qqdHPv4VTguDbtn4bu98mp9cNfuTmeDmXQ4ldC5S4z5xPaTLWQQmQ/IiPpxIxU7U6HIKOL58sDJuMTnVoauq3zBNZhhfE9kajUo1JzhIVcR5Eb5AERhgn6Y9hOQJ9cA7QOH1f61Gi4lFcABkpt53FxFFdq+HL/fWsuQQ4DgSZcn5LzL57OC8ooMMdaU4Sg2C6/D+vWKJwXqflFga3f3KkMP3LU4M0Cf1KzFoKrTLdr5G/u3zEIwvxIUQXVTzcyNSA1xnN11B/FNzNEnKOnF7/6eG59UWnrY+bDJN5wE89JTNietGqccFgQKocs6IjxJF3UIG3jKi8WBKmFg2PJy15UgheqDy8KPp4C3c3eWiO1LYkIRmZaNK/3mnvx/zCkof+NFDnxaNhkHyc= - file: "/tmp/Banker.zip" - on: - repo: Nols1000/Banker - tags: true -env: - global: - secure: akF3JIJlyIZ6j1xrPlrpgGhCG3o0srO0dV1pR0vRHsm5rljLd9AvSujL4U2VAYGSNTqvzOyJYz5IudAyWYX7Xly/1roZt/LA29SciYvBT7WtjZYPoe7UkCHy90n9sK0dn2l3NFT83DMtI3rc0sHypRgl1sm3UBHOEgp+KDgerA/Bk1uZ+sGIrB1mo0dP+K+uSQciFkRfBPY/rmY4VfqjVpcDO/sgJGYKm/loZdzeLrDLjLGoKuGGpNjUR9Gs2GhEGSeHUqrRMTX1JfVqiCP/gTAe35mP2R5LZgqI7KvupcjChn+lXMrIF9NHSzjH34LJL3ymWWqMGp/+OXUZs9xZk47aWfa29MYUAgwqlQVGq49M8rOqHqSuidswSddP8jN6G5PkDAbwaipAi3TjYusmGcg5rijpfJQM411S8C2dRCSUvqyC3ADJYzXC3ZI74mgJboaPzQ6d04Y2w0E55ilBaCKXnK2bLyuS9OHSBJ00wf2QGKA0cLHbghumzPWaq2xmra9HZj57NABW2vhz8Jr+Y8rQqH1GJU7hAnU4J0VRrF3D29rtApg7yJLN1YgFCCP+UgpVbZjjAwqObJPlcVaT/Upd+JxhIt6prscW5gxpvynE9Zba9vdTRv/3v9kQSeeUyarFc6og96By7CSQvENR+OkSqmxOH59DCrGEFbr+0yQ= +language: minimal + +before_deploy: + - mkdir -p /tmp/addon/Banker + - cp -R . /tmp/addon/Banker + - rm -rf /tmp/addon/Banker/.git /tmp/addon/Banker/.travis /tmp/addon/Banker/*.md + - pushd /tmp/addon && zip -r /tmp/Banker.zip Banker && popd +addons: + apt: + packages: + - zip +deploy: + - provider: script + script: sh .travis/deploy.sh $TRAVIS_TAG 4.2 /tmp/Banker.zip + on: + repo: Nols1000/Banker + tags: true + - provider: releases + api_key: + secure: L2YZPuVaxqKsgWjmOvg/+XmX+RXg45aCKp4uOrpFoef5LWHusiaSmaDsSWsIF7vdg/wGKcdDHgapqyawS7vlr3Y7IT7widvlgPIhQGKMb5FWoTMOfay1jBO3GGJyXY+pNM75bozJJZPaCftKWWg9ljBAt53QzoEOZo83o2TDbfTbYmfz2JkufSwcB113PR8/F3IIgym/8UcbgPiwIH6S8YTY2iDVkL1u6DExuzvF4+oB7p/rYokwXj49FvzQzSe8WaPzmsVK7Tjuz0c53+BKF4Vsx0IGe4qqdHPv4VTguDbtn4bu98mp9cNfuTmeDmXQ4ldC5S4z5xPaTLWQQmQ/IiPpxIxU7U6HIKOL58sDJuMTnVoauq3zBNZhhfE9kajUo1JzhIVcR5Eb5AERhgn6Y9hOQJ9cA7QOH1f61Gi4lFcABkpt53FxFFdq+HL/fWsuQQ4DgSZcn5LzL57OC8ooMMdaU4Sg2C6/D+vWKJwXqflFga3f3KkMP3LU4M0Cf1KzFoKrTLdr5G/u3zEIwvxIUQXVTzcyNSA1xnN11B/FNzNEnKOnF7/6eG59UWnrY+bDJN5wE89JTNietGqccFgQKocs6IjxJF3UIG3jKi8WBKmFg2PJy15UgheqDy8KPp4C3c3eWiO1LYkIRmZaNK/3mnvx/zCkof+NFDnxaNhkHyc= + file: "/tmp/Banker.zip" + on: + repo: Nols1000/Banker + tags: true +env: + global: + secure: akF3JIJlyIZ6j1xrPlrpgGhCG3o0srO0dV1pR0vRHsm5rljLd9AvSujL4U2VAYGSNTqvzOyJYz5IudAyWYX7Xly/1roZt/LA29SciYvBT7WtjZYPoe7UkCHy90n9sK0dn2l3NFT83DMtI3rc0sHypRgl1sm3UBHOEgp+KDgerA/Bk1uZ+sGIrB1mo0dP+K+uSQciFkRfBPY/rmY4VfqjVpcDO/sgJGYKm/loZdzeLrDLjLGoKuGGpNjUR9Gs2GhEGSeHUqrRMTX1JfVqiCP/gTAe35mP2R5LZgqI7KvupcjChn+lXMrIF9NHSzjH34LJL3ymWWqMGp/+OXUZs9xZk47aWfa29MYUAgwqlQVGq49M8rOqHqSuidswSddP8jN6G5PkDAbwaipAi3TjYusmGcg5rijpfJQM411S8C2dRCSUvqyC3ADJYzXC3ZI74mgJboaPzQ6d04Y2w0E55ilBaCKXnK2bLyuS9OHSBJ00wf2QGKA0cLHbghumzPWaq2xmra9HZj57NABW2vhz8Jr+Y8rQqH1GJU7hAnU4J0VRrF3D29rtApg7yJLN1YgFCCP+UgpVbZjjAwqObJPlcVaT/Upd+JxhIt6prscW5gxpvynE9Zba9vdTRv/3v9kQSeeUyarFc6og96By7CSQvENR+OkSqmxOH59DCrGEFbr+0yQ= diff --git a/.travis/blackfriday b/.travis/blackfriday new file mode 100755 index 0000000..d337c40 Binary files /dev/null and b/.travis/blackfriday differ diff --git a/.travis/deploy.sh b/.travis/deploy.sh index 6c82b59..af52374 100644 --- a/.travis/deploy.sh +++ b/.travis/deploy.sh @@ -1,8 +1,10 @@ #!/bin/sh curl --url 'https://api.esoui.com/addons/update' \ --header "x-api-token: ${ESOUI_API_KEY}" \ - --form id=$1 \ - --form version=$2 \ - --form archive=Yes \ - --form compatible=$3 \ - --form updatefile=@$4 \ No newline at end of file + --form "id=362" \ + --form "version=$1" \ + --form "archive=Yes" \ + --form "compatible=$2" \ + --form "updatefile=@$3" \ + --form "description=$(.travis/blackfriday -common-extensions -format=vb-code Readme.md)" \ + --form "changelog=$(.travis/blackfriday -common-extensions -format=vb-code Changelog.md)" \ No newline at end of file diff --git a/Banker.lua b/Banker.lua index 97f17ea..538902e 100644 --- a/Banker.lua +++ b/Banker.lua @@ -1,364 +1,364 @@ -SI = Banker.SI - -Banker.newItem = function(iBagId, iSlotId, iType, iName, iLink, iIcon) - local item ={ - bagId = iBagId, - slotId = iSlotId, - itemType = iType, - name = iName, - link = iLink, - icon = iIcon, - } - - return item -end - -Banker.initVars = function() - PACKAGE = "com.github.Nols1000.banker" - VERSION = 8 - - defaults = {} - defaults.lang = 1 - defaults.iTypes = {} - - for i = 0, #Banker.ItemTypes - 1, 1 do - defaults.iTypes[Banker.ItemTypes[i]] = true - end - - defaults.items = true - defaults.money = true - defaults.debug = false - defaults.msg = true - defaults.keymenu = true - - defaults.mStep = 50 - defaults.mMin = 500 - - defaults.updated = false - - Banker.isBankOpen = false -end - -Banker.initUI = function() - local SI = Banker.SI - local s = Banker.Settings - - Banker.KeybindStripDescriptor = - { - { - name = SI.get(SI.KB_SYNC_ITEMS), - keybind = "SYNC_INVENTORY", - callback = function() Banker.stackItems() end, - visible = function() return Banker.isBankOpen end, - }, - { - name = SI.get(SI.KB_SAFE_MONEY), - keybind = "AUTO_DEPOSIT_MONEY", - callback = function() Banker.safeMoney() end, - visible = function() return Banker.isBankOpen end, - }, - alignment = KEYBIND_STRIP_ALIGN_CENTER, - } - - s.init() - - s.add({ - type = "header", - name = SI.get(SI.COMMON_TITLE), - }); - - s.add({ - type = "description", - text = SI.get(SI.COMMON_DESC), - }) - - s.add({ - type = "checkbox", - name = SI.get(SI.EITEMS_TITLE), - tooltip = "", - getFunc = function() - return Banker.vars.items - end, - setFunc = function(bool) - Banker.vars.items = bool - end, - default = function() - return defaults.items - end - }) - - s.add({ - type = "checkbox", - name = SI.get(SI.MSG_TITLE), - tooltip = "", - getFunc = function() - return Banker.vars.msg - end, - setFunc = function(bool) - Banker.vars.msg = bool - end, - default = function() - return defaults.msg - end - }) - - s.add({ - type = "checkbox", - name = SI.get(SI.DEBUG_TITLE), - tooltip = "", - getFunc = function() - return Banker.vars.debug - end, - setFunc = function(bool) - Banker.vars.debug = bool - end, - default = function() - return defaults.debug - end - }) - - s.add({ - type = "checkbox", - name = SI.get(SI.KB_TITLE), - tooltip = "", - getFunc = function() - return Banker.vars.keymenu - end, - setFunc = function(bool) - Banker.vars.keymenu = bool - end, - default = function() - return defaults.keymenu - end - }) - - s.add({ - type = "slider", - name = SI.get(SI.STEP_TITLE), - max = 1000, - min = 5, - getFunc = function() - return Banker.vars.mStep - end, - setFunc = function(arg0) - Banker.vars.mStep = arg0 - end, - default = function() - return defaults.mStep - end, - }) - - s.add({ - type = "slider", - name = SI.get(SI.MIN_TITLE), - max = 10000, - min = 500, - getFunc = function() - return Banker.vars.mMin - end, - setFunc = function(arg0) - Banker.vars.mMin = arg0 - end, - default = function() - return defaults.mMin - end, - }) - - s.add({ - type = "header", - name = SI.get(SI.ITEMTYPE_TITLE), - }); - - s.add({ - type = "description", - text = SI.get(SI.ITEMTYPE_DESC), - }) - - for i = 0, #Banker.ItemTypes, 1 do - - s.add({ - type = "checkbox", - name = GetString("SI_ITEMTYPE", Banker.ItemTypes[i]), - tooltip = "", - getFunc = function() - return Banker.vars.iTypes[Banker.ItemTypes[i]] - end, - setFunc = function(bool) - Banker.vars.iTypes[Banker.ItemTypes[i]] = bool - end, - default = function() - return defaults.iTypes[Banker.ItemTypes[i]] - end - }) - end -end - -Banker.onLoaded = function(event, name) - if name ~= "Banker" then return end - - Banker.initVars() - Banker.vars = ZO_SavedVars:New("BankerVariables", VERSION, nil, defaults) - Banker.vars.lang = GetCVar("language.2") or "en" - - if Banker.vars.lang ~= "en" or Banker.vars.lang ~= "de" or Banker.vars.lang ~= "fr" then - Banker.mDebug(string.format("%s is not supported. Banker will use standard language (en).", Banker.vars.lang)) - end - - Banker.initUI() -end - -Banker.onOpenBank = function() - Banker.toggleSyncBinding() - - if Banker.vars.items then - Banker.stackItems() - end - - if Banker.vars.money then - Banker.safeMoney() - end -end - -Banker.onCloseBank = function() - Banker.toggleSyncBinding() -end - -Banker.stackItems = function() - local bankItems = Banker.getItems(BAG_BANK) - local backpackItems = Banker.getItems(BAG_BACKPACK) - - for i = 0, #backpackItems-1, 1 do - for k = 0, #bankItems-1, 1 do - if backpackItems[i].name == bankItems[k].name then - if Banker.vars.iTypes[backpackItems[i].itemType] then - Banker.transferItem(BAG_BACKPACK, BAG_BANK, i, k) - end - end - end - end -end - -Banker.safeMoney = function() - local bankMoney = GetBankedMoney() - local playerMoney = GetCurrentMoney() - - if playerMoney > Banker.vars.mMin then - local n = math.floor( (playerMoney - Banker.vars.mMin) / Banker.vars.mStep ) - - if n > 0 then - local tMoney = n * Banker.vars.mStep - - DepositMoneyIntoBank(tMoney) - Banker.msg(string.format("%s |t16:16:EsoUI/Art/currency/currency_gold.dds|t were transferd to your bank.", tMoney)) - end - end -end - -Banker.getItems = function(bagId) - local items = {} - local numBagSlots = GetBagSize(bagId) - - for i = 0, numBagSlots, 1 do - icon, _, _, _, _, _ = GetItemInfo(bagId, i) - itemType = GetItemType(bagId, i) - name = GetItemName(bagId, i) - link = GetItemLink(bagId, i, LINK_STYLE_BRACKETS) -- LINK_STYLE_DEFAULT - - Banker.test = { - bagId = bagId, - index = i, - itemT = itemType, - name = name, - link = link, - icon = icon - } - items[i] = Banker.newItem(bagId, i, itemType, name, link, icon) - end - - return items -end - -Banker.transferItem = function(fromBag, toBag, fromSlot, toSlot) - - local fStackSize = GetSlotStackSize(fromBag, fromSlot) - local fName = GetItemLink(fromBag, fromSlot) - local tStackSize = GetSlotStackSize(toBag, toSlot) - - local stack = (fStackSize + tStackSize) - 200 - - if stack <= 0 and fStackSize ~= 0 then - if Banker.Lib.stackItem(fromBag, fromSlot, toBag, toSlot, fStackSize, fName) then - local texture = GetItemInfo(fromBag, fromSlot) - Banker.msg(string.format("%s x [%s] was added to bank.", fStackSize, fName)) - else - Banker.msg(string.format("[%s] wasn't added to bank.", fName)) - end - elseif fStackSize ~= 0 then - fStackSize = fStackSize - stack - if fStackSize > 0 then - if Banker.Lib.stackItem(fromBag, fromSlot, toBag, toSlot, fStackSize, fName) then - local texture = GetItemInfo(fromBag, fromSlot) - Banker.msg(string.format("%s x [%s] was added to bank.", fStackSize, fName)) - else - Banker.msg(string.format("[%s] wasn't added to bank.", fName)) - end - end - end -end - -Banker.toggleSyncBinding = function() - Banker.isBankOpen = not Banker.isBankOpen - - if Banker.isBankOpen then - Banker.mDebug("Banker.isBankOpen: true") - else - Banker.mDebug("Banker.isBankOpen: false"); - end - - if Banker.vars.keymenu then - if Banker.isBankOpen then - Banker.mDebug("show") - KEYBIND_STRIP:AddKeybindButtonGroup(Banker.KeybindStripDescriptor) - KEYBIND_STRIP:UpdateKeybindButtonGroup(Banker.KeybindStripDescriptor) - else - Banker.mDebug("hide") - KEYBIND_STRIP:RemoveKeybindButtonGroup(Banker.KeybindStripDescriptor) - end - end -end - -Banker.mDebug = function(arg0) - if Banker.vars.debug then - CHAT_SYSTEM:AddMessage("[BANKER] " .. arg0) - end -end - -Banker.msg = function(arg0) - if Banker.vars.msg then - CHAT_SYSTEM:AddMessage(arg0) - end -end - -EVENT_MANAGER:RegisterForEvent("BankerOnBankOpen", EVENT_OPEN_BANK, Banker.onOpenBank) -EVENT_MANAGER:RegisterForEvent("BankerOnBankClose", EVENT_CLOSE_BANK, Banker.onCloseBank) -EVENT_MANAGER:RegisterForEvent("BankerOnLoad", EVENT_ADD_ON_LOADED, Banker.onLoaded) - -Banker.Lib = {} - -Banker.Lib.stackItem = function(fromBag, fromSlot, toBag, toSlot, quantity, name) - Banker.mDebug("stacking") - local result = true - -- just in case - ClearCursor() - -- must call secure protected (pickup the item via cursor) - result = CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity) - Banker.mDebug("called secure protected") - if (result) then - -- must call secure protected (drop the item on the cursor) - Banker.mDebug("called secure protected2") - result = CallSecureProtected("PlaceInInventory", toBag, toSlot) - end - -- clear the cursor to avoid issues - ClearCursor() - return result +SI = Banker.SI + +Banker.newItem = function(iBagId, iSlotId, iType, iName, iLink, iIcon) + local item ={ + bagId = iBagId, + slotId = iSlotId, + itemType = iType, + name = iName, + link = iLink, + icon = iIcon, + } + + return item +end + +Banker.initVars = function() + PACKAGE = "com.github.Nols1000.banker" + VERSION = 8 + + defaults = {} + defaults.lang = 1 + defaults.iTypes = {} + + for i = 0, #Banker.ItemTypes - 1, 1 do + defaults.iTypes[Banker.ItemTypes[i]] = true + end + + defaults.items = true + defaults.money = true + defaults.debug = false + defaults.msg = true + defaults.keymenu = true + + defaults.mStep = 50 + defaults.mMin = 500 + + defaults.updated = false + + Banker.isBankOpen = false +end + +Banker.initUI = function() + local SI = Banker.SI + local s = Banker.Settings + + Banker.KeybindStripDescriptor = + { + { + name = SI.get(SI.KB_SYNC_ITEMS), + keybind = "SYNC_INVENTORY", + callback = function() Banker.stackItems() end, + visible = function() return Banker.isBankOpen end, + }, + { + name = SI.get(SI.KB_SAFE_MONEY), + keybind = "AUTO_DEPOSIT_MONEY", + callback = function() Banker.safeMoney() end, + visible = function() return Banker.isBankOpen end, + }, + alignment = KEYBIND_STRIP_ALIGN_CENTER, + } + + s.init() + + s.add({ + type = "header", + name = SI.get(SI.COMMON_TITLE), + }); + + s.add({ + type = "description", + text = SI.get(SI.COMMON_DESC), + }) + + s.add({ + type = "checkbox", + name = SI.get(SI.EITEMS_TITLE), + tooltip = "", + getFunc = function() + return Banker.vars.items + end, + setFunc = function(bool) + Banker.vars.items = bool + end, + default = function() + return defaults.items + end + }) + + s.add({ + type = "checkbox", + name = SI.get(SI.MSG_TITLE), + tooltip = "", + getFunc = function() + return Banker.vars.msg + end, + setFunc = function(bool) + Banker.vars.msg = bool + end, + default = function() + return defaults.msg + end + }) + + s.add({ + type = "checkbox", + name = SI.get(SI.DEBUG_TITLE), + tooltip = "", + getFunc = function() + return Banker.vars.debug + end, + setFunc = function(bool) + Banker.vars.debug = bool + end, + default = function() + return defaults.debug + end + }) + + s.add({ + type = "checkbox", + name = SI.get(SI.KB_TITLE), + tooltip = "", + getFunc = function() + return Banker.vars.keymenu + end, + setFunc = function(bool) + Banker.vars.keymenu = bool + end, + default = function() + return defaults.keymenu + end + }) + + s.add({ + type = "slider", + name = SI.get(SI.STEP_TITLE), + max = 1000, + min = 5, + getFunc = function() + return Banker.vars.mStep + end, + setFunc = function(arg0) + Banker.vars.mStep = arg0 + end, + default = function() + return defaults.mStep + end, + }) + + s.add({ + type = "slider", + name = SI.get(SI.MIN_TITLE), + max = 10000, + min = 500, + getFunc = function() + return Banker.vars.mMin + end, + setFunc = function(arg0) + Banker.vars.mMin = arg0 + end, + default = function() + return defaults.mMin + end, + }) + + s.add({ + type = "header", + name = SI.get(SI.ITEMTYPE_TITLE), + }); + + s.add({ + type = "description", + text = SI.get(SI.ITEMTYPE_DESC), + }) + + for i = 0, #Banker.ItemTypes, 1 do + + s.add({ + type = "checkbox", + name = GetString("SI_ITEMTYPE", Banker.ItemTypes[i]), + tooltip = "", + getFunc = function() + return Banker.vars.iTypes[Banker.ItemTypes[i]] + end, + setFunc = function(bool) + Banker.vars.iTypes[Banker.ItemTypes[i]] = bool + end, + default = function() + return defaults.iTypes[Banker.ItemTypes[i]] + end + }) + end +end + +Banker.onLoaded = function(event, name) + if name ~= "Banker" then return end + + Banker.initVars() + Banker.vars = ZO_SavedVars:New("BankerVariables", VERSION, nil, defaults) + Banker.vars.lang = GetCVar("language.2") or "en" + + if Banker.vars.lang ~= "en" or Banker.vars.lang ~= "de" or Banker.vars.lang ~= "fr" then + Banker.mDebug(string.format("%s is not supported. Banker will use standard language (en).", Banker.vars.lang)) + end + + Banker.initUI() +end + +Banker.onOpenBank = function() + Banker.toggleSyncBinding() + + if Banker.vars.items then + Banker.stackItems() + end + + if Banker.vars.money then + Banker.safeMoney() + end +end + +Banker.onCloseBank = function() + Banker.toggleSyncBinding() +end + +Banker.stackItems = function() + local bankItems = Banker.getItems(BAG_BANK) + local backpackItems = Banker.getItems(BAG_BACKPACK) + + for i = 0, #backpackItems-1, 1 do + for k = 0, #bankItems-1, 1 do + if backpackItems[i].name == bankItems[k].name then + if Banker.vars.iTypes[backpackItems[i].itemType] then + Banker.transferItem(BAG_BACKPACK, BAG_BANK, i, k) + end + end + end + end +end + +Banker.safeMoney = function() + local bankMoney = GetBankedMoney() + local playerMoney = GetCurrentMoney() + + if playerMoney > Banker.vars.mMin then + local n = math.floor( (playerMoney - Banker.vars.mMin) / Banker.vars.mStep ) + + if n > 0 then + local tMoney = n * Banker.vars.mStep + + DepositMoneyIntoBank(tMoney) + Banker.msg(string.format("%s |t16:16:EsoUI/Art/currency/currency_gold.dds|t were transferd to your bank.", tMoney)) + end + end +end + +Banker.getItems = function(bagId) + local items = {} + local numBagSlots = GetBagSize(bagId) + + for i = 0, numBagSlots, 1 do + icon, _, _, _, _, _ = GetItemInfo(bagId, i) + itemType = GetItemType(bagId, i) + name = GetItemName(bagId, i) + link = GetItemLink(bagId, i, LINK_STYLE_BRACKETS) -- LINK_STYLE_DEFAULT + + Banker.test = { + bagId = bagId, + index = i, + itemT = itemType, + name = name, + link = link, + icon = icon + } + items[i] = Banker.newItem(bagId, i, itemType, name, link, icon) + end + + return items +end + +Banker.transferItem = function(fromBag, toBag, fromSlot, toSlot) + + local fStackSize = GetSlotStackSize(fromBag, fromSlot) + local fName = GetItemLink(fromBag, fromSlot) + local tStackSize = GetSlotStackSize(toBag, toSlot) + + local stack = (fStackSize + tStackSize) - 200 + + if stack <= 0 and fStackSize ~= 0 then + if Banker.Lib.stackItem(fromBag, fromSlot, toBag, toSlot, fStackSize, fName) then + local texture = GetItemInfo(fromBag, fromSlot) + Banker.msg(string.format("%s x [%s] was added to bank.", fStackSize, fName)) + else + Banker.msg(string.format("[%s] wasn't added to bank.", fName)) + end + elseif fStackSize ~= 0 then + fStackSize = fStackSize - stack + if fStackSize > 0 then + if Banker.Lib.stackItem(fromBag, fromSlot, toBag, toSlot, fStackSize, fName) then + local texture = GetItemInfo(fromBag, fromSlot) + Banker.msg(string.format("%s x [%s] was added to bank.", fStackSize, fName)) + else + Banker.msg(string.format("[%s] wasn't added to bank.", fName)) + end + end + end +end + +Banker.toggleSyncBinding = function() + Banker.isBankOpen = not Banker.isBankOpen + + if Banker.isBankOpen then + Banker.mDebug("Banker.isBankOpen: true") + else + Banker.mDebug("Banker.isBankOpen: false"); + end + + if Banker.vars.keymenu then + if Banker.isBankOpen then + Banker.mDebug("show") + KEYBIND_STRIP:AddKeybindButtonGroup(Banker.KeybindStripDescriptor) + KEYBIND_STRIP:UpdateKeybindButtonGroup(Banker.KeybindStripDescriptor) + else + Banker.mDebug("hide") + KEYBIND_STRIP:RemoveKeybindButtonGroup(Banker.KeybindStripDescriptor) + end + end +end + +Banker.mDebug = function(arg0) + if Banker.vars.debug then + CHAT_SYSTEM:AddMessage("[BANKER] " .. arg0) + end +end + +Banker.msg = function(arg0) + if Banker.vars.msg then + CHAT_SYSTEM:AddMessage(arg0) + end +end + +EVENT_MANAGER:RegisterForEvent("BankerOnBankOpen", EVENT_OPEN_BANK, Banker.onOpenBank) +EVENT_MANAGER:RegisterForEvent("BankerOnBankClose", EVENT_CLOSE_BANK, Banker.onCloseBank) +EVENT_MANAGER:RegisterForEvent("BankerOnLoad", EVENT_ADD_ON_LOADED, Banker.onLoaded) + +Banker.Lib = {} + +Banker.Lib.stackItem = function(fromBag, fromSlot, toBag, toSlot, quantity, name) + Banker.mDebug("stacking") + local result = true + -- just in case + ClearCursor() + -- must call secure protected (pickup the item via cursor) + result = CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity) + Banker.mDebug("called secure protected") + if (result) then + -- must call secure protected (drop the item on the cursor) + Banker.mDebug("called secure protected2") + result = CallSecureProtected("PlaceInInventory", toBag, toSlot) + end + -- clear the cursor to avoid issues + ClearCursor() + return result end \ No newline at end of file diff --git a/Banker.txt b/Banker.txt index b77fb58..1d14d87 100644 --- a/Banker.txt +++ b/Banker.txt @@ -1,34 +1,34 @@ -## Title: Banker -## Description: An Addon to keep your inventory clear and easily stack all stackable items in your Bank. -## Author: Nols1000 -## Version: 1.5 -## APIVersion: 100025 -## SavedVariables: BankerVariables -## OptionalDependsOn: LibAddonMenu-2.0 - -libs\LibStub\LibStub.lua -libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua -libs\LibAddonMenu-2.0\controls\panel.lua -libs\LibAddonMenu-2.0\controls\submenu.lua -libs\LibAddonMenu-2.0\controls\button.lua -libs\LibAddonMenu-2.0\controls\checkbox.lua -libs\LibAddonMenu-2.0\controls\colorpicker.lua -libs\LibAddonMenu-2.0\controls\custom.lua -libs\LibAddonMenu-2.0\controls\description.lua -libs\LibAddonMenu-2.0\controls\dropdown.lua -libs\LibAddonMenu-2.0\controls\editbox.lua -libs\LibAddonMenu-2.0\controls\header.lua -libs\LibAddonMenu-2.0\controls\slider.lua -libs\LibAddonMenu-2.0\controls\texture.lua - -core\globalVariables.lua - -localization\SI.lua -localization\en.lua -localization\$(language).lua - -Settings.lua - -Banker.lua - +## Title: Banker +## Description: An Addon to keep your inventory clear and easily stack all stackable items in your Bank. +## Author: Nols1000 +## Version: 1.5 +## APIVersion: 100025 +## SavedVariables: BankerVariables +## OptionalDependsOn: LibAddonMenu-2.0 + +libs\LibStub\LibStub.lua +libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua +libs\LibAddonMenu-2.0\controls\panel.lua +libs\LibAddonMenu-2.0\controls\submenu.lua +libs\LibAddonMenu-2.0\controls\button.lua +libs\LibAddonMenu-2.0\controls\checkbox.lua +libs\LibAddonMenu-2.0\controls\colorpicker.lua +libs\LibAddonMenu-2.0\controls\custom.lua +libs\LibAddonMenu-2.0\controls\description.lua +libs\LibAddonMenu-2.0\controls\dropdown.lua +libs\LibAddonMenu-2.0\controls\editbox.lua +libs\LibAddonMenu-2.0\controls\header.lua +libs\LibAddonMenu-2.0\controls\slider.lua +libs\LibAddonMenu-2.0\controls\texture.lua + +core\globalVariables.lua + +localization\SI.lua +localization\en.lua +localization\$(language).lua + +Settings.lua + +Banker.lua + Bindings.xml \ No newline at end of file diff --git a/Banker.xml b/Banker.xml index 47268f1..cd35d36 100644 --- a/Banker.xml +++ b/Banker.xml @@ -1,14 +1,14 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/Bindings.xml b/Bindings.xml index 6541c63..eae1a2d 100644 --- a/Bindings.xml +++ b/Bindings.xml @@ -1,12 +1,12 @@ - - - - - Banker.stackItems() - - - Banker.safeMoney() - - - + + + + + Banker.stackItems() + + + Banker.safeMoney() + + + \ No newline at end of file diff --git a/Changelog.md b/Changelog.md index 05d8cd5..67bffdd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,55 +1,69 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - -## Unreleased -- Nothing - -## 1.4 - 2018-10-10 -### Changed -- Updated the ItemTypes -- Use SI_ITEMTYPES instead of the addon specific translation - -## 1.3 -- adds Feature: Stacks that aren't in your Bank if they're big enough -- added disableing Money-Transfer - -## 1.2 -- fixed Hotkey Support (hopefully this time realy) - -## 1.1 -- fixed Settings (now using LibAddonMenu-2.0) -- fixed Hotkey Support - -## 1.0a -- Update 6 ready -- LibAddonMenu 2.0 ready - -## 0.9b -- new Localization-Sytem (bug) - -## 0.8b -- option to disable keybinbsbar (DEVELOPER-SETTINGS) -- better French translation - -## 0.7b -- added keybinds -- better German translation - -## 0.6a -- added feature to safe money (view upside) -- added some options -- changed English translation -- changed German translation - -## 0.4a -- fixed some issues with chat notification -- added uncomplete german translation -- redone settings - -## 0.2a -- now stacks up to 100 - -## 0.1a +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## 1.5 - 2018-11-13 + +- Bump APIVersion to 1000025 (4.2) +- Change maximum stack size to 200 + +## 1.4 - 2018-10-10 + +- Updated the ItemTypes +- Use SI_ITEMTYPES instead of the addon specific translation + +## 1.3 + +- adds Feature: Stacks that aren't in your Bank if they're big enough +- added disableing Money-Transfer + +## 1.2 + +- fixed Hotkey Support (hopefully this time realy) + +## 1.1 + +- fixed Settings (now using LibAddonMenu-2.0) +- fixed Hotkey Support + +## 1.0a + +- Update 6 ready +- LibAddonMenu 2.0 ready + +## 0.9b + +- new Localization-Sytem (bug) + +## 0.8b + +- option to disable keybinbsbar (DEVELOPER-SETTINGS) +- better French translation + +## 0.7b + +- added keybinds +- better German translation + +## 0.6a + +- added feature to safe money (view upside) +- added some options +- changed English translation +- changed German translation + +## 0.4a + +- fixed some issues with chat notification +- added uncomplete german translation +- redone settings + +## 0.2a + +- now stacks up to 100 + +## 0.1a + - inital release \ No newline at end of file diff --git a/LICENSE b/LICENSE index 732bb5f..723f620 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,674 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 2015 Nils-Börge Margotti - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Banker Copyright (C) 2015 Nils-Börge Margotti - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 2015 Nils-Börge Margotti + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Banker Copyright (C) 2015 Nils-Börge Margotti + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read . \ No newline at end of file diff --git a/Readme.md b/Readme.md index 9f85bf7..abf7847 100644 --- a/Readme.md +++ b/Readme.md @@ -1,37 +1,43 @@ -# Banker -Banker is an addon for The Elder Scrolls Online that helps to keep the bag and bank account organized by depositing stackable items in the bank account, either automatic or with one keypress. - -## Features -- Automatic depositing of stackable items in the bank -- Automatic depositing of a configurable amount of gold in the bank -- Configurable shortcuts to trigger depositing of stackable items -- Configurable shortcuts to trigger depositing of money - - -## Built With -- [LibAddonMenu 2.0](http://www.esoui.com/downloads/info7-LibAddonMenu.html) -- [LibStub](http://www.esoui.com/downloads/info44-LibStub.html) - - -## Credits -Thanks to Zupa for English translation -Thanks to [MrOsmose](http://www.nexusmods.com/games/users/6182996/?) for French translation - - -## Bugs -You can report bugs [at Nexusmods](https://www.nexusmods.com/elderscrollsonline/mods/34/?tab=bugs) or [at Github](https://github.com/Nols1000/Banker/issues). -- ~~Settings-Strings null~~ [SOLVED] -- ~~no hotkey support~~ [SOLVED] -- ~~dont deposite sometimes~~ [SOLVED] -- ~~disables chatmessages of other addones~~ [SOLVED] (Thanks to [hatecreeper](http://www.nexusmods.com/elderscrollsonline/users/3925519) for reporting) - -## Authors -- Nils-Börge Margotti - Maintainer -- Zupa - English translation -- [MrOsmose](http://www.nexusmods.com/games/users/6182996/?) - French translation - -## Changelog -The changelog can be found in the file [Changelog.md](Changelog.md). - -## License -This project is licensed under the GPLv3 - see the [LICENSE](LICENSE) file for details. +# Banker + +Banker is an addon for The Elder Scrolls Online that helps to keep the bag and bank account organized by depositing stackable items in the bank account, either automatic or with one keypress. + +## Features + +- Automatic depositing of stackable items in the bank +- Automatic depositing of a configurable amount of gold in the bank +- Configurable shortcuts to trigger depositing of stackable items +- Configurable shortcuts to trigger depositing of money + +## Built With + +- [LibAddonMenu 2.0](http://www.esoui.com/downloads/info7-LibAddonMenu.html) +- [LibStub](http://www.esoui.com/downloads/info44-LibStub.html) + +## Credits + +Thanks to Zupa for English translation +Thanks to [MrOsmose](http://www.nexusmods.com/games/users/6182996/?) for French translation + +## Bugs + +You can report bugs [at Nexusmods](https://www.nexusmods.com/elderscrollsonline/mods/34/?tab=bugs) or [at Github](https://github.com/Nols1000/Banker/issues). + +- ~~Settings-Strings null~~ [SOLVED] +- ~~no hotkey support~~ [SOLVED] +- ~~dont deposite sometimes~~ [SOLVED] +- ~~disables chatmessages of other addones~~ [SOLVED] \(Thanks to [hatecreeper](http://www.nexusmods.com/elderscrollsonline/users/3925519) for reporting\) + +## Authors + +- Nils-Börge Margotti - *Maintainer* +- Zupa - *English translation* +- [MrOsmose](http://www.nexusmods.com/games/users/6182996/?) - *French translation* + +## Changelog + +The changelog can be found in the file [Changelog.md](https://github.com/Nols1000/Banker/blob/master/Changelog.md). + +## License + +This project is licensed under the GPLv3 - see the [LICENSE](https://github.com/Nols1000/Banker/blob/master/LICENSE) file for details. diff --git a/Settings.lua b/Settings.lua index 7b3927f..88d96cb 100644 --- a/Settings.lua +++ b/Settings.lua @@ -1,67 +1,67 @@ - -Banker.LAM = LibStub("LibAddonMenu-2.0") - -Banker.Settings = { - - panel = { - type = "panel", - name = SI.get(SI.BANKER_NAME), - author="Nils-Börge Margotti", - version="1.5", - slashCommand="/banker", - registerForRefresh=true, - registerForDefaults=true - }, - - settings = { - - [1] = { - type="header", - name=SI.get(SI.HEADER_SETTINGS), - }, - [2] = { - type="description", - name=SI.get(SI.DESC_MAIN_TITLE), - text=SI.get(SI.DESC_MAIN), - } - }, - - init = function() - - local s = Banker.Settings - - Banker.LAM:RegisterAddonPanel("BankerOptions", s.panel); - end, - - add = function(option) - - local s = Banker.Settings - - local n = table.getn(s.settings) + 1 - s.settings[n] = option - - s.refresh() - end, - - clear = function() - - local s = Banker.Settings - - s.settings = { - - [1] = { - type="header", - name=SI.get("HEADER_SETTINGS") - } - } - - s.refresh() - end, - - refresh = function() - - local s = Banker.Settings - - Banker.LAM:RegisterOptionControls("BankerOptions", s.settings) - end + +Banker.LAM = LibStub("LibAddonMenu-2.0") + +Banker.Settings = { + + panel = { + type = "panel", + name = SI.get(SI.BANKER_NAME), + author="Nils-Börge Margotti", + version="1.5", + slashCommand="/banker", + registerForRefresh=true, + registerForDefaults=true + }, + + settings = { + + [1] = { + type="header", + name=SI.get(SI.HEADER_SETTINGS), + }, + [2] = { + type="description", + name=SI.get(SI.DESC_MAIN_TITLE), + text=SI.get(SI.DESC_MAIN), + } + }, + + init = function() + + local s = Banker.Settings + + Banker.LAM:RegisterAddonPanel("BankerOptions", s.panel); + end, + + add = function(option) + + local s = Banker.Settings + + local n = table.getn(s.settings) + 1 + s.settings[n] = option + + s.refresh() + end, + + clear = function() + + local s = Banker.Settings + + s.settings = { + + [1] = { + type="header", + name=SI.get("HEADER_SETTINGS") + } + } + + s.refresh() + end, + + refresh = function() + + local s = Banker.Settings + + Banker.LAM:RegisterOptionControls("BankerOptions", s.settings) + end } \ No newline at end of file diff --git a/core/globalVariables.lua b/core/globalVariables.lua index 54aecb2..d4ddf57 100644 --- a/core/globalVariables.lua +++ b/core/globalVariables.lua @@ -1,75 +1,75 @@ -Banker = { - ItemTypes = { - [0] = ITEMTYPE_ADDITIVE, - [1] = ITEMTYPE_ARMOR, - [2] = ITEMTYPE_ARMOR_TRAIT, - [3] = ITEMTYPE_ARMOR_BOOSTER, - [4] = ITEMTYPE_ARMOR_TRAIT, - [5] = ITEMTYPE_AVA_REPAIR, - [6] = ITEMTYPE_BLACKSMITHING_BOOSTER, - [7] = ITEMTYPE_BLACKSMITHING_MATERIAL, - [8] = ITEMTYPE_BLACKSMITHING_RAW_MATERIAL, - [9] = ITEMTYPE_CLOTHIER_BOOSTER, - [10] = ITEMTYPE_CLOTHIER_MATERIAL, - [11] = ITEMTYPE_CLOTHIER_RAW_MATERIAL, - [12] = ITEMTYPE_COLLECTIBLE, - [13] = ITEMTYPE_CONTAINER, - [14] = ITEMTYPE_COSTUME, - [15] = ITEMTYPE_CROWN_ITEM, - [16] = ITEMTYPE_CROWN_REPAIR, - [17] = ITEMTYPE_DEPRECATED, - [18] = ITEMTYPE_DISGUISE, - [19] = ITEMTYPE_DRINK, - [20] = ITEMTYPE_DYE_STAMP, - [21] = ITEMTYPE_ENCHANTING_RUNE_ASPECT, - [22] = ITEMTYPE_ENCHANTING_RUNE_ESSENCE, - [23] = ITEMTYPE_ENCHANTING_RUNE_POTENCY, - [24] = ITEMTYPE_ENCHANTMENT_BOOSTER, - [25] = ITEMTYPE_FISH, - [26] = ITEMTYPE_FLAVORING, - [27] = ITEMTYPE_FOOD, - [28] = ITEMTYPE_FURNISHING, - [29] = ITEMTYPE_FURNISHING_MATERIAL, - [30] = ITEMTYPE_GLYPH_ARMOR, - [31] = ITEMTYPE_GLYPH_JEWELRY, - [32] = ITEMTYPE_GLYPH_WEAPON, - [33] = ITEMTYPE_INGREDIENT, - [34] = ITEMTYPE_JEWELRYCRAFTING_BOOSTER, - [35] = ITEMTYPE_JEWELRYCRAFTING_MATERIAL, - [36] = ITEMTYPE_JEWELRYCRAFTING_RAW_BOOSTER, - [37] = ITEMTYPE_JEWELRYCRAFTING_RAW_MATERIAL, - [38] = ITEMTYPE_JEWELRY_RAW_TRAIT, - [39] = ITEMTYPE_JEWELRY_TRAIT, - [40] = ITEMTYPE_LOCKPICK, - [41] = ITEMTYPE_LURE, - [42] = ITEMTYPE_MASTER_WRIT, - [43] = ITEMTYPE_MOUNT, - [44] = ITEMTYPE_NONE, - [45] = ITEMTYPE_PLUG, - [46] = ITEMTYPE_POISON, - [47] = ITEMTYPE_POISON_BASE, - [48] = ITEMTYPE_POTION, - [49] = ITEMTYPE_POTION_BASE, - [50] = ITEMTYPE_RACIAL_STYLE_MOTIF, - [51] = ITEMTYPE_RAW_MATERIAL, - [52] = ITEMTYPE_REAGENT, - [53] = ITEMTYPE_RECALL_STONE, - [54] = ITEMTYPE_RECIPE, - [55] = ITEMTYPE_SIEGE, - [56] = ITEMTYPE_SOUL_GEM, - [57] = ITEMTYPE_SPELLCRAFTING_TABLET, - [58] = ITEMTYPE_SPICE, - [59] = ITEMTYPE_STYLE_MATERIAL, - [60] = ITEMTYPE_TABARD, - [61] = ITEMTYPE_TOOL, - [62] = ITEMTYPE_TRASH, - [63] = ITEMTYPE_TREASURE, - [64] = ITEMTYPE_TROPHY, - [65] = ITEMTYPE_WEAPON, - [66] = ITEMTYPE_WEAPON_BOOSTER, - [67] = ITEMTYPE_WEAPON_TRAIT, - [68] = ITEMTYPE_WOODWORKING_BOOSTER, - [69] = ITEMTYPE_WOODWORKING_MATERIAL, - [70] = ITEMTYPE_WOODWORKING_RAW_MATERIAL, - }, -} +Banker = { + ItemTypes = { + [0] = ITEMTYPE_ADDITIVE, + [1] = ITEMTYPE_ARMOR, + [2] = ITEMTYPE_ARMOR_TRAIT, + [3] = ITEMTYPE_ARMOR_BOOSTER, + [4] = ITEMTYPE_ARMOR_TRAIT, + [5] = ITEMTYPE_AVA_REPAIR, + [6] = ITEMTYPE_BLACKSMITHING_BOOSTER, + [7] = ITEMTYPE_BLACKSMITHING_MATERIAL, + [8] = ITEMTYPE_BLACKSMITHING_RAW_MATERIAL, + [9] = ITEMTYPE_CLOTHIER_BOOSTER, + [10] = ITEMTYPE_CLOTHIER_MATERIAL, + [11] = ITEMTYPE_CLOTHIER_RAW_MATERIAL, + [12] = ITEMTYPE_COLLECTIBLE, + [13] = ITEMTYPE_CONTAINER, + [14] = ITEMTYPE_COSTUME, + [15] = ITEMTYPE_CROWN_ITEM, + [16] = ITEMTYPE_CROWN_REPAIR, + [17] = ITEMTYPE_DEPRECATED, + [18] = ITEMTYPE_DISGUISE, + [19] = ITEMTYPE_DRINK, + [20] = ITEMTYPE_DYE_STAMP, + [21] = ITEMTYPE_ENCHANTING_RUNE_ASPECT, + [22] = ITEMTYPE_ENCHANTING_RUNE_ESSENCE, + [23] = ITEMTYPE_ENCHANTING_RUNE_POTENCY, + [24] = ITEMTYPE_ENCHANTMENT_BOOSTER, + [25] = ITEMTYPE_FISH, + [26] = ITEMTYPE_FLAVORING, + [27] = ITEMTYPE_FOOD, + [28] = ITEMTYPE_FURNISHING, + [29] = ITEMTYPE_FURNISHING_MATERIAL, + [30] = ITEMTYPE_GLYPH_ARMOR, + [31] = ITEMTYPE_GLYPH_JEWELRY, + [32] = ITEMTYPE_GLYPH_WEAPON, + [33] = ITEMTYPE_INGREDIENT, + [34] = ITEMTYPE_JEWELRYCRAFTING_BOOSTER, + [35] = ITEMTYPE_JEWELRYCRAFTING_MATERIAL, + [36] = ITEMTYPE_JEWELRYCRAFTING_RAW_BOOSTER, + [37] = ITEMTYPE_JEWELRYCRAFTING_RAW_MATERIAL, + [38] = ITEMTYPE_JEWELRY_RAW_TRAIT, + [39] = ITEMTYPE_JEWELRY_TRAIT, + [40] = ITEMTYPE_LOCKPICK, + [41] = ITEMTYPE_LURE, + [42] = ITEMTYPE_MASTER_WRIT, + [43] = ITEMTYPE_MOUNT, + [44] = ITEMTYPE_NONE, + [45] = ITEMTYPE_PLUG, + [46] = ITEMTYPE_POISON, + [47] = ITEMTYPE_POISON_BASE, + [48] = ITEMTYPE_POTION, + [49] = ITEMTYPE_POTION_BASE, + [50] = ITEMTYPE_RACIAL_STYLE_MOTIF, + [51] = ITEMTYPE_RAW_MATERIAL, + [52] = ITEMTYPE_REAGENT, + [53] = ITEMTYPE_RECALL_STONE, + [54] = ITEMTYPE_RECIPE, + [55] = ITEMTYPE_SIEGE, + [56] = ITEMTYPE_SOUL_GEM, + [57] = ITEMTYPE_SPELLCRAFTING_TABLET, + [58] = ITEMTYPE_SPICE, + [59] = ITEMTYPE_STYLE_MATERIAL, + [60] = ITEMTYPE_TABARD, + [61] = ITEMTYPE_TOOL, + [62] = ITEMTYPE_TRASH, + [63] = ITEMTYPE_TREASURE, + [64] = ITEMTYPE_TROPHY, + [65] = ITEMTYPE_WEAPON, + [66] = ITEMTYPE_WEAPON_BOOSTER, + [67] = ITEMTYPE_WEAPON_TRAIT, + [68] = ITEMTYPE_WOODWORKING_BOOSTER, + [69] = ITEMTYPE_WOODWORKING_MATERIAL, + [70] = ITEMTYPE_WOODWORKING_RAW_MATERIAL, + }, +} diff --git a/libs/LibAddonMenu-1.0/LibAddonMenu-1.0.lua b/libs/LibAddonMenu-1.0/LibAddonMenu-1.0.lua index 7e382b1..d7a547c 100644 --- a/libs/LibAddonMenu-1.0/LibAddonMenu-1.0.lua +++ b/libs/LibAddonMenu-1.0/LibAddonMenu-1.0.lua @@ -1,373 +1,373 @@ -local MAJOR, MINOR = "LibAddonMenu-1.0", 6 -local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not lam then return end --the same or newer version of this lib is already loaded into memory - ---UPVALUES-- -lam.lastAddedControl = {} -local lastAddedControl = lam.lastAddedControl -local wm = GetWindowManager() -local strformat = string.format -local tostring = tostring -local round = zo_round -local optionsWindow = ZO_OptionsWindowSettingsScrollChild - ---maybe return the controls from the creation functions? - -function lam:CreateControlPanel(controlPanelID, controlPanelName) - local panelID - - if _G[controlPanelID] then - panelID = _G[controlPanelID] - return panelID - end - - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelName) - - --disables Defaults button because we don't need it, but keybind still works :/ ... - panelID = _G[controlPanelID] - ZO_PreHook("ZO_OptionsWindow_ChangePanels", function(panel) - local enable = (panel ~= panelID) - ZO_OptionsWindowResetToDefaultButton:SetEnabled(enable) - ZO_OptionsWindowResetToDefaultButton:SetKeybindEnabled(enable) - end) - - return panelID -end - -function lam:AddHeader(panelID, controlName, text) - local header = wm:CreateControlFromVirtual(controlName, optionsWindow, lastAddedControl[panelID] and "ZO_Options_SectionTitle_WithDivider" or "ZO_Options_SectionTitle") - if lastAddedControl[panelID] then - header:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 15) - else - header:SetAnchor(TOPLEFT) - end - header.controlType = OPTIONS_SECTION_TITLE - header.panel = panelID - header.text = text - - ZO_OptionsWindow_InitializeControl(header) - - lastAddedControl[panelID] = header - - return header -end - - ---To-Do list: ---extra sub-options window out to the right?? (or maybe addon list?) ---find alternatives to handler hooks - -function lam:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText) - local slider = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Slider") - slider:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) - slider.controlType = OPTIONS_SLIDER - slider.system = SETTING_TYPE_UI - slider.panel = panelID - slider.text = text - slider.tooltipText = tooltip - slider.showValue = true - slider.showValueMin = minValue - slider.showValueMax = maxValue - local range = maxValue - minValue - local slidercontrol = slider:GetNamedChild("Slider") - local slidervalue = slider:GetNamedChild("ValueLabel") - slidercontrol:SetValueStep(1/range * step) - slider:SetHandler("OnShow", function() - local curValue = getFunc() - slidercontrol:SetValue((curValue - minValue)/range) - slidervalue:SetText(tostring(curValue)) - end) - slidercontrol:SetHandler("OnValueChanged", function (self, value) - self:SetValue(value) - value = round(value*range + minValue) - slidervalue:SetText(strformat("%d", value)) - end) - slidercontrol:SetHandler("OnSliderReleased", function(self, value) - value = round(value*range + minValue) - setFunc(value) - end) - - if warning then - slider.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", slider, "ZO_Options_WarningIcon") - slider.warning:SetAnchor(RIGHT, slidercontrol, LEFT, -5, 0) - slider.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(slider) - - lastAddedControl[panelID] = slider - - return slider -end - -function lam:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText) - local dropdown = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Dropdown") - dropdown:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) - dropdown.controlType = OPTIONS_DROPDOWN - dropdown.system = SETTING_TYPE_UI - dropdown.panel = panelID - dropdown.text = text - dropdown.tooltipText = tooltip - dropdown.valid = validChoices - local dropmenu = ZO_ComboBox_ObjectFromContainer(GetControl(dropdown, "Dropdown")) - local setText = dropmenu.m_selectedItemText.SetText - local selectedName - ZO_PreHookHandler(dropmenu.m_selectedItemText, "OnTextChanged", function(self) - if dropmenu.m_selectedItemData then - selectedName = dropmenu.m_selectedItemData.name - setText(self, selectedName) - setFunc(selectedName) - end - end) - dropdown:SetHandler("OnShow", function() - dropmenu:SetSelectedItem(getFunc()) - end) - - if warning then - dropdown.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", dropdown, "ZO_Options_WarningIcon") - dropdown.warning:SetAnchor(RIGHT, dropdown:GetNamedChild("Dropdown"), LEFT, -5, 0) - dropdown.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(dropdown) - - lastAddedControl[panelID] = dropdown - - return dropdown -end - -function lam:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) - local checkbox = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Checkbox") - checkbox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) - checkbox.controlType = OPTIONS_CHECKBOX - checkbox.system = SETTING_TYPE_UI - checkbox.settingId = _G[strformat("SETTING_%s", controlName)] - checkbox.panel = panelID - checkbox.text = text - checkbox.tooltipText = tooltip - - local checkboxButton = checkbox:GetNamedChild("Checkbox") - - ZO_PreHookHandler(checkbox, "OnShow", function() - checkboxButton:SetState(getFunc() and 1 or 0) - checkboxButton:toggleFunction(getFunc()) - end) - ZO_PreHookHandler(checkboxButton, "OnClicked", function() setFunc(not getFunc()) end) - - if warning then - checkbox.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", checkbox, "ZO_Options_WarningIcon") - checkbox.warning:SetAnchor(RIGHT, checkboxButton, LEFT, -5, 0) - checkbox.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(checkbox) - - lastAddedControl[panelID] = checkbox - - return checkbox -end - -function lam:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) - local colorpicker = wm:CreateTopLevelWindow(controlName) - colorpicker:SetParent(optionsWindow) - colorpicker:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) - colorpicker:SetResizeToFitDescendents(true) - colorpicker:SetWidth(510) - colorpicker:SetMouseEnabled(true) - - colorpicker.label = wm:CreateControl(controlName.."Label", colorpicker, CT_LABEL) - local label = colorpicker.label - label:SetDimensions(300, 26) - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(text) - - colorpicker.color = wm:CreateControl(controlName.."Color", colorpicker, CT_CONTROL) - local color = colorpicker.color - color:SetDimensions(200,26) - color:SetAnchor(RIGHT) - - color.thumb = wm:CreateControl(controlName.."ColorThumb", color, CT_TEXTURE) - local thumb = color.thumb - thumb:SetDimensions(36, 18) - thumb:SetAnchor(LEFT, color, LEFT, 4, 0) - local r, g, b, a = getFunc() - thumb:SetColor(r, g, b, a or 1) - - color.border = wm:CreateControl(controlName.."ColorBorder", color, CT_TEXTURE) - local border = color.border - border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") - border:SetTextureCoords(0, .625, 0, .8125) - border:SetDimensions(40, 22) - border:SetAnchor(CENTER, thumb, CENTER, 0, 0) - - local ColorPickerCallback - if not ColorPickerCallback then - ColorPickerCallback = function(r, g, b, a) - thumb:SetColor(r, g, b, a or 1) - setFunc(r, g, b, a) - end - end - - colorpicker.controlType = OPTIONS_CUSTOM - colorpicker.customSetupFunction = function(colorpicker) - colorpicker:SetHandler("OnMouseUp", function(self, btn, upInside) - if upInside then - local r, g, b, a = getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, text) - end - end) - end - colorpicker.panel = panelID - colorpicker.tooltipText = tooltip - colorpicker:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - colorpicker:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - if warning then - colorpicker.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", colorpicker, "ZO_Options_WarningIcon") - colorpicker.warning:SetAnchor(RIGHT, colorpicker:GetNamedChild("Color"), LEFT, -5, 0) - colorpicker.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(colorpicker) - - lastAddedControl[panelID] = colorpicker - - return colorpicker -end - -function lam:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText) - local editbox = wm:CreateTopLevelWindow(controlName) - editbox:SetParent(optionsWindow) - editbox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) - editbox:SetResizeToFitDescendents(true) - editbox:SetWidth(510) - editbox:SetMouseEnabled(true) - - editbox.label = wm:CreateControl(controlName.."Label", editbox, CT_LABEL) - local label = editbox.label - label:SetDimensions(300, 26) - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(text) - - editbox.bg = wm:CreateControlFromVirtual(controlName.."BG", editbox, "ZO_EditBackdrop") - local bg = editbox.bg - bg:SetDimensions(200,isMultiLine and 100 or 24) - bg:SetAnchor(RIGHT) - editbox.edit = wm:CreateControlFromVirtual(controlName.."Edit", bg, isMultiLine and "ZO_DefaultEditMultiLineForBackdrop" or "ZO_DefaultEditForBackdrop") - editbox.edit:SetText(getFunc()) - editbox.edit:SetHandler("OnFocusLost", function(self) setFunc(self:GetText()) end) - - - editbox.panel = panelID - editbox.tooltipText = tooltip - editbox:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - editbox:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - if warning then - editbox.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", editbox, "ZO_Options_WarningIcon") - editbox.warning:SetAnchor(TOPRIGHT, editbox:GetNamedChild("BG"), TOPLEFT, -5, 0) - editbox.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(editbox) - - lastAddedControl[panelID] = editbox - - return editbox -end - -function lam:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText) - local button = wm:CreateTopLevelWindow(controlName) - button:SetParent(optionsWindow) - button:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) - button:SetDimensions(510, 28) - button:SetMouseEnabled(true) - - button.btn = wm:CreateControlFromVirtual(controlName.."Button", button, "ZO_DefaultButton") - local btn = button.btn - btn:SetAnchor(TOPRIGHT) - btn:SetWidth(200) - btn:SetText(text) - btn:SetHandler("OnClicked", onClick) - - button.controlType = OPTIONS_CUSTOM - button.customSetupFunction = function() end --move handlers into this function? (since I created a function...) - button.panel = panelID - btn.tooltipText = tooltip - btn:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - btn:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - if warning then - button.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", button, "ZO_Options_WarningIcon") - button.warning:SetAnchor(RIGHT, btn, LEFT, -5, 0) - button.warning.tooltipText = warningText - end - - ZO_OptionsWindow_InitializeControl(button) - - lastAddedControl[panelID] = button - - return button -end - -function lam:AddDescription(panelID, controlName, text, titleText) - local textBox = wm:CreateTopLevelWindow(controlName) - textBox:SetParent(optionsWindow) - textBox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) - textBox:SetResizeToFitDescendents(true) - textBox:SetWidth(510) - - if titleText then - textBox.title = wm:CreateControl(controlName.."Title", textBox, CT_LABEL) - local title = textBox.title - title:SetWidth(510) - title:SetAnchor(TOPLEFT, textBox, TOPLEFT) - title:SetFont("ZoFontWinH4") - title:SetText(titleText) - end - - textBox.desc = wm:CreateControl(controlName.."Text", textBox, CT_LABEL) - local desc = textBox.desc - desc:SetWidth(510) - if titleText then - desc:SetAnchor(TOPLEFT, textBox.title, BOTTOMLEFT) - else - desc:SetAnchor(TOPLEFT) - end - desc:SetVerticalAlignment(TEXT_ALIGN_TOP) - desc:SetFont("ZoFontGame") - desc:SetText(text) - - textBox.controlType = OPTIONS_CUSTOM - textBox.panel = panelID - - ZO_OptionsWindow_InitializeControl(textBox) - - lastAddedControl[panelID] = textBox - - return textBox -end - - ---test controls & examples-- ---[[local controlPanelID = lam:CreateControlPanel("ZAM_ADDON_OPTIONS", "ZAM Addons") -lam:AddHeader(controlPanelID, "ZAM_Addons_TESTADDON", "TEST ADDON") -lam:AddDescription(controlPanelID, "ZAM_Addons_TESTDESC", "This is a test description.", "Header") -lam:AddSlider(controlPanelID, "ZAM_TESTSLIDER", "Test slider", "Adjust the slider.", 1, 10, 1, function() return 7 end, function(value) end, true, "needs UI reload") -lam:AddDropdown(controlPanelID, "ZAM_TESTDROPDOWN", "Test Dropdown", "Pick something!", {"thing 1", "thing 2", "thing 3"}, function() return "thing 2" end, function(self,valueString) print(valueString) end) -local checkbox1 = true -lam:AddCheckbox(controlPanelID, "ZAM_TESTCHECKBOX", "Test Checkbox", "On or off?", function() return checkbox1 end, function(value) checkbox1 = not checkbox1 print(value, checkbox1) end) -lam:AddColorPicker(controlPanelID, "ZAM_TESTCOLORPICKER", "Test color picker", "What's your favorite color?", function() return 1, 1, 0 end, function(r,g,b) print(r,g,b) end) -lam:AddEditBox(controlPanelID, "ZAM_TESTEDITBOX", "Test Edit Box", "This is a tooltip!", false, function() return "hi" end, function(text) print(text) end) -lam:AddHeader(controlPanelID, "ZAM_Addons_TESTADDON2", "TEST ADDON 2") -local checkbox2 = false -lam:AddCheckbox(controlPanelID, "ZAM_TESTCHECKBOX2", "Test Checkbox 2", "On or off?", function() return checkbox2 end, function(value) checkbox2 = not checkbox2 print(value, checkbox2) end) -lam:AddButton(controlPanelID, "ZAM_TESTBUTTON", "Test Button", "Click me", function() print("hi") end, true, "oh noez!") -lam:AddEditBox(controlPanelID, "ZAM_TESTEDITBOX2", "Test Edit Box 2", "This is a tooltip!", true, function() return "hi" end, function(text) print(text) end, true, "warning text") -lam:AddSlider(controlPanelID, "ZAM_TESTSLIDER2", "Test slider 2", "Adjust the slider.", 50, 100, 10, function() return 80 end, function(value) end) -lam:AddDropdown(controlPanelID, "ZAM_TESTDROPDOWN2", "Test Dropdown 2", "Pick something!", {"thing 4", "thing 5", "thing 6"}, function() return "thing 6" end, function(self,valueString) print(valueString) end) +local MAJOR, MINOR = "LibAddonMenu-1.0", 6 +local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) +if not lam then return end --the same or newer version of this lib is already loaded into memory + +--UPVALUES-- +lam.lastAddedControl = {} +local lastAddedControl = lam.lastAddedControl +local wm = GetWindowManager() +local strformat = string.format +local tostring = tostring +local round = zo_round +local optionsWindow = ZO_OptionsWindowSettingsScrollChild + +--maybe return the controls from the creation functions? + +function lam:CreateControlPanel(controlPanelID, controlPanelName) + local panelID + + if _G[controlPanelID] then + panelID = _G[controlPanelID] + return panelID + end + + ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelName) + + --disables Defaults button because we don't need it, but keybind still works :/ ... + panelID = _G[controlPanelID] + ZO_PreHook("ZO_OptionsWindow_ChangePanels", function(panel) + local enable = (panel ~= panelID) + ZO_OptionsWindowResetToDefaultButton:SetEnabled(enable) + ZO_OptionsWindowResetToDefaultButton:SetKeybindEnabled(enable) + end) + + return panelID +end + +function lam:AddHeader(panelID, controlName, text) + local header = wm:CreateControlFromVirtual(controlName, optionsWindow, lastAddedControl[panelID] and "ZO_Options_SectionTitle_WithDivider" or "ZO_Options_SectionTitle") + if lastAddedControl[panelID] then + header:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 15) + else + header:SetAnchor(TOPLEFT) + end + header.controlType = OPTIONS_SECTION_TITLE + header.panel = panelID + header.text = text + + ZO_OptionsWindow_InitializeControl(header) + + lastAddedControl[panelID] = header + + return header +end + + +--To-Do list: +--extra sub-options window out to the right?? (or maybe addon list?) +--find alternatives to handler hooks + +function lam:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText) + local slider = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Slider") + slider:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) + slider.controlType = OPTIONS_SLIDER + slider.system = SETTING_TYPE_UI + slider.panel = panelID + slider.text = text + slider.tooltipText = tooltip + slider.showValue = true + slider.showValueMin = minValue + slider.showValueMax = maxValue + local range = maxValue - minValue + local slidercontrol = slider:GetNamedChild("Slider") + local slidervalue = slider:GetNamedChild("ValueLabel") + slidercontrol:SetValueStep(1/range * step) + slider:SetHandler("OnShow", function() + local curValue = getFunc() + slidercontrol:SetValue((curValue - minValue)/range) + slidervalue:SetText(tostring(curValue)) + end) + slidercontrol:SetHandler("OnValueChanged", function (self, value) + self:SetValue(value) + value = round(value*range + minValue) + slidervalue:SetText(strformat("%d", value)) + end) + slidercontrol:SetHandler("OnSliderReleased", function(self, value) + value = round(value*range + minValue) + setFunc(value) + end) + + if warning then + slider.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", slider, "ZO_Options_WarningIcon") + slider.warning:SetAnchor(RIGHT, slidercontrol, LEFT, -5, 0) + slider.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(slider) + + lastAddedControl[panelID] = slider + + return slider +end + +function lam:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText) + local dropdown = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Dropdown") + dropdown:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) + dropdown.controlType = OPTIONS_DROPDOWN + dropdown.system = SETTING_TYPE_UI + dropdown.panel = panelID + dropdown.text = text + dropdown.tooltipText = tooltip + dropdown.valid = validChoices + local dropmenu = ZO_ComboBox_ObjectFromContainer(GetControl(dropdown, "Dropdown")) + local setText = dropmenu.m_selectedItemText.SetText + local selectedName + ZO_PreHookHandler(dropmenu.m_selectedItemText, "OnTextChanged", function(self) + if dropmenu.m_selectedItemData then + selectedName = dropmenu.m_selectedItemData.name + setText(self, selectedName) + setFunc(selectedName) + end + end) + dropdown:SetHandler("OnShow", function() + dropmenu:SetSelectedItem(getFunc()) + end) + + if warning then + dropdown.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", dropdown, "ZO_Options_WarningIcon") + dropdown.warning:SetAnchor(RIGHT, dropdown:GetNamedChild("Dropdown"), LEFT, -5, 0) + dropdown.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(dropdown) + + lastAddedControl[panelID] = dropdown + + return dropdown +end + +function lam:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) + local checkbox = wm:CreateControlFromVirtual(controlName, optionsWindow, "ZO_Options_Checkbox") + checkbox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) + checkbox.controlType = OPTIONS_CHECKBOX + checkbox.system = SETTING_TYPE_UI + checkbox.settingId = _G[strformat("SETTING_%s", controlName)] + checkbox.panel = panelID + checkbox.text = text + checkbox.tooltipText = tooltip + + local checkboxButton = checkbox:GetNamedChild("Checkbox") + + ZO_PreHookHandler(checkbox, "OnShow", function() + checkboxButton:SetState(getFunc() and 1 or 0) + checkboxButton:toggleFunction(getFunc()) + end) + ZO_PreHookHandler(checkboxButton, "OnClicked", function() setFunc(not getFunc()) end) + + if warning then + checkbox.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", checkbox, "ZO_Options_WarningIcon") + checkbox.warning:SetAnchor(RIGHT, checkboxButton, LEFT, -5, 0) + checkbox.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(checkbox) + + lastAddedControl[panelID] = checkbox + + return checkbox +end + +function lam:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) + local colorpicker = wm:CreateTopLevelWindow(controlName) + colorpicker:SetParent(optionsWindow) + colorpicker:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) + colorpicker:SetResizeToFitDescendents(true) + colorpicker:SetWidth(510) + colorpicker:SetMouseEnabled(true) + + colorpicker.label = wm:CreateControl(controlName.."Label", colorpicker, CT_LABEL) + local label = colorpicker.label + label:SetDimensions(300, 26) + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(text) + + colorpicker.color = wm:CreateControl(controlName.."Color", colorpicker, CT_CONTROL) + local color = colorpicker.color + color:SetDimensions(200,26) + color:SetAnchor(RIGHT) + + color.thumb = wm:CreateControl(controlName.."ColorThumb", color, CT_TEXTURE) + local thumb = color.thumb + thumb:SetDimensions(36, 18) + thumb:SetAnchor(LEFT, color, LEFT, 4, 0) + local r, g, b, a = getFunc() + thumb:SetColor(r, g, b, a or 1) + + color.border = wm:CreateControl(controlName.."ColorBorder", color, CT_TEXTURE) + local border = color.border + border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") + border:SetTextureCoords(0, .625, 0, .8125) + border:SetDimensions(40, 22) + border:SetAnchor(CENTER, thumb, CENTER, 0, 0) + + local ColorPickerCallback + if not ColorPickerCallback then + ColorPickerCallback = function(r, g, b, a) + thumb:SetColor(r, g, b, a or 1) + setFunc(r, g, b, a) + end + end + + colorpicker.controlType = OPTIONS_CUSTOM + colorpicker.customSetupFunction = function(colorpicker) + colorpicker:SetHandler("OnMouseUp", function(self, btn, upInside) + if upInside then + local r, g, b, a = getFunc() + COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, text) + end + end) + end + colorpicker.panel = panelID + colorpicker.tooltipText = tooltip + colorpicker:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + colorpicker:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + if warning then + colorpicker.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", colorpicker, "ZO_Options_WarningIcon") + colorpicker.warning:SetAnchor(RIGHT, colorpicker:GetNamedChild("Color"), LEFT, -5, 0) + colorpicker.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(colorpicker) + + lastAddedControl[panelID] = colorpicker + + return colorpicker +end + +function lam:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText) + local editbox = wm:CreateTopLevelWindow(controlName) + editbox:SetParent(optionsWindow) + editbox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) + editbox:SetResizeToFitDescendents(true) + editbox:SetWidth(510) + editbox:SetMouseEnabled(true) + + editbox.label = wm:CreateControl(controlName.."Label", editbox, CT_LABEL) + local label = editbox.label + label:SetDimensions(300, 26) + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(text) + + editbox.bg = wm:CreateControlFromVirtual(controlName.."BG", editbox, "ZO_EditBackdrop") + local bg = editbox.bg + bg:SetDimensions(200,isMultiLine and 100 or 24) + bg:SetAnchor(RIGHT) + editbox.edit = wm:CreateControlFromVirtual(controlName.."Edit", bg, isMultiLine and "ZO_DefaultEditMultiLineForBackdrop" or "ZO_DefaultEditForBackdrop") + editbox.edit:SetText(getFunc()) + editbox.edit:SetHandler("OnFocusLost", function(self) setFunc(self:GetText()) end) + + + editbox.panel = panelID + editbox.tooltipText = tooltip + editbox:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + editbox:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + if warning then + editbox.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", editbox, "ZO_Options_WarningIcon") + editbox.warning:SetAnchor(TOPRIGHT, editbox:GetNamedChild("BG"), TOPLEFT, -5, 0) + editbox.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(editbox) + + lastAddedControl[panelID] = editbox + + return editbox +end + +function lam:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText) + local button = wm:CreateTopLevelWindow(controlName) + button:SetParent(optionsWindow) + button:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 6) + button:SetDimensions(510, 28) + button:SetMouseEnabled(true) + + button.btn = wm:CreateControlFromVirtual(controlName.."Button", button, "ZO_DefaultButton") + local btn = button.btn + btn:SetAnchor(TOPRIGHT) + btn:SetWidth(200) + btn:SetText(text) + btn:SetHandler("OnClicked", onClick) + + button.controlType = OPTIONS_CUSTOM + button.customSetupFunction = function() end --move handlers into this function? (since I created a function...) + button.panel = panelID + btn.tooltipText = tooltip + btn:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + btn:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + if warning then + button.warning = wm:CreateControlFromVirtual(controlName.."WarningIcon", button, "ZO_Options_WarningIcon") + button.warning:SetAnchor(RIGHT, btn, LEFT, -5, 0) + button.warning.tooltipText = warningText + end + + ZO_OptionsWindow_InitializeControl(button) + + lastAddedControl[panelID] = button + + return button +end + +function lam:AddDescription(panelID, controlName, text, titleText) + local textBox = wm:CreateTopLevelWindow(controlName) + textBox:SetParent(optionsWindow) + textBox:SetAnchor(TOPLEFT, lastAddedControl[panelID], BOTTOMLEFT, 0, 10) + textBox:SetResizeToFitDescendents(true) + textBox:SetWidth(510) + + if titleText then + textBox.title = wm:CreateControl(controlName.."Title", textBox, CT_LABEL) + local title = textBox.title + title:SetWidth(510) + title:SetAnchor(TOPLEFT, textBox, TOPLEFT) + title:SetFont("ZoFontWinH4") + title:SetText(titleText) + end + + textBox.desc = wm:CreateControl(controlName.."Text", textBox, CT_LABEL) + local desc = textBox.desc + desc:SetWidth(510) + if titleText then + desc:SetAnchor(TOPLEFT, textBox.title, BOTTOMLEFT) + else + desc:SetAnchor(TOPLEFT) + end + desc:SetVerticalAlignment(TEXT_ALIGN_TOP) + desc:SetFont("ZoFontGame") + desc:SetText(text) + + textBox.controlType = OPTIONS_CUSTOM + textBox.panel = panelID + + ZO_OptionsWindow_InitializeControl(textBox) + + lastAddedControl[panelID] = textBox + + return textBox +end + + +--test controls & examples-- +--[[local controlPanelID = lam:CreateControlPanel("ZAM_ADDON_OPTIONS", "ZAM Addons") +lam:AddHeader(controlPanelID, "ZAM_Addons_TESTADDON", "TEST ADDON") +lam:AddDescription(controlPanelID, "ZAM_Addons_TESTDESC", "This is a test description.", "Header") +lam:AddSlider(controlPanelID, "ZAM_TESTSLIDER", "Test slider", "Adjust the slider.", 1, 10, 1, function() return 7 end, function(value) end, true, "needs UI reload") +lam:AddDropdown(controlPanelID, "ZAM_TESTDROPDOWN", "Test Dropdown", "Pick something!", {"thing 1", "thing 2", "thing 3"}, function() return "thing 2" end, function(self,valueString) print(valueString) end) +local checkbox1 = true +lam:AddCheckbox(controlPanelID, "ZAM_TESTCHECKBOX", "Test Checkbox", "On or off?", function() return checkbox1 end, function(value) checkbox1 = not checkbox1 print(value, checkbox1) end) +lam:AddColorPicker(controlPanelID, "ZAM_TESTCOLORPICKER", "Test color picker", "What's your favorite color?", function() return 1, 1, 0 end, function(r,g,b) print(r,g,b) end) +lam:AddEditBox(controlPanelID, "ZAM_TESTEDITBOX", "Test Edit Box", "This is a tooltip!", false, function() return "hi" end, function(text) print(text) end) +lam:AddHeader(controlPanelID, "ZAM_Addons_TESTADDON2", "TEST ADDON 2") +local checkbox2 = false +lam:AddCheckbox(controlPanelID, "ZAM_TESTCHECKBOX2", "Test Checkbox 2", "On or off?", function() return checkbox2 end, function(value) checkbox2 = not checkbox2 print(value, checkbox2) end) +lam:AddButton(controlPanelID, "ZAM_TESTBUTTON", "Test Button", "Click me", function() print("hi") end, true, "oh noez!") +lam:AddEditBox(controlPanelID, "ZAM_TESTEDITBOX2", "Test Edit Box 2", "This is a tooltip!", true, function() return "hi" end, function(text) print(text) end, true, "warning text") +lam:AddSlider(controlPanelID, "ZAM_TESTSLIDER2", "Test slider 2", "Adjust the slider.", 50, 100, 10, function() return 80 end, function(value) end) +lam:AddDropdown(controlPanelID, "ZAM_TESTDROPDOWN2", "Test Dropdown 2", "Pick something!", {"thing 4", "thing 5", "thing 6"}, function() return "thing 6" end, function(self,valueString) print(valueString) end) ]]-- \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 03fb4c4..2e7aa91 100644 --- a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -1,384 +1,384 @@ --- LibAddonMenu-2.0 & its files © Ryan Lakanen (Seerah) -- --- Distributed under The Artistic License 2.0 (see LICENSE) -- ------------------------------------------------------------------- - - ---Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 17 -local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not lam then return end --the same or newer version of this lib is already loaded into memory - -local messages = {} -local MESSAGE_PREFIX = "[LAM2] " -local function PrintLater(msg) - if(CHAT_SYSTEM.primaryContainer) then - d(MESSAGE_PREFIX .. msg) - else - messages[#messages + 1] = msg - end -end - -local function FlushMessages() - for i = 1, #messages do - d(MESSAGE_PREFIX .. messages[i]) - end - messages = {} -end - -if(LAMSettingsPanelCreated and not LAMCompatibilityWarning) then - PrintLater("An old version of LibAddonMenu with compatibility issues was detected. For more information on how to proceed search for LibAddonMenu on esoui.com") - LAMCompatibilityWarning = true -end - ---UPVALUES-- -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert -local optionsWindow = ZO_OptionsWindowSettingsScrollChild -local _ - -local addonsForList = {} -local addonToOptionsMap = {} -local optionsCreated = {} -lam.widgets = lam.widgets or {} -local widgets = lam.widgets - - ---METHOD: REGISTER WIDGET-- ---each widget has its version checked before loading, ---so we only have the most recent one in memory ---Usage: --- widgetType = "string"; the type of widget being registered --- widgetVersion = integer; the widget's version number -LAMCreateControl = LAMCreateControl or {} -local lamcc = LAMCreateControl - -function lam:RegisterWidget(widgetType, widgetVersion) - if widgets[widgetType] and widgets[widgetType] >= widgetVersion then - return false - else - widgets[widgetType] = widgetVersion - return true - end -end - - ---METHOD: OPEN TO ADDON PANEL-- ---opens to a specific addon's option panel ---Usage: --- panel = userdata; the panel returned by the :RegisterOptionsPanel method -local locSettings = GetString(SI_GAME_MENU_SETTINGS) -function lam:OpenToPanel(panel) - SCENE_MANAGER:Show("gameMenuInGame") - zo_callLater(function() - local settingsMenu = ZO_GameMenu_InGame.gameMenu.headerControls[locSettings] - settingsMenu:SetOpen(true) - SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) - KEYBOARD_OPTIONS:ChangePanels(lam.panelID) - for i, child in pairs(settingsMenu.children) do - if type(child) == "table" and child.data.name == KEYBOARD_OPTIONS.panelNames[lam.panelID] then - ZO_TreeEntry_OnMouseUp(child.control, true) - break - end - end - local scroll = LAMAddonPanelsMenuScrollChild - for i = 1, scroll:GetNumChildren() do - local button = scroll:GetChild(i) - if button.panel == panel then - zo_callHandler(button, "OnClicked") - ZO_Scroll_ScrollControlToTop(LAMAddonPanelsMenu, button) - break - end - end - end, 200) -end - - ---INTERNAL FUNCTION ---creates controls when options panel is first shown ---controls anchoring of these controls in the panel -local function CreateOptionsControls(panel) - local addonID = panel:GetName() - local optionsTable = addonToOptionsMap[addonID] - - if optionsTable then - local isHalf, widget - local lastAddedControl, lacAtHalfRow, oIndex, widgetData, widgetType - local submenu, subWidgetData, sIndex, subWidgetType, subWidget - local anchorOffset = 0 - local anchorOffsetSub - local lastAddedControlSub, lacAtHalfRowSub - for oIndex=1,#optionsTable do - widgetData = optionsTable[oIndex] - widgetType = widgetData.type - if widgetType == "submenu" then - submenu = LAMCreateControl[widgetType](panel, widgetData) - if lastAddedControl then - submenu:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) - else - submenu:SetAnchor(TOPLEFT) - end - lastAddedControl = submenu - lacAtHalfRow = false - - anchorOffsetSub = 0 - lacAtHalfRowSub = nil - lastAddedControlSub = nil - for sIndex=1,#widgetData.controls do - subWidgetData = widgetData.controls[sIndex] - subWidgetType = subWidgetData.type - subWidget = LAMCreateControl[subWidgetType](submenu, subWidgetData) - isHalf = subWidgetData.width == "half" - if lastAddedControlSub then - if lacAtHalfRowSub and isHalf then - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, TOPRIGHT, 5, 0) - lacAtHalfRowSub = false - anchorOffsetSub = zo_max(0, subWidget:GetHeight() - lastAddedControlSub:GetHeight()) - else - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, BOTTOMLEFT, 0, 15 + anchorOffsetSub) - lacAtHalfRowSub = isHalf - anchorOffsetSub = 0 - lastAddedControlSub = subWidget - end - else - subWidget:SetAnchor(TOPLEFT) - lacAtHalfRowSub = isHalf - lastAddedControlSub = subWidget - end - end - else - widget = LAMCreateControl[widgetType](panel, widgetData) - isHalf = widgetData.width == "half" - if lastAddedControl then - if lacAtHalfRow and isHalf then - widget:SetAnchor(TOPLEFT, lastAddedControl, TOPRIGHT, 10, 0) - anchorOffset = zo_max(0, widget:GetHeight() - lastAddedControl:GetHeight()) - lacAtHalfRow = false - else - widget:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) - lacAtHalfRow = isHalf - anchorOffset = 0 - lastAddedControl = widget - end - else - widget:SetAnchor(TOPLEFT) - lacAtHalfRow = isHalf - lastAddedControl = widget - end - end - end - end - - optionsCreated[addonID] = true - cm:FireCallbacks("LAM-PanelControlsCreated", panel) -end - - ---INTERNAL FUNCTION ---handles switching between panels -local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel - local currentlySelected = LAMAddonPanelsMenu.currentlySelected - if currentlySelected and currentlySelected ~= panel then - currentlySelected:SetHidden(true) - end - LAMAddonPanelsMenu.currentlySelected = panel - - if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options - CreateOptionsControls(panel) - end - - cm:FireCallbacks("LAM-RefreshPanel", panel) -end - -local Initialize -local hasInitialized = false - ---METHOD: REGISTER ADDON PANEL ---registers your addon with LibAddonMenu and creates a panel ---Usage: --- addonID = "string"; unique ID which will be the global name of your panel --- panelData = table; data object for your panel - see controls\panel.lua -function lam:RegisterAddonPanel(addonID, panelData) - if(not hasInitialized) then Initialize(addonID) end - local panel = lamcc.panel(nil, panelData, addonID) --addonID==global name of panel - panel:SetHidden(true) - panel:SetAnchor(TOPLEFT, LAMAddonPanelsMenu, TOPRIGHT, 10, 0) - panel:SetAnchor(BOTTOMLEFT, LAMAddonPanelsMenu, BOTTOMRIGHT, 10, 0) - panel:SetWidth(549) - panel:SetDrawLayer(DL_OVERLAY) - tinsert(addonsForList, {panel = addonID, name = panelData.name}) - panel:SetHandler("OnShow", ToggleAddonPanels) - if panelData.slashCommand then - SLASH_COMMANDS[panelData.slashCommand] = function() - lam:OpenToPanel(panel) - end - end - - return panel --return for authors creating options manually -end - - ---METHOD: REGISTER OPTION CONTROLS ---registers the options you want shown for your addon ---these are stored in a table where each key-value pair is the order ---of the options in the panel and the data for that control, respectively ---see exampleoptions.lua for an example ---see controls\.lua for each widget type ---Usage: --- addonID = "string"; the same string passed to :RegisterAddonPanel --- optionsTable = table; the table containing all of the options controls and their data -function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sliderData, buttonData, etc} - addonToOptionsMap[addonID] = optionsTable -end - - ---INTERNAL FUNCTION ---handles switching between LAM's Addon Settings panel and other panels in the Settings menu -local oldDefaultButton = ZO_OptionsWindowResetToDefaultButton -local oldCallback = oldDefaultButton.callback -local dummyFunc = function() end -local panelWindow = ZO_OptionsWindow -local bgL = ZO_OptionsWindowBGLeft -local bgR = ZO_OptionsWindowBGLeftBGRight -local function HandlePanelSwitching(self, panel) - if panel == lam.panelID then --our addon settings panel - oldDefaultButton:SetCallback(dummyFunc) - oldDefaultButton:SetHidden(true) - oldDefaultButton:SetAlpha(0) --just because it still bugs out - panelWindow:SetDimensions(999, 960) - bgL:SetWidth(666) - bgR:SetWidth(333) - else - local shown = LAMAddonPanelsMenu.currentlySelected - if shown then shown:SetHidden(true) end - oldDefaultButton:SetCallback(oldCallback) - oldDefaultButton:SetHidden(false) - oldDefaultButton:SetAlpha(1) - panelWindow:SetDimensions(768, 914) - bgL:SetWidth(512) - bgR:SetWidth(256) - end -end - - ---INTERNAL FUNCTION ---creates LAM's Addon Settings panel -local function CreateAddonSettingsPanel() - if not LAMSettingsPanelCreated then - local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" - --Russian for TERAB1T's RuESO addon, which creates an "ru" locale - --game font does not support Cyrillic, so they are using custom fonts + extended latin charset - --Spanish provided by Luisen75 for their translation project - local controlPanelNames = { - en = "Addon Settings", - fr = "Extensions", - de = "Erweiterungen", - ru = "Îacòpoéêè äoïoìîeîèé", - es = "Configura Addons", - } - - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelNames["en"], PANEL_TYPE_SETTINGS) - - lam.panelID = _G[controlPanelID] - - ZO_PreHook(ZO_KeyboardOptions, "ChangePanels", HandlePanelSwitching) - - LAMSettingsPanelCreated = true - end -end - - ---INTERNAL FUNCTION ---adds each registered addon to the menu in LAM's panel -local function CreateAddonButtons(list, addons) - for i = 1, #addons do - local button = wm:CreateControlFromVirtual("LAMAddonMenuButton"..i, list.scrollChild, "ZO_DefaultTextButton") - button.name = addons[i].name - button.panel = _G[addons[i].panel] - button:SetText(button.name) - button:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - button:SetWidth(190) - if i == 1 then - button:SetAnchor(TOPLEFT, list.scrollChild, TOPLEFT, 5, 5) - else - button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton"..i-1], BOTTOMLEFT) - end - button:SetHandler("OnClicked", function(self) self.panel:SetHidden(false) end) - end -end - - ---INTERNAL FUNCTION ---creates the left-hand menu in LAM's panel -local function CreateAddonList() - local list - --check if an earlier loaded copy of LAM created it already - list = LAMAddonPanelsMenu or wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") - list:ClearAnchors() - list:SetAnchor(TOPLEFT) - list:SetHeight(675) - list:SetWidth(200) - - list.bg = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) - local bg = list.bg - bg:SetAnchorFill() --offsets of 8? - bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) - bg:SetCenterColor(0, 0, 0, 0) - - list.scrollChild = LAMAddonPanelsMenuScrollChild - list.scrollChild:SetResizeToFitPadding(0, 15) - - local generatedButtons - list:SetHandler("OnShow", function(self) - if not generatedButtons and #addonsForList > 0 then - --we're about to show our list for the first time - let's sort the buttons before creating them - table.sort(addonsForList, function(a, b) - return a.name < b.name - end) - CreateAddonButtons(list, addonsForList) - self.currentlySelected = LAMAddonMenuButton1 and LAMAddonMenuButton1.panel - --since our addon panels don't have a parent, let's make sure they hide when we're done with them - ZO_PreHookHandler(ZO_OptionsWindow, "OnHide", function() self.currentlySelected:SetHidden(true) end) - generatedButtons = true - end - if self.currentlySelected then self.currentlySelected:SetHidden(false) end - end) - - --list.controlType = OPTIONS_CUSTOM - --list.panel = lam.panelID - list.data = { - controlType = OPTIONS_CUSTOM, - panel = lam.panelID, - } - - ZO_OptionsWindow_InitializeControl(list) - - return list -end - ---INITIALIZING -local safeToInitialize = false - -local eventHandle = table.concat({MAJOR, MINOR}, "r") -local function OnLoad(_, addonName) - -- wait for the first loaded event - EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_ADD_ON_LOADED) - safeToInitialize = true -end -EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_ADD_ON_LOADED, OnLoad) - -local function OnActivated(_, addonName) - EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED) - FlushMessages() -end -EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED, OnActivated) - -function Initialize(addonID) - if(not safeToInitialize) then - local msg = string.format("The panel with id '%s' was registered before addon loading has completed. This might break the AddOn Settings menu.", addonID) - PrintLater(msg) - end - CreateAddonSettingsPanel() - CreateAddonList() - hasInitialized = true -end +-- LibAddonMenu-2.0 & its files © Ryan Lakanen (Seerah) -- +-- Distributed under The Artistic License 2.0 (see LICENSE) -- +------------------------------------------------------------------ + + +--Register LAM with LibStub +local MAJOR, MINOR = "LibAddonMenu-2.0", 17 +local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) +if not lam then return end --the same or newer version of this lib is already loaded into memory + +local messages = {} +local MESSAGE_PREFIX = "[LAM2] " +local function PrintLater(msg) + if(CHAT_SYSTEM.primaryContainer) then + d(MESSAGE_PREFIX .. msg) + else + messages[#messages + 1] = msg + end +end + +local function FlushMessages() + for i = 1, #messages do + d(MESSAGE_PREFIX .. messages[i]) + end + messages = {} +end + +if(LAMSettingsPanelCreated and not LAMCompatibilityWarning) then + PrintLater("An old version of LibAddonMenu with compatibility issues was detected. For more information on how to proceed search for LibAddonMenu on esoui.com") + LAMCompatibilityWarning = true +end + +--UPVALUES-- +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert +local optionsWindow = ZO_OptionsWindowSettingsScrollChild +local _ + +local addonsForList = {} +local addonToOptionsMap = {} +local optionsCreated = {} +lam.widgets = lam.widgets or {} +local widgets = lam.widgets + + +--METHOD: REGISTER WIDGET-- +--each widget has its version checked before loading, +--so we only have the most recent one in memory +--Usage: +-- widgetType = "string"; the type of widget being registered +-- widgetVersion = integer; the widget's version number +LAMCreateControl = LAMCreateControl or {} +local lamcc = LAMCreateControl + +function lam:RegisterWidget(widgetType, widgetVersion) + if widgets[widgetType] and widgets[widgetType] >= widgetVersion then + return false + else + widgets[widgetType] = widgetVersion + return true + end +end + + +--METHOD: OPEN TO ADDON PANEL-- +--opens to a specific addon's option panel +--Usage: +-- panel = userdata; the panel returned by the :RegisterOptionsPanel method +local locSettings = GetString(SI_GAME_MENU_SETTINGS) +function lam:OpenToPanel(panel) + SCENE_MANAGER:Show("gameMenuInGame") + zo_callLater(function() + local settingsMenu = ZO_GameMenu_InGame.gameMenu.headerControls[locSettings] + settingsMenu:SetOpen(true) + SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) + KEYBOARD_OPTIONS:ChangePanels(lam.panelID) + for i, child in pairs(settingsMenu.children) do + if type(child) == "table" and child.data.name == KEYBOARD_OPTIONS.panelNames[lam.panelID] then + ZO_TreeEntry_OnMouseUp(child.control, true) + break + end + end + local scroll = LAMAddonPanelsMenuScrollChild + for i = 1, scroll:GetNumChildren() do + local button = scroll:GetChild(i) + if button.panel == panel then + zo_callHandler(button, "OnClicked") + ZO_Scroll_ScrollControlToTop(LAMAddonPanelsMenu, button) + break + end + end + end, 200) +end + + +--INTERNAL FUNCTION +--creates controls when options panel is first shown +--controls anchoring of these controls in the panel +local function CreateOptionsControls(panel) + local addonID = panel:GetName() + local optionsTable = addonToOptionsMap[addonID] + + if optionsTable then + local isHalf, widget + local lastAddedControl, lacAtHalfRow, oIndex, widgetData, widgetType + local submenu, subWidgetData, sIndex, subWidgetType, subWidget + local anchorOffset = 0 + local anchorOffsetSub + local lastAddedControlSub, lacAtHalfRowSub + for oIndex=1,#optionsTable do + widgetData = optionsTable[oIndex] + widgetType = widgetData.type + if widgetType == "submenu" then + submenu = LAMCreateControl[widgetType](panel, widgetData) + if lastAddedControl then + submenu:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) + else + submenu:SetAnchor(TOPLEFT) + end + lastAddedControl = submenu + lacAtHalfRow = false + + anchorOffsetSub = 0 + lacAtHalfRowSub = nil + lastAddedControlSub = nil + for sIndex=1,#widgetData.controls do + subWidgetData = widgetData.controls[sIndex] + subWidgetType = subWidgetData.type + subWidget = LAMCreateControl[subWidgetType](submenu, subWidgetData) + isHalf = subWidgetData.width == "half" + if lastAddedControlSub then + if lacAtHalfRowSub and isHalf then + subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, TOPRIGHT, 5, 0) + lacAtHalfRowSub = false + anchorOffsetSub = zo_max(0, subWidget:GetHeight() - lastAddedControlSub:GetHeight()) + else + subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, BOTTOMLEFT, 0, 15 + anchorOffsetSub) + lacAtHalfRowSub = isHalf + anchorOffsetSub = 0 + lastAddedControlSub = subWidget + end + else + subWidget:SetAnchor(TOPLEFT) + lacAtHalfRowSub = isHalf + lastAddedControlSub = subWidget + end + end + else + widget = LAMCreateControl[widgetType](panel, widgetData) + isHalf = widgetData.width == "half" + if lastAddedControl then + if lacAtHalfRow and isHalf then + widget:SetAnchor(TOPLEFT, lastAddedControl, TOPRIGHT, 10, 0) + anchorOffset = zo_max(0, widget:GetHeight() - lastAddedControl:GetHeight()) + lacAtHalfRow = false + else + widget:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) + lacAtHalfRow = isHalf + anchorOffset = 0 + lastAddedControl = widget + end + else + widget:SetAnchor(TOPLEFT) + lacAtHalfRow = isHalf + lastAddedControl = widget + end + end + end + end + + optionsCreated[addonID] = true + cm:FireCallbacks("LAM-PanelControlsCreated", panel) +end + + +--INTERNAL FUNCTION +--handles switching between panels +local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel + local currentlySelected = LAMAddonPanelsMenu.currentlySelected + if currentlySelected and currentlySelected ~= panel then + currentlySelected:SetHidden(true) + end + LAMAddonPanelsMenu.currentlySelected = panel + + if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options + CreateOptionsControls(panel) + end + + cm:FireCallbacks("LAM-RefreshPanel", panel) +end + +local Initialize +local hasInitialized = false + +--METHOD: REGISTER ADDON PANEL +--registers your addon with LibAddonMenu and creates a panel +--Usage: +-- addonID = "string"; unique ID which will be the global name of your panel +-- panelData = table; data object for your panel - see controls\panel.lua +function lam:RegisterAddonPanel(addonID, panelData) + if(not hasInitialized) then Initialize(addonID) end + local panel = lamcc.panel(nil, panelData, addonID) --addonID==global name of panel + panel:SetHidden(true) + panel:SetAnchor(TOPLEFT, LAMAddonPanelsMenu, TOPRIGHT, 10, 0) + panel:SetAnchor(BOTTOMLEFT, LAMAddonPanelsMenu, BOTTOMRIGHT, 10, 0) + panel:SetWidth(549) + panel:SetDrawLayer(DL_OVERLAY) + tinsert(addonsForList, {panel = addonID, name = panelData.name}) + panel:SetHandler("OnShow", ToggleAddonPanels) + if panelData.slashCommand then + SLASH_COMMANDS[panelData.slashCommand] = function() + lam:OpenToPanel(panel) + end + end + + return panel --return for authors creating options manually +end + + +--METHOD: REGISTER OPTION CONTROLS +--registers the options you want shown for your addon +--these are stored in a table where each key-value pair is the order +--of the options in the panel and the data for that control, respectively +--see exampleoptions.lua for an example +--see controls\.lua for each widget type +--Usage: +-- addonID = "string"; the same string passed to :RegisterAddonPanel +-- optionsTable = table; the table containing all of the options controls and their data +function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sliderData, buttonData, etc} + addonToOptionsMap[addonID] = optionsTable +end + + +--INTERNAL FUNCTION +--handles switching between LAM's Addon Settings panel and other panels in the Settings menu +local oldDefaultButton = ZO_OptionsWindowResetToDefaultButton +local oldCallback = oldDefaultButton.callback +local dummyFunc = function() end +local panelWindow = ZO_OptionsWindow +local bgL = ZO_OptionsWindowBGLeft +local bgR = ZO_OptionsWindowBGLeftBGRight +local function HandlePanelSwitching(self, panel) + if panel == lam.panelID then --our addon settings panel + oldDefaultButton:SetCallback(dummyFunc) + oldDefaultButton:SetHidden(true) + oldDefaultButton:SetAlpha(0) --just because it still bugs out + panelWindow:SetDimensions(999, 960) + bgL:SetWidth(666) + bgR:SetWidth(333) + else + local shown = LAMAddonPanelsMenu.currentlySelected + if shown then shown:SetHidden(true) end + oldDefaultButton:SetCallback(oldCallback) + oldDefaultButton:SetHidden(false) + oldDefaultButton:SetAlpha(1) + panelWindow:SetDimensions(768, 914) + bgL:SetWidth(512) + bgR:SetWidth(256) + end +end + + +--INTERNAL FUNCTION +--creates LAM's Addon Settings panel +local function CreateAddonSettingsPanel() + if not LAMSettingsPanelCreated then + local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" + --Russian for TERAB1T's RuESO addon, which creates an "ru" locale + --game font does not support Cyrillic, so they are using custom fonts + extended latin charset + --Spanish provided by Luisen75 for their translation project + local controlPanelNames = { + en = "Addon Settings", + fr = "Extensions", + de = "Erweiterungen", + ru = "Îacòpoéêè äoïoìîeîèé", + es = "Configura Addons", + } + + ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelNames["en"], PANEL_TYPE_SETTINGS) + + lam.panelID = _G[controlPanelID] + + ZO_PreHook(ZO_KeyboardOptions, "ChangePanels", HandlePanelSwitching) + + LAMSettingsPanelCreated = true + end +end + + +--INTERNAL FUNCTION +--adds each registered addon to the menu in LAM's panel +local function CreateAddonButtons(list, addons) + for i = 1, #addons do + local button = wm:CreateControlFromVirtual("LAMAddonMenuButton"..i, list.scrollChild, "ZO_DefaultTextButton") + button.name = addons[i].name + button.panel = _G[addons[i].panel] + button:SetText(button.name) + button:SetHorizontalAlignment(TEXT_ALIGN_LEFT) + button:SetWidth(190) + if i == 1 then + button:SetAnchor(TOPLEFT, list.scrollChild, TOPLEFT, 5, 5) + else + button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton"..i-1], BOTTOMLEFT) + end + button:SetHandler("OnClicked", function(self) self.panel:SetHidden(false) end) + end +end + + +--INTERNAL FUNCTION +--creates the left-hand menu in LAM's panel +local function CreateAddonList() + local list + --check if an earlier loaded copy of LAM created it already + list = LAMAddonPanelsMenu or wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") + list:ClearAnchors() + list:SetAnchor(TOPLEFT) + list:SetHeight(675) + list:SetWidth(200) + + list.bg = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) + local bg = list.bg + bg:SetAnchorFill() --offsets of 8? + bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) + bg:SetCenterColor(0, 0, 0, 0) + + list.scrollChild = LAMAddonPanelsMenuScrollChild + list.scrollChild:SetResizeToFitPadding(0, 15) + + local generatedButtons + list:SetHandler("OnShow", function(self) + if not generatedButtons and #addonsForList > 0 then + --we're about to show our list for the first time - let's sort the buttons before creating them + table.sort(addonsForList, function(a, b) + return a.name < b.name + end) + CreateAddonButtons(list, addonsForList) + self.currentlySelected = LAMAddonMenuButton1 and LAMAddonMenuButton1.panel + --since our addon panels don't have a parent, let's make sure they hide when we're done with them + ZO_PreHookHandler(ZO_OptionsWindow, "OnHide", function() self.currentlySelected:SetHidden(true) end) + generatedButtons = true + end + if self.currentlySelected then self.currentlySelected:SetHidden(false) end + end) + + --list.controlType = OPTIONS_CUSTOM + --list.panel = lam.panelID + list.data = { + controlType = OPTIONS_CUSTOM, + panel = lam.panelID, + } + + ZO_OptionsWindow_InitializeControl(list) + + return list +end + +--INITIALIZING +local safeToInitialize = false + +local eventHandle = table.concat({MAJOR, MINOR}, "r") +local function OnLoad(_, addonName) + -- wait for the first loaded event + EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_ADD_ON_LOADED) + safeToInitialize = true +end +EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_ADD_ON_LOADED, OnLoad) + +local function OnActivated(_, addonName) + EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED) + FlushMessages() +end +EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED, OnActivated) + +function Initialize(addonID) + if(not safeToInitialize) then + local msg = string.format("The panel with id '%s' was registered before addon loading has completed. This might break the AddOn Settings menu.", addonID) + PrintLater(msg) + end + CreateAddonSettingsPanel() + CreateAddonList() + hasInitialized = true +end diff --git a/libs/LibAddonMenu-2.0/controls/button.lua b/libs/LibAddonMenu-2.0/controls/button.lua index 8a6ecda..49d0059 100644 --- a/libs/LibAddonMenu-2.0/controls/button.lua +++ b/libs/LibAddonMenu-2.0/controls/button.lua @@ -1,88 +1,88 @@ ---[[buttonData = { - type = "button", - name = "My Button", - tooltip = "Button's tooltip text.", - func = function() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - icon = "icon\\path.dds", --(optional) - warning = "Will need to reload the UI.", --(optional) - reference = "MyAddonButton" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 6 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("button", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.button:SetEnabled(not disable) -end - - ---controlName is optional -function LAMCreateControl.button(parent, buttonData, controlName) - local control = wm:CreateControl(controlName or buttonData.reference, parent.scroll or parent, CT_CONTROL) - - local isHalfWidth = buttonData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) - control:SetMouseEnabled(true) - - if buttonData.icon then - control.button = wm:CreateControl(nil, control, CT_BUTTON) - control.button:SetDimensions(26, 26) - control.button:SetNormalTexture(buttonData.icon) - control.button:SetPressedOffset(2, 2) - else - --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") - control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") - control.button:SetWidth(isHalfWidth and 180 or 200) - control.button:SetText(buttonData.name) - end - local button = control.button - button:SetAnchor(isHalfWidth and CENTER or RIGHT) - button:SetClickSound("Click") - --button.tooltipText = buttonData.tooltip - button.data = {tooltipText = buttonData.tooltip} - button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - button:SetHandler("OnClicked", function(self, ...) - buttonData.func(self, ...) - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - end) - - if buttonData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) - --control.warning.tooltipText = buttonData.warning - control.warning.data = {tooltipText = buttonData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = buttonData - - if buttonData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - - --this is here because buttons don't have an UpdateValue method - if control.panel.data.registerForRefresh then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - end - - return control +--[[buttonData = { + type = "button", + name = "My Button", + tooltip = "Button's tooltip text.", + func = function() end, + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + icon = "icon\\path.dds", --(optional) + warning = "Will need to reload the UI.", --(optional) + reference = "MyAddonButton" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 6 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("button", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.button:SetEnabled(not disable) +end + + +--controlName is optional +function LAMCreateControl.button(parent, buttonData, controlName) + local control = wm:CreateControl(controlName or buttonData.reference, parent.scroll or parent, CT_CONTROL) + + local isHalfWidth = buttonData.width == "half" + control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) + control:SetMouseEnabled(true) + + if buttonData.icon then + control.button = wm:CreateControl(nil, control, CT_BUTTON) + control.button:SetDimensions(26, 26) + control.button:SetNormalTexture(buttonData.icon) + control.button:SetPressedOffset(2, 2) + else + --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") + control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") + control.button:SetWidth(isHalfWidth and 180 or 200) + control.button:SetText(buttonData.name) + end + local button = control.button + button:SetAnchor(isHalfWidth and CENTER or RIGHT) + button:SetClickSound("Click") + --button.tooltipText = buttonData.tooltip + button.data = {tooltipText = buttonData.tooltip} + button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + button:SetHandler("OnClicked", function(self, ...) + buttonData.func(self, ...) + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + end) + + if buttonData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) + --control.warning.tooltipText = buttonData.warning + control.warning.data = {tooltipText = buttonData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = buttonData + + if buttonData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + + --this is here because buttons don't have an UpdateValue method + if control.panel.data.registerForRefresh then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/checkbox.lua b/libs/LibAddonMenu-2.0/controls/checkbox.lua index ef8bf09..a5142a9 100644 --- a/libs/LibAddonMenu-2.0/controls/checkbox.lua +++ b/libs/LibAddonMenu-2.0/controls/checkbox.lua @@ -1,171 +1,171 @@ ---[[checkboxData = { - type = "checkbox", - name = "My Checkbox", - tooltip = "Checkbox's tooltip text.", - getFunc = function() return db.var end, - setFunc = function(value) db.var = value doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonCheckbox" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 8 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("checkbox", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert ---label -local enabledColor = ZO_DEFAULT_ENABLED_COLOR -local enabledHLcolor = ZO_HIGHLIGHT_TEXT -local disabledColor = ZO_DEFAULT_DISABLED_COLOR -local disabledHLcolor = ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR ---checkbox -local checkboxColor = ZO_NORMAL_TEXT -local checkboxHLcolor = ZO_HIGHLIGHT_TEXT - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.label:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or control.value and ZO_DEFAULT_ENABLED_COLOR or ZO_DEFAULT_DISABLED_COLOR):UnpackRGBA()) - control.checkbox:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or ZO_NORMAL_TEXT):UnpackRGBA()) - --control:SetMouseEnabled(not disable) - --control:SetMouseEnabled(true) - - control.isDisabled = disable -end - -local function ToggleCheckbox(control) - if control.value then - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.checkedText) - else - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.uncheckedText) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value ~= nil then --our value could be false - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - control.value = value - - ToggleCheckbox(control) -end - -local function OnMouseEnter(control) - ZO_Options_OnMouseEnter(control) - - if control.isDisabled then return end - - local label = control.label - if control.value then - label:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) -end - -local function OnMouseExit(control) - ZO_Options_OnMouseExit(control) - - if control.isDisabled then return end - - local label = control.label - if control.value then - label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) -end - - ---controlName is optional -function LAMCreateControl.checkbox(parent, checkboxData, controlName) - local control = wm:CreateControl(controlName or checkboxData.reference, parent.scroll or parent, CT_CONTROL) - control:SetMouseEnabled(true) - --control.tooltipText = checkboxData.tooltip - control:SetHandler("OnMouseEnter", OnMouseEnter) - control:SetHandler("OnMouseExit", OnMouseExit) - control:SetHandler("OnMouseUp", function(control) - if control.isDisabled then return end - PlaySound(SOUNDS.DEFAULT_CLICK) - control.value = not control.value - control:UpdateValue(false, control.value) - end) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetText(checkboxData.name) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetHeight(26) - - control.checkbox = wm:CreateControl(nil, control, CT_LABEL) - local checkbox = control.checkbox - checkbox:SetFont("ZoFontGameBold") - checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) - control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() - control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() - - local isHalfWidth = checkboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - checkbox:SetDimensions(100, 26) - checkbox:SetAnchor(BOTTOMRIGHT) - label:SetAnchor(TOPLEFT) - label:SetAnchor(TOPRIGHT) - else - control:SetDimensions(510, 30) - checkbox:SetDimensions(200, 26) - checkbox:SetAnchor(RIGHT) - label:SetAnchor(LEFT) - label:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - end - - if checkboxData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - --control.warning.tooltipText = checkboxData.warning - control.warning.data = {tooltipText = checkboxData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = checkboxData - control.data.tooltipText = checkboxData.tooltip - - if checkboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[checkboxData = { + type = "checkbox", + name = "My Checkbox", + tooltip = "Checkbox's tooltip text.", + getFunc = function() return db.var end, + setFunc = function(value) db.var = value doStuff() end, + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + warning = "Will need to reload the UI.", --(optional) + default = defaults.var, --(optional) + reference = "MyAddonCheckbox" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 8 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("checkbox", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert +--label +local enabledColor = ZO_DEFAULT_ENABLED_COLOR +local enabledHLcolor = ZO_HIGHLIGHT_TEXT +local disabledColor = ZO_DEFAULT_DISABLED_COLOR +local disabledHLcolor = ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR +--checkbox +local checkboxColor = ZO_NORMAL_TEXT +local checkboxHLcolor = ZO_HIGHLIGHT_TEXT + + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.label:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or control.value and ZO_DEFAULT_ENABLED_COLOR or ZO_DEFAULT_DISABLED_COLOR):UnpackRGBA()) + control.checkbox:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or ZO_NORMAL_TEXT):UnpackRGBA()) + --control:SetMouseEnabled(not disable) + --control:SetMouseEnabled(true) + + control.isDisabled = disable +end + +local function ToggleCheckbox(control) + if control.value then + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.checkbox:SetText(control.checkedText) + else + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.checkbox:SetText(control.uncheckedText) + end +end + +local function UpdateValue(control, forceDefault, value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + elseif value ~= nil then --our value could be false + control.data.setFunc(value) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + end + control.value = value + + ToggleCheckbox(control) +end + +local function OnMouseEnter(control) + ZO_Options_OnMouseEnter(control) + + if control.isDisabled then return end + + local label = control.label + if control.value then + label:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) + else + label:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + end + control.checkbox:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) +end + +local function OnMouseExit(control) + ZO_Options_OnMouseExit(control) + + if control.isDisabled then return end + + local label = control.label + if control.value then + label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + else + label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + end + control.checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) +end + + +--controlName is optional +function LAMCreateControl.checkbox(parent, checkboxData, controlName) + local control = wm:CreateControl(controlName or checkboxData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + --control.tooltipText = checkboxData.tooltip + control:SetHandler("OnMouseEnter", OnMouseEnter) + control:SetHandler("OnMouseExit", OnMouseExit) + control:SetHandler("OnMouseUp", function(control) + if control.isDisabled then return end + PlaySound(SOUNDS.DEFAULT_CLICK) + control.value = not control.value + control:UpdateValue(false, control.value) + end) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetFont("ZoFontWinH4") + label:SetText(checkboxData.name) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetHeight(26) + + control.checkbox = wm:CreateControl(nil, control, CT_LABEL) + local checkbox = control.checkbox + checkbox:SetFont("ZoFontGameBold") + checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) + control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() + control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() + + local isHalfWidth = checkboxData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + checkbox:SetDimensions(100, 26) + checkbox:SetAnchor(BOTTOMRIGHT) + label:SetAnchor(TOPLEFT) + label:SetAnchor(TOPRIGHT) + else + control:SetDimensions(510, 30) + checkbox:SetDimensions(200, 26) + checkbox:SetAnchor(RIGHT) + label:SetAnchor(LEFT) + label:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) + end + + if checkboxData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) + --control.warning.tooltipText = checkboxData.warning + control.warning.data = {tooltipText = checkboxData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = checkboxData + control.data.tooltipText = checkboxData.tooltip + + if checkboxData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control:UpdateValue() + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/colorpicker.lua b/libs/LibAddonMenu-2.0/controls/colorpicker.lua index c5724b0..e820539 100644 --- a/libs/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/libs/LibAddonMenu-2.0/controls/colorpicker.lua @@ -1,138 +1,138 @@ ---[[colorpickerData = { - type = "colorpicker", - name = "My Color Picker", - tooltip = "Color Picker's tooltip text.", - getFunc = function() return db.r, db.g, db.b, db.a end, --(alpha is optional) - setFunc = function(r,g,b,a) db.r=r, db.g=g, db.b=b, db.a=a end, --(alpha is optional) - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = {r = defaults.r, g = defaults.g, b = defaults.b, a = defaults.a}, --(optional) table of default color values (or default = defaultColor, where defaultColor is a table with keys of r, g, b[, a]) - reference = "MyAddonColorpicker" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 6 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - - control.isDisabled = disable -end - -local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) - if forceDefault then --if we are forcing defaults - local color = control.data.default - valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a - control.data.setFunc(valueR, valueG, valueB, valueA) - elseif valueR and valueG and valueB then - control.data.setFunc(valueR, valueG, valueB, valueA or 1) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - valueR, valueG, valueB, valueA = control.data.getFunc() - end - - control.thumb:SetColor(valueR, valueG, valueB, valueA or 1) -end - - -function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) - local control = wm:CreateControl(controlName or colorpickerData.reference, parent.scroll or parent, CT_CONTROL) - control:SetMouseEnabled(true) - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetDimensions(300, 26) - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(colorpickerData.name) - - control.color = wm:CreateControl(nil, control, CT_CONTROL) - local color = control.color - - local isHalfWidth = colorpickerData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - color:SetDimensions(100, 24) - color:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - color:SetDimensions(200, 24) - color:SetAnchor(TOPRIGHT) - end - - control.thumb = wm:CreateControl(nil, color, CT_TEXTURE) - local thumb = control.thumb - thumb:SetDimensions(36, 18) - thumb:SetAnchor(LEFT, color, LEFT, 4, 0) - - color.border = wm:CreateControl(nil, color, CT_TEXTURE) - local border = color.border - border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") - border:SetTextureCoords(0, .625, 0, .8125) - border:SetDimensions(40, 22) - border:SetAnchor(CENTER, thumb, CENTER, 0, 0) - - local function ColorPickerCallback(r, g, b, a) - control:UpdateValue(false, r, g, b, a) - end - - control:SetHandler("OnMouseUp", function(self, btn, upInside) - if self.isDisabled then return end - - if upInside then - local r, g, b, a = colorpickerData.getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) - end - end) - - if colorpickerData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) - --control.warning.tooltipText = colorpickerData.warning - control.warning.data = {tooltipText = colorpickerData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = colorpickerData - control.data.tooltipText = colorpickerData.tooltip - - if colorpickerData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[colorpickerData = { + type = "colorpicker", + name = "My Color Picker", + tooltip = "Color Picker's tooltip text.", + getFunc = function() return db.r, db.g, db.b, db.a end, --(alpha is optional) + setFunc = function(r,g,b,a) db.r=r, db.g=g, db.b=b, db.a=a end, --(alpha is optional) + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + warning = "Will need to reload the UI.", --(optional) + default = {r = defaults.r, g = defaults.g, b = defaults.b, a = defaults.a}, --(optional) table of default color values (or default = defaultColor, where defaultColor is a table with keys of r, g, b[, a]) + reference = "MyAddonColorpicker" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 6 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert + + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + + control.isDisabled = disable +end + +local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) + if forceDefault then --if we are forcing defaults + local color = control.data.default + valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a + control.data.setFunc(valueR, valueG, valueB, valueA) + elseif valueR and valueG and valueB then + control.data.setFunc(valueR, valueG, valueB, valueA or 1) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + valueR, valueG, valueB, valueA = control.data.getFunc() + end + + control.thumb:SetColor(valueR, valueG, valueB, valueA or 1) +end + + +function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) + local control = wm:CreateControl(controlName or colorpickerData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetDimensions(300, 26) + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(colorpickerData.name) + + control.color = wm:CreateControl(nil, control, CT_CONTROL) + local color = control.color + + local isHalfWidth = colorpickerData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + label:SetDimensions(250, 26) + color:SetDimensions(100, 24) + color:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + else + control:SetDimensions(510, 30) + label:SetDimensions(300, 26) + color:SetDimensions(200, 24) + color:SetAnchor(TOPRIGHT) + end + + control.thumb = wm:CreateControl(nil, color, CT_TEXTURE) + local thumb = control.thumb + thumb:SetDimensions(36, 18) + thumb:SetAnchor(LEFT, color, LEFT, 4, 0) + + color.border = wm:CreateControl(nil, color, CT_TEXTURE) + local border = color.border + border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") + border:SetTextureCoords(0, .625, 0, .8125) + border:SetDimensions(40, 22) + border:SetAnchor(CENTER, thumb, CENTER, 0, 0) + + local function ColorPickerCallback(r, g, b, a) + control:UpdateValue(false, r, g, b, a) + end + + control:SetHandler("OnMouseUp", function(self, btn, upInside) + if self.isDisabled then return end + + if upInside then + local r, g, b, a = colorpickerData.getFunc() + COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) + end + end) + + if colorpickerData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) + --control.warning.tooltipText = colorpickerData.warning + control.warning.data = {tooltipText = colorpickerData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = colorpickerData + control.data.tooltipText = colorpickerData.tooltip + + if colorpickerData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control:UpdateValue() + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/custom.lua b/libs/LibAddonMenu-2.0/controls/custom.lua index 6a31c34..bb1c2d1 100644 --- a/libs/LibAddonMenu-2.0/controls/custom.lua +++ b/libs/LibAddonMenu-2.0/controls/custom.lua @@ -1,44 +1,44 @@ ---[[customData = { - type = "custom", - reference = "MyAddonCustomControl", --(optional) unique name for your control to use as reference - refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh - width = "full", --or "half" (optional) -} ]] - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("custom", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - if control.data.refreshFunc then - control.data.refreshFunc(control) - end -end - -function LAMCreateControl.custom(parent, customData, controlName) - local control = wm:CreateControl(controlName or customData.reference, parent.scroll or parent, CT_CONTROL) - control:SetResizeToFitDescendents(true) - - local isHalfWidth = customData.width == "half" - if isHalfWidth then --note these restrictions - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = customData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[customData = { + type = "custom", + reference = "MyAddonCustomControl", --(optional) unique name for your control to use as reference + refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh + width = "full", --or "half" (optional) +} ]] + +local widgetVersion = 5 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("custom", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + if control.data.refreshFunc then + control.data.refreshFunc(control) + end +end + +function LAMCreateControl.custom(parent, customData, controlName) + local control = wm:CreateControl(controlName or customData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + + local isHalfWidth = customData.width == "half" + if isHalfWidth then --note these restrictions + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 30, 510, 100) + control:SetDimensions(510, 30) + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = customData + + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/description.lua b/libs/LibAddonMenu-2.0/controls/description.lua index b886b83..795ac10 100644 --- a/libs/LibAddonMenu-2.0/controls/description.lua +++ b/libs/LibAddonMenu-2.0/controls/description.lua @@ -1,66 +1,66 @@ ---[[descriptionData = { - type = "description", - title = "My Title", --(optional) - text = "My description text to display.", - width = "full", --or "half" (optional) - reference = "MyAddonDescription" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("description", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - if control.title then - control.title:SetText(control.data.title) - end - control.desc:SetText(control.data.text) -end - -function LAMCreateControl.description(parent, descriptionData, controlName) - local control = wm:CreateControl(controlName or descriptionData.reference, parent.scroll or parent, CT_CONTROL) - control:SetResizeToFitDescendents(true) - local isHalfWidth = descriptionData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 40, 510, 100) - control:SetDimensions(510, 30) - end - - control.desc = wm:CreateControl(nil, control, CT_LABEL) - local desc = control.desc - desc:SetVerticalAlignment(TEXT_ALIGN_TOP) - desc:SetFont("ZoFontGame") - desc:SetText(descriptionData.text) - desc:SetWidth(isHalfWidth and 250 or 510) - - if descriptionData.title then - control.title = wm:CreateControl(nil, control, CT_LABEL) - local title = control.title - title:SetWidth(isHalfWidth and 250 or 510) - title:SetAnchor(TOPLEFT, control, TOPLEFT) - title:SetFont("ZoFontWinH4") - title:SetText(descriptionData.title) - desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) - else - desc:SetAnchor(TOPLEFT) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = descriptionData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control - +--[[descriptionData = { + type = "description", + title = "My Title", --(optional) + text = "My description text to display.", + width = "full", --or "half" (optional) + reference = "MyAddonDescription" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 5 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("description", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + if control.title then + control.title:SetText(control.data.title) + end + control.desc:SetText(control.data.text) +end + +function LAMCreateControl.description(parent, descriptionData, controlName) + local control = wm:CreateControl(controlName or descriptionData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + local isHalfWidth = descriptionData.width == "half" + if isHalfWidth then + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 40, 510, 100) + control:SetDimensions(510, 30) + end + + control.desc = wm:CreateControl(nil, control, CT_LABEL) + local desc = control.desc + desc:SetVerticalAlignment(TEXT_ALIGN_TOP) + desc:SetFont("ZoFontGame") + desc:SetText(descriptionData.text) + desc:SetWidth(isHalfWidth and 250 or 510) + + if descriptionData.title then + control.title = wm:CreateControl(nil, control, CT_LABEL) + local title = control.title + title:SetWidth(isHalfWidth and 250 or 510) + title:SetAnchor(TOPLEFT, control, TOPLEFT) + title:SetFont("ZoFontWinH4") + title:SetText(descriptionData.title) + desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) + else + desc:SetAnchor(TOPLEFT) + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = descriptionData + + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control + end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/dropdown.lua b/libs/LibAddonMenu-2.0/controls/dropdown.lua index 795404c..346f23d 100644 --- a/libs/LibAddonMenu-2.0/controls/dropdown.lua +++ b/libs/LibAddonMenu-2.0/controls/dropdown.lua @@ -1,157 +1,157 @@ ---[[dropdownData = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted - getFunc = function() return db.var end, - setFunc = function(var) db.var = var doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonDropdown" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 8 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("dropdown", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.dropdown:SetEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.dropdown:SetSelectedItem(value) - elseif value then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.dropdown:SetSelectedItem(value) - end -end - -local function DropdownCallback(control, choiceText, choice) - choice.control:UpdateValue(false, choiceText) -end - -local function UpdateChoices(control, choices) - control.dropdown:ClearItems() --remove previous choices --(need to call :SetSelectedItem()?) - - --build new list of choices - local choices = choices or control.data.choices - for i = 1, #choices do - local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) - entry.control = control - control.dropdown:AddItem(entry, not control.data.sort and ZO_COMBOBOX_SUPRESS_UPDATE) --if sort type/order isn't specified, then don't sort - end -end - -local function GrabSortingInfo(sortInfo) - local t, i = {}, 1 - for info in string.gmatch(sortInfo, "([^%-]+)") do - t[i] = info - i = i + 1 - end - - return t -end - - -function LAMCreateControl.dropdown(parent, dropdownData, controlName) - local control = wm:CreateControl(controlName or dropdownData.reference, parent.scroll or parent, CT_CONTROL) - control:SetMouseEnabled(true) - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(dropdownData.name) - - local countControl = parent - local name = parent:GetName() - if not name or #name == 0 then - countControl = LAMCreateControl - name = "LAM" - end - local comboboxCount = (countControl.comboboxCount or 0) + 1 - countControl.comboboxCount = comboboxCount - control.combobox = wm:CreateControlFromVirtual(zo_strjoin(nil, name, "Combobox", comboboxCount), control, "ZO_ComboBox") - - local combobox = control.combobox - combobox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - combobox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) - control.dropdown = ZO_ComboBox_ObjectFromContainer(combobox) - local dropdown = control.dropdown - if dropdownData.sort then - local sortInfo = GrabSortingInfo(dropdownData.sort) - local sortType, sortOrder = sortInfo[1], sortInfo[2] - dropdown:SetSortOrder(sortOrder == "up" and ZO_SORT_ORDER_UP or ZO_SORT_ORDER_DOWN, sortType == "name" and ZO_SORT_BY_NAME or ZO_SORT_BY_NAME_NUMERIC) - end - - local isHalfWidth = dropdownData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - combobox:SetDimensions(225, 26) - combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - combobox:SetDimensions(200, 26) - combobox:SetAnchor(TOPRIGHT) - end - - if dropdownData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - control.warning.data = {tooltipText = dropdownData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = dropdownData - control.data.tooltipText = dropdownData.tooltip - - if dropdownData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateChoices = UpdateChoices - control:UpdateChoices(dropdownData.choices) - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[dropdownData = { + type = "dropdown", + name = "My Dropdown", + tooltip = "Dropdown's tooltip text.", + choices = {"table", "of", "choices"}, + sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted + getFunc = function() return db.var end, + setFunc = function(var) db.var = var doStuff() end, + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + warning = "Will need to reload the UI.", --(optional) + default = defaults.var, --(optional) + reference = "MyAddonDropdown" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 8 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("dropdown", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert + + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.dropdown:SetEnabled(not disable) + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end +end + +local function UpdateValue(control, forceDefault, value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + control.dropdown:SetSelectedItem(value) + elseif value then + control.data.setFunc(value) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + control.dropdown:SetSelectedItem(value) + end +end + +local function DropdownCallback(control, choiceText, choice) + choice.control:UpdateValue(false, choiceText) +end + +local function UpdateChoices(control, choices) + control.dropdown:ClearItems() --remove previous choices --(need to call :SetSelectedItem()?) + + --build new list of choices + local choices = choices or control.data.choices + for i = 1, #choices do + local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) + entry.control = control + control.dropdown:AddItem(entry, not control.data.sort and ZO_COMBOBOX_SUPRESS_UPDATE) --if sort type/order isn't specified, then don't sort + end +end + +local function GrabSortingInfo(sortInfo) + local t, i = {}, 1 + for info in string.gmatch(sortInfo, "([^%-]+)") do + t[i] = info + i = i + 1 + end + + return t +end + + +function LAMCreateControl.dropdown(parent, dropdownData, controlName) + local control = wm:CreateControl(controlName or dropdownData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(dropdownData.name) + + local countControl = parent + local name = parent:GetName() + if not name or #name == 0 then + countControl = LAMCreateControl + name = "LAM" + end + local comboboxCount = (countControl.comboboxCount or 0) + 1 + countControl.comboboxCount = comboboxCount + control.combobox = wm:CreateControlFromVirtual(zo_strjoin(nil, name, "Combobox", comboboxCount), control, "ZO_ComboBox") + + local combobox = control.combobox + combobox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + combobox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) + control.dropdown = ZO_ComboBox_ObjectFromContainer(combobox) + local dropdown = control.dropdown + if dropdownData.sort then + local sortInfo = GrabSortingInfo(dropdownData.sort) + local sortType, sortOrder = sortInfo[1], sortInfo[2] + dropdown:SetSortOrder(sortOrder == "up" and ZO_SORT_ORDER_UP or ZO_SORT_ORDER_DOWN, sortType == "name" and ZO_SORT_BY_NAME or ZO_SORT_BY_NAME_NUMERIC) + end + + local isHalfWidth = dropdownData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + label:SetDimensions(250, 26) + combobox:SetDimensions(225, 26) + combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + else + control:SetDimensions(510, 30) + label:SetDimensions(300, 26) + combobox:SetDimensions(200, 26) + combobox:SetAnchor(TOPRIGHT) + end + + if dropdownData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) + control.warning.data = {tooltipText = dropdownData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = dropdownData + control.data.tooltipText = dropdownData.tooltip + + if dropdownData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateChoices = UpdateChoices + control:UpdateChoices(dropdownData.choices) + control.UpdateValue = UpdateValue + control:UpdateValue() + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/editbox.lua b/libs/LibAddonMenu-2.0/controls/editbox.lua index 3ab069f..b473f23 100644 --- a/libs/LibAddonMenu-2.0/controls/editbox.lua +++ b/libs/LibAddonMenu-2.0/controls/editbox.lua @@ -1,153 +1,153 @@ ---[[editboxData = { - type = "editbox", - name = "My Editbox", - tooltip = "Editbox's tooltip text.", - getFunc = function() return db.text end, - setFunc = function(text) db.text = text doStuff() end, - isMultiline = true, --boolean - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.text, --(optional) - reference = "MyAddonEditbox" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 7 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("editbox", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - --control.editbox:SetEditEnabled(not disable) - control.editbox:SetMouseEnabled(not disable) -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.editbox:SetText(value) - elseif value then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.editbox:SetText(value) - end -end - - -function LAMCreateControl.editbox(parent, editboxData, controlName) - local control = wm:CreateControl(controlName or editboxData.reference, parent.scroll or parent, CT_CONTROL) - control:SetMouseEnabled(true) - control:SetResizeToFitDescendents(true) - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(editboxData.name) - - control.bg = wm:CreateControlFromVirtual(nil, control, "ZO_EditBackdrop") - local bg = control.bg - - if editboxData.isMultiline then - control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditMultiLineForBackdrop") - control.editbox:SetHandler("OnMouseWheel", function(self, delta) - if self:HasFocus() then --only set focus to new spots if the editbox is currently in use - local cursorPos = self:GetCursorPosition() - local text = self:GetText() - local textLen = text:len() - local newPos - if delta > 0 then --scrolling up - local reverseText = text:reverse() - local revCursorPos = textLen - cursorPos - local revPos = reverseText:find("\n", revCursorPos+1) - newPos = revPos and textLen - revPos - else --scrolling down - newPos = text:find("\n", cursorPos+1) - end - if newPos then --if we found a new line, then scroll, otherwise don't - self:SetCursorPosition(newPos) - end - end - end) - else - control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditForBackdrop") - end - local editbox = control.editbox - editbox:SetText(editboxData.getFunc()) - editbox:SetMaxInputChars(3000) - editbox:SetHandler("OnFocusLost", function(self) control:UpdateValue(false, self:GetText()) end) - editbox:SetHandler("OnEscape", function(self) self:LoseFocus() control:UpdateValue(false, self:GetText()) end) - editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) - - local isHalfWidth = editboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - bg:SetDimensions(225, editboxData.isMultiline and 74 or 24) - bg:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - if editboxData.isMultiline then - editbox:SetDimensionConstraints(210, 74, 210, 500) - end - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - bg:SetDimensions(200, editboxData.isMultiline and 100 or 24) - bg:SetAnchor(TOPRIGHT) - if editboxData.isMultiline then - editbox:SetDimensionConstraints(185, 100, 185, 500) - end - end - - if editboxData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) - --control.warning.tooltipText = editboxData.warning - control.warning.data = {tooltipText = editboxData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = editboxData - control.data.tooltipText = editboxData.tooltip - - if editboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[editboxData = { + type = "editbox", + name = "My Editbox", + tooltip = "Editbox's tooltip text.", + getFunc = function() return db.text end, + setFunc = function(text) db.text = text doStuff() end, + isMultiline = true, --boolean + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + warning = "Will need to reload the UI.", --(optional) + default = defaults.text, --(optional) + reference = "MyAddonEditbox" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 7 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("editbox", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local tinsert = table.insert + + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.editbox:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.editbox:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + --control.editbox:SetEditEnabled(not disable) + control.editbox:SetMouseEnabled(not disable) +end + +local function UpdateValue(control, forceDefault, value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + control.editbox:SetText(value) + elseif value then + control.data.setFunc(value) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + control.editbox:SetText(value) + end +end + + +function LAMCreateControl.editbox(parent, editboxData, controlName) + local control = wm:CreateControl(controlName or editboxData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetResizeToFitDescendents(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(editboxData.name) + + control.bg = wm:CreateControlFromVirtual(nil, control, "ZO_EditBackdrop") + local bg = control.bg + + if editboxData.isMultiline then + control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditMultiLineForBackdrop") + control.editbox:SetHandler("OnMouseWheel", function(self, delta) + if self:HasFocus() then --only set focus to new spots if the editbox is currently in use + local cursorPos = self:GetCursorPosition() + local text = self:GetText() + local textLen = text:len() + local newPos + if delta > 0 then --scrolling up + local reverseText = text:reverse() + local revCursorPos = textLen - cursorPos + local revPos = reverseText:find("\n", revCursorPos+1) + newPos = revPos and textLen - revPos + else --scrolling down + newPos = text:find("\n", cursorPos+1) + end + if newPos then --if we found a new line, then scroll, otherwise don't + self:SetCursorPosition(newPos) + end + end + end) + else + control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditForBackdrop") + end + local editbox = control.editbox + editbox:SetText(editboxData.getFunc()) + editbox:SetMaxInputChars(3000) + editbox:SetHandler("OnFocusLost", function(self) control:UpdateValue(false, self:GetText()) end) + editbox:SetHandler("OnEscape", function(self) self:LoseFocus() control:UpdateValue(false, self:GetText()) end) + editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) + + local isHalfWidth = editboxData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + label:SetDimensions(250, 26) + bg:SetDimensions(225, editboxData.isMultiline and 74 or 24) + bg:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + if editboxData.isMultiline then + editbox:SetDimensionConstraints(210, 74, 210, 500) + end + else + control:SetDimensions(510, 30) + label:SetDimensions(300, 26) + bg:SetDimensions(200, editboxData.isMultiline and 100 or 24) + bg:SetAnchor(TOPRIGHT) + if editboxData.isMultiline then + editbox:SetDimensionConstraints(185, 100, 185, 500) + end + end + + if editboxData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) + --control.warning.tooltipText = editboxData.warning + control.warning.data = {tooltipText = editboxData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = editboxData + control.data.tooltipText = editboxData.tooltip + + if editboxData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control:UpdateValue() + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/header.lua b/libs/LibAddonMenu-2.0/controls/header.lua index 83c862b..14851ee 100644 --- a/libs/LibAddonMenu-2.0/controls/header.lua +++ b/libs/LibAddonMenu-2.0/controls/header.lua @@ -1,46 +1,46 @@ ---[[headerData = { - type = "header", - name = "My Header", - width = "full", --or "half" (optional) - reference = "MyAddonHeader" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("header", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - control.header:SetText(control.data.name) -end - -function LAMCreateControl.header(parent, headerData, controlName) - local control = wm:CreateControl(controlName or headerData.reference, parent.scroll or parent, CT_CONTROL) - local isHalfWidth = headerData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, 30) - - control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") - local divider = control.divider - divider:SetWidth(isHalfWidth and 250 or 510) - divider:SetAnchor(TOPLEFT) - - control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local header = control.header - header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) - header:SetAnchor(BOTTOMRIGHT) - header:SetText(headerData.name) - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = headerData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[headerData = { + type = "header", + name = "My Header", + width = "full", --or "half" (optional) + reference = "MyAddonHeader" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 5 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("header", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + control.header:SetText(control.data.name) +end + +function LAMCreateControl.header(parent, headerData, controlName) + local control = wm:CreateControl(controlName or headerData.reference, parent.scroll or parent, CT_CONTROL) + local isHalfWidth = headerData.width == "half" + control:SetDimensions(isHalfWidth and 250 or 510, 30) + + control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") + local divider = control.divider + divider:SetWidth(isHalfWidth and 250 or 510) + divider:SetAnchor(TOPLEFT) + + control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") + local header = control.header + header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) + header:SetAnchor(BOTTOMRIGHT) + header:SetText(headerData.name) + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = headerData + + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/panel.lua b/libs/LibAddonMenu-2.0/controls/panel.lua index 8db73ee..46d39a0 100644 --- a/libs/LibAddonMenu-2.0/controls/panel.lua +++ b/libs/LibAddonMenu-2.0/controls/panel.lua @@ -1,138 +1,138 @@ ---[[panelData = { - type = "panel", - name = "Window Title", - displayName = "My Longer Window Title", --(optional) (can be useful for long addon names or if you want to colorize it) - author = "Seerah", --(optional) - version = "2.0", --(optional) - slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel (don't forget to include the slash!) - registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) - registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) - resetFunc = function() print("defaults reset") end, --(optional) custom function to run after settings are reset to defaults -} ]] - - -local widgetVersion = 8 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("panel", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER - -local function RefreshPanel(control) - local panel = control.panel or control --callback can be fired by a single control or by the panel showing - local panelControls = panel.controlsToRefresh - - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl ~= control then - if updateControl.UpdateValue then - updateControl:UpdateValue() - end - if updateControl.UpdateDisabled then - updateControl:UpdateDisabled() - end - end - end -end - -local function ForceDefaults(panel) - local panelControls = panel.controlsToRefresh - - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl.UpdateValue and updateControl.data.default ~= nil then - updateControl:UpdateValue(true) - end - end - - if panel.data.resetFunc then - panel.data.resetFunc() - end - - cm:FireCallbacks("LAM-RefreshPanel", panel) -end -ESO_Dialogs["LAM_DEFAULTS"] = { - title = { - text = SI_OPTIONS_RESET_TITLE, - }, - mainText = { - text = SI_OPTIONS_RESET_PROMPT, - align = TEXT_ALIGN_CENTER, - }, - buttons = { - [1] = { - text = SI_OPTIONS_RESET, - callback = function(dialog) ForceDefaults(dialog.data[1]) end, - }, - [2] = { - text = SI_DIALOG_CANCEL, - }, - }, -} - -local callbackRegistered = false -LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 -function LAMCreateControl.panel(parent, panelData, controlName) - local control = wm:CreateTopLevelWindow(controlName) - control:SetParent(parent) - - control.bg = wm:CreateControl(nil, control, CT_BACKDROP) - local bg = control.bg - bg:SetAnchorFill() - bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) - bg:SetCenterColor(0, 0, 0, 0) - - control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 10, 10) - label:SetText(panelData.displayName and panelData.displayName or panelData.name) - - if panelData.author or panelData.version then - control.info = wm:CreateControl(nil, control, CT_LABEL) - local info = control.info - info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") - info:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) - info:SetHeight(13) - info:SetAnchor(TOPRIGHT, control, BOTTOMRIGHT, -5, 2) - if panelData.author and panelData.version then - --info:SetText("Version: "..panelData.version.." - "..GetString(SI_ADDON_MANAGER_AUTHOR)..": "..panelData.author) - info:SetText(string.format("Version: %s - %s: %s", panelData.version, GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) - elseif panelData.author then - info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) - else - info:SetText("Version: "..panelData.version) - end - end - - control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") - LAMCreateControl.scrollCount = LAMCreateControl.scrollCount + 1 - local container = control.container - container:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 20) - container:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -3, -3) - control.scroll = GetControl(control.container, "ScrollChild") - control.scroll:SetResizeToFitPadding(0, 20) - - if panelData.registerForDefaults then - control.defaultButton = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultTextButton") - local defaultButton = control.defaultButton - defaultButton:SetFont("ZoFontDialogKeybindDescription") - defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - --defaultButton:SetText("Reset To Defaults") - defaultButton:SetText(GetString(SI_OPTIONS_RESET_TITLE)) - defaultButton:SetDimensions(200, 30) - defaultButton:SetAnchor(TOPLEFT, control, BOTTOMLEFT, 0, 2) - defaultButton:SetHandler("OnClicked", function() - ZO_Dialogs_ShowDialog("LAM_DEFAULTS", {control}) - end) - end - - if panelData.registerForRefresh and not callbackRegistered then --don't want to register our callback more than once - cm:RegisterCallback("LAM-RefreshPanel", RefreshPanel) - callbackRegistered = true - end - - control.data = panelData - control.controlsToRefresh = {} - - return control +--[[panelData = { + type = "panel", + name = "Window Title", + displayName = "My Longer Window Title", --(optional) (can be useful for long addon names or if you want to colorize it) + author = "Seerah", --(optional) + version = "2.0", --(optional) + slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel (don't forget to include the slash!) + registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) + registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) + resetFunc = function() print("defaults reset") end, --(optional) custom function to run after settings are reset to defaults +} ]] + + +local widgetVersion = 8 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("panel", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER + +local function RefreshPanel(control) + local panel = control.panel or control --callback can be fired by a single control or by the panel showing + local panelControls = panel.controlsToRefresh + + for i = 1, #panelControls do + local updateControl = panelControls[i] + if updateControl ~= control then + if updateControl.UpdateValue then + updateControl:UpdateValue() + end + if updateControl.UpdateDisabled then + updateControl:UpdateDisabled() + end + end + end +end + +local function ForceDefaults(panel) + local panelControls = panel.controlsToRefresh + + for i = 1, #panelControls do + local updateControl = panelControls[i] + if updateControl.UpdateValue and updateControl.data.default ~= nil then + updateControl:UpdateValue(true) + end + end + + if panel.data.resetFunc then + panel.data.resetFunc() + end + + cm:FireCallbacks("LAM-RefreshPanel", panel) +end +ESO_Dialogs["LAM_DEFAULTS"] = { + title = { + text = SI_OPTIONS_RESET_TITLE, + }, + mainText = { + text = SI_OPTIONS_RESET_PROMPT, + align = TEXT_ALIGN_CENTER, + }, + buttons = { + [1] = { + text = SI_OPTIONS_RESET, + callback = function(dialog) ForceDefaults(dialog.data[1]) end, + }, + [2] = { + text = SI_DIALOG_CANCEL, + }, + }, +} + +local callbackRegistered = false +LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 +function LAMCreateControl.panel(parent, panelData, controlName) + local control = wm:CreateTopLevelWindow(controlName) + control:SetParent(parent) + + control.bg = wm:CreateControl(nil, control, CT_BACKDROP) + local bg = control.bg + bg:SetAnchorFill() + bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) + bg:SetCenterColor(0, 0, 0, 0) + + control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") + local label = control.label + label:SetAnchor(TOPLEFT, control, TOPLEFT, 10, 10) + label:SetText(panelData.displayName and panelData.displayName or panelData.name) + + if panelData.author or panelData.version then + control.info = wm:CreateControl(nil, control, CT_LABEL) + local info = control.info + info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") + info:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) + info:SetHeight(13) + info:SetAnchor(TOPRIGHT, control, BOTTOMRIGHT, -5, 2) + if panelData.author and panelData.version then + --info:SetText("Version: "..panelData.version.." - "..GetString(SI_ADDON_MANAGER_AUTHOR)..": "..panelData.author) + info:SetText(string.format("Version: %s - %s: %s", panelData.version, GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) + elseif panelData.author then + info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) + else + info:SetText("Version: "..panelData.version) + end + end + + control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") + LAMCreateControl.scrollCount = LAMCreateControl.scrollCount + 1 + local container = control.container + container:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 20) + container:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -3, -3) + control.scroll = GetControl(control.container, "ScrollChild") + control.scroll:SetResizeToFitPadding(0, 20) + + if panelData.registerForDefaults then + control.defaultButton = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultTextButton") + local defaultButton = control.defaultButton + defaultButton:SetFont("ZoFontDialogKeybindDescription") + defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) + --defaultButton:SetText("Reset To Defaults") + defaultButton:SetText(GetString(SI_OPTIONS_RESET_TITLE)) + defaultButton:SetDimensions(200, 30) + defaultButton:SetAnchor(TOPLEFT, control, BOTTOMLEFT, 0, 2) + defaultButton:SetHandler("OnClicked", function() + ZO_Dialogs_ShowDialog("LAM_DEFAULTS", {control}) + end) + end + + if panelData.registerForRefresh and not callbackRegistered then --don't want to register our callback more than once + cm:RegisterCallback("LAM-RefreshPanel", RefreshPanel) + callbackRegistered = true + end + + control.data = panelData + control.controlsToRefresh = {} + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/slider.lua b/libs/LibAddonMenu-2.0/controls/slider.lua index 845fa7d..e02cb5d 100644 --- a/libs/LibAddonMenu-2.0/controls/slider.lua +++ b/libs/LibAddonMenu-2.0/controls/slider.lua @@ -1,183 +1,183 @@ ---[[sliderData = { - type = "slider", - name = "My Slider", - tooltip = "Slider's tooltip text.", - min = 0, - max = 20, - step = 1, --(optional) - getFunc = function() return db.var end, - setFunc = function(value) db.var = value doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonSlider" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 6 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("slider", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local round = zo_round -local strformat = string.format -local tinsert = table.insert - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.slider:SetEnabled(not disable) - control.slidervalue:SetEditEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value and value >= control.data.min and value <= control.data.max then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - - control.slider:SetValue(value) - control.slidervalue:SetText(value) -end - - -function LAMCreateControl.slider(parent, sliderData, controlName) - local control = wm:CreateControl(controlName or sliderData.reference, parent.scroll or parent, CT_CONTROL) - local isHalfWidth = sliderData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - else - control:SetDimensions(510, 40) - end - control:SetMouseEnabled(true) - --control.tooltipText = sliderData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetDimensions(isHalfWidth and 250 or 300, 26) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetAnchor(isHalfWidth and TOPLEFT or LEFT) - label:SetText(sliderData.name) - - --skipping creating the backdrop... Is this the actual slider texture? - control.slider = wm:CreateControl(nil, control, CT_SLIDER) - local slider = control.slider - slider:SetDimensions(190, 14) - if isHalfWidth then - slider:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT, -5, 2) - else - slider:SetAnchor(RIGHT, control, RIGHT, -5, -5) - end - slider:SetMouseEnabled(true) - slider:SetOrientation(ORIENTATION_HORIZONTAL) - --put nil for highlighted texture file path, and what look to be texture coords - slider:SetThumbTexture("EsoUI\\Art\\Miscellaneous\\scrollbox_elevator.dds", "EsoUI\\Art\\Miscellaneous\\scrollbox_elevator_disabled.dds", nil, 8, 16) - local minValue = sliderData.min - local maxValue = sliderData.max - slider:SetMinMax(minValue, maxValue) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) - - slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) - local bg = slider.bg - bg:SetCenterColor(0, 0, 0) - bg:SetAnchor(TOPLEFT, slider, TOPLEFT, 0, 4) - bg:SetAnchor(BOTTOMRIGHT, slider, BOTTOMRIGHT, 0, -4) - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-SliderBackdrop.dds", 32, 4) - - control.minText = wm:CreateControl(nil, slider, CT_LABEL) - local minText = control.minText - minText:SetFont("ZoFontGameSmall") - minText:SetAnchor(TOPLEFT, slider, BOTTOMLEFT) - minText:SetText(sliderData.min) - - control.maxText = wm:CreateControl(nil, slider, CT_LABEL) - local maxText = control.maxText - maxText:SetFont("ZoFontGameSmall") - maxText:SetAnchor(TOPRIGHT, slider, BOTTOMRIGHT) - maxText:SetText(sliderData.max) - - control.slidervalueBG = wm:CreateControlFromVirtual(nil, slider, "ZO_EditBackdrop") - control.slidervalueBG:SetDimensions(50, 16) - control.slidervalueBG:SetAnchor(TOP, slider, BOTTOM, 0, 0) - control.slidervalue = wm:CreateControlFromVirtual(nil, control.slidervalueBG, "ZO_DefaultEditForBackdrop") - local slidervalue = control.slidervalue - slidervalue:ClearAnchors() - slidervalue:SetAnchor(TOPLEFT, slidervaluebg, TOPLEFT, 3, 1) - slidervalue:SetAnchor(BOTTOMRIGHT, slidervaluebg, BOTTOMRIGHT, -3, -1) - slidervalue:SetTextType(TEXT_TYPE_NUMERIC) - slidervalue:SetFont("ZoFontGameSmall") - slidervalue:SetHandler("OnEscape", function(self) - self:LoseFocus() - control:UpdateValue() - end) - slidervalue:SetHandler("OnEnter", function(self) - self:LoseFocus() - control:UpdateValue(false, tonumber(self:GetText())) - end) - - local range = maxValue - minValue - slider:SetValueStep(sliderData.step or 1) - slider:SetHandler("OnValueChanged", function(self, value, eventReason) - if eventReason == EVENT_REASON_SOFTWARE then return end - self:SetValue(value) --do we actually need this line? - slidervalue:SetText(value) - end) - slider:SetHandler("OnSliderReleased", function(self, value) - --sliderData.setFunc(value) - control:UpdateValue(false, value) --does this work here instead? - end) - - if sliderData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) - --control.warning.tooltipText = sliderData.warning - control.warning.data = {tooltipText = sliderData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent - control.data = sliderData - control.data.tooltipText = sliderData.tooltip - - if sliderData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control +--[[sliderData = { + type = "slider", + name = "My Slider", + tooltip = "Slider's tooltip text.", + min = 0, + max = 20, + step = 1, --(optional) + getFunc = function() return db.var end, + setFunc = function(value) db.var = value doStuff() end, + width = "full", --or "half" (optional) + disabled = function() return db.someBooleanSetting end, --or boolean (optional) + warning = "Will need to reload the UI.", --(optional) + default = defaults.var, --(optional) + reference = "MyAddonSlider" --(optional) unique global reference to control +} ]] + + +local widgetVersion = 6 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("slider", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local cm = CALLBACK_MANAGER +local round = zo_round +local strformat = string.format +local tinsert = table.insert + +local function UpdateDisabled(control) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.slider:SetEnabled(not disable) + control.slidervalue:SetEditEnabled(not disable) + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.minText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.maxText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.slidervalue:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.minText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.maxText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.slidervalue:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end +end + +local function UpdateValue(control, forceDefault, value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + elseif value and value >= control.data.min and value <= control.data.max then + control.data.setFunc(value) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + end + + control.slider:SetValue(value) + control.slidervalue:SetText(value) +end + + +function LAMCreateControl.slider(parent, sliderData, controlName) + local control = wm:CreateControl(controlName or sliderData.reference, parent.scroll or parent, CT_CONTROL) + local isHalfWidth = sliderData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + else + control:SetDimensions(510, 40) + end + control:SetMouseEnabled(true) + --control.tooltipText = sliderData.tooltip + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetFont("ZoFontWinH4") + label:SetDimensions(isHalfWidth and 250 or 300, 26) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetAnchor(isHalfWidth and TOPLEFT or LEFT) + label:SetText(sliderData.name) + + --skipping creating the backdrop... Is this the actual slider texture? + control.slider = wm:CreateControl(nil, control, CT_SLIDER) + local slider = control.slider + slider:SetDimensions(190, 14) + if isHalfWidth then + slider:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT, -5, 2) + else + slider:SetAnchor(RIGHT, control, RIGHT, -5, -5) + end + slider:SetMouseEnabled(true) + slider:SetOrientation(ORIENTATION_HORIZONTAL) + --put nil for highlighted texture file path, and what look to be texture coords + slider:SetThumbTexture("EsoUI\\Art\\Miscellaneous\\scrollbox_elevator.dds", "EsoUI\\Art\\Miscellaneous\\scrollbox_elevator_disabled.dds", nil, 8, 16) + local minValue = sliderData.min + local maxValue = sliderData.max + slider:SetMinMax(minValue, maxValue) + slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) + + slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) + local bg = slider.bg + bg:SetCenterColor(0, 0, 0) + bg:SetAnchor(TOPLEFT, slider, TOPLEFT, 0, 4) + bg:SetAnchor(BOTTOMRIGHT, slider, BOTTOMRIGHT, 0, -4) + bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-SliderBackdrop.dds", 32, 4) + + control.minText = wm:CreateControl(nil, slider, CT_LABEL) + local minText = control.minText + minText:SetFont("ZoFontGameSmall") + minText:SetAnchor(TOPLEFT, slider, BOTTOMLEFT) + minText:SetText(sliderData.min) + + control.maxText = wm:CreateControl(nil, slider, CT_LABEL) + local maxText = control.maxText + maxText:SetFont("ZoFontGameSmall") + maxText:SetAnchor(TOPRIGHT, slider, BOTTOMRIGHT) + maxText:SetText(sliderData.max) + + control.slidervalueBG = wm:CreateControlFromVirtual(nil, slider, "ZO_EditBackdrop") + control.slidervalueBG:SetDimensions(50, 16) + control.slidervalueBG:SetAnchor(TOP, slider, BOTTOM, 0, 0) + control.slidervalue = wm:CreateControlFromVirtual(nil, control.slidervalueBG, "ZO_DefaultEditForBackdrop") + local slidervalue = control.slidervalue + slidervalue:ClearAnchors() + slidervalue:SetAnchor(TOPLEFT, slidervaluebg, TOPLEFT, 3, 1) + slidervalue:SetAnchor(BOTTOMRIGHT, slidervaluebg, BOTTOMRIGHT, -3, -1) + slidervalue:SetTextType(TEXT_TYPE_NUMERIC) + slidervalue:SetFont("ZoFontGameSmall") + slidervalue:SetHandler("OnEscape", function(self) + self:LoseFocus() + control:UpdateValue() + end) + slidervalue:SetHandler("OnEnter", function(self) + self:LoseFocus() + control:UpdateValue(false, tonumber(self:GetText())) + end) + + local range = maxValue - minValue + slider:SetValueStep(sliderData.step or 1) + slider:SetHandler("OnValueChanged", function(self, value, eventReason) + if eventReason == EVENT_REASON_SOFTWARE then return end + self:SetValue(value) --do we actually need this line? + slidervalue:SetText(value) + end) + slider:SetHandler("OnSliderReleased", function(self, value) + --sliderData.setFunc(value) + control:UpdateValue(false, value) --does this work here instead? + end) + + if sliderData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) + --control.warning.tooltipText = sliderData.warning + control.warning.data = {tooltipText = sliderData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent + control.data = sliderData + control.data.tooltipText = sliderData.tooltip + + if sliderData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control:UpdateValue() + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/submenu.lua b/libs/LibAddonMenu-2.0/controls/submenu.lua index d3da3eb..c456d49 100644 --- a/libs/LibAddonMenu-2.0/controls/submenu.lua +++ b/libs/LibAddonMenu-2.0/controls/submenu.lua @@ -1,114 +1,114 @@ ---[[submenuData = { - type = "submenu", - name = "Submenu Title", - tooltip = "My submenu tooltip", --(optional) - controls = {sliderData, buttonData} --(optional) used by LAM - reference = "MyAddonSubmenu" --(optional) unique global reference to control -} ]] - -local widgetVersion = 8 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("submenu", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local am = ANIMATION_MANAGER -local tinsert = table.insert - - -local function UpdateValue(control) - control.label:SetText(control.data.name) - if control.data.tooltip then - control.label.data = {tooltipText = control.data.tooltip} - end -end - -local function AnimateSubmenu(clicked) - local control = clicked:GetParent() - control.open = not control.open - - if control.open then - control.animation:PlayFromStart() - else - control.animation:PlayFromEnd() - end -end - - -function LAMCreateControl.submenu(parent, submenuData, controlName) - local control = wm:CreateControl(controlName or submenuData.reference, parent.scroll or parent, CT_CONTROL) - control.panel = parent - control:SetDimensions(523, 40) - - control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) - label:SetDimensions(520, 30) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(submenuData.name) - label:SetMouseEnabled(true) - if submenuData.tooltip then - label.data = {tooltipText = submenuData.tooltip} - label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - end - - control.scroll = wm:CreateControl(nil, control, CT_SCROLL) - local scroll = control.scroll - scroll:SetParent(control) - scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) - scroll:SetDimensionConstraints(525, 0, 525, 2500) - - control.bg = wm:CreateControl(nil, label, CT_BACKDROP) - local bg = control.bg - bg:SetAnchor(TOPLEFT, label, TOPLEFT, -5, -5) - bg:SetAnchor(BOTTOMRIGHT, scroll, BOTTOMRIGHT, -7, 0) - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) - bg:SetCenterTexture("EsoUI\\Art\\Tooltips\\UI-TooltipCenter.dds") - bg:SetInsets(16, 16, -16, -16) - - control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) - local arrow = control.arrow - arrow:SetDimensions(28, 28) - arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way - arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) - - --figure out the cool animation later... - control.animation = am:CreateTimeline() - local animation = control.animation - animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count - - control:SetResizeToFitDescendents(true) - control.open = false - label:SetHandler("OnMouseUp", AnimateSubmenu) - animation:SetHandler("OnStop", function(self, completedPlaying) - scroll:SetResizeToFitDescendents(control.open) - if control.open then - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") - scroll:SetResizeToFitPadding(5, 20) - else - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") - scroll:SetResizeToFitPadding(5, 0) - scroll:SetHeight(0) - end - end) - - --small strip at the bottom of the submenu that you can click to close it - control.btmToggle = wm:CreateControl(nil, control, CT_TEXTURE) - local btmToggle = control.btmToggle - btmToggle:SetMouseEnabled(true) - btmToggle:SetAnchor(BOTTOMLEFT, control.scroll, BOTTOMLEFT) - btmToggle:SetAnchor(BOTTOMRIGHT, control.scroll, BOTTOMRIGHT) - btmToggle:SetHeight(15) - btmToggle:SetAlpha(0) - btmToggle:SetHandler("OnMouseUp", AnimateSubmenu) - - control.data = submenuData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end +--[[submenuData = { + type = "submenu", + name = "Submenu Title", + tooltip = "My submenu tooltip", --(optional) + controls = {sliderData, buttonData} --(optional) used by LAM + reference = "MyAddonSubmenu" --(optional) unique global reference to control +} ]] + +local widgetVersion = 8 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("submenu", widgetVersion) then return end + +local wm = WINDOW_MANAGER +local am = ANIMATION_MANAGER +local tinsert = table.insert + + +local function UpdateValue(control) + control.label:SetText(control.data.name) + if control.data.tooltip then + control.label.data = {tooltipText = control.data.tooltip} + end +end + +local function AnimateSubmenu(clicked) + local control = clicked:GetParent() + control.open = not control.open + + if control.open then + control.animation:PlayFromStart() + else + control.animation:PlayFromEnd() + end +end + + +function LAMCreateControl.submenu(parent, submenuData, controlName) + local control = wm:CreateControl(controlName or submenuData.reference, parent.scroll or parent, CT_CONTROL) + control.panel = parent + control:SetDimensions(523, 40) + + control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") + local label = control.label + label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) + label:SetDimensions(520, 30) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(submenuData.name) + label:SetMouseEnabled(true) + if submenuData.tooltip then + label.data = {tooltipText = submenuData.tooltip} + label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + end + + control.scroll = wm:CreateControl(nil, control, CT_SCROLL) + local scroll = control.scroll + scroll:SetParent(control) + scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) + scroll:SetDimensionConstraints(525, 0, 525, 2500) + + control.bg = wm:CreateControl(nil, label, CT_BACKDROP) + local bg = control.bg + bg:SetAnchor(TOPLEFT, label, TOPLEFT, -5, -5) + bg:SetAnchor(BOTTOMRIGHT, scroll, BOTTOMRIGHT, -7, 0) + bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) + bg:SetCenterTexture("EsoUI\\Art\\Tooltips\\UI-TooltipCenter.dds") + bg:SetInsets(16, 16, -16, -16) + + control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) + local arrow = control.arrow + arrow:SetDimensions(28, 28) + arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way + arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) + + --figure out the cool animation later... + control.animation = am:CreateTimeline() + local animation = control.animation + animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count + + control:SetResizeToFitDescendents(true) + control.open = false + label:SetHandler("OnMouseUp", AnimateSubmenu) + animation:SetHandler("OnStop", function(self, completedPlaying) + scroll:SetResizeToFitDescendents(control.open) + if control.open then + control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") + scroll:SetResizeToFitPadding(5, 20) + else + control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") + scroll:SetResizeToFitPadding(5, 0) + scroll:SetHeight(0) + end + end) + + --small strip at the bottom of the submenu that you can click to close it + control.btmToggle = wm:CreateControl(nil, control, CT_TEXTURE) + local btmToggle = control.btmToggle + btmToggle:SetMouseEnabled(true) + btmToggle:SetAnchor(BOTTOMLEFT, control.scroll, BOTTOMLEFT) + btmToggle:SetAnchor(BOTTOMRIGHT, control.scroll, BOTTOMRIGHT) + btmToggle:SetHeight(15) + btmToggle:SetAlpha(0) + btmToggle:SetHandler("OnMouseUp", AnimateSubmenu) + + control.data = submenuData + + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + + return control +end diff --git a/libs/LibAddonMenu-2.0/controls/texture.lua b/libs/LibAddonMenu-2.0/controls/texture.lua index 26b0353..d0e6905 100644 --- a/libs/LibAddonMenu-2.0/controls/texture.lua +++ b/libs/LibAddonMenu-2.0/controls/texture.lua @@ -1,50 +1,50 @@ ---[[textureData = { - type = "texture", - image = "file/path.dds", - imageWidth = 64, --max of 250 for half width, 510 for full - imageHeight = 32, --max of 100 - tooltip = "Image's tooltip text.", --(optional) - width = "full", --or "half" (optional) - reference = "MyAddonTexture" --(optional) unique global reference to control -} ]] - ---add texture coords support? - -local widgetVersion = 6 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("texture", widgetVersion) then return end - -local wm = WINDOW_MANAGER - -function LAMCreateControl.texture(parent, textureData, controlName) - local control = wm:CreateControl(controlName or textureData.reference, parent.scroll or parent, CT_CONTROL) - control:SetResizeToFitDescendents(true) - - local isHalfWidth = textureData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - control.texture = wm:CreateControl(nil, control, CT_TEXTURE) - local texture = control.texture - texture:SetAnchor(CENTER) - texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) - texture:SetTexture(textureData.image) - - if textureData.tooltip then - texture:SetMouseEnabled(true) - --texture.tooltipText = textureData.tooltip - texture.data = {tooltipText = textureData.tooltip} - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = textureData - - return control +--[[textureData = { + type = "texture", + image = "file/path.dds", + imageWidth = 64, --max of 250 for half width, 510 for full + imageHeight = 32, --max of 100 + tooltip = "Image's tooltip text.", --(optional) + width = "full", --or "half" (optional) + reference = "MyAddonTexture" --(optional) unique global reference to control +} ]] + +--add texture coords support? + +local widgetVersion = 6 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("texture", widgetVersion) then return end + +local wm = WINDOW_MANAGER + +function LAMCreateControl.texture(parent, textureData, controlName) + local control = wm:CreateControl(controlName or textureData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + + local isHalfWidth = textureData.width == "half" + if isHalfWidth then + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 30, 510, 100) + control:SetDimensions(510, 30) + end + + control.texture = wm:CreateControl(nil, control, CT_TEXTURE) + local texture = control.texture + texture:SetAnchor(CENTER) + texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) + texture:SetTexture(textureData.image) + + if textureData.tooltip then + texture:SetMouseEnabled(true) + --texture.tooltipText = textureData.tooltip + texture.data = {tooltipText = textureData.tooltip} + texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = textureData + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu/LibAddonMenu-2.0.txt b/libs/LibAddonMenu/LibAddonMenu-2.0.txt index b4fe7b9..9ea1599 100644 --- a/libs/LibAddonMenu/LibAddonMenu-2.0.txt +++ b/libs/LibAddonMenu/LibAddonMenu-2.0.txt @@ -1,24 +1,24 @@ -## APIVersion: 100011 -## Title: LibAddonMenu-2.0 -## Version: 2.0 r17 -## Author: Seerah, sirinsidiator, et al. -## Contributors: votan, merlight, Garkin -## Description: A library to aid in the creation of option panels. - - -LibStub\LibStub.lua - -LibAddonMenu-2.0\LibAddonMenu-2.0.lua - -LibAddonMenu-2.0\controls\panel.lua -LibAddonMenu-2.0\controls\submenu.lua -LibAddonMenu-2.0\controls\button.lua -LibAddonMenu-2.0\controls\checkbox.lua -LibAddonMenu-2.0\controls\colorpicker.lua -LibAddonMenu-2.0\controls\custom.lua -LibAddonMenu-2.0\controls\description.lua -LibAddonMenu-2.0\controls\dropdown.lua -LibAddonMenu-2.0\controls\editbox.lua -LibAddonMenu-2.0\controls\header.lua -LibAddonMenu-2.0\controls\slider.lua -LibAddonMenu-2.0\controls\texture.lua +## APIVersion: 100011 +## Title: LibAddonMenu-2.0 +## Version: 2.0 r17 +## Author: Seerah, sirinsidiator, et al. +## Contributors: votan, merlight, Garkin +## Description: A library to aid in the creation of option panels. + + +LibStub\LibStub.lua + +LibAddonMenu-2.0\LibAddonMenu-2.0.lua + +LibAddonMenu-2.0\controls\panel.lua +LibAddonMenu-2.0\controls\submenu.lua +LibAddonMenu-2.0\controls\button.lua +LibAddonMenu-2.0\controls\checkbox.lua +LibAddonMenu-2.0\controls\colorpicker.lua +LibAddonMenu-2.0\controls\custom.lua +LibAddonMenu-2.0\controls\description.lua +LibAddonMenu-2.0\controls\dropdown.lua +LibAddonMenu-2.0\controls\editbox.lua +LibAddonMenu-2.0\controls\header.lua +LibAddonMenu-2.0\controls\slider.lua +LibAddonMenu-2.0\controls\texture.lua diff --git a/libs/LibAddonMenu/LibStub/LibStub.lua b/libs/LibAddonMenu/LibStub/LibStub.lua index 879d132..4dbff7b 100644 --- a/libs/LibAddonMenu/LibStub/LibStub.lua +++ b/libs/LibAddonMenu/LibStub/LibStub.lua @@ -1,34 +1,34 @@ --- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info --- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke --- LibStub developed for World of Warcraft by above members of the WowAce community. --- Ported to Elder Scrolls Online by Seerah - -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! -local LibStub = _G[LIBSTUB_MAJOR] - -local strformat = string.format -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - function LibStub:NewLibrary(major, minor) - assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") - minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - - local oldminor = self.minors[major] - if oldminor and oldminor >= minor then return nil end - self.minors[major], self.libs[major] = minor, self.libs[major] or {} - return self.libs[major], oldminor - end - - function LibStub:GetLibrary(major, silent) - if not self.libs[major] and not silent then - error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) - end - return self.libs[major], self.minors[major] - end - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +-- LibStub developed for World of Warcraft by above members of the WowAce community. +-- Ported to Elder Scrolls Online by Seerah + +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +local strformat = string.format +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + function LibStub:IterateLibraries() return pairs(self.libs) end + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/libs/LibAddonMenu/exampleoptions.lua b/libs/LibAddonMenu/exampleoptions.lua index 0bb8311..4059b9d 100644 --- a/libs/LibAddonMenu/exampleoptions.lua +++ b/libs/LibAddonMenu/exampleoptions.lua @@ -1,119 +1,119 @@ -local panelData = { - type = "panel", - name = "Window Title", - displayName = "Longer Window Title", - author = "Seerah", - version = "1.3", - slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel - registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) - registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) -} - -local optionsTable = { - [1] = { - type = "header", - name = "My Header", - width = "full", --or "half" (optional) - }, - [2] = { - type = "description", - --title = "My Title", --(optional) - title = nil, --(optional) - text = "My description text to display. blah blah blah blah blah blah blah - even more sample text!!", - width = "full", --or "half" (optional) - }, - [3] = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - getFunc = function() return "of" end, - setFunc = function(var) print(var) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [4] = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - getFunc = function() return "of" end, - setFunc = function(var) print(var) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [5] = { - type = "slider", - name = "My Slider", - tooltip = "Slider's tooltip text.", - min = 0, - max = 20, - step = 1, --(optional) - getFunc = function() return 3 end, - setFunc = function(value) d(value) end, - width = "half", --or "half" (optional) - default = 5, --(optional) - }, - [6] = { - type = "button", - name = "My Button", - tooltip = "Button's tooltip text.", - func = function() d("button pressed!") end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [7] = { - type = "submenu", - name = "Submenu Title", - tooltip = "My submenu tooltip", --(optional) - controls = { - [1] = { - type = "checkbox", - name = "My Checkbox", - tooltip = "Checkbox's tooltip text.", - getFunc = function() return true end, - setFunc = function(value) d(value) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [2] = { - type = "colorpicker", - name = "My Color Picker", - tooltip = "Color Picker's tooltip text.", - getFunc = function() return 1, 0, 0, 1 end, --(alpha is optional) - setFunc = function(r,g,b,a) print(r, g, b, a) end, --(alpha is optional) - width = "half", --or "half" (optional) - warning = "warning text", - }, - [3] = { - type = "editbox", - name = "My Editbox", - tooltip = "Editbox's tooltip text.", - getFunc = function() return "this is some text" end, - setFunc = function(text) print(text) end, - isMultiline = false, --boolean - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - default = "", --(optional) - }, - }, - }, - [8] = { - type = "custom", - reference = "MyAddonCustomControl", --unique name for your control to use as reference - refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh - width = "half", --or "half" (optional) - }, - [9] = { - type = "texture", - image = "EsoUI\\Art\\ActionBar\\abilityframe64_up.dds", - imageWidth = 64, --max of 250 for half width, 510 for full - imageHeight = 64, --max of 100 - tooltip = "Image's tooltip text.", --(optional) - width = "half", --or "half" (optional) - }, -} - -local LAM = LibStub("LibAddonMenu-2.0") -LAM:RegisterAddonPanel("MyAddon", panelData) +local panelData = { + type = "panel", + name = "Window Title", + displayName = "Longer Window Title", + author = "Seerah", + version = "1.3", + slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel + registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) + registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) +} + +local optionsTable = { + [1] = { + type = "header", + name = "My Header", + width = "full", --or "half" (optional) + }, + [2] = { + type = "description", + --title = "My Title", --(optional) + title = nil, --(optional) + text = "My description text to display. blah blah blah blah blah blah blah - even more sample text!!", + width = "full", --or "half" (optional) + }, + [3] = { + type = "dropdown", + name = "My Dropdown", + tooltip = "Dropdown's tooltip text.", + choices = {"table", "of", "choices"}, + getFunc = function() return "of" end, + setFunc = function(var) print(var) end, + width = "half", --or "half" (optional) + warning = "Will need to reload the UI.", --(optional) + }, + [4] = { + type = "dropdown", + name = "My Dropdown", + tooltip = "Dropdown's tooltip text.", + choices = {"table", "of", "choices"}, + getFunc = function() return "of" end, + setFunc = function(var) print(var) end, + width = "half", --or "half" (optional) + warning = "Will need to reload the UI.", --(optional) + }, + [5] = { + type = "slider", + name = "My Slider", + tooltip = "Slider's tooltip text.", + min = 0, + max = 20, + step = 1, --(optional) + getFunc = function() return 3 end, + setFunc = function(value) d(value) end, + width = "half", --or "half" (optional) + default = 5, --(optional) + }, + [6] = { + type = "button", + name = "My Button", + tooltip = "Button's tooltip text.", + func = function() d("button pressed!") end, + width = "half", --or "half" (optional) + warning = "Will need to reload the UI.", --(optional) + }, + [7] = { + type = "submenu", + name = "Submenu Title", + tooltip = "My submenu tooltip", --(optional) + controls = { + [1] = { + type = "checkbox", + name = "My Checkbox", + tooltip = "Checkbox's tooltip text.", + getFunc = function() return true end, + setFunc = function(value) d(value) end, + width = "half", --or "half" (optional) + warning = "Will need to reload the UI.", --(optional) + }, + [2] = { + type = "colorpicker", + name = "My Color Picker", + tooltip = "Color Picker's tooltip text.", + getFunc = function() return 1, 0, 0, 1 end, --(alpha is optional) + setFunc = function(r,g,b,a) print(r, g, b, a) end, --(alpha is optional) + width = "half", --or "half" (optional) + warning = "warning text", + }, + [3] = { + type = "editbox", + name = "My Editbox", + tooltip = "Editbox's tooltip text.", + getFunc = function() return "this is some text" end, + setFunc = function(text) print(text) end, + isMultiline = false, --boolean + width = "half", --or "half" (optional) + warning = "Will need to reload the UI.", --(optional) + default = "", --(optional) + }, + }, + }, + [8] = { + type = "custom", + reference = "MyAddonCustomControl", --unique name for your control to use as reference + refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh + width = "half", --or "half" (optional) + }, + [9] = { + type = "texture", + image = "EsoUI\\Art\\ActionBar\\abilityframe64_up.dds", + imageWidth = 64, --max of 250 for half width, 510 for full + imageHeight = 64, --max of 100 + tooltip = "Image's tooltip text.", --(optional) + width = "half", --or "half" (optional) + }, +} + +local LAM = LibStub("LibAddonMenu-2.0") +LAM:RegisterAddonPanel("MyAddon", panelData) LAM:RegisterOptionControls("MyAddon", optionsTable) \ No newline at end of file diff --git a/libs/LibStub/LibStub.lua b/libs/LibStub/LibStub.lua index 879d132..4dbff7b 100644 --- a/libs/LibStub/LibStub.lua +++ b/libs/LibStub/LibStub.lua @@ -1,34 +1,34 @@ --- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info --- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke --- LibStub developed for World of Warcraft by above members of the WowAce community. --- Ported to Elder Scrolls Online by Seerah - -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! -local LibStub = _G[LIBSTUB_MAJOR] - -local strformat = string.format -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - function LibStub:NewLibrary(major, minor) - assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") - minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - - local oldminor = self.minors[major] - if oldminor and oldminor >= minor then return nil end - self.minors[major], self.libs[major] = minor, self.libs[major] or {} - return self.libs[major], oldminor - end - - function LibStub:GetLibrary(major, silent) - if not self.libs[major] and not silent then - error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) - end - return self.libs[major], self.minors[major] - end - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +-- LibStub developed for World of Warcraft by above members of the WowAce community. +-- Ported to Elder Scrolls Online by Seerah + +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +local strformat = string.format +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + function LibStub:IterateLibraries() return pairs(self.libs) end + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/localization/SI.lua b/localization/SI.lua index 38fc1ce..d64c521 100644 --- a/localization/SI.lua +++ b/localization/SI.lua @@ -1,38 +1,38 @@ -if SI == nil then SI = {} end - --------- -------------------------------------------------------------------- --- Each SI you create you need to register with it with ESO like below ------------------------------------------------------------------------------ -SI.BANKER_NAME = "SI_BANKER_NAME" -SI.HEADER_SETTINGS = "SI_HEADER_SETTINGS" -SI.HEADER_ITEM_TYPES = "SI_HEADER_ITEM_TYPES" -SI.WARNING_ITEM_TYPES = "SI_WARNING_ITEM_TYPES" -SI.DESC_MAIN = "SI_DESC_MAIN" -SI.DESC_MAIN_TITLE = "SI_DESC_MAIN_TITLE" -SI.HEADER_DEVELOPER="SI_HEADER_DEVELOPER" -SI.TITLE_DEBUG="SI_TITLE_DEBUG" -SI.WARNING_DEVELOPER="SI_WARNING_DEVELOPER" -SI.ITEMTYPE_TITLE="SI_ITEMTYPE_TITLE" -SI.ITEMTYPE_DESC="SI_ITEMTYPE_DESC" -SI.COMMON_TITLE="SI_COMMON_TITLE" -SI.COMMON_DESC="SI_COMMON_DESC" -SI.MIN_TITLE="SI_TITLE_MIN" -SI.STEP_TITLE="SI_TITLE_STEP" -SI.EITEMS_TITLE="SI_TITLE_EITEMS" -SI.EMONEY_TITLE="SI_TITLE_EMONEY" -SI.MSG_TITLE="SI_TITLE_MSG" -SI.DEBUG_TITLE="SI_TITLE_DEBUG" -SI.KB_TITLE="SI_KB_TITLE" -SI.KB_SYNC_ITEMS="SI_KB_SYNC_ITEMS" -SI.KB_SAFE_MONEY="SI_KB_SAFE_MONEY" -SI.BINDING_NAME_SYNC_INVENTORY="SI_BINDING_NAME_SYNC_INVENTORY" -SI.BINDING_NAME_AUTO_DEPOSIT_MONEY="SI_BINDING_NAME_AUTO_DEPOSIT_MONEY" - --- utility functions -SI.get = function(key, n) - assert(key ~= nil) - return assert(GetString(_G[key], n)) -end - ----- Your global sampleApp var from SampleApp.lua. We're setting it to SI here. +if SI == nil then SI = {} end + +-------- -------------------------------------------------------------------- +-- Each SI you create you need to register with it with ESO like below +----------------------------------------------------------------------------- +SI.BANKER_NAME = "SI_BANKER_NAME" +SI.HEADER_SETTINGS = "SI_HEADER_SETTINGS" +SI.HEADER_ITEM_TYPES = "SI_HEADER_ITEM_TYPES" +SI.WARNING_ITEM_TYPES = "SI_WARNING_ITEM_TYPES" +SI.DESC_MAIN = "SI_DESC_MAIN" +SI.DESC_MAIN_TITLE = "SI_DESC_MAIN_TITLE" +SI.HEADER_DEVELOPER="SI_HEADER_DEVELOPER" +SI.TITLE_DEBUG="SI_TITLE_DEBUG" +SI.WARNING_DEVELOPER="SI_WARNING_DEVELOPER" +SI.ITEMTYPE_TITLE="SI_ITEMTYPE_TITLE" +SI.ITEMTYPE_DESC="SI_ITEMTYPE_DESC" +SI.COMMON_TITLE="SI_COMMON_TITLE" +SI.COMMON_DESC="SI_COMMON_DESC" +SI.MIN_TITLE="SI_TITLE_MIN" +SI.STEP_TITLE="SI_TITLE_STEP" +SI.EITEMS_TITLE="SI_TITLE_EITEMS" +SI.EMONEY_TITLE="SI_TITLE_EMONEY" +SI.MSG_TITLE="SI_TITLE_MSG" +SI.DEBUG_TITLE="SI_TITLE_DEBUG" +SI.KB_TITLE="SI_KB_TITLE" +SI.KB_SYNC_ITEMS="SI_KB_SYNC_ITEMS" +SI.KB_SAFE_MONEY="SI_KB_SAFE_MONEY" +SI.BINDING_NAME_SYNC_INVENTORY="SI_BINDING_NAME_SYNC_INVENTORY" +SI.BINDING_NAME_AUTO_DEPOSIT_MONEY="SI_BINDING_NAME_AUTO_DEPOSIT_MONEY" + +-- utility functions +SI.get = function(key, n) + assert(key ~= nil) + return assert(GetString(_G[key], n)) +end + +---- Your global sampleApp var from SampleApp.lua. We're setting it to SI here. Banker.SI = SI \ No newline at end of file diff --git a/localization/de.lua b/localization/de.lua index afc717b..ac1b409 100644 --- a/localization/de.lua +++ b/localization/de.lua @@ -1,24 +1,24 @@ -ZO_CreateStringId(Banker.SI.BANKER_NAME, "Bankier") -ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Beschreibung") -ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "ItemTypen") -ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "Stelle auf Ein um Items von diesem Typ automatisch in die Bank zu transferieren,falls das Item schon in der Bank liegt.") -ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Beschreibung") -ZO_CreateStringId(Banker.SI.DESC_MAIN, "Banker ist eine Mod, die dir hilft dein Inventar aufzur\195\164umen.Daf\195\188 r werden Items in deine Bank verschoben, die bereits vorhanden sind.") -ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Entwickler Einstellung") -ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") -ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Itemtype Description") -ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Zeige Debug-Informationen") -ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Allgemeine Einstellungen") -ZO_CreateStringId(Banker.SI.COMMON_DESC, "") -ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Wenn du nicht wei�t was diese Option macht, dann lass die Finger davon.") -ZO_CreateStringId(Banker.SI.MIN_TITLE, "Gold Minimum") -ZO_CreateStringId(Banker.SI.STEP_TITLE, "Schritt") -ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Item-Transfer") -ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Money-Transfer") -ZO_CreateStringId(Banker.SI.MSG_TITLE, "Zeige Chat-Nachrichten") -ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Zeige Debug-Nachrichten") -ZO_CreateStringId(Banker.SI.KB_TITLE, "Zeige Shortcut") -ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Synchronisiere Bank und Tasche") -ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Geldeinzahlen") -ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Synchronisiere Bank und Tasche") +ZO_CreateStringId(Banker.SI.BANKER_NAME, "Bankier") +ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Beschreibung") +ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "ItemTypen") +ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "Stelle auf Ein um Items von diesem Typ automatisch in die Bank zu transferieren,falls das Item schon in der Bank liegt.") +ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Beschreibung") +ZO_CreateStringId(Banker.SI.DESC_MAIN, "Banker ist eine Mod, die dir hilft dein Inventar aufzur\195\164umen.Daf\195\188 r werden Items in deine Bank verschoben, die bereits vorhanden sind.") +ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Entwickler Einstellung") +ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") +ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Itemtype Description") +ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Zeige Debug-Informationen") +ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Allgemeine Einstellungen") +ZO_CreateStringId(Banker.SI.COMMON_DESC, "") +ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Wenn du nicht wei�t was diese Option macht, dann lass die Finger davon.") +ZO_CreateStringId(Banker.SI.MIN_TITLE, "Gold Minimum") +ZO_CreateStringId(Banker.SI.STEP_TITLE, "Schritt") +ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Item-Transfer") +ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Money-Transfer") +ZO_CreateStringId(Banker.SI.MSG_TITLE, "Zeige Chat-Nachrichten") +ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Zeige Debug-Nachrichten") +ZO_CreateStringId(Banker.SI.KB_TITLE, "Zeige Shortcut") +ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Synchronisiere Bank und Tasche") +ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Geldeinzahlen") +ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Synchronisiere Bank und Tasche") ZO_CreateStringId(Banker.SI.BINDING_NAME_AUTO_DEPOSIT_MONEY, "Geldeinzahlen") \ No newline at end of file diff --git a/localization/en.lua b/localization/en.lua index 986060d..1eaa340 100644 --- a/localization/en.lua +++ b/localization/en.lua @@ -1,24 +1,24 @@ -ZO_CreateStringId(Banker.SI.BANKER_NAME, "Banker") -ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Description") -ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "ItemTypen") -ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "If this is true it will transfer automatic items from your inventory to your bank.") -ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Description") -ZO_CreateStringId(Banker.SI.DESC_MAIN, "Banker helps you to keep your inventory clean.") -ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Developer Settings") -ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") -ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Filter which Itemtypes should tranferd to your bank.") -ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Show Debug-Information") -ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Common Settings") -ZO_CreateStringId(Banker.SI.COMMON_DESC, "") -ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Do not change anything here, unless you know what you do.") -- Sorry for my bad english -ZO_CreateStringId(Banker.SI.MIN_TITLE, "Gold-Minimum") -ZO_CreateStringId(Banker.SI.STEP_TITLE, "Step") -ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Item-Transfer") -ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Money-Transfer") -ZO_CreateStringId(Banker.SI.MSG_TITLE, "Show Chat-Messages") -ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Show Debug-Messages") -ZO_CreateStringId(Banker.SI.KB_TITLE, "Show Shortcut") -ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Transfer Items") -ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Deposit Gold") -ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Transfer Items") +ZO_CreateStringId(Banker.SI.BANKER_NAME, "Banker") +ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Description") +ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "ItemTypen") +ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "If this is true it will transfer automatic items from your inventory to your bank.") +ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Description") +ZO_CreateStringId(Banker.SI.DESC_MAIN, "Banker helps you to keep your inventory clean.") +ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Developer Settings") +ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") +ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Filter which Itemtypes should tranferd to your bank.") +ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Show Debug-Information") +ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Common Settings") +ZO_CreateStringId(Banker.SI.COMMON_DESC, "") +ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Do not change anything here, unless you know what you do.") -- Sorry for my bad english +ZO_CreateStringId(Banker.SI.MIN_TITLE, "Gold-Minimum") +ZO_CreateStringId(Banker.SI.STEP_TITLE, "Step") +ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Item-Transfer") +ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Money-Transfer") +ZO_CreateStringId(Banker.SI.MSG_TITLE, "Show Chat-Messages") +ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Show Debug-Messages") +ZO_CreateStringId(Banker.SI.KB_TITLE, "Show Shortcut") +ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Transfer Items") +ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Deposit Gold") +ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Transfer Items") ZO_CreateStringId(Banker.SI.BINDING_NAME_AUTO_DEPOSIT_MONEY, "Deposit Gold") \ No newline at end of file diff --git a/localization/fr.lua b/localization/fr.lua index bc36296..8fc76ee 100644 --- a/localization/fr.lua +++ b/localization/fr.lua @@ -1,28 +1,28 @@ --- French Tranlation by MrOsmose --- (C) 13 May 2014 --- If you can do better send me a pm - -ZO_CreateStringId(Banker.SI.BANKER_NAME, "Banquier") -ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Description") -ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "Type d'objet") -ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "If this is true it will transfer automatic items from your inventory to your bank.") -ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Description") -ZO_CreateStringId(Banker.SI.DESC_MAIN, "Ce mod vous aide � garder votre inventaire propre, en transf�rant automatiquement les objets d�j� sotck� dans votre boite de d�pot.") -ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Configuration d�veloppeur") -ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") -ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Filter which Itemtypes should tranferd to your bank.") -ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Montrer les informations de Debug") -ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Common Settings") -ZO_CreateStringId(Banker.SI.COMMON_DESC, "") -ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Activez pour transf�rer les objets d�j� rang� de ce type dans votre boite de d�pot.") -ZO_CreateStringId(Banker.SI.MIN_TITLE, "Minimum d'Or") -ZO_CreateStringId(Banker.SI.STEP_TITLE, "Step") -ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Transfer d'objets") -ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Transfer d'argent") -ZO_CreateStringId(Banker.SI.MSG_TITLE, "Montrer les messages de discussion") -ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Show Debug-Message") -ZO_CreateStringId(Banker.SI.KB_TITLE, "Show Shortcut") -ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Transfer d'objets") -ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Transfer d'argent") -ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Transfer d'objets") +-- French Tranlation by MrOsmose +-- (C) 13 May 2014 +-- If you can do better send me a pm + +ZO_CreateStringId(Banker.SI.BANKER_NAME, "Banquier") +ZO_CreateStringId(Banker.SI.HEADER_SETTINGS, "Description") +ZO_CreateStringId(Banker.SI.HEADER_ITEM_TYPES, "Type d'objet") +ZO_CreateStringId(Banker.SI.WARNING_ITEM_TYPES, "If this is true it will transfer automatic items from your inventory to your bank.") +ZO_CreateStringId(Banker.SI.DESC_MAIN_TITLE, "Description") +ZO_CreateStringId(Banker.SI.DESC_MAIN, "Ce mod vous aide � garder votre inventaire propre, en transf�rant automatiquement les objets d�j� sotck� dans votre boite de d�pot.") +ZO_CreateStringId(Banker.SI.HEADER_DEVELOPER, "Configuration d�veloppeur") +ZO_CreateStringId(Banker.SI.ITEMTYPE_TITLE, "Itemtype") +ZO_CreateStringId(Banker.SI.ITEMTYPE_DESC, "Filter which Itemtypes should tranferd to your bank.") +ZO_CreateStringId(Banker.SI.TITLE_DEBUG, "Montrer les informations de Debug") +ZO_CreateStringId(Banker.SI.COMMON_TITLE, "Common Settings") +ZO_CreateStringId(Banker.SI.COMMON_DESC, "") +ZO_CreateStringId(Banker.SI.WARNING_DEVELOPER, "Activez pour transf�rer les objets d�j� rang� de ce type dans votre boite de d�pot.") +ZO_CreateStringId(Banker.SI.MIN_TITLE, "Minimum d'Or") +ZO_CreateStringId(Banker.SI.STEP_TITLE, "Step") +ZO_CreateStringId(Banker.SI.EITEMS_TITLE, "Transfer d'objets") +ZO_CreateStringId(Banker.SI.EMONEY_TITLE, "Transfer d'argent") +ZO_CreateStringId(Banker.SI.MSG_TITLE, "Montrer les messages de discussion") +ZO_CreateStringId(Banker.SI.DEBUG_TITLE, "Show Debug-Message") +ZO_CreateStringId(Banker.SI.KB_TITLE, "Show Shortcut") +ZO_CreateStringId(Banker.SI.KB_SYNC_ITEMS, "Transfer d'objets") +ZO_CreateStringId(Banker.SI.KB_SAFE_MONEY, "Transfer d'argent") +ZO_CreateStringId(Banker.SI.BINDING_NAME_SYNC_INVENTORY, "Transfer d'objets") ZO_CreateStringId(Banker.SI.BINDING_NAME_AUTO_DEPOSIT_MONEY, "Transfer d'argent") \ No newline at end of file