Пример #1
0
        public override bool Build(CompileMessages errors, bool forceRebuild)
        {
            if (!base.Build(errors, forceRebuild))
            {
                return(false);
            }
            try
            {
                string             baseGameFileName = Factory.AGSEditor.BaseGameFileName;
                string             exeFileName      = baseGameFileName + ".exe";
                BuildTargetWindows targetWin        = BuildTargetsInfo.FindBuildTargetByName("Windows") as BuildTargetWindows;
                if (targetWin == null)
                {
                    errors.Add(new CompileError("Debug build depends on Windows build target being available! Your AGS installation may be corrupted!"));
                    return(false);
                }
                string compiledEXE = targetWin.GetCompiledPath(exeFileName);
                string compiledDat = targetWin.GetCompiledPath(baseGameFileName + ".ags");
                string sourceEXE   = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME);
                Utilities.DeleteFileIfExists(compiledEXE);
                Utilities.DeleteFileIfExists(compiledDat);
                File.Copy(sourceEXE, exeFileName, true);
                BusyDialog.Show("Please wait while we prepare to run the game...", new BusyDialog.ProcessingHandler(CreateDebugFiles), errors);
                if (errors.HasErrors)
                {
                    return(false);
                }
                Utilities.DeleteFileIfExists(GetDebugPath(exeFileName));
                File.Move(exeFileName, GetDebugPath(exeFileName));
                // copy configuration from Compiled folder to use with Debugging
                string cfgFilePath = targetWin.GetCompiledPath(AGSEditor.CONFIG_FILE_NAME);
                if (File.Exists(cfgFilePath))
                {
                    File.Copy(cfgFilePath, GetDebugPath(AGSEditor.CONFIG_FILE_NAME), true);
                }
                else
                {
                    cfgFilePath = Path.Combine(AGSEditor.OUTPUT_DIRECTORY, Path.Combine(AGSEditor.DATA_OUTPUT_DIRECTORY, AGSEditor.CONFIG_FILE_NAME));
                    if (File.Exists(cfgFilePath))
                    {
                        File.Copy(cfgFilePath, GetDebugPath(AGSEditor.CONFIG_FILE_NAME), true);
                    }
                }
                foreach (Plugin plugin in Factory.AGSEditor.CurrentGame.Plugins)
                {
                    File.Copy(Path.Combine(Factory.AGSEditor.EditorDirectory, plugin.FileName), GetDebugPath(plugin.FileName), true);
                }

                // Copy files from Compiled/Data to Compiled/Windows, because this is currently where game will be looking them up
                targetWin.CopyAuxiliaryGameFiles(Path.Combine(AGSEditor.OUTPUT_DIRECTORY, AGSEditor.DATA_OUTPUT_DIRECTORY), false);
            }
            catch (Exception ex)
            {
                errors.Add(new CompileError("Unexpected error: " + ex.Message));
                return(false);
            }
            return(true);
        }
 public AndroidBuilderPlugin(IAGSEditor editor)
 {
     _editor = editor;
     _editor.AddComponent(AndroidBuilderComponent.Instance);
     _editor.GUIController.RegisterIcon(ICON_KEY, Properties.Resources.PluginIcon);
     _pane = new ContentDocument(AndroidBuilderPane.Instance, "Android", AndroidBuilderComponent.Instance, ICON_KEY);
     BuildTargetsInfo.RegisterBuildTarget(BuildTargetAndroid.Instance);
     AGS_VERSION_CURRENT = new AGSVersion(_editor.Version);
 }
