Skip to content

Commit

Permalink
only allow digits for steamid64's textbox
Browse files Browse the repository at this point in the history
  • Loading branch information
sabpprook committed Mar 21, 2022
1 parent 61506cb commit 2c54998
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ private void btn_LoadFile_Click(object sender, EventArgs e)

private void btn_SaveFile_Click(object sender, EventArgs e)
{
if (UInt64.TryParse(tb_NewSteamID.Text, out UInt64 value))
var newSteamID = false;
tb_NewSteamID.Text = Regex.Replace(tb_NewSteamID.Text, "[^0-9]", "");

newSteamID = UInt64.TryParse(tb_NewSteamID.Text, out UInt64 value);

if (newSteamID)
newSteamID = !tb_CurrentSteamID.Text.Equals(value.ToString());

if (newSteamID)
{
if (MessageBox.Show(String.Format(Locale.MSG_SAVE_NEW_STEAMID64, value), "",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
Expand All @@ -141,9 +149,6 @@ private void btn_SaveFile_Click(object sender, EventArgs e)
}
else
{
if (MessageBox.Show(String.Format(Locale.MSG_SAVE_ORIG_STEAMID64, OrigSteamID), "",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
return;
NewSteamID = OrigSteamID;
}

Expand All @@ -162,8 +167,8 @@ private void btn_SaveFile_Click(object sender, EventArgs e)
if (ofd.ShowDialog() != DialogResult.OK)
return;

var downgrade = MessageBox.Show(Locale.MSG_SAVEDATA_DOWNGRADE, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
SaveData.isDowngrade = downgrade;
SaveData.isDowngrade = (MessageBox.Show(Locale.MSG_SAVEDATA_DOWNGRADE, "",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);

SaveData.SetSteamID64(NewSteamID);
SaveData.Save(ofd.FileName);
Expand Down

0 comments on commit 2c54998

Please sign in to comment.