Implement Daily Jackpot Spin

Fix Profile Form Not Resizing With Username Length
This commit is contained in:
Alan Moon 2025-12-10 13:41:36 -08:00
parent 4e3a057177
commit 1e220a23a1
3 changed files with 108 additions and 122 deletions

View File

@ -414,63 +414,7 @@ namespace qtcnet_client
KryptonMessageBox.Show("The Server Has Logged You Out. Please Try Signing In Again.", "Uh Oh.", KryptonMessageBox.Show("The Server Has Logged You Out. Please Try Signing In Again.", "Uh Oh.",
KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.Error); KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.Error);
var _res = await _apiService.LogoutAsync(); LogoutAsync();
if(_res)
{
_credentialService.DeleteAccessToken();
SuspendLayout();
// remove controls
Controls.Remove(MainTabControl);
Controls.Remove(CurrentProfileControl);
// dispose of them
MainTabControl?.Dispose();
MainTabControl = null;
CurrentProfileControl?.Dispose();
CurrentProfileControl = null;
// readd login control and branding
Size = LoggedOutSize;
// unsub from gateway events
_gatewayService.OnServerReconnecting -= _gatewayService_OnServerReconnecting;
_gatewayService.OnServerReconnected -= _gatewayService_OnServerReconnected;
_gatewayService.OnServerDisconnect -= _gatewayService_OnServerDisconnect;
//_gatewayService.OnDirectMessageReceived -= _gatewayService_OnDirectMessageReceived;
_gatewayService.OnRoomMessageReceived -= _gatewayService_OnRoomMessageReceived;
_gatewayService.OnRoomUserListReceived -= _gatewayService_OnRoomUserListReceived;
_gatewayService.OnRefreshUserListsReceived -= _gatewayService_OnRefreshUserListReceived;
_gatewayService.OnRefreshRoomListReceived -= _gatewayService_OnRefreshRoomListReceived;
_gatewayService.OnRefreshContactsListReceived -= _gatewayService_OnRefreshContactsListReceived;
_gatewayService.OnServerConfigReceived -= _gatewayService_OnServerConfigReceived;
_gatewayService.OnUserForceLogout -= _gatewayService_OnUserForceLogout;
// stop gateway connection
await _gatewayService.StopAsync();
// add branding control
BrandingControl = new()
{
Location = new(-2, -17),
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
// add login control
LoginControl = new()
{
Location = new(12, 233)
};
LoginControl.OnSuccessfulLogin += LoginControl_OnSuccessfulLogin;
LoginControl.OnRegisterPressed += LoginControl_OnRegisterPressed;
Controls.Add(BrandingControl);
Controls.Add(LoginControl);
ResumeLayout(true);
}
} }
private void _gatewayService_OnServerConfigReceived(object? sender, EventArgs e) private void _gatewayService_OnServerConfigReceived(object? sender, EventArgs e)
@ -688,6 +632,30 @@ namespace qtcnet_client
Controls.Add(MainTabControl); Controls.Add(MainTabControl);
ResumeLayout(true); ResumeLayout(true);
// check for daily spin eligibility
var now = DateTime.UtcNow;
var lastSpin = _apiService.CurrentUser.LastCurrencySpin;
if(lastSpin.Date < now.Date)
{
Random rnd = new();
JackpotSpinForm _jackpotSpin = new()
{
CurrencyWon = rnd.Next(0, 500)
};
var _dialogRes = _jackpotSpin.ShowDialog();
if(_dialogRes == DialogResult.OK)
{
// claim
var _apiRes = await _apiService.AddCurrencyToCurrentUser(_jackpotSpin.CurrencyWon, true);
if (_apiRes.Success)
_jackpotSpin.Dispose();
else
KryptonMessageBox.Show("We Couldn't Claim Your Prize At This Time. You Should Be Able To Spin Again Next Restart.", "Uh Oh.");
}
}
} }
else else
{ {
@ -698,12 +666,7 @@ namespace qtcnet_client
} }
} }
private async void CurrentProfileControl_OnSignOutClicked(object? sender, EventArgs e) private async void LogoutAsync()
{
var _dialogRes = KryptonMessageBox.Show("Doing This Will Sign You Out. Are You Sure?", "are you sure...?",
KryptonMessageBoxButtons.YesNo, KryptonMessageBoxIcon.Question);
if (_dialogRes == DialogResult.Yes)
{ {
var _res = await _apiService.LogoutAsync(); var _res = await _apiService.LogoutAsync();
@ -764,6 +727,14 @@ namespace qtcnet_client
ResumeLayout(true); ResumeLayout(true);
} }
} }
private async void CurrentProfileControl_OnSignOutClicked(object? sender, EventArgs e)
{
var _dialogRes = KryptonMessageBox.Show("Doing This Will Sign You Out. Are You Sure?", "are you sure...?",
KryptonMessageBoxButtons.YesNo, KryptonMessageBoxIcon.Question);
if (_dialogRes == DialogResult.Yes)
LogoutAsync();
} }
private async void CurrentProfileControl_OnEditProfileClicked(object? sender, EventArgs e) private async void CurrentProfileControl_OnEditProfileClicked(object? sender, EventArgs e)