Пример #3
0
 public override bool Build(CompileMessages errors, bool forceRebuild)
 {
     if (!base.Build(errors, forceRebuild))
     {
         return(false);
     }
     try
     {
         string baseGameFileName = Factory.AGSEditor.BaseGameFileName;
         string exeFileName      = baseGameFileName + ".exe";
         string compiledEXE      = Path.Combine(Path.Combine(AGSEditor.OUTPUT_DIRECTORY,
                                                             BuildTargetWindows.WINDOWS_DIRECTORY), exeFileName);
         string sourceEXE = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME);
         Utilities.DeleteFileIfExists(compiledEXE);
         File.Copy(sourceEXE, exeFileName, true);
         BusyDialog.Show("Please wait while we prepare to run the game...", new BusyDialog.ProcessingHandler(CreateDebugFiles), errors);
         if (errors.HasErrors)
         {
             return(false);
         }
         Utilities.DeleteFileIfExists(GetDebugPath(exeFileName));
         File.Move(exeFileName, GetDebugPath(exeFileName));
         // copy configuration from Compiled folder to use with Debugging
         string cfgFilePath = Path.Combine(AGSEditor.OUTPUT_DIRECTORY, AGSEditor.CONFIG_FILE_NAME);
         if (!Factory.AGSEditor.Preferences.UseLegacyCompiler)
         {
             IBuildTarget targetWin = BuildTargetsInfo.FindBuildTargetByName("Windows");
             if (targetWin != null)
             {
                 cfgFilePath = targetWin.GetCompiledPath(AGSEditor.OUTPUT_DIRECTORY, AGSEditor.CONFIG_FILE_NAME);
             }
         }
         if (File.Exists(cfgFilePath))
         {
             File.Copy(cfgFilePath, GetDebugPath(AGSEditor.CONFIG_FILE_NAME), true);
         }
         foreach (Plugin plugin in Factory.AGSEditor.CurrentGame.Plugins)
         {
             File.Copy(Path.Combine(Factory.AGSEditor.EditorDirectory, plugin.FileName), GetDebugPath(plugin.FileName), true);
         }
     }
     catch (Exception ex)
     {
         errors.Add(new CompileError("Unexpected error: " + ex.Message));
         return(false);
     }
     return(true);
 }
Пример #4
0
 public override bool Build(CompileMessages errors, bool forceRebuild)
 {
     if (!base.Build(errors, forceRebuild))
     {
         return(false);
     }
     Factory.AGSEditor.SetMODMusicFlag();
     DeleteAnyExistingSplitResourceFiles();
     if (Factory.AGSEditor.Preferences.UseLegacyCompiler)
     {
         Factory.NativeProxy.CompileGameToDTAFile(Factory.AGSEditor.CurrentGame, AGSEditor.COMPILED_DTA_FILE_NAME);
         // if using the legacy compiler, make sure engine EXE is copied before calling CreateGameEXE
         string newExeName = GetCompiledPath(Factory.AGSEditor.BaseGameFileName + ".exe");
         string sourceEXE  = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME);
         File.Copy(sourceEXE, newExeName, true);
         BuildTargetWindows targetWindows = (BuildTargetsInfo.FindBuildTargetByName("Windows") as BuildTargetWindows);
         // updating the Vista game explorer resources after the EXE is fully created is deleting the data file,
         // corrupting the game resources
         targetWindows.UpdateWindowsEXE(newExeName, errors);
         // the above all needs to be done here anyway, so finish up by creating the setup EXE and copying plugins
         targetWindows.CreateCompiledSetupProgram();
         targetWindows.CopyPlugins(errors);
         Factory.NativeProxy.CreateGameEXE(ConstructFileListForDataFile(), Factory.AGSEditor.CurrentGame, Factory.AGSEditor.BaseGameFileName);
     }
     else
     {
         if (!DataFileWriter.SaveThisGameToFile(AGSEditor.COMPILED_DTA_FILE_NAME, Factory.AGSEditor.CurrentGame, errors))
         {
             return(false);
         }
         string errorMsg = DataFileWriter.MakeDataFile(ConstructFileListForDataFile(), Factory.AGSEditor.CurrentGame.Settings.SplitResources * 1000000,
                                                       Factory.AGSEditor.BaseGameFileName, true);
         if (errorMsg != null)
         {
             errors.Add(new CompileError(errorMsg));
         }
     }
     File.Delete(AGSEditor.COMPILED_DTA_FILE_NAME);
     CreateAudioVOXFile(forceRebuild);
     // Update config file with current game parameters
     Factory.AGSEditor.WriteConfigFile(AGSEditor.OUTPUT_DIRECTORY);
     return(true);
 }
