combine some of the code from the last commit

This commit is contained in:
Mitchell Livingston 2008-06-10 21:33:13 +00:00
parent a896093804
commit 6a0038f146
1 changed files with 30 additions and 68 deletions

View File

@ -33,8 +33,8 @@
#define PIECE_NONE 0
#define PIECE_MIXED 1
#define PIECE_FINISHED 2
#define PIECE_HIGH_PEERS 3
#define PIECE_HIGH_PEERS 2
#define PIECE_FINISHED 3
#define PIECE_FLASHING 4
@implementation PiecesView
@ -145,84 +145,46 @@
}
NSColor * pieceColor = nil;
if (showAvailablity)
if (showAvailablity ? pieces[index] == -1 : piecesPercent[index] == 1.0)
{
if (pieces[index] == -1)
if (first || fPieces[index] != PIECE_FINISHED)
{
if (first || fPieces[index] != PIECE_FINISHED)
if (!first && fPieces[index] != PIECE_FLASHING)
{
if (!first && fPieces[index] != PIECE_FLASHING)
{
pieceColor = [NSColor orangeColor];
fPieces[index] = PIECE_FLASHING;
}
else
{
pieceColor = fBluePieceColor;
fPieces[index] = PIECE_FINISHED;
}
pieceColor = [NSColor orangeColor];
fPieces[index] = PIECE_FLASHING;
}
else
{
pieceColor = fBluePieceColor;
fPieces[index] = PIECE_FINISHED;
}
}
else if (pieces[index] == 0)
}
else if (showAvailablity ? pieces[index] == 0 : piecesPercent[index] == 0.0)
{
if (first || fPieces[index] != PIECE_NONE)
{
if (first || fPieces[index] != PIECE_NONE)
{
pieceColor = [NSColor whiteColor];
fPieces[index] = PIECE_NONE;
}
pieceColor = [NSColor whiteColor];
fPieces[index] = PIECE_NONE;
}
else if (pieces[index] >= HIGH_PEERS)
}
else if (showAvailablity && pieces[index] >= HIGH_PEERS)
{
if (first || fPieces[index] != PIECE_HIGH_PEERS)
{
if (first || fPieces[index] != PIECE_HIGH_PEERS)
{
pieceColor = fGreenAvailabilityColor;
fPieces[index] = PIECE_HIGH_PEERS;
}
}
else
{
if (first || fPieces[index] != PIECE_MIXED)
{
float percent = (float)pieces[index]/HIGH_PEERS;
pieceColor = [[NSColor whiteColor] blendedColorWithFraction: percent ofColor: fGreenAvailabilityColor];
fPieces[index] = PIECE_MIXED;
}
pieceColor = fGreenAvailabilityColor;
fPieces[index] = PIECE_HIGH_PEERS;
}
}
else
{
if (piecesPercent[index] == 1.0)
{
if (first || fPieces[index] != PIECE_FINISHED)
{
if (!first && fPieces[index] != PIECE_FLASHING)
{
pieceColor = [NSColor orangeColor];
fPieces[index] = PIECE_FLASHING;
}
else
{
pieceColor = fBluePieceColor;
fPieces[index] = PIECE_FINISHED;
}
}
}
else if (piecesPercent[index] == 0.0)
{
if (first || fPieces[index] != PIECE_NONE)
{
pieceColor = [NSColor whiteColor];
fPieces[index] = PIECE_NONE;
}
}
else
{
if (first || fPieces[index] != PIECE_MIXED)
{
pieceColor = [[NSColor whiteColor] blendedColorWithFraction: piecesPercent[index] ofColor: fBluePieceColor];
fPieces[index] = PIECE_MIXED;
}
}
//always redraw "mixed"
float percent = showAvailablity ? (float)pieces[index]/HIGH_PEERS : piecesPercent[index];
NSColor * fullColor = showAvailablity ? fGreenAvailabilityColor : fBluePieceColor;
pieceColor = [[NSColor whiteColor] blendedColorWithFraction: percent ofColor: fullColor];
fPieces[index] = PIECE_MIXED;
}
if (pieceColor)