Fix formatting + game update issues

pull/21/head
Miepee 5 years ago
parent c6563ce5e5
commit 906ec2cefe

@ -53,10 +53,13 @@ namespace AM2RLauncher
SetPlayButtonState(UpdateState.Downloading); SetPlayButtonState(UpdateState.Downloading);
progressBar.Visible = true;
progressLabel.Visible = true;
progressBar.Value = 0;
// Try to pull first. // Try to pull first.
try try
{ {
progressBar.Visible = true;
await Task.Run(() => PullPatchData()); await Task.Run(() => PullPatchData());
// thank you druid, for this case that should never happen // thank you druid, for this case that should never happen
@ -95,6 +98,7 @@ namespace AM2RLauncher
finally finally
{ {
progressBar.Visible = false; progressBar.Visible = false;
progressLabel.Visible = false;
LoadProfiles(); LoadProfiles();
} }
@ -810,9 +814,21 @@ namespace AM2RLauncher
/// </summary> /// </summary>
private void CustomMirrorTextBoxLostFocus(object sender, EventArgs e) private void CustomMirrorTextBoxLostFocus(object sender, EventArgs e)
{ {
CrossPlatformOperations.WriteToConfig("CustomMirrorText", customMirrorTextBox.Text);
currentMirror = customMirrorTextBox.Text; currentMirror = customMirrorTextBox.Text;
CrossPlatformOperations.WriteToConfig("CustomMirrorText", currentMirror);
log.Info("Overwriting mirror in gitconfig.");
//check if the gitConfig exists, if yes regex the gitURL, and replace it with the new current Mirror.
string gitConfigPath = CrossPlatformOperations.CURRENTPATH + "/PatchData/.git/config";
if (!File.Exists(gitConfigPath)) return;
string gitConfig = File.ReadAllText(gitConfigPath);
Regex gitURLRegex = new Regex("https://.*\\.git");
Match match = gitURLRegex.Match(gitConfig);
gitConfig = gitConfig.Replace(match.Value, currentMirror);
File.WriteAllText(gitConfigPath, gitConfig);
log.Info("Custom Mirror has been set to " + currentMirror + "."); log.Info("Custom Mirror has been set to " + currentMirror + ".");
} }

@ -73,45 +73,45 @@ namespace AM2RLauncher
/// Git Pulls from the repository. /// Git Pulls from the repository.
/// </summary> /// </summary>
private void PullPatchData() private void PullPatchData()
{ {
log.Info("Attempting to pull repository " + currentMirror + "..."); log.Info("Attempting to pull repository " + currentMirror + "...");
using (var repo = new Repository(CrossPlatformOperations.CURRENTPATH + "/PatchData")) using (var repo = new Repository(CrossPlatformOperations.CURRENTPATH + "/PatchData"))
{ {
// Permanently undo commits not pushed to remote // Permanently undo commits not pushed to remote
Branch originMaster = repo.Branches["origin/master"]; Branch originMaster = repo.Branches["origin/master"];
if (originMaster == null) if (originMaster == null)
{ {
// Directory exists, but seems corrupted, we delete it and prompt the user to download it again. // Directory exists, but seems corrupted, we delete it and prompt the user to download it again.
MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error); MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
throw new UserCancelledException(); throw new UserCancelledException();
} }
repo.Reset(ResetMode.Hard, originMaster.Tip); repo.Reset(ResetMode.Hard, originMaster.Tip);
// Credential information to fetch // Credential information to fetch
PullOptions options = new PullOptions(); PullOptions options = new PullOptions();
options.FetchOptions = new FetchOptions(); options.FetchOptions = new FetchOptions();
options.FetchOptions.OnTransferProgress += TransferProgressHandlerMethod; options.FetchOptions.OnTransferProgress += TransferProgressHandlerMethod;
// User information to create a merge commit // User information to create a merge commit
var signature = new Signature("null", "null", DateTimeOffset.Now); var signature = new Signature("null", "null", DateTimeOffset.Now);
// Pull // Pull
try try
{ {
Commands.Pull(repo, signature, options); Commands.Pull(repo, signature, options);
} }
catch catch
{ {
log.Info("Repository pull attempt failed!"); log.Info("Repository pull attempt failed!");
return; return;
}
}
log.Info("Repository pulled successfully.");
} }
}
log.Info("Repository pulled successfully.");
}
/// <summary> /// <summary>
/// Deletes the given <paramref name="profile"/>. Reloads the <see cref="profileList"/> if <paramref name="reloadProfileList"/> is true. /// Deletes the given <paramref name="profile"/>. Reloads the <see cref="profileList"/> if <paramref name="reloadProfileList"/> is true.
@ -229,6 +229,10 @@ namespace AM2RLauncher
settingsProfileDropDown.SelectedIndex = profileDropDown.Items.Count != 0 ? 0 : -1; settingsProfileDropDown.SelectedIndex = profileDropDown.Items.Count != 0 ? 0 : -1;
log.Info("Profiles loaded."); log.Info("Profiles loaded.");
// refresh the author and version label on the main tab
profileAuthorLabel.Text = Language.Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author;
profileVersionLabel.Text = Language.Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save