示例#1
0
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);

            if (contentFile.FileType != ContentFileType.Image)
            {
                throw new CmdExecutionFailedException(
                          String.Format("Invalid targetContentPath: \"{0}\". It doesn't target an image content file.", data.ContentPath),
                          DefaultExecutionErrorMsg);
            }

            TgvImage oldTgv = BytesToTgv(contentFile.Content);
            TgvImage newtgv = DDSFileToTgv(data.ModificationSourcePath, !Command.UseMipMaps);

            ImageComposerService.ReplaceImageTile(
                oldTgv,
                newtgv,
                (uint)Command.TileSize.Value,
                (uint)Command.Column.Value,
                (uint)Command.Row.Value);

            var newContet = TgvToBytes(oldTgv, !Command.UseMipMaps);

            contentFile.LoadCustomContent(newContet);
        }
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);
            var content     = (new ContentFileReader()).Read(data.ModificationSourcePath);

            contentFile.LoadCustomContent(content);
        }
示例#3
0
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);

            //To nie będzie potrzebne tutaj jeśli nie bedzie trzeba ładować i wykorzystywać starego obrazka.
            if (contentFile.FileType != ContentFileType.Image)
            {
                throw new CmdExecutionFailedException(
                          String.Format("Invalid targetContentPath: \"{0}\". It doesn't target an image content file.", data.ContentPath),
                          DefaultExecutionErrorMsg);
            }

            //Ładowanie starego obrazka nie będzie potrzebne jeśli bedzie pewnośc ze recznie wygenerowana checkusma jest ok.
            //Ale co z info o kompresji? Trudno żeby użytkownik je znał poprawnie...
            TgvImage oldTgv = BytesToTgv(contentFile.Content, false);
            TgvImage newtgv = DDSFileToTgv(data.ModificationSourcePath, !Command.UseMipMaps);

            //newtgv.SourceChecksum = newtgv.ComputeContentChecksum();
            //newtgv.IsCompressed = Command.UseCompression;
            newtgv.SourceChecksum = oldTgv.SourceChecksum;
            newtgv.IsCompressed   = oldTgv.IsCompressed;

            var newContent = TgvToBytes(newtgv, !Command.UseMipMaps);

            contentFile.LoadCustomContent(newContent);
        }
        protected override void ExecuteInternal(CmdExecutionContext context, CancellationToken token)
        {
            InitializeProgress();

            //Cancel if requested;
            token.ThrowIfCancellationRequested();

            String sourceFullPath = Command.SourcePath.GetAbsoluteOrPrependIfRelative(context.InstallerSourceDirectory);

            if (!File.Exists(sourceFullPath))
            {
                throw new CmdExecutionFailedException(
                          String.Format("One of the commands refers to a non-existing source file: \"{0}\" ", Command.SourcePath),
                          DefaultExecutionErrorMsg);
            }

            String targetfullPath = Command.TargetPath.GetAbsoluteOrPrependIfRelative(context.InstallerTargetDirectory);

            if (!File.Exists(targetfullPath))
            {
                throw new CmdExecutionFailedException(
                          String.Format("One of the commands refers to a non-existing target file: \"{0}\"", Command.TargetPath),
                          DefaultExecutionErrorMsg);
            }

            String contentPath = Command.NestedTargetPath.LastPart;

            if (contentPath == null)
            {
                throw new CmdExecutionFailedException(
                          "One of the commands has an invalid targetContentPath value.",
                          DefaultExecutionErrorMsg);
            }

            //var containerFileReader = new EdataFileReader();
            //var containerFile = CanGetTargetContainerFromContext(context) ?
            //    GetTargetContainerFromContext(context) :
            //    containerFileReader.Read(targetfullPath, false);

            var containerFile = GetTargetContainerFromContext(context);
            var data          = new CmdsExecutionData
            {
                ContainerFile = containerFile,
                //ContainerPath = targetfullPath,
                ContentPath            = contentPath,
                ModificationSourcePath = sourceFullPath,
            };

            ExecuteCommandsLogic(data);

            //if (!CanGetTargetContainerFromContext(context))
            //{
            //    SaveTargetContainerFile(containerFile, token);
            //}

            SetMaxProgress();
        }
