Improve unit switching UX

This commit is contained in:
SilentSpike 2015-07-16 18:31:49 +01:00
parent 458fe363ff
commit 20f05d9906
3 changed files with 21 additions and 24 deletions

View File

@ -146,9 +146,9 @@ class GVAR(overlay) {
class unitTree: RscTree {
idc = IDC_TREE;
x = safeZoneX;
y = safezoneY + TOOL_H;
y = safezoneY + TOOL_H * 2;
w = TOOL_W * 2;
h = safeZoneH - TOOL_H;
h = safeZoneH - TOOL_H * 4;
borderSize = 1;
colorBorder[] = {1,1,1,1};
colorBackground[] = {0.1,0.1,0.1,0.8};
@ -161,7 +161,6 @@ class GVAR(overlay) {
multiselectEnabled = 0;
maxHistoryDelay = 1;
onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface));
onTreeSelChanged = QUOTE([ARR_2('onTreeSelChanged',_this)] call FUNC(handleInterface));
};
class spectatorMap: RscMapControl {
idc = IDC_MAP;

View File

@ -278,7 +278,7 @@ switch (toLower _mode) do {
};
// Tree events
case "ontreedblclick": {
if (GVAR(camMode) != 0) then {
// Update camera view when listbox unit is double clicked on
private ["_sel","_netID"];
_sel = _args select 1;
@ -286,22 +286,12 @@ switch (toLower _mode) do {
if (count _sel == 2) then {
_netID = (_args select 0) tvData _sel;
GVAR(camUnit) = objectFromNetId _netID;
};
} else {
// Only update camera mode when in free cam
if (GVAR(camMode) == 0) then {
GVAR(camMode) = 1;
};
call FUNC(updateView);
};
case "ontreeselchanged": {
if (GVAR(camMode) == 0) then {
private ["_sel","_netID"];
_sel = _args select 1;
// Ensure a unit was selected
if (count _sel == 2) then {
_netID = (_args select 0) tvData _sel;
GVAR(camUnit) = objectFromNetId _netID;
};
};
};
};

View File

@ -27,6 +27,9 @@ disableSerialization;
_display = GETUVAR(GVAR(display),displayNull);
_ctrl = _display displayCtrl IDC_TREE;
// Cache current selection
_curSelData = _ctrl tvData (tvCurSel _ctrl);
// Clear the tree
_ctrl tvDelete [];
@ -53,6 +56,11 @@ _cachedGrps = [];
_ctrl tvAdd [[_node], name _x];
_ctrl tvSetData [[_node,_index], netID _x];
// Preserve the previous selection
if (_curSelData == (_ctrl tvData [_node,_index])) then {
_ctrl tvSetCurSel [_node,_index];
};
_ctrl tvSort [[_node],false];
} forEach GVAR(unitList);