ESOUI SVN ESOutpost

[/] [trunk/] [ESOutpost/] [GUI.lua] - Rev 5

Go to most recent revision | Compare with Previous | Blame | View Log

-- ESOutpost © ZAM Network LLC
-- All Rights Reserved

local wm = WINDOW_MANAGER
local M = ESOutpostMaps


local gui = wm:CreateTopLevelWindow("ESOutpostGUI")
gui:SetDimensions(525, 350)
gui:SetAnchor(CENTER)
gui:SetClampedToScreen(true)
gui:SetClampedToScreenInsets(-425, -15, 5, 5)   --width of tooltip frame on left == 416
gui:SetMouseEnabled(true)
gui:SetMovable(true)
gui:SetHandler("OnReceiveDrag", function(self)
                self:StartMoving()
        end)
gui:SetHandler("OnMouseUp", function(self)
                self:StopMovingOrResizing()
        end)
gui.bg = wm:CreateControlFromVirtual("ESOutpostBG", gui, "ZO_DefaultBackdrop")

gui.bg.watermark = wm:CreateControl(nil, gui.bg, CT_TEXTURE)
gui.bg.watermark:SetDimensions(300, 300)
gui.bg.watermark:SetAnchor(CENTER)
gui.bg.watermark:SetTexture("ESOutpost\\ESO-Outpost-Logo.dds")
gui.bg.watermark:SetAlpha(.3)

gui.title = wm:CreateControl(nil, gui, CT_LABEL)
gui.title:SetFont("ZoFontCallout")
gui.title:SetAnchor(TOP)
--local textIcon = "|t40:40:ESOutpost\\ESO-Outpost-Logo.dds|t"
--local colorHex = "c5c29e"
--gui.title:SetText(string.format("%s |c%sESO|rutpost", textIcon, colorHex))
gui.title:SetText("|cC5C29EESO|rutpost")

gui.icon = wm:CreateControl(nil, gui, CT_TEXTURE)
gui.icon:SetAnchor(TOPLEFT, gui, TOPLEFT, 15, 70)
gui.icon:SetDimensions(100, 100)
gui.icon:SetTexture("EsoUI\\Art\\ActionBar\\abilityframe64_up.dds")
gui.icon.texture = wm:CreateControl(nil, gui.icon, CT_TEXTURE)
gui.icon.texture:SetDimensions(90, 90)
gui.icon.texture:SetAnchor(CENTER)

gui.name = wm:CreateControl(nil, gui, CT_LABEL)
gui.name:SetFont("ZoFontHeader4")
gui.name:SetAnchor(TOPLEFT, gui.icon, TOPRIGHT, 20, 0)
gui.name:SetDimensions(365, 32)
gui.name:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS)

gui.lvl = wm:CreateControl(nil, gui, CT_LABEL)
gui.lvl:SetFont("ZoFontHeader2")
gui.lvl:SetHeight(26)
gui.lvl:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS)
gui.lvl:SetAnchor(TOPLEFT, gui.name, BOTTOMLEFT, 0, 6)
gui.lvl:SetText("Level")

gui.lvlNumbg = wm:CreateControlFromVirtual("ESOutpostLevelBG", gui, "ZO_EditBackdrop")
gui.lvlNumbg:SetDimensions(33, 28)
gui.lvlNumbg:SetAnchor(LEFT, gui.lvl, RIGHT, 5, 0)
gui.lvlNum = wm:CreateControlFromVirtual("ESOutpostLevel", gui.lvlNumbg, "ZO_DefaultEditForBackdrop")
gui.lvlNum:SetTextType(TEXT_TYPE_NUMERIC)
gui.lvlNum.tooltipText = "Please confirm the level of the item as stated in the tooltip.\nOccasionally, this information as given by the API to ESOutpost is incorrect.\nIf the item has no level, this number should be 0."
gui.lvlNum:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.lvlNum:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.lvlNum:SetHandler("OnEscape", gui.lvlNum.LoseFocus)
gui.lvlNum:SetHandler("OnTab", function()
                if not gui.traitValue:IsHidden() then
                        gui.traitValue:TakeFocus()
                elseif not gui.enchantValueX:IsHidden() then
                        gui.enchantValueX:TakeFocus()
                end
        end)

