06/13/21, 03:52 PM | #1 |
|
How to two columns in ZO_ScrollList?
Hi there,
I am very new (2 days) to the LUA AddOn development. I want to make an addon which shows me the cloth related materials and how much i have in stock. Its for my old brain to know what I still have to buy for my crafting cause i am low on stockitems. So far i have managed this (see Attachment). A lot of examples and reading and try and error... Last thing i want to do: How can i get the data in 2 columns? At the moment i add the Data via a DataType from an array to the xml in a ZO_ScrollList control. I use a simple string concatenate Any help would be very appreciated! Relevant parts from the lua Code:
function Crafty.CreateScrollListDataType() d("Crafty: CreateScrollListDataType") local control = CraftyListList local typeId = 1 local templateName = "ZO_SelectableLabel" local height = 25 -- height of the row, not the window local setupFunction = Crafty.LayoutRow local hideCallback = nil local dataTypeSelectSound = nil local resetControlCallback = nil local selectTemplate = "ZO_ThinListHighlight" local selectCallback = Crafty.OnRowSelect ZO_ScrollList_AddDataType(control, typeId, templateName, height, setupFunction, hideCallback, dataTypeSelectSound, resetControlCallback) --ZO_ScrollList_EnableSelection(control, selectTemplate, selectCallback) end function Crafty.Populate() d("Crafty: Populate") local stock = {} local stockcounter = 0 for index, data in pairs(SHARED_INVENTORY.bagCache[BAG_VIRTUAL]) do if data ~= nil then if GetItemCraftingInfo(BAG_VIRTUAL,data.slotIndex) == 2 then stockcounter = stockcounter + 1 stock[stockcounter] = { link = GetItemLink(BAG_VIRTUAL,data.slotIndex), name = GetItemName(BAG_VIRTUAL,data.slotIndex), amount = GetSlotStackSize(BAG_VIRTUAL,data.slotIndex), cinfo = GetItemCraftingInfo(BAG_VIRTUAL,data.slotIndex) } end end end return stock end function Crafty.UpdateScrollList(control, data, rowType) d("Crafty: UpdateScrollList") local dataCopy = ZO_DeepTableCopy(data) local dataList = ZO_ScrollList_GetDataList(control) ZO_ScrollList_Clear(control) for key, value in ipairs(dataCopy) do local entry = ZO_ScrollList_CreateDataEntry(rowType, value) table.insert(dataList, entry) end table.sort(dataList, function(a,b) return a.data.name < b.data.name end) ZO_ScrollList_Commit(control) end function Crafty.LayoutRow(rowControl, data, scrollList) --d("Crafty: LayoutRow") rowControl:SetFont("ZoFontWinH4") rowControl:SetMaxLineCount(1) rowControl:SetText(data.link.." / "..data.amount) rowControl:SetHandler("OnMouseUp", function() ZO_ScrollList_MouseClick(scrollList, rowControl) end) end Code:
<GuiXml> <Controls> <TopLevelControl name="CraftyList" hidden="false" mouseEnabled="true" movable="true" clampedToScreen="true"> <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="BOTTOM" offsetX="0" offsetY="-128"/> <OnMoveStop> Crafty.OnIndicatorMoveStop() </OnMoveStop> <Dimensions x="300" y="400" /> <Controls> <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" /> <Button name="$(parent)ButtonClose" inherits="ZO_ButtonBehaviorClickSound"> <Dimensions x="30" y="30" /> <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="5" offsetY="5" /> <Textures normal="EsoUI/Art/Buttons/closebutton_up.dds" pressed="EsoUI/Art/Buttons/closebutton_down.dds" mouseOver="EsoUI/Art/Buttons/closebutton_mouseover.dds" disabled="EsoUI/Art/Buttons/closebutton_disabled.dds"/> <OnClicked> Crafty.UpdateScrollList() </OnClicked> </Button> <Button name="$(parent)ButtonRrefresh" inherits="ZO_ButtonBehaviorClickSound"> <Dimensions x="30" y="30" /> <Anchor point="TOPRIGHT" relativeTo="$(parent)ButtonClose" relativePoint="TOPLEFT" offsetX="-5" offsetY="-2" /> <Textures normal="EsoUI/Art/Buttons/downarrow_up.dds" pressed="EsoUI/Art/Buttons/downarrow_down.dds" mouseOver="EsoUI/Art/Buttons/downarrow_over.dds" disabled="EsoUI/Art/Buttons/downarrow_disabled.dds"/> <OnClicked> Crafty.UpdateScrollList() </OnClicked> </Button> <Label name="$(parent)Title" font="ZoFontGameLargeBold" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="STOCKLIST"> <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="10" offsetY="10"/> </Label> <Label name="$(parent)Heading" font="ZoFontGameLargeBold" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Itemname / Stockamount"> <Anchor point="TOPLEFT" relativeTo="$(parent)Title" relativePoint="BOTTOMLEFT" offsetX="0" offsetY="10"/> </Label> <Texture name="$(parent)Divider" textureFile="/esoui/art/miscellaneous/horizontaldivider.dds" tier="HIGH"> <Dimensions x="300" y="4"/> <Anchor point="TOPLEFT" relativeTo="$(parent)Heading" relativePoint="BOTTOMLEFT" offsetY="10" /> </Texture> <Control name="$(parent)List" inherits="ZO_ScrollList"> <Anchor point="TOPLEFT" relativeTo="$(parent)Divider" relativePoint="BOTTOMLEFT" offsetY="10" /> <Anchor point="BOTTOMRIGHT" offsetX="-10" offsetY="-10" /> </Control> </Controls> </TopLevelControl> </Controls> </GuiXml> |
ESOUI » Developer Discussions » Lua/XML Help » How to two columns in ZO_ScrollList? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|