Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Fix frontend's copy routines
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed Sep 28, 2013
1 parent 34effc0 commit 408afb0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
3 changes: 2 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,5 @@ Revision Log Message
495 Give cores on absorbed vassals
496 Update converter mod
497 Merge minor to main
498 Put saves in the correct places
498 Put saves in the correct places
499 Fix frontend's copy routines
22 changes: 19 additions & 3 deletions Data Files/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ EU3:DW version 5.1 or later
INSTRUCTIONS
----

1) Run Converter.UI.exe.
2) Set the paths correctly.
If the browse buttons don't work, type something into the text fields and try again.
3) Set the options how you want them.
4) Go to the convert tab.
5) Click 'save configuration file'.
6) Click Convert.
7) When the converter finishes, load up the save and verify everything converted well.



----
INSTRUCTIONS (manual method)
----

1) Find the desired save file in "[YOUR CK2 SAVE DIRECTORY]/save games".
2) Open the file "configuration.txt". In the file there is a line that reads
CK2directory = "D:\Paradox Interactive\Crusader Kings II"
Expand All @@ -30,9 +45,10 @@ INSTRUCTIONS
If using Steam, this is likely "C:\Program Files\Steam\steamapps\common\Europa Universalis III\"
Otherwise it is likely "C:\Program Files\Paradox Interactive\Europa Universalis III\"
4) Run "CK2ToEU3.exe" by dropping your save onto the exe. This will create a file in the converter's directory called "output.eu3".
6) Copy output.eu3 to "[YOUR EU3 DIRECTORY]/save games".
7) A file named log.txt will also be created. Immediately report any errors to the thread on the forums.
8) Load up the save and verify everything converted well.
5a) If you are not using the converter mod, copy the new save to "[YOUR EU3 DIRECTORY]/save games".
5b) If you are using the converter mod, copy the items in the new mod folder to "[YOUR EU3 DIRECTORY]/mod".
6) A file named log.txt will also be created. Immediately report any errors to the thread on the forums.
7) Load up the save and verify everything converted well.



Expand Down
27 changes: 14 additions & 13 deletions UI/Commands/ConvertCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,14 @@ protected override void AfterExecute(object parameter, Exception error)
/// </summary>
private void OnSuccessfulConversion()
{
var wasMoveSuccessful = this.MoveSaveGame();

if (this.Options.UseConverterMod && wasMoveSuccessful)
if (this.Options.UseConverterMod)
{
this.InstallConverterMod();
}
else
{
this.MoveSaveGame();
}
}

/// <summary>
Expand All @@ -209,24 +211,24 @@ private void InstallConverterMod()
if (!Directory.Exists(absoluteSourcePath))
{
// Log error
this.Log("Could not find mod folder (" + absoluteSourcePath + "), making it somewhat hard to copy said folder to " + this.Options.TargetGame.ModPath + ". This means that the converter mod isn't installed, so you might want to try to do it manually instead.", LogEntrySeverity.Error, LogEntrySource.UI);
this.Log("Could not find mod folder (" + absoluteSourcePath + "), making it somewhat hard to copy said folder to " + this.Options.TargetGame.InstallationPath + "\\mod" + ". This means that the converter mod isn't installed, so you might want to try to do it manually instead.", LogEntrySeverity.Error, LogEntrySource.UI);
return;
}

// Overwrite needed?
if (!File.Exists(this.Options.TargetGame.ModPath))
if (!File.Exists(this.Options.TargetGame.InstallationPath + "\\mod"))
{
// Ask permission for overwrite (or delete whole thing, then recopy?)
}

try
{
DirectoryCopyHelper.DirectoryCopy(absoluteSourcePath, this.Options.TargetGame.ModPath, true, true);
this.Log("Converter mod copied successfully from " + absoluteSourcePath + " to " + this.Options.TargetGame.ModPath, LogEntrySeverity.Info, LogEntrySource.UI);
DirectoryCopyHelper.DirectoryCopy(absoluteSourcePath, this.Options.TargetGame.InstallationPath + "\\mod", true, true);
this.Log("Converter mod copied successfully from " + absoluteSourcePath + " to " + this.Options.TargetGame.InstallationPath + "\\mod", LogEntrySeverity.Info, LogEntrySource.UI);
}
catch (Exception ex)
{
this.Log("Converter mod installation failed. Directory could not be copied from " + absoluteSourcePath + " to " + this.Options.TargetGame.ModPath + ". The internal error message was: " + ex.Message, LogEntrySeverity.Error, LogEntrySource.UI);
this.Log("Converter mod installation failed. Directory could not be copied from " + absoluteSourcePath + " to " + this.Options.TargetGame.InstallationPath + "\\mod" + ". The internal error message was: " + ex.Message, LogEntrySeverity.Error, LogEntrySource.UI);
}
}

Expand All @@ -238,9 +240,9 @@ private bool MoveSaveGame()
bool wasMoveSuccessful = false;

// Copy the newly created save to the target game output directory.
var desiredFileName = Path.GetFileNameWithoutExtension(this.Options.SourceSaveGame) + "_Converted" + this.Options.TargetGame.SaveGameExtension;
var desiredFileName = Path.GetFileNameWithoutExtension(this.Options.SourceSaveGame) + this.Options.TargetGame.SaveGameExtension;
var canOverWrite = false;
var expectedOutputDirectoryAndFile = Path.Combine(this.Options.TargetGame.SaveGamePath, desiredFileName);
var expectedOutputDirectoryAndFile = Path.Combine(this.Options.TargetGame.InstallationPath + this.Options.TargetGame.SaveGamePath, desiredFileName);

// Don't blindly overwrite any existing saves - that's just rude
if (File.Exists(expectedOutputDirectoryAndFile))
Expand All @@ -264,7 +266,7 @@ private bool MoveSaveGame()
{
var outputSavePath = this.DetermineOutputSavePath();
File.Copy(outputSavePath, expectedOutputDirectoryAndFile, canOverWrite);
this.Log(desiredFileName + " has been written to \"" + this.Options.TargetGame.SaveGamePath + "\".", LogEntrySeverity.Info, LogEntrySource.UI);
this.Log(desiredFileName + " has been written to \"" + this.Options.TargetGame.InstallationPath + this.Options.TargetGame.SaveGamePath + "\".", LogEntrySeverity.Info, LogEntrySource.UI);

//File.Delete(outputSavePath);
//this.Log("Deleted temporary file(s).", LogEntrySeverity.Info, LogEntrySource.UI);
Expand All @@ -285,8 +287,7 @@ private bool MoveSaveGame()
/// <returns></returns>
private string DetermineOutputSavePath()
{
var outputSaveName = Path.GetFileNameWithoutExtension(this.Options.SourceSaveGame) + this.Options.SourceGame.SaveGameExtension;
return Path.Combine(Path.GetDirectoryName(this.Options.SourceSaveGame), outputSaveName);
return Path.GetFileNameWithoutExtension(this.Options.SourceSaveGame) + this.Options.TargetGame.SaveGameExtension;
}

/// <summary>
Expand Down

0 comments on commit 408afb0

Please sign in to comment.