--[[gui.staffType = wm:CreateControlFromVirtual("ESOutpostStaffType", gui, "ZO_StatsDropdownRow")
gui.staffType:SetAnchor(LEFT, gui.lvlNumbg, RIGHT, 10, 0)
gui.staffType:SetWidth(103)
local staffdrop = gui.staffType:GetNamedChild("Dropdown")
staffdrop:SetWidth(103)
local function OnItemSelect(_, choiceText, choice)
        gui.staffType.hash = M.staffTypes.hash[choiceText]
end
local types = ESOutpostMaps.staffTypes.text
for i=1,#types do
        local entry = gui.staffType.dropdown:CreateItemEntry(types[i], OnItemSelect)
        gui.staffType.dropdown:AddItem(entry, ZO_COMBOBOX_SUPRESS_UPDATE)
end
staffdrop.tooltipText = "Please select your staff type."
staffdrop:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
staffdrop:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.staffType.dropdown:SetSelectedItem("Type")]]

gui.type = wm:CreateControl(nil, gui, CT_LABEL)
gui.type:SetFont("ZoFontHeader2")
gui.type:SetHeight(26)
--gui.type:SetAnchor(LEFT, gui.staffType, RIGHT, 10, 1)
gui.type:SetAnchor(LEFT, gui.lvlNumbg, RIGHT, 15, 1)
gui.type:SetAnchor(TOPRIGHT, gui.name, BOTTOMRIGHT, 0, 6)
gui.type:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS)

gui.statValue = wm:CreateControl(nil, gui, CT_LABEL)
gui.statValue:SetFont("ZoFontHeader2")
gui.statValue:SetAnchor(TOPLEFT, gui.lvl, BOTTOMLEFT, 0, 6)
gui.statValue:SetHeight(26)
gui.statValue:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS)

gui.trait = wm:CreateControl(nil, gui, CT_LABEL)
gui.trait:SetFont("ZoFontHeader2")
gui.trait:SetAnchor(LEFT, gui.statValue, RIGHT, 20, 0)
gui.trait:SetHeight(26)
gui.trait:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS)

gui.traitValuebg = wm:CreateControlFromVirtual("ESOutpostTraitValueBG", gui, "ZO_EditBackdrop")
gui.traitValuebg:SetDimensions(50, 28)
gui.traitValuebg:SetAnchor(LEFT, gui.trait, RIGHT, 10, 0)
gui.traitValue = wm:CreateControlFromVirtual("ESOutpostTraitValue", gui.traitValuebg, "ZO_DefaultEditForBackdrop")
gui.traitValue:SetTextType(TEXT_TYPE_NUMERIC)
gui.traitValue.tooltipText = "Please enter the amount of the trait's effect.\nThis is a |cFFFFFFwhite|r number, found in the item's tooltip in the item trait description."
gui.traitValue:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.traitValue:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.traitValue:SetHandler("OnTab", function()
                if not gui.enchantValueX:IsHidden() then
                        gui.enchantValueX:TakeFocus()
                end
        end)

gui.enchant = wm:CreateControlFromVirtual("ESOutpostEnchant", gui, "ZO_StatsDropdownRow")
gui.enchant:SetAnchor(TOPLEFT, gui.icon, BOTTOMLEFT, 0, 15)
gui.enchant:SetWidth(350)
local enchantdrop = gui.enchant:GetNamedChild("Dropdown")
enchantdrop:SetWidth(350)
gui.enchant.callback = function(_, choiceText, choice)
        gui.enchant.type = choiceText
        gui.enchant.hash = choice.hash
        if choice.vars == 0 then
                gui.enchantValueXbg:SetHidden(true)
                gui.enchantValueYbg:SetHidden(true)
        else
                gui.enchantValueXbg:SetHidden(false)
                gui.enchantValueYbg:SetHidden(choice.vars ~= 2)
                gui.enchantValueX:SetText("")
                gui.enchantValueY:SetText("")
        end
