Skip to content

Commit d2eb29d

Browse files
Merge pull request michael811125#39 from michael811125/dev
updated to v2.11.9
2 parents 1cbcada + 5f31755 commit d2eb29d

File tree

8 files changed

+312
-47
lines changed

8 files changed

+312
-47
lines changed

Assets/OxGFrame/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## [2.11.9] - 2024-09-06
4+
- Added CoreFrames.SRFrame.CloseAllAndExcluded() method.
5+
- Added CoreFrames.UIFrame.CloseAllAndExcluded() method.
6+
- Added CoreFrames.UIFrame.SetupAndCheckUICanvas() method.
7+
- Added Bundle url set plan editor.
8+
- Added Media url set plan editor.
9+
- Fixed UIManager dict check issue.
10+
311
## [2.11.8] - 2024-08-10
412
- Added Reset method in Hotfixers.
513
- Modified nnId byte to int (NetFrame).

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/CoreFrames.cs

+33-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public static void InitInstance()
4040
UIManager.GetInstance();
4141
}
4242

43+
/// <summary>
44+
/// Finds an object by its name and sets and checks if there is a matching UICanvas context
45+
/// </summary>
46+
/// <param name="canvasName"></param>
47+
public static bool SetupAndCheckUICanvas(string canvasName)
48+
{
49+
return UIManager.GetInstance().SetupAndCheckUICanvas(canvasName);
50+
}
51+
4352
public static bool CheckIsShowing(string assetName)
4453
{
4554
return UIManager.GetInstance().CheckIsShowing(assetName);
@@ -252,12 +261,22 @@ public static void Close(string assetName, bool disabledPreClose = false, bool f
252261

253262
public static void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
254263
{
255-
UIManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, withoutAssetNames);
264+
UIManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, false, withoutAssetNames);
256265
}
257266

258267
public static void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
259268
{
260-
UIManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, withoutAssetNames);
269+
UIManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, false, withoutAssetNames);
270+
}
271+
272+
public static void CloseAllAndExcluded(bool disabledPreClose = false, bool forceDestroy = false)
273+
{
274+
UIManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, true);
275+
}
276+
277+
public static void CloseAllAndExcluded(int groupId, bool disabledPreClose = false, bool forceDestroy = false)
278+
{
279+
UIManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, true);
261280
}
262281

263282
/// <summary>
@@ -537,12 +556,22 @@ public static void Close(string assetName, bool disabledPreClose = false, bool f
537556

538557
public static void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
539558
{
540-
SRManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, withoutAssetNames);
559+
SRManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, false, withoutAssetNames);
541560
}
542561

543562
public static void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
544563
{
545-
SRManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, withoutAssetNames);
564+
SRManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, false, withoutAssetNames);
565+
}
566+
567+
public static void CloseAllAndExcluded(bool disabledPreClose = false, bool forceDestroy = false)
568+
{
569+
SRManager.GetInstance().CloseAll(disabledPreClose, forceDestroy, true);
570+
}
571+
572+
public static void CloseAllAndExcluded(int groupId, bool disabledPreClose = false, bool forceDestroy = false)
573+
{
574+
SRManager.GetInstance().CloseAll(groupId, disabledPreClose, forceDestroy, true);
546575
}
547576
#endregion
548577

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/Implement/FrameManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public virtual void Close(string assetName, bool disabledPreClose = false, bool
579579
/// <param name="disabledPreClose"></param>
580580
/// <param name="forceDestroy"></param>
581581
/// <param name="withoutAssetNames"></param>
582-
public virtual void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames) { }
582+
public virtual void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames) { }
583583

584584
/// <summary>
585585
/// 透過 id 群組進行全部關閉
@@ -588,7 +588,7 @@ public virtual void CloseAll(bool disabledPreClose = false, bool forceDestroy =
588588
/// <param name="disabledPreClose"></param>
589589
/// <param name="forceDestroy"></param>
590590
/// <param name="withoutAssetNames"></param>
591-
public virtual void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames) { }
591+
public virtual void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames) { }
592592
#endregion
593593

594594
#region Reveal

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/SRFrame/SRManager.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public override void Close(string assetName, bool disabledPreClose = false, bool
178178
this._Close(assetName, disabledPreClose, forceDestroy, false);
179179
}
180180

181-
public override void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
181+
public override void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames)
182182
{
183183
if (this._dictAllCache.Count == 0) return;
184184

@@ -212,13 +212,13 @@ public override void CloseAll(bool disabledPreClose = false, bool forceDestroy =
212212
if (!forceDestroy && !this.CheckIsShowing(srBase)) continue;
213213

214214
// 如有啟用 CloseAll 需跳過開關, 則不列入關閉執行
215-
if (srBase.srSetting.whenCloseAllToSkip) continue;
215+
if (!forceCloseExcluded && srBase.srSetting.whenCloseAllToSkip) continue;
216216

217217
this._Close(assetName, disabledPreClose, forceDestroy, true);
218218
}
219219
}
220220

