2 GUI OList
Vantha edited this page 2024-05-24 17:02:44 +02:00

{{Template:GUI_Object|olist| buffer_zone, cell_id, font, list, scrollbar, scrollbar_style, selected, selected_column, selected_column_order, sortable, sprite, sprite_asc, sprite_desc, sprite_heading, sprite_selectarea, text_align, textcolor, textcolor_selected|SelectionChange}}

An OList is a type of List with multiple columns that can be sorted by each.

Each column has its own set of attributes:

color

  • required: no (default: "0 0 0")
  • value: color

The color of items in that column. (headings take on the textcolor property)

colorSelected

  • required: no (default: value of the "color" attribute)
  • value: color

The color of selected items in that column.

heading

  • required: no (default: "null")
  • value: name

The translatable caption of the column's heading.

hidden

  • required: no (default: false)
  • value: bool

Whether or not the column is rendered.

id

  • required: yes
  • value: name

A unique identifier for the column. .

width

  • required: yes
  • value: percentage

The width of the column relative to that of the entire object.

Examples

How to write an OList in XML:

<object name="exampleOList"
				type="olist"
				style="ModernSortedList"
				sortable="true"
				selected_column="name"
				selected_column_order="1"
				size="0 0 100% 150"
				font="sans-stroke-13"
				auto_scroll="true"
			>
				<action on="SelectionChange">DoSomething()</action>

				<!-- List headers -->
				<column id="name" color="255 255 255" width="60%">
					<translatableAttribute id="heading">Name</translatableAttribute>
				</column>
				<column id="birth" color="255 255 255" width="20%">
					<translatableAttribute id="heading">Year of Birth</translatableAttribute>
				</column>
				<column id="death" color="255 255 255" width="20%">
					<translatableAttribute id="heading">Year of Death</translatableAttribute>
				</column>
			</object>

How to add items with JavaScript:

let example = Engine.GetGUIObjectByName("exampleOList");
example.list = ["hannibal", "caesar", "alexander"];
example.list_name = ["Hannibal", "Julius Caesar", "Alexander III"];
example.list_birth = ["247 BC", "100 BC", "356 BC"];
example.list_death = ["183 - 181BC", "44 BC", "323 BC"];