Skip to content

Commit

Permalink
Created Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiF90 committed Apr 13, 2024
0 parents commit b2efa09
Show file tree
Hide file tree
Showing 52 changed files with 4,113 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ARMAPERSCORE - Arma Persistent Core System Changelog

## Known Issues
None currently

## Version History

* Version 1.0.0
- Initial Release
Binary file added Images/Cover_Image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions Licence.md

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions Persistent/Core/fn_clearSave.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Author: PrinceF90
Description:
Removes all persisted data for given save _slot.
Parameter(s):
0: _slot(optional) - if not specified, all data persisted by this system will be removed
*/
params ["_slot"];

[PersistentDebug, "clearSave", "Clearing save...", false] call F90_fnc_debug;
// private ["_variables"];

if (isNil "_slot") then
{
[PersistentDebug, "clearSave", "Clearing all saves.", false] call F90_fnc_debug;
//_variables = [] call F90_fnc_listExistingVariables;
} else
{
[PersistentDebug, "clearSave", format ["Clearing progress from slot %1", _slot], false] call F90_fnc_debug;
//_variables = [_slot] call F90_fnc_listExistingVariables;
};

/*
{
profileNamespace setVariable [_x, nil];
} forEach _variables;
saveProfileNamespace;
*/

[PersistentDebug, "clearSave", "Save cleared.", false] call F90_fnc_debug;
36 changes: 36 additions & 0 deletions Persistent/Core/fn_loadData.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Funtion to retrieves a value for given _key from profileNamespace for save on given _slot.
This script is modified so that old save can still be loaded even after the mission gets updated without corrupting old saves
SYNTAX:
[key, slot] call F90_fnc_loadData;
PARAMETERS:
key : Can be one of the following:
- STRING
- ARRAY [key,default] where default is the default value to use if key doesn't exist
slot: save slot to find the key from
RETURN:
value of given _key on given save _slots
*/

params ["_key", "_slot"];
[PersistentDebug, "loadData", format ["Loading data for key %1 on save slot %2.", _key, _slot], false] call F90_fnc_debug;

private ["_returnData", "_loadKey", "_default", "_keyToFind"];
if (typeName _key == "STRING") then
{
_loadKey = _key;
_keyToFind = format ["%1.%2.%3", Persistent_SavePrefix, _slot, _loadKey];
_returnData = profileNamespace getVariable _keyToFind;
};
if (typeName _key == "ARRAY") then
{
_loadKey = _key # 0;
_default = _key # 1;
_keyToFind = format ["%1.%2.%3", Persistent_SavePrefix, _slot, _loadKey];
_returnData = profileNamespace getVariable [_keyToFind, _default];
};

[PersistentDebug, "loadData", format ["Key %1 loaded.", _key, _slot], false] call F90_fnc_debug;

_returnData;
27 changes: 27 additions & 0 deletions Persistent/Core/fn_saveData.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Author: PrinceF90
Description:
Function to save data into the profileNamespace using a specified key, value, and slot. It sets a variable in the profileNamespace with a formatted key name and assigns it the provided value.
Parameter(s):
0: STRING - _key: The key used to identify the data being saved.
1: Any - _value: The value to be saved.
2: SCALAR - _slot: The slot number where the data will be saved.
Returns:
None
Examples:
// Example 1: Saving data with key "player_name" and value "John" into slot 1
["player_name", "John", 1] call F90_fnc_saveData;
// Example 2: Saving data with key "score" and value 100 into slot 2
["score", 100, 2] call F90_fnc_saveData;
*/

params ["_key", "_value", "_slot"];

profileNamespace setVariable [format ["%1.%2.%3", Persistent_SavePrefix, _slot, _key], _value];

[PersistentDebug, "saveData", format["Data saved to %1.%2.%3", Persistent_SavePrefix, _slot, _key],false] call F90_fnc_debug;
25 changes: 25 additions & 0 deletions Persistent/Functions/fn_configurePersistent.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Author: PrinceF90
Description:
Configuration for ARMAPERSCORE
Parameters:
Does not accept any parameters
Returns:
0
Example:
[] call F90_fnc_configurePersistent;
*/
PersistentDebug = true;
[PersistentDebug, "configurePersistent",format ["Configuring %1...", Scenario_Name], true] call F90_fnc_debug;

Persistent_Host = player;

Persistent_SavePrefix = "F90_ARMAPERSCORE"; // The script will find saves from file by using this prefix
Persistent_SaveIntervals = 600;

