示例#1
0
 protected static void addPrototype(Image val)
 {
     PrototypeList.Add(val);
     NextSlot++;
 }
示例#2
0
文件: Overlord.cs 项目: Weesals/ModHQ
        public void Load(Action <LogCapture> onLoad)
        {
            TextureRegistry = new TextureRegistry();
            TextureRegistry.Initialize(Texture2File, TextureFile);
            PrototypeList protoList    = null;
            Action        completeLoad = () => {
                Prototypes = protoList;
                var logger = SerializationContext.GetService <LogCapture>();
                if (logger != null)
                {
                    onLoad(logger);

                    /*string errors = logger.ErrorsAsString, warnings = logger.WarningsAsString, infos = logger.InfosAsString;
                     * if (!string.IsNullOrWhiteSpace(errors) || !string.IsNullOrWhiteSpace(warnings) || !string.IsNullOrWhiteSpace(infos)) {
                     *  MessageBox.Show("Load complete." +
                     *      (!string.IsNullOrWhiteSpace(errors) ? "\n\nErrors:\n" + errors : "") +
                     *      (!string.IsNullOrWhiteSpace(warnings) ? "\n\nWarnings:\n" + warnings : "") +
                     *      (!string.IsNullOrWhiteSpace(infos) ? "\n\nInfo:\n" + infos : "")
                     *  );
                     * }*/
                    logger.Clear();
                }
                if (OnLoad != null)
                {
                    OnLoad();
                }
                loaded = true;
                NotifyPropertyChanged("IsLoaded", "IsNotLoaded");
            };

            ThreadPool.QueueUserWorkItem(delegate {
                /*using (var outFile = File.Create(@"E:\Games\AOM - Other shit\extracted\protox_uncomp.xmb")) {
                 *  XMBFile.DecompressAndSkipHeader(DataFile.GetFileStream("protox.xmb")).CopyTo(outFile);
                 * }*/
                Data.XMBFile protoFile = null;
                if (protoFile == null)
                {
                    try { LoadXMB(Data2File ?? DataFile, "protox.xmb"); } catch { }
                }
                if (protoFile == null)
                {
                    try { protoFile = LoadXMB(Data2File ?? DataFile, "proto.xmb"); } catch { }
                }
                if (protoFile == null)
                {
                    try { protoFile = LoadXMB(Data2File ?? DataFile, "proto.xml"); } catch { }
                }

                /*string fileName = @"E:\Games\AOM - Other shit\extracted\protox_my_uncomp.xmb";
                 * using (var protoFileOut = File.Create(fileName)) { protoFile.Save(protoFileOut, false); }
                 * XMBFile protoFile2 = null;
                 * using (var protoFileOut = File.OpenRead(fileName)) { protoFile2 = XMBFile.Load(protoFileOut); }
                 * using (var protoFileOut = File.Create(fileName + ".xml")) { protoFile2.GetAsXDocument().Save(protoFileOut); }*/
                if (protoFile != null)
                {
                    using (new XElementExt.Case(true)) {
                        var xml   = protoFile.GetAsXDocument();
                        protoList = new ProtoXML().Deserialize(
                            SerializationContext,
                            xml.Root
                            );
                    }
                }
                App.Current.Dispatcher.BeginInvoke(completeLoad);
            });
        }