end
enchantdrop.tooltipText = 'Please select the enchant on your item.\nIf your item is not enchanted, select "None".'
enchantdrop:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
enchantdrop:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.enchant.dropdown:SetSelectedItem("Select Enchant")

gui.locked = wm:CreateControl("ESOutpostLock", gui.enchant, CT_TEXTURE)
gui.locked:SetDimensions(16, 16)
gui.locked:SetTexture("EsoUI\\Art\\Miscellaneous\\locked_up.dds")
gui.locked:SetAnchor(LEFT, gui.enchant, RIGHT, 10, 0)

gui.enchantValueXbg = wm:CreateControlFromVirtual("ESOutpostEnchantValueXBG", gui, "ZO_EditBackdrop")
gui.enchantValueXbg:SetDimensions(40, 28)
gui.enchantValueXbg:SetAnchor(LEFT, gui.locked, RIGHT, 10, 0)
gui.enchantValueX = wm:CreateControlFromVirtual("ESOutpostEnchantValueX", gui.enchantValueXbg, "ZO_DefaultEditForBackdrop")
gui.enchantValueX:SetTextType(TEXT_TYPE_NUMERIC)
gui.enchantValueX.tooltipText = "Please enter the value of |cFFFFFF<x>|r.\nThis is a |cFFFFFFwhite|r number in the enchant text, found in the item's tooltip."
gui.enchantValueX:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.enchantValueX:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.enchantValueX:SetHandler("OnEscape", gui.enchantValueX.LoseFocus)
gui.traitValue:SetHandler("OnTab", function()
                if not gui.enchantValueY:IsHidden() then
                        gui.enchantValueY:TakeFocus()
                end
        end)

gui.enchantValueYbg = wm:CreateControlFromVirtual("ESOutpostEnchantValueYBG", gui, "ZO_EditBackdrop")
gui.enchantValueYbg:SetDimensions(40, 28)
gui.enchantValueYbg:SetAnchor(LEFT, gui.enchantValueX, RIGHT, 15, -1)
gui.enchantValueY = wm:CreateControlFromVirtual("ESOutpostEnchantValueY", gui.enchantValueYbg, "ZO_DefaultEditForBackdrop")
gui.enchantValueY:SetTextType(TEXT_TYPE_NUMERIC)
gui.enchantValueY.tooltipText = "Please enter the value of |cFFFFFF<y>|r.\nThis is a |cFFFFFFwhite|r number in the enchant text, found in the item's tooltip."
gui.enchantValueY:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.enchantValueY:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.enchantValueY:SetHandler("OnEscape", gui.enchantValueY.LoseFocus)

gui.generate = wm:CreateControlFromVirtual("ESOutpostGenerate", gui, "ZO_DefaultButton")
gui.generate:SetAnchor(BOTTOM, gui, BOTTOM, 0, -75)
gui.generate:SetDimensions(400, 32)
gui.generate:SetText("Generate Merchandise Appraisal String")
gui.generate.tooltipText = "Click to generate your Appraisal String after ensuring all information is correct."
gui.generate:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.generate:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)

gui.genstringbg = wm:CreateControlFromVirtual("ESOutpostGeneratedStringBG", gui, "ZO_EditBackdrop")
gui.genstringbg:SetDimensions(475, 30)
gui.genstringbg:SetAnchor(BOTTOMLEFT, gui, BOTTOMLEFT, 15, -20)
gui.genstringbg:SetAnchor(BOTTOMRIGHT, gui, BOTTOMRIGHT, -65, -20)
gui.genstring = wm:CreateControlFromVirtual("ESOutpostGeneratedString", gui.genstringbg, "ZO_DefaultEditForBackdrop")
gui.genstring:SetMaxInputChars(1000)
gui.genstring.tooltipText = "Copy this text to your clipboard using the |cFFFFFFCopy|r button, then paste your Appraisal String at |cFFFFFFESOutpost.com|r"
gui.genstring:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
gui.genstring:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
gui.genstring:SetHandler("OnEscape", gui.genstring.LoseFocus)
gui.genstring:SetCopyEnabled(true)
gui.genstring:SetEditEnabled(false)

