#include "..\script_component.hpp"

params [["_store", objNull, [objNull]]];

if (isNull _store) exitWith {};

disableSerialization;
createDialog "RscStoreDialog";

private _display = findDisplay IDD_STOREDIALOG;
private _categoryList = _display displayCtrl IDC_CATEGORYLIST;
private _paymentList = _display displayCtrl IDC_PAYMENTLIST;
private _storeName = _display displayCtrl IDC_DIALOGNAME;
private _data = _store getVariable "storeData";
private _categories = _data select 0;
private _products = _data select 1;
private _name = _data select 2;
private _paymentMethods = _data select 3;

GVAR(currentStore) = _data;

_storeName ctrlSetText _name;

{
    private _index = _categoryList lbAdd _x;
    _categoryList lbSetData [_index, _x];
} forEach _categories;
_categoryList lbSetCurSel 0;

{
    private _payment = _x select 0;
    private _index = _paymentList lbAdd _payment;
    _paymentList lbSetData [_index, format ["%1", _x]];
} forEach _paymentMethods;
_paymentList lbSetCurSel 0;