private void DoImport(SaveFileInfo file)
        {
            try
            {
                // load stuff
                Scribe.InitLoading(_folder + "/" + file.FileInfo.Name);
                Manager.LoadSaveMode = Manager.Modes.ImportExport;
                ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false);
                Scribe.EnterNode("JobStack");
                _jobStackIO.ExposeData();
                Scribe.ExitNode();
                Scribe.FinalizeLoading();

                // resolve crossreferences
                // these are registered during the loading stage, and cleared afterwards
                // will most definitely give errors/warnings on crossgame imports
                CrossRefResolver.ResolveAllCrossReferences();

                // replace the old jobstack
                Manager.For(manager).NewJobStack(_jobStackIO);

                // remove invalid jobs
                var invalid = 0;
                foreach (ManagerJob job in Manager.For(manager).JobStack.FullStack())
                {
                    if (!job.IsValid)
                    {
                        invalid++;
                        job.Delete(false);
                    }
                }

                // provide some feedback on failed import(s)
                // if debug is enabled the screen will also pop up with reference errors.
                if (invalid > 0)
                {
                    Messages.Message("FM.InvalidJobsDeleted".Translate(invalid), MessageSound.SeriousAlert);
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception while loading jobstack: " + e);
            }
            finally
            {
                // done?
                Scribe.mode          = LoadSaveMode.Inactive;
                Manager.LoadSaveMode = Manager.Modes.Normal;
                Messages.Message("FM.JobsImported".Translate(_jobStackIO.FullStack().Count), MessageSound.Standard);
                Refresh();
            }
        }
예제 #2
0
        internal static void _CheckVersionAndLoad(string path, ScribeMetaHeaderUtility.ScribeHeaderMode mode, Action loadAct)
        {
            bool mismatchWarnings;

            try
            {
                try
                {
                    Scribe.InitLoadingMetaHeaderOnly(path);
                }
                catch (Exception ex)
                {
                    Log.Warning(string.Concat(new object[4]
                    {
                        (object)"Exception loading ",
                        (object)path,
                        (object)": ",
                        (object)ex
                    }));
                }
                ScribeMetaHeaderUtility.LoadGameDataHeader(mode, false);
                mismatchWarnings = ScribeMetaHeaderUtility.TryCreateDialogsForVersionMismatchWarnings(loadAct);
                CrossRefResolver.ResolveAllCrossReferences();
                PostLoadInitter.DoAllPostLoadInits();
            }
            catch
            {
                CrossRefResolver.Clear();
                PostLoadInitter.Clear();
                throw;
            }
            Controller.Data.ResetInjectionSubController();
            if (mismatchWarnings)
            {
                return;
            }
            loadAct();
        }
예제 #3
0
        public static void load(ref List <Thing> thingsToLoad, string fileLocation, Thing currentSource)
        {
            Log.Message("ScribeINIT, loding from:" + fileLocation);
            Scribe.InitLoading(fileLocation);

            //Scribe.EnterNode("Stargate");

            Log.Message("DeepProfiler.Start()");
            DeepProfiler.Start("Load non-compressed things");

            // List<Thing> list2 = (List<Thing>)null;
            Log.Message("Scribe_Collections.LookList");
            Scribe_Collections.LookList <Thing>(ref thingsToLoad, "things", LookMode.Deep);
            Log.Message("List1Count:" + thingsToLoad.Count);

            Log.Message("DeepProfiler.End()");
            DeepProfiler.End();

            //Scribe.ExitNode();
            Scribe.mode = LoadSaveMode.Inactive;

            //Log.Message("list: " + thingsToLoad.Count.ToString());


            Log.Message("Exit Node");
            //Scribe.ExitNode();


            Log.Message("ResolveAllCrossReferences");
            CrossRefResolver.ResolveAllCrossReferences();


            Log.Message("DoAllPostLoadInits");
            PostLoadInitter.DoAllPostLoadInits();

            Log.Message("Return");
        }