Skip to content

Commit

Permalink
Merge pull request #2 from xrandox/dev_autopause
Browse files Browse the repository at this point in the history
added auto-pause during sync
  • Loading branch information
xrandox authored Jan 25, 2023
2 parents ccf9008 + 063d8d4 commit d6b46e4
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions BlacklistBuddyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ protected override void OnModuleLoaded(EventArgs e)

CheckForBlacklistUpdate(true, true);

GameService.GameIntegration.Gw2Instance.Gw2LostFocus += delegate {
if (_doSync)
{
_doSync = false;
_popupWindow.Dispose();
MakePauseWindow(1);
}
};

base.OnModuleLoaded(e);
}

Expand Down Expand Up @@ -201,10 +210,10 @@ private async Task SyncNames()
_popupWindow = new PopupWindow("Syncing");
_popupWindow.ShowBackgroundImage();
_popupWindow.ShowLeftButton("Pause");
_popupWindow.leftButton.Click += delegate { _doSync = false; _popupWindow.Dispose(); MakePauseWindow(); };
_popupWindow.leftButton.Click += delegate { _doSync = false; _popupWindow.Dispose(); MakePauseWindow(0); };
_popupWindow.ShowRightButton("Cancel");
_popupWindow.rightButton.Click += delegate { _doSync = false; _popupWindow.Dispose(); };
_popupWindow.ShowUpperLabel("If names start stacking up in the text box,\npause and manually enter them before resuming");
_popupWindow.ShowUpperLabel("Please do not alt-tab\nIf names start stacking up in the text box,\npause and manually enter them before resuming");

int count = _blacklists.missingAll;

Expand Down Expand Up @@ -262,10 +271,23 @@ private async Task SyncNames()
/// <summary>
/// Creates a pause window for if the user pause in the middle of syncing
/// </summary>
private void MakePauseWindow()
private void MakePauseWindow(int reason)
{
_popupWindow = new PopupWindow("Syncing Paused");
_popupWindow.ShowUpperLabel("Syncing Paused\n\n\nMake sure to the text box is clear before resuming.");

string reasonStr = "";

switch (reason)
{
case 0: reasonStr = "Syncing Paused\n\n\nMake sure to the text box is clear before resuming.";
break;
case 1: reasonStr = "Syncing Paused\n\n\nPlease do not alt-tab while syncing is in progress";
break;
default: reasonStr = "Syncing Paused";
break;
}

_popupWindow.ShowUpperLabel(reasonStr);
_popupWindow.ShowLeftButton("Resume");
_popupWindow.leftButton.Click += async delegate { _popupWindow.Dispose(); await SyncNames(); };
_popupWindow.ShowRightButton("Cancel");
Expand Down

0 comments on commit d6b46e4

Please sign in to comment.