Пример #5
0
        private void SetDefaultValuesForNewFeatures(Game game)
        {
            // TODO: this may be noticably if upgrading lots of items. Display some kind of
            // progress window to notify user.

            int xmlVersionIndex = 0;

            if (game.SavedXmlVersionIndex.HasValue)
            {
                xmlVersionIndex = game.SavedXmlVersionIndex.Value;
            }

            if (xmlVersionIndex < 2)
            {
                // Upgrade old games to use the Anti-Glide Mode setting
                foreach (Character character in game.RootCharacterFolder.AllItemsFlat)
                {
                    character.MovementLinkedToAnimation = game.Settings.AntiGlideMode;
                }
            }

            if (xmlVersionIndex < 3)
            {
                // Upgrade old games to flatten the dialog scripts
                foreach (Dialog dialog in game.RootDialogFolder.AllItemsFlat)
                {
                    dialog.Script = RemoveAllLeadingSpacesFromLines(dialog.Script);
                }
            }

            if (xmlVersionIndex < 15)
            {
                game.DefaultSetup.SetDefaults();
            }

            if (xmlVersionIndex < 18)
            {
                foreach (Font font in game.Fonts)
                {
                    font.SizeMultiplier = 1;
                }
                // Apply font scaling to each individual font settings.
                // Bitmap fonts save multiplier explicitly, while vector fonts have their size doubled.
                if (game.Settings.HighResolution && !game.Settings.FontsForHiRes)
                {
                    foreach (Font font in game.Fonts)
                    {
                        if (font.PointSize == 0)
                        {
                            font.SizeMultiplier = 2;
                        }
                        else
                        {
                            font.PointSize *= 2;
                        }
                    }
                }
            }

            if (xmlVersionIndex < 18)
            {
                game.Settings.AllowRelativeAssetResolutions = true;
                game.Settings.DefaultRoomMaskResolution     = 1;
            }

            if (xmlVersionIndex < 19)
            {
                game.Settings.GameFileName = AGSEditor.Instance.BaseGameFileName;

                var buildNames = new Dictionary <string, string>();
                foreach (IBuildTarget target in BuildTargetsInfo.GetRegisteredBuildTargets())
                {
                    buildNames[target.Name] = AGSEditor.Instance.BaseGameFileName;
                }
                game.WorkspaceState.SetLastBuildGameFiles(buildNames);
            }

            game.SetScriptAPIForOldProject();
        }
