ViewManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. using System.Collections.Generic;
  2. using System;
  3. using FairyGUI;
  4. using System.Linq;
  5. using ET;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class ViewStructure
  10. {
  11. public string name;
  12. public object viewData;
  13. public IUIView iUIView;
  14. public bool backRefresh;
  15. public List<String> smallWindow;
  16. }
  17. /// <summary>
  18. /// 视图管理类
  19. /// 管理视图的显示、隐藏
  20. /// </summary>
  21. public class ViewManager
  22. {
  23. private static List<ViewStructure> _viewStack;
  24. private static Dictionary<string, IUIView> _viewDic;
  25. private static GComponent _bottomLayer;
  26. private static GComponent _topLayer;
  27. private static GComponent _guideLayer;
  28. private static GComponent _modalLayer;
  29. private static GComponent _alertLayer;
  30. private static GComponent _debugLayer;
  31. private static GComponent _floatLayer;
  32. private static bool _nowHideOthers = false; //正在关闭所有界面的循环中
  33. private static Dictionary<string, List<object[]>> _goBackDatas = new Dictionary<string, List<object[]>>();
  34. public static void Clear()
  35. {
  36. _viewStack.Clear();
  37. }
  38. private static int _packagesLoaded = 0;
  39. private static int _totalPackagesToLoad = 0;
  40. private static Action _onAllPackagesLoaded;
  41. private static Action<string> _onPackageError;
  42. public static void Init(Action onComplete, Action<string> onError = null)
  43. {
  44. //设置CustomLoader
  45. UIObjectFactory.SetLoaderExtension(typeof(GFGGLoader));
  46. _onAllPackagesLoaded = onComplete;
  47. _onPackageError = onError;
  48. _packagesLoaded = 0;
  49. string[] packagePaths = new string[]
  50. {
  51. "Login",
  52. "Common",
  53. "CommonGame",
  54. "CreateRole",
  55. "Loading",
  56. "Main",
  57. "TimeTracing",
  58. };
  59. _totalPackagesToLoad = packagePaths.Length;
  60. foreach (var package in packagePaths)
  61. {
  62. string path = ResPathUtil.GetUIPackagePath(package);
  63. GFGUIPackage.AddPackage(path, () =>
  64. {
  65. _packagesLoaded++;
  66. if (_packagesLoaded == _totalPackagesToLoad)
  67. {
  68. FinalizeInit();
  69. }
  70. },
  71. (error) => { _onPackageError?.Invoke(error); });
  72. }
  73. }
  74. public static void Init2(Action onComplete, Action<string> onError = null)
  75. {
  76. //设置CustomLoader
  77. //UIObjectFactory.SetLoaderExtension(typeof(GFGGLoader));
  78. _onPackageError = onError;
  79. _packagesLoaded = 0;
  80. string[] packagePaths = new string[]
  81. {
  82. "Travel",
  83. "TurnTable",
  84. "XiuFang",
  85. "MatchingCompetition",
  86. "MiniGame",
  87. "NewYearLogin",
  88. "NewYearRedEnvelope",
  89. "Notice",
  90. "OpenServerActivity",
  91. "Poem",
  92. "PopWindow",
  93. "RoleInfo",
  94. "RoleLvUp",
  95. "Share",
  96. "Store",
  97. "Studio",
  98. "Task",
  99. "LuckyBox",
  100. "Mail",
  101. "DailyWelfare",
  102. "DeleteAccount",
  103. "DressUp",
  104. "EnduringGiftBox",
  105. "Field",
  106. "FieldGuide",
  107. "FieldWork",
  108. "Friend",
  109. "Guide",
  110. "InstanceZones",
  111. "League",
  112. "Arena",
  113. "Bag",
  114. "BlindBox",
  115. "BornLimit",
  116. "Card",
  117. "CardSynthetic",
  118. "ClothingDecompose",
  119. "ClothingFoster",
  120. "ClothingShop",
  121. "ClothingSynthetic",
  122. "ClothingUpgrade",
  123. "ActivityAfternoonTea",
  124. "ActivityAFuGift",
  125. "ActivityDay7",
  126. "ActivityGetYuanXiao",
  127. "ActivityHuaRongDao",
  128. "ActivityMain",
  129. "ActivityThemeLuckyBox",
  130. "ActivityWanShiLi",
  131. };
  132. _totalPackagesToLoad = packagePaths.Length;
  133. foreach (var package in packagePaths)
  134. {
  135. string path = ResPathUtil.GetUIPackagePath(package);
  136. GFGUIPackage.AddPackage(path, () =>
  137. {
  138. _packagesLoaded++;
  139. if (_packagesLoaded == _totalPackagesToLoad)
  140. {
  141. onComplete?.Invoke();
  142. }
  143. },
  144. (error) => { _onPackageError?.Invoke(error); });
  145. }
  146. }
  147. private static void FinalizeInit()
  148. {
  149. UIConfig.buttonSound = (NAudioClip)UIPackage.GetItemAsset("Common", "click");
  150. UIConfig.defaultFont = "FZKTJW--GB1-0";
  151. UIConfig.bringWindowToFrontOnClick = false;
  152. _viewDic = new Dictionary<string, IUIView>();
  153. _viewStack = new List<ViewStructure>();
  154. //初始化视图层容器
  155. _bottomLayer = CreateLayer("BottomLayer");
  156. _topLayer = CreateLayer("TopLayer");
  157. _topLayer.sortingOrder = ConstViewLayerSortingOrder.TOP;
  158. _guideLayer = CreateLayer("GuideLayer");
  159. _guideLayer.sortingOrder = ConstViewLayerSortingOrder.Guide;
  160. _modalLayer = CreateLayer("ModalLayer");
  161. _modalLayer.sortingOrder = ConstViewLayerSortingOrder.Modal;
  162. _alertLayer = CreateLayer("AlertLayer");
  163. _alertLayer.sortingOrder = ConstViewLayerSortingOrder.Alert;
  164. //debug层
  165. _debugLayer = CreateLayer("DebugLayer");
  166. _debugLayer.sortingOrder = ConstViewLayerSortingOrder.Debug;
  167. _floatLayer = CreateLayer("FloatLayer");
  168. _floatLayer.sortingOrder = ConstViewLayerSortingOrder.Float;
  169. SetMaskAlpha(0.6f);
  170. _onAllPackagesLoaded?.Invoke();
  171. }
  172. public static void AddChildToBottomLayer(GObject gObject)
  173. {
  174. _bottomLayer.AddChild(gObject);
  175. }
  176. public static void AddChildToTopLayer(GObject gObject)
  177. {
  178. _topLayer.AddChild(gObject);
  179. }
  180. public static void AddChildToGuideLayer(GObject gObject)
  181. {
  182. _guideLayer.AddChild(gObject);
  183. }
  184. public static void AddChildToModalLayer(GObject gObject)
  185. {
  186. _modalLayer.AddChild(gObject);
  187. }
  188. public static void AddChildToAlertLayer(GObject gObject)
  189. {
  190. _alertLayer.AddChild(gObject);
  191. }
  192. public static void AddChildToDebugLayer(GObject gObject)
  193. {
  194. _debugLayer.AddChild(gObject);
  195. }
  196. public static void AddChildToFloatLayer(GObject gObject)
  197. {
  198. _floatLayer.AddChild(gObject);
  199. }
  200. public static float ViewWidth
  201. {
  202. get
  203. {
  204. //这里做了最大宽度适配
  205. float maxAspectRatio = 1080 * 1.0f / 1920;
  206. if (Screen.width * 1.0f / Screen.height > maxAspectRatio)
  207. {
  208. return GRoot.inst.height * maxAspectRatio;
  209. }
  210. return GRoot.inst.width;
  211. }
  212. }
  213. /// <summary>
  214. /// 显示一个视图
  215. /// </summary>
  216. /// <param name="viewName">要显示的视图名称</param>
  217. /// <param name="viewData">要传递给视图的参数</param>
  218. /// <param name="goBackParams">从该视图返回的视图信息</param>
  219. /// <param name="hideOthers">是否关闭其他视图</param>
  220. /// <param name="backRefresh">返回上一个界面的时候,上一个界面是否需要刷新界面</param>
  221. public static bool Show(string fullViewName, object viewData = null, bool hideOthers = false,
  222. bool backRefresh = true, bool isHideToShow = false)
  223. {
  224. string name = GetName(fullViewName);
  225. if (!GameGlobal.skipCheckOpen && !FunctionOpenDataManager.Instance.CheckIsFunOpenById(name))
  226. {
  227. return false;
  228. }
  229. if (hideOthers)
  230. {
  231. HideAllView(name);
  232. }
  233. IUIView obj = null;
  234. if (_viewDic.ContainsKey(name))
  235. {
  236. obj = _viewDic[name];
  237. }
  238. else
  239. {
  240. obj = CreateViewInstance(fullViewName) as IUIView;
  241. obj.viewName = name;
  242. _viewDic.Add(name, obj);
  243. }
  244. if (obj != null)
  245. {
  246. IUIView view = (IUIView)obj;
  247. view.viewData = viewData;
  248. if (!view.isShowing)
  249. {
  250. if (isHideToShow && _viewStack.Count > 0)
  251. {
  252. view.backRefresh = _viewStack[_viewStack.Count - 1].backRefresh;
  253. _viewStack[_viewStack.Count - 1].iUIView = obj;
  254. }
  255. else
  256. view.backRefresh = true;
  257. view.Show();
  258. }
  259. else
  260. {
  261. view.Refresh();
  262. }
  263. LogUtil.LogDev("当前打开:" + name);
  264. }
  265. if (name == "MainUIView")
  266. {
  267. _viewStack.Clear();
  268. }
  269. //判断是否需要保存界面数据, 会帮助关闭上一个保存界面
  270. if (obj.isReturnView && (_viewStack.Count <= 0 ||
  271. (_viewStack.Count > 0 && _viewStack[_viewStack.Count - 1].name != name)))
  272. {
  273. //保存上一个界面是否需要返回刷新
  274. if (!isHideToShow && _viewStack.Count > 1)
  275. _viewStack[_viewStack.Count - 1].backRefresh = backRefresh;
  276. ViewStructure viewStructure = new ViewStructure();
  277. viewStructure.name = name;
  278. viewStructure.viewData = viewData;
  279. viewStructure.iUIView = obj;
  280. _viewStack.Add(viewStructure);
  281. if (_viewStack.Count > 1 && !hideOthers)
  282. {
  283. if (_viewStack[_viewStack.Count - 2].smallWindow == null)
  284. _viewStack[_viewStack.Count - 2].smallWindow = new List<string>();
  285. _viewStack[_viewStack.Count - 2].smallWindow.Clear();
  286. //把开着的小弹窗存起来
  287. foreach (var objName in _viewDic.Keys)
  288. {
  289. IUIView view = (IUIView)_viewDic[objName];
  290. if (view.isReturnWindow)
  291. {
  292. if (view.isShowing)
  293. {
  294. _viewStack[_viewStack.Count - 2].smallWindow.Add(objName);
  295. view.Hide();
  296. }
  297. }
  298. }
  299. _viewStack[_viewStack.Count - 2].iUIView.Hide();
  300. }
  301. }
  302. return true;
  303. }
  304. //
  305. /// <summary>
  306. /// 界面可返回栈里的跳转
  307. /// </summary>
  308. /// <param name="viewName">跳转到界面缓存栈里的某个界面,使用这个参数时写在打开下一个界面后</param>
  309. /// <param name="count">删除队列中的倒数几个,较灵活应对更多种情况,可自由控制</param>
  310. public static void DeleteViewStackCountDown(string viewName, int count = 0)
  311. {
  312. if (viewName != null && viewName != "")
  313. {
  314. for (int i = _viewStack.Count - 2; i > 0; i--)
  315. {
  316. ViewStructure viewStructure = _viewStack[i];
  317. if (viewStructure.name == viewName)
  318. break;
  319. _viewStack.RemoveAt(i);
  320. }
  321. return;
  322. }
  323. for (int i = 0; i < count; i++)
  324. {
  325. if (_viewStack.Count <= 1)
  326. break;
  327. _viewStack.RemoveAt(_viewStack.Count - 1);
  328. }
  329. }
  330. public static bool isViewOpen(string fullViewName)
  331. {
  332. string name = GetName(fullViewName);
  333. IUIView obj = null;
  334. if (_viewDic.ContainsKey(name))
  335. {
  336. obj = _viewDic[name];
  337. if (obj != null)
  338. {
  339. IUIView view = (IUIView)obj;
  340. if (view.isShowing) return true;
  341. }
  342. }
  343. return false;
  344. }
  345. public static bool Show<T>(object viewData = null, bool hideOthers = false, bool backRefresh = true)
  346. where T : class, new()
  347. {
  348. // string[] names = typeof(T).FullName.Split('.');
  349. // string viewName = names[names.Length - 1];
  350. //string name = GetName(typeof(T).FullName);
  351. return ViewManager.Show(typeof(T).FullName, viewData, hideOthers, backRefresh);
  352. }
  353. public static void HideWin(string viewName)
  354. {
  355. if (_nowHideOthers)
  356. return;
  357. if (_viewStack.Count >= 1)
  358. {
  359. bool hasShowingView = false;
  360. bool needShowNextView = false;
  361. bool backRefresh = true;
  362. foreach (var info in _viewDic.Keys)
  363. {
  364. IUIView objIsShowing = _viewDic[info];
  365. if (objIsShowing != null && objIsShowing.isShowing)
  366. {
  367. hasShowingView = true;
  368. break;
  369. }
  370. }
  371. ViewStructure viewStructure = _viewStack[_viewStack.Count - 1];
  372. if (_viewStack.Count == 1)
  373. {
  374. //没有界面显示了,栈被清除剩1个的时候,做保底
  375. if (!hasShowingView)
  376. needShowNextView = true;
  377. }
  378. else
  379. {
  380. if (!hasShowingView || (viewStructure.iUIView.isReturnView && viewStructure.name == viewName))
  381. {
  382. //关闭自己,在队列里去除
  383. if (viewStructure.iUIView.isReturnView && viewStructure.name == viewName)
  384. {
  385. backRefresh = viewStructure.backRefresh;
  386. _viewStack.RemoveAt(_viewStack.Count - 1);
  387. }
  388. if (_viewStack.Count >= 1)
  389. needShowNextView = true;
  390. }
  391. }
  392. if (needShowNextView)
  393. {
  394. viewStructure = _viewStack[_viewStack.Count - 1];
  395. ViewManager.Show($"GFGGame.{viewStructure.name}", viewStructure.viewData, false, backRefresh, true);
  396. //重新打开小弹窗
  397. if (viewStructure.smallWindow != null)
  398. {
  399. foreach (var objName in viewStructure.smallWindow)
  400. {
  401. ViewManager.Show($"GFGGame.{objName}");
  402. }
  403. }
  404. //foreach (var objName in _viewDic.Keys)
  405. //{
  406. // if (objName != viewStructure.name)
  407. // {
  408. // IUIView view = (IUIView)_viewDic[objName];
  409. // if (view.isShowing)
  410. // view.Show();
  411. // }
  412. //}
  413. }
  414. }
  415. }
  416. public static void Hide(string fullViewName)
  417. {
  418. string name = GetName(fullViewName);
  419. if (!_viewDic.ContainsKey(name))
  420. {
  421. return;
  422. }
  423. object obj = _viewDic[name];
  424. if (obj != null)
  425. {
  426. IUIView view = (IUIView)obj;
  427. view.Hide();
  428. LogUtil.LogDev("当前关闭:" + name);
  429. }
  430. }
  431. public static void Hide<T>()
  432. {
  433. //string name = GetName(typeof(T).FullName);
  434. Hide(typeof(T).FullName);
  435. }
  436. public static void GoBackFrom(string fullViewName, bool hideOther = true)
  437. {
  438. string name = GetName(fullViewName);
  439. ViewManager.Hide(name);
  440. foreach (var info in _viewDic.Keys)
  441. {
  442. IUIView objIsShowing = _viewDic[info];
  443. if (objIsShowing != null && objIsShowing.isShowing)
  444. {
  445. return;
  446. }
  447. }
  448. MainDataManager.Instance.ViewType = 0;
  449. ViewManager.Show<MainUIView>(null, true);
  450. }
  451. public static object[] GetGoBackDatas(string fullViewName)
  452. {
  453. //string name = GetName(fullViewName);
  454. object[] value = null;
  455. //if (_goBackDatas.ContainsKey(name) && _goBackDatas[name].Count > 0)
  456. //{
  457. // value = _goBackDatas[name][_goBackDatas[name].Count - 1];
  458. //}
  459. return value;
  460. }
  461. public static IUIView GetUIView(string viewName)
  462. {
  463. if (_viewDic.ContainsKey(viewName))
  464. {
  465. IUIView obj = _viewDic[viewName];
  466. if (obj != null && obj.isShowing)
  467. {
  468. return obj as IUIView;
  469. }
  470. }
  471. return null;
  472. }
  473. public static void ClearUIView(string viewName)
  474. {
  475. if (!string.IsNullOrEmpty(viewName) && _viewDic.ContainsKey(viewName))
  476. {
  477. if (_viewDic[viewName] != null && !_viewDic[viewName].isShowing)
  478. {
  479. // _viewDic[viewName] = null;
  480. _viewDic.Remove(viewName);
  481. }
  482. }
  483. }
  484. public static void HideAllView(string excludeViewName = null)
  485. {
  486. for (int i = _viewDic.Keys.Count - 1; i >= 0; i--) //不用foreach是因为:循环过程中可能会触发dispose,导致_viewDic.Keys变化,最终报错
  487. {
  488. int index = i > _viewDic.Keys.Count - 1
  489. ? _viewDic.Keys.Count - 1
  490. : i; //直接去最后一个,不用i是因为关闭一个界面可能会连带关闭其他界面,最终i比_viewDic.Keys.Count大而报错
  491. KeyValuePair<string, IUIView> kv = _viewDic.ElementAt(index);
  492. if (kv.Key != excludeViewName)
  493. {
  494. if (kv.Key == typeof(FunctionOpenView).Name) continue; //功能开启界面不能强制关闭
  495. _nowHideOthers = true;
  496. Hide(kv.Key);
  497. }
  498. }
  499. _nowHideOthers = false;
  500. // _viewDic.Clear();
  501. // foreach (string viewName in _viewDic.Keys)
  502. // {
  503. // if (viewName != excludeViewName)
  504. // {
  505. // if (viewName == typeof(FunctionOpenView).Name) continue;//功能开启界面不能强制关闭
  506. // Hide(viewName);
  507. // }
  508. // }
  509. }
  510. public static void CheckDispose()
  511. {
  512. for (int i = _viewDic.Keys.Count - 1; i >= 0; i--) //不用foreach是因为:循环过程中可能会触发dispose,导致_viewDic.Keys变化,最终报错
  513. {
  514. int index = i > _viewDic.Keys.Count - 1
  515. ? _viewDic.Keys.Count - 1
  516. : i; //直接去最后一个,不用i是因为关闭一个界面可能会连带关闭其他界面,最终i比_viewDic.Keys.Count大而报错
  517. KeyValuePair<string, IUIView> kv = _viewDic.ElementAt(index);
  518. if (kv.Value.isShowing == true) continue;
  519. // if (kv.Value.packageName == ResPathUtil.GetUIPackagePath("CommonGame") || kv.Value.packageName == ResPathUtil.GetUIPackagePath("Common") || kv.Value.packageName == ResPathUtil.GetUIPackagePath("Main")) return;//这几个包不释放
  520. if (_viewDic.Keys.Count <= 50) return; //打开界面小于10个就不销毁了
  521. long currentTime = TimeHelper.ClientNowSeconds();
  522. long closeTime = kv.Value.closeTime;
  523. if (closeTime > 0 && currentTime - closeTime >= TimeUtil.SECOND_PER_MUNITE * 1)
  524. {
  525. kv.Value.closeTime = 0;
  526. kv.Value.Dispose();
  527. }
  528. }
  529. }
  530. private static object CreateViewInstance(string name)
  531. {
  532. //LogUtil.LogFormatDev("CreateViewInstance {0}", name);
  533. Type type = Type.GetType(name);
  534. if (type != null)
  535. {
  536. return Activator.CreateInstance(type);
  537. }
  538. return null;
  539. }
  540. private static GComponent CreateLayer(string name)
  541. {
  542. GComponent layer = new GComponent();
  543. layer.name = name;
  544. GRoot.inst.AddChild(layer);
  545. layer.SetSize(GRoot.inst.size.x, GRoot.inst.size.y);
  546. layer.AddRelation(GRoot.inst, RelationType.Size);
  547. return layer;
  548. }
  549. public static bool CheckIsTopView(GComponent viewCom)
  550. {
  551. if (ViewManager.isViewOpen(typeof(GuideView).Name)) return false;
  552. if (viewCom.parent != null)
  553. {
  554. int index = viewCom.parent.GetChildIndex(viewCom);
  555. if (index == viewCom.parent.numChildren - 1 && GRoot.inst.GetTopWindow() == null)
  556. {
  557. return true;
  558. }
  559. }
  560. if (GRoot.inst.GetTopWindow() == viewCom)
  561. {
  562. return true;
  563. }
  564. return false;
  565. }
  566. public static string GetName(string fullName)
  567. {
  568. string[] names = fullName.Split('.');
  569. string name = names[names.Length - 1];
  570. return name;
  571. }
  572. public static void SetMaskAlpha(float alpha)
  573. {
  574. GRoot.inst.modalLayer.alpha = alpha;
  575. }
  576. /// <summary>
  577. /// 任务界面跳转
  578. /// </summary>
  579. /// <param name="jumpId"></param>
  580. public static void JumpToView(string jumpId, object[] param, bool hideOther = false, bool backRefresh = true,
  581. Action onSuccess = null)
  582. {
  583. switch (jumpId)
  584. {
  585. case nameof(LeagueAnswerView):
  586. if (LeagueDataManager.Instance.Type == LeagueJoinType.Join)
  587. {
  588. ViewManager.Show<LeagueView>(null, hideOther, backRefresh);
  589. ViewManager.Show($"GFGGame.{jumpId}");
  590. }
  591. else
  592. {
  593. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(nameof(LeagueView))) return;
  594. ViewManager.Show<LeagueJoinView>(null, hideOther, backRefresh);
  595. }
  596. break;
  597. case nameof(LeagueView):
  598. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(nameof(LeagueView))) return;
  599. if (LeagueDataManager.Instance.Type == LeagueJoinType.Join)
  600. {
  601. ViewManager.Show<LeagueView>(null, hideOther, backRefresh);
  602. }
  603. else
  604. {
  605. ViewManager.Show<LeagueJoinView>(null, hideOther, backRefresh);
  606. }
  607. break;
  608. case nameof(StoreView):
  609. ViewManager.Show<StoreView>(param, hideOther, backRefresh);
  610. break;
  611. case nameof(StoryChapterListView):
  612. ViewManager.Show($"GFGGame.{jumpId}", param, hideOther, backRefresh);
  613. break;
  614. case nameof(StoryChapterView):
  615. ViewManager.Show<StoryChapterView>(param[0], hideOther, backRefresh);
  616. break;
  617. case nameof(FirstChargeBonusView):
  618. ViewManager.Show<FirstChargeBonusView>(param, false, backRefresh);
  619. break;
  620. case nameof(ClothingSyntheticView):
  621. ViewManager.Show<ClothingSyntheticView>(param, hideOther, backRefresh);
  622. break;
  623. case nameof(LuckyBoxView):
  624. if (param.Length > 0)
  625. ViewManager.Show<LuckyBoxView>(param[0], hideOther, backRefresh);
  626. else
  627. ViewManager.Show<LuckyBoxView>(null, hideOther, backRefresh);
  628. break;
  629. default:
  630. ViewManager.Show($"GFGGame.{jumpId}", null, hideOther, backRefresh);
  631. break;
  632. }
  633. onSuccess?.Invoke();
  634. }
  635. // 在ViewManager中添加预加载方法
  636. public static void PreloadViews<T>()
  637. {
  638. string name = GetName(typeof(T).FullName);
  639. var obj = CreateViewInstance(typeof(T).FullName) as IUIView;
  640. obj.viewName = name;
  641. if (!_viewDic.ContainsKey(name))
  642. {
  643. _viewDic.Add(name, obj);
  644. }
  645. }
  646. }
  647. }