collapsable & stuff

This commit is contained in:
Crom (Thibaut CHARLES) 2020-01-13 19:02:26 +01:00
parent 1dda72a42f
commit a4a314df31
Signed by: tcharles
GPG Key ID: 45A3D5F880B9E6D0
1 changed files with 60 additions and 22 deletions

View File

@ -6,9 +6,6 @@ date: 2020-01-12T19:52:27.380Z
tags:
---
<!-- TITLE: Nwn 2 Gui Scripting -->
<!-- SUBTITLE: A quick summary of Nwn 2 Gui Scripting -->
# Resources
- [oeiprogrammer](https://oeiprogrammer.blogspot.fr)
@ -42,6 +39,10 @@ The GUI file can store client-side variables that can be either local (limited t
Examples: `local:0`, `local:1337`, `global:42`, ...
### Listbox variables
- `listboxrow:LISTBOX_NAME`: The listbox's selected row number _need testing_
- `listboxtext:LISTBOX_NAME.TEXT_NAME`: The content of a UIText located inside the UIListbox's prototype child. Tip: `UIText` elements with `hidden=true` are useful for storing arbitrary data inside a listbox row
## Event attributes
Events attributes are special attributes that can trigger [callbacks](#callbacks) when specific actions are executed by the player (ex: clicking a button) or the client's engine (ex: when a frame is rendered).
@ -294,7 +295,6 @@ Inherits from UIPane element.
| `mhside` | Do not seem to work (see [oeiprogrammer](https://oeiprogrammer.blogspot.fr/search/label/uiframe)) | |
| `mvside` | Do not seem to work (see [oeiprogrammer](https://oeiprogrammer.blogspot.fr/search/label/uiframe)) | |
| `maside` | Do not seem to work (see [oeiprogrammer](https://oeiprogrammer.blogspot.fr/search/label/uiframe)) | |
| | | |
---
@ -366,18 +366,28 @@ Define one of these children inside the UIButton element will override the style
# UIText
# UICollapsable
# UIGrid
---
# UIListBox
UIListBoxes serve two purposes:
- Provide a scrollable view, where elements are dynamically placed top to bottom
- Provide a scrollable view, where elements are automatically placed vertically from top to bottom
- Provide a container that can be filled with rows by some NWScript
See [Listbox variables](#listbox-variables) for special variables related to listboxes.
## Children
If no `y` position is defined _need confirmation_, children of a listbox are dynamically placed from top to bottom.
If a child element has the attribute `prototype` set to `true`, the element will be used as a row template. Any row
added to the listbox using `AddListBoxRow` will copy the prototype child and append it to the listbox.
You must add a `UIScrollBar` child, otherwise no scrollbar will be visible.
## Attributes
| Attribute | Usage | Possible values |
@ -389,23 +399,18 @@ UIListBoxes serve two purposes:
| `snaptobottom=false` | `true` will keep the listbox scrolled all the way down when adding children | Boolean |
| `scrollsegmentsize` | Number of pixels the listbox content is moved when scrolling it with the wheel or by clicking the scrollbar arrows | Integer |
| `scrollbaronright=true` | Set to `false` to move the scrollbar to the left side of the listbox | Boolean |
| `selectonleftclick=false` | If `true`, clicking a row will make it selected (probably for `listboxtext:LBName.UITxtName` __need info__) | Boolean |
| `selectonleftclick=false` | If `true`, clicking a row will make it selected (probably for `listboxtext:LBName.UITxtName` _need testing_) | Boolean |
| `hidescrollbarwhennotneeded=false` | If `true` the scrollbar will be hidden when scrolling is not necessary. | Boolean |
| `hidescrollbar=false` | `true` to always hide the scrollbar | Boolean |
| `` | | |
| | | |
### Notes
- `hidescrollbarwhennotneeded` `hidescrollbar`: It is better to keep those to `false`, as sometimes the scroll position
is kept when removing/adding content, and you can end up having a UIListbox with some content but no visible scrollbar nor children.
## Children
If no `y` position is defined, children of a listbox are dynamically placed from top to bottom.
## NWScript
### Prototypes
If a child element has the attribute `prototype` set to `true`, the element will be used as a row template.
The following functions in NWScript can interact with listbox rows:
##### ClearListBox
@ -417,7 +422,6 @@ Remove all rows from a `UIListBox`
- `sScreenName`: `UIScene` `name` attribute
- `sListBox`: `UIListBox` `name` attribute
##### AddListBoxRow
```c
void AddListBoxRow( object oPlayer, string sScreenName, string sListBox, string sRowName, string sTextFields, string sTextures, string sVariables, string sHideUnhide );
@ -442,17 +446,47 @@ void ModifyListBoxRow( object oPlayer, string sScreenName, string sListBox, stri
```
Modifies an existing row inside a `UIListBox`. The parameters are the same as `AddListBoxRow`
## Special variables
listboxrow:listboxname => row number?
listboxtext:listboxname.textElementName => text content
---
# UIScrollBar
Note: Custom UIScrollbars can be build by placing UIButton children with the names `up`, `down`, `slider`, `back`, similar to how it's done in `stylesheet.xml`.
---
# UICollapsable
A UIPane that can be collapsed or expanded with a button action.
Like `UIListBox` children elements are automatically placed vertically from top to bottom, allowing to easily nest `UICollapsable` inside other `UICollapsable`s.
A tree view can be built using multiple nested `UICollapsable`s with `indent` set to a non-0 value.
## Children
The UICollapsable can have any number of children, but requires at least a `UIButton` element with the `header` attribute set to `true` to be interacted with.
When collapsed (closed), the UICollapsable's height will be the height of the header UIButton element. When expanded (opened), UICollapsable's height will be the height defined as the `height` attribute.
The UICollapsable works particularly well inside a UIListbox, since content will be automatically rearranged when the UICollapsable changes its height.
Note: UICollapsable inside other UICollapsable will be be badly offset by the header height if they have `isexpanded=true`. The offset is corrected when collapsing/expanding it manually.
## Attributes
| Attribute | Usage | Possible values |
|----------------|------------------------------------------------------|-----------------|
| `isexpanded` | `true` will make the collapsable expanded by default | Boolean |
| `collapselock` | | Boolean |
| `indent=0` | Space on the left of the children elements | Integer |
| `xPadding=0` | horizontal space between around elements | Integer |
| `yPadding=0` | vertical space between around elements | Integer |
---
# UIProgressBar
# Special files
## contextmenu.xml
## `contextmenu.xml`
### UIScene
Using the `OnAdd` event to trigger `UIObject_Misc_ExecuteServerScript` will prevent the GUI from loading.
@ -484,6 +518,10 @@ The `node` property refers to an existing `UIRadialNode`'s `name` property.
- `UIPortrait`
- `UITextTree`
## `stylesheet.xml`
## `fontfamily.xml`
---
# Generic callbacks
@ -525,4 +563,4 @@ The `node` property refers to an existing `UIRadialNode`'s `name` property.
- `void DisplayMessageBox( object oPC, int nMessageStrRef, string sMessage, string sOkCB="", string sCancelCB="", int bShowCancel=FALSE, string sScreenName="", int nOkStrRef=0, string sOkString="", int nCancelStrRef=0, string sCancelString="" );`
- `void DisplayInputBox( object oPC, int nMessageStrRef, string sMessage, string sOkCB="", string sCancelCB="", int bShowCancel=FALSE, string sScreenName="", int nOkStrRef=0, string sOkString="", int nCancelStrRef=0, string sCancelString="", string sDefaultString="", string sUnusedString="" );`
- `void DisplayInputBox( object oPC, int nMessageStrRef, string sMessage, string sOkCB="", string sCancelCB="", int bShowCancel=FALSE, string sScreenName="", int nOkStrRef=0, string sOkString="", int nCancelStrRef=0, string sCancelString="", string sDefaultString="", string sUnusedString="" );`