1234- (void) drawEquipmentList:(NSArray *)eqptList z:(GLfloat)z
1236 if ([eqptList
count] == 0)
return;
1240 if ([[
PLAYER hud] allowBigGui])
1244 NSUInteger itemsPerColumn = maxRows;
1247 NSInteger firstY = 40;
1248 NSUInteger eqptCount = [
eqptList count];
1249 NSUInteger pageCount = 1;
1252 NSArray *info =
nil;
1253 NSString *name =
nil;
1259 i = itemsPerColumn * 2 + 2;
1262 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1264 i = itemsPerColumn * 4;
1269 if (statusPage == 1)
1276 start = i/statusPage;
1281 pageCount = ceil((
float)(eqptCount-i)/(itemsPerColumn*2)) + 2;
1282 statusPage = (NSInteger)
OOClampInteger(statusPage, 1, pageCount);
1283 start = (statusPage == 1) ? 0 : (statusPage-1) * itemsPerColumn * 2 + 2;
1288 statusPage = pageCount;
1299 [
self setText:@""
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1300 [
self setKey:GUI_KEY_SKIP
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1303 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
1313 if (statusPage == pageCount)
1319 if (statusPage < pageCount)
1322 [
self setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ",nil]
forRow:firstRow + maxRows];
1324 if (statusPage == 1)
1330 if (statusPage > 1 && statusPage < pageCount)
1332 [
self setSelectableRange:NSMakeRange(firstRow, MIN(firstRow + maxRows, GUI_DEFAULT_ROWS - firstRow))];
1334 if ([
self selectedRow] == -1) [
self setSelectedRow:firstRow + maxRows];
1337 if (statusPage == 1 || statusPage == pageCount) itemsPerColumn++;
1338 eqptCount = (NSInteger)
OOClampInteger(eqptCount, 1, start + itemsPerColumn * 2);
1339 for (i = start; i < eqptCount; i++)
1341 info = [
eqptList oo_arrayAtIndex:i];
1342 name = [
info oo_stringAtIndex:0];
1343 if([name length] > 42) name = [[
name substringToIndex:40] stringByAppendingString:@"..."];
1345 damaged = ![
info oo_boolAtIndex:1];
1358 if (i - start < itemsPerColumn)
1360 OODrawString(name, -220, firstY - 16 * (NSInteger)(i - start), z, NSMakeSize(15, 15));
1364 OODrawString(name, 50, firstY - 16 * (NSInteger)(i - itemsPerColumn - start), z, NSMakeSize(15, 15));
1483- (void) drawGLDisplay:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha
1488 NSSize characterSize = pixel_text_size;
1489 NSSize titleCharacterSize = pixel_title_size;
1490 float backgroundAlpha =
self == [UNIVERSE messageGUI] && ![UNIVERSE permanentMessageLog] ? 0.0f : alpha;
1496 for (i = 0; i < n_rows; i++)
1498 row_alpha[
i] = alpha;
1500 if(![
UNIVERSE autoMessageLogBg] && [
PLAYER guiScreen] == GUI_SCREEN_MAIN) backgroundAlpha = alpha;
1502 if (rowFadeTime[i] > 0.0f && ![
UNIVERSE permanentMessageLog])
1504 rowFadeTime[
i] -= (float)delta_t;
1505 if (rowFadeTime[i] <= 0.0f)
1507 [
rowText replaceObjectAtIndex:i withObject:@""];
1508 rowFadeTime[
i] = 0.0f;
1511 if ((rowFadeTime[i] > 0.0f)&&(rowFadeTime[i] < 1.0))
1513 row_alpha[
i] *= rowFadeTime[
i];
1514 if (backgroundAlpha < row_alpha[i]) backgroundAlpha = row_alpha[
i];
1518 backgroundAlpha = alpha;
1526 if (backgroundColor)
1528 int playerStatus = [PLAYER status];
1529 if (playerStatus != STATUS_START_GAME && playerStatus != STATUS_DEAD)
1531 OOGL(glColor4f([backgroundColor redComponent], [backgroundColor greenComponent], [backgroundColor blueComponent], backgroundAlpha * [backgroundColor alphaComponent]));
1533 glVertex3f(
x + 0.0f,
y + 0.0f, z);
1534 glVertex3f(
x + size_in_pixels.width,
y + 0.0f, z);
1535 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height, z);
1536 glVertex3f(
x + 0.0f,
y + size_in_pixels.height, z);
1543 if (foregroundSprite !=
nil)
1545 [
foregroundSprite blitCentredToX:x + 0.5f * size_in_pixels.width Y:y + 0.5f * size_in_pixels.height Z:z alpha:alpha];
1548 if (!
RowInRange(selectedRow, selectableRange))
1562 OODrawString(title,
x + pixel_row_center - strsize.width/2.0,
y + size_in_pixels.height - pixel_title_size.height, z, titleCharacterSize);
1569 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1570 glVertex3f(
x + size_in_pixels.width,
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 + 2, z);
1572 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1579 for (i = 0; i < n_rows; i++)
1582 glColor4f([row_color redComponent], [row_color greenComponent], [row_color blueComponent], row_alpha[i]);
1584 if ([[rowText objectAtIndex:i] isKindOfClass:[NSString
class]])
1586 NSString* text = (NSString *)[rowText objectAtIndex:i];
1587 if (![text isEqual:
@""])
1590 switch (rowAlignment[i])
1593 rowPosition[
i].x = 0.0f;
1596 rowPosition[
i].x = size_in_pixels.width - strsize.width;
1599 rowPosition[
i].x = (size_in_pixels.width - strsize.width)/2.0f;
1602 if (i == (
unsigned)selectedRow)
1604 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1608 glVertex3f(block.origin.x, block.origin.y, z);
1609 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1610 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1611 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1620 if ((showTextCursor)&&(i == (
unsigned)currentRow))
1623 NSPoint cu = NSMakePoint(
x + rowPosition[i].
x + tr.size.width + 0.2f * characterSize.width,
y + rowPosition[i].y);
1625 tr.size.width = 0.5f * characterSize.width;
1626 GLfloat g_alpha = 0.5f * (1.0f + (float)sin(6 * [
UNIVERSE getTime]));
1630 glVertex3f(tr.origin.x, tr.origin.y, z);
1631 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y, z);
1632 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y + tr.size.height, z);
1633 glVertex3f(tr.origin.x, tr.origin.y + tr.size.height, z);
1639 if ([[rowText objectAtIndex:i] isKindOfClass:[NSArray
class]])
1641 NSArray *array = [
rowText oo_arrayAtIndex:i];
1642 NSUInteger j, max_columns =
MIN([array
count], n_columns);
1645 for (j = 0; j < max_columns; j++)
1647 NSString* text = [
array oo_stringAtIndex:j];
1648 if ([text length] != 0)
1650 isLeftAligned = tabStops[
j] >= 0;
1651 rowPosition[
i].x = labs(tabStops[j]);
1654 NSString *hilitedText = [
text stringByTrimmingCharactersInSet:[
NSCharacterSet characterSetWithCharactersInString:@" \037"]];
1655 NSRange txtRange = [
text rangeOfString:hilitedText];
1656 unsigned leadingSpaces = 0;
1658 if (
EXPECT_NOT(txtRange.location == NSNotFound))
1663 else if (txtRange.location > 0)
1667 padRange.location = 0;
1668 padRange.length = txtRange.location;
1669 NSRect charBlock =
OORectFromString([text substringWithRange:padRange], 0, 0, characterSize);
1670 leadingSpaces = (unsigned)charBlock.size.width;
1683 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1687 rowPosition[
i].x -= block.size.width + 3;
1689 block =
OORectFromString(hilitedText,
x + rowPosition[i].
x + 1 + leadingSpaces,
y + rowPosition[i].
y + 2, characterSize);
1690 block.size.width += 3;
1693 if (i == (
unsigned)selectedRow)
1698 glVertex3f(block.origin.x, block.origin.y, z);
1699 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1700 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1701 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1757- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOOL)compact
1773 GLfloat r = 1.0, g = 1.0, b = 1.0;
1776 NSUInteger systemParameter;
1780 double hcenter = size_in_pixels.width/2.0;
1784 double hoffset = hcenter - chart_centre_coordinates.x*hscale;
1785 double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y*vscale;
1789 hscale = size_in_pixels.width / 256.0;
1790 vscale = -1.0 * size_in_pixels.height / 512.0;
1792 voffset = size_in_pixels.height - pixel_title_size.height - 5;
1794 chart_centre_coordinates.x = 128.0;
1795 chart_centre_coordinates.y = 128.0;
1800 double d, distance = 0.0, time = 0.0;
1807 BOOL routeExists = NO;
1809 NSInteger concealment[256];
1810 for (i=0;i<256;i++) {
1812 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
1815 BOOL *systemsFound = [UNIVERSE systemsFound];
1816 NSSize viewSize = [[UNIVERSE gameView] backingViewSize];
1817 double aspect_ratio = viewSize.width / viewSize.height;
1820 GLfloat govcol[] = { 0.5, 0.0, 0.7,
1829 if (aspect_ratio > 4.0/3.0)
1831 pixelRatio = viewSize.height / 480.0;
1835 pixelRatio = viewSize.width / 640.0;
1840 clipRect = NSMakeRect((viewSize.width - size_in_pixels.width*pixelRatio)/2.0,
1841 (viewSize.height + size_in_pixels.height*pixelRatio)/2.0 - (pixel_title_size.height + 15 + (textRow-2)*
MAIN_GUI_ROW_HEIGHT) * pixelRatio,
1842 size_in_pixels.width * pixelRatio,
1852 cu = NSMakePoint((
float)(hscale*galaxy_coordinates.x+hoffset),(
float)(vscale*galaxy_coordinates.y+voffset));
1855 OOGL(glEnable(GL_SCISSOR_TEST));
1856 OOGL(glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height));
1862 static struct saved_system
1868 } nearby_systems[ 256 ];
1869 static int num_nearby_systems = 0;
1875 for (i = 0; i < num_nearby_systems; i++)
1876 [nearby_systems[ i ].p_name release];
1878 num_nearby_systems = 0;
1879 for (i = 0; i < 256; i++)
1882 NSDictionary* sys_info = [UNIVERSE generateSystemData:i];
1883 if (
EXPECT_NOT([sys_info oo_boolForKey:
@"sun_gone_nova"]))
1895 nearby_systems[
num_nearby_systems ].nova = [[UNIVERSE generateSystemData:i] oo_boolForKey:@"sun_gone_nova"];
1896 num_nearby_systems++;
1904 static NSDictionary *routeInfo =
nil;
1920 if (advancedNavArrayMode !=
OPTIMIZED_BY_NONE && [player hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
1923 OOSystemID destNumber = [PLAYER targetSystemID];
1924 if (routeInfo ==
nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber || advancedNavArrayMode != savedArrayMode)
1927 routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
1928 savedPlanetNumber = planetNumber;
1929 savedDestNumber = destNumber;
1930 savedArrayMode = advancedNavArrayMode;
1932 target = destNumber;
1938 if (routeInfo) routeExists = YES;
1944 distance = [
routeInfo oo_doubleForKey:@"distance"];
1945 time = [
routeInfo oo_doubleForKey:@"time"];
1946 jumps = [
routeInfo oo_intForKey:@"jumps"];
1948 if (distance == 0.0 && planetNumber != destNumber)
1965 if (distance == 0.0)
1967 if (target != [
PLAYER systemID])
1974 if ([player hasHyperspaceMotor] && distance <= [player fuel]/10.0)
1976 time = distance * distance;
1984 if ([player hasHyperspaceMotor])
1990 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel*hscale), 2*(
float)(fuel*vscale)), 5);
2004 cu = NSMakePoint((
float)(hscale*cursor_coordinates.x+hoffset),(
float)(vscale*cursor_coordinates.y+voffset));
2010 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
2012 for (i = 0; i < num_nearby_systems; i++)
2016 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2017 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2029 float blob_factor = [
guiUserSettings oo_floatForKey:kGuiChartCircleScale defaultValue:0.0017];
2030 float blob_size = (1.0f + blob_factor * [
systemInfo oo_floatForKey:@"radius"])/zoom;
2031 if (blob_size < 0.5) blob_size = 0.5;
2033 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2034 star.y = (float)(sys_coordinates.y * vscale + voffset);
2036 noNova = !nearby_systems[
i].nova;
2037 NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL,
@"Long range chart mode %i out of range", (
int)chart_mode);
2042 GLfloat base_size = 0.5f * blob_size + 2.5f;
2049 OOGL(glColor4f(r, g, b, alpha));
2053 case OOLRC_MODE_ECONOMY:
2056 systemParameter = nearby_systems[
i].eco;
2057 GLfloat ce1 = 1.0f - 0.125f * systemParameter;
2065 OOGL(glColor4f(r, g, b, alpha));
2068 case OOLRC_MODE_GOVERNMENT:
2071 systemParameter = nearby_systems[
i].gov;
2079 OOGL(glColor4f(r, g, b, alpha));
2082 case OOLRC_MODE_TECHLEVEL:
2085 systemParameter = nearby_systems[
i].tec;
2087 g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
2093 OOGL(glColor4f(r, g, b, alpha));
2095 case OOLRC_MODE_UNKNOWN:
2096 case OOLRC_MODE_SUNCOLOR:
2101 if (sunColor !=
nil) {
2112 OOGL(glColor4f(r, g, b, alpha));
2122 GLfloat systemNameScale = [
guiUserSettings oo_floatForKey:kGuiChartLabelScale defaultValue:1.0];
2127 int n_matches = 0, foundIndex = -1;
2129 for (i = 0; i < 256; i++)
if (systemsFound[i])
2131 if(foundSystem == n_matches) foundIndex = i;
2145 for (i = 0; i < 256; i++)
2152 BOOL mark = systemsFound[
i];
2153 float marker_size = 8.0/zoom;
2156 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2157 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2161 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2162 star.y = (float)(sys_coordinates.y * vscale + voffset);
2164 glVertex3f(
x + star.x - marker_size,
y + star.y - marker_size, z);
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);
2169 if (i == foundIndex || n_matches == 1)
2171 if (n_matches == 1) foundSystem = 0;
2175 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2181 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2192 struct saved_system *sys;
2193 NSSize chSize = NSMakeSize(pixel_row_height*systemNameScale/zoom,pixel_row_height*systemNameScale/zoom);
2196 for (i = 0; i < num_nearby_systems; i++)
2203 sys = nearby_systems + i;
2206 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2207 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2211 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2212 star.y = (float)(sys_coordinates.y * vscale + voffset);
2213 if (sys->sysid == target)
2222 if (![player showInfoFlag])
2236 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
2238 else if (
EXPECT(sys->gov >= 0))
2247 OODrawPlanetInfo(sys->gov, sys->eco, sys->tec,
x + star.x + 2.0,
y + star.y + 2.0, z, chSize);
2259 sys = nearby_systems + targetIdx;
2262 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2263 star.y = (float)(sys_coordinates.y * vscale + voffset);
2265 if (![player showInfoFlag])
2280 else if (sys->gov >= 0)
2301 NSString *targetName = [[UNIVERSE getSystemName:target] retain];
2304 NSString *travelDistLine =
@"";
2307 travelDistLine =
OOExpandKey(
@"long-range-chart-distance", distance);
2309 NSString *travelTimeLine =
@"";
2312 travelTimeLine =
OOExpandKey(
@"long-range-chart-est-travel-time", time);
2317 [
self setArray:[
NSArray arrayWithObjects:targetName, travelDistLine,travelTimeLine,nil]
forRow:textRow];
2323 if ([
PLAYER guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART)
2327 [
self setArray:[
NSArray arrayWithObjects: @"", OOExpandKey(@"short-range-chart-jumps", jumps), nil]
forRow: textRow + 1];
2339 cu = NSMakePoint((
float)(hscale*info_system_coordinates.x+hoffset),(
float)(vscale*info_system_coordinates.y+voffset));
2340 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize(6.0f/zoom+2.0f, 6.0f/zoom+2.0f), 5);
2343 OOGL(glDisable(GL_SCISSOR_TEST));
2348 glVertex3f(
x + 0, (
float)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2349 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
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 - 2), z);
2351 glVertex3f(
x + 0, (GLfloat)(
y + size_in_pixels.height - (textRow-1)*
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2480- (void) drawAdvancedNavArrayAtX:(
float)x y:(
float)y z:(
float)z alpha:(
float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(
OORouteType) optimizeBy zoom: (
OOScalar) zoom
2482 GLfloat lr,lg,lb,la,lr2,lg2,lb2,la2;
2485 NSPoint star = NSZeroPoint,
2486 star2 = NSZeroPoint,
2487 starabs = NSZeroPoint,
2488 star2abs = NSZeroPoint;
2502 NSInteger concealment[256];
2503 for (NSUInteger i=0;i<256;i++) {
2505 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
2526 star.x = (float)(starabs.x * hscale);
2527 star.y = (float)(starabs.y * vscale);
2550 star2.x = (float)(star2abs.x * hscale);
2551 star2.y = (float)(star2abs.y * vscale);
2556 OOGL(glColor4f(lr, lg, lb, la*alpha));
2557 glVertex3f(
x+star.x,
y+star.y, z);
2559 float frac = (d/jumpRange);
2561 OOLerp(lr,lr2,frac),
2562 OOLerp(lg,lg2,frac),
2563 OOLerp(lb,lb2,frac),
2566 glVertex3f(
x+star2.x,
y+star2.y, z);
2573 if (thisConnectionColor ==
nil)
2575 thisConnectionColor = defaultConnectionColor;
2578 OOGL(glColor4f(lr, lg, lb, la*alpha));
2580 glVertex3f(
x+star.x,
y+star.y, z);
2585 if (thatConnectionColor ==
nil)
2587 thatConnectionColor = thisConnectionColor;
2590 OOGL(glColor4f(lr, lg, lb, la*alpha));
2592 glVertex3f(
x+star2.x,
y+star2.y, z);
2606 NSUInteger i, route_hops = [[
routeInfo oo_arrayForKey:@"route"] count] - 1;
2619 for (i = 0; i < route_hops; i++)
2621 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];
2625 star.x = (float)(starabs.x * hscale);
2626 star.y = (float)(starabs.y * vscale);
2628 star2.x = (float)(star2abs.x * hscale);
2629 star2.y = (float)(star2abs.y * vscale);
2633 glVertex3f(
x+star.x,
y+star.y, z);
2634 glVertex3f(
x+star2.x,
y+star2.y, z);
2646 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];