1103- (void)drawEquipmentList:(NSArray*)eqptList z:(GLfloat)z
1105 if ([eqptList
count] == 0)
1110 if ([[
PLAYER hud] allowBigGui]) {
1113 NSUInteger itemsPerColumn = maxRows;
1115 NSInteger firstY = 40;
1116 NSUInteger eqptCount = [
eqptList count];
1117 NSUInteger pageCount = 1;
1120 NSArray* info =
nil;
1121 NSString* name =
nil;
1127 i = itemsPerColumn * 2 + 2;
1130 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1132 i = itemsPerColumn * 4;
1137 if (statusPage == 1) {
1141 start = i / statusPage;
1145 pageCount = ceil((
float)(eqptCount - i) / (itemsPerColumn * 2)) + 2;
1146 statusPage = (NSInteger)
OOClampInteger(statusPage, 1, pageCount);
1147 start = (statusPage == 1) ? 0 : (statusPage - 1) * itemsPerColumn * 2 + 2;
1150 statusPage = pageCount;
1160 [
self setText:@""
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1161 [
self setKey:GUI_KEY_SKIP
forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1164 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
1168 if (statusPage > 1) {
1173 if (statusPage == pageCount) {
1178 if (statusPage < pageCount) {
1180 [
self setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ", nil]
forRow:firstRow + maxRows];
1182 if (statusPage == 1) {
1187 if (statusPage > 1 && statusPage < pageCount) {
1188 [
self setSelectableRange:NSMakeRange(firstRow, MIN(firstRow + maxRows, GUI_DEFAULT_ROWS - firstRow))];
1190 if ([
self selectedRow] == -1)
1194 if (statusPage == 1 || statusPage == pageCount)
1196 eqptCount = (NSInteger)
OOClampInteger(eqptCount, 1, start + itemsPerColumn * 2);
1197 for (i = start; i < eqptCount; i++) {
1198 info = [
eqptList oo_arrayAtIndex:i];
1199 name = [
info oo_stringAtIndex:0];
1200 if ([name length] > 42)
1201 name = [[
name substringToIndex:40] stringByAppendingString:@"..."];
1203 damaged = ![
info oo_boolAtIndex:1];
1214 if (i - start < itemsPerColumn) {
1215 OODrawString(name, -220, firstY - 16 * (NSInteger)(i - start), z, NSMakeSize(15, 15));
1217 OODrawString(name, 50, firstY - 16 * (NSInteger)(i - itemsPerColumn - start), z, NSMakeSize(15, 15));
1321- (void)drawGLDisplay:(GLfloat)x y:(GLfloat)y z:(GLfloat)z alpha:(GLfloat)alpha
1326 NSSize characterSize = pixel_text_size;
1327 NSSize titleCharacterSize = pixel_title_size;
1328 float backgroundAlpha =
self == [UNIVERSE messageGUI] && ![UNIVERSE permanentMessageLog] ? 0.0f : alpha;
1334 for (i = 0; i < n_rows; i++) {
1335 row_alpha[
i] = alpha;
1337 if (![
UNIVERSE autoMessageLogBg] && [
PLAYER guiScreen] == GUI_SCREEN_MAIN)
1338 backgroundAlpha = alpha;
1340 if (rowFadeTime[i] > 0.0f && ![
UNIVERSE permanentMessageLog]) {
1341 rowFadeTime[
i] -= (float)delta_t;
1342 if (rowFadeTime[i] <= 0.0f) {
1343 [
rowText replaceObjectAtIndex:i withObject:@""];
1344 rowFadeTime[
i] = 0.0f;
1347 if ((rowFadeTime[i] > 0.0f) && (rowFadeTime[i] < 1.0)) {
1348 row_alpha[
i] *= rowFadeTime[
i];
1349 if (backgroundAlpha < row_alpha[i])
1350 backgroundAlpha = row_alpha[
i];
1352 backgroundAlpha = alpha;
1360 if (backgroundColor) {
1361 int playerStatus = [PLAYER status];
1362 if (playerStatus != STATUS_START_GAME && playerStatus != STATUS_DEAD) {
1363 OOGL(glColor4f([backgroundColor redComponent], [backgroundColor greenComponent], [backgroundColor blueComponent], backgroundAlpha * [backgroundColor alphaComponent]));
1365 glVertex3f(
x + 0.0f,
y + 0.0f, z);
1366 glVertex3f(
x + size_in_pixels.width,
y + 0.0f, z);
1367 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height, z);
1368 glVertex3f(
x + 0.0f,
y + size_in_pixels.height, z);
1375 if (foregroundSprite !=
nil) {
1376 [
foregroundSprite blitCentredToX:x + 0.5f * size_in_pixels.width Y:y + 0.5f * size_in_pixels.height Z:z alpha:alpha];
1379 if (!
RowInRange(selectedRow, selectableRange))
1392 OODrawString(title,
x + pixel_row_center - strsize.width / 2.0,
y + size_in_pixels.height - pixel_title_size.height, z, titleCharacterSize);
1399 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1400 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 4, z);
1401 glVertex3f(
x + size_in_pixels.width,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1402 glVertex3f(
x + 0,
y + size_in_pixels.height - pixel_title_size.height + 2, z);
1409 for (i = 0; i < n_rows; i++) {
1411 glColor4f([row_color redComponent], [row_color greenComponent], [row_color blueComponent], row_alpha[i]);
1413 if ([[rowText objectAtIndex:i] isKindOfClass:[NSString
class]]) {
1414 NSString* text = (NSString*)[rowText objectAtIndex:i];
1415 if (![text isEqual:
@""]) {
1417 switch (rowAlignment[i]) {
1419 rowPosition[
i].x = 0.0f;
1422 rowPosition[
i].x = size_in_pixels.width - strsize.width;
1425 rowPosition[
i].x = (size_in_pixels.width - strsize.width) / 2.0f;
1428 if (i == (
unsigned)selectedRow) {
1429 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1433 glVertex3f(block.origin.x, block.origin.y, z);
1434 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1435 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1436 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1445 if ((showTextCursor) && (i == (
unsigned)currentRow)) {
1447 NSPoint cu = NSMakePoint(
x + rowPosition[i].
x + tr.size.width + 0.2f * characterSize.width,
y + rowPosition[i].y);
1449 tr.size.width = 0.5f * characterSize.width;
1450 GLfloat g_alpha = 0.5f * (1.0f + (float)sin(6 * [
UNIVERSE getTime]));
1454 glVertex3f(tr.origin.x, tr.origin.y, z);
1455 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y, z);
1456 glVertex3f(tr.origin.x + tr.size.width, tr.origin.y + tr.size.height, z);
1457 glVertex3f(tr.origin.x, tr.origin.y + tr.size.height, z);
1463 if ([[rowText objectAtIndex:i] isKindOfClass:[NSArray
class]]) {
1464 NSArray* array = [
rowText oo_arrayAtIndex:i];
1465 NSUInteger j, max_columns =
MIN([array
count], n_columns);
1468 for (j = 0; j < max_columns; j++) {
1469 NSString* text = [
array oo_stringAtIndex:j];
1470 if ([text length] != 0) {
1471 isLeftAligned = tabStops[
j] >= 0;
1472 rowPosition[
i].x = llabs(tabStops[j]);
1475 NSString* hilitedText = [
text stringByTrimmingCharactersInSet:[
NSCharacterSet characterSetWithCharactersInString:@" \037"]];
1476 NSRange txtRange = [
text rangeOfString:hilitedText];
1477 unsigned leadingSpaces = 0;
1479 if (
EXPECT_NOT(txtRange.location == NSNotFound)) {
1482 }
else if (txtRange.location > 0) {
1485 padRange.location = 0;
1486 padRange.length = txtRange.location;
1487 NSRect charBlock =
OORectFromString([text substringWithRange:padRange], 0, 0, characterSize);
1488 leadingSpaces = (unsigned)charBlock.size.width;
1501 NSRect block =
OORectFromString(text,
x + rowPosition[i].
x + 2,
y + rowPosition[i].
y + 2, characterSize);
1503 if (!isLeftAligned) {
1504 rowPosition[
i].x -= block.size.width + 3;
1506 block =
OORectFromString(hilitedText,
x + rowPosition[i].
x + 1 + leadingSpaces,
y + rowPosition[i].
y + 2, characterSize);
1507 block.size.width += 3;
1509 if (i == (
unsigned)selectedRow) {
1513 glVertex3f(block.origin.x, block.origin.y, z);
1514 glVertex3f(block.origin.x + block.size.width, block.origin.y, z);
1515 glVertex3f(block.origin.x + block.size.width, block.origin.y + block.size.height, z);
1516 glVertex3f(block.origin.x, block.origin.y + block.size.height, z);
1563- (void)drawStarChart:(GLfloat)x y:(GLfloat)y z:(GLfloat)z alpha:(GLfloat)alpha compact:(BOOL)compact
1579 GLfloat r = 1.0, g = 1.0, b = 1.0;
1582 NSUInteger systemParameter;
1586 double hcenter = size_in_pixels.width / 2.0;
1590 double hoffset = hcenter - chart_centre_coordinates.x * hscale;
1591 double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y * vscale;
1594 hscale = size_in_pixels.width / 256.0;
1595 vscale = -1.0 * size_in_pixels.height / 512.0;
1597 voffset = size_in_pixels.height - pixel_title_size.height - 5;
1599 chart_centre_coordinates.x = 128.0;
1600 chart_centre_coordinates.y = 128.0;
1605 double d,
distance = 0.0, time = 0.0;
1612 BOOL routeExists = NO;
1614 NSInteger concealment[256];
1615 for (i = 0; i < 256; i++) {
1617 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
1620 BOOL* systemsFound = [UNIVERSE systemsFound];
1621 NSSize viewSize = [[UNIVERSE gameView] backingViewSize];
1622 double aspect_ratio = viewSize.width / viewSize.height;
1625 GLfloat govcol[] = { 0.5, 0.0, 0.7,
1634 if (aspect_ratio > 4.0 / 3.0) {
1635 pixelRatio = viewSize.height / 480.0;
1637 pixelRatio = viewSize.width / 640.0;
1642 clipRect = NSMakeRect((viewSize.width - size_in_pixels.width * pixelRatio) / 2.0,
1643 (viewSize.height + size_in_pixels.height * pixelRatio) / 2.0 - (pixel_title_size.height + 15 + (textRow - 2) *
MAIN_GUI_ROW_HEIGHT) * pixelRatio,
1644 size_in_pixels.width * pixelRatio,
1654 cu = NSMakePoint((
float)(hscale * galaxy_coordinates.x + hoffset), (
float)(vscale * galaxy_coordinates.y + voffset));
1657 OOGL(glEnable(GL_SCISSOR_TEST));
1658 OOGL(glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height));
1664 static struct saved_system {
1669 } nearby_systems[256];
1670 static int num_nearby_systems = 0;
1675 for (i = 0; i < num_nearby_systems; i++)
1676 [nearby_systems[i].p_name release];
1678 num_nearby_systems = 0;
1679 for (i = 0; i < 256; i++) {
1681 NSDictionary* sys_info = [UNIVERSE generateSystemData:i];
1682 if (
EXPECT_NOT([sys_info oo_boolForKey:
@"sun_gone_nova"])) {
1691 nearby_systems[
num_nearby_systems].nova = [[UNIVERSE generateSystemData:i] oo_boolForKey:@"sun_gone_nova"];
1692 num_nearby_systems++;
1700 static NSDictionary* routeInfo =
nil;
1709 if (advancedNavArrayMode !=
OPTIMIZED_BY_NONE && [player hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"]) {
1711 OOSystemID destNumber = [PLAYER targetSystemID];
1712 if (routeInfo ==
nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber || advancedNavArrayMode != savedArrayMode) {
1714 routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
1715 savedPlanetNumber = planetNumber;
1716 savedDestNumber = destNumber;
1717 savedArrayMode = advancedNavArrayMode;
1719 target = destNumber;
1732 time = [
routeInfo oo_doubleForKey:@"time"];
1733 jumps = [
routeInfo oo_intForKey:@"jumps"];
1735 if (
distance == 0.0 && planetNumber != destNumber) {
1749 if (target != [
PLAYER systemID]) {
1755 if ([player hasHyperspaceMotor] &&
distance <= [player fuel] / 10.0) {
1762 if ([player hasHyperspaceMotor]) {
1767 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel * hscale), 2 * (
float)(fuel * vscale)), 5);
1779 cu = NSMakePoint((
float)(hscale * cursor_coordinates.x + hoffset), (
float)(vscale * cursor_coordinates.y + voffset));
1785 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
1787 for (i = 0; i < num_nearby_systems; i++) {
1790 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
1791 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
1802 float blob_factor = [
guiUserSettings oo_floatForKey:kGuiChartCircleScale defaultValue:0.0017];
1803 float blob_size = (1.0f + blob_factor * [
systemInfo oo_floatForKey:@"radius"]) / zoom;
1804 if (blob_size < 0.5)
1807 star.x = (float)(sys_coordinates.x * hscale + hoffset);
1808 star.y = (float)(sys_coordinates.y * vscale + voffset);
1810 noNova = !nearby_systems[
i].nova;
1811 NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL,
@"Long range chart mode %i out of range", (
int)chart_mode);
1816 GLfloat base_size = 0.5f * blob_size + 2.5f;
1823 OOGL(glColor4f(r, g, b, alpha));
1825 switch (chart_mode) {
1826 case OOLRC_MODE_ECONOMY:
1828 systemParameter = nearby_systems[
i].eco;
1829 GLfloat ce1 = 1.0f - 0.125f * systemParameter;
1835 OOGL(glColor4f(r, g, b, alpha));
1838 case OOLRC_MODE_GOVERNMENT:
1840 systemParameter = nearby_systems[
i].gov;
1846 OOGL(glColor4f(r, g, b, alpha));
1849 case OOLRC_MODE_TECHLEVEL:
1851 systemParameter = nearby_systems[
i].tec;
1853 g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
1857 OOGL(glColor4f(r, g, b, alpha));
1859 case OOLRC_MODE_UNKNOWN:
1860 case OOLRC_MODE_SUNCOLOR:
1864 if (sunColor !=
nil) {
1873 OOGL(glColor4f(r, g, b, alpha));
1883 GLfloat systemNameScale = [
guiUserSettings oo_floatForKey:kGuiChartLabelScale defaultValue:1.0];
1888 int n_matches = 0, foundIndex = -1;
1890 for (i = 0; i < 256; i++)
1891 if (systemsFound[i]) {
1892 if (foundSystem == n_matches)
1897 if (n_matches == 0) {
1902 for (i = 0; i < 256; i++) {
1907 BOOL mark = systemsFound[
i];
1908 float marker_size = 8.0 / zoom;
1911 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
1912 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
1915 star.x = (float)(sys_coordinates.x * hscale + hoffset);
1916 star.y = (float)(sys_coordinates.y * vscale + voffset);
1918 glVertex3f(
x + star.x - marker_size,
y + star.y - marker_size, z);
1919 glVertex3f(
x + star.x + marker_size,
y + star.y - marker_size, z);
1920 glVertex3f(
x + star.x + marker_size,
y + star.y + marker_size, z);
1921 glVertex3f(
x + star.x - marker_size,
y + star.y + marker_size, z);
1923 if (i == foundIndex || n_matches == 1) {
1928 OODrawString([
UNIVERSE systemNameIndex:i],
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10 * systemNameScale, 10 * systemNameScale));
1932 OODrawString([
UNIVERSE systemNameIndex:i],
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10 * systemNameScale, 10 * systemNameScale));
1943 struct saved_system* sys;
1944 NSSize chSize = NSMakeSize(pixel_row_height * systemNameScale / zoom, pixel_row_height * systemNameScale / zoom);
1947 for (i = 0; i < num_nearby_systems; i++) {
1952 sys = nearby_systems + i;
1955 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
1956 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
1960 star.x = (float)(sys_coordinates.x * hscale + hoffset);
1961 star.y = (float)(sys_coordinates.y * vscale + voffset);
1962 if (sys->sysid == target)
1968 if (![player showInfoFlag])
1972 if (d <= jumpRange) {
1978 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
1979 }
else if (
EXPECT(sys->gov >= 0))
1985 OODrawPlanetInfo(sys->gov, sys->eco, sys->tec,
x + star.x + 2.0,
y + star.y + 2.0, z, chSize);
1995 sys = nearby_systems + targetIdx;
1998 star.x = (float)(sys_coordinates.x * hscale + hoffset);
1999 star.y = (float)(sys_coordinates.y * vscale + voffset);
2001 if (![player showInfoFlag]) {
2003 if (d <= jumpRange) {
2010 }
else if (sys->gov >= 0)
2028 NSString* targetName = [[UNIVERSE getSystemName:target] retain];
2031 NSString* travelDistLine =
@"";
2035 NSString* travelTimeLine =
@"";
2037 travelTimeLine =
OOExpandKey(
@"long-range-chart-est-travel-time", time);
2041 [
self setArray:[
NSArray arrayWithObjects:targetName, travelDistLine, travelTimeLine, nil]
forRow:textRow];
2045 if ([
PLAYER guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART) {
2047 [
self setArray:[
NSArray arrayWithObjects:@"", OOExpandKey(@"short-range-chart-jumps", jumps), nil]
forRow:textRow + 1];
2057 cu = NSMakePoint((
float)(hscale * info_system_coordinates.x + hoffset), (
float)(vscale * info_system_coordinates.y + voffset));
2058 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize(6.0f / zoom + 2.0f, 6.0f / zoom + 2.0f), 5);
2061 OOGL(glDisable(GL_SCISSOR_TEST));
2066 glVertex3f(
x + 0, (
float)(
y + size_in_pixels.height - (textRow - 1) *
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2067 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow - 1) *
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height), z);
2068 glVertex3f(
x + size_in_pixels.width, (GLfloat)(
y + size_in_pixels.height - (textRow - 1) *
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2069 glVertex3f(
x + 0, (GLfloat)(
y + size_in_pixels.height - (textRow - 1) *
MAIN_GUI_ROW_HEIGHT - pixel_title_size.height - 2), z);
2177- (void)drawAdvancedNavArrayAtX:(
float)x y:(
float)y z:(
float)z alpha:(
float)alpha usingRoute:(NSDictionary*)routeInfo optimizedBy:(
OORouteType)optimizeBy zoom:(
OOScalar)zoom
2179 GLfloat lr, lg, lb, la, lr2, lg2, lb2, la2;
2182 NSPoint star = NSZeroPoint,
2183 star2 = NSZeroPoint,
2184 starabs = NSZeroPoint,
2185 star2abs = NSZeroPoint;
2199 NSInteger concealment[256];
2200 for (NSUInteger i = 0; i < 256; i++) {
2202 concealment[
i] = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
2220 star.x = (float)(starabs.x * hscale);
2221 star.y = (float)(starabs.y * vscale);
2227 for (
OOSystemID j = loopstart; j < 256; j++) {
2242 star2.x = (float)(star2abs.x * hscale);
2243 star2.y = (float)(star2abs.y * vscale);
2247 OOGL(glColor4f(lr, lg, lb, la * alpha));
2248 glVertex3f(
x + star.x,
y + star.y, z);
2250 float frac = (d / jumpRange);
2256 glVertex3f(
x + star2.x,
y + star2.y, z);
2261 if (thisConnectionColor ==
nil) {
2262 thisConnectionColor = defaultConnectionColor;
2265 OOGL(glColor4f(lr, lg, lb, la * alpha));
2267 glVertex3f(
x + star.x,
y + star.y, z);
2272 if (thatConnectionColor ==
nil) {
2273 thatConnectionColor = thisConnectionColor;
2276 OOGL(glColor4f(lr, lg, lb, la * alpha));
2278 glVertex3f(
x + star2.x,
y + star2.y, z);
2290 NSUInteger i, route_hops = [[
routeInfo oo_arrayForKey:@"route"] count] - 1;
2300 for (i = 0; i < route_hops; i++) {
2301 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];
2305 star.x = (float)(starabs.x * hscale);
2306 star.y = (float)(starabs.y * vscale);
2308 star2.x = (float)(star2abs.x * hscale);
2309 star2.y = (float)(star2abs.y * vscale);
2312 glVertex3f(
x + star.x,
y + star.y, z);
2313 glVertex3f(
x + star2.x,
y + star2.y, z);
2323 loc = [[
routeInfo objectForKey:@"route"] oo_intAtIndex:i];