Open Laurinchen opened 7 months ago
appendum: There should also be a
[UIElement].GetAncestorCount()
I would like to see methods like GetDialogHeight
and GetDialogWidth
that would return the size of the dialog.
Using the setMaxSize
function sets the window IF the given sizes fit on the device. This would at least allow us to create fixed menu's
appendum: There should also be a
[UIElement].GetAncestorCount()
In theory this is already possible. I've written a small UI package, that keeps track of each element created. You can easily track how many children / ancestors an element using something like this
Created suggestion in uservoice forum:
Since it is the easiest to get debug info about font size, position etc. on the Website, the Mod library has been primarily made for the Website Version of Warzone. For example, width of a char, spaces between two Elements in a HorizontalLayoutGroup, extra space needed for every Element down the UI hierarchy chain, etc. are easily to get via the Website with inspect Element. Unfortunately, the same cannot be said about the Standalone and Mobile Client. I'm therefore suggesting following (client only) UI APIs:
UI.Metrics.GetTextWidth(text)
: Takes a string as the argument and returns the width oftext
in pixels as a number. Depends on the client type (website, standaloneclient, ...) and the current font used. Suggested Resources:UI.Metrics.HorizontalGapSize
: Constant number, the gap Size between 2 Elements in a HorizontalLayoutGroup. Will depend on the the client type (website, standaloneclient, ...) the game is being played onUI.Metrics.VerticalGapSize
: Constant number, the gap size between 2 Elements in a VerticalLayoutGroup. Will depend on the the client type the game is being played onUI.Metrics.ExtraSpacePerChildLevel
: Constant number. Every child of a parent gets moved left further (left:
CSS-property) depending how deep down it is the ancestor tree. This constant reflects thatDefinition of a
[UIElement]
: Everything that can have a size, which can for example be set via[UIElement].SetPreferredWidth
, for example a HorizontalLayoutGroup or Label. API suggestions:[UIElement].GetCurrentWidth()
: Returns a number of how much width the element currently uses in pixels[UIElement].GetAvailableWidth()
: Returns a number of the max width the element can expand into in pixels[UIElement].GetAvailableWidthLeft()
: Returns a number of how much space there's left it still can expand into in pixels. BasicallyGetAvailableWidth() - GetCurrentWidth()
[UIElement].GetCurrentHeight()
: Returns a number of how much height the element currently uses in pixels[UIElement].GetAvailableHeight()
: Returns a number of the max height the element can expand into in pixels[UIElement].GetAvailableHeightLeft()
: Returns a number of how much space there's left it still can expand into in pixels. BasicallyGetAvailableHeight() - GetCurrentHeight()
[UIElement].GetAncestorCount()
: Returns the ancestor count of the UI Element. For example, the method called on a Label directly inheriting from rootParent should return 1.EDIT: Definition of
dialogRootParent
: the rootParent passed to the callback of ClientGame.CreateDialog(callback).GetDialogHeight(dialogRootParent)
: Returns the height of the created menu created by callingClientGame.CreateDialog(...)
GetDialogWidth(dialogRootParent)
: Returns the width of the created menu created by callingClientGame.CreateDialog(...)
ClientGame.CreateDialog(callback)
Edit 2: I think, following function(s) should be enabled:
Reasoning:
pcall
(andxpcall
) are core parts of the exception system of Lua and allow for simple error recovery. This is generally useful for general modding and programming, but it is also useful for this library: If the parsing fails, it could insteadAnother reason is that http://lua-users.org/wiki/SandBoxes calls
pcall
andxpcall
safe, so there shouldn't be much to worry about except ifpcall
(andxpcall
) in an important waypcall
(andxpcall
)pcall
(andxpcall
) don't work as expected anymore