diff --git a/binaries/data/mods/official/gui/test/functions_utility_list.js b/binaries/data/mods/official/gui/test/functions_utility_list.js index ccefd70077..fea63c7329 100644 --- a/binaries/data/mods/official/gui/test/functions_utility_list.js +++ b/binaries/data/mods/official/gui/test/functions_utility_list.js @@ -59,4 +59,58 @@ function addItem (objectName, pos, value) } } +// ==================================================================== + +// Adds an element to the end of the list +function pushItem(objectName, value) +{ + var list = getGUIObjectByName(objectName).list; + list.push(value); + getGUIObjectByName(objectName).list = list; + // No need to update selection +} + +// ==================================================================== + +// Removes the last element +function popItem(objectName) +{ + var selected = getGUIObjectByName(objectName).selected; + removeItem(objectName, getNumItems(objectName)-1); + + If (selected == getNumItems(objectName)-1) + { + getGUIObjectByName(objectName).selected = -1; + } +} + +// ==================================================================== + +// Retrieves the number of elements in the list +function getNumItems(objectName) +{ + var list = getGUIObjectByName(objectName).list; + return list.length; +} + +// ==================================================================== + +// Retrieves the value of the item at 'pos' +function getItemValue(objectName, pos) +{ + var list = getGUIObjectByName(objectName).list; + return list[pos]; +} + +// ==================================================================== + +// Retrieves the value of the currently selected item +function getCurItemValue(objectName) +{ + if (getGUIObjectByName(objectName).selected == -1) + return ""; + var list = getGUIObjectByName(objectName).list; + return list[getGUIObjectByName(objectName).selected]; +} + // ==================================================================== \ No newline at end of file