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);
progressBar.Visible = true;
progressLabel.Visible = true;
progressBar.Value = 0;
// Try to pull first.
try
{
progressBar.Visible = true;
await Task.Run(() => PullPatchData());
// thank you druid, for this case that should never happen
@ -95,6 +98,7 @@ namespace AM2RLauncher
finally
{
progressBar.Visible = false;
progressLabel.Visible = false;
LoadProfiles();
}
@ -810,9 +814,21 @@ namespace AM2RLauncher
/// </summary>
private void CustomMirrorTextBoxLostFocus(object sender, EventArgs e)
{
CrossPlatformOperations.WriteToConfig("CustomMirrorText", 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 + ".");
}

@ -73,45 +73,45 @@ namespace AM2RLauncher
/// Git Pulls from the repository.
/// </summary>
private void PullPatchData()
{
log.Info("Attempting to pull repository " + currentMirror + "...");
using (var repo = new Repository(CrossPlatformOperations.CURRENTPATH + "/PatchData"))
{
// Permanently undo commits not pushed to remote
Branch originMaster = repo.Branches["origin/master"];
{
log.Info("Attempting to pull repository " + currentMirror + "...");
using (var repo = new Repository(CrossPlatformOperations.CURRENTPATH + "/PatchData"))
{
// Permanently undo commits not pushed to remote
Branch originMaster = repo.Branches["origin/master"];
if (originMaster == null)
{
// 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);
HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
throw new UserCancelledException();
}
if (originMaster == null)
{
// 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);
HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
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();
options.FetchOptions = new FetchOptions();
options.FetchOptions.OnTransferProgress += TransferProgressHandlerMethod;
PullOptions options = new PullOptions();
options.FetchOptions = new FetchOptions();
options.FetchOptions.OnTransferProgress += TransferProgressHandlerMethod;
// User information to create a merge commit
var signature = new Signature("null", "null", DateTimeOffset.Now);
// User information to create a merge commit
var signature = new Signature("null", "null", DateTimeOffset.Now);
// Pull
try
{
Commands.Pull(repo, signature, options);
}
catch
{
log.Info("Repository pull attempt failed!");
return;
}
}
log.Info("Repository pulled successfully.");
// Pull
try
{
Commands.Pull(repo, signature, options);
}
catch
{
log.Info("Repository pull attempt failed!");
return;
}
}
log.Info("Repository pulled successfully.");
}
/// <summary>
/// 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;
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>

Loading…
Cancel
Save