From 1dda72a42fc69cda10ea5a05cd8916fd07547387 Mon Sep 17 00:00:00 2001 From: "Thibaut CHARLES (Crom)" Date: Sun, 12 Jan 2020 19:52:30 +0000 Subject: [PATCH] docs: update nwn-2-gui-scripting --- nwn-2-gui-scripting.md | 83 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/nwn-2-gui-scripting.md b/nwn-2-gui-scripting.md index 75ea90d..8f2fc8e 100644 --- a/nwn-2-gui-scripting.md +++ b/nwn-2-gui-scripting.md @@ -2,7 +2,7 @@ title: Nwn 2 Gui Scripting description: A quick summary of Nwn 2 Gui Scripting published: 1 -date: 2020-01-10T23:05:32.063Z +date: 2020-01-12T19:52:27.380Z tags: --- @@ -327,8 +327,10 @@ Inherits from UIPane element. | `groupmemberid` | ID of a button inside a group | Integer | | `color` | Color to blend with the button | Hexadecimal color (ie `ff00ff`) | | `disabledcolor` | Color to blend when the button is disabled | Hexadecimal color (ie `ff00ff`) | -| `disabledtextcolor` | Color to blend with the button text when the it is disabled | Hexadecimal color (ie `ff00ff`) | +| `disabledtextcolor` | Color to blend with the button text when the it is disabled | Hexadecimal color (ie `ff00ff`) | | `style=""` | Name of an UIButton style defined in `stylesheet.xml`. The button will inherit all attributes values from its style | See `stylesheet.xml` | +| `header=false` | This button is the UICollapsable's header button | Boolean | +| | | | ## Children @@ -367,10 +369,83 @@ Define one of these children inside the UIButton element will override the style # UICollapsable # UIGrid + + + # UIListBox -Notes: -- Hiding the listbox scrollbar can cause issues because when you empty/re-fill it, the scrollbar position may be kept. +UIListBoxes serve two purposes: +- Provide a scrollable view, where elements are dynamically placed top to bottom +- Provide a container that can be filled with rows by some NWScript + +## Attributes + +| Attribute | Usage | Possible values | +|------------------------------------|---------------------------------------------------------------------------------------------------------------------|-----------------| +| `showpartialchild=true` | `false` will hide children that don't have enough space to be fully displayed | Boolean | +| `unequalcontrols` | Set to `false` if each listbox child has the same height, to improve scrolling performance. Set to `true` otherwise | Boolean | +| `xPadding` | Horizontal space between two children of the listbox | Integer | +| `yPadding` | Vertical space between two children of the listbox | Integer | +| `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 | +| `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. + + +### 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 +```c +void ClearListBox( object oPlayer, string sScreenName, string sListBox ); +``` +Remove all rows from a `UIListBox` +- `oPlayer`: player object +- `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 ); +``` +Adds a new row into a `UIListBox` +- `oPlayer`: player object +- `sScreenName`: `UIScene` `name` attribute +- `sListBox`: `UIListBox` `name` attribute +- `sRowName`: a string identifier for the row (__needs testing__) +- `sTextFields`: List of `UIText` elements to set the `text` attribute. + + Examples: `TEXT_ELEMENT_NAME=Hello world`, `ITEM_NAME=Great sword;PRICE=42` (TODO: test if the element test lookup + is restricted to the listbox content, i.e. if there are issues if there are multiple elements with the same name) +- `sTextures`: List of `UIFrame` (TODO: or `UIIcon` ?) elements to set the image/icon. + + Examples: `FRAME_ELEMENT_NAME=ia_attack.tga`, `ITEM_ICON=it_am_scalemail00.tga;ITEM_CAT_ICON=b_armor_normal.tga` +- `sVariables`: GUI variables to set? (__needs testing__) +- `sHideUnhide`: List of UI elements to show or hide. + + Examples: `ELEMENT_NAME=hide`, `BUTTON_ATTACK=hide;BUTTON_BEFRIENDS=show` + +##### ModifyListBoxRow +```c +void ModifyListBoxRow( object oPlayer, string sScreenName, string sListBox, string sRowName, string sTextFields, string sTextures, string sVariables, string sHideUnhide ); +``` +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 # UIProgressBar