Skip to content

Commit

Permalink
Merge pull request #150 from Theseus-Aegis/armoryInsignias
Browse files Browse the repository at this point in the history
Add Armory Insignias
  • Loading branch information
jonpas committed Apr 28, 2016
2 parents 1de7308 + 37fc8b8 commit 2b36637
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 17 deletions.
Binary file added addons/armory/UI/btnCategory_insignia.paa
Binary file not shown.
Binary file added addons/armory/UI/titleCategory_insignia.paa
Binary file not shown.
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_dialogControl.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if (_requestedMenu == "main") exitWith {
[false] call FUNC(dialogControl_main);

// Set Title
ctrlSetText [TITLE, format[QUOTE(PATHTOF(UI\titleCategory_%1.paa)), _requestedMenu]];
ctrlSetText [TITLE, format [QUOTE(PATHTOF(UI\titleCategory_%1.paa)), _requestedMenu]];

// Show List
[_requestedMenu] call FUNC(dialogControl_list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TRACE_1("Amount of selected item",_quantity);
lbClear DROPDOWNAMOUNT;

for "_x" from 1 to (parseNumber _quantity) do {
lbAdd [DROPDOWNAMOUNT, str(_x)];
lbAdd [DROPDOWNAMOUNT, str _x];
};

// Set initial value to 1 (will not fire onLBSelChanged)
Expand Down
8 changes: 4 additions & 4 deletions addons/armory/functions/fnc_dialogControl_main.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ params ["_show"];
MAINPIC7, MAINBTN7,
MAINPIC8, MAINBTN8,
//MAINPIC9, MAINBTN9,
//MAINPIC10, MAINBTN10,
MAINPIC10, MAINBTN10,
//MAINPIC11, MAINBTN11,
MAINPIC12, MAINBTN12
];
Expand Down Expand Up @@ -76,9 +76,9 @@ CTRL(MAINBTN8) ctrlSetTooltip localize LSTRING(BtnApparelTooltip);
buttonSetAction [MAINBTN9, QUOTE([''] call FUNC(dialogControl))];
CTRL(MAINBTN9) ctrlSetTooltip "Access ";*/

/*ctrlSetText [MAINPIC10, QUOTE(PATHTOF(UI\btnCategory_kits.paa))];
buttonSetAction [MAINBTN10, QUOTE([''] call FUNC(dialogControl))];
CTRL(MAINBTN10) ctrlSetTooltip "Access ";*/
ctrlSetText [MAINPIC10, QUOTE(PATHTOF(UI\btnCategory_insignia.paa))];
buttonSetAction [MAINBTN10, QUOTE(['insignia'] call FUNC(dialogControl))];
CTRL(MAINBTN10) ctrlSetTooltip localize LSTRING(BtnInsigniasTooltip);

/*ctrlSetText [MAINPIC11, QUOTE(PATHTOF(UI\btnCategory_locker.paa))];
buttonSetAction [MAINBTN11, QUOTE([''] call FUNC(dialogControl))];
Expand Down
12 changes: 9 additions & 3 deletions addons/armory/functions/fnc_dialogControl_populateList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ lnbClear NLIST;
private _rowNum = 0; // Needed for proper row images and data

// Fill List
_armoryData sort true; // Errors when used in combination with forEach
{
_x params ["_className", "_subCategory", "_description", "_quantity"];

Expand All @@ -36,7 +37,10 @@ private _rowNum = 0; // Needed for proper row images and data
if (_configCfg == "") then {
_configCfg = [_className] call ACE_Common_fnc_getConfigTypeObject;
};
if (_configCfg == "") exitWith {ACE_LOGERROR_1("Config Type not found for classname: %1",_className)};
if (_configCfg == "") then {
_configCfg = ["", "CfgUnitInsignia"] select (isClass (configFile >> "CfgUnitInsignia" >> _className));
};
if (_configCfg == "") exitWith {ACE_LOGERROR_2("Config type not found for classname: %1, Config return: %2",_className,_configCfg)};

// Check sub-category for proper listing
if (_selectedSubCategory == "" || {_selectedSubCategory == _subCategory}) then {
Expand All @@ -50,15 +54,17 @@ private _rowNum = 0; // Needed for proper row images and data
_displayName = [_displayName, "..."] joinString "";
};

lnbAddRow [NLIST, ["", _displayName, _quantity]];
private _quantityList = [_quantity, ""] select (_configCfg == "CfgUnitInsignia");
lnbAddRow [NLIST, ["", _displayName, _quantityList]];
lbSetTooltip [NLIST, _rowNum, _tooltip];

// Set hidden data with classname to displayName column and quantity to quantity column
lnbSetData [NLIST, [_rowNum, 1], _className];
lnbSetData [NLIST, [_rowNum, 2], _quantity];

// Set picture
private _picture = getText (configFile >> _configCfg >> _className >> "picture");
private _pictureType = ["picture", "texture"] select (_configCfg == "CfgUnitInsignia");
private _picture = getText (configFile >> _configCfg >> _className >> _pictureType);
lnbSetPicture [NLIST, [_rowNum, 0], _picture];
_rowNum = _rowNum + 1;
};
Expand Down
13 changes: 13 additions & 0 deletions addons/armory/functions/fnc_getDataVanilla.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,18 @@ if (_selectedCategory == "wearable") then {
["G_Bandanna_Shades", "Goggles", "Blabla, this item, blabla", "4"]
];
};
if (_selectedCategory == "insignia") then {
/*_armoryData = [
// Classname, Subcategory, Description, Quantity
["Curator", "Insignia", "Blabla, this item, blabla", "1"],
["MANW", "Insignia", "Blabla, this item, blabla", "1"],
["BI", "Insignia", "Blabla, this item, blabla", "1"]
];*/
private _config = configFile >> "CfgUnitInsignia";
for "_x" from 0 to (count _config - 1) do {
private _configName = configName (_config select _x);
_armoryData pushBack [_configName, "Insignia", "Insignia", "1"];
};
};

