Exemplo n.º 1
0
        private IAlternativePath ReadConverterPath(XElement xmlElement, string tagName, string friendlyName, string predefinedFileName)
        {
            var subFolderLocation = XElementHelper.ReadStringValue(xmlElement, "subFolderLocation");

            // If a predefined file name is set, include it in the absolute path (and hence the alternativepath.exists check)
            var absolutePath = string.IsNullOrEmpty(predefinedFileName) ?
                               Path.Combine(environmentProxy.GetFrontendWorkingDirectory(), subFolderLocation) :
                               Path.Combine(environmentProxy.GetFrontendWorkingDirectory(), subFolderLocation, predefinedFileName);

            return(BuildAlternativePathObject(absolutePath, tagName, friendlyName));
        }
Exemplo n.º 2
0
        public OperationResult Process()
        {
            var savePath     = options.CurrentConverter.AbsoluteSourceSaveGame.SelectedValue;
            var extractPath  = environmentProxy.GetFrontendWorkingDirectory();
            var result       = new OperationResult();
            var saveFileName = Path.GetFileName(savePath);

            result.State = OperationResultState.Error;
            result.LogEntries.Add(new LogEntry("Ironman saves are not supported", LogEntrySeverity.Error, LogEntrySource.UI));

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Constructs the string that will be saved to disk as the config file.
        /// </summary>
        /// <returns></returns>
        public string BuiltOutputString(IConverterSettings converterSettings, IDirectoryHelper directoryHelper)
        {
            var sb = new StringBuilder();

            sb.AppendLine(ReadTextFile(environmentProxy.GetFrontendWorkingDirectory() + "\\Docs\\license.txt"));

            sb.AppendLine("configuration =");
            sb.AppendLine("{");

            // TODO: Mod support
            // Output source and target game settings

            // Why the "where clause": Some entries in the requireditems list is only used by the frontend.
            // Those that needs to go into configuration.txt has the "TagName" attribute check, the others don't.
            foreach (var folder in converterSettings.RequiredItems.OfType <IRequiredFolder>()
                     .Where(f => !string.IsNullOrEmpty(f.TagName)))
            {
                sb.AppendLine("\t# " + folder.FriendlyName + ": " + folder.Description);
                sb.AppendLine("\t" + folder.TagName + " = \"" + folder.SelectedValue + "\"");
                sb.AppendLine();
            }

            foreach (var file in converterSettings.RequiredItems.OfType <IRequiredFile>()
                     .Where(f => string.IsNullOrEmpty(f.InternalTagName)).Where(f => !f.IsHidden))
            {
                sb.AppendLine("\t# " + file.FriendlyName + ": " + file.Description);
                sb.AppendLine("\t" + file.TagName + " = \"" + file.SelectedValue + "\"");
                sb.AppendLine();
            }

            // Preferences
            foreach (var category in converterSettings.Categories)
            {
                category.Preferences.ForEach(p => sb.AppendLine("\t" + p.ToString()));
            }

            sb.AppendLine("}");
            return(sb.ToString());
        }
        public OperationResult Process()
        {
            var savePath     = options.CurrentConverter.AbsoluteSourceSaveGame.SelectedValue;
            var extractPath  = environmentProxy.GetFrontendWorkingDirectory();
            var result       = new OperationResult();
            var saveFileName = Path.GetFileName(savePath);

            try
            {
                zipFileHelper.ExtractFile(savePath, saveFileName, extractPath);
                options.CurrentConverter.AbsoluteSourceSaveGame.SelectedValue = Path.Combine(extractPath,
                                                                                             saveFileName);
                result.State = OperationResultState.Success;
            }
            catch (Exception e)
            {
                result.State = OperationResultState.Error;
                result.LogEntries.Add(new LogEntry(e.Message, LogEntrySeverity.Error, LogEntrySource.UI));
            }

            return(result);
        }