Skip to content

Commit

Permalink
Merge pull request #11 from KillahPotatoes/KPCF-v1.0.1
Browse files Browse the repository at this point in the history
KPCF v1.0.1 publishing
  • Loading branch information
Dubjunk authored Oct 19, 2018
2 parents 019c731 + 61a3bdb commit b973916
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 50 deletions.
4 changes: 2 additions & 2 deletions KP-Cratefiller/KPCF/fnc/fn_addEquipment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ if (_index == -1) exitWith {
private _item = (KPCF_activeCategory select _index);

// Check for enough inventory capacity
if (!(KPCF_activeStorage canAdd _item)) exitWith {
if (!(KPCF_activeStorage canAdd [_item, _amount])) exitWith {
hint format [localize "STR_KPCF_HINTFULL"];
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

// Add the given item
KPCF_activeStorage addItemCargoGlobal [_item, _amount];

remoteExecCall ["KPCF_fnc_getInventory"];
remoteExecCall ["KPCF_fnc_getInventory", -2];

private _config = [_item] call KPCF_fnc_getConfigPath;
private _name = (getText (configFile >> _config >> _item >> "displayName"));
Expand Down
4 changes: 3 additions & 1 deletion KP-Cratefiller/KPCF/fnc/fn_deleteCrate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ if (!((typeOf KPCF_activeStorage) in KPCF_crates)) exitWith {
// Delete crate
deleteVehicle KPCF_activeStorage;

remoteExecCall ["KPCF_fnc_getInventory"];
KPCF_activeStorage = objNull;

remoteExecCall ["KPCF_fnc_getInventory", -2];

private _config = [typeOf KPCF_activeStorage] call KPCF_fnc_getConfigPath;
private _name = (getText (configFile >> _config >> typeOf KPCF_activeStorage >> "displayName"));
Expand Down
7 changes: 2 additions & 5 deletions KP-Cratefiller/KPCF/fnc/fn_getInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
// Dialog controls
private _dialog = findDisplay 758067;

// Check if script runs on server
if (!hasInterface) exitWith {};

// Check if dialog is open
if (isNull _dialog) exitWith {};

// Check for an active storage
if (isNull KPCF_activeStorage) exitWith {
hint localize "STR_KPCF_HINTSELECTION";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
KPCF_inventory = [];
call KPCF_fnc_showInventory;
};

// Reset variables
Expand Down
2 changes: 1 addition & 1 deletion KP-Cratefiller/KPCF/fnc/fn_getNearStorages.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ KPCF_nearStorage = [];
if (_number > 0) then {
KPCF_nearStorage pushBack _x;
};
} forEach (KPCF_activeSpawn nearObjects KPCF_spawnRadius);
} forEach ((KPCF_activeSpawn nearObjects KPCF_spawnRadius) select {!(typeOf _x in KPCF_cratefillerBase)});

// Fill the list
{
Expand Down
17 changes: 9 additions & 8 deletions KP-Cratefiller/KPCF/fnc/fn_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
* KPGUI
*/

// Read the config file
call compile preprocessFileLineNumbers "KPCF_config.sqf";
// Only run, when we've a real player
if (hasInterface) then {

// Read the variables
call compile preprocessFileLineNumbers "KPCF\variables.sqf";
// Read the config file
call compile preprocessFileLineNumbers "KPCF_config.sqf";

// Check for ACE
KPCF_ace = isClass (configfile >> "CfgPatches" >> "ace_common");
// Read the variables
call compile preprocessFileLineNumbers "KPCF\variables.sqf";

// Check for ACE
KPCF_ace = isClass (configfile >> "CfgPatches" >> "ace_common");

// Only run, when we've a real player
if (hasInterface) then {
call KPCF_fnc_manageActions;
};
4 changes: 1 addition & 3 deletions KP-Cratefiller/KPCF/fnc/fn_manageActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
private _foundBase = [];

{
_foundBase append ((getPos player) nearObjects [_x, 500]);
_foundBase append ((getPos player) nearObjects [_x, KPCF_checkDistance]);
} forEach KPCF_cratefillerBase;

systemchat format ["%1", _foundBase];

// Add the action
{
if (!(_x in KPCF_usedBase)) then {
Expand Down
2 changes: 1 addition & 1 deletion KP-Cratefiller/KPCF/fnc/fn_setActiveStorage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ if (_storageIndex == -1) exitWith {
// Define active Storage
KPCF_activeStorage = KPCF_nearStorage select _storageIndex;

remoteExecCall ["KPCF_fnc_getInventory"];
remoteExecCall ["KPCF_fnc_getInventory", -2];
4 changes: 2 additions & 2 deletions KP-Cratefiller/KPCF/fnc/fn_setInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (count KPCF_inventory == 0) exitWith {
clearMagazineCargoGlobal KPCF_activeStorage;
clearItemCargoGlobal KPCF_activeStorage;
clearBackpackCargoGlobal KPCF_activeStorage;
remoteExecCall ["KPCF_fnc_getInventory"];
remoteExecCall ["KPCF_fnc_getInventory", -2];
};

// Clear the storage
Expand All @@ -37,4 +37,4 @@ for "_i" from 0 to (_count-1) do {
KPCF_activeStorage addItemCargoGlobal [(KPCF_inventory select _i) select 0, (KPCF_inventory select _i) select 1];
};

remoteExecCall ["KPCF_fnc_getInventory"];
remoteExecCall ["KPCF_fnc_getInventory", -2];
8 changes: 2 additions & 6 deletions KP-Cratefiller/KPCF/fnc/fn_showInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@
// Dialog controls
private _dialog = findDisplay 758067;
private _ctrlInventory = _dialog displayCtrl 75822;
private _ctrlInventoryAmount = _dialog displayCtrl 75823;
private _ctlrProgress = _dialog displayCtrl 75824;
private _ctlrProgress = _dialog displayCtrl 75823;

// Reset variables
lbClear _ctrlInventory;
lbClear _ctrlInventoryAmount;

// Fill the controls
{
private _config = [_x select 0] call KPCF_fnc_getConfigPath;
_ctrlInventory lbAdd (getText (configFile >> _config >> _x select 0 >> "displayName"));
_ctrlInventoryAmount lbAdd str (_x select 1);
_ctrlInventory lbAdd (format ["%1x %2", str (_x select 1), (getText (configFile >> _config >> _x select 0 >> "displayName"))]);
} forEach KPCF_inventory;

// Maths for the progress bar
Expand All @@ -48,7 +45,6 @@ private _itemMass = 0;
};
} else {
_itemMass = getNumber (configFile >> _config >> _type >> "mass");
systemChat format ["%1", _itemMass];
};
_load = _load + (_itemMass * (_x select 1));
} forEach KPCF_inventory;
Expand Down
19 changes: 6 additions & 13 deletions KP-Cratefiller/KPCF/ui/KPCF_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class KPCF_dialog {
};

// Inventory

/*
class KP_ExportName: KPGUI_PRE_EditBox {
idc = 75820;
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,2,4);
Expand Down Expand Up @@ -173,20 +173,12 @@ class KPCF_dialog {
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,3,4);
onButtonClick = "";
};

*/
class KP_InventoryList: KPGUI_PRE_ListBox {
idc = 75822;
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,9,16);
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,8,16);
y = KP_GETCY(KP_Y_VAL_S,KP_HEIGHT_VAL_S,14,48);
w = KP_GETW(KP_WIDTH_VAL_S,(16/6));
h = KP_GETH(KP_HEIGHT_VAL_S,(48/32));
};

class KP_InventoryAmount: KP_InventoryList {
idc = 75823;
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,1,2);
y = KP_GETCY(KP_Y_VAL_S,KP_HEIGHT_VAL_S,14,48);
w = KP_GETW(KP_WIDTH_VAL_S,16);
w = KP_GETW(KP_WIDTH_VAL_S,(16/7));
h = KP_GETH(KP_HEIGHT_VAL_S,(48/32));
};

Expand Down Expand Up @@ -218,11 +210,12 @@ class KPCF_dialog {
};

class KP_ProgressBar : KPGUI_PRE_ProgressBar {
idc = 75824;
idc = 75823;
x = KP_GETCX(KP_X_VAL_S,KP_WIDTH_VAL_S,0,1);
y = KP_GETCY(KP_Y_VAL_S,KP_HEIGHT_VAL_S,46,48);
w = KP_GETW(KP_WIDTH_VAL_S,1);
h = KP_GETH(KP_HEIGHT_VAL_S,24);
tooltip = "$STR_KPCF_FILLLEVEL"
};

};
Expand Down
11 changes: 8 additions & 3 deletions KP-Cratefiller/KPCF_config.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@
Configuration file for various variables of the KP cratefiller.
*/