221-
public override void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
221+
public override void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames)
222222
{
223223
if (this._dictAllCache.Count == 0) return;
224224

@@ -254,7 +254,7 @@ public override void CloseAll(int groupId, bool disabledPreClose = false, bool f
254254
if (!forceDestroy && !this.CheckIsShowing(srBase)) continue;
255255

256256
// 如有啟用 CloseAll 需跳過開關, 則不列入關閉執行
257-
if (srBase.srSetting.whenCloseAllToSkip) continue;
257+
if (!forceCloseExcluded && srBase.srSetting.whenCloseAllToSkip) continue;
258258

259259
this._Close(assetName, disabledPreClose, forceDestroy, true);
260260
}

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/UIFrame/UIManager.cs

+42-35
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void Awake()
5656
/// 透過對應名稱查找物件, 並且設置與檢查是否有匹配的 UICanvas 環境
5757
/// </summary>
5858
/// <param name="canvasName"></param>
59-
private bool _SetupAndCheckUICanvas(string canvasName)
59+
public bool SetupAndCheckUICanvas(string canvasName)
6060
{
6161
if (this._dictUICanvas.ContainsKey(canvasName)) return true;
6262

@@ -205,7 +205,7 @@ protected override UIBase Instantiate(UIBase uiBase, string assetName, AddIntoCa
205205
if (uiBase != null)
206206
{
207207
// 先檢查與設置 UICanvas 環境
208-
if (this._SetupAndCheckUICanvas(uiBase.uiSetting.canvasName))
208+
if (this.SetupAndCheckUICanvas(uiBase.uiSetting.canvasName))
209209
{
210210
uiCanvas = this.GetUICanvas(uiBase.uiSetting.canvasName);
211211
}
@@ -506,6 +506,7 @@ public int GetStackByStackCount(int groupId, string canvasName)
506506
{
507507
if (this._dictStackByStack.Count == 0) return 0;
508508
string key = $"{groupId}{canvasName}";
509+
if (!this._dictStackByStack.ContainsKey(key)) return 0;
509510
return this._dictStackByStack[key].Count;
510511
}
511512

@@ -609,7 +610,7 @@ public override void Close(string assetName, bool disabledPreClose = false, bool
609610
this._Close(assetName, disabledPreClose, forceDestroy, false);
610611
}
611612

612-
public override void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
613+
public override void CloseAll(bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames)
613614
{
614615
if (this._dictAllCache.Count == 0) return;
615616

@@ -643,13 +644,13 @@ public override void CloseAll(bool disabledPreClose = false, bool forceDestroy =
643644
if (!forceDestroy && !this.CheckIsShowing(uiBase) && !uiBase.allowInstantiate) continue;
644645

645646
// 如有啟用 CloseAll 需跳過開關, 則不列入關閉執行
646-
if (uiBase.uiSetting.whenCloseAllToSkip) continue;
647+
if (!forceCloseExcluded && uiBase.uiSetting.whenCloseAllToSkip) continue;
647648

648649
this._Close(assetName, disabledPreClose, forceDestroy, true);
649650
}
650651
}
651652

652-
public override void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, params string[] withoutAssetNames)
653+
public override void CloseAll(int groupId, bool disabledPreClose = false, bool forceDestroy = false, bool forceCloseExcluded = false, params string[] withoutAssetNames)
653654
{
654655
if (this._dictAllCache.Count == 0) return;
655656

@@ -685,7 +686,7 @@ public override void CloseAll(int groupId, bool disabledPreClose = false, bool f
685686
if (!forceDestroy && !this.CheckIsShowing(uiBase) && !uiBase.allowInstantiate) continue;
686687

687688
// 如有啟用 CloseAll 需跳過開關, 則不列入關閉執行
688-
if (uiBase.uiSetting.whenCloseAllToSkip) continue;
689+
if (!forceCloseExcluded && uiBase.uiSetting.whenCloseAllToSkip) continue;
689690

690691
this._Close(assetName, disabledPreClose, forceDestroy, true);
691692
}
@@ -994,20 +995,23 @@ protected void ExitAndHideReverse(UIBase uiBase, bool doReverse = true)
994995
{
995996
// 使用 GroupId + CanvasName 作為 Reverse 緩存的 Key (主要是獨立切出不同 Canvas 的反切緩存)
996997
var key = $"{uiBase.groupId}{uiBase.uiSetting.canvasName}";
997-
if (this._dictReverse[key].Count > 1)
998-
{
999-
// 如果當前 UI 是 Reverse 模式, 將會直接移除最上層的緩存
1000-
this._dictReverse[key].RemoveAt(this._dictReverse[key].Count - 1);
1001-
// 移除最上層後, 再取一次最上層 (等於是倒數第二變成最 Top)
1002-
var top = this._dictReverse[key][this._dictReverse[key].Count - 1];
1003-
// 開啟最上層的 UI (堆疊的緩存中後出的會有 isHidden = false 參考問題, 所以需要強制 doStack = false, 避免影響堆疊計數)
1004-
// ※備註: 另外就是如果 allowInstantiate = false, 會有 Data Reference 問題, 所以會需要儲存上一次的數據進行還原 (需注意在同參考的情況下, 當 Second Last 被關閉時, Hidden = true 剛好不用數據還原)
1005-
this.LoadAndDisplay(top.uiBase, top.data, false).Forget();
1006-
}
1007-
else if (this._dictReverse[key].Count > 0 && this._dictReverse[key].Count < 2)
998+
if (this._dictReverse.ContainsKey(key))
1008999
{
1009-
this._dictReverse[key].RemoveAt(this._dictReverse[key].Count - 1);
1010-
this._dictReverse.Remove(key);
1000+
if (this._dictReverse[key].Count > 1)
1001+
{
1002+
// 如果當前 UI 是 Reverse 模式, 將會直接移除最上層的緩存
1003+
this._dictReverse[key].RemoveAt(this._dictReverse[key].Count - 1);
1004+
// 移除最上層後, 再取一次最上層 (等於是倒數第二變成最 Top)
1005+
var top = this._dictReverse[key][this._dictReverse[key].Count - 1];
1006+
// 開啟最上層的 UI (堆疊的緩存中後出的會有 isHidden = false 參考問題, 所以需要強制 doStack = false, 避免影響堆疊計數)
1007+
// ※備註: 另外就是如果 allowInstantiate = false, 會有 Data Reference 問題, 所以會需要儲存上一次的數據進行還原 (需注意在同參考的情況下, 當 Second Last 被關閉時, Hidden = true 剛好不用數據還原)
1008+
this.LoadAndDisplay(top.uiBase, top.data, false).Forget();
1009+
}
1010+
else if (this._dictReverse[key].Count > 0 && this._dictReverse[key].Count < 2)
1011+
{
1012+
this._dictReverse[key].RemoveAt(this._dictReverse[key].Count - 1);
1013+
this._dictReverse.Remove(key);
1014+
}
10111015
}
10121016
}
10131017
}
@@ -1044,25 +1048,28 @@ protected void PopStackByStack(UIBase uiBase)
10441048
// 以 GroupId + CanvasName 作為 key
10451049
var key = $"{uiBase.groupId}{uiBase.uiSetting.canvasName}";
10461050
string currentAssetName = uiBase.assetName;
1047-
if (this._dictStackByStack[key].Count > 1)
1051+
if (this._dictStackByStack.ContainsKey(key))
10481052
{
1049-
int count = 1;
1050-
string assetName = this._dictStackByStack[key][this._dictStackByStack[key].Count - count];
1051-
// 如果 currentAssetName != assetName 表示被特別關閉
1052-
while (currentAssetName != assetName)
1053+
if (this._dictStackByStack[key].Count > 1)
10531054
{
1054-
// 往下查找直到匹配
1055-
++count;
1056-
if (count > this._dictStackByStack[key].Count) break;
1057-
assetName = this._dictStackByStack[key][this._dictStackByStack[key].Count - count];
1055+
int count = 1;
1056+
string assetName = this._dictStackByStack[key][this._dictStackByStack[key].Count - count];
1057+
// 如果 currentAssetName != assetName 表示被特別關閉
1058+
while (currentAssetName != assetName)
1059+
{
1060+
// 往下查找直到匹配
1061+
++count;
1062+
if (count > this._dictStackByStack[key].Count) break;
1063+
assetName = this._dictStackByStack[key][this._dictStackByStack[key].Count - count];
1064+
}
1065+
// 如果當前 UI 是 StackByStack 模式, 將會直接移除最上層的緩存
1066+
this._dictStackByStack[key].RemoveAt(this._dictStackByStack[key].Count - count);
1067+
}
1068+
else if (this._dictStackByStack[key].Count > 0 && this._dictStackByStack[key].Count < 2)
1069+
{
1070+
this._dictStackByStack[key].RemoveAt(this._dictStackByStack[key].Count - 1);
1071+
this._dictStackByStack.Remove(key);
10581072
}
1059-
// 如果當前 UI 是 StackByStack 模式, 將會直接移除最上層的緩存
1060-
this._dictStackByStack[key].RemoveAt(this._dictStackByStack[key].Count - count);
1061-
}
1062-
else if (this._dictStackByStack[key].Count > 0 && this._dictStackByStack[key].Count < 2)
1063-
{
1064-
this._dictStackByStack[key].RemoveAt(this._dictStackByStack[key].Count - 1);
1065-
this._dictStackByStack.Remove(key);
10661073
}
10671074
}
10681075
}

0 commit comments

Comments
 (0)