示例#5
0
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);

            var entries          = (new TradDictBinReader()).Read(contentFile.Content);
            var hashToEntriesMap = entries.ToDictionary(key => key.Hash, new ByteArrayComparer());

            RemoveEntries(hashToEntriesMap);

            AddEntries(hashToEntriesMap);

            RenameEntries(hashToEntriesMap);

            var rawDictionaryData = (new TradDictBinWriter()).Write(hashToEntriesMap.Values);

            contentFile.LoadCustomContent(rawDictionaryData);
        }
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            if (!data.ContainerFile.ContainsContentFileWithPath(data.ContentPath))
            {
                TgvImage image = DDSFileToTgv(data.ModificationSourcePath, !Command.UseMipMaps);
                //Trzeba mieć na to oko, czy nie powoduje problemów, bo przy replace była używana checksuma starego obrazka.
                image.SourceChecksum = !String.IsNullOrEmpty(Command.Checksum)
                    ? MiscUtilities.HexByteStringToByteArray(Command.Checksum)
                    : image.ComputeContentChecksum();
                image.IsCompressed = Command.UseCompression;

                var newContentFile = new EdataContentFile();
                newContentFile.Path = data.ContentPath;
                newContentFile.LoadCustomContent(TgvToBytes(image, !Command.UseMipMaps));

                data.ContainerFile.AddContentFile(newContentFile);
            }
            else if (Command.OverwriteIfExist)
            {
                var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);

                //To nie będzie potrzebne tutaj jeśli nie bedzie trzeba ładować i wykorzystywać starego obrazka.
                if (contentFile.FileType != ContentFileType.Image)
                {
                    throw new CmdExecutionFailedException(
                              String.Format("Invalid targetContentPath: \"{0}\". It doesn't target an image content file.", data.ContentPath),
                              DefaultExecutionErrorMsg);
                }

                //Ładowanie starego obrazka nie będzie potrzebne jeśli bedzie pewnośc ze recznie wygenerowana checkusma jest ok.
                //Ok, tu kiedyś było odczytywanie starych danych z starego obrazka, teraz checksuma jest generowana na nowo,
                //żeby uniknac konieczności ładowania tych starych danych, bo nie sa potrzeben przy dodawaniu, a tutaj były by potrzebne
                //i trudno to rozwiązać przy założeniu ze dane są ładowane na zewnątrz.

                //TgvImage oldTgv = BytesToTgv(contentFile.Content);
                TgvImage image = DDSFileToTgv(data.ModificationSourcePath, !Command.UseMipMaps);
                image.SourceChecksum = !String.IsNullOrEmpty(Command.Checksum)
                    ? MiscUtilities.HexByteStringToByteArray(Command.Checksum)
                    : image.ComputeContentChecksum();
                image.IsCompressed = Command.UseCompression;

                contentFile.LoadCustomContent(TgvToBytes(image, !Command.UseMipMaps));
            }
        }
示例#7
0
        protected override void ExecuteCommandsLogic(CmdsExecutionData data)
        {
            if (!data.ContainerFile.ContainsContentFileWithPath(data.ContentPath))
            {
                var newContentFile = new EdataContentFile();
                newContentFile.Path = data.ContentPath;

                var content = (new ContentFileReader()).Read(data.ModificationSourcePath);
                newContentFile.LoadCustomContent(content);

                data.ContainerFile.AddContentFile(newContentFile);
            }
            else if (Command.OverwriteIfExist)
            {
                var contentFile = data.ContainerFile.GetContentFileByPath(data.ContentPath);
                var content     = (new ContentFileReader()).Read(data.ModificationSourcePath);
                contentFile.LoadCustomContent(content);
            }
        }
 protected abstract void ExecuteCommandsLogic(CmdsExecutionData data);