コード例 #1
0
        void DoBruteForceWork(object sender, System.ComponentModel.DoWorkEventArgs eventArgs)
        {
            var dlg = (Ookii.Dialogs.Wpf.ProgressDialog)sender;

            var newEntries = new Models.ModelCharaHierarchy(Entries.MainFormat, Entries.SubFormat, Entries.VariantFormat);

            for (var m = 0; m < 10000; ++m)
            {
                if (dlg.CancellationPending)
                {
                    return;
                }
                dlg.ReportProgress(m / 100, null, string.Format("Current progress: {0:P}", m / 10000.0));
                for (var b = 0; b < 10000; ++b)
                {
                    var imcPath = string.Format(ImcPathFormat, m, b);
                    SaintCoinach.IO.File imcBase;
                    if (!Parent.Realm.Packs.TryGetFile(imcPath, out imcBase))
                    {
                        continue;
                    }
                    try {
                        var imc = new SaintCoinach.Graphics.ImcFile(imcBase);
                        for (var v = 1; v < imc.Count; ++v)
                        {
                            if (Entries.Contains(m, b, v))
                            {
                                continue;
                            }

                            var any = false;
                            foreach (var p in imc.Parts)
                            {
                                if (p.Variants[v].Variant != 0)
                                {
                                    any = true;
                                    break;
                                }
                            }
                            if (any)
                            {
                                newEntries.Add(m, b, v);
                            }
                        }
                    } catch (Exception ex) {
                        Console.Error.WriteLine("Failed parsing imc file {0}:{1}{2}", imcPath, Environment.NewLine, ex);
                    }
                }
            }
            Entries = newEntries;
        }
コード例 #2
0
        private bool TryGetModel(out Skeleton skeleton, out ModelDefinition model, out ImcVariant variant, out int m, out int b)
        {
            model = null;
            skeleton = null;
            variant = ImcVariant.Default;
            m = 0;
            b = 0;

            var asVariant = SelectedEntry as Models.ModelCharaVariant;
            if (asVariant == null)
                return false;

            int v = asVariant.Value;
            b = asVariant.Parent.Value;
            m = asVariant.Parent.Parent.Value;

            var imcPath = string.Format(ImcPathFormat, m, b);
            var mdlPath = string.Format(ModelPathFormat, m, b);
            var sklPath = string.Format(SkeletonPathFormat, m, 1);// b);

            SaintCoinach.IO.File imcFileBase;
            SaintCoinach.IO.File mdlFileBase;
            if (!Parent.Realm.Packs.TryGetFile(imcPath, out imcFileBase) || !Parent.Realm.Packs.TryGetFile(mdlPath, out mdlFileBase) || !(mdlFileBase is ModelFile)) {
                System.Windows.MessageBox.Show(string.Format("Unable to find files for {0}.", asVariant), "File not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }

            SaintCoinach.IO.File sklFileBase;
            if(!Parent.Realm.Packs.TryGetFile(sklPath, out sklFileBase)) {
                System.Windows.MessageBox.Show(string.Format("Unable to find skeleton for {0}.", asVariant), "File not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }

            skeleton = new Skeleton(new SklbFile(sklFileBase));

            try {
                var imcFile = new ImcFile(imcFileBase);
                model = ((ModelFile)mdlFileBase).GetModelDefinition();
                variant = imcFile.GetVariant(v);

                return true;
            } catch (Exception e) {
                System.Windows.MessageBox.Show(string.Format("Unable to load model for {0}:{1}{2}", asVariant, Environment.NewLine, e), "Failure to load", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }
        }
コード例 #3
0
        void DoBruteForceWork(object sender, System.ComponentModel.DoWorkEventArgs eventArgs)
        {
            var dlg = (Ookii.Dialogs.Wpf.ProgressDialog)sender;

            var newEntries = new Models.ModelCharaHierarchy(Entries.MainFormat, Entries.SubFormat, Entries.VariantFormat);
            for (var m = 0; m < 10000; ++m) {
                if (dlg.CancellationPending)
                    return;
                dlg.ReportProgress(m / 100, null, string.Format("Current progress: {0:P}", m / 10000.0));
                for (var b = 0; b < 10000; ++b) {

                    var imcPath = string.Format(ImcPathFormat, m, b);
                    SaintCoinach.IO.File imcBase;
                    if (!Parent.Realm.Packs.TryGetFile(imcPath, out imcBase))
                        continue;
                    try {
                        var imc = new SaintCoinach.Graphics.ImcFile(imcBase);
                        for (var v = 1; v < imc.Count; ++v) {
                            if (Entries.Contains(m, b, v))
                                continue;

                            var any = false;
                            foreach (var p in imc.Parts) {
                                if (p.Variants[v].Variant != 0) {
                                    any = true;
                                    break;
                                }
                            }
                            if (any)
                                newEntries.Add(m, b, v);
                        }
                    } catch (Exception ex) {
                        Console.Error.WriteLine("Failed parsing imc file {0}:{1}{2}", imcPath, Environment.NewLine, ex);
                    }
                }
            }
            Entries = newEntries;
        }
コード例 #4
0
        private bool TryGetModel(out string title, out Tuple<ModelDefinition, ImcVariant>[] models)
        {
            title = null;
            models = null;

            var asVariant = SelectedEntry as Models.ModelCharaVariant;
            if (asVariant == null)
                return false;

            title = asVariant.ToString();

            int v = asVariant.Value;
            int e = asVariant.Parent.Value;
            var d = asVariant.Parent.Parent.Value;

            var imcPath = string.Format(ImcPathFormat, d, e);

            SaintCoinach.IO.File imcFileBase;
            if (!Parent.Realm.Packs.TryGetFile(imcPath, out imcFileBase)) {
                System.Windows.MessageBox.Show(string.Format("Unable to find files for {0}.", title), "File not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }

            try {
                var imcFile = new ImcFile(imcFileBase);
                var modelsList = new List<Tuple<ModelDefinition, ImcVariant>>();
                foreach(var part in imcFile.Parts) {
                    if (!_SelectedParts[part.Bit])
                        continue;

                    var variant = part.Variants[v];
                    if(variant.Variant == 0)
                        continue;

                    var mdlPath = string.Format(ModelPathFormats[part.Bit], d, e);
                    SaintCoinach.IO.File mdlBase;
                    if(!Parent.Realm.Packs.TryGetFile(mdlPath, out mdlBase))
                        continue;
                    var mdl = ((ModelFile)mdlBase).GetModelDefinition();

                    modelsList.Add(Tuple.Create(mdl, variant));
                }

                if(modelsList.Count == 0) {
                    System.Windows.MessageBox.Show(string.Format("No models found for {0}.", title), "No models", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    return false;
                }
                models = modelsList.ToArray();

                return true;
            } catch (Exception ex) {
                System.Windows.MessageBox.Show(string.Format("Unable to load model for {0}:{1}{2}", title, Environment.NewLine, ex), "Failure to load", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }
        }