1235- (void) drawEquipmentList:(NSArray *)eqptList z:(GLfloat)z
1237 if ([eqptList
count] == 0)
return;
1241 if ([[
PLAYER hud] allowBigGui])
1245 NSUInteger itemsPerColumn = maxRows;
1248 NSInteger firstY = 40;
1249 NSUInteger eqptCount = [
eqptList count];
1250 NSUInteger pageCount = 1;
1253 NSArray *info =
nil;
1254 NSString *name =
nil;
1260 i = itemsPerColumn * 2 + 2;
1263 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1265 i = itemsPerColumn * 4;
1270 if (statusPage == 1)
1277 start = i/statusPage;
1282 pageCount = ceil((
float)(eqptCount-i)/(itemsPerColumn*2)) + 2;
1283 statusPage = (NSInteger)
OOClampInteger(statusPage, 1, pageCount);
1284 start = (statusPage == 1) ? 0 : (statusPage-1) * itemsPerColumn * 2 + 2;
1289 statusPage = pageCount;
1300 [
self setText:@""
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1301 [
self setKey:GUI_KEY_SKIP
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1304 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
1314 if (statusPage == pageCount)
1320 if (statusPage < pageCount)
1323 [
self setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ",nil]
forRow:firstRow + maxRows];
1325 if (statusPage == 1)
1331 if (statusPage > 1 && statusPage < pageCount)
1333 [
self setSelectableRange:NSMakeRange(firstRow, MIN(firstRow + maxRows, GUI_DEFAULT_ROWS - firstRow))];
1335 if ([
self selectedRow] == -1) [
self setSelectedRow:firstRow + maxRows];
1338 if (statusPage == 1 || statusPage == pageCount) itemsPerColumn++;
1339 eqptCount = (NSInteger)
OOClampInteger(eqptCount, 1, start + itemsPerColumn * 2);
1340 for (i = start; i < eqptCount; i++)
1342 info = [
eqptList oo_arrayAtIndex:i];
1343 name = [
info oo_stringAtIndex:0];
1344 if([name length] > 42) name = [[
name substringToIndex:40] stringByAppendingString:@"..."];
1346 damaged = ![
info oo_boolAtIndex:1];
1359 if (i - start < itemsPerColumn)
1361 OODrawString(name, -220, firstY - 16 * (NSInteger)(i - start), z, NSMakeSize(15, 15));
1365 OODrawString(name, 50, firstY - 16 * (NSInteger)(i - itemsPerColumn - start), z, NSMakeSize(15, 15));
1484- (void) drawGLDisplay:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha
1489 NSSize characterSize = pixel_text_size;
1490 NSSize titleCharacterSize = pixel_title_size;
1491 float backgroundAlpha =
self == [UNIVERSE messageGUI] && ![UNIVERSE permanentMessageLog] ? 0.0f : alpha;
1497 for (i = 0; i < n_rows; i++)
1499 row_alpha[
i] = alpha;
1501 if(![
UNIVERSE autoMessageLogBg] && [
PLAYER guiScreen] == GUI_SCREEN_MAIN) backgroundAlpha = alpha;
1503 if (rowFadeTime[i] > 0.0f && ![
UNIVERSE permanentMessageLog])
1505 rowFadeTime[
i] -= (float)delta_t;
1506 if (rowFadeTime[i] <= 0.0f)
1508 [
rowText replaceObjectAtIndex:i withObject:@""];
1509 rowFadeTime[
i] = 0.0f;
1512 if ((rowFadeTime[i] > 0.0f)&&(rowFadeTime[i] < 1.0))
1514 row_alpha[
i] *= rowFadeTime[
i];
1515 if (backgroundAlpha < row_alpha[i]) backgroundAlpha = row_alpha[
i];
1519 backgroundAlpha = alpha;
1527 if (backgroundColor)
1529 int playerStatus = [PLAYER status];
1530 if (playerStatus != STATUS_START_GAME && playerStatus != STATUS_DEAD)
1532 OOGL(glColor4f([backgroundColor redComponent], [backgroundColor greenComponent], [backgroundColor blueComponent], backgroundAlpha * [backgroundColor alphaComponent]));
1534 glVertex3f(
x + 0.0f,
y + 0.0f, z);
1535 glVertex3f(
x + size_in_pixels.width,
y + 0.0f, z);
1536 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height, z);
1537 glVertex3f(
x + 0.0f,
y + size_in_pixels.height, z);
1544 if (foregroundSprite !=
nil)
1546 [
foregroundSprite blitCentredToX:x + 0.5f * size_in_pixels.width Y:y + 0.5f * size_in_pixels.height Z:z alpha:alpha];
1549 if (!
RowInRange(selectedRow, selectableRange))
1563 OODrawString(title,
x + pixel_row_center - strsize.width/2.0,
y + size_in_pixels.height - pixel_title_size.height, z, titleCharacterSize);
1570 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1571 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1572 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1573 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1580 for (i = 0; i < n_rows; i++)
1583 glColor4f([row_color redComponent], [row_color greenComponent], [row_color blueComponent], row_alpha[i]);
1585 if ([[rowText objectAtIndex:i] isKindOfClass:[NSString
class]])
1587 NSString* text = (NSString *)[rowText objectAtIndex:i];
1588 if (![text isEqual:
@""])
1591 switch (rowAlignment[i])
1594 rowPosition[
i].x = 0.0f;
1597 rowPosition[
i].x = size_in_pixels.width - strsize.width;
1600 rowPosition[
i].x = (size_in_pixels.width - strsize.width)/2.0f;
1603 if (i == (
unsigned)selectedRow)
1605 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1609 glVertex3f(block.origin.x, block.origin.y, z);
1610 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1611 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1612 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1621 if ((showTextCursor)&&(i == (
unsigned)currentRow))
1624 NSPoint cu = NSMakePoint(
x + rowPosition[i].
x + tr.size.width + 0.2f * characterSize.width,
y + rowPosition[i].y);
1626 tr.size.width = 0.5f * characterSize.width;
1627 GLfloat g_alpha = 0.5f * (1.0f + (float)sin(6 * [
UNIVERSE getTime]));
1631 glVertex3f(tr.origin.x, tr.origin.y, z);
1632 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y, z);
1633 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y + tr.size.height, z);
1634 glVertex3f(tr.origin.x, tr.origin.y + tr.size.height, z);
1640 if ([[rowText objectAtIndex:i] isKindOfClass:[NSArray
class]])
1642 NSArray *array = [
rowText oo_arrayAtIndex:i];
1643 NSUInteger j, max_columns =
MIN([array
count], n_columns);
1646 for (j = 0; j < max_columns; j++)
1648 NSString* text = [
array oo_stringAtIndex:j];
1649 if ([text length] != 0)
1651 isLeftAligned = tabStops[
j] >= 0;
1652 rowPosition[
i].x = llabs(tabStops[j]);
1655 NSString *hilitedText = [
text stringByTrimmingCharactersInSet:[
NSCharacterSet characterSetWithCharactersInString:@" \037"]];
1656 NSRange txtRange = [
text rangeOfString:hilitedText];
1657 unsigned leadingSpaces = 0;
1659 if (
EXPECT_NOT(txtRange.location == NSNotFound))
1664 else if (txtRange.location > 0)
1668 padRange.location = 0;
1669 padRange.length = txtRange.location;
1670 NSRect charBlock =
OORectFromString([text substringWithRange:padRange], 0, 0, characterSize);
1671 leadingSpaces = (unsigned)charBlock.size.width;
1684 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1688 rowPosition[
i].x -= block.size.width + 3;
1690 block =
OORectFromString(hilitedText,
x + rowPosition[i].
x + 1 + leadingSpaces,
y + rowPosition[i].
y + 2, characterSize);
1691 block.size.width += 3;
1694 if (i == (
unsigned)selectedRow)
1699 glVertex3f(block.origin.x, block.origin.y, z);
1700 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1701 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1702 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1758- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOOL)compact
1774 GLfloat r = 1.0, g = 1.0, b = 1.0;
1777 NSUInteger systemParameter;
1781 double hcenter = size_in_pixels.width/2.0;
1785 double hoffset = hcenter - chart_centre_coordinates.x*hscale;
1786 double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y*vscale;
1790 hscale = size_in_pixels.width / 256.0;
1791 vscale = -1.0 * size_in_pixels.height / 512.0;
1793 voffset = size_in_pixels.height - pixel_title_size.height - 5;
1795 chart_centre_coordinates.x = 128.0;
1796 chart_centre_coordinates.y = 128.0;
1801 double d, distance = 0.0, time = 0.0;
1808 BOOL routeExists = NO;
1810 NSInteger concealment[256];
1811 for (i=0;i<256;i++) {
1813 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
1816 BOOL *systemsFound = [UNIVERSE systemsFound];
1817 NSSize viewSize = [[UNIVERSE gameView] backingViewSize];
1818 double aspect_ratio = viewSize.width / viewSize.height;
1821 GLfloat govcol[] = { 0.5, 0.0, 0.7,
1830 if (aspect_ratio > 4.0/3.0)
1832 pixelRatio = viewSize.height / 480.0;
1836 pixelRatio = viewSize.width / 640.0;
1841 clipRect = NSMakeRect((viewSize.width - size_in_pixels.width*pixelRatio)/2.0,
1842 (viewSize.height + size_in_pixels.height*pixelRatio)/2.0 - (pixel_title_size.height + 15 + (textRow-2)*
MAIN_GUI_ROW_HEIGHT) * pixelRatio,
1843 size_in_pixels.width * pixelRatio,
1853 cu = NSMakePoint((
float)(hscale*galaxy_coordinates.x+hoffset),(
float)(vscale*galaxy_coordinates.y+voffset));
1856 OOGL(glEnable(GL_SCISSOR_TEST));
1857 OOGL(glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height));
1863 static struct saved_system
1869 } nearby_systems[ 256 ];
1870 static int num_nearby_systems = 0;
1876 for (i = 0; i < num_nearby_systems; i++)
1877 [nearby_systems[ i ].p_name release];
1879 num_nearby_systems = 0;
1880 for (i = 0; i < 256; i++)
1883 NSDictionary* sys_info = [UNIVERSE generateSystemData:i];
1884 if (
EXPECT_NOT([sys_info oo_boolForKey:
@"sun_gone_nova"]))
1896 nearby_systems[
num_nearby_systems ].nova = [[UNIVERSE generateSystemData:i] oo_boolForKey:@"sun_gone_nova"];
1897 num_nearby_systems++;
1905 static NSDictionary *routeInfo =
nil;
1921 if (advancedNavArrayMode !=
OPTIMIZED_BY_NONE && [player hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
1924 OOSystemID destNumber = [PLAYER targetSystemID];
1925 if (routeInfo ==
nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber || advancedNavArrayMode != savedArrayMode)
1928 routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
1929 savedPlanetNumber = planetNumber;
1930 savedDestNumber = destNumber;
1931 savedArrayMode = advancedNavArrayMode;
1933 target = destNumber;
1939 if (routeInfo) routeExists = YES;
1945 distance = [
routeInfo oo_doubleForKey:@"distance"];
1946 time = [
routeInfo oo_doubleForKey:@"time"];
1947 jumps = [
routeInfo oo_intForKey:@"jumps"];
1949 if (distance == 0.0 && planetNumber != destNumber)
1966 if (distance == 0.0)
1968 if (target != [
PLAYER systemID])
1975 if ([player hasHyperspaceMotor] && distance <= [player fuel]/10.0)
1977 time = distance * distance;
1985 if ([player hasHyperspaceMotor])
1991 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel*hscale), 2*(
float)(fuel*vscale)), 5);
2005 cu = NSMakePoint((
float)(hscale*cursor_coordinates.x+hoffset),(
float)(vscale*cursor_coordinates.y+voffset));
2011 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
2013 for (i = 0; i < num_nearby_systems; i++)
2017 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2018 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2030 float blob_factor = [
guiUserSettings oo_floatForKey:kGuiChartCircleScale defaultValue:0.0017];
2031 float blob_size = (1.0f + blob_factor * [
systemInfo oo_floatForKey:@"radius"])/zoom;
2032 if (blob_size < 0.5) blob_size = 0.5;
2034 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2035 star.y = (float)(sys_coordinates.y * vscale + voffset);
2037 noNova = !nearby_systems[
i].nova;
2038 NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL,
@"Long range chart mode %i out of range", (
int)chart_mode);
2043 GLfloat base_size = 0.5f * blob_size + 2.5f;
2050 OOGL(glColor4f(r, g, b, alpha));
2054 case OOLRC_MODE_ECONOMY:
2057 systemParameter = nearby_systems[
i].eco;
2058 GLfloat ce1 = 1.0f - 0.125f * systemParameter;
2066 OOGL(glColor4f(r, g, b, alpha));
2069 case OOLRC_MODE_GOVERNMENT:
2072 systemParameter = nearby_systems[
i].gov;
2080 OOGL(glColor4f(r, g, b, alpha));
2083 case OOLRC_MODE_TECHLEVEL:
2086 systemParameter = nearby_systems[
i].tec;
2088 g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
2094 OOGL(glColor4f(r, g, b, alpha));
2096 case OOLRC_MODE_UNKNOWN:
2097 case OOLRC_MODE_SUNCOLOR:
2102 if (sunColor !=
nil) {
2113 OOGL(glColor4f(r, g, b, alpha));
2123 GLfloat systemNameScale = [
guiUserSettings oo_floatForKey:kGuiChartLabelScale defaultValue:1.0];
2128 int n_matches = 0, foundIndex = -1;
2130 for (i = 0; i < 256; i++)
if (systemsFound[i])
2132 if(foundSystem == n_matches) foundIndex = i;
2146 for (i = 0; i < 256; i++)
2153 BOOL mark = systemsFound[
i];
2154 float marker_size = 8.0/zoom;
2157 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2158 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2162 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2163 star.y = (float)(sys_coordinates.y * vscale + voffset);
2165 glVertex3f(
x + star.x - marker_size,
y + star.y - marker_size, z);
2166 glVertex3f(
x + star.x + marker_size,
y + star.y - marker_size, z);
2167 glVertex3f(
x + star.x + marker_size,
y + star.y + marker_size, z);
2168 glVertex3f(
x + star.x - marker_size,
y + star.y + marker_size, z);
2170 if (i == foundIndex || n_matches == 1)
2172 if (n_matches == 1) foundSystem = 0;
2176 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2182 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2193 struct saved_system *sys;
2194 NSSize chSize = NSMakeSize(pixel_row_height*systemNameScale/zoom,pixel_row_height*systemNameScale/zoom);
2197 for (i = 0; i < num_nearby_systems; i++)
2204 sys = nearby_systems + i;
2207 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2208 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2212 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2213 star.y = (float)(sys_coordinates.y * vscale + voffset);
2214 if (sys->sysid == target)
2223 if (![player showInfoFlag])
2237 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
2239 else if (
EXPECT(sys->gov >= 0))
2248 OODrawPlanetInfo(sys->gov, sys->eco, sys->tec,
x + star.x + 2.0,
y + star.y + 2.0, z, chSize);
2260 sys = nearby_systems + targetIdx;
2263 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2264 star.y = (float)(sys_coordinates.y * vscale + voffset);
2266 if (![player showInfoFlag])
2281 else if (sys->gov >= 0)
2302 NSString *targetName = [[UNIVERSE getSystemName:target] retain];
2305 NSString *travelDistLine =
@"";
2308 travelDistLine =
OOExpandKey(
@"long-range-chart-distance", distance);
2310 NSString *travelTimeLine =
@"";
2313 travelTimeLine =
OOExpandKey(
@"long-range-chart-est-travel-time", time);
2318 [
self setArray:[
NSArray arrayWithObjects:targetName, travelDistLine,travelTimeLine,nil]
forRow:textRow];
2324 if ([
PLAYER guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART)
2328 [
self setArray:[
NSArray arrayWithObjects: @"", OOExpandKey(@"short-range-chart-jumps", jumps), nil]
forRow: textRow + 1];
2340 cu = NSMakePoint((
float)(hscale*info_system_coordinates.x+hoffset),(
float)(vscale*info_system_coordinates.y+voffset));
2341 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize(6.0f/zoom+2.0f, 6.0f/zoom+2.0f), 5);
2344 OOGL(glDisable(GL_SCISSOR_TEST));
2349 glVertex3f(
x + 0, (
float)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2350 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2351 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2352 glVertex3f(
x + 0, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2481- (void) drawAdvancedNavArrayAtX:(
float)x y:(
float)y z:(
float)z alpha:(
float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(
OORouteType) optimizeBy zoom: (
OOScalar) zoom
2483 GLfloat lr,lg,lb,la,lr2,lg2,lb2,la2;
2486 NSPoint star = NSZeroPoint,
2487 star2 = NSZeroPoint,
2488 starabs = NSZeroPoint,
2489 star2abs = NSZeroPoint;
2503 NSInteger concealment[256];
2504 for (NSUInteger i=0;i<256;i++) {
2506 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
2527 star.x = (float)(starabs.x * hscale);
2528 star.y = (float)(starabs.y * vscale);
2551 star2.x = (float)(star2abs.x * hscale);
2552 star2.y = (float)(star2abs.y * vscale);
2557 OOGL(glColor4f(lr, lg, lb, la*alpha));
2558 glVertex3f(
x+star.x,
y+star.y, z);
2560 float frac = (d/jumpRange);
2562 OOLerp(lr,lr2,frac),
2563 OOLerp(lg,lg2,frac),
2564 OOLerp(lb,lb2,frac),
2567 glVertex3f(
x+star2.x,
y+star2.y, z);
2574 if (thisConnectionColor ==
nil)
2576 thisConnectionColor = defaultConnectionColor;
2579 OOGL(glColor4f(lr, lg, lb, la*alpha));
2581 glVertex3f(
x+star.x,
y+star.y, z);
2586 if (thatConnectionColor ==
nil)
2588 thatConnectionColor = thisConnectionColor;
2591 OOGL(glColor4f(lr, lg, lb, la*alpha));
2593 glVertex3f(
x+star2.x,
y+star2.y, z);
2607 NSUInteger i, route_hops = [[
routeInfo oo_arrayForKey:@"route"] count] - 1;
2620 for (i = 0; i < route_hops; i++)
2622 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];
2626 star.x = (float)(starabs.x * hscale);
2627 star.y = (float)(starabs.y * vscale);
2629 star2.x = (float)(star2abs.x * hscale);
2630 star2.y = (float)(star2abs.y * vscale);
2634 glVertex3f(
x+star.x,
y+star.y, z);
2635 glVertex3f(
x+star2.x,
y+star2.y, z);
2647 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];