gui.copy = wm:CreateControlFromVirtual("ESOutpostCopy", gui, "ZO_DefaultTextButton")
gui.copy:SetWidth(50)
gui.copy:SetAnchor(BOTTOMRIGHT, gui, BOTTOMRIGHT, -15, -20)
gui.copy:SetText("Copy")
gui.copy:SetHandler("OnClicked", function()
                gui.genstring:CopyAllTextToClipboard()
                ZO_Alert(nil, SOUNDS.SKILL_GAINED, "|cC5C29EESO|rutpost: Copied to clipboard.")
        end)

gui.close = wm:CreateControlFromVirtual("ESOutpostClose", gui, "ZO_CloseButton")
gui.close:SetHandler("OnClicked", function() gui:SetHidden(true) end)

gui.tooltip = wm:CreateControlFromVirtual("ESOutpostTooltip", gui, "ZO_ItemIconTooltip")
gui.tooltip:ClearAnchors()
gui.tooltip:SetAnchor(TOPRIGHT, gui, TOPLEFT, -10, -8)
gui.tooltip:SetHidden(false)

gui:SetHidden(true)


------------


local buttonPool
local function CreateButton(buttonPool)
        local button = ZO_ObjectPool_CreateControl("ESOutpostItemButton", buttonPool, GuiRoot)
        button.outpostBtn = true
        button.tooltipText = "ESOutpost"
        button:SetHandler("OnClicked", CollectESOutpostItemData)
        button:SetHandler("OnMouseEnter", function(...)
                        local anim = button.row:GetNamedChild("Highlight").animation
                        if anim then
                                anim:PlayInstantlyToEnd()
                        end
                        ZO_Options_OnMouseEnter(...)
                end)
        button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
        return button
end

local function RemoveButton(button)
        button:SetHidden(true)
        button.row.outpostIcon = nil
end

function gui:CreateInventoryButtons()
        ESOutpostDB = ESOutpostDB or {icons = true}
        local db = ESOutpostDB

        if not buttonPool then
                buttonPool = ZO_ObjectPool:New(CreateButton, RemoveButton)
        end
        
        local inventories = PLAYER_INVENTORY.inventories
        local origCallback
        local function newCallback(row, slot, ...)
                origCallback(row, slot, ...)
                if db.icons then
                        local itemData = row.dataEntry.data
                        if not IsItemBound(itemData.bagId, itemData.slotIndex) then
                                if not row.outpostIcon then
                                        local button, key = buttonPool:AcquireObject()
                                        local rowLabel = row:GetNamedChild("Name")
                                        button:SetParent(rowLabel)
                                        button:ClearAnchors()
                                        button:SetAnchor(LEFT, rowLabel, RIGHT)
                                        button:SetHidden(false)
                                        row.outpostIcon = button
                                        button.row = row
                                        button.key = key
                                end
                        else
                                if row.outpostIcon then
                                        buttonPool:ReleaseObject(row.outpostIcon.key)
                                end
                        end
                end
        end
        for i = 1, #inventories do
                local inventoryView = inventories[i].listView
                --skip this - only want backpack, bank and guild bank
                if inventoryView ~= ZO_PlayerInventoryQuest then
                        --find the callback function for updating inventory rows
                        local callback = inventoryView.dataTypes[1].setupCallback
                        origCallback = callback
                        --overwrite it to have our post-hook
                        inventoryView.dataTypes[1].setupCallback = newCallback
                end
        end
        
        SLASH_COMMANDS["/esoutpost"] = function()
                        db.icons = not db.icons
                        if db.icons then
                                buttonPool:ReleaseAllObjects()
                        end
                end
end

Go to most recent revision | Compare with Previous | Blame