Skip to content

Commit

Permalink
modified do all rule for close all, hide all, reveal all (v2.12.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Oct 24, 2024
1 parent 71c5daf commit cfb0a45
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 237 deletions.
8 changes: 8 additions & 0 deletions Assets/OxGFrame/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## [2.12.0] - 2024-10-24 (rule changed)
- Modified CloseAll, HideAll, RevealAll rules of method for UIFrame and SRFrame.
- Set the default group id to 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1.
- ex: CloseAll(-1) do all without any group id.
- ex: HideAll(-1) do all without any group id.
- ex: RevealAll(-1) do all without any group id.
- Modified CloseAllAndExcluded and HideAllAndExcluded to support the withoutAssetNames param.

## [2.11.12] - 2024-10-17
- Optimized the bundle decryption memory allocation method to avoid allocating excessively large memory in a single ReadAllBytes operation.

Expand Down
92 changes: 73 additions & 19 deletions Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/CoreFrames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace OxGFrame.CoreFrame
{
public static class CoreFrames
{
/// <summary>
/// Default group id
/// </summary>
internal const int DEFAULT_GROUP_ID = 0;

public static class UIFrame
{
public static bool ignoreTimeScale
Expand Down Expand Up @@ -200,6 +205,7 @@ public static async UniTask Preload(string packageName, string[] assetNames, uin
#region Show
/// <summary>
/// If use prefix "res#" will load from resources else will load from bundle
/// <para>Default group id is 0</para>
/// </summary>
/// <param name="assetName"></param>
/// <param name="data"></param>
Expand All @@ -211,12 +217,12 @@ public static async UniTask Preload(string packageName, string[] assetNames, uin
public static async UniTask<UIBase> Show(string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
{
var packageName = AssetPatcher.GetDefaultPackageName();
return await UIManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
return await UIManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
}

public static async UniTask<UIBase> Show(string packageName, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
{
return await UIManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
return await UIManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
}

public static async UniTask<UIBase> Show(int groupId, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
Expand All @@ -233,12 +239,12 @@ public static async UniTask<UIBase> Show(int groupId, string packageName, string
public static async UniTask<T> Show<T>(string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : UIBase
{
var packageName = AssetPatcher.GetDefaultPackageName();
return await UIManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
return await UIManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
}

public static async UniTask<T> Show<T>(string packageName, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : UIBase
{
return await UIManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
return await UIManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
}

public static async UniTask<T> Show<T>(int groupId, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : UIBase
Expand All @@ -259,19 +265,31 @@ public static void Close(string assetName, bool disabledPreClose = false, bool f
UIManager.GetInstance().Close(assetName, disabledPreClose, forceDestroy);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="disabledPreClose"></param>
/// <param name="forceDestroy"></param>
/// <param name="withoutAssetNames"></param>
public static void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
UIManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, false, withoutAssetNames);
UIManager.GetInstance().CloseAll(DEFAULT_GROUP_ID, disabledPreClose, forceDestroy, false, withoutAssetNames);
}

public static void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
UIManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, false, withoutAssetNames);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="disabledPreClose"></param>
/// <param name="forceDestroy"></param>
/// <param name="withoutAssetNames"></param>
public static void CloseAllAndExcluded(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
UIManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, true, withoutAssetNames);
UIManager.GetInstance().CloseAll(DEFAULT_GROUP_ID, disabledPreClose, forceDestroy, true, withoutAssetNames);
}

public static void CloseAllAndExcluded(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
Expand All @@ -287,7 +305,7 @@ public static void CloseAllAndExcluded(int groupId, bool disabledPreClose = fals
/// <param name="forceDestroy"></param>
public static void CloseStackByStack(string canvasName, bool disabledPreClose = false, bool forceDestroy = false)
{
UIManager.GetInstance().CloseStackByStack(0, canvasName, disabledPreClose, forceDestroy);
UIManager.GetInstance().CloseStackByStack(DEFAULT_GROUP_ID, canvasName, disabledPreClose, forceDestroy);
}

/// <summary>
Expand All @@ -309,9 +327,12 @@ public static void Reveal(string assetName)
UIManager.GetInstance().Reveal(assetName);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
public static void RevealAll()
{
UIManager.GetInstance().RevealAll();
UIManager.GetInstance().RevealAll(DEFAULT_GROUP_ID);
}

public static void RevealAll(int groupId)
Expand All @@ -326,19 +347,27 @@ public static void Hide(string assetName)
UIManager.GetInstance().Hide(assetName);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="withoutAssetNames"></param>
public static void HideAll(params string[] withoutAssetNames)
{
UIManager.GetInstance().HideAll(false, withoutAssetNames);
UIManager.GetInstance().HideAll(DEFAULT_GROUP_ID, false, withoutAssetNames);
}

public static void HideAll(int groupId, params string[] withoutAssetNames)
{
UIManager.GetInstance().HideAll(groupId, false, withoutAssetNames);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="withoutAssetNames"></param>
public static void HideAllAndExcluded(params string[] withoutAssetNames)
{
UIManager.GetInstance().HideAll(true, withoutAssetNames);
UIManager.GetInstance().HideAll(DEFAULT_GROUP_ID, true, withoutAssetNames);
}

public static void HideAllAndExcluded(int groupId, params string[] withoutAssetNames)
Expand Down Expand Up @@ -505,6 +534,7 @@ public static async UniTask Preload(string packageName, string[] assetNames, uin
#region Show
/// <summary>
/// If use prefix "res#" will load from resources else will load from bundle
/// <para>Default group id is 0</para>
/// </summary>
/// <param name="assetName"></param>
/// <param name="data"></param>
Expand All @@ -516,12 +546,12 @@ public static async UniTask Preload(string packageName, string[] assetNames, uin
public static async UniTask<SRBase> Show(string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
{
var packageName = AssetPatcher.GetDefaultPackageName();
return await SRManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
return await SRManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
}

public static async UniTask<SRBase> Show(string packageName, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
{
return await SRManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
return await SRManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent);
}

public static async UniTask<SRBase> Show(int groupId, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null)
Expand All @@ -538,12 +568,12 @@ public static async UniTask<SRBase> Show(int groupId, string packageName, string
public static async UniTask<T> Show<T>(string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : SRBase
{
var packageName = AssetPatcher.GetDefaultPackageName();
return await SRManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
return await SRManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
}

public static async UniTask<T> Show<T>(string packageName, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : SRBase
{
return await SRManager.GetInstance().Show(0, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
return await SRManager.GetInstance().Show(DEFAULT_GROUP_ID, packageName, assetName, data, awaitingUIAssetName, priority, progression, parent) as T;
}

public static async UniTask<T> Show<T>(int groupId, string assetName, object data = null, string awaitingUIAssetName = null, uint priority = 0, Progression progression = null, Transform parent = null) where T : SRBase
Expand All @@ -564,19 +594,31 @@ public static void Close(string assetName, bool disabledPreClose = false, bool f
SRManager.GetInstance().Close(assetName, disabledPreClose, forceDestroy);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="disabledPreClose"></param>
/// <param name="forceDestroy"></param>
/// <param name="withoutAssetNames"></param>
public static void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
SRManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, false, withoutAssetNames);
SRManager.GetInstance().CloseAll(DEFAULT_GROUP_ID, disabledPreClose, forceDestroy, false, withoutAssetNames);
}

public static void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
SRManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, false, withoutAssetNames);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="disabledPreClose"></param>
/// <param name="forceDestroy"></param>
/// <param name="withoutAssetNames"></param>
public static void CloseAllAndExcluded(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
{
SRManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, true, withoutAssetNames);
SRManager.GetInstance().CloseAll(DEFAULT_GROUP_ID, disabledPreClose, forceDestroy, true, withoutAssetNames);
}

public static void CloseAllAndExcluded(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
Expand All @@ -591,9 +633,12 @@ public static void Reveal(string assetName)
SRManager.GetInstance().Reveal(assetName);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
public static void RevealAll()
{
SRManager.GetInstance().RevealAll();
SRManager.GetInstance().RevealAll(DEFAULT_GROUP_ID);
}

public static void RevealAll(int groupId)
Expand All @@ -610,17 +655,26 @@ public static void Hide(string assetName)

public static void HideAll(params string[] withoutAssetNames)
{
SRManager.GetInstance().HideAll(false, withoutAssetNames);
SRManager.GetInstance().HideAll(DEFAULT_GROUP_ID, false, withoutAssetNames);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="groupId"></param>
/// <param name="withoutAssetNames"></param>
public static void HideAll(int groupId, params string[] withoutAssetNames)
{
SRManager.GetInstance().HideAll(groupId, false, withoutAssetNames);
}

/// <summary>
/// Default group id is 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1
/// </summary>
/// <param name="withoutAssetNames"></param>
public static void HideAllAndExcluded(params string[] withoutAssetNames)
{
SRManager.GetInstance().HideAll(true, withoutAssetNames);
SRManager.GetInstance().HideAll(DEFAULT_GROUP_ID, true, withoutAssetNames);
}

public static void HideAllAndExcluded(int groupId, params string[] withoutAssetNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,6 @@ public async virtual UniTask<T> Show(int groupId, string packageName, string ass
/// <param name="forceDestroy"></param>
public virtual void Close(string assetName, bool disabledPreClose = false, bool forceDestroy = false) { }

/// <summary>
/// 全部關閉
/// </summary>
/// <param name="disabledPreClose"></param>
/// <param name="forceDestroy"></param>
/// <param name="withoutAssetNames"></param>
public virtual void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames) { }

/// <summary>
/// 透過 id 群組進行全部關閉
/// </summary>
Expand All @@ -598,11 +590,6 @@ public virtual void CloseAll(int groupId, bool disabledPreClose = false, bool fo
/// <param name="assetName"></param>
public virtual void Reveal(string assetName) { }

/// <summary>
/// 全部解除隱藏 (只允許 Hide, 如果透過 Close 則無法進行 Reveal)
/// </summary>
public virtual void RevealAll() { }

/// <summary>
/// 透過 id 群組進行全部解除隱藏 (只允許 Hide, 如果透過 Close 則無法進行 Reveal)
/// </summary>
Expand All @@ -617,11 +604,6 @@ public virtual void RevealAll(int groupId) { }
/// <param name="assetName"></param>
public virtual void Hide(string assetName) { }

/// <summary>
/// 全部隱藏 (可透過 Show 或者 Reveal 進行顯示, 差別在於初始行為)
/// </summary>
public virtual void HideAll(bool forceHideExcluded = false, params string[] withoutAssetNames) { }

/// <summary>
/// 透過 id 群組進行全部隱藏 (可透過 Show 或者 Reveal 進行顯示, 差別在於初始行為)
/// </summary>
Expand Down
Loading

0 comments on commit cfb0a45

Please sign in to comment.