|Go to Page...|
|Thread Tools||Display Modes|
|03/24/21, 02:11 PM||#1|
Creating a scrollable XML "list control" and adding data via LUA
How would I go about creating a scrollable XML list control that can have items added to it. I am trying to simply add a text entry to a list via LUA, and then display them into the XML list window when it is visible.
There is an addon which has a great looking history window that I would like to recreate in some form:
I really appreciate any help.
Last edited by scorpius2k1 : 03/24/21 at 02:22 PM.
|03/24/21, 02:28 PM||#2|
@votan73 (EU - megaserver)
|03/25/21, 03:47 AM||#3|
My answer from my pm to you (seems I wasn't fast enough ):
ZO_SortFilterList is a base class you can reuse here but I also always have to look at what is needed.
XML is needed to define header controls for the sortheaders, a "List" control to show the lines and scrollbar, and so on.
I think there is a library by Circonian which was aiding here, but I do not know if it still works.
Start small and try to understand the whole ZO_SortFilterList.
I think this will be better to do than using Circonian's library. Who knows what ZOs will change and if the libs till works or will work soon...
See my example below.
It basically eased the usage of the ZO class functions and provided an API to create such lists.
I've never used it. MAybe there is a wiki example how to create such lists somewhere...
Didn't find any
Else it is try and error + read ZOs code at github e.g.
Use the forum search:
Search for ZO_SortFilterList or ZO_SortList or similar to find threads about it, getting some more info.
All I can help you with is give a short introduction. Have a look at the addon WishList -> WishList_window.lua
At the top the subclass of the ZO_SortFilterList will be defined:
<Controls> <!-- Virtual labels --> <Label name="WishListRowLabel" font="MyFontGame16" wrapMode="ELLIPSIS" horizontalAlignment="LEFT" verticalAlignment="CENTER" virtual="true" > </Label> <!--Sort headers --> <Control name="WhisListSortHeader" inherits="ZO_SortHeaderBehavior" virtual="true"> <Controls> <Label name="$(parent)Name" font="MyFontGame20" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_NORMAL" horizontalAlignment="CENTER" verticalAlignment="CENTER" wrapMode="ELLIPSIS"> <AnchorFill /> </Label> </Controls> </Control> <!-- Virtual Rows --> <Control name="WishListRow" mouseEnabled="true" virtual="true"> ...
having some of the sort header controls (using the virtuals defined at top as template) and then the <list control is below, where the ZO_SortFilterList will be loaded into via the lua code in WishList_window.lua:
<!-- Frame/Window --> <TopLevelControl name="WishListFrame" inherits="ZO_RightPanelFootPrint" hidden="true"> <Controls> ... search box here and backdrop of editbox etc. Sort headers: <Control name="$(parent)Headers"> <Anchor point="TOPLEFT" offsetX="30" offsetY="51" /> <Anchor point="TOPRIGHT" offsetY="51" /> <Dimensions y="32" /> <Controls> <Control name="$(parent)DateTime" inherits="WhisListSortHeader"> ... List for the ZO_SortFilterList. $(parent) points to WishListFrame so the name of the control is globally defined as "WishListFrameList" and can be accessed by this, or as we "add" the ZO_SortFilterList to the global WishListWindow.frame.list it can also be accesed via this pointer (See lua code below) <Control name="$(parent)List" inherits="ZO_ScrollList"> <Anchor point="TOPLEFT" relativeTo="$(parent)Headers" relativePoint="BOTTOMLEFT" offsetY="3" /> <Anchor point="BOTTOMRIGHT" offsetX="-35" offsetY="-32" /> </Control>
The connection between the XML and the lua stuff will happen in WishList_Window.lua in function:
function WishListWindow:Setup( )
So you can check these other functions what is being done there. It will first build the masterList, which calls
self:FilterScrollList then filters the masterlist according to your filter parameters (e.g. a search editbox using string text search)
self:SortScrollList will sort the entries thena ccordingly to the selected sortheaders
self:CommitScrollList will then apply all that changed stuff, update the visuals etc.
The self:SetupItemRow is the function which reads the info from the masterlist of the current row and applies the data.locality to e.g. the locality label of the row control (defined in XML).
Just as info:
WL.CurrentTab = The currently selected tab at the WishList UI. The sets search, the WishList of each toon, or the history "who found what set item where and when"
WL.CurrentState = The current state of the tab (could be "fetching data" at the sets tab, "finished fetching data" and so on)
Depending on these values the ZO_SortFilter list headers, and rows will change.
You'd only have to define 1 rowtype and use it for your history. You do not need to differ it depending on the selected UI etc.
|03/25/21, 11:01 AM||#4|
THANK YOU both very much! With the information provided from you both, I was able to get it figured out (and learn quite a bit about creating custom controls in the process). LUA/XML has a very interesting correlation, especially from the other types of coding I am used to over the years. Thanks again, truly appreciate the help!
|ESOUI » Developer Discussions » Lua/XML Help » Creating a scrollable XML "list control" and adding data via LUA|