示例#1
0
        public void Initialize()
        {
            GeneralSettingsFile = GeneralSettingsFile.LoadOrCreateNew();

            CommandLineManager.Self.ReadCommandLine();

            if (!CommandLineManager.Self.ShouldExitImmediately)
            {
                if (!string.IsNullOrEmpty(CommandLineManager.Self.GlueProjectToLoad))
                {
                    GumCommands.Self.FileCommands.LoadProject(CommandLineManager.Self.GlueProjectToLoad);

                    if (!string.IsNullOrEmpty(CommandLineManager.Self.ElementName))
                    {
                        SelectedState.Self.SelectedElement = ObjectFinder.Self.GetElementSave(CommandLineManager.Self.ElementName);
                    }
                }
                else if (!string.IsNullOrEmpty(GeneralSettingsFile.LastProject))
                {
                    GumCommands.Self.FileCommands.LoadProject(GeneralSettingsFile.LastProject);
                }
                else
                {
                    CreateNewProject();
                }
            }
        }
示例#2
0
        public void BindTo(GeneralSettingsFile generalSettings, GumProjectSave gumProject)
        {
            this.generalSettings = generalSettings;
            this.gumProject      = gumProject;

            AutoSave                       = this.generalSettings.AutoSave;
            ShowOutlines                   = this.gumProject.ShowOutlines;
            RestrictToUnitValues           = this.gumProject.RestrictToUnitValues;
            CanvasHeight                   = this.gumProject.DefaultCanvasHeight;
            CanvasWidth                    = this.gumProject.DefaultCanvasWidth;
            RestrictFileNamesForAndroid    = this.gumProject.RestrictFileNamesForAndroid;
            RenderTextCharacterByCharacter = global::RenderingLibrary.Graphics.Text.TextRenderingMode ==
                                             global::RenderingLibrary.Graphics.TextRenderingMode.CharacterByCharacter;
        }
示例#3
0
        // made public so that File commands can access this function
        public void LoadProject(string fileName)
        {
            GumLoadResult result;

            mGumProjectSave = GumProjectSave.Load(fileName, out result);

            string errors = result.ErrorMessage;

            if (!string.IsNullOrEmpty(errors))
            {
                MessageBox.Show("Errors loading " + fileName + "\n\n" + errors);

                // If the file doesn't exist, that's okay we will let the user still work - it's not like they can overwrite a file that doesn't exist
                // But if it does exist, we want to be careful and not allow overwriting because they could be wiping out good data
                if (FileManager.FileExists(fileName))
                {
                    mHaveErrorsOccurred = true;
                }

                // We used to not load the project, but maybe we still should, just disable autosaving
                //
                //mGumProjectSave = new GumProjectSave();
            }
            else
            {
                mHaveErrorsOccurred = false;
            }

            ObjectFinder.Self.GumProjectSave = mGumProjectSave;

            WpfDataUi.Controls.FileSelectionDisplay.FolderRelativeTo = FileManager.GetDirectory(fileName);

            if (mGumProjectSave != null)
            {
                bool wasModified = mGumProjectSave.Initialize();


                RecreateMissingStandardElements();

                if (mGumProjectSave.AddNewStandardElementTypes())
                {
                    wasModified = true;
                }
                if (FixSlashesInNames(mGumProjectSave))
                {
                    wasModified = true;
                }

                mGumProjectSave.FixStandardVariables();

                FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);
                mGumProjectSave.RemoveDuplicateVariables();


                GraphicalUiElement.ShowLineRectangles    = mGumProjectSave.ShowOutlines;
                EditingManager.Self.RestrictToUnitValues = mGumProjectSave.RestrictToUnitValues;

                PluginManager.Self.ProjectLoad(mGumProjectSave);

                if (wasModified)
                {
                    ProjectManager.Self.SaveProject(forceSaveContainedElements: true);
                }

                GraphicalUiElement.CanvasWidth  = mGumProjectSave.DefaultCanvasWidth;
                GraphicalUiElement.CanvasHeight = mGumProjectSave.DefaultCanvasHeight;

                FileWatchLogic.Self.HandleProjectLoaded();
            }
            else
            {
                PluginManager.Self.ProjectLoad(mGumProjectSave);
            }

            // Now that a new project is loaded, refresh the UI!
            GumCommands.Self.GuiCommands.RefreshElementTreeView();


            GeneralSettingsFile.AddToRecentFilesIfNew(fileName);

            if (GeneralSettingsFile.LastProject != fileName)
            {
                GeneralSettingsFile.LastProject = fileName;
                GeneralSettingsFile.Save();
            }

            if (RecentFilesUpdated != null)
            {
                RecentFilesUpdated();
            }
        }