_armoryData
5 changes: 5 additions & 0 deletions addons/armory/functions/fnc_sendData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ private _selectedItem = lnbData [NLIST, [lnbCurSelRow NLIST, 1]]; // ClassName
private _selectedAmount = lbText [DROPDOWNAMOUNT, lbCurSel CTRL(DROPDOWNAMOUNT)]; // Quantity
private _object = ACE_player getVariable [QGVAR(object), objNull];

// Insignia application
if (isClass (configFile >> "CfgUnitInsignia" >> _selectedItem)) exitWith {
[ACE_player, _selectedItem] call BIS_fnc_setUnitInsignia;
};

TRACE_3("Send data",_type,_selectedItem,_selectedAmount);

// Exit if any variable is not set
Expand Down
5 changes: 4 additions & 1 deletion addons/armory/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<English>Access Apparel</English>
<German>Auf Bekleidung zugreifen</German>
</Key>
<Key ID="STR_TAC_Armory_BtnInsigniasTooltip">
<English>Access Insignias</English>
</Key>
<Key ID="STR_TAC_Armory_BtnStashTooltip">
<English>Stash Container Contents</English>
<German>Containerinhalt wegpacken</German>
Expand All @@ -110,4 +113,4 @@
<German>Der Container ist voll! Schaffe Platz zum herausholen.</German>
</Key>
</Package>
</Project>
</Project>
8 changes: 8 additions & 0 deletions addons/insignia/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ class Extended_Take_EventHandlers {
};
};
};

class Extended_InventoryOpened_EventHandlers {
class CAManBase {
class ADDON {
clientInventoryOpened = QUOTE(_this call FUNC(getInsignia));
};
};
};
1 change: 1 addition & 0 deletions addons/insignia/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PREP(getInsignia);
PREP(setInsignia);
2 changes: 2 additions & 0 deletions addons/insignia/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ ADDON = false;

#include "XEH_PREP.hpp"

GVAR(activeInsignia) = QGVAR(logoStitch);

ADDON = true;
23 changes: 23 additions & 0 deletions addons/insignia/functions/fnc_getInsignia.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Author: Jonpas
* Gets insignia from a player if it's actual player (and not remote controlled or AI).
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [unit] call tac_insignia_fnc_getInsignia;
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit"];

if (!local _unit || !(_unit == player)) exitWith {};

GVAR(activeInsignia) = [_unit] call BIS_fnc_getUnitInsignia;
TRACE_2("Insignia getted",_unit,GVAR(activeInsignia));
11 changes: 4 additions & 7 deletions addons/insignia/functions/fnc_setInsignia.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

params ["_unit"];

if (local _unit && {_unit == player}) then {
[_unit, QGVAR(logoStitch)] call BIS_fnc_setUnitInsignia;
TRACE_2("Insignia added",_unit,player);
} else {
TRACE_2("Insignia NOT added",_unit,player);
};
if (!local _unit || !(_unit == player)) exitWith {};

[_unit, GVAR(activeInsignia)] call BIS_fnc_setUnitInsignia;
TRACE_2("Insignia added",_unit,GVAR(activeInsignia));

0 comments on commit 2b36637

Please sign in to comment.