コード例 #1
0
        private object UpdateTranslationsProcess(IWorkProgress progress, object translationList)
        {
            List <Translation>   translations = (List <Translation>)translationList;
            TranslationGenerator generator    = new TranslationGenerator();
            CompileMessages      errors       = generator.CreateTranslationList(_agsEditor.CurrentGame);

            foreach (string line in generator.LinesForTranslation)
            {
                foreach (Translation translation in translations)
                {
                    if (!translation.TranslatedLines.ContainsKey(line))
                    {
                        translation.TranslatedLines.Add(line, string.Empty);
                        translation.Modified = true;
                    }
                }
            }
            foreach (Translation translation in translations)
            {
                if (translation.Modified)
                {
                    if (_agsEditor.AttemptToGetWriteAccess(translation.FileName))
                    {
                        translation.SaveData();
                    }
                }
            }
            return(errors);
        }
コード例 #2
0
 private object DownloadUpdateStatusThread(IWorkProgress progress, object parameter)
 {
     using (System.Net.WebClient webClient = new System.Net.WebClient())
     {
         // NOTE: the message encoding depends on the data exchange format
         byte[] data = webClient.DownloadData(UPDATES_URL);
         return(Encoding.Default.GetString(data));
     }
 }
コード例 #3
0
        /// <summary>
        /// Writes the sprite file, importing all the existing sprites either from the
        /// their sources, or sprite cache, - whatever is present (in that order).
        /// </summary>
        public static void WriteSpriteFileFromSources(string filename, IWorkProgress progress)
        {
            int storeFlags = 0;

            if (Factory.AGSEditor.CurrentGame.Settings.OptimizeSpriteStorage)
            {
                storeFlags |= (int)Native.SpriteFileWriter.StorageFlags.OptimizeForSize;
            }
            var compressSprites = Factory.AGSEditor.CurrentGame.Settings.CompressSpritesType;

            SpriteFolder folder         = Factory.AGSEditor.CurrentGame.RootSpriteFolder;
            var          sprites        = folder.GetAllSpritesFromAllSubFolders();
            var          orderedSprites = sprites.OrderBy(sprite => sprite.Number);

            progress.Total   = orderedSprites.Count();
            progress.Current = 0;

            var writer = new Native.SpriteFileWriter(filename);

            writer.Begin(storeFlags, compressSprites);
            int spriteIndex = 0;
            int realSprites = 0;

            foreach (Sprite sprite in orderedSprites)
            {
                // NOTE: we must add empty slots to fill all the gaps in sprite IDs!
                for (; spriteIndex < sprite.Number; ++spriteIndex)
                {
                    writer.WriteEmptySlot();
                }

                // Try get the image, first from source, then from editor's cache
                var bmp = LoadBitmapFromSource(sprite);
                // TODO: this is quite suboptimal, find a way to retrieve a native handle instead?
                if (bmp == null)
                {
                    bmp = Factory.NativeProxy.GetBitmapForSprite(sprite.Number, sprite.Width, sprite.Height);
                }

                if (bmp != null)
                {
                    writer.WriteBitmap(bmp, sprite.TransparentColour, sprite.RemapToGamePalette,
                                       sprite.RemapToRoomPalette, sprite.AlphaChannel);
                    bmp.Dispose();
                }
                else
                {
                    bmp = new Bitmap(sprite.Width, sprite.Height);
                    writer.WriteBitmap(bmp);
                    bmp.Dispose();
                }
                progress.Current = ++realSprites;
                spriteIndex++;
            }
            writer.End();
        }
