07/23/14, 03:59 AM | #1 |
|
Creating a whole bunch of Elements dynamic from code
I have been thinking for a while now about making something I call the "Event Explorer". A single window that allows you to register every event in the game for simple debugging/testing purposes.
LibConstantMapper provides me the ability to get all the Event ID and thier names in a fully automatic fashion. And later even get me subgroups. My current count for 1.2.6 is 469 Event ID's The only piece still missing is the GUI side of the equation. At a simple level the window will look like this: Window ->Row1 -->Label with event ID -->Label with event Name -->Checkbox to enabeled/disable listening to the event -->maybe extra checkboxes for the way the data is output (into chat, onscreen notification, how detailed the output should be (all parameters or only that the event was fired?)) ->Row2 -->Label with event ID ->Row3 I propably have to add some paging/register cards for efficiency. A later version will likely have some categories/filters/grouping for specific event groups (like all COMBAT Events). But for now the big issues are the handlers on the first checkbox. Basically I need one handler that can automagically identify to wich Row (and thus event ID) it belongs too. One handler to regsiter it 469 times at 469 UI Elements. I wil propably need a big code behind table anyway to hold all the data (wich setting is enabeled/disabeled). So if I need to store something like the UI Element reference after creating it would not be an issue. |
07/23/14, 05:04 AM | #2 |
|
I think paging will be the way to go. That way you create say 50 rows from a template, which you can write in xml with checkbox and labels already in it. You can put any data you want in the row control, similar to how inventory rows have control.data={bagId=1, slotIndex=2, etc}. There were ingame scripts from Aug 2013 on XeNTaX forum, where loot window was paged, and it did pretty much exactly what I described - OnInitialize created a fixed number of rows from a template, and on EVENT_LOOT_UPDATED and when switching pages, updated data in those rows.
Later you can even make a search filter, e.g. events containing "TRADE" in their name edit: can we even publish snippets from ingame scripts? It's so awkward to always tell people "there is something somewhere ..." Last edited by merlight : 07/23/14 at 05:07 AM. |
07/23/14, 06:07 AM | #3 | |
|
I know that as "Tag" property from WinForms and WPF. It is the second best solution for such a problem. What is the way to get the "parent" XML Element of a control? I would perfer to just drop the Event's ID as data in the Row. The event handler would get the Checkboxes Reference. Then I would go up on step to get the Row it is contained in and use the ID from that. Edit: I think I found it. Something liek thsi event handler code? Lua Code:
Last edited by zgrssd : 07/23/14 at 06:10 AM. |
|
07/23/14, 06:21 AM | #4 |
|
I tried to write some untested code for illustration. Careful with dot where colon should be -- control:GetParent()
edit: or look at LAM controls, they too have custom data: control.panel is the panel it's contained in control.data is the optionData it was created from Code:
<Control name="EventExplorerRow" virtual="true"> <Dimensions y="45"/> <Controls> <Label name="$(parent)Id" font="ZoFontGame" horizontalAlignment="RIGHT"> <Anchor point="RIGHT" relativePoint="LEFT" offsetX="50"/> </Label> <Label name="$(parent)Name" font="ZoFontGame"> <!-- I don't know how, but it's definitely possible to make this clickable, so that you can enable/disable events by cliking on the name (see "ZO_CheckButtonLabel") --> <Anchor point="LEFT" relativeTo="$(parent)Id" relativePoint="RIGHT" offsetX="20"/> </Label> </Controls> </Control> Lua Code:
Lua Code:
Last edited by merlight : 07/23/14 at 06:30 AM. |
07/23/14, 06:28 AM | #5 |
|
|
07/23/14, 02:00 PM | #6 |
|
I took the basic window from AIResearch Grid:
xml Code:
Added merlights template: xml Code:
And made up some basic code to get the table and fill the window with entries: Lua Code:
And all I get are those error messages and an empty window: Code:
CreateControlFromVirtual failed. ControlName[EventExplorerDynamicRow1], ParentName[EventExplorerWindow], VirtualName[EventExplorerRow]. CreateControlFromVirtual failed. ControlName[EventExplorerDynamicRow2], ParentName[EventExplorerWindow], VirtualName[EventExplorerRow]. CreateControlFromVirtual failed. ControlName[EventExplorerDynamicRow3], ParentName[EventExplorerWindow], VirtualName[EventExplorerRow]. |
07/23/14, 02:19 PM | #7 |
How your xml looks like? It should be something like this:
xml Code:
There is no UI error with this .xml file. |
|
07/23/14, 02:57 PM | #8 | |
|
After solving this issues and some minor issue with the retreival of data I have anotehr issue: Nothing is shown in the window. I double checked by giving the lables text and putting d(row) into the code - it is executed and the items are created. They are just not shown. I asume that I am adding them on a level too high or that something in my window is wrong. |
|
07/23/14, 03:08 PM | #9 | |
Try this code: xml Code:
Lua Code:
EDIT: By the way list of events in your library contains global reference to EVENT_MANAGER. Updated mapping: lua Code:
Last edited by Garkin : 07/23/14 at 03:11 PM. Reason: added LibConstantMapper note |
||
07/23/14, 03:30 PM | #10 | |
|
Then I noticed the list also includes "EVENT_REASON_HARDWARE" & SOFTWARE. And I cannot fix that until I get multiple-exclusions patterns running. I think I understand it now a bit better, but have to let it go through my head a bit more. By the way, are there any Container controlls? Stack Pannels, Scroll Pannels, Grids, that kind of thing? Right now I am just dropping the labels as children of the same level onto the Window. I prefer to have a proper visual tree. |
|
07/23/14, 04:36 PM | #11 | |
But before implementing such functionalities yourself, you could use the code I have written for my addon ItemSetGuide. I have made an helper that creates as much rows as are possible in it's parent and adds and handles a vertical scrollbar all by itself: Lua Code:
The container gets the following fields:
The row control gets the following fields:
I know it could be better, but it's a start I plan to make this available as a library here on esoui as soon as I am happy with the implementation. |
||
07/23/14, 04:40 PM | #12 | |
Example of ZO_ScrollList: http://www.esoui.com/downloads/info5...stExample.html |
||
07/24/14, 05:28 AM | #13 | |
|
Please give me an example for this simple case: I have a Window of Size 400x400 I have three labels 400x200 to put into that window. Since the labels together are higher then the window, I need to put a scrollist in the window and the labels in the scrollist. How do I use ZoScrollList to do that? If possible, make a pure XML example (I am not sure you can even use ZoScrollList in XML as it seems not valid as control type when I tried). My expierence would say the XML tree would look roughly like this: Window ->ZoScrollList -->Label1 -->Label2 -->Label2 ->Maybe other controls contained in the Window like menu strip, satus bar, etc. |
|
07/24/14, 06:42 AM | #14 | ||
|
In Garkin's XML above, it's this part (with ZO_ScrollContainer instead):
"EventExplorerWindow" -> "Container" -> "ScrollChild" is then named EventExplorerWindowContainerScrollChild in _G, look that up in Garkins code, this control is used as the parent of created rows. |
||
07/24/14, 07:11 AM | #15 | |
|
I try to get some understanding of what happens via the rules that apply to WPF. There writing code like this: xml Code:
would just be different syntax for this: xml Code:
Going from there: xml Code:
Wich elements all have a "Controls" property and are thus containers? Is it only "GuiXML", "Control" and "TopLevelControl"? All of them? All of them but a few? |
|
07/24/14, 09:01 AM | #16 | ||
|
This is element node <Label> with no attributes and 1 child element node <Content>, which in turn has 1 child text node with value "Test": Whereas this is element node <Label> with 1 attribute Content="Test": I don't know how ESO parses XML, but I tell you if I were to do that, I'd take a ready-made library that would parse the file and give me DOM tree, and then just walk the tree. That attribute<=>text equality (or ambiquity) you decribed is a hack invented by people who thought XML should be written by humans, and they complicate their parsers to make that torture less painful. Now back to ESO. They made their UI elements reusable through inheritance, so that any control can be used as a template. For example: xml Code:
In addition to those I found <Slider>, <EditBox>, <Tooltip>, <Label>, <Cooldown> with inner <Controls>. Perhaps all controls can have children, to me it'd seem logical, since <Control> can have them and I think that's the base for other controls, but who knows. Last edited by merlight : 07/24/14 at 09:08 AM. |
||
07/24/14, 12:56 PM | #17 |
|
Virtuals sole purpose seem to be to be inherited. Template might not be the right word after all.
It's a bit like comparing a virtual control to a abstract class - it is only there to be inhereted, not be shown itself directly. And CreateFromVirtual does little more then create a element that does inherit it. Already figured out that Property Element Syntax of WPF does not work here. Instead they seem to have a special "kind" of Cildren. "Atribute Children" or "Property Children" might be a propper name. They are children with the sole purpose to define stuff about thier parent. They have no meaning of thier own. Property Children do not inherit from Control and seem mostly structures. But they may also have inherentianc chains and functions (like AnimationBase and it's Inheritors). 'Controls' is just one of the "Property Children" of Control and it's job is to contain a list of other controls. Every control itself seems to be derived from control, hence every control is also a container itself. Now stuff makes a lot more sense then it did before. |
07/24/14, 01:11 PM | #18 | |
|
Lua Code:
xml Code:
|
|
07/24/14, 01:39 PM | #19 |
|
Currently my XML looks like this:
xml Code:
with fill Window looking like: Lua Code:
Still not getting quite the results I expected, but at least I am hitting the right container element: I would guess the Scroll Window is not properly aware that it's own Dimensions should bve confined to the Windows Dimensions. So it will automatically stretch to it's contents size instead of doing scroll panel stuff. |
07/24/14, 01:43 PM | #20 |
|
ZO_ScrollList has a child <Scroll name="$(parent)Contents" mouseEnabled="true">, use that as row parent, i.e. EventExplorerWindowScrollContents.
|
ESOUI » Developer Discussions » Lua/XML Help » Creating a whole bunch of Elements dynamic from code |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|