View File

@ -119,16 +119,17 @@
// tlpUsernameTags // tlpUsernameTags
// //
tlpUsernameTags.AutoSize = true; tlpUsernameTags.AutoSize = true;
tlpUsernameTags.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tlpUsernameTags.ColumnCount = 2; tlpUsernameTags.ColumnCount = 2;
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tlpUsernameTags.ColumnStyles.Add(new ColumnStyle());
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tlpUsernameTags.ColumnStyles.Add(new ColumnStyle());
tlpUsernameTags.Controls.Add(lblUsername, 0, 0); tlpUsernameTags.Controls.Add(lblUsername, 0, 0);
tlpUsernameTags.Controls.Add(tlpTagIcons, 1, 0); tlpUsernameTags.Controls.Add(tlpTagIcons, 1, 0);
tlpUsernameTags.Location = new Point(115, 11); tlpUsernameTags.Location = new Point(115, 11);
tlpUsernameTags.Name = "tlpUsernameTags"; tlpUsernameTags.Name = "tlpUsernameTags";
tlpUsernameTags.RowCount = 1; tlpUsernameTags.RowCount = 1;
tlpUsernameTags.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tlpUsernameTags.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tlpUsernameTags.Size = new Size(304, 55); tlpUsernameTags.Size = new Size(303, 55);
tlpUsernameTags.TabIndex = 6; tlpUsernameTags.TabIndex = 6;
// //
// lblUsername // lblUsername
@ -184,6 +185,7 @@
Controls.Add(rtxtBio); Controls.Add(rtxtBio);
Controls.Add(lblStatus); Controls.Add(lblStatus);
Controls.Add(pbProfileImage); Controls.Add(pbProfileImage);
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false; MaximizeBox = false;
Name = "ProfileForm"; Name = "ProfileForm";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;

View File

@ -49,6 +49,8 @@ namespace qtcnet_client.Forms
rtxtBio.Text = Bio; rtxtBio.Text = Bio;
pbProfileImage.Image = ProfileImage; pbProfileImage.Image = ProfileImage;
ResizeFormToUsername();
if (Status == 0) lblStatus.Visible = false; if (Status == 0) lblStatus.Visible = false;
if (UserId == _apiService.CurrentUser?.Id) if (UserId == _apiService.CurrentUser?.Id)
@ -202,7 +204,7 @@ namespace qtcnet_client.Forms
{ {
Text = lblUsername.Text, Text = lblUsername.Text,
Font = lblUsername.Font, Font = lblUsername.Font,
MaxLength = 16, MaxLength = 25,
Dock = lblUsername.Dock, Dock = lblUsername.Dock,
Location = lblUsername.Location, Location = lblUsername.Location,
Size = lblUsername.Size, Size = lblUsername.Size,
@ -220,6 +222,7 @@ namespace qtcnet_client.Forms
lblUsername.Text = txtUsernameEdit.Text; lblUsername.Text = txtUsernameEdit.Text;
tlpUsernameTags.Controls.Remove(txtUsernameEdit); tlpUsernameTags.Controls.Remove(txtUsernameEdit);
txtUsernameEdit.Dispose(); txtUsernameEdit.Dispose();
ResizeFormToUsername();
lblUsername.Visible = true; lblUsername.Visible = true;
} }
} }
@ -294,5 +297,15 @@ namespace qtcnet_client.Forms
pbProfileImage.Cursor = Cursors.Default; pbProfileImage.Cursor = Cursors.Default;
pbProfileImage.Invalidate(); pbProfileImage.Invalidate();
} }
private void ResizeFormToUsername()
{
int padding = 40;
int minWidth = 445;
int newWidth = lblUsername.Right + padding;
if (newWidth > minWidth)
Width = newWidth;
}
} }
} }