Пример #6
0
        private void SetDefaultValuesForNewFeatures(Game game)
        {
            // TODO: this may be noticably if upgrading lots of items. Display some kind of
            // progress window to notify user.

            int xmlVersionIndex = 0;

            if (game.SavedXmlVersionIndex.HasValue)
            {
                xmlVersionIndex = game.SavedXmlVersionIndex.Value;
            }

            if (xmlVersionIndex < 2)
            {
                // Upgrade old games to use the Anti-Glide Mode setting
                foreach (Character character in game.RootCharacterFolder.AllItemsFlat)
                {
                    character.MovementLinkedToAnimation = game.Settings.AntiGlideMode;
                }
            }

            if (xmlVersionIndex < 3)
            {
                // Upgrade old games to flatten the dialog scripts
                foreach (Dialog dialog in game.RootDialogFolder.AllItemsFlat)
                {
                    dialog.Script = RemoveAllLeadingSpacesFromLines(dialog.Script);
                }
            }

            if (xmlVersionIndex < 15)
            {
                game.DefaultSetup.SetDefaults();
            }

            if (xmlVersionIndex < 18)
            {
                // Promote sprites to "real" resolution when possible (ideally almost always)
                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    sprite.Resolution = Utilities.FixupSpriteResolution(sprite.Resolution);
                }
            }

            if (xmlVersionIndex < 18)
            {
                foreach (Font font in game.Fonts)
                {
                    font.SizeMultiplier = 1;
                }
                // Apply font scaling to each individual font settings.
                // Bitmap fonts save multiplier explicitly, while vector fonts have their size doubled.
                if (game.IsHighResolution && !game.Settings.FontsForHiRes)
                {
                    foreach (Font font in game.Fonts)
                    {
                        if (font.PointSize == 0)
                        {
                            font.SizeMultiplier = 2;
                        }
                        else
                        {
                            font.PointSize *= 2;
                        }
                    }
                }
            }

            if (xmlVersionIndex < 18)
            {
                game.Settings.AllowRelativeAssetResolutions = true;
                game.Settings.DefaultRoomMaskResolution     = game.IsHighResolution ? 2 : 1;
            }

            if (xmlVersionIndex < 19)
            {
                game.Settings.GameFileName = AGSEditor.Instance.BaseGameFileName ??
                                             Path.GetFileName(game.DirectoryPath);

                var buildNames = new Dictionary <string, string>();
                foreach (IBuildTarget target in BuildTargetsInfo.GetRegisteredBuildTargets())
                {
                    buildNames[target.Name] = game.Settings.GameFileName;
                }
                game.WorkspaceState.SetLastBuildGameFiles(buildNames);
            }

            if (xmlVersionIndex < 20)
            {
                // Set the alpha channel requests for re-import based on the presence of an alpha channel
                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    sprite.ImportAlphaChannel = sprite.AlphaChannel;
                }
            }

            if (xmlVersionIndex < 21)
            {
                // Assign audio clip ids to match and solidify their current position in AudioClips array.
                int clipId = 0;
                foreach (AudioClip clip in game.RootAudioClipFolder.GetAllAudioClipsFromAllSubFolders())
                {
                    clip.ID = clipId++;
                }
                game.RootAudioClipFolder.Sort(true);
            }

            if (xmlVersionIndex < 22)
            {
                game.Settings.ScaleMovementSpeedWithMaskResolution = true;
            }

            if (xmlVersionIndex < 23)
            {
                // Set the import dimensions based on existing sprite dimensions
                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    sprite.ImportWidth  = sprite.Width;
                    sprite.ImportHeight = sprite.Height;
                }
            }

            if (xmlVersionIndex < 24)
            {
                // get all known source images and their largest known size
                // (avoiding System.Drawing / GDI as a dependency to load the project)
                Dictionary <string, Tuple <int, int> > sourceMaxSize = new Dictionary <string, Tuple <int, int> >(StringComparer.OrdinalIgnoreCase);

                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    if (!string.IsNullOrWhiteSpace(sprite.SourceFile))
                    {
                        int currentX = sprite.OffsetX + sprite.ImportWidth;
                        int currentY = sprite.OffsetY + sprite.ImportHeight;

                        if (sourceMaxSize.ContainsKey(sprite.SourceFile))
                        {
                            int maxX = sourceMaxSize[sprite.SourceFile].Item1;
                            int maxY = sourceMaxSize[sprite.SourceFile].Item2;
                            if (maxX < currentX)
                            {
                                maxX = currentX;
                            }
                            if (maxY < currentY)
                            {
                                maxY = currentY;
                            }
                            sourceMaxSize[sprite.SourceFile] = Tuple.Create(maxX, maxY);
                        }
                        else
                        {
                            sourceMaxSize.Add(sprite.SourceFile, Tuple.Create(currentX, currentY));
                        }
                    }
                }

                // Set the tiled image flag for existing imports - the only misdetection would be
                // a single import from a source image that starts at 0,0, but wasn't for the
                // entire image
                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    if (sprite.OffsetX > 0 || sprite.OffsetY > 0)
                    {
                        sprite.ImportAsTile = true;
                    }
                    else if (sourceMaxSize.ContainsKey(sprite.SourceFile))
                    {
                        int maxX = sourceMaxSize[sprite.SourceFile].Item1;
                        int maxY = sourceMaxSize[sprite.SourceFile].Item2;
                        sprite.ImportAsTile = sprite.ImportWidth < maxX || sprite.ImportHeight < maxY;
                    }
                    else
                    {
                        sprite.ImportAsTile = false;
                    }
                }
            }

            if (xmlVersionIndex >= 21 && xmlVersionIndex <= 25)
            {
                // Remap erroneous volatile clip ID references back to Fixed Index
                Dictionary <int, int> audioIDToIndex = new Dictionary <int, int>();
                foreach (AudioClip clip in game.RootAudioClipFolder.GetAllAudioClipsFromAllSubFolders())
                {
                    audioIDToIndex.Add(clip.ID, clip.Index);
                }

                game.Settings.PlaySoundOnScore = RemapAudioClipIDToFixedIndex(game.Settings.PlaySoundOnScore, audioIDToIndex);
                foreach (Types.View view in game.RootViewFolder.AllItemsFlat)
                {
                    foreach (Types.ViewLoop loop in view.Loops)
                    {
                        foreach (Types.ViewFrame frame in loop.Frames)
                        {
                            if (frame.Sound == AudioClip.IDNoValue)
                            {
                                frame.Sound = AudioClip.FixedIndexNoValue;
                            }
                            else
                            {
                                frame.Sound = RemapAudioClipIDToFixedIndex(frame.Sound, audioIDToIndex);
                            }
                        }
                    }
                }
            }

            System.Version editorVersion  = new System.Version(AGS.Types.Version.AGS_EDITOR_VERSION);
            System.Version projectVersion = game.SavedXmlEditorVersion != null?Types.Utilities.TryParseVersion(game.SavedXmlEditorVersion) : null;

            if (projectVersion == null || projectVersion < editorVersion)
            {
                game.SetScriptAPIForOldProject();
            }
        }
