From 4afcc546e7b7f489f8c26083ceb4312e56da53ba Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sat, 26 Aug 2017 19:16:24 +0100 Subject: [PATCH] Improve spectator focus widget (#5452) * Optimize widget updates * Improve focus widget vehicle position display * Remove insignia from widget * Add current throwable to widget * Fix padding/spacing of widget items * Fix incorrect vehicle cargo icon being used --- .../functions/fnc_ui_updateWidget.sqf | 60 +++++--- addons/spectator/script_component.hpp | 8 +- addons/spectator/ui.hpp | 131 +++++++++--------- 3 files changed, 113 insertions(+), 86 deletions(-) diff --git a/addons/spectator/functions/fnc_ui_updateWidget.sqf b/addons/spectator/functions/fnc_ui_updateWidget.sqf index f0bfb2ec0d..141397280f 100644 --- a/addons/spectator/functions/fnc_ui_updateWidget.sqf +++ b/addons/spectator/functions/fnc_ui_updateWidget.sqf @@ -18,7 +18,8 @@ #define IMG_COMMANDER "a3\Ui_f\data\IGUI\Cfg\CommandBar\imageCommander_ca.paa" #define IMG_DRIVER "a3\Ui_f\data\IGUI\Cfg\CommandBar\imageDriver_ca.paa" #define IMG_GUNNER "a3\Ui_f\data\IGUI\Cfg\CommandBar\imageGunner_ca.paa" -#define IMG_CARGO "a3\Ui_f\data\IGUI\Cfg\CommandBar\imageCommander_ca.paa" +#define IMG_CARGO "a3\Ui_f\data\IGUI\Cfg\CommandBar\imageCargo_ca.paa" +#define IMG_UNARMED "" // TODO: Find suitable unarmed icon // Hide if no target or widget is toggled off if (!GVAR(uiWidgetVisible) || {isNull GVAR(camTarget)}) exitWith {CTRL_WIDGET ctrlShow false}; @@ -28,41 +29,60 @@ private _focus = GVAR(camTarget); private _name = ([_focus] call EFUNC(common,getName)) select [0, NAME_MAX_CHARACTERS]; if !(isPlayer _focus) then { _name = format ["%1: %2", localize "str_player_ai", _name]; }; -private _unitTypePicture = [_focus] call EFUNC(common,getVehicleIcon); -private _vehicleTypePicture = getText (configFile >> "CfgVehicles" >> typeOf vehicle _focus >> "Picture"); -private _insigniaTexture = ["GetGroupTexture", [group _focus]] call BIS_fnc_dynamicGroups; +private _unitTypePicture = ""; +private _vehicleTypePicture = ""; +private _vehiclePositionPicture = ""; +if (_focus != vehicle _focus) then { + _vehicleTypePicture = getText (configFile >> "CfgVehicles" >> typeOf vehicle _focus >> "Picture"); + + _vehiclePositionPicture = switch (_focus) do { + case (commander vehicle _focus): {IMG_COMMANDER}; + case (driver vehicle _focus): {IMG_DRIVER}; + case (gunner vehicle _focus): {IMG_GUNNER}; + default {IMG_CARGO}; + }; +} else { + _unitTypePicture = [_focus] call EFUNC(common,getVehicleIcon); +}; + private _weapon = currentWeapon _focus; private _weaponPicture = if (_weapon != "") then { - getText (configFile >> "CfgWeapons" >> _weapon >> "Picture"); + getText (configFile >> "CfgWeapons" >> _weapon >> "Picture") } else { - if (_focus != vehicle _focus) then { - if (commander vehicle _focus == _focus) exitWith {IMG_COMMANDER}; - if (driver vehicle _focus == _focus) exitWith {IMG_DRIVER}; - if (gunner vehicle _focus == _focus) exitWith {IMG_GUNNER}; - IMG_CARGO - } else {""}; + IMG_UNARMED }; -(getPlayerScores _focus) params [["_kills",0,[0]], ["_softKills",0,[0]], ["_armoredKills",0,[0]], ["_airKills",0,[0]], ["_deaths",0,[0]], ["_total",0,[0]]]; +private _throwable = (currentThrowable _focus) param [0,""]; +private _throwablePicture = if (_throwable != "") then { + getText (configFile >> "CfgMagazines" >> _throwable >> "Picture") +} else { + IMG_UNARMED +}; + +(getPlayerScores _focus) params [ + ["_kills",0,[0]], + ["_softKills",0,[0]], + ["_armoredKills",0,[0]], + ["_airKills",0,[0]], + ["_deaths",0,[0]], + ["_total",0,[0]] +]; CTRL_WIDGET_NAME ctrlSetText _name; -CTRL_WIDGET_AVATAR ctrlSetText _insigniaTexture; CTRL_WIDGET_KILLS ctrlSetText str _kills; CTRL_WIDGET_LAND ctrlSetText str _softKills; CTRL_WIDGET_ARMORED ctrlSetText str _armoredKills; CTRL_WIDGET_AIR ctrlSetText str _airKills; CTRL_WIDGET_DEATHS ctrlSetText str _deaths; CTRL_WIDGET_TOTAL ctrlSetText str _total; + CTRL_WIDGET_WEAPON ctrlSetText _weaponPicture; +CTRL_WIDGET_THROWABLE ctrlSetText _throwablePicture; -CTRL_WIDGET_UNIT ctrlSetText (["",_unitTypePicture] select (vehicle _focus == _focus)); -CTRL_WIDGET_UNIT ctrlShow (vehicle _focus == _focus); -CTRL_WIDGET_VEHICLE ctrlSetText (["",_vehicleTypePicture] select (vehicle _focus != _focus)); -CTRL_WIDGET_VEHICLE ctrlShow (vehicle _focus != _focus); - -CTRL_WIDGET_WEAPON ctrlShow (_weaponPicture != ""); -CTRL_WIDGET_WEAPON_BACK ctrlShow (_weaponPicture != ""); +CTRL_WIDGET_UNIT ctrlSetText _unitTypePicture; +CTRL_WIDGET_VEHICLE ctrlSetText _vehicleTypePicture; +CTRL_WIDGET_VEHICLE_POS ctrlSetText _vehiclePositionPicture; // Handle widget toggling if !(ctrlShown CTRL_WIDGET) then { diff --git a/addons/spectator/script_component.hpp b/addons/spectator/script_component.hpp index 2384984ba2..b4e7c82ac8 100644 --- a/addons/spectator/script_component.hpp +++ b/addons/spectator/script_component.hpp @@ -120,8 +120,8 @@ #define CTRL_WIDGET_UNIT (SPEC_DISPLAY displayCtrl IDC_WIDGET_UNIT) #define IDC_WIDGET_NAME 60033 #define CTRL_WIDGET_NAME (SPEC_DISPLAY displayCtrl IDC_WIDGET_NAME) -#define IDC_WIDGET_AVATAR 60034 -#define CTRL_WIDGET_AVATAR (SPEC_DISPLAY displayCtrl IDC_WIDGET_AVATAR) +#define IDC_WIDGET_VEHICLE_POS 60034 +#define CTRL_WIDGET_VEHICLE_POS (SPEC_DISPLAY displayCtrl IDC_WIDGET_VEHICLE_POS) #define IDC_WIDGET_KILLS 60035 #define CTRL_WIDGET_KILLS (SPEC_DISPLAY displayCtrl IDC_WIDGET_KILLS) #define IDC_WIDGET_LAND 60036 @@ -136,5 +136,5 @@ #define CTRL_WIDGET_TOTAL (SPEC_DISPLAY displayCtrl IDC_WIDGET_TOTAL) #define IDC_WIDGET_WEAPON 60041 #define CTRL_WIDGET_WEAPON (SPEC_DISPLAY displayCtrl IDC_WIDGET_WEAPON) -#define IDC_WIDGET_WEAPON_BACK 60042 -#define CTRL_WIDGET_WEAPON_BACK (SPEC_DISPLAY displayCtrl IDC_WIDGET_WEAPON_BACK) +#define IDC_WIDGET_THROWABLE 60042 +#define CTRL_WIDGET_THROWABLE (SPEC_DISPLAY displayCtrl IDC_WIDGET_THROWABLE) diff --git a/addons/spectator/ui.hpp b/addons/spectator/ui.hpp index 691d48cb31..7ef4620489 100644 --- a/addons/spectator/ui.hpp +++ b/addons/spectator/ui.hpp @@ -259,112 +259,111 @@ class GVAR(display) { }; class FocusInfo: RscControlsGroupNoScrollbars { idc = IDC_WIDGET; - x = X_PART(12.1); + x = X_PART(12.9); y = Y_PART(24); - w = W_PART(16); + w = W_PART(14.2); h = H_PART(3.5); class controls { class UpperBackground: RscText { - x = W_PART(3.5); + x = 0; y = 0; - w = W_PART(12.4); + w = W_PART(14.2); h = H_PART(1.4); colorBackground[] = {0,0,0,0.75}; }; - class LowerLeftBackground: RscText { - idc = CTRL_WIDGET_WEAPON_BACK; - x = W_PART(9.8); + class StatsBackground: RscText { + x = 0; y = H_PART(1.5); - w = W_PART(6.1); + w = W_PART(6); + h = H_PART(2); + colorBackground[] = {0,0,0,0.75}; + }; + class WeaponBackground: RscText { + x = W_PART(6.1); + y = H_PART(1.5); + w = W_PART(6); h = H_PART(2); colorBackground[] = {1,1,1,0.4}; }; - class LowerRightBackground: RscText { - x = W_PART(3.5); + class ThrowableBackground: RscText { + x = W_PART(12.2); y = H_PART(1.5); - w = W_PART(6.2); + w = W_PART(2); h = H_PART(2); - colorBackground[] = {0,0,0,0.75}; - }; - class AvatarBackground: RscText { - x = W_PART(-0.2); - y = 0; - w = W_PART(3.6); - h = H_PART(3.5); - colorBackground[] = {0,0,0,0.75}; - }; - class VehicleType: RscPicture { - idc = IDC_WIDGET_VEHICLE; - text = "\A3\ui_f\data\map\vehicleicons\iconMan_ca.paa"; - x = W_PART(13.5); - y = H_PART(0.3); - w = W_PART(2.1); - h = H_PART(1); - }; - class UnitType: RscPictureKeepAspect { - idc = IDC_WIDGET_UNIT; - text = "\A3\ui_f\data\map\vehicleicons\iconMan_ca.paa"; - x = W_PART(14.6); - y = H_PART(0.3); - w = W_PART(1); - h = H_PART(1); + colorBackground[] = {1,1,1,0.4}; }; class Name: RscText { shadow = 0; idc = IDC_WIDGET_NAME; text = ""; - x = W_PART(3.6); - y = 0; - w = W_PART(9.9); - h = H_PART(1.4); + x = W_PART(0.1); + y = H_PART(0.1); + w = W_PART(10.8); + h = H_PART(1.2); sizeEx = H_PART(1); }; - class Avatar: RscPictureKeepAspect { - idc = IDC_WIDGET_AVATAR; - text = "a3\Ui_f\data\GUI\Cfg\UnitInsignia\bi_ca.paa"; - x = 0; - y = H_PART(0.3); - w = W_PART(3.2); - h = H_PART(2.9); + class VehiclePos: RscPictureKeepAspect { + idc = IDC_WIDGET_VEHICLE_POS; + text = ""; + x = W_PART(11); + y = H_PART(0.2); + w = W_PART(1); + h = H_PART(1); + }; + class VehicleType: RscPicture { + idc = IDC_WIDGET_VEHICLE; + text = ""; + x = W_PART(12.1); + y = H_PART(0.2); + w = W_PART(2); + h = H_PART(1); + }; + class UnitType: RscPictureKeepAspect { + idc = IDC_WIDGET_UNIT; + text = ""; + x = W_PART(13.1); + y = H_PART(0.2); + w = W_PART(1); + h = H_PART(1); }; class Kills: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\infantry_ca.paa"; - x = W_PART(3.6); + x = W_PART(0.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); }; class LandKills: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\soft_ca.paa"; - x = W_PART(4.64); + x = W_PART(1.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); }; class ArmoredKills: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\armored_ca.paa"; - x = W_PART(5.76); + x = W_PART(2.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); }; class AirKills: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\air_ca.paa"; - x = W_PART(6.9); + x = W_PART(3.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); }; class Deaths: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\killed_ca.paa"; - x = W_PART(7.92); + x = W_PART(4.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); }; class Total: RscPictureKeepAspect { text = "a3\Ui_f\data\IGUI\Cfg\MPTable\total_ca.paa"; - x = W_PART(8.86); + x = W_PART(5.1); y = H_PART(1.6); w = W_PART(0.8); h = H_PART(0.8); @@ -374,9 +373,9 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_KILLS; text = ""; - x = W_PART(3.6); + x = W_PART(0.1); y = H_PART(2.5); - w = W_PART(0.9); + w = W_PART(0.8); h = H_PART(0.9); sizeEx = H_PART(0.7); }; @@ -385,7 +384,7 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_LAND; text = ""; - x = W_PART(4.6); + x = W_PART(1.1); y = H_PART(2.5); w = W_PART(0.8); h = H_PART(0.9); @@ -396,7 +395,7 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_ARMORED; text = ""; - x = W_PART(5.7); + x = W_PART(2.1); y = H_PART(2.5); w = W_PART(0.8); h = H_PART(0.9); @@ -407,7 +406,7 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_AIR; text = ""; - x = W_PART(6.8); + x = W_PART(3.1); y = H_PART(2.5); w = W_PART(0.8); h = H_PART(0.9); @@ -418,7 +417,7 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_DEATHS; text = ""; - x = W_PART(7.9); + x = W_PART(4.1); y = H_PART(2.5); w = W_PART(0.8); h = H_PART(0.9); @@ -429,7 +428,7 @@ class GVAR(display) { shadow = 0; idc = IDC_WIDGET_TOTAL; text = ""; - x = W_PART(8.8); + x = W_PART(5.1); y = H_PART(2.5); w = W_PART(0.8); h = H_PART(0.9); @@ -437,10 +436,18 @@ class GVAR(display) { }; class WeaponPicture: RscPictureKeepAspect { idc = IDC_WIDGET_WEAPON; - text = "A3\weapons_F\Rifles\MX\data\UI\gear_mx_rifle_X_CA.paa"; - x = W_PART(9.9); + text = ""; + x = W_PART(6.2); y = H_PART(1.6); - w = W_PART(5.9); + w = W_PART(5.8); + h = H_PART(1.8); + }; + class ThrowablePicture: RscPictureKeepAspect { + idc = IDC_WIDGET_THROWABLE; + text = ""; + x = W_PART(12.3); + y = H_PART(1.6); + w = W_PART(1.8); h = H_PART(1.8); }; };