74[
EntityEditorProps(
category:
"", description:
"A centralized system which lets many users perform actions on addons. Most likely only needed in the main menu world.")]
84 static const string ADDONS_CLI =
"addons";
85 static const string VERSION_DOT =
".";
149 array<ref SCR_WorkshopItem> ret = {};
161 array<ref SCR_WorkshopItem> ret = {};
164 if (item.GetOffline())
177 #ifdef WORKSHOP_DEBUG
178 _print(
string.Format(
"Register WorkshopItem: ID: %1, Name: %2, Found in map: %3",
id, item.Name(), existingItem != null));
183 existingItem.Internal_UpdateObjects(item, null);
185 #ifdef WORKSHOP_DEBUG
195 #ifdef WORKSHOP_DEBUG
209 #ifdef WORKSHOP_DEBUG
210 _print(
string.Format(
"Register Dependency: ID: %1, Name: %2, Found in map: %3",
id, item.GetName(), existingItem != null));
215 existingItem.Internal_UpdateObjects(null, item);
217 #ifdef WORKSHOP_DEBUG
227 #ifdef WORKSHOP_DEBUG
256 return SocialComponent.IsPrivilegedTo(
EUserInteraction.UserGeneratedContent);
288 return System.IsCLIParam(ADDONS_CLI);
306 array<ref SCR_WorkshopItem> ret = {};
327 if (returnOnFirstMatch)
340 array<ref SCR_WorkshopItem> ret = {};
361 if (returnOnFirstMatch)
374 array<ref SCR_WorkshopItem> ret = {};
394 if (returnOnFirstMatch)
408 array<string> fromNums = {};
409 vFrom.Split(VERSION_DOT, fromNums,
false);
411 array<string> toNums = {};
412 vTo.Split(VERSION_DOT, toNums,
false);
415 int count = fromNums.Count();
416 if (count > toNums.Count())
417 count = toNums.Count();
419 for (
int i; i < count; i++)
421 int iFrom = fromNums[i].ToInt();
422 int iTo = toNums[i].ToInt();
430 else if (iFrom > iTo)
435 else if (iFrom == iTo)
438 int end = vTo.IndexOfFrom(i, VERSION_DOT) - 1;
453 Revision currentRev = item.GetActiveRevision();
457 if (item.GetDownloadingRevision())
458 return SCR_ERevisionAvailability.ERA_DOWNLOAD_NOT_FINISHED;
460 return SCR_ERevisionAvailability.ERA_UNKNOWN_AVAILABILITY;
467 return SCR_ERevisionAvailability.ERA_AVAILABLE;
469 Revision latestRev = item.GetLatestRevision();
474 Print(
"ItemAvailability() - Can't compare availability of item " + item.Name() +
" latest revision",
LogLevel.WARNING);
475 return SCR_ERevisionAvailability.ERA_DELETED;
483 return SCR_ERevisionAvailability.ERA_COMPATIBLE_UPDATE_AVAILABLE;
485 return SCR_ERevisionAvailability.ERA_DELETED;
493 return SCR_ERevisionAvailability.ERA_COMPATIBLE_UPDATE_AVAILABLE;
496 return SCR_ERevisionAvailability.ERA_OBSOLETE;
499 return SCR_ERevisionAvailability.ERA_AVAILABLE;
541 int count = items.Count() - 1;
559 addons[remaining].SetEnabled(enable);
605 #ifdef WORKSHOP_DEBUG
606 _print(
string.Format(
"Registered new item: %1", itemWrapper.
GetName()));
657 default:
return false;
669 for (
int bit = 0; bit < 32; bit++)
671 if (
flags & currentFlag)
676 currentFlag = currentFlag << 1;
686 for (
int bit = 0; bit < 32; bit++)
688 if (
flags & currentFlag)
693 currentFlag = currentFlag << 1;
708 private void ~SCR_AddonManager()
741 api.ScanOfflineItems();
749 item.SetEnabled(
false);
780 array<WorkshopItem> items = {};
781 api.GetOfflineItems(items);
789 array<ref SCR_WorkshopItem> pendingDownloads = {};
796 scrItem.Internal_OnAddonsChecked();
800 pendingDownloads.Insert(scrItem);
811 download.PauseDownload();
816 array<string> addonIds = {};
817 GetGame().ReloadFailureAddons(addonIds);
818 array<ref SCR_WorkshopItem> arr = {};
819 foreach(
auto addon: addonIds)
833 _print(
"Callback_GetPrivilege_OnPrivilegeResult()",
LogLevel.NORMAL);
839 _print(
string.Format(
" UserPrivilege.USER_GEN_CONTENT: %1", allowed),
LogLevel.NORMAL);
863 array<string> unregisterIds;
864 array<SCR_WorkshopItem> updateItems;
876 int refCount = item.GetRefCount();
877 bool canBeUnregistered = item.Internal_GetCanBeUnregistered();
878 if (canBeUnregistered && item.GetRefCount() == 2)
883 unregisterIds.Insert(
id);
891 updateItems.Insert(item);
901 item.Internal_Update(timeSlice);
907 #ifdef WORKSHOP_DEBUG
908 _print(
string.Format(
"Unregistering items: %1", unregisterIds.Count()));
911 foreach (
string id : unregisterIds)
913 #ifdef WORKSHOP_DEBUG
915 _print(
string.Format(
"Unregistered item: %1", item.
GetName()));
928 string addonsEnabled;
931 if (item.GetEnabled())
932 addonsEnabled = addonsEnabled +
id +
" ";
979 auto wi = item.Internal_GetWorkshopItem();
980 if (!wi || (wi.GetLatestRevision() && !wi.GetLatestRevision().IsDownloaded()))
1011 void SelectPreset(SCR_WorkshopAddonPreset preset, notnull array<ref SCR_WorkshopAddonPresetAddonMeta> addonsNotFound)
1024 array<ref SCR_WorkshopAddonPresetAddonMeta> enabledAddons =
m_SelectedPreset.GetAddons();
1025 array<ref SCR_WorkshopItem> addons = {};
1029 string guid = meta.GetGuid();
1033 addons.Insert(item);
1068 array<ref SCR_WorkshopAddonPresetAddonMeta> addonsMeta = {};
1071 string guid = item.GetId();
1075 if (addonsMeta.IsEmpty())
1078 SCR_WorkshopAddonPreset preset = (
new SCR_WorkshopAddonPreset()).
Init(presetName, addonsMeta);
1088 return enabledAddons.Count();
1105 Print(
string.Format(
"[SCR_AddonManager] %1 %2",
this, str), logLevel);
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
ScriptInvokerBase< ScriptInvokerSCRWorkshopItemMethod > ScriptInvokerWorkshopItem
func ScriptInvokerSCRWorkshopItemMethod
SCR_AddonManager ERA_COMPATIBLE_UPDATE_AVAILABLE
SCR_AddonManager ERA_UNKNOWN_AVAILABILITY
@ DEPENDENCY_UPDATE_AVAILABLE
@ LOCAL_VERSION_MATCH_DEPENDENCY
@ NOT_LOCAL_VERSION_MATCH_DEPENDENCY
@ ENABLED_AND_DEPENDENCY_DISABLED
SCR_AddonManager ERA_DOWNLOAD_NOT_FINISHED
SCR_WorkshopItem GetItem()
@ BLOCKED
User has this asset blocked so it should not be possible to interact with it until unblocked.
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
SCR_ContentBrowserTileComponent RESTRICTED
enum SCR_EServicePointType OFFLINE
enum SCR_EServicePointType ONLINE
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external EntityEvent SetEventMask(EntityEvent e)
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
Shows a list of addons and some text.
static SCR_AddonListDialog CreateFailedToStartWithMods(array< ref SCR_WorkshopItem > items)
Dialog when failed to load game with selected mods.
float m_fAddonsEnabledTimer
static int CountItemsBasic(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query, bool returnOnFirstMatch=false)
ref array< ref SCR_WorkshopAddonPresetAddonMeta > m_aAddonsNotFound
ScriptInvoker GetEventOnAddonEnabled()
static bool CheckQueryFlagsAnd(SCR_WorkshopItem item, EWorkshopItemQuery flags)
Checks if all flags are satisfied.
SCR_WorkshopItem Register(WorkshopItem item)
Returns a SCR_WorkshopItem. If it's not registered, creates a new one and registers it.
int CountOfEnabledAddons()
Return int count of all enabled mods.
void SelectPreset(SCR_WorkshopAddonPreset preset, notnull array< ref SCR_WorkshopAddonPresetAddonMeta > addonsNotFound)
static bool GetAddonEnabledExternally(SCR_WorkshopItem item)
Returns true if addon was enabled through external configuration (CLI or other).
SCR_WorkshopAddonPreset CreatePresetFromEnabledAddons(string presetName)
ref ScriptInvoker m_OnAddonOfflineStateChanged
ref ScriptInvoker Event_OnAllAddonsEnabled
array< ref SCR_WorkshopItem > GetOfflineAddons()
Returns array with all offline addons.
int GetCountAddonsOutdated()
Returns count of outdated addons.
SCR_WorkshopAddonPreset m_SelectedPreset
override void EOnInit(IEntity owner)
void Callback_GetPrivilege_OnPrivilegeResult(UserPrivilege privilege, UserPrivilegeResult result)
ref ScriptInvoker m_OnUgcPrivilegeResult
static const float ADDONS_OUTDATED_UPDATE_INTERVAL_S
void Callback_CheckAddons_OnSuccess()
void Callback_OnAddonOfflineStateChanged(SCR_WorkshopItem item, bool newState)
Called from the specific SCR_WorkshopItem.
void NegotiateUgcPrivilegeAsync()
static array< ref SCR_WorkshopItem > SelectItemsBasic(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query)
void Callback_OnAddonReportStateChanged(SCR_WorkshopItem item, bool newReport)
Called from the specific SCR_WorkshopItem.
static bool GetAddonsEnabledExternally()
Returns true when external addon configuration is used (through CLI or other means).
void AddonCheckError(BackendCallback callback)
string GetItemId(WorkshopItem item)
static int CountItemsAnd(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query, bool returnOnFirstMatch=false)
Counts items which match query. All flags must match.
void AddonCheckResponse(BackendCallback callback)
float m_fAddonsOutdatedTimer
void _print(string str, LogLevel logLevel=LogLevel.DEBUG)
ref map< string, ref SCR_WorkshopItem > m_mItems
ScriptInvoker GetEventOnAllAddonsEnabled()
ref SCR_ScriptPlatformRequestCallback m_CallbackGetPrivilege
array< ref SCR_WorkshopItem > GetAllAddons()
Returns array with all addons currently in the system - online and offline.
SCR_LoadingOverlay m_LoadingOverlay
void EnableAddonsRecursively(array< ref SCR_WorkshopItem > addons, out int remaining, bool enable)
static SCR_ComparerOperator DifferenceBetweenVersions(string vFrom, string vTo)
Return difference type between current version from current to target.
static SCR_AddonManager s_Instance
map< string, ref SCR_WorkshopItem > GetItemsMap()
static SCR_ERevisionAvailability ItemAvailability(notnull WorkshopItem item)
void Internal_OnNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
Called by SCR_WorkshopItem when it starts a new download.
void InvokeEventOnAddonEnabled(SCR_WorkshopItem arg0, int arg1)
void RegisterNewItem(string id, SCR_WorkshopItem itemWrapper)
SCR_WorkshopAddonManagerPresetStorage GetPresetStorage()
void OnOfflineAddonsDisabled()
ref ScriptInvoker m_OnAddonsChecked
ref array< WorkshopItem > m_aAddonsToRegister
static bool CheckQueryFlag(SCR_WorkshopItem item, EWorkshopItemQuery flag)
bool GetUgcPrivilege()
Returns immediate value of UserPrivilege.USER_GEN_CONTENT.
static int CountItemsOr(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query, bool returnOnFirstMatch=false)
Counts items which match query.Any flag must match.
ref ScriptInvoker m_OnAddonReportedStateChanged
void CountOutdatedAddons()
Go throught all offline addons and count size.
static array< ref SCR_WorkshopItem > SelectItemsOr(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query)
bool GetAddonsChecked()
True when all async checks are done. Doesn't indicate that all checks were successful!
ref ScriptInvoker m_OnNewDownload
void InvokeEventOnAllAddonsEnabled()
string GetItemId(Dependency item)
ref SCR_WorkshopAddonManagerPresetStorage m_Storage
void Internal_CheckAddons()
When internet is disabled, might take a lot of time to complete the request.
static const float ADDONS_ENABLED_UPDATE_INTERVAL_S
SCR_WorkshopItem Register(Dependency item)
Returns a SCR_WorkshopItem. If it's not registered, creates a new one and registers it.
ref ScriptInvoker m_OnAddonsEnabledChanged
void FinalizeInitAfterAsyncChecks()
Finishes init after all async checks are done.
static bool CheckQueryFlagsOr(SCR_WorkshopItem item, EWorkshopItemQuery flags)
Checks if any flag is satisfied.
void OnAllAddonsEnabledCorrupted()
Call this when all dialog are enabled, but some are missing to show which one.
string m_sAddonsEnabledPrev
SCR_WorkshopItem GetItem(string id)
ref BackendCallback m_AddonCheckCallback
ref BackendCallback m_CallbackCheckAddons
static array< ref SCR_WorkshopItem > SelectItemsAnd(array< ref SCR_WorkshopItem > items, EWorkshopItemQuery query)
void EnableMultipleAddons(array< ref SCR_WorkshopItem > items, bool enable)
Enable/disable multiple mods recursively to save performance.
ref ScriptInvoker< SCR_WorkshopItem, int > Event_OnAddonEnabled
override void EOnFrame(IEntity owner, float timeSlice)
static SCR_AddonManager GetInstance()
static SCR_DownloadManager GetInstance()
array< ref SCR_WorkshopItemActionDownload > DownloadItems(array< ref SCR_WorkshopItem > items)
static SCR_LoadingOverlay ShowForWidget(Widget targetWidget, string text=string.Empty, bool showBlur=true, bool showBackground=true)
array< ref SCR_WorkshopItem > GetLoadedDependencies()
void LogState()
Logs all properties of the object into console.
bool GetLoaded()
True when addon is loaded by engine. It means that the game is already running with this mod.
bool GetOffline()
True when we have the item on our local storage.
bool GetEnabledAndAnyDependencyDisabled()
Returns true if any dependency is offline and disabled.
EWorkshopItemProblem GetHighestPriorityProblem()
bool GetAnyDependencyUpdateAvailable()
bool GetUpdateAvailable()
Returns true when we have an old version offline, and the new version.
bool GetRestricted()
Returns true when item is restricted for any reason (blocked or reported).
static SCR_WorkshopItem Internal_CreateFromWorkshopItem(WorkshopItem item)
bool GetAnyDependencyMissing()
bool GetModAuthorReportedByMe()
bool GetOnline()
True when the item is stored in the backend.
bool GetCurrentLocalVersionMatchDependency()
Returns true if current local version matches version of dependency.
static SCR_WorkshopItem Internal_CreateFromDependency(Dependency dependency)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
EntityEvent
Various entity events.
EntityFlags
Various entity flags.
EUserInteraction
Interaction type between two players.