Beispiel #1
0
        public void Load()
        {
            if (ViewModel == null)
            {
                return;
            }
            if (!IsVisible)
            {
                dirty = true;
                return;
            }
            Layout = null;
            ViewModel.LoadUIFileList();
            Data.XMBFile uiFile = null;
            if (Directory != null)
            {
                if (uiFile == null)
                {
                    try { uiFile = Directory.LoadXMB(AOMDirectory.Data2BAR, ViewModel.UIFile + ".xml"); } catch { }
                }
                if (uiFile == null)
                {
                    try { uiFile = Directory.LoadXMB(AOMDirectory.Data2BAR, ViewModel.UIFile + ".xmb"); } catch { }
                }
                if (uiFile == null)
                {
                    try { uiFile = Directory.LoadXMB(AOMDirectory.DataBAR, ViewModel.UIFile + ".xml"); } catch { }
                }
                if (uiFile == null)
                {
                    try { uiFile = Directory.LoadXMB(AOMDirectory.DataBAR, ViewModel.UIFile + ".xmb"); } catch { }
                }
            }
            var xdoc = uiFile != null?uiFile.GetAsXDocument() : null;

            if (xdoc != null)
            {
                Layout = GadgetSerializer.Parse(xdoc.Root);
            }
            if (Layout == null)
            {
                return;
            }

            Views = Layout.Gadgets.
                    SelectManyRecursive(g => g.Children).
                    Select(g => new GadgetView(Overlord.TextureRegistry, g, Space)).
                    ToArray();
            foreach (var view in Views)
            {
                view.ChildViews = Views.Where(v => v.Gadget.Parent == view.Gadget).ToArray();
            }
            ViewsContainer.Children.Clear();
            foreach (var view in Views)
            {
                ViewsContainer.Children.Add(view);
            }
            SidePanel.IsExpanded  = true;
            LayoutRoot.Visibility = Visibility.Visible;
            ViewModel.NotifyDataChanged();
            dirty = false;
        }
Beispiel #2
0
        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);
            });
        }