configurePersistentDone = true;
[PersistentDebug, "configurePersistent", format ["Done configuring %1.", Scenario_Name], true] call F90_fnc_debug;
30 changes: 30 additions & 0 deletions Persistent/Functions/fn_deleteSlot.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Author: PrinceF90
Description:
Deletes a selected item from a persistent list and updates the profile namespace.
Parameter(s):
None
Returns:
None
Examples:
// [] call F90_fnc_deleteSlot;
// Result: Deletes the item at selected index from the persistent list and updates the profile namespace.
*/

PersistentMenu_SelectedList = [PersistentMenu_ListBox] call F90_fnc_getSelectedList;

if (PersistentMenu_SelectedList != 0) then
{
private _deletedItem = Persistent_Slots deleteAt PersistentMenu_SelectedList;
[PersistentDebug, "deleteSlot", format ["Deleted %1 from persistent list.", _deletedItem], false] call F90_fnc_debug;

profileNamespace setVariable [Persistent_PersistentListKey, Persistent_Slots];
[PersistentMenu_ListBox] call F90_fnc_updatePersistentList;
} else
{
[PersistentDebug, "deleteSlot", "Can't delete empty slot.", false] call F90_fnc_debug;
};
23 changes: 23 additions & 0 deletions Persistent/Functions/fn_generateSaveDate.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Generate a string Date and Time using format [hh:mm dd/mm/yy]
returns string Date and Time
*/

[PersistentDebug, "generateSaveDate", "Generating date and time string...", false] call F90_fnc_debug;

private _returnData = "";
private _time = systemTime;
private _hour = _time # 3;
private _minute = _time # 4;
private _day = _time # 2;
private _month = _time # 1;
private _year = _time # 0;

private _string = format ["%1:%2 %3/%4/%5",_hour,_minute,_day,_month,_year];

AWSP_Savetime = _string;
_returnData = _string;

[PersistentDebug, "generateSaveDate", "Date and time string generated.", false] call F90_fnc_debug;

_returnData;
27 changes: 27 additions & 0 deletions Persistent/Functions/fn_getSelectedList.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Author: PrinceF90
Description:
Returns the index of the currently selected item of the listbox with the idc (_listID).
Parameter(s):
0: NUMBER - The idc of the listbox
Returns:
NUMBER - The index of the currently selected item in the listbox , default will be the first item if nothing is selected
Examples:
// Example 1: Retrieving the selected index from listbox with ID 1106
private _lbList = 1106;
_selectedIndex = [_lbList] call F90_fnc_getSelectedList;
// Example 2: Retrieving the selected index from listbox with ID 1107
_selectedIndex = [1107] call F90_fnc_getSelectedList;
*/

params ["_listID"];

_selected = lbCurSel _listID;

if (_selected == -1) then {_selected = 0};

_selected;
11 changes: 11 additions & 0 deletions Persistent/Functions/fn_loadFromSlot.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PersistentMenu_SelectedList = [PersistentMenu_ListBox] call F90_fnc_getSelectedList;

[PersistentDebug, "loadFromSlot", "Loading progress...", false] call F90_fnc_debug;

if (PersistentMenu_SelectedList != 0) then
{
[PersistentMenu_SelectedList] call F90_fnc_loadGame;
} else
{
[PersistentDebug, "loadFromSlot", "Empty slot selected. Nothing to load from here.", false] call F90_fnc_debug;
};
30 changes: 30 additions & 0 deletions Persistent/Functions/fn_makePersistent.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Author: PrinceF90
Description:
A function that manages the persistence of an object by adding it to a persistent array if it is not already present.
Parameter(s):
0: OBJECT - The object to be made persistent.
1: ARRAY - The array containing persistent objects.
Returns:
None
Examples:
[_container, Persistent_ContainersToSave] call F90_fnc_makePersistent;
*/
params ["_object", "_persistentArray"];

[PersistentDebug, "makePersistent", format ["Trying to make %1 persistent...", _object], true] call F90_fnc_debug;

private _objectID = _persistentArray find _object;

if (_objectID == -1) then
{
_persistentArray pushback _object;
[PersistentDebug, "makePersistent", format ["%1 is now persistent.", _object], true] call F90_fnc_debug;
} else
{
[PersistentDebug, "makePersistent", format ["%1 is already persistent.", _object], true] call F90_fnc_debug;
};
20 changes: 20 additions & 0 deletions Persistent/Functions/fn_openPersistentTab.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[PersistentDebug, "openPersistentTab", format ["%1 opened Persistent Tab.", Persistent_Host], false] call F90_fnc_debug;

