Skip to content

Commit

Permalink
Add manual date reset button
Browse files Browse the repository at this point in the history
  • Loading branch information
LegoFigure11 committed Oct 18, 2023
1 parent d22b897 commit 48edfd7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RaidCrawler.Core/Connection/ConnectionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private async Task SkipHour(int hours, int delay, CancellationToken token)
}
}

private async Task ResetTime(CancellationToken token)
public async Task ResetTime(CancellationToken token)
{
var command = Encoding.ASCII.GetBytes($"resetTime{(CRLF ? "\r\n" : "")}");
await Connection.SendAsync(command, token).ConfigureAwait(false);
Expand Down
16 changes: 15 additions & 1 deletion RaidCrawler.WinForms/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions RaidCrawler.WinForms/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ await ErrorHandler
ButtonDownloadEvents,
SendScreenshot,
btnOpenMap,
Rewards
Rewards,
B_ResetTime
},
true
);
Expand Down Expand Up @@ -423,7 +424,8 @@ private void Disconnect(CancellationToken token)
ButtonDisconnect,
ButtonViewRAM,
ButtonDownloadEvents,
SendScreenshot
SendScreenshot,
B_ResetTime
},
false
);
Expand Down Expand Up @@ -2201,5 +2203,30 @@ private static string GetSpriteNameForUrl(PK9 pk, bool shiny)
)[1..];
return spriteName.Replace('_', '-').Insert(0, "_");
}

private void B_ResetTime_Click(object sender, EventArgs e)
{
Task.Run(async () =>
{
try
{
UpdateStatus("Resetting date...");
await ConnectionWrapper.ResetTime(Source.Token).ConfigureAwait(false);
UpdateStatus("Date reset!");
}
catch (Exception ex)
{
await ErrorHandler
.DisplayMessageBox(
this,
Webhook,
$"Could not reset the date: {ex.Message}",
Source.Token
)
.ConfigureAwait(false);
return;
}
});
}
}
}

0 comments on commit 48edfd7

Please sign in to comment.