replace a loop with math
This commit is contained in:
parent
456adc3558
commit
fab1ffb8a2
|
@ -3864,46 +3864,25 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
searchFrame.origin.x += searchFrame.size.width - SEARCH_FILTER_MIN_WIDTH;
|
searchFrame.origin.x += searchFrame.size.width - SEARCH_FILTER_MIN_WIDTH;
|
||||||
searchFrame.size.width = SEARCH_FILTER_MIN_WIDTH;
|
searchFrame.size.width = SEARCH_FILTER_MIN_WIDTH;
|
||||||
|
|
||||||
//resize each button until they don't overlap search
|
//resize the buttons so they don't overlay
|
||||||
int download = 0;
|
int difference = (NSMaxX(pauseRect) + 5.0) - searchFrame.origin.x;
|
||||||
BOOL seeding = NO, paused = NO;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (download < 8)
|
|
||||||
{
|
|
||||||
download++;
|
|
||||||
downloadRect.size.width--;
|
|
||||||
|
|
||||||
seedRect.origin.x--;
|
//decrease downloading by 8, seeding by 1, paused by 1, active by 1, repeat
|
||||||
pauseRect.origin.x--;
|
int download = (difference / 11 * 8) + MIN(difference % 11 + 1, 8); //8 for every 11
|
||||||
}
|
int seed = (difference / 11) + (difference % 11 >= 8 ? 1 : 0);
|
||||||
else if (!seeding)
|
int paused = (difference / 11) + (difference % 11 >= 9 ? 1 : 0);
|
||||||
{
|
int active = (difference / 11) + (difference % 11 >= 10 ? 1 : 0);
|
||||||
seeding = YES;
|
|
||||||
seedRect.size.width--;
|
|
||||||
|
|
||||||
pauseRect.origin.x--;
|
activeRect.size.width -= active;
|
||||||
}
|
|
||||||
else if (!paused)
|
|
||||||
{
|
|
||||||
paused = YES;
|
|
||||||
pauseRect.size.width--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
activeRect.size.width--;
|
|
||||||
|
|
||||||
downloadRect.origin.x--;
|
downloadRect.size.width -= download;
|
||||||
seedRect.origin.x--;
|
downloadRect.origin.x -= active;
|
||||||
pauseRect.origin.x--;
|
|
||||||
|
|
||||||
//reset
|
seedRect.size.width -= seed;
|
||||||
download = 0;
|
seedRect.origin.x -= active + download;
|
||||||
seeding = NO;
|
|
||||||
paused = NO;
|
pauseRect.size.width -= paused;
|
||||||
}
|
pauseRect.origin.x -= active + download + seed;
|
||||||
}
|
|
||||||
while (NSMaxX(pauseRect) + 5.0 > searchFrame.origin.x);
|
|
||||||
}
|
}
|
||||||
else;
|
else;
|
||||||
|
|
||||||
|
|
|
@ -1651,17 +1651,14 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
||||||
- (void) createFileList
|
- (void) createFileList
|
||||||
{
|
{
|
||||||
int count = [self fileCount], i;
|
int count = [self fileCount], i;
|
||||||
tr_file * file;
|
|
||||||
NSMutableArray * pathComponents;
|
|
||||||
NSString * path;
|
|
||||||
|
|
||||||
NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
|
NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
file = &fInfo->files[i];
|
tr_file * file = &fInfo->files[i];
|
||||||
|
|
||||||
pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
|
NSMutableArray * pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
|
||||||
|
NSString * path;
|
||||||
if ([self folder])
|
if ([self folder])
|
||||||
{
|
{
|
||||||
path = [pathComponents objectAtIndex: 0];
|
path = [pathComponents objectAtIndex: 0];
|
||||||
|
|
Loading…
Reference in New Issue