Skip to content

Commit

Permalink
Merge pull request #23 from KillahPotatoes/KPCF-v1.1.0
Browse files Browse the repository at this point in the history
KPCF v1.1.0 publishing
  • Loading branch information
Dubjunk authored Nov 5, 2018
2 parents d116c1f + f52dc05 commit f9a1e9c
Show file tree
Hide file tree
Showing 38 changed files with 983 additions and 2,168 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"sqf.enableCBA": true,
"sqf.enableACE3": true,
"sqflint.ignoredVariables": [

"ace_interact_menu_fnc_createAction",
"ace_interact_menu_fnc_addActionToObject",
"CBA_fnc_compatibleMagazines"
]
}
27 changes: 24 additions & 3 deletions KP-Cratefiller/KPCF/KPCF_functions.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Killah Potatoes Cratefiller
Killah Potatoes Cratefiller v1.1.0
Author: Dubjunk - https://github.com/KillahPotatoes
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -23,24 +23,39 @@ class KPCF {
// Changes the shown equipment category
class createEquipmentList {};

// Changes the shown magazines
class createMagazineList {};
// Creates a list with valueable magazines or attachments
class createSubList {};

// Deletes the nearest crate
class deleteCrate {};

// Deletes the selected preset
class deletePreset {};

// Exports the active inventory
class export {};

// Gets the config path for the given classname
class getConfigPath {};

// Gets all inventory items of the active crate
class getInventory {};

// Creates the item lists if generateLists is enabled
class getItems {};

// Scans the spawn area for possible storages
class getNearStorages {};

// Imports the selected preset
class import {};

// Manages the actions
class manageActions {};

// Manages the ACE actions
class manageAceActions {};

// Open the dialog
class openDialog {};

Expand All @@ -56,6 +71,12 @@ class KPCF {
// Displays the items of the active crate
class showInventory {};

// Reads all saved presets and lists them.
class showPresets {};

// Sorts the displaynames of the given item array.
class sortList {};

// Spawns the selected crate
class spawnCrate {};
};
Expand Down
25 changes: 21 additions & 4 deletions KP-Cratefiller/KPCF/fnc/fn_addEquipment.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Killah Potatoes Cratefiller
Killah Potatoes Cratefiller v1.1.0
Author: Dubjunk - https://github.com/KillahPotatoes
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -25,14 +25,27 @@ private _ctrlEquipment = _dialog displayCtrl 75812;
// Read controls
private _index = lbCurSel _ctrlEquipment;

// Check for empty variable
if (isNull KPCF_activeStorage) exitWith {
hint localize "STR_KPCF_HINTSELECTION";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

// Check for empty selection
if (_index == -1) exitWith {
hint localize "STR_KPCF_HINTSELECTION";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

// Check if the storage is in range
if ((KPCF_activeStorage distance2D KPCF_activeSpawn) > KPCF_spawnRadius) exitWith {
hint localize "STR_KPCF_HINTRANGE";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
[] remoteExecCall ["KPCF_fnc_getNearStorages", (allPlayers - entities "HeadlessClient_F")];
};

// Item selection
private _item = (KPCF_activeCategory select _index);
private _item = _ctrlEquipment lbData _index;

// Check for enough inventory capacity
if (!(KPCF_activeStorage canAdd [_item, _amount])) exitWith {
Expand All @@ -41,9 +54,13 @@ if (!(KPCF_activeStorage canAdd [_item, _amount])) exitWith {
};

// Add the given item
KPCF_activeStorage addItemCargoGlobal [_item, _amount];
if (_item isKindOf "Bag_Base") then {
KPCF_activeStorage addBackpackCargoGlobal [_item, _amount];
} else {
KPCF_activeStorage addItemCargoGlobal [_item, _amount];
};

remoteExecCall ["KPCF_fnc_getInventory", (allPlayers - entities "HeadlessClient_F")];
[] remoteExecCall ["KPCF_fnc_getInventory", (allPlayers - entities "HeadlessClient_F")];

private _config = [_item] call KPCF_fnc_getConfigPath;
private _name = (getText (configFile >> _config >> _item >> "displayName"));
Expand Down
117 changes: 74 additions & 43 deletions KP-Cratefiller/KPCF/fnc/fn_createEquipmentList.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Killah Potatoes Cratefiller
Killah Potatoes Cratefiller v1.1.0
Author: Dubjunk - https://github.com/KillahPotatoes
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -24,9 +24,6 @@ private _ctrlEquipment = _dialog displayCtrl 75812;
lbClear _ctrlWeapon;
lbClear _ctrlEquipment;

// Reset variables
KPCF_activeCategory = [];

// Hide controls
_ctrlWeapon ctrlShow false;

Expand All @@ -39,47 +36,81 @@ if (_catIndex == -1) exitWith {
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

// Weapons
if (_catIndex == 0) then {
KPCF_activeCategory = KPCF_weapons;
{
private _config = [_x] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbAdd (getText (configFile >> _config >> _x >> "displayName"));
} forEach KPCF_weapons;
};
private _index = 0;
private _config = "";

// Magazines
if (_catIndex == 1) then {
_ctrlWeapon ctrlShow true;
{
private _config = [_x] call KPCF_fnc_getConfigPath;
_ctrlWeapon lbAdd (getText (configFile >> _config >> _x >> "displayName"));
} forEach KPCF_weapons;
};
switch (_catIndex) do {

// Grenades
if (_catIndex == 2) then {
KPCF_activeCategory = KPCF_grenades;
{
private _config = [_x] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbAdd (getText (configFile >> _config >> _x >> "displayName"));
} forEach KPCF_grenades;
};
// Weapons
case 0 : {
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedWeapons;
};

// Explosives
if (_catIndex == 3) then {
KPCF_activeCategory = KPCF_explosives;
{
private _config = [_x] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbAdd (getText (configFile >> _config >> _x >> "displayName"));
} forEach KPCF_explosives;
};
// Magazines
case 1 : {
_ctrlWeapon ctrlShow true;
{
_index = _ctrlWeapon lbAdd (_x select 0);
_ctrlWeapon lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlWeapon lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedWeapons;
};

// Attachments
case 2 : {
_ctrlWeapon ctrlShow true;
{
_index = _ctrlWeapon lbAdd (_x select 0);
_ctrlWeapon lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlWeapon lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedWeapons;
};

// Grenades
case 3 : {
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedGrenades;
};

// Explosives
case 4 : {
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedExplosives;
};

// Items
case 5 : {
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedItems;
};

// Backpacks
case 6 : {
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach KPCF_sortedBackpacks;
};

// Items
if (_catIndex == 4) then {
KPCF_activeCategory = KPCF_items;
{
private _config = [_x] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbAdd (getText (configFile >> _config >> _x >> "displayName"));
} forEach KPCF_items;
};
49 changes: 0 additions & 49 deletions KP-Cratefiller/KPCF/fnc/fn_createMagazineList.sqf

This file was deleted.

78 changes: 78 additions & 0 deletions KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Killah Potatoes Cratefiller v1.1.0
Author: Dubjunk - https://github.com/KillahPotatoes
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Creates a list with valueable magazines or attachments.
Parameter(s):
NONE
Returns:
NONE
*/

// Dialog controls
private _dialog = findDisplay 758067;
private _ctrlCat = _dialog displayCtrl 75810;
private _ctrlWeapon = _dialog displayCtrl 75811;
private _ctrlEquipment = _dialog displayCtrl 75812;

// Clear the lists
lbClear _ctrlEquipment;

// Read controls
private _catIndex = lbCurSel _ctrlCat;
private _weaponIndex = lbCurSel _ctrlWeapon;

// Check for empty selection
if (_weaponIndex == -1) exitWith {
hint localize "STR_KPCF_HINTSELECTION";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

// Weapon selection
private _weaponType = _ctrlWeapon lbData _weaponIndex;

private _config = "";

switch (_catIndex) do {

// Magazines
case 1 : {
// Get compatible magazines
private _glType = (getArray (configfile >> "CfgWeapons" >> _weaponType >> "muzzles")) select 1;
private _magazines = [_weaponType] call CBA_fnc_compatibleMagazines;
_magazines append ([configfile >> "CfgWeapons" >> _weaponType >> _glType] call CBA_fnc_compatibleMagazines);
private _sortedMagazines = [_magazines] call KPCF_fnc_sortList;

private _index = 0;

// Fill controls
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach _sortedMagazines;
};

// Attachments
case 2 : {
// Get compatible attachments
private _attachments = [_weaponType] call BIS_fnc_compatibleItems;
private _sortedAttachments = [_attachments] call KPCF_fnc_sortList;

private _index = 0;

// Fill controls
{
_index = _ctrlEquipment lbAdd (_x select 0);
_ctrlEquipment lbSetData [_index , _x select 1];
_config = [_x select 1] call KPCF_fnc_getConfigPath;
_ctrlEquipment lbSetPicture [_index, getText (configFile >> _config >> (_x select 1) >> "picture")];
} forEach _sortedAttachments;
};
};
Loading

0 comments on commit f9a1e9c

Please sign in to comment.