コード例 #4
0
        private object ImportOldGameThread(IWorkProgress progress, object parameter)
        {
            ImportGameResult result     = new ImportGameResult();
            string           gameToLoad = (string)parameter;

            result.LoadedGame = Factory.NativeProxy.ImportOldGame(gameToLoad);
            Dictionary <int, Sprite> spriteList = Factory.NativeProxy.LoadSpriteDimensions();

            result.Errors = ImportExport.ImportOldEditorDatFile(gameToLoad, result.LoadedGame, spriteList);
            result.LoadedGame.ConvertCoordinatesToNativeResolution();
            ImportExport.CreateInteractionScripts(result.LoadedGame, result.Errors);
            return(result);
        }
コード例 #5
0
        private object CreateDebugFiles(IWorkProgress progress, object parameter)
        {
            Factory.AGSEditor.SetMODMusicFlag();
            CompileMessages errors = (parameter as CompileMessages);

            if (!DataFileWriter.SaveThisGameToFile(AGSEditor.COMPILED_DTA_FILE_NAME, Factory.AGSEditor.CurrentGame, errors))
            {
                return(null);
            }
            Factory.NativeProxy.CreateDebugMiniEXE(new string[] { AGSEditor.COMPILED_DTA_FILE_NAME },
                                                   Factory.AGSEditor.BaseGameFileName + ".exe");
            Utilities.TryDeleteFile(AGSEditor.COMPILED_DTA_FILE_NAME);
            return(null);
        }
コード例 #6
0
        private object ReplaceGameTextWithTranslationProcess(IWorkProgress progress, object translationAsObj)
        {
            Translation     translation = (Translation)translationAsObj;
            CompileMessages errors      = TextImporter.ReplaceAllGameText(_agsEditor.CurrentGame, translation);
            // Make a copy of the dictionary, otherwise it can get overwritten
            // while updating its translation
            Dictionary <string, string> textChanges = new Dictionary <string, string>();

            foreach (string key in translation.TranslatedLines.Keys)
            {
                textChanges.Add(key, translation.TranslatedLines[key]);
            }

            UpdateAllTranslationsWithNewDefaultText(textChanges, errors);
            return(errors);
        }
コード例 #7
0
        private object MakeBackupCopyOfGameFolderThread(IWorkProgress progress, object backupLocationAsObject)
        {
            string backupLocation = (string)backupLocationAsObject;
            string sourceDir      = Path.GetDirectoryName(backupLocation);

            string[] fileNames = Utilities.GetDirectoryFileList(sourceDir, "*", SearchOption.AllDirectories);
            foreach (string file in fileNames)
            {
                string destinationFile      = backupLocation + file.Substring(sourceDir.Length);
                string destinationDirectory = Path.GetDirectoryName(destinationFile);
                if (!Directory.Exists(destinationDirectory))
                {
                    Directory.CreateDirectory(destinationDirectory);
                }
                File.Copy(file, destinationFile);
            }

            return(null);
        }
コード例 #8
0
        private object SendErrorReportThread(IWorkProgress progress, object parameter)
        {
            string exceptionText = "AGSVersion: " + AGS.Types.Version.AGS_EDITOR_VERSION +
                                   Environment.NewLine + "WinVer: " + Environment.OSVersion.VersionString +
                                   Environment.NewLine + _exception.ToString();

            string encodedForm = "exceptionText=" + HttpUtility.UrlEncode(exceptionText)
                                 + "&screenShot=" + HttpUtility.UrlEncode(GetScreenshotAsSerializedBase64String());

            // NOTE: the message encoding depends on the data exchange format
            byte[] dataToUpload = System.Text.Encoding.Default.GetBytes(encodedForm);

            using (System.Net.WebClient webClient = new System.Net.WebClient())
            {
                webClient.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
                byte[] reply = webClient.UploadData("https://www.adventuregamestudio.co.uk/errorReport.php", dataToUpload);
                return(System.Text.Encoding.Default.GetString(reply));
            }
        }
コード例 #9
0
 private object CreateTemplateFromCurrentGameProcess(IWorkProgress progress, object templateFileName)
 {
     _tasks.CreateTemplateFromCurrentGame((string)templateFileName);
     return(null);
 }