Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mod icons to Tracers module dialog lists #606

Merged
merged 3 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions addons/modules/functions/fnc_gui_tracers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,52 @@ _params params ["_weapon", "_magazine", "_delay", "_dispersion", "_target"];
// Store the logic and target (in case the target is not changed)
_display setVariable [QGVAR(params), [_logic, _target]];

// Populate the weapons list
private _ctrlWeapon = _display displayCtrl IDC_TRACERS_WEAPON;
private _cfgWeapons = configFile >> "CfgWeapons";
// Common function to populate weapon and magazine lists with entries
private _fnc_populateList = {
params ["_ctrlList", "_entries", "_baseConfig"];

{
private _config = _cfgWeapons >> _x;
private _name = getText (_config >> "displayName");
private _icon = getText (_config >> "picture");
lnbClear _ctrlList;

private _index = _ctrlWeapon lnbAddRow ["", _name];
_ctrlWeapon lnbSetTooltip [[_index, 0], format ["%1\n%2", _name, _x]];
_ctrlWeapon lnbSetPicture [[_index, 0], _icon];
_ctrlWeapon lnbSetData [[_index, 0], _x];
} forEach keys (uiNamespace getVariable QGVAR(tracersCache));
{
private _config = _baseConfig >> _x;
private _name = getText (_config >> "displayName");
private _icon = getText (_config >> "picture");

private _index = _ctrlList lnbAddRow ["", _name];
_ctrlList lnbSetTooltip [[_index, 0], format ["%1\n%2", _name, _x]];
_ctrlList lnbSetPicture [[_index, 0], _icon];
_ctrlList lnbSetData [[_index, 0], _x];

private _mod = [_config] call EFUNC(common,getDLC);

if (_mod != "") then {
private _logo = modParams [_mod, ["logo"]] param [0, ""];
_ctrlList lnbSetPicture [[_index, 2], _logo];
};
} forEach _entries;

_ctrlList lnbSort [1];
_ctrlList lnbSetCurSelRow 0;
};

_ctrlWeapon lnbSort [1];
_display setVariable [QFUNC(populateList), _fnc_populateList];

// Populate the weapons list
private _ctrlWeapon = _display displayCtrl IDC_TRACERS_WEAPON;
private _weapons = keys (uiNamespace getVariable QGVAR(tracersCache));
[_ctrlWeapon, _weapons, configFile >> "CfgWeapons"] call _fnc_populateList;

// Refresh the magazines list when a weapon is selected
_ctrlWeapon ctrlAddEventHandler ["LBSelChanged", {
params ["_ctrlWeapon", "_index"];

private _display = ctrlParent _ctrlWeapon;
private _weapon = _ctrlWeapon lnbData [_index, 0];
private _fnc_populateList = _display getVariable QFUNC(populateList);

private _ctrlMagazine = _display displayCtrl IDC_TRACERS_MAGAZINE;
private _cfgMagazines = configFile >> "CfgMagazines";

lnbClear _ctrlMagazine;

{
private _config = _cfgMagazines >> _x;
private _name = getText (_config >> "displayName");
private _icon = getText (_config >> "picture");

private _index = _ctrlMagazine lnbAddRow ["", _name];
_ctrlMagazine lnbSetTooltip [[_index, 0], format ["%1\n%2", _name, _x]];
_ctrlMagazine lnbSetPicture [[_index, 0], _icon];
_ctrlMagazine lnbSetData [[_index, 0], _x];
} forEach (uiNamespace getVariable QGVAR(tracersCache) get _weapon);

_ctrlMagazine lnbSort [1];
_ctrlMagazine lnbSetCurSelRow 0;
private _magazines = uiNamespace getVariable QGVAR(tracersCache) get _weapon;
[_ctrlMagazine, _magazines, configFile >> "CfgMagazines"] call _fnc_populateList;
}];

// Select the current weapon in the list (also initially populates magazines list)
Expand Down
2 changes: 1 addition & 1 deletion addons/modules/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ class GVAR(RscTracers): GVAR(RscDisplay) {
w = POS_W(26);
h = POS_H(5);
rowHeight = POS_H(1.2);
columns[] = {0.05, 0.15};
columns[] = {0.05, 0.15, 0.9};
tooltipPerColumn = 0;
};
class MagazineLabel: WeaponLabel {
Expand Down