Skip to content

Commit

Permalink
Resharper
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonty800 committed Nov 10, 2013
1 parent 240d433 commit 0b5544f
Show file tree
Hide file tree
Showing 58 changed files with 749 additions and 617 deletions.
Binary file removed AIMLbot.dll
Binary file not shown.
26 changes: 14 additions & 12 deletions ConfigGUI/ChatPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using fCraft.ConfigGUI.Properties;
Expand Down Expand Up @@ -78,27 +79,27 @@ public void SetText( string[] lines ) {
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;

int y = 5;
for ( int i = 0; i < lines.Length; i++ ) {
if ( lines[i] == null || lines[i].Length == 0 )
foreach (string t in lines)
{
if ( string.IsNullOrEmpty(t) )
continue;
int x = 5;
string[] plainTextSegments = SplitByColorRegex.Split( lines[i] );
string[] plainTextSegments = SplitByColorRegex.Split( t );

int color = Color.ParseToIndex( Color.White );

for ( int j = 0; j < plainTextSegments.Length; j++ ) {
if ( plainTextSegments[j].Length == 0 )
continue;
if ( plainTextSegments[j][0] == '&' ) {
color = Color.ParseToIndex( plainTextSegments[j] );
foreach (string t1 in plainTextSegments.Where(t1 => t1.Length != 0))
{
if ( t1[0] == '&' ) {
color = Color.ParseToIndex( t1 );
} else {
newSegments.Add( new TextSegment {
Color = ColorPairs[color],
Text = plainTextSegments[j],
Text = t1,
X = x,
Y = y
} );
x += ( int )g.MeasureString( plainTextSegments[j], MinecraftFont ).Width;
x += ( int )g.MeasureString( t1, MinecraftFont ).Width;
}
}
y += 20;
Expand All @@ -115,8 +116,9 @@ protected override void OnPaint( PaintEventArgs e ) {
e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;

if ( segments != null && segments.Length > 0 ) {
for ( int i = 0; i < segments.Length; i++ ) {
segments[i].Draw( e.Graphics );
foreach (TextSegment t in segments)
{
t.Draw( e.Graphics );
}
}

Expand Down
4 changes: 2 additions & 2 deletions ConfigGUI/MainForm.Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void ApplyTabWorlds() {
WorldListEntry.DefaultRankOption
};
foreach ( Rank rank in RankManager.Ranks ) {
rankNameList.Add( MainForm.ToComboBoxOption( rank ) );
rankNameList.Add( ToComboBoxOption( rank ) );
}
dgvcAccess.DataSource = rankNameList;
dgvcBuild.DataSource = rankNameList;
Expand All @@ -212,7 +212,7 @@ private void ApplyTabWorlds() {
rankNameList.Clear();
rankNameList.Add( WorldListEntry.DefaultRankOption );
foreach ( Rank rank in RankManager.Ranks ) {
rankNameList.Add( MainForm.ToComboBoxOption( rank ) );
rankNameList.Add( ToComboBoxOption( rank ) );
}
foreach ( WorldListEntry world in Worlds ) {
world.ReparseRanks();
Expand Down
16 changes: 8 additions & 8 deletions ConfigGUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private void SelectRank( Rank rank ) {
private void RebuildRankList() {
vRanks.Items.Clear();
foreach ( Rank rank in RankManager.Ranks ) {
vRanks.Items.Add( MainForm.ToComboBoxOption( rank ) );
vRanks.Items.Add( ToComboBoxOption( rank ) );
}

FillRankList( cDefaultRank, "(lowest rank)" );
Expand Down Expand Up @@ -667,7 +667,7 @@ private static void FillRankList( [NotNull] ComboBox box, string firstItem ) {
box.Items.Clear();
box.Items.Add( firstItem );
foreach ( Rank rank in RankManager.Ranks ) {
box.Items.Add( MainForm.ToComboBoxOption( rank ) );
box.Items.Add( ToComboBoxOption( rank ) );
}
}

Expand All @@ -686,7 +686,7 @@ private void bAddRank_Click( object sender, EventArgs e ) {
RebuildRankList();
SelectRank( rank );

rankNameList.Insert( rank.Index + 1, MainForm.ToComboBoxOption( rank ) );
rankNameList.Insert( rank.Index + 1, ToComboBoxOption( rank ) );
}

private void bDeleteRank_Click( object sender, EventArgs e ) {
Expand Down Expand Up @@ -739,12 +739,12 @@ private void bDeleteRank_Click( object sender, EventArgs e ) {
// Update world permissions
string worldUpdates = "";
foreach ( WorldListEntry world in Worlds ) {
if ( world.AccessPermission == MainForm.ToComboBoxOption( deletedRank ) ) {
world.AccessPermission = MainForm.ToComboBoxOption( replacementRank );
if ( world.AccessPermission == ToComboBoxOption( deletedRank ) ) {
world.AccessPermission = ToComboBoxOption( replacementRank );
worldUpdates += " - " + world.Name + ": access permission changed to " + replacementRank.Name + Environment.NewLine;
}
if ( world.BuildPermission == MainForm.ToComboBoxOption( deletedRank ) ) {
world.BuildPermission = MainForm.ToComboBoxOption( replacementRank );
if ( world.BuildPermission == ToComboBoxOption( deletedRank ) ) {
world.BuildPermission = ToComboBoxOption( replacementRank );
worldUpdates += " - " + world.Name + ": build permission changed to " + replacementRank.Name + Environment.NewLine;
}
}
Expand Down Expand Up @@ -1629,7 +1629,7 @@ private void SwearEditor_Click( object sender, EventArgs e ) {

private void ReqsEditor_Click( object sender, EventArgs e ) {
if ( !System.IO.Directory.Exists( Paths.ReqPath ) ) {
System.IO.Directory.CreateDirectory( Paths.ReqPath );
Directory.CreateDirectory( Paths.ReqPath );
System.IO.Path.Combine( Paths.ReqPath, "howto.txt" );
File.WriteAllText( Path.Combine( Paths.ReqPath, "howto.txt" ),
"This folder is where you list the requirements " +
Expand Down
3 changes: 1 addition & 2 deletions ServerGUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ private void StartUp( object sender, EventArgs a ) {
Server.PlayerListChanged += OnPlayerListChanged;
Server.ShutdownEnded += OnServerShutdownEnded;
Text = "800Craft " + Updater.CurrentRelease.VersionString + " - starting...";
startupThread = new Thread( StartupThread );
startupThread.Name = "800Craft ServerGUI Startup";
startupThread = new Thread( StartupThread ) {Name = "800Craft ServerGUI Startup"};
startupThread.Start();
}

Expand Down
26 changes: 12 additions & 14 deletions ServerGUI/SkinViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ private void SetPlayerInfoText( PlayerInfo info ) {
if ( !info.LastIP.Equals( System.Net.IPAddress.None ) ) {
// Time on the server
TimeSpan totalTime = info.TotalTime;
if ( info != null ) {
totalTime = totalTime.Add( info.TimeSinceLastLogin );
}
totalTime = totalTime.Add( info.TimeSinceLastLogin );
textBox1.Text += String.Format( " Spent a total of {0:F1} hours ({1:F1} minutes) here.\r\n",
totalTime.TotalHours,
totalTime.TotalMinutes );
Expand Down Expand Up @@ -272,13 +270,14 @@ private void GetSetSkin() {
pictureBox1.Image = MakeGrayscale( pictureBox1.Image as Bitmap ); //make it black and white
pictureBox1.Image = ResizeBitmap( pictureBox1.Image as Bitmap, 148, 148 ); //resize to picturebox max size
temp = ResizeBitmap( temp, 64, 128 ); //resize the stitched skin and then copy it onto the giant b/w head
CopyRegionIntoImage( temp,
new Rectangle( 0, 0, temp.Width, temp.Height ),
pictureBox1.Image as Bitmap,
new Rectangle( pictureBox1.Image.Width - temp.Width,
pictureBox1.Height - ( temp.Height - 8 ),
temp.Width,
temp.Height ) );
if (pictureBox1.Image != null)
CopyRegionIntoImage( temp,
new Rectangle( 0, 0, temp.Width, temp.Height ),
pictureBox1.Image as Bitmap,
new Rectangle( pictureBox1.Image.Width - temp.Width,
pictureBox1.Height - ( temp.Height - 8 ),
temp.Width,
temp.Height ) );
}

private void SetTextRankColor( string c ) {
Expand Down Expand Up @@ -406,10 +405,9 @@ private static void CopyRegionIntoImage( Bitmap srcBitmap, Rectangle srcRegion,
}

private void GetSkin() {
System.Net.WebClient webClient = new System.Net.WebClient();
var webClient = new System.Net.WebClient();
try {
byte[] buffer;
buffer = webClient.DownloadData( "http://s3.amazonaws.com/MinecraftSkins/" + this.player.Name + ".png" );
byte[] buffer = webClient.DownloadData( "http://s3.amazonaws.com/MinecraftSkins/" + this.player.Name + ".png" );
if ( this.webSkin != null )
this.webSkin.Dispose();
this.webSkin = Image.FromStream( ( System.IO.Stream )new System.IO.MemoryStream( buffer ) );
Expand All @@ -421,7 +419,7 @@ private void GetSkin() {
public static Bitmap MakeGrayscale( Bitmap original ) {
unsafe {
//create an empty bitmap the same size as original
Bitmap newBitmap = new Bitmap( original.Width, original.Height );
var newBitmap = new Bitmap( original.Width, original.Height );

//lock the original bitmap in memory
System.Drawing.Imaging.BitmapData originalData = original.LockBits(
Expand Down
Binary file modified fCraft.suo
Binary file not shown.
13 changes: 7 additions & 6 deletions fCraft/AutoRank/AutoRankManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ public static Rank Check( [NotNull] PlayerInfo info ) {
if ( info == null )
throw new ArgumentNullException( "info" );
// ReSharper disable LoopCanBeConvertedToQuery
for ( int i = 0; i < Criteria.Count; i++ ) {
if ( Criteria[i].FromRank == info.Rank &&
!info.IsBanned &&
Criteria[i].Condition.Eval( info ) ) {
return Criteria[i].ToRank;
}
foreach (Criterion t in Criteria)
{
if ( t.FromRank == info.Rank &&
!info.IsBanned &&
t.Condition.Eval( info ) ) {
return t.ToRank;
}
}
// ReSharper restore LoopCanBeConvertedToQuery
return null;
Expand Down
Loading

0 comments on commit 0b5544f

Please sign in to comment.