1222- (void) drawEquipmentList:(NSArray *)eqptList z:(GLfloat)z
1224 if ([eqptList
count] == 0)
return;
1228 if ([[
PLAYER hud] allowBigGui])
1232 NSUInteger itemsPerColumn = maxRows;
1235 NSInteger firstY = 40;
1236 NSUInteger eqptCount = [
eqptList count];
1237 NSUInteger pageCount = 1;
1240 NSArray *info =
nil;
1241 NSString *name =
nil;
1247 i = itemsPerColumn * 2 + 2;
1250 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1252 i = itemsPerColumn * 4;
1257 if (statusPage == 1)
1264 start = i/statusPage;
1269 pageCount = ceil((
float)(eqptCount-i)/(itemsPerColumn*2)) + 2;
1270 statusPage = (NSInteger)
OOClampInteger(statusPage, 1, pageCount);
1271 start = (statusPage == 1) ? 0 : (statusPage-1) * itemsPerColumn * 2 + 2;
1276 statusPage = pageCount;
1287 [
self setText:@""
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1288 [
self setKey:GUI_KEY_SKIP
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1291 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
1301 if (statusPage == pageCount)
1307 if (statusPage < pageCount)
1310 [
self setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ",nil]
forRow:firstRow + maxRows];
1312 if (statusPage == 1)
1318 if (statusPage > 1 && statusPage < pageCount)
1320 [
self setSelectableRange:NSMakeRange(firstRow, MIN(firstRow + maxRows, GUI_DEFAULT_ROWS - firstRow))];
1322 if ([
self selectedRow] == -1) [
self setSelectedRow:firstRow + maxRows];
1325 if (statusPage == 1 || statusPage == pageCount) itemsPerColumn++;
1326 eqptCount = (NSInteger)
OOClampInteger(eqptCount, 1, start + itemsPerColumn * 2);
1327 for (i = start; i < eqptCount; i++)
1329 info = [
eqptList oo_arrayAtIndex:i];
1330 name = [
info oo_stringAtIndex:0];
1331 if([name length] > 42) name = [[
name substringToIndex:40] stringByAppendingString:@"..."];
1333 damaged = ![
info oo_boolAtIndex:1];
1346 if (i - start < itemsPerColumn)
1348 OODrawString(name, -220, firstY - 16 * (NSInteger)(i - start), z, NSMakeSize(15, 15));
1352 OODrawString(name, 50, firstY - 16 * (NSInteger)(i - itemsPerColumn - start), z, NSMakeSize(15, 15));
1471- (void) drawGLDisplay:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha
1476 NSSize characterSize = pixel_text_size;
1477 NSSize titleCharacterSize = pixel_title_size;
1478 float backgroundAlpha =
self == [UNIVERSE messageGUI] && ![UNIVERSE permanentMessageLog] ? 0.0f : alpha;
1484 for (i = 0; i < n_rows; i++)
1486 row_alpha[
i] = alpha;
1488 if(![
UNIVERSE autoMessageLogBg] && [
PLAYER guiScreen] == GUI_SCREEN_MAIN) backgroundAlpha = alpha;
1490 if (rowFadeTime[i] > 0.0f && ![
UNIVERSE permanentMessageLog])
1492 rowFadeTime[
i] -= (float)delta_t;
1493 if (rowFadeTime[i] <= 0.0f)
1495 [
rowText replaceObjectAtIndex:i withObject:@""];
1496 rowFadeTime[
i] = 0.0f;
1499 if ((rowFadeTime[i] > 0.0f)&&(rowFadeTime[i] < 1.0))
1501 row_alpha[
i] *= rowFadeTime[
i];
1502 if (backgroundAlpha < row_alpha[i]) backgroundAlpha = row_alpha[
i];
1506 backgroundAlpha = alpha;
1514 if (backgroundColor)
1516 int playerStatus = [PLAYER status];
1517 if (playerStatus != STATUS_START_GAME && playerStatus != STATUS_DEAD)
1519 OOGL(glColor4f([backgroundColor redComponent], [backgroundColor greenComponent], [backgroundColor blueComponent], backgroundAlpha * [backgroundColor alphaComponent]));
1521 glVertex3f(
x + 0.0f,
y + 0.0f, z);
1522 glVertex3f(
x + size_in_pixels.width,
y + 0.0f, z);
1523 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height, z);
1524 glVertex3f(
x + 0.0f,
y + size_in_pixels.height, z);
1531 if (foregroundSprite !=
nil)
1533 [
foregroundSprite blitCentredToX:x + 0.5f * size_in_pixels.width Y:y + 0.5f * size_in_pixels.height Z:z alpha:alpha];
1536 if (!
RowInRange(selectedRow, selectableRange))
1550 OODrawString(title,
x + pixel_row_center - strsize.width/2.0,
y + size_in_pixels.height - pixel_title_size.height, z, titleCharacterSize);
1557 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1558 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1559 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1560 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1567 for (i = 0; i < n_rows; i++)
1570 glColor4f([row_color redComponent], [row_color greenComponent], [row_color blueComponent], row_alpha[i]);
1572 if ([[rowText objectAtIndex:i] isKindOfClass:[NSString
class]])
1574 NSString* text = (NSString *)[rowText objectAtIndex:i];
1575 if (![text isEqual:
@""])
1578 switch (rowAlignment[i])
1581 rowPosition[
i].x = 0.0f;
1584 rowPosition[
i].x = size_in_pixels.width - strsize.width;
1587 rowPosition[
i].x = (size_in_pixels.width - strsize.width)/2.0f;
1590 if (i == (
unsigned)selectedRow)
1592 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1596 glVertex3f(block.origin.x, block.origin.y, z);
1597 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1598 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1599 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1608 if ((showTextCursor)&&(i == (
unsigned)currentRow))
1611 NSPoint cu = NSMakePoint(
x + rowPosition[i].
x + tr.size.width + 0.2f * characterSize.width,
y + rowPosition[i].y);
1613 tr.size.width = 0.5f * characterSize.width;
1614 GLfloat g_alpha = 0.5f * (1.0f + (float)sin(6 * [
UNIVERSE getTime]));
1618 glVertex3f(tr.origin.x, tr.origin.y, z);
1619 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y, z);
1620 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y + tr.size.height, z);
1621 glVertex3f(tr.origin.x, tr.origin.y + tr.size.height, z);
1627 if ([[rowText objectAtIndex:i] isKindOfClass:[NSArray
class]])
1629 NSArray *array = [
rowText oo_arrayAtIndex:i];
1630 NSUInteger j, max_columns =
MIN([array
count], n_columns);
1633 for (j = 0; j < max_columns; j++)
1635 NSString* text = [
array oo_stringAtIndex:j];
1636 if ([text length] != 0)
1638 isLeftAligned = tabStops[
j] >= 0;
1639 rowPosition[
i].x = labs(tabStops[j]);
1642 NSString *hilitedText = [
text stringByTrimmingCharactersInSet:[
NSCharacterSet characterSetWithCharactersInString:@" \037"]];
1643 NSRange txtRange = [
text rangeOfString:hilitedText];
1644 unsigned leadingSpaces = 0;
1646 if (
EXPECT_NOT(txtRange.location == NSNotFound))
1651 else if (txtRange.location > 0)
1655 padRange.location = 0;
1656 padRange.length = txtRange.location;
1657 NSRect charBlock =
OORectFromString([text substringWithRange:padRange], 0, 0, characterSize);
1658 leadingSpaces = (unsigned)charBlock.size.width;
1671 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1675 rowPosition[
i].x -= block.size.width + 3;
1677 block =
OORectFromString(hilitedText,
x + rowPosition[i].
x + 1 + leadingSpaces,
y + rowPosition[i].
y + 2, characterSize);
1678 block.size.width += 3;
1681 if (i == (
unsigned)selectedRow)
1686 glVertex3f(block.origin.x, block.origin.y, z);
1687 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1688 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1689 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1745- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOOL)compact
1761 GLfloat r = 1.0, g = 1.0, b = 1.0;
1764 NSUInteger systemParameter;
1768 double hcenter = size_in_pixels.width/2.0;
1772 double hoffset = hcenter - chart_centre_coordinates.x*hscale;
1773 double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y*vscale;
1777 hscale = size_in_pixels.width / 256.0;
1778 vscale = -1.0 * size_in_pixels.height / 512.0;
1780 voffset = size_in_pixels.height - pixel_title_size.height - 5;
1782 chart_centre_coordinates.x = 128.0;
1783 chart_centre_coordinates.y = 128.0;
1788 double d, distance = 0.0, time = 0.0;
1795 BOOL routeExists = NO;
1797 NSInteger concealment[256];
1798 for (i=0;i<256;i++) {
1800 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
1803 BOOL *systemsFound = [UNIVERSE systemsFound];
1804 NSSize viewSize = [[UNIVERSE gameView] backingViewSize];
1805 double aspect_ratio = viewSize.width / viewSize.height;
1808 GLfloat govcol[] = { 0.5, 0.0, 0.7,
1817 if (aspect_ratio > 4.0/3.0)
1819 pixelRatio = viewSize.height / 480.0;
1823 pixelRatio = viewSize.width / 640.0;
1828 clipRect = NSMakeRect((viewSize.width - size_in_pixels.width*pixelRatio)/2.0,
1829 (viewSize.height + size_in_pixels.height*pixelRatio)/2.0 - (pixel_title_size.height + 15 + (textRow-2)*
MAIN_GUI_ROW_HEIGHT) * pixelRatio,
1830 size_in_pixels.width * pixelRatio,
1840 cu = NSMakePoint((
float)(hscale*galaxy_coordinates.x+hoffset),(
float)(vscale*galaxy_coordinates.y+voffset));
1843 OOGL(glEnable(GL_SCISSOR_TEST));
1844 OOGL(glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height));
1850 static struct saved_system
1856 } nearby_systems[ 256 ];
1857 static int num_nearby_systems = 0;
1863 for (i = 0; i < num_nearby_systems; i++)
1864 [nearby_systems[ i ].p_name release];
1866 num_nearby_systems = 0;
1867 for (i = 0; i < 256; i++)
1870 NSDictionary* sys_info = [UNIVERSE generateSystemData:i];
1871 if (
EXPECT_NOT([sys_info oo_boolForKey:
@"sun_gone_nova"]))
1883 nearby_systems[
num_nearby_systems ].nova = [[UNIVERSE generateSystemData:i] oo_boolForKey:@"sun_gone_nova"];
1884 num_nearby_systems++;
1892 static NSDictionary *routeInfo =
nil;
1908 if (advancedNavArrayMode !=
OPTIMIZED_BY_NONE && [player hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
1911 OOSystemID destNumber = [PLAYER targetSystemID];
1912 if (routeInfo ==
nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber || advancedNavArrayMode != savedArrayMode)
1915 routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
1916 savedPlanetNumber = planetNumber;
1917 savedDestNumber = destNumber;
1918 savedArrayMode = advancedNavArrayMode;
1920 target = destNumber;
1926 if (routeInfo) routeExists = YES;
1932 distance = [
routeInfo oo_doubleForKey:@"distance"];
1933 time = [
routeInfo oo_doubleForKey:@"time"];
1934 jumps = [
routeInfo oo_intForKey:@"jumps"];
1936 if (distance == 0.0 && planetNumber != destNumber)
1953 if (distance == 0.0)
1955 if (target != [
PLAYER systemID])
1962 if ([player hasHyperspaceMotor] && distance <= [player fuel]/10.0)
1964 time = distance * distance;
1972 if ([player hasHyperspaceMotor])
1978 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel*hscale), 2*(
float)(fuel*vscale)), 5);
1992 cu = NSMakePoint((
float)(hscale*cursor_coordinates.x+hoffset),(
float)(vscale*cursor_coordinates.y+voffset));
1998 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
2000 for (i = 0; i < num_nearby_systems; i++)
2004 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2005 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2017 float blob_factor = [
guiUserSettings oo_floatForKey:kGuiChartCircleScale defaultValue:0.0017];
2018 float blob_size = (1.0f + blob_factor * [
systemInfo oo_floatForKey:@"radius"])/zoom;
2019 if (blob_size < 0.5) blob_size = 0.5;
2021 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2022 star.y = (float)(sys_coordinates.y * vscale + voffset);
2024 noNova = !nearby_systems[
i].nova;
2025 NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL,
@"Long range chart mode %i out of range", (
int)chart_mode);
2030 GLfloat base_size = 0.5f * blob_size + 2.5f;
2037 OOGL(glColor4f(r, g, b, alpha));
2041 case OOLRC_MODE_ECONOMY:
2044 systemParameter = nearby_systems[
i].eco;
2045 GLfloat ce1 = 1.0f - 0.125f * systemParameter;
2053 OOGL(glColor4f(r, g, b, alpha));
2056 case OOLRC_MODE_GOVERNMENT:
2059 systemParameter = nearby_systems[
i].gov;
2067 OOGL(glColor4f(r, g, b, alpha));
2070 case OOLRC_MODE_TECHLEVEL:
2073 systemParameter = nearby_systems[
i].tec;
2075 g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
2081 OOGL(glColor4f(r, g, b, alpha));
2083 case OOLRC_MODE_UNKNOWN:
2084 case OOLRC_MODE_SUNCOLOR:
2089 if (sunColor !=
nil) {
2100 OOGL(glColor4f(r, g, b, alpha));
2110 GLfloat systemNameScale = [
guiUserSettings oo_floatForKey:kGuiChartLabelScale defaultValue:1.0];
2115 int n_matches = 0, foundIndex = -1;
2117 for (i = 0; i < 256; i++)
if (systemsFound[i])
2119 if(foundSystem == n_matches) foundIndex = i;
2133 for (i = 0; i < 256; i++)
2140 BOOL mark = systemsFound[
i];
2141 float marker_size = 8.0/zoom;
2144 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2145 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2149 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2150 star.y = (float)(sys_coordinates.y * vscale + voffset);
2152 glVertex3f(
x + star.x - marker_size,
y + star.y - marker_size, z);
2153 glVertex3f(
x + star.x + marker_size,
y + star.y - marker_size, z);
2154 glVertex3f(
x + star.x + marker_size,
y + star.y + marker_size, z);
2155 glVertex3f(
x + star.x - marker_size,
y + star.y + marker_size, z);
2157 if (i == foundIndex || n_matches == 1)
2159 if (n_matches == 1) foundSystem = 0;
2163 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2169 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2180 struct saved_system *sys;
2181 NSSize chSize = NSMakeSize(pixel_row_height*systemNameScale/zoom,pixel_row_height*systemNameScale/zoom);
2184 for (i = 0; i < num_nearby_systems; i++)
2191 sys = nearby_systems + i;
2194 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2195 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2199 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2200 star.y = (float)(sys_coordinates.y * vscale + voffset);
2201 if (sys->sysid == target)
2210 if (![player showInfoFlag])
2224 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
2226 else if (
EXPECT(sys->gov >= 0))
2235 OODrawPlanetInfo(sys->gov, sys->eco, sys->tec,
x + star.x + 2.0,
y + star.y + 2.0, z, chSize);
2247 sys = nearby_systems + targetIdx;
2250 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2251 star.y = (float)(sys_coordinates.y * vscale + voffset);
2253 if (![player showInfoFlag])
2268 else if (sys->gov >= 0)
2289 NSString *targetName = [[UNIVERSE getSystemName:target] retain];
2292 NSString *travelDistLine =
@"";
2295 travelDistLine =
OOExpandKey(
@"long-range-chart-distance", distance);
2297 NSString *travelTimeLine =
@"";
2300 travelTimeLine =
OOExpandKey(
@"long-range-chart-est-travel-time", time);
2305 [
self setArray:[
NSArray arrayWithObjects:targetName, travelDistLine,travelTimeLine,nil]
forRow:textRow];
2311 if ([
PLAYER guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART)
2315 [
self setArray:[
NSArray arrayWithObjects: @"", OOExpandKey(@"short-range-chart-jumps", jumps), nil]
forRow: textRow + 1];
2327 cu = NSMakePoint((
float)(hscale*info_system_coordinates.x+hoffset),(
float)(vscale*info_system_coordinates.y+voffset));
2328 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize(6.0f/zoom+2.0f, 6.0f/zoom+2.0f), 5);
2331 OOGL(glDisable(GL_SCISSOR_TEST));
2336 glVertex3f(
x + 0, (
float)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2337 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2338 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2339 glVertex3f(
x + 0, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2468- (void) drawAdvancedNavArrayAtX:(
float)x y:(
float)y z:(
float)z alpha:(
float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(
OORouteType) optimizeBy zoom: (
OOScalar) zoom
2470 GLfloat lr,lg,lb,la,lr2,lg2,lb2,la2;
2473 NSPoint star = NSZeroPoint,
2474 star2 = NSZeroPoint,
2475 starabs = NSZeroPoint,
2476 star2abs = NSZeroPoint;
2490 NSInteger concealment[256];
2491 for (NSUInteger i=0;i<256;i++) {
2493 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
2514 star.x = (float)(starabs.x * hscale);
2515 star.y = (float)(starabs.y * vscale);
2538 star2.x = (float)(star2abs.x * hscale);
2539 star2.y = (float)(star2abs.y * vscale);
2544 OOGL(glColor4f(lr, lg, lb, la*alpha));
2545 glVertex3f(
x+star.x,
y+star.y, z);
2547 float frac = (d/jumpRange);
2549 OOLerp(lr,lr2,frac),
2550 OOLerp(lg,lg2,frac),
2551 OOLerp(lb,lb2,frac),
2554 glVertex3f(
x+star2.x,
y+star2.y, z);
2561 if (thisConnectionColor ==
nil)
2563 thisConnectionColor = defaultConnectionColor;
2566 OOGL(glColor4f(lr, lg, lb, la*alpha));
2568 glVertex3f(
x+star.x,
y+star.y, z);
2573 if (thatConnectionColor ==
nil)
2575 thatConnectionColor = thisConnectionColor;
2578 OOGL(glColor4f(lr, lg, lb, la*alpha));
2580 glVertex3f(
x+star2.x,
y+star2.y, z);
2594 NSUInteger i, route_hops = [[
routeInfo oo_arrayForKey:@"route"] count] - 1;
2607 for (i = 0; i < route_hops; i++)
2609 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];
2613 star.x = (float)(starabs.x * hscale);
2614 star.y = (float)(starabs.y * vscale);
2616 star2.x = (float)(star2abs.x * hscale);
2617 star2.y = (float)(star2abs.y * vscale);
2621 glVertex3f(
x+star.x,
y+star.y, z);
2622 glVertex3f(
x+star2.x,
y+star2.y, z);
2634 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];