Пример #7
0
        private void SetDefaultValuesForNewFeatures(Game game)
        {
            // TODO: this may be noticably if upgrading lots of items. Display some kind of
            // progress window to notify user.

            int xmlVersionIndex = 0;

            if (game.SavedXmlVersionIndex.HasValue)
            {
                xmlVersionIndex = game.SavedXmlVersionIndex.Value;
            }

            if (xmlVersionIndex < 2)
            {
                // Upgrade old games to use the Anti-Glide Mode setting
                foreach (Character character in game.RootCharacterFolder.AllItemsFlat)
                {
                    character.MovementLinkedToAnimation = game.Settings.AntiGlideMode;
                }
            }

            if (xmlVersionIndex < 3)
            {
                // Upgrade old games to flatten the dialog scripts
                foreach (Dialog dialog in game.RootDialogFolder.AllItemsFlat)
                {
                    dialog.Script = RemoveAllLeadingSpacesFromLines(dialog.Script);
                }
            }

            if (xmlVersionIndex < 15)
            {
                game.DefaultSetup.SetDefaults();
            }

            if (xmlVersionIndex < 18)
            {
                foreach (Font font in game.Fonts)
                {
                    font.SizeMultiplier = 1;
                }
                // Apply font scaling to each individual font settings.
                // Bitmap fonts save multiplier explicitly, while vector fonts have their size doubled.
                if (game.Settings.HighResolution && !game.Settings.FontsForHiRes)
                {
                    foreach (Font font in game.Fonts)
                    {
                        if (font.PointSize == 0)
                        {
                            font.SizeMultiplier = 2;
                        }
                        else
                        {
                            font.PointSize *= 2;
                        }
                    }
                }
            }

            if (xmlVersionIndex < 18)
            {
                game.Settings.AllowRelativeAssetResolutions = true;
                game.Settings.DefaultRoomMaskResolution     = 1;
            }

            if (xmlVersionIndex < 19)
            {
                game.Settings.GameFileName = AGSEditor.Instance.BaseGameFileName;

                var buildNames = new Dictionary <string, string>();
                foreach (IBuildTarget target in BuildTargetsInfo.GetRegisteredBuildTargets())
                {
                    buildNames[target.Name] = AGSEditor.Instance.BaseGameFileName;
                }
                game.WorkspaceState.SetLastBuildGameFiles(buildNames);
            }

            if (xmlVersionIndex < 20)
            {
                // Set the alpha channel requests for re-import based on the presence of an alpha channel
                foreach (Sprite sprite in game.RootSpriteFolder.GetAllSpritesFromAllSubFolders())
                {
                    sprite.ImportAlphaChannel = sprite.AlphaChannel;
                }
            }

            if (xmlVersionIndex < 21)
            {
                // Assign audio clip ids to match and solidify their current position in AudioClips array.
                int clipId = 0;
                Dictionary <int, int> audioIndexToID = new Dictionary <int, int>();
                foreach (AudioClip clip in game.RootAudioClipFolder.GetAllAudioClipsFromAllSubFolders())
                {
                    clip.ID = clipId++;
                    audioIndexToID.Add(clip.Index, clip.ID);
                }
                game.RootAudioClipFolder.Sort(true);

                // Remap old cache indexes to new IDs
                if (game.Settings.PlaySoundOnScore == 0)
                {
                    game.Settings.PlaySoundOnScore = -1;
                }
                else
                {
                    int id;
                    if (audioIndexToID.TryGetValue(game.Settings.PlaySoundOnScore, out id))
                    {
                        game.Settings.PlaySoundOnScore = id;
                    }
                    else
                    {
                        game.Settings.PlaySoundOnScore = -1;
                    }
                }

                foreach (Types.View view in game.RootViewFolder.AllItemsFlat)
                {
                    foreach (Types.ViewLoop loop in view.Loops)
                    {
                        foreach (Types.ViewFrame frame in loop.Frames)
                        {
                            if (frame.Sound == 0)
                            {
                                frame.Sound = -1;
                            }
                            else
                            {
                                int id;
                                if (audioIndexToID.TryGetValue(frame.Sound, out id))
                                {
                                    frame.Sound = id;
                                }
                                else
                                {
                                    frame.Sound = -1;
                                }
                            }
                        }
                    }
                }
            }

            game.SetScriptAPIForOldProject();
        }