模块加载改为排序加载

This commit is contained in:
shenjianxing 2025-01-08 17:05:35 +08:00
parent 44fffc2b5a
commit f54e479c9b
5 changed files with 32 additions and 12 deletions

View File

@ -172,8 +172,8 @@ public class ActionHelper
}
case "LoadRes":
{
var strAction = (XMLTool.StringListAction)act;
return LoadResAction.Allocate(act.Value, strAction.args[0]);
var dictAction = (XMLTool.DictionaryAction)act;
return LoadResAction.Allocate(act.Value, dictAction.args);
}
case "Audio":
{

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using XMLTool;
@ -21,14 +22,16 @@ namespace QFramework
string fileName;
string type;
public static LoadResAction Allocate(string fileName, string type, System.Action OnFinished = null)
string index;
public static LoadResAction Allocate(string fileName, Dictionary<string, string> datas, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.fileName = fileName;
retNode.type = type;
retNode.type = datas.ContainsKey("resType") ? datas["resType"] : string.Empty;
retNode.index = datas.ContainsKey("index") ? datas["index"] : string.Empty;
retNode.OnFinished = OnFinished;
return retNode;
}
@ -55,7 +58,10 @@ namespace QFramework
XDocument doc = XDocument.Parse(xmlStr);
// »ñÈ¡¸ùÔªËØ
XElement moduleXml = doc.Root;
XmlParser.LoadModule(moduleXml, Global.Instance.appData);
Global.moduleDict.Add(index, moduleXml);
// Ö±½Ó¼ÓÔØ»áµ¼ÖÂÎÞÐò
//XmlParser.LoadModule(moduleXml, Global.Instance.appData);
}
}
});

View File

@ -2,6 +2,7 @@ using QFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using XMLTool;
@ -35,6 +36,6 @@ public class Global : Singleton<Global>
public static AppType appTpe = AppType.UnKnow;
public static Dictionary<string, XElement> moduleDict = new Dictionary<string, XElement>();
}

View File

@ -43,6 +43,18 @@ public class Launch : MonoBehaviour
{
yield return ActionHelper.GetActionAndSub(Global.Instance.appData.preLoad.action).Start(this);
}
// 暂时放在这里
if (Global.moduleDict.Count > 0)
{
for (int i = 0; i < Global.moduleDict.Count; i++)
{
string index = (i + 1).ToString();
if (Global.moduleDict.ContainsKey(index))
{
XmlParser.LoadModule(Global.moduleDict[index], Global.Instance.appData);
}
}
}
yield return UIKit.OpenPanelAsync<UIModeSelect>();
UIKit.HidePanel<UILoading>();

View File

@ -784,15 +784,16 @@ namespace XMLTool
break;
case "LoadRes":
{
var act = new StringListAction();
var act = new DictionaryAction();
XAttribute resType = action.Attribute("resType");
if (resType != null)
{
act.args.Add(resType.Value);
act.args.Add("resType", resType.Value);
}
else
XAttribute index = action.Attribute("index");
if (index != null)
{
act.args.Add("");
act.args.Add("index", index.Value);
}
newAction = act;
}