#include "..\script_component.hpp"

private _display = findDisplay IDD_LOCKERDIALOG;
private _itemList = _display displayCtrl IDC_LOCKEREQUIPMENTLIST;
// private _locker = player getVariable ["FORGE_Locker", []];
private _locker = GETVAR(player,FORGE_Locker,[]);

{
    _x params ["_itemType", "_item"];
    private _index = -1;
    
    switch (_itemType) do {
        case "backpack": {
            private _displayName = getText (configFile >> "CfgVehicles" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgVehicles" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "facewear": {
            private _displayName = getText (configFile >> "CfgGlasses" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgGlasses" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "headgear": {
            private _displayName = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "hmd": {
            private _display = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "item": {
            private _displayName = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "magazine": {
            private _displayName = format["%1 (%2/%3)", getText (configFile >> "CfgMagazines" >> (_item select 0) >> "displayName"), (_item select 1), (_item select 2)];
            private _picture = getText (configFile >> "CfgMagazines" >> (_item select 0) >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "uniform": {
            private _displayName = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "vest": {
            private _displayName = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
        case "weapon": {
            private _displayName = getText (configFile >> "CfgWeapons" >> _item >> "displayName");
            private _picture = getText (configFile >> "CfgWeapons" >> _item >> "picture");

            _index = _itemList lbAdd _displayName;
            _itemList lbSetData [_index, str [_itemType, _item]];
            _itemList lbSetPicture [_index, _picture];
        };
    };
} forEach _locker;