Go to Page... |
Thread Tools | Display Modes |
08/14/15, 09:30 AM | #1 |
What is a Scene, the SceneManager and other concepts
I've been fooling around here fore about 2 weeks now. I even published my very first - and beta - add-on.
I've spent some dozens hours now reading the game UI code base. Still, I don't grasp most of the concepts here, for instance, what is a Scene ? And I come from a web development background, so I'm not a layman at all. I don't mean to sound ungrateful, I know and value all the effort and time put into the wiki, but I think it lacks broader introductions to how things work, and the concepts involved. Things like: 1. Event and initialization order, for instance, does the GUI is ready when the load event is triggered ? 2. The most prominent ZO_* objects, what they're for and how can you benefit from them 2. Callbacks; I know what they're but what are some actual use cases, besides events I haven't see any asynchrony 3. Other stuff that once you discovered allowed you to write add-ons more efficiently and add more features I'm willing to expand the wiki once I understand more of all this! Thanks for everything so far and for everything to come! |
|
08/14/15, 10:07 AM | #2 |
About scenes is alot to say:
Ayantir and Garkin (two of our Grandmasters) already wrote examples and libs: http://www.esoui.com/downloads/info989-LibMainMenu.html http://www.esoui.com/portal.php?&id=27&pageid=12 If you use ZO_FadeSceneFragment, always specify a fade-out duration less than 200ms: Lua Code:
Secure Render Mode Bug You can take a look to Rare Fish Tracker for fadings > 200ms. |
|
08/14/15, 10:12 AM | #3 | ||
|
Every Scene contains Fragments. A Fragment may be visual -- displaying a TopLevelControl, e.g. the inventory window with buttons and a list of items -- or behavioral -- switching keybinding sets for example. When a Scene is shown, its fragments are shown/activated, and all other fragments are hidden/deactivated. A fragment may be contained in multiple scenes at once, in which case transitions between those scenes keep the fragment shown ("mailInbox" and "mailSend" are two scenes with common interface, and you can't even notice they're different scenes when switching the tab).
After all add-ons have been compiled and executed, EVENT_ADD_ON_LOADED events are generated. They're useful for implementing publisher-subscriber pattern. For example SHARED_INVENTORY holds a cache of inventory slot data, and defines callbacks anyone interested in inventory contents updates can subscribe to. |
||
08/14/15, 10:41 AM | #4 |
@merlight and @votan thank you so much, you already have given me enough to chew on for days!
One question though; when developing an add-on with a form-like GUI, should I use an existing scene or scene fragment or should it reside in its own ? And why ? |
|
08/14/15, 11:08 AM | #5 | |
|
A) If you wanted to add another tab to the guild interface (the four existing tabs switch scenes), you'd probably create a new scene, add some of the common fragments in there (e.g. the background and the guild selection dropdown), and add your own fragment to that. B) If you wanted to show your form next to the character sheet, you'd add your fragment to the existing "stats" scene. |
|
08/14/15, 11:19 AM | #6 | |
It may also helps you to keep a look'n'feel. And why? Because all controls are created forever and use memory forever. If you can re-use, why not. Another nice topic: control-pools. |
||
08/14/15, 01:12 PM | #7 |
|
I just want to add another topic which I have been wondering about.
- GUI size units and scaling. What are the units on when you do something like in XML: Code:
<Dimensions x="750" y="52" /> What are the best practices for building a GUI that scales correctly? |
08/14/15, 01:29 PM | #8 | |
Wandamey
Guest
Posts: n/a
|
from what i have experienced, i'd say the less you bother, the better it will look.
Just do thing so they look well proportionned on your screen, it should render the same for everybody. try to change your UI scale in the UI settings of ESO to see that everything is handled without you having to touch anything. you can lock/unlock the scaling of controls in special situations (text Inside a preformatted tooltip, etc...) but messing with the maths behind the scale is just asking for problems. now i'm a bit limited to test things on many resolutions. But from the screenshot/videos i've seen, i'm confident the game looks the same whatever the screen size. and the units, you answered yourself, they seem to be GUI size units edit : scale is inherited from parents to children, so that's the only thing you have to care for : placing elements one according to the other (with raw dimensions), then scale the top one if needed. If you need to do something that looks proportional to the window/screen you can use as raw dimensions something alongside of : width, height = yourproportion * GuiRoot:GetDimensions() -- didn't check the syntax, but you'll get the idea-- knowing that the result will be scalable again with SetScale() But that may force you to use % for all children dimensions depending on what you're doing Better start with fixed dimensions (choose it with the default scale UI setting) then later on you'll always be able to add an option to rescale if needed. rereredit, idk if we can use something similar to $lang to conditionally set dimension of a "sub"ui according to some Guiroot sizes ranges (like bootstrap could do for example) but i don't see why not if you have some very specific needs to do something like that. Last edited by Wandamey : 08/14/15 at 04:10 PM. |
|
Wandamey |
08/14/15, 03:47 PM | #9 | |||||
|
Some great technical answers have already been given, so I tried to list a few more basic answers.
Lua Code:
Lua Code:
|
|||||
08/15/15, 04:28 PM | #10 |
This is real gold, thank you so much guys!
My schedule's kinda tight but I'll definitely take some time to organize the content and write it down. |
|
08/15/15, 04:37 PM | #11 |
Look at this http://esodata.uesp.net/100011/data/...ForUpdate.html
You'll see a bunch of cases where the game code calls RegisterForUpdate function on a control. I'm only 90% sure of what it does, do you guys know ? What I got from it is that it registers a callback for when a given UI is updated (more like a tick, and many times per second actually, maybe the same as frames per second) but I'm not sure about the second argument, which looks like a delay. Maybe it's something like, "on update call this, but only once every X milliseconds" ? Last edited by haggen : 08/15/15 at 04:50 PM. |
|
08/15/15, 05:01 PM | #12 | |
Lua Code:
identifier (string) - unique identifier, you can use for example name of your addon or some kind of description. If you register the same identifier again, it will overwrite previous function call. interval (integer) - interval in milliseconds between function calls function (function) - function which will be called Example - function OnUpdate is called every 5 seconds (5000ms): Lua Code:
If you want to unregister this function call, use: Lua Code:
Last edited by Garkin : 08/15/15 at 05:05 PM. |
||
08/15/15, 06:56 PM | #13 |
08/15/15, 07:02 PM | #14 | |
|
Unless I misunderstand what you meant:
If you try to register it twice (without unregistering): Lua Code:
|
|
08/15/15, 07:44 PM | #15 |
Am I bugging you guys too much ? I hope not
Another question: I just found this post http://www.esoui.com/forums/showthread.php?t=2136 about localization/internationalization strings. But why should I bother to learn that, when I could simply do something like... Code:
GetMyString = { ["Hello"] = "Hello" } GetMyString["Hello"] Thanks again! |
|
08/15/15, 08:00 PM | #16 | |
|
Lua Code:
The method discussed in that thread is used to get strings for the users client language. As Garkin posted: Lua Code:
The Lang/$(language).lua line would automatically load the correct language file (see code below) for the users current language. Each language file you create would have different definitions in it. Lua Code:
This way you do not need to worry about what language the client is using. When you call Lua Code:
It frees you from having to worry about what language the users client is in. Otherwise every time you wanted to do your version of GetMyString, you would have to have something like this: Lua Code:
I should point out this is not something you have to do. This is only done if you are concerned with translating/displaying the strings in the users client language. If you are not concerned with that, then there would be nothing wrong with just defining the strings in normal variables & just using them when you need them: Lua Code:
Last edited by circonian : 08/15/15 at 09:34 PM. |
|
08/15/15, 08:08 PM | #17 |
@circonian now I see that my example was bad.
Say you use $(language) to include the correct file, and in each locale file you put something simpler, like: Code:
-- EN.lua STRING_JEWELRY = "Jewelry" Code:
-- DE.lua STRING_JEWELRY = "Schmuch" Code:
-- ... STRING_JEWELRY Thanks Edit. I ask because the concept I illustrated above is clear enough and seems to work pretty well: you use the same variable name but load different files and bingo it all works. But maybe the localization API provided (GetString, etc.) has more implications than what meets the eye. Last edited by haggen : 08/15/15 at 08:13 PM. |
|
08/15/15, 09:18 PM | #18 | |
|
As for the differences in methods, there are also these functions:
GetString does have an extra parameter contextId:
GetString(...) will return "[Empty String]" (literally a string with that text) if the stringId does not exist. Last edited by circonian : 08/15/15 at 09:43 PM. |
|
08/15/15, 09:29 PM | #19 |
@circonian Thanks fella! That's clear as it can get, and I'll totally favor ZO standards.
|
|
08/16/15, 02:22 AM | #20 |
There is another use of ZO_CreateStringId and SafeAddString:
In your manifest file you could do: ... lang\strings.lua lang\$(language).lua ... in strings.lua you define the id with default text (english) ZO_CreateStringId("SI_ADDONNAME_TEXT1", "what ever") ... and in the other files you do, e.g. de.lua: SafeAddString(SI_ADDONNAME_TEXT1, "was auch immer") ... This way strings default to english if: 1. The language is not translated at all. (language file missing) 2. You have new, yet not translated, strings. |
|
ESOUI » Developer Discussions » General Authoring Discussion » What is a Scene, the SceneManager and other concepts |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|