Skip to content

Commit

Permalink
clamp output threat level
Browse files Browse the repository at this point in the history
  • Loading branch information
kidfearless committed Jan 7, 2021
1 parent 85ab854 commit a202b76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Views/AddCheater.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
<TextBox x:Name="TxtSteam"
TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" VerticalContentAlignment="Top" AcceptsReturn="True"
GotFocus="TxtSteam_GotFocus" LostFocus="TxtSteam_LostFocus"
Text="https://steamcommunity.com/id/kidfearless/" Margin="10,23,10,0"/>
Text="https://steamcommunity.com/id/kidfearless/" Margin="10,23,10,0" />

<Label Margin="10,5,10,0" Grid.Column="1" Content="Threat Level" Height="70" Grid.RowSpan="2" VerticalAlignment="Top" />
<TextBox x:Name="TxtThreat"
TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" VerticalContentAlignment="Top" AcceptsReturn="True"
GotFocus="TxtThreat_GotFocus" LostFocus="TxtThreat_LostFocus"
Text="1-10" Grid.Column="1" Margin="10,23,10,0"/>
Text="1-10" Grid.Column="1" Margin="10,23,10,0" />

<Label Margin="10,5,10,0" Content="Cheat List" Grid.Column="0" Grid.Row="1" Height="46" VerticalAlignment="Top"/>
<TextBox x:Name="TxtCheats"
TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" VerticalContentAlignment="Top" AcceptsReturn="True"
Text="" Grid.Column="0" Margin="10,23,10,0" Grid.Row="1" />

<Label Margin="10,5,10,0" Content="Notes" Grid.Row="1" Grid.Column="1" Height="46" VerticalAlignment="Top"/>
<TextBox x:Name="TxtNotes"
TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" VerticalContentAlignment="Top" AcceptsReturn="True"
Text="" Margin="10,23,10,0" Grid.Row="1" Grid.Column="1"/>

<Label Margin="10,5,10,0" Content="Cheat List" Grid.Column="0" Grid.Row="1" Height="46" VerticalAlignment="Top"/>
<TextBox x:Name="TxtCheats"
TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" VerticalContentAlignment="Top" AcceptsReturn="True"
Text="" Grid.Column="0" Margin="10,23,10,0" Grid.Row="1"/>

<Label Margin="10,5,10,0" Content="Submitter" Grid.Column="0" Grid.Row="2" Height="46" VerticalAlignment="Top"/>
<TextBox x:Name="TxtSubmitter"
TextWrapping="Wrap" Height="Auto" VerticalContentAlignment="Top"
Expand Down
9 changes: 6 additions & 3 deletions Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ protected override Size MeasureOverride(Size availableSize)

private void BulkAdd_Clicked(object sender, RoutedEventArgs e)
{
new BulkAddWindow().ShowDialog();
new BulkAddWindow().Show();
}

private void SingleAdd_Clicked(object sender, RoutedEventArgs e)
{
new AddCheater().ShowDialog();
new AddCheater().Show();
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Wrong Usage", "DF0010:Marks undisposed local variables.", Justification = "It is disposed")]
Expand Down Expand Up @@ -658,13 +658,15 @@ Color GetBackgroundColor(User user)
threatLevel += 5;
}
}
threatLevel = Math.Clamp(threatLevel, 0, 10);
}
else
{
threatLevel = -1;
user.UI.ThreatLevel.Text += $"private: N/A ";

}
}
threatLevel = Math.Clamp(threatLevel, 0, 10);
return threatLevel switch
{
1 =>
Expand All @@ -686,6 +688,7 @@ Color GetBackgroundColor(User user)
9 =>
Color.FromArgb(100, 100, 100, 25),
10 => Color.FromArgb(100, 255, 255, 0),
-1 => Color.FromArgb(50, 200, 200, 200),
_ => Color.FromArgb(0, 0, 0, 0),
};
}
Expand Down

0 comments on commit a202b76

Please sign in to comment.