createDialog "persistentMenu";

// Tab ID
PersistentMenu_ListBox = 1102;
PersistentMenu_SaveButton = 1103;
PersistentMenu_LoadButton = 1104;
PersistentMenu_DeleteButton = 1105;
PersistentMenu_ScenarioNameText = 1106;
PersistentMenu_SaveVehicleButton = 1107;

// Update Scenario Name
ctrlSetText [PersistentMenu_ScenarioNameText, Scenario_Name];

// Update List Box
[PersistentMenu_ListBox] call F90_fnc_updatePersistentList;

// Tab Variables
PersistentMenu_SelectedList = [PersistentMenu_ListBox] call F90_fnc_getSelectedList;
29 changes: 29 additions & 0 deletions Persistent/Functions/fn_saveTarget.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Author: PrinceF90
Description:
This script checks the type of object the player is looking at (vehicle or container) and saves the object to a persistent array for future reference.
Parameter(s):
0: OBJECT - The cursor target object to be checked and saved.
1: ARRAY - The array where the persistent objects are stored.
Returns:
None
Examples:
[] call F90_fnc_saveTarget;
*/

private _cursorTarget = cursorTarget;
private _objectToSave = objNull;

if (_cursorTarget isKindOf "LandVehicle" || _cursorTarget isKindOf "Air" || _cursorTarget isKindOf "Ship") then
{
_objectToSave = _cursorTarget;
[_objectToSave] call F90_fnc_generateVehicleID;
[PersistentDebug, "saveTarget", format ["%1 added to save queue.", _cursorTarget], true] call F90_fnc_debug;
} else
{
[PersistentDebug, "saveTarget", format ["%1 is not a vehicle.", _cursorTarget], true] call F90_fnc_debug;
};
21 changes: 21 additions & 0 deletions Persistent/Functions/fn_saveTargetContainer.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Author: PrinceF90
Description:
Same as saveTarget, this script checks the type of object the player is looking at and saves the object to a persistent array. Use with caution as the script supposed to save only container.
Parameter(s):
0: OBJECT - The cursor target object to be checked and saved.
1: ARRAY - The array where the persistent objects are stored.
Returns:
None
Examples:
[] call F90_fnc_saveTarget;
*/

private _cursorTarget = cursorTarget;

[_cursorTarget, Persistent_ContainersToSave] call F90_fnc_makePersistent;
[PersistentDebug, "saveTargetContainer", format ["%1 is now persistent.", _cursorTarget], true] call F90_fnc_debug;
39 changes: 39 additions & 0 deletions Persistent/Functions/fn_saveToSlot.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Description:
This function is responsible for saving data to a specific slot in a persistent list. It generates a save date, creates a save name, and either creates a new save slot or updates an existing one based on user selection.
Parameters:
None
Returns:
0
Example Usage:
[] call F90_fnc_saveToSlot;
*/

PersistentMenu_SelectedList = [PersistentMenu_ListBox] call F90_fnc_getSelectedList;

[PersistentDebug, "saveToSlot", "Generating save...", false] call F90_fnc_debug;
private _saveDate = [] call F90_fnc_generateSaveDate;
private _saveName = format["%1 saved on, %2", Scenario_Name, _saveDate];
private _saveSlot = 0;

if (PersistentMenu_SelectedList == 0) then
{
[PersistentDebug, "saveToSlot", "Creating a new save slot...", false] call F90_fnc_debug;
Persistent_Slots pushBack _saveName;
_saveSlot = (count Persistent_Slots) -1;
} else
{
[PersistentDebug, "saveToSlot", format ["Saving to slot %1", PersistentMenu_SelectedList], false] call F90_fnc_debug;
Persistent_Slots set [PersistentMenu_SelectedList, _saveName];
_saveSlot = PersistentMenu_SelectedList;
};

[PersistentDebug, "saveToSlot", "Now saving...", false] call F90_fnc_debug;
[_saveSlot] call F90_fnc_saveGame;
profileNamespace setVariable [Persistent_PersistentListKey, Persistent_Slots];

[PersistentDebug, "saveToSlot", "Progress saved.", false] call F90_fnc_debug;
[PersistentMenu_ListBox] call F90_fnc_updatePersistentList;
Loading

0 comments on commit b2efa09

Please sign in to comment.