68 if ((
self = [super init]))
73 pixel_row_center = size_in_pixels.width / 2;
78 pixel_text_size = NSMakeSize(0.9f * pixel_row_height, pixel_row_height);
80 pixel_title_size = NSMakeSize(pixel_row_height * 1.75f, pixel_row_height * 1.5f);
82 int stops[6] = {0, 192, 256, 320, 384, 448};
85 rowRange = NSMakeRange(0,n_rows);
87 rowText = [[NSMutableArray alloc] initWithCapacity:n_rows];
88 rowKey = [[NSMutableArray alloc] initWithCapacity:n_rows];
89 rowColor = [[NSMutableArray alloc] initWithCapacity:n_rows];
91 for (i = 0; i < n_rows; i++)
94 [
rowKey addObject:[NSString stringWithFormat:@"%d",i]];
96 rowPosition[i].x = 0.0f;
97 rowPosition[i].y = size_in_pixels.height - (pixel_row_start + i * pixel_row_height);
101 for (i = 0; i < n_columns; i++)
103 tabStops[i] = stops[i];
110 drawPosition = make_vector(0.0f, 0.0f, 640.0f);
120- (id) initWithPixelSize:(NSSize)gui_size
121 columns:(
int)gui_cols
123 rowHeight:(
int)gui_row_height
124 rowStart:(
int)gui_row_start
125 title:(NSString*)gui_title
129 size_in_pixels = gui_size;
130 n_columns = gui_cols;
132 pixel_row_center = size_in_pixels.width / 2;
133 pixel_row_height = gui_row_height;
134 pixel_row_start = gui_row_start;
137 pixel_text_size = NSMakeSize(pixel_row_height, pixel_row_height);
139 pixel_title_size = NSMakeSize(pixel_row_height * 1.75f, pixel_row_height * 1.5f);
143 rowRange = NSMakeRange(0,n_rows);
145 rowText = [[NSMutableArray alloc] initWithCapacity:n_rows];
146 rowKey = [[NSMutableArray alloc] initWithCapacity:n_rows];
147 rowColor = [[NSMutableArray alloc] initWithCapacity:n_rows];
149 for (i = 0; i < n_rows; i++)
151 [rowText addObject:@""];
152 [rowKey addObject:@""];
154 rowPosition[i].x = 0.0f;
155 rowPosition[i].y = size_in_pixels.height - (pixel_row_start + i * pixel_row_height);
159 title = [gui_title retain];
169 [backgroundSprite release];
170 [foregroundSprite release];
171 [backgroundColor release];
177 [guiUserSettings release];
183- (void) resizeWithPixelSize:(NSSize)gui_size
184 columns:(
int)gui_cols
186 rowHeight:(
int)gui_row_height
187 rowStart:(
int)gui_row_start
188 title:(NSString*) gui_title
192 size_in_pixels = gui_size;
193 n_columns = gui_cols;
195 pixel_row_center = size_in_pixels.width / 2;
196 pixel_row_height = gui_row_height;
197 pixel_row_start = gui_row_start;
199 pixel_text_size = NSMakeSize(pixel_row_height, pixel_row_height);
200 pixel_title_size = NSMakeSize(pixel_row_height * 1.75f, pixel_row_height * 1.5f);
202 rowRange = NSMakeRange(0,n_rows);
205 [
self setTitle: gui_title];
209- (void) resizeTo:(NSSize)gui_size
210 characterHeight:(
int)csize
211 title:(NSString*)gui_title
215 size_in_pixels = gui_size;
216 n_columns = gui_size.width / csize;
217 n_rows = (
int)gui_size.height / csize;
219 [
self setTitle: gui_title];
221 pixel_row_center = gui_size.width / 2;
222 pixel_row_height = csize;
223 currentRow = n_rows - 1;
226 pixel_row_start = 2.75f * csize + 0.5f * (gui_size.height - n_rows * csize);
228 pixel_row_start = csize + 0.5f * (gui_size.height - n_rows * csize);
230 [rowText removeAllObjects];
231 [rowKey removeAllObjects];
232 [rowColor removeAllObjects];
235 for (i = 0; i < n_rows; i++)
237 [rowText addObject:@""];
238 [rowKey addObject:@""];
240 rowPosition[i].x = 0.0f;
241 rowPosition[i].y = size_in_pixels.height - (pixel_row_start + i * pixel_row_height);
245 pixel_text_size = NSMakeSize(csize, csize);
246 pixel_title_size = NSMakeSize(csize * 1.75f, csize * 1.5f);
248 OOLog(
@"gui.reset",
@"gui %@ reset to rows:%d columns:%d start:%d",
self, n_rows, n_columns, pixel_row_start);
250 rowRange = NSMakeRange(0,n_rows);
257 return size_in_pixels;
275 return pixel_row_height;
281 return pixel_row_start;
291- (void) setTitle:(NSString *)str
296 if ([str length] == 0) str =
nil;
302- (void) setDrawPosition:(Vector) vector
304 drawPosition = vector;
308- (Vector) drawPosition
314- (NSDictionary *) userSettings
316 return guiUserSettings;
322 if (fade_alpha <= 0.0f)
327 fade_sign = -1000.0f;
329 fade_sign = (float)(-fade_alpha / duration);
345- (void) setAlpha:(GLfloat) an_alpha
347 fade_alpha = an_alpha * max_alpha;
351- (void) setMaxAlpha:(GLfloat) an_alpha
353 max_alpha = an_alpha;
357- (void) setBackgroundColor:(
OOColor*) color
359 [backgroundColor release];
360 backgroundColor = [color retain];
371- (void) setTextColor:(
OOColor*) color
375 textColor = [color retain];
381 return textCommsColor;
385- (void) setTextCommsColor:(
OOColor*) color
387 [textCommsColor release];
389 textCommsColor = [color retain];
393- (
OOColor *) colorFromSetting:(NSString *)setting defaultValue:(
OOColor *)def
397 if (setting !=
nil) {
408 return [[col copy] autorelease];
412- (void) setGLColorFromSetting:(NSString *)setting defaultValue:(
OOColor *)def alpha:(GLfloat)alpha
415 OOColor *col = [
self colorFromSetting:setting defaultValue:def];
418 OOGL(glColor4f(r, g, b, a*alpha));
422- (void) setGuiColorSettingFromKey:(NSString *)key color:(
OOColor *)col
424 NSMutableDictionary *guiCopy = [guiUserSettings mutableCopy];
427 [guiCopy removeObjectForKey:key];
431 [guiCopy setObject:col forKey:key];
433 [guiUserSettings release];
434 guiUserSettings = [guiCopy copy];
439- (void) setCharacterSize:(NSSize) character_size
441 pixel_text_size = character_size;
445- (void)setShowAdvancedNavArray:(BOOL)inFlag
447 showAdvancedNavArray = inFlag;
454 [rowColor replaceObjectAtIndex:row withObject:color];
461 return [rowText objectAtIndex:row];
467- (
OOGUIRow) rowForKey:(NSString*)key
469 for (
unsigned i=0;i<[rowKey count];i++)
471 if ([key isEqualToString:[rowKey objectAtIndex:i]])
480- (NSString*) keyForRow:(
OOGUIRow)row
483 return [rowKey objectAtIndex:row];
498- (BOOL) setSelectedRow:(
OOGUIRow)row
500 if ((row == selectedRow)&&
RowInRange(row, selectableRange))
514- (BOOL) setNextRow:(
int) direction
516 OOGUIRow row = selectedRow + direction;
530- (BOOL) setFirstSelectableRow
532 NSUInteger row = selectableRange.location;
547- (BOOL) setLastSelectableRow
549 NSUInteger row = selectableRange.location + selectableRange.length - 1;
564- (void) setNoSelectedRow
570- (NSString *) selectedRowText
572 if ([[rowText objectAtIndex:selectedRow] isKindOfClass:[NSString
class]])
573 return (NSString *)[rowText objectAtIndex:selectedRow];
574 if ([[rowText objectAtIndex:selectedRow] isKindOfClass:[NSArray
class]])
575 return (NSString *)[[rowText objectAtIndex:selectedRow] objectAtIndex:0];
580- (NSString *) selectedRowKey
582 if ((selectedRow < 0)||((
unsigned)selectedRow > [rowKey
count]))
585 return (NSString *)[rowKey objectAtIndex:selectedRow];
589- (void) setShowTextCursor:(BOOL) yesno
591 showTextCursor = yesno;
595- (void) setCurrentRow:(
OOGUIRow) value
597 if ((value < 0)||((
unsigned)value >= n_rows))
609- (NSRange) selectableRange
611 return selectableRange;
615- (void) setSelectableRange:(NSRange) range
617 selectableRange = range;
623 if (stops != NULL) memmove(tabStops, stops,
sizeof tabStops);
626- (void) overrideTabs:(
OOGUITabSettings)stops from:(NSString *)setting length:(NSUInteger)len
628 NSArray *
override = [guiUserSettings oo_arrayForKey:setting defaultValue:nil];
630 if (stops != NULL &&
override !=
nil)
638 stops[i] = [override oo_unsignedIntegerAtIndex:i defaultValue:stops[i]];
646 [
self clearAndKeepBackground:NO];
650- (void) clearAndKeepBackground:(BOOL)keepBackground
653 [
self setTitle: nil];
654 for (i = 0; i < n_rows; i++)
656 [
self setText:@"" forRow:i align:GUI_ALIGN_LEFT];
657 [
self setColor:textColor forRow:i];
659 [
self setKey:GUI_KEY_SKIP forRow:i];
661 rowFadeTime[i] = 0.0f;
663 [
self setShowTextCursor:NO];
664 [
self setSelectableRange:NSMakeRange(0,0)];
665 if (!keepBackground) [
self clearBackground];
669- (void) setKey:(NSString *)str forRow:(
OOGUIRow)row
672 [rowKey replaceObjectAtIndex:row withObject:str];
676- (void) setText:(NSString *)str forRow:(
OOGUIRow)row
680 [rowText replaceObjectAtIndex:row withObject:str];
689 [rowText replaceObjectAtIndex:row withObject:str];
690 rowAlignment[row] = alignment;
695- (
OOGUIRow) addLongText:(NSString *)str
700 if ([str rangeOfString:
@"\n"].location != NSNotFound)
702 NSArray *lines = [str componentsSeparatedByString:@"\n"];
704 for (i = 0; i < [lines count]; i++)
706 row = [
self addLongText:[lines oo_stringAtIndex:i] startingAtRow:row align:alignment];
711 NSSize chSize = pixel_text_size;
713 if (strsize.width < size_in_pixels.width)
715 [
self setText:str forRow:row align:alignment];
721 NSMutableString *string1 = [NSMutableString stringWithCapacity:256];
722 NSMutableString *string2 = [NSMutableString stringWithCapacity:256];
723 strsize.width = 0.0f;
724 while ((strsize.width < size_in_pixels.width)&&([words
count] > 0))
726 [string1 appendString:(NSString *)[words objectAtIndex:0]];
727 [string1 appendString:@" "];
728 [words removeObjectAtIndex:0];
730 if ([words
count] > 0)
731 strsize.width +=
OORectFromString((NSString *)[words objectAtIndex:0], 0.0f, 0.0f, chSize).size.width;
733 [string2 appendString:[words componentsJoinedByString:@" "]];
734 [
self setText:string1 forRow:row align:alignment];
735 return [
self addLongText:string2 startingAtRow:row+1 align:alignment];
1018 texture = TextureForGUITexture(descriptor);
1019 if (texture ==
nil)
return nil;
1021 double specifiedWidth = [descriptor oo_doubleForKey:@"width" defaultValue:-INFINITY];
1022 double specifiedHeight = [descriptor oo_doubleForKey:@"height" defaultValue:-INFINITY];
1023 BOOL haveWidth = isfinite(specifiedWidth);
1024 BOOL haveHeight = isfinite(specifiedHeight);
1026 if (haveWidth && haveHeight)
1029 size.width = specifiedWidth;
1030 size.height = specifiedHeight;
1039 CGFloat ratio = originalDimensions.height / originalDimensions.width;
1040 size.width = specifiedWidth;
1043 else if (haveHeight)
1046 CGFloat ratio = originalDimensions.width / originalDimensions.height;
1047 size.height = specifiedHeight;
1053 size = originalDimensions;
1065 NSDictionary *bgDescriptor =
nil;
1066 OOGalaxyID galaxy_number = [PLAYER galaxyNumber];
1073 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"custom_chart_mission"];
1074 if (bgDescriptor ==
nil)
1076 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart_mission"];
1077 if (bgDescriptor ==
nil)
1079 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart"];
1086 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart_mission"];
1087 if (bgDescriptor ==
nil)
1089 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"short_range_chart"];
1095 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:[NSString stringWithFormat:@"long_range_chart%d_mission", galaxy_number+1]];
1096 if (bgDescriptor ==
nil)
1098 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"long_range_chart_mission"];
1099 if (bgDescriptor ==
nil)
1101 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:[NSString stringWithFormat:@"long_range_chart%d", galaxy_number+1]];
1102 if (bgDescriptor ==
nil)
1104 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"long_range_chart"];
1113 if (bgDescriptor !=
nil)
1115 [
self setBackgroundTextureDescriptor:bgDescriptor];
1118 backgroundSpecial = spec;
1119 [
self refreshStarChart];
1123- (BOOL) setBackgroundTextureDescriptor:(NSDictionary *)descriptor
1125 [backgroundSprite autorelease];
1127 backgroundSprite = NewTextureSpriteWithDescriptor(descriptor);
1128 return backgroundSprite !=
nil;
1132- (BOOL) setForegroundTextureDescriptor:(NSDictionary *)descriptor
1134 [foregroundSprite autorelease];
1135 foregroundSprite = NewTextureSpriteWithDescriptor(descriptor);
1136 return foregroundSprite !=
nil;
1140- (BOOL) setBackgroundTextureKey:(NSString *)key
1142 return [
self setBackgroundTextureDescriptor:[UNIVERSE screenTextureDescriptorForKey:key]];
1146- (BOOL) setForegroundTextureKey:(NSString *)key
1148 return [
self setForegroundTextureDescriptor:[UNIVERSE screenTextureDescriptorForKey:key]];
1152- (BOOL) preloadGUITexture:(NSDictionary *)descriptor
1154 return TextureForGUITexture(descriptor) !=
nil;
1158- (NSDictionary *) textureDescriptorFromJSValue:(jsval)value
1159 inContext:(JSContext *)context
1160 callerDescription:(NSString *)callerDescription
1164 NSDictionary *result =
nil;
1166 if (JSVAL_IS_OBJECT(value))
1169 if (JSVAL_IS_NULL(value))
return [NSDictionary dictionary];
1171 JSObject *objValue = JSVAL_TO_OBJECT(value);
1185 result = [NSDictionary dictionaryWithObject:name forKey:@"name"];
1186 if ([name length] == 0)
return result;
1191 if (result !=
nil && ![
self preloadGUITexture:result])
1193 OOJSReportWarning(context,
@"%@: texture \"%@\
" could not be found.", callerDescription, [result oo_stringForKey:
@"name"]);
1203- (void) setStatusPage:(NSInteger)pageNum
1205 if (pageNum == 0 || (pageNum < 0 && ((NSUInteger)-pageNum) >= statusPage))
1211 statusPage += pageNum;
1216- (NSUInteger) statusPage
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;
1285 [
self setText:@"" forRow:firstRow];
1286 [
self setKey:GUI_KEY_SKIP forRow:firstRow];
1287 [
self setText:@"" forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1288 [
self setKey:GUI_KEY_SKIP forRow:firstRow + STATUS_EQUIPMENT_MAX_ROWS];
1289 [
self setSelectableRange:NSMakeRange(0,0)];
1291 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
1297 [
self setColor:[
self colorFromSetting:kGuiStatusEquipmentScrollColor defaultValue:[
OOColor greenColor]] forRow:firstRow];
1298 [
self setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @" <-- ",nil] forRow:firstRow];
1299 [
self setKey:GUI_KEY_OK forRow:firstRow];
1301 if (statusPage == pageCount)
1303 [
self setSelectableRange:NSMakeRange(firstRow, 1)];
1304 [
self setSelectedRow:firstRow];
1307 if (statusPage < pageCount)
1309 [
self setColor:[
self colorFromSetting:kGuiStatusEquipmentScrollColor defaultValue:[
OOColor greenColor]] forRow:firstRow + maxRows];
1310 [
self setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ",nil] forRow:firstRow + maxRows];
1311 [
self setKey:GUI_KEY_OK forRow:firstRow + maxRows];
1312 if (statusPage == 1)
1314 [
self setSelectableRange:NSMakeRange(firstRow + maxRows, 1)];
1315 [
self setSelectedRow:firstRow + maxRows];
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];
1337 [
self setGLColorFromSetting:@"status_equipment_damaged_color" defaultValue:[
OOColor orangeColor] alpha:1.0];
1341 OOColor *dispCol = [info oo_objectAtIndex:2];
1343 [
self setGLColorFromSetting:@"status_equipment_ok_color" defaultValue:dispCol alpha:1.0];
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));
1358- (void) drawGUIBackground
1360 GLfloat
x = drawPosition.x;
1361 GLfloat
y = drawPosition.y;
1362 GLfloat z = [[UNIVERSE gameView] display_z];
1364 if (backgroundSprite!=
nil)
1366 [backgroundSprite blitBackgroundCentredToX:x Y:y Z:z alpha:1.0f];
1372- (void) refreshStarChart
1378- (
int) drawGUI:(GLfloat) alpha drawCursor:(BOOL) drawCursor
1380 GLfloat
x = drawPosition.x;
1381 GLfloat
y = drawPosition.y;
1382 GLfloat z = [[UNIVERSE gameView] display_z];
1388 [
self drawGLDisplay:x - 0.5f * size_in_pixels.width :y - 0.5f * size_in_pixels.height :z :alpha];
1392 if ([player guiScreen] == GUI_SCREEN_SHORT_RANGE_CHART || [player guiScreen] == GUI_SCREEN_LONG_RANGE_CHART ||
1400 [
self drawStarChart:x - 0.5f * size_in_pixels.width :y - 0.5f * size_in_pixels.height :z :alpha :NO];
1406 [
self drawStarChart:x - 0.5f * size_in_pixels.width :y - 0.5f * size_in_pixels.height :z :alpha :YES];
1408 if ([player guiScreen] == GUI_SCREEN_STATUS)
1412 if ([player guiScreen] == GUI_SCREEN_STICKPROFILE)
1420 fade_alpha += (float)(fade_sign * [
UNIVERSE getTimeDelta]);
1421 if (fade_alpha < 0.05f)
1426 if (fade_alpha >= max_alpha)
1428 fade_alpha = max_alpha;
1438 NSPoint vjpos = [[UNIVERSE gameView] virtualJoystickPosition];
1439 double cursor_x = size_in_pixels.width * vjpos.x;
1440 if (cursor_x < -size_in_pixels.width * 0.5) cursor_x = -size_in_pixels.width * 0.5f;
1441 if (cursor_x > size_in_pixels.width * 0.5) cursor_x = size_in_pixels.width * 0.5f;
1442 double cursor_y = -size_in_pixels.height * vjpos.
y;
1443 if (cursor_y < -size_in_pixels.height * 0.5) cursor_y = -size_in_pixels.height * 0.5f;
1444 if (cursor_y > size_in_pixels.height * 0.5) cursor_y = size_in_pixels.height * 0.5f;
1446 cursor_row = 1 + (float)floor((0.5f * size_in_pixels.height - pixel_row_start - cursor_y) / pixel_row_height);
1450 OOGL(glColor4f(0.6f, 0.6f, 1.0f, 1.0f));
1455 [[UNIVERSE gameView] setVirtualJoystick:cursor_x/size_in_pixels.width :-cursor_y/size_in_pixels.height];
1458 glVertex3f((
float)cursor_x - h1, (
float)cursor_y, z); glVertex3f((
float)cursor_x - h3, (
float)cursor_y, z);
1459 glVertex3f((
float)cursor_x + h1, (
float)cursor_y, z); glVertex3f((
float)cursor_x + h3, (
float)cursor_y, z);
1460 glVertex3f((
float)cursor_x, (
float)cursor_y - h1, z); glVertex3f((
float)cursor_x, (
float)cursor_y - h3, z);
1461 glVertex3f((
float)cursor_x, (
float)cursor_y + h1, z); glVertex3f((
float)cursor_x, (
float)cursor_y + h3, z);
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;
1479 float row_alpha[n_rows];
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))
1548 [
self setGLColorFromSetting:kGuiScreenTitleColor defaultValue:[
OOColor redColor] alpha:alpha];
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);
1594 [
self setGLColorFromSetting:kGuiSelectedRowBackgroundColor defaultValue:[
OOColor redColor] alpha:alpha];
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);
1601 [
self setGLColorFromSetting:kGuiSelectedRowColor defaultValue:[
OOColor blackColor] alpha:alpha];
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]));
1616 [
self setGLColorFromSetting:kGuiTextInputCursorColor defaultValue:[
OOColor redColor] alpha:row_alpha[i]*g_alpha];
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)
1684 [
self setGLColorFromSetting:kGuiSelectedRowBackgroundColor defaultValue:[
OOColor redColor] alpha:alpha];
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);
1691 [
self setGLColorFromSetting:kGuiSelectedRowColor defaultValue:[
OOColor blackColor] alpha:alpha];
1704- (void) drawCrossHairsWithSize:(GLfloat) size x:(GLfloat)x y:(GLfloat)y z:(GLfloat)z
1707 glVertex3f(
x - 1,
y -
size, z);
1708 glVertex3f(
x + 1,
y -
size, z);
1709 glVertex3f(
x + 1,
y +
size, z);
1710 glVertex3f(
x - 1,
y +
size, z);
1711 glVertex3f(
x -
size,
y - 1, z);
1712 glVertex3f(
x +
size,
y - 1, z);
1713 glVertex3f(
x +
size,
y + 1, z);
1714 glVertex3f(
x -
size,
y + 1, z);
1719- (void) setStarChartTitle
1725 NSString *location_key = [NSString stringWithFormat:@"long-range-chart-title-%d-%ld", galaxy_number, (long)system_id];
1726 if ([[
UNIVERSE descriptions] valueForKey:location_key] ==
nil)
1728 NSString *gal_key = [NSString stringWithFormat:@"long-range-chart-title-%d", galaxy_number];
1729 if ([[
UNIVERSE descriptions] valueForKey:gal_key] ==
nil)
1731 [
self setTitle:[NSString stringWithFormat:DESC(@"long-range-chart-title-d"), galaxy_number+1]];
1735 [
self setTitle:[UNIVERSE descriptionForKey:gal_key]];
1740 [
self setTitle:[UNIVERSE descriptionForKey:location_key]];
1745- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOOL)compact
1758 NSPoint info_system_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem: [player
infoSystemID] inGalaxy: [player
galaxyNumber]];
1761 GLfloat r = 1.0, g = 1.0, b = 1.0;
1764 NSUInteger systemParameter;
1766 double fuel = 35.0 * [player
dialFuel];
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++) {
1799 NSDictionary *systemInfo = [systemManager getPropertiesForSystem:i inGalaxy:galaxy_id];
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"]))
1873 nearby_systems[ num_nearby_systems ].gov = -1;
1877 nearby_systems[ num_nearby_systems ].tec = [sys_info oo_intForKey:KEY_TECHLEVEL];
1878 nearby_systems[ num_nearby_systems ].eco = [sys_info oo_intForKey:KEY_ECONOMY];
1879 nearby_systems[ num_nearby_systems ].gov = [sys_info oo_intForKey:KEY_GOVERNMENT];
1881 nearby_systems[ num_nearby_systems ].sysid = i;
1882 nearby_systems[ num_nearby_systems ].p_name = [[sys_info oo_stringForKey:KEY_NAME] retain];
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)
1914 [routeInfo release];
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;
1928 [
self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute: (planetNumber != destNumber ? (id)routeInfo : nil) optimizedBy:advancedNavArrayMode zoom: zoom];
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)
1946 [
self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute:nil optimizedBy:OPTIMIZED_BY_NONE zoom: zoom];
1950 NSPoint targetCoordinates = [systemManager getCoordinatesForSystem:target inGalaxy:galaxy_id];
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])
1976 [
self setGLColorFromSetting:kGuiChartRangeColor defaultValue:[
OOColor greenColor] alpha:alpha];
1978 GLDrawOval(
x + cu.x,
y + cu.y, z, NSMakeSize((
float)(fuel*hscale), 2*(
float)(fuel*vscale)), 5);
1984 [
self setGLColorFromSetting:kGuiChartCrosshairColor defaultValue:[
OOColor greenColor] alpha:alpha];
1986 [
self drawCrossHairsWithSize:12/zoom+2 x:x + cu.x y:y + cu.y z:z];
1991 [
self setGLColorFromSetting:kGuiChartCursorColor defaultValue:[
OOColor redColor] alpha:alpha];
1992 cu = NSMakePoint((
float)(hscale*cursor_coordinates.x+hoffset),(
float)(vscale*cursor_coordinates.y+voffset));
1993 [
self drawCrossHairsWithSize:7/zoom+2 x:x + cu.x y:y + cu.y z:z];
1998 OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha));
2000 for (i = 0; i < num_nearby_systems; i++)
2002 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:i inGalaxy:galaxy_id];
2004 dx = fabs(chart_centre_coordinates.x - sys_coordinates.x);
2005 dy = fabs(chart_centre_coordinates.y - sys_coordinates.y);
2016 NSDictionary *systemInfo = [systemManager getPropertiesForSystem:i inGalaxy:galaxy_id];
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);
2027 NSArray *markers = [markedDestinations objectForKey:[NSNumber numberWithInt:i]];
2030 GLfloat base_size = 0.5f * blob_size + 2.5f;
2031 [
self drawSystemMarkers:markers atX:x+star.x andY:y+star.y andZ:z withAlpha:alpha andScale:base_size];
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;
2046 [
self setGLColorFromSetting:[NSString stringWithFormat:kGuiChartEconomyUColor, (unsigned long)systemParameter]
2053 OOGL(glColor4f(r, g, b, alpha));
2056 case OOLRC_MODE_GOVERNMENT:
2059 systemParameter = nearby_systems[i].gov;
2060 [
self setGLColorFromSetting:[NSString stringWithFormat:kGuiChartGovernmentUColor, (unsigned long)systemParameter]
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];
2113 [
self setGLColorFromSetting:kGuiChartMatchBoxColor defaultValue:[
OOColor greenColor] alpha:alpha];
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;
2142 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:i inGalaxy:galaxy_id];
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;
2162 [
self setGLColorFromSetting:kGuiChartMatchLabelColor defaultValue:[
OOColor cyanColor] alpha:alpha];
2163 OODrawString([
UNIVERSE systemNameIndex:i] ,
x + star.x + 2.0,
y + star.y - 10.0f, z, NSMakeSize(10*systemNameScale,10*systemNameScale));
2164 [
self setGLColorFromSetting:kGuiChartMatchBoxColor defaultValue:[
OOColor greenColor] alpha:alpha];
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;
2192 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:sys->sysid inGalaxy:galaxy_id];
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])
2216 [
self setGLColorFromSetting:kGuiChartLabelReachableColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2220 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2224 OODrawString(sys->p_name,
x + star.x + 2.0,
y + star.y, z, chSize);
2226 else if (
EXPECT(sys->gov >= 0))
2230 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
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;
2248 NSPoint sys_coordinates = [systemManager getCoordinatesForSystem:sys->sysid inGalaxy:galaxy_id];
2250 star.x = (float)(sys_coordinates.x * hscale + hoffset);
2251 star.y = (float)(sys_coordinates.y * vscale + voffset);
2253 if (![player showInfoFlag])
2258 [
self setGLColorFromSetting:kGuiChartLabelReachableColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2262 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2268 else if (sys->gov >= 0)
2272 [
self setGLColorFromSetting:kGuiChartLabelColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2287 [
self overrideTabs:tab_stops from:kGuiChartTraveltimeTabs length:3];
2288 [
self setTabStops:tab_stops];
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];
2309 [
self setArray:[NSArray arrayWithObjects:@"", 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];
2319 [
self setArray:[NSArray array] forRow: textRow + 1];
2322 [targetName release];
2326 [
self setGLColorFromSetting: kGuiChartInfoMarkerColor defaultValue:[
OOColor blueColor] alpha:alpha];
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);
2344- (void) drawSystemMarkers:(NSArray *)markers atX:(GLfloat)x andY:(GLfloat)y andZ:(GLfloat)z withAlpha:(GLfloat)alpha andScale:(GLfloat)scale
2346 NSEnumerator *mEnum;
2347 NSDictionary *marker;
2348 for (mEnum = [markers objectEnumerator]; (marker = [mEnum nextObject]); )
2350 [
self drawSystemMarker:marker atX:x andY:y andZ:z withAlpha:alpha andScale:scale];
2355- (void) drawSystemMarker:(NSDictionary *)marker atX:(GLfloat)x andY:(GLfloat)y andZ:(GLfloat)z withAlpha:(GLfloat)alpha andScale:(GLfloat)scale
2357 NSString *colorDesc = [marker oo_stringForKey:@"markerColor" defaultValue:@"redColor"];
2360 OOGL(glColor4f(color.
r, color.
g, color.
b, alpha));
2361 GLfloat mark_size = [marker oo_floatForKey:@"markerScale" defaultValue:1.0];
2362 if (mark_size > 2.0)
2366 else if (mark_size < 0.5)
2372 NSString *shape = [marker oo_stringForKey:@"markerShape" defaultValue:@"MARKER_X"];
2375 if ([shape isEqualToString:
@"MARKER_X"])
2377 glVertex3f(
x - mark_size,
y - mark_size, z);
2378 glVertex3f(
x + mark_size,
y + mark_size, z);
2379 glVertex3f(
x - mark_size,
y + mark_size, z);
2380 glVertex3f(
x + mark_size,
y - mark_size, z);
2382 else if ([shape isEqualToString:
@"MARKER_PLUS"])
2385 glVertex3f(
x,
y - mark_size, z);
2386 glVertex3f(
x,
y + mark_size, z);
2387 glVertex3f(
x - mark_size,
y, z);
2388 glVertex3f(
x + mark_size,
y, z);
2390 else if ([shape isEqualToString:
@"MARKER_SQUARE"])
2392 glVertex3f(
x - mark_size,
y - mark_size, z);
2393 glVertex3f(
x - mark_size,
y + mark_size, z);
2394 glVertex3f(
x - mark_size,
y + mark_size, z);
2395 glVertex3f(
x + mark_size,
y + mark_size, z);
2396 glVertex3f(
x + mark_size,
y + mark_size, z);
2397 glVertex3f(
x + mark_size,
y - mark_size, z);
2398 glVertex3f(
x + mark_size,
y - mark_size, z);
2399 glVertex3f(
x - mark_size,
y - mark_size, z);
2401 else if ([shape isEqualToString:
@"MARKER_DIAMOND"])
2404 glVertex3f(
x,
y - mark_size, z);
2405 glVertex3f(
x - mark_size,
y, z);
2406 glVertex3f(
x - mark_size,
y, z);
2407 glVertex3f(
x,
y + mark_size, z);
2408 glVertex3f(
x,
y + mark_size, z);
2409 glVertex3f(
x + mark_size,
y, z);
2410 glVertex3f(
x + mark_size,
y, z);
2411 glVertex3f(
x,
y - mark_size, z);
2417- (
OOSystemID) targetNextFoundSystem:(
int)direction
2420 if ([
PLAYER guiScreen] != GUI_SCREEN_SHORT_RANGE_CHART && [
PLAYER guiScreen] != GUI_SCREEN_LONG_RANGE_CHART)
return sys;
2422 BOOL *systemsFound = [UNIVERSE systemsFound];
2423 unsigned i, first = 0, last = 0,
count = 0;
2424 int systemIndex = foundSystem + direction;
2426 if (direction == 0) systemIndex = 0;
2430 if (systemsFound[i])
2440 if (systemIndex == (
int)
count)
2448 if (
count == 0)
return sys;
2451 if (systemIndex < 0)
2453 systemIndex =
count - 1;
2456 if (systemIndex >= (
int)
count)
2462 foundSystem = systemIndex;
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++) {
2492 NSDictionary *systemInfo = [systemManager getPropertiesForSystem:i inGalaxy:g];
2493 concealment[i] = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
2512 starabs = [systemManager getCoordinatesForSystem:i inGalaxy:g];
2514 star.x = (float)(starabs.x * hscale);
2515 star.y = (float)(starabs.y * vscale);
2533 star2abs = [systemManager getCoordinatesForSystem:j inGalaxy:g];
2538 star2.x = (float)(star2abs.x * hscale);
2539 star2.y = (float)(star2abs.y * vscale);
2542 [currentJumpColorStart getRed:&lr green:&lg blue:&lb alpha:&la];
2543 [currentJumpColorEnd getRed:&lr2 green:&lg2 blue:&lb2 alpha:&la2];
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);
2559 thisConnectionColor = [
OOColor colorWithDescription:[systemManager getProperty:@"link_color" forSystemKey:[NSString stringWithFormat:@"interstellar: %d %ld %ld", g, (long)i, (long)j]]];
2561 if (thisConnectionColor ==
nil)
2563 thisConnectionColor = defaultConnectionColor;
2565 [thisConnectionColor getRed:&lr green:&lg blue:&lb alpha:&la];
2566 OOGL(glColor4f(lr, lg, lb, la*alpha));
2568 glVertex3f(
x+star.x,
y+star.y, z);
2571 thatConnectionColor = [
OOColor colorWithDescription:[systemManager getProperty:@"link_color" forSystemKey:[NSString stringWithFormat:@"interstellar: %d %ld %ld", g, (long)j, (long)i]]];
2573 if (thatConnectionColor ==
nil)
2575 thatConnectionColor = thisConnectionColor;
2577 [thatConnectionColor getRed:&lr green:&lg blue:&lb alpha:&la];
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;
2599 [
self setGLColorFromSetting:kGuiChartRouteShortColor defaultValue:[
OOColor yellowColor] alpha:alpha];
2604 [
self setGLColorFromSetting:kGuiChartRouteQuickColor defaultValue:[
OOColor cyanColor] alpha:alpha];
2607 for (i = 0; i < route_hops; i++)
2609 loc = [[routeInfo objectForKey:@"route"] oo_intAtIndex:i];
2610 starabs = [systemManager getCoordinatesForSystem:loc inGalaxy:g];
2611 star2abs = [systemManager getCoordinatesForSystem:[[routeInfo objectForKey:@"route"] oo_intAtIndex:i+1] inGalaxy:g];
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];