// Defines the cratefiller base
// The Base object is for the player interaction, so at these object you can open the dialog
KPCF_cratefillerBase = [
"Land_Cargo10_military_green_F"
];

// Defines the cratefiller spawn
// The Spawn object is the point where crates will spawn and acts the center for the KPCF_spawnRadius
KPCF_cratefillerSpawn = "Land_HelipadCivil_F";

// Defines the radius of the spawn
// These variable defines the range where inventories can be edited
// Example: With an setting of 10 all objects in a radius of 10m from the center of the spawn object can be edited
KPCF_spawnRadius = 10;

// Defines the distance for the interaction (addAction / ACE)
KPCF_interactRadius = 5;

// Defines the distance in which the loop searches for placed interaction (base) objects
// A lower value will be more performant
KPCF_checkDistance = 200;

// Defines the available crates
KPCF_crates = [
"B_supplyCrate_F",
Expand Down
23 changes: 23 additions & 0 deletions KP-Cratefiller/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

## [1.0.1] - 2018-10-19
### Added
- New variable in the config file to define the distance for the base object search radius
- Tooltip for the progress bar

### Changed
- Comments in the config file for a better understanding
- Some stringtable adjustments
- Moved whole module to the clients, no more server executions

### Fixed
- Hide unused dialog controls
- Syntax changes to the storage capacity check
- Sync problem of the inventory listboxes
- Base objects are no longer detected as valid storage
- Inventory list will now clear if the selected storage will be removed

### Removed
- Old debug testing outputs

[1.0.1]: https://github.com/KillahPotatoes/dubjunks-scripts/pull/11
11 changes: 8 additions & 3 deletions KP-Cratefiller/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,18 @@
<German>%1 wurde bereitgestellt!</German>
</Key>
<Key ID="STR_KPCF_HINTFULL">
<Original>The selected storage is full!</Original>
<English>The selected storage is full!</English>
<German>Der ausgewählte Laderaum ist voll!</German>
<Original>The selected cargo space doesn't have sufficient space!</Original>
<English>The selected cargo space doesn't have sufficient space!</English>
<German>Der ausgewählte Laderaum hat keinen ausreichenden Platz!</German>
</Key>
<Key ID="STR_KPCF_NOSPAWN">
<Original>No loading zone available!</Original>
<English>No loading zone available!</English>
<German>Keine Ladezone vorhanden!</German>
</Key>
<Key ID="STR_KPCF_FILLLEVEL">
<Original>Shows the current cargo space!</Original>
<English>Shows the current cargo space!</English>
<German>Zeigt den aktuellen Laderaum stand!</German>
</Key>
</Project>
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# KP Cratefiller

## Description
![cfpreview](https://i.imgur.com/ysawNQ2.jpg)
![cfpreview](https://i.imgur.com/zx96NAN.jpg)

With this script you get a dialog with the ability to manage several inventories. It's created to make logistics easier and pleasant.

Expand All @@ -25,7 +25,7 @@ You can spawn and delete defined crates, fill these crates and also other object

## Languages

Currently the mod is localized for:
Currently the module is localized for:
* English
* German

Expand Down Expand Up @@ -66,7 +66,10 @@ For Support join the Killah Potatoes discord and move in the `#kp-mods`channel.

* Automatic generated item lists with blacklist
* More equipment categorys
* Alphabetical sorting of the lists
* Export and import function for created inventories
* ACE3 interaction support
* Various code optimizations

## Licence
Copyright (C) 2018 [Dubjunk](https://github.com/Dubjunk)
Expand Down

0 comments on commit b973916

Please sign in to comment.