Changeset 9318


Ignore:
Timestamp:
Oct 18, 2009, 2:12:43 AM (12 years ago)
Author:
livings124
Message:

trivial adjustments to pieceview: use an enum instead of #defines; calculate the current piece index being drawn within each pass of the loop instead of incrementing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PiecesView.m

    r9317 r9318  
    3333#define HIGH_PEERS 30
    3434
    35 #define PIECE_NONE 0
    36 #define PIECE_SOME 1
    37 #define PIECE_HIGH_PEERS 2
    38 #define PIECE_FINISHED 3
    39 #define PIECE_FLASHING 4
     35enum
     36{
     37    PIECE_NONE,
     38    PIECE_SOME,
     39    PIECE_HIGH_PEERS,
     40    PIECE_FINISHED,
     41    PIECE_FLASHING
     42};
    4043
    4144@implementation PiecesView
     
    7275        fAcross = ceil(sqrt(fNumPieces));
    7376       
    74         CGFloat width = [self bounds].size.width;
     77        const CGFloat width = [self bounds].size.width;
    7578        fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
    7679        fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
     
    128131    NSColor * fillColors[fNumPieces];
    129132   
    130     NSInteger index = -1, usedCount = 0;
     133    NSInteger usedCount = 0;
    131134   
    132135    for (NSInteger i = 0; i < fAcross; i++)
    133136        for (NSInteger j = 0; j < fAcross; j++)
    134137        {
    135             index++;
     138            const NSInteger index = i * fAcross + j;
    136139            if (index >= fNumPieces)
    137140            {
Note: See TracChangeset for help on using the changeset viewer.