Merge pull request #186 from OoliteProject/ANA_info

System information facility for all systems on a route.
This commit is contained in:
Kevin Anthoney 2016-04-16 21:27:48 +01:00
commit 63322e6b85
16 changed files with 397 additions and 126 deletions

View File

@ -11,6 +11,7 @@ General:
as a cheat as a cheat
* Atmospheric fog is now applied also with shaders enabled * Atmospheric fog is now applied also with shaders enabled
* Add mobile external view camera * Add mobile external view camera
* Add ability to inspect system information for all systems along ANA route
Expansion pack development: Expansion pack development:
=========================== ===========================

@ -1 +1 @@
Subproject commit 391c76d8ab72094cceb57349ea529166fa73f199 Subproject commit 49b3f7f342ba85c0b7bbbfae8cd1416809ea0f7b

View File

@ -1272,6 +1272,8 @@
"oolite-keydesc-key_docking_music" = "Docking music"; "oolite-keydesc-key_docking_music" = "Docking music";
"oolite-keydesc-key_advanced_nav_array" = "Route planner"; "oolite-keydesc-key_advanced_nav_array" = "Route planner";
"oolite-keydesc-key_next_info_system" = "Next Planet Info";
"oolite-keydesc-key_previous_info_system" = "Previous Planet Info";
"oolite-keydesc-key_map_home" = "Home map"; "oolite-keydesc-key_map_home" = "Home map";
"oolite-keydesc-key_map_info" = "Show chart icons"; "oolite-keydesc-key_map_info" = "Show chart icons";

View File

@ -158,9 +158,12 @@
/* color of location crosshair */ /* color of location crosshair */
// "chart_crosshair_color" = "greenColor"; // "chart_crosshair_color" = "greenColor";
/* color of fuel range circle */ /* color of chart cursor */
// "chart_cursor_color" = "redColor"; // "chart_cursor_color" = "redColor";
/* color of info system marker */
// "chart_info_marker_color" = "blueColor";
/* color of matched system box when name searching */ /* color of matched system box when name searching */
// "chart_match_color" = "greenColor"; // "chart_match_color" = "greenColor";

2
deps/Windows-deps vendored

@ -1 +1 @@
Subproject commit e8f45e81fe5bafe1fb972d940cab11634defff3e Subproject commit fa987fe850f078054d1ef226fda4c811991b5284

View File

@ -361,6 +361,7 @@ typedef enum
@private @private
OOSystemID system_id; OOSystemID system_id;
OOSystemID target_system_id; OOSystemID target_system_id;
OOSystemID info_system_id;
float occlusion_dial; float occlusion_dial;
@ -488,6 +489,7 @@ typedef enum
NSPoint chart_centre_coordinates; NSPoint chart_centre_coordinates;
// where we want the chart centre to be - used for smooth transitions // where we want the chart centre to be - used for smooth transitions
NSPoint target_chart_centre; NSPoint target_chart_centre;
NSPoint target_chart_focus;
// Chart zoom is 1.0 when fully zoomed in and increases as we zoom out. The reason I've done it that way round // Chart zoom is 1.0 when fully zoomed in and increases as we zoom out. The reason I've done it that way round
// is because we might want to implement bigger galaxies one day, and thus may need to zoom out indefinitely. // is because we might want to implement bigger galaxies one day, and thus may need to zoom out indefinitely.
OOScalar chart_zoom; OOScalar chart_zoom;
@ -586,6 +588,8 @@ typedef enum
OOKeyCode key_docking_music; OOKeyCode key_docking_music;
OOKeyCode key_advanced_nav_array; OOKeyCode key_advanced_nav_array;
OOKeyCode key_info_next_system;
OOKeyCode key_info_previous_system;
OOKeyCode key_map_home; OOKeyCode key_map_home;
OOKeyCode key_map_info; OOKeyCode key_map_info;
@ -778,6 +782,13 @@ typedef enum
- (OOSystemID) targetSystemID; - (OOSystemID) targetSystemID;
- (void) setTargetSystemID:(OOSystemID) sid; - (void) setTargetSystemID:(OOSystemID) sid;
- (OOSystemID) nextHopTargetSystemID; - (OOSystemID) nextHopTargetSystemID;
- (OOSystemID) infoSystemID;
- (void) setInfoSystemID: (OOSystemID) sid;
- (void) nextInfoSystem;
- (void) previousInfoSystem;
- (void) homeInfoSystem;
- (void) targetInfoSystem;
- (BOOL) infoSystemOnRoute;
- (NSDictionary *) commanderDataDictionary; - (NSDictionary *) commanderDataDictionary;

View File

@ -691,6 +691,111 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
} }
- (OOSystemID) infoSystemID
{
return info_system_id;
}
- (void) setInfoSystemID: (OOSystemID) sid
{
info_system_id = sid;
}
- (void) nextInfoSystem
{
if (ANA_mode == OPTIMIZED_BY_NONE)
{
info_system_id = target_system_id;
return;
}
NSArray *route = [[[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"] retain];
NSUInteger i;
if (route == nil)
{
info_system_id = target_system_id;
return;
}
for (i = 0; i < [route count]; i++)
{
if ([[route objectAtIndex: i] unsignedIntValue] == info_system_id)
{
if (i + 1 < [route count])
{
info_system_id = [[route objectAtIndex:i + 1] unsignedIntValue];
}
break;
}
}
[route release];
return;
}
- (void) previousInfoSystem
{
if (ANA_mode == OPTIMIZED_BY_NONE)
{
info_system_id = system_id;
return;
}
NSArray *route = [[[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"] retain];
NSUInteger i;
if (route == nil)
{
info_system_id = system_id;
return;
}
for (i = 0; i < [route count]; i++)
{
if ([[route objectAtIndex: i] unsignedIntValue] == info_system_id)
{
if (i > 0)
{
info_system_id = [[route objectAtIndex: i - 1] unsignedIntValue];
}
break;
}
}
[route release];
return;
}
- (void) homeInfoSystem
{
info_system_id = system_id;
return;
}
- (void) targetInfoSystem
{
info_system_id = target_system_id;
return;
}
- (BOOL) infoSystemOnRoute
{
NSArray *route = [[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"];
NSUInteger i;
if (route == nil)
{
return NO;
}
for (i = 0; i < [route count]; i++)
{
if ([[route objectAtIndex: i] unsignedIntValue] == info_system_id)
{
return YES;
}
}
return NO;
}
- (WormholeEntity *) wormhole - (WormholeEntity *) wormhole
{ {
return wormhole; return wormhole;
@ -1055,12 +1160,14 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
target_system_id = [dict oo_intForKey:@"target_id" defaultValue:system_id]; target_system_id = [dict oo_intForKey:@"target_id" defaultValue:system_id];
info_system_id = target_system_id;
coord_vals = ScanTokensFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:target_system_id inGalaxy:galaxy_number]); coord_vals = ScanTokensFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:target_system_id inGalaxy:galaxy_number]);
cursor_coordinates.x = [coord_vals oo_unsignedCharAtIndex:0]; cursor_coordinates.x = [coord_vals oo_unsignedCharAtIndex:0];
cursor_coordinates.y = [coord_vals oo_unsignedCharAtIndex:1]; cursor_coordinates.y = [coord_vals oo_unsignedCharAtIndex:1];
chart_cursor_coordinates = cursor_coordinates; chart_cursor_coordinates = cursor_coordinates;
chart_focus_coordinates = chart_centre_coordinates; chart_focus_coordinates = chart_centre_coordinates;
target_chart_focus = chart_focus_coordinates;
found_system_id = [dict oo_intForKey:@"found_system_id" defaultValue:-1]; found_system_id = [dict oo_intForKey:@"found_system_id" defaultValue:-1];
} }
@ -1092,6 +1199,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
} }
chart_cursor_coordinates = cursor_coordinates; chart_cursor_coordinates = cursor_coordinates;
chart_focus_coordinates = chart_centre_coordinates; chart_focus_coordinates = chart_centre_coordinates;
target_chart_focus = chart_focus_coordinates;
// calculate system ID, target ID // calculate system ID, target ID
if ([dict objectForKey:@"current_system_name"]) if ([dict objectForKey:@"current_system_name"])
@ -1114,6 +1222,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
{ {
target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:YES]; target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:YES];
} }
info_system_id = target_system_id;
found_system_id = -1; found_system_id = -1;
} }
@ -1927,6 +2036,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
cursor_coordinates = galaxy_coordinates; cursor_coordinates = galaxy_coordinates;
chart_cursor_coordinates = cursor_coordinates; chart_cursor_coordinates = cursor_coordinates;
chart_focus_coordinates = cursor_coordinates; chart_focus_coordinates = cursor_coordinates;
target_chart_focus = chart_focus_coordinates;
chart_zoom = 1.0; chart_zoom = 1.0;
target_chart_zoom = 1.0; target_chart_zoom = 1.0;
saved_chart_zoom = 1.0; saved_chart_zoom = 1.0;
@ -2697,6 +2807,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
if (EXPECT_NOT(target_system_id != system_id)) // overridden: we're going to a nearby system! if (EXPECT_NOT(target_system_id != system_id)) // overridden: we're going to a nearby system!
{ {
system_id = target_system_id; system_id = target_system_id;
info_system_id = target_system_id;
[UNIVERSE setSystemTo:system_id]; [UNIVERSE setSystemTo:system_id];
galaxy_coordinates = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:system_id inGalaxy:galaxy_number]); galaxy_coordinates = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:system_id inGalaxy:galaxy_number]);
@ -6165,6 +6276,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
// set up the standard location where the escape pod will dock. // set up the standard location where the escape pod will dock.
target_system_id = system_id; // we're staying in this system target_system_id = system_id; // we're staying in this system
info_system_id = system_id;
[self setDockTarget:[UNIVERSE station]]; // we're docking at the main station, if there is one [self setDockTarget:[UNIVERSE station]]; // we're docking at the main station, if there is one
[self doScriptEvent:OOJSID("shipLaunchedEscapePod") withArgument:escapePod]; // no player.ship properties should be available to script [self doScriptEvent:OOJSID("shipLaunchedEscapePod") withArgument:escapePod]; // no player.ship properties should be available to script
@ -7100,6 +7212,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
break; break;
} }
target_system_id = system_id; target_system_id = system_id;
info_system_id = system_id;
[self setBounty:0 withReason:kOOLegalStatusReasonNewGalaxy]; // let's make a fresh start! [self setBounty:0 withReason:kOOLegalStatusReasonNewGalaxy]; // let's make a fresh start!
cursor_coordinates = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:system_id inGalaxy:galaxy_number]); cursor_coordinates = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:system_id inGalaxy:galaxy_number]);
@ -7903,22 +8016,21 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
- (void) setGuiToSystemDataScreen - (void) setGuiToSystemDataScreen
{ {
NSDictionary *targetSystemData; NSDictionary *infoSystemData;
NSString *targetSystemName; NSString *infoSystemName;
targetSystemData = [[UNIVERSE generateSystemData:target_system_id] retain]; // retained infoSystemData = [[UNIVERSE generateSystemData:info_system_id] retain]; // retained
NSInteger concealment = [targetSystemData oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE]; NSInteger concealment = [infoSystemData oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
infoSystemName = [infoSystemData oo_stringForKey:KEY_NAME];
targetSystemName = [targetSystemData oo_stringForKey:KEY_NAME]; BOOL sunGoneNova = ([infoSystemData oo_boolForKey:@"sun_gone_nova"]);
BOOL sunGoneNova = ([targetSystemData oo_boolForKey:@"sun_gone_nova"]);
OOGUIScreenID oldScreen = gui_screen; OOGUIScreenID oldScreen = gui_screen;
GuiDisplayGen *gui = [UNIVERSE gui]; GuiDisplayGen *gui = [UNIVERSE gui];
gui_screen = GUI_SCREEN_SYSTEM_DATA; gui_screen = GUI_SCREEN_SYSTEM_DATA;
BOOL guiChanged = (oldScreen != gui_screen); BOOL guiChanged = (oldScreen != gui_screen);
Random_Seed targetSystemRandomSeed = [[UNIVERSE systemManager] getRandomSeedForSystem:target_system_id Random_Seed infoSystemRandomSeed = [[UNIVERSE systemManager] getRandomSeedForSystem:info_system_id
inGalaxy:[self galaxyNumber]]; inGalaxy:[self galaxyNumber]];
[[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO]; [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
@ -7932,19 +8044,19 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
[gui overrideTabs:tab_stops from:kGuiSystemdataTabs length:3]; [gui overrideTabs:tab_stops from:kGuiSystemdataTabs length:3];
[gui setTabStops:tab_stops]; [gui setTabStops:tab_stops];
NSUInteger techLevel = [targetSystemData oo_intForKey:KEY_TECHLEVEL] + 1; NSUInteger techLevel = [infoSystemData oo_intForKey:KEY_TECHLEVEL] + 1;
int population = [targetSystemData oo_intForKey:KEY_POPULATION]; int population = [infoSystemData oo_intForKey:KEY_POPULATION];
int productivity = [targetSystemData oo_intForKey:KEY_PRODUCTIVITY]; int productivity = [infoSystemData oo_intForKey:KEY_PRODUCTIVITY];
int radius = [targetSystemData oo_intForKey:KEY_RADIUS]; int radius = [infoSystemData oo_intForKey:KEY_RADIUS];
NSString *government_desc = [targetSystemData oo_stringForKey:KEY_GOVERNMENT_DESC NSString *government_desc = [infoSystemData oo_stringForKey:KEY_GOVERNMENT_DESC
defaultValue:OODisplayStringFromGovernmentID([targetSystemData oo_intForKey:KEY_GOVERNMENT])]; defaultValue:OODisplayStringFromGovernmentID([infoSystemData oo_intForKey:KEY_GOVERNMENT])];
NSString *economy_desc = [targetSystemData oo_stringForKey:KEY_ECONOMY_DESC NSString *economy_desc = [infoSystemData oo_stringForKey:KEY_ECONOMY_DESC
defaultValue:OODisplayStringFromEconomyID([targetSystemData oo_intForKey:KEY_ECONOMY])]; defaultValue:OODisplayStringFromEconomyID([infoSystemData oo_intForKey:KEY_ECONOMY])];
NSString *inhabitants = [targetSystemData oo_stringForKey:KEY_INHABITANTS]; NSString *inhabitants = [infoSystemData oo_stringForKey:KEY_INHABITANTS];
NSString *system_desc = [targetSystemData oo_stringForKey:KEY_DESCRIPTION]; NSString *system_desc = [infoSystemData oo_stringForKey:KEY_DESCRIPTION];
NSString *populationDesc = [targetSystemData oo_stringForKey:KEY_POPULATION_DESC NSString *populationDesc = [infoSystemData oo_stringForKey:KEY_POPULATION_DESC
defaultValue:OOExpandKeyWithSeed(kNilRandomSeed, @"sysdata-pop-value", population, inhabitants)]; defaultValue:OOExpandKeyWithSeed(kNilRandomSeed, @"sysdata-pop-value", population, inhabitants)];
if (sunGoneNova) if (sunGoneNova)
@ -7953,14 +8065,15 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
productivity = 0; productivity = 0;
radius = 0; radius = 0;
techLevel = 0; techLevel = 0;
government_desc = OOExpandKeyWithSeed(targetSystemRandomSeed, @"nova-system-government");
economy_desc = OOExpandKeyWithSeed(targetSystemRandomSeed, @"nova-system-economy"); government_desc = OOExpandKeyWithSeed(infoSystemRandomSeed, @"nova-system-government");
inhabitants = OOExpandKeyWithSeed(targetSystemRandomSeed, @"nova-system-inhabitants"); economy_desc = OOExpandKeyWithSeed(infoSystemRandomSeed, @"nova-system-economy");
inhabitants = OOExpandKeyWithSeed(infoSystemRandomSeed, @"nova-system-inhabitants");
{ {
NSString *system = targetSystemName; NSString *system = infoSystemName;
system_desc = OOExpandKeyWithSeed(targetSystemRandomSeed, @"nova-system-description", system); system_desc = OOExpandKeyWithSeed(infoSystemRandomSeed, @"nova-system-description", system);
} }
populationDesc = OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-pop-value", population, inhabitants); populationDesc = OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-pop-value", population, inhabitants);
} }
@ -7969,68 +8082,48 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
if (concealment < OO_SYSTEMCONCEALMENT_NONAME) if (concealment < OO_SYSTEMCONCEALMENT_NONAME)
{ {
NSString *system = infoSystemName;
NSString *system = targetSystemName; [gui setTitle:OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-data-on-system", system)];
[gui setTitle:OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-data-on-system", system)];
}
else
{
[gui setTitle:OOExpandKey(@"sysdata-data-on-system-no-name")];
}
if (concealment >= OO_SYSTEMCONCEALMENT_NODATA)
{
OOGUIRow i = [gui addLongText:OOExpandKey(@"sysdata-data-on-system-no-data") startingAtRow:15 align:GUI_ALIGN_LEFT];
missionTextRow = i;
for (i-- ; i > 14 ; --i)
{
[gui setColor:[gui colorFromSetting:kGuiSystemdataDescriptionColor defaultValue:[OOColor greenColor]] forRow:i];
}
}
else
{
NSArray *populationDescLines = [populationDesc componentsSeparatedByString:@"\n"]; NSArray *populationDescLines = [populationDesc componentsSeparatedByString:@"\n"];
NSString *populationDesc1 = [populationDescLines objectAtIndex:0]; NSString *populationDesc1 = [populationDescLines objectAtIndex:0];
NSString *populationDesc2 = [populationDescLines lastObject]; NSString *populationDesc2 = [populationDescLines lastObject];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-eco"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-eco"),
economy_desc, economy_desc,
nil] nil]
forRow:1]; forRow:1];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-govt"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-govt"),
government_desc, government_desc,
nil] nil]
forRow:3]; forRow:3];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-tl"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-tl"),
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-tl-value", techLevel), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-tl-value", techLevel),
nil] nil]
forRow:5]; forRow:5];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-pop"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-pop"),
populationDesc1, populationDesc1,
nil] nil]
forRow:7]; forRow:7];
[gui setArray:[NSArray arrayWithObjects:@"", [gui setArray:[NSArray arrayWithObjects:@"",
populationDesc2, populationDesc2,
nil] nil]
forRow:8]; forRow:8];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-prod"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-prod"),
@"", @"",
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-prod-value", productivity), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-prod-value", productivity),
nil] nil]
forRow:10]; forRow:10];
[gui setArray:[NSArray arrayWithObjects: [gui setArray:[NSArray arrayWithObjects:
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-radius"), OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-radius"),
@"", @"",
OOExpandKeyWithSeed(targetSystemRandomSeed, @"sysdata-radius-value", OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-radius-value",
radius), radius),
nil] nil]
forRow:12]; forRow:12];
OOGUIRow i = [gui addLongText:system_desc startingAtRow:15 align:GUI_ALIGN_LEFT]; OOGUIRow i = [gui addLongText:system_desc startingAtRow:15 align:GUI_ALIGN_LEFT];
@ -8045,6 +8138,16 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
[gui setColor:[gui colorFromSetting:kGuiSystemdataFactsColor defaultValue:nil] forRow:i]; [gui setColor:[gui colorFromSetting:kGuiSystemdataFactsColor defaultValue:nil] forRow:i];
} }
} }
else
{
[gui setTitle:OOExpandKey(@"sysdata-data-on-system-no-name")];
OOGUIRow i = [gui addLongText:OOExpandKey(@"sysdata-data-on-system-no-data") startingAtRow:15 align:GUI_ALIGN_LEFT];
missionTextRow = i;
for (i-- ; i > 14 ; --i)
{
[gui setColor:[gui colorFromSetting:kGuiSystemdataDescriptionColor defaultValue:[OOColor greenColor]] forRow:i];
}
}
[gui setShowTextCursor:NO]; [gui setShowTextCursor:NO];
} }
@ -8055,7 +8158,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
[[UNIVERSE gameView] clearMouse]; [[UNIVERSE gameView] clearMouse];
[targetSystemData release]; [infoSystemData release];
[self setShowDemoShips:NO]; [self setShowDemoShips:NO];
[UNIVERSE enterGUIViewModeWithMouseInteraction:NO]; [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
@ -8068,7 +8171,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
RANROTSeed ranrotSavedSeed = RANROTGetFullSeed(); RANROTSeed ranrotSavedSeed = RANROTGetFullSeed();
RNG_Seed saved_seed = currentRandomSeed(); RNG_Seed saved_seed = currentRandomSeed();
if (target_system_id == system_id) if (info_system_id == system_id)
{ {
[self setBackgroundFromDescriptionsKey:@"gui-scene-show-local-planet"]; [self setBackgroundFromDescriptionsKey:@"gui-scene-show-local-planet"];
} }

View File

@ -136,6 +136,10 @@ static BOOL cycleMFD_pressed;
static BOOL switchMFD_pressed; static BOOL switchMFD_pressed;
static BOOL mouse_left_down; static BOOL mouse_left_down;
static BOOL oxz_manager_pressed; static BOOL oxz_manager_pressed;
static BOOL next_planet_info_pressed;
static BOOL previous_planet_info_pressed;
static BOOL home_info_pressed;
static BOOL target_info_pressed;
static NSPoint mouse_click_position; static NSPoint mouse_click_position;
static NSPoint centre_at_mouse_click; static NSPoint centre_at_mouse_click;
@ -489,6 +493,7 @@ static NSTimeInterval time_last_frame;
- (void) targetNewSystem:(int) direction whileTyping:(BOOL) whileTyping - (void) targetNewSystem:(int) direction whileTyping:(BOOL) whileTyping
{ {
target_system_id = [[UNIVERSE gui] targetNextFoundSystem:direction]; target_system_id = [[UNIVERSE gui] targetNextFoundSystem:direction];
info_system_id = target_system_id;
cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number]; cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
found_system_id = target_system_id; found_system_id = target_system_id;
@ -1762,7 +1767,7 @@ static NSTimeInterval time_last_frame;
{ {
queryPressed = NO; queryPressed = NO;
} }
if ([gameView isDown:key_map_info] && chart_zoom <= CHART_ZOOM_SHOW_LABELS) if ([gameView isDown:key_map_info] && chart_zoom <= CHART_ZOOM_SHOW_LABELS)
{ {
if (!chartInfoPressed) if (!chartInfoPressed)
@ -1802,6 +1807,10 @@ static NSTimeInterval time_last_frame;
default: ANA_mode = OPTIMIZED_BY_NONE; break; default: ANA_mode = OPTIMIZED_BY_NONE; break;
} }
} }
if (ANA_mode == OPTIMIZED_BY_NONE || ![self infoSystemOnRoute])
{
info_system_id = target_system_id;
}
} }
pling_pressed = YES; pling_pressed = YES;
} }
@ -1837,6 +1846,7 @@ static NSTimeInterval time_last_frame;
mouse_click_position = maus; mouse_click_position = maus;
chart_focus_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0); chart_focus_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
chart_focus_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0); chart_focus_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
target_chart_focus = chart_focus_coordinates;
} }
if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH > 2 || if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH > 2 ||
fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT > 2) fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT > 2)
@ -1866,20 +1876,32 @@ static NSTimeInterval time_last_frame;
} }
if ([gameView isDown:key_map_home]) if ([gameView isDown:key_map_home])
{ {
[gameView resetTypedString]; if ([gameView isOptDown])
cursor_coordinates = galaxy_coordinates; {
chart_focus_coordinates = cursor_coordinates; [self homeInfoSystem];
target_chart_centre = galaxy_coordinates; target_chart_focus = galaxy_coordinates;
found_system_id = -1; }
[UNIVERSE findSystemCoordinatesWithPrefix:@""]; else
moving = YES; {
[gameView resetTypedString];
cursor_coordinates = galaxy_coordinates;
target_chart_focus = cursor_coordinates;
target_chart_centre = galaxy_coordinates;
found_system_id = -1;
[UNIVERSE findSystemCoordinatesWithPrefix:@""];
moving = YES;
}
}
if ([gameView isDown:gvEndKey] && [gameView isOptDown])
{
[self targetInfoSystem];
target_chart_focus = cursor_coordinates;
} }
if ([gameView isDown:gvPageDownKey] || [gameView mouseWheelState] == gvMouseWheelDown) if ([gameView isDown:gvPageDownKey] || [gameView mouseWheelState] == gvMouseWheelDown)
{ {
target_chart_zoom *= CHART_ZOOM_SPEED_FACTOR; target_chart_zoom *= CHART_ZOOM_SPEED_FACTOR;
if (target_chart_zoom > CHART_MAX_ZOOM) target_chart_zoom = CHART_MAX_ZOOM; if (target_chart_zoom > CHART_MAX_ZOOM) target_chart_zoom = CHART_MAX_ZOOM;
saved_chart_zoom = target_chart_zoom; saved_chart_zoom = target_chart_zoom;
moving = YES;
} }
if ([gameView isDown:gvPageUpKey] || [gameView mouseWheelState] == gvMouseWheelUp) if ([gameView isDown:gvPageUpKey] || [gameView mouseWheelState] == gvMouseWheelUp)
{ {
@ -1892,47 +1914,65 @@ static NSTimeInterval time_last_frame;
target_chart_zoom /= CHART_ZOOM_SPEED_FACTOR; target_chart_zoom /= CHART_ZOOM_SPEED_FACTOR;
if (target_chart_zoom < 1.0) target_chart_zoom = 1.0; if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
saved_chart_zoom = target_chart_zoom; saved_chart_zoom = target_chart_zoom;
moving = YES;
//target_chart_centre = cursor_coordinates; //target_chart_centre = cursor_coordinates;
chart_focus_coordinates = target_chart_centre; target_chart_focus = target_chart_centre;
} }
BOOL nextSystem = [gameView isShiftDown]; BOOL nextSystem = [gameView isShiftDown];
BOOL nextSystemOnRoute = [gameView isOptDown];
if ([gameView isDown:key_gui_arrow_left]) if ([gameView isDown:key_gui_arrow_left])
{ {
if (nextSystem && pressedArrow != key_gui_arrow_left) if ((nextSystem || nextSystemOnRoute) && pressedArrow != key_gui_arrow_left)
{ {
[self targetNewSystem:-1]; if (nextSystem)
{
[self targetNewSystem:-1];
target_chart_focus = cursor_coordinates;
}
else
{
[self previousInfoSystem];
target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
}
pressedArrow = key_gui_arrow_left; pressedArrow = key_gui_arrow_left;
} }
else if (!nextSystem) else if (!nextSystem && !nextSystemOnRoute)
{ {
[gameView resetTypedString]; [gameView resetTypedString];
cursor_coordinates.x -= cursor_speed*delta_t; cursor_coordinates.x -= cursor_speed*delta_t;
if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0; if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0;
moving = YES; moving = YES;
target_chart_focus = cursor_coordinates;
} }
chart_focus_coordinates = cursor_coordinates;
} }
else else
pressedArrow = pressedArrow == key_gui_arrow_left ? 0 : pressedArrow; pressedArrow = pressedArrow == key_gui_arrow_left ? 0 : pressedArrow;
if ([gameView isDown:key_gui_arrow_right]) if ([gameView isDown:key_gui_arrow_right])
{ {
if (nextSystem && pressedArrow != key_gui_arrow_right) if ((nextSystem || nextSystemOnRoute) && pressedArrow != key_gui_arrow_right)
{ {
[self targetNewSystem:+1]; if (nextSystem)
{
[self targetNewSystem:+1];
target_chart_focus = cursor_coordinates;
}
else
{
[self nextInfoSystem];
target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
}
pressedArrow = key_gui_arrow_right; pressedArrow = key_gui_arrow_right;
} }
else if (!nextSystem) else if (!nextSystem && !nextSystemOnRoute)
{ {
[gameView resetTypedString]; [gameView resetTypedString];
cursor_coordinates.x += cursor_speed*delta_t; cursor_coordinates.x += cursor_speed*delta_t;
if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0; if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0;
moving = YES; moving = YES;
target_chart_focus = cursor_coordinates;
} }
chart_focus_coordinates = cursor_coordinates;
} }
else else
pressedArrow = pressedArrow == key_gui_arrow_right ? 0 : pressedArrow; pressedArrow = pressedArrow == key_gui_arrow_right ? 0 : pressedArrow;
@ -1951,7 +1991,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0; if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0;
moving = YES; moving = YES;
} }
chart_focus_coordinates = cursor_coordinates; target_chart_focus = cursor_coordinates;
} }
else else
pressedArrow = pressedArrow == key_gui_arrow_down ? 0 : pressedArrow; pressedArrow = pressedArrow == key_gui_arrow_down ? 0 : pressedArrow;
@ -1970,7 +2010,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0; if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0;
moving = YES; moving = YES;
} }
chart_focus_coordinates = cursor_coordinates; target_chart_focus = cursor_coordinates;
} }
else else
pressedArrow = pressedArrow == key_gui_arrow_up ? 0 : pressedArrow; pressedArrow = pressedArrow == key_gui_arrow_up ? 0 : pressedArrow;
@ -1979,6 +2019,7 @@ static NSTimeInterval time_last_frame;
if (found_system_id == -1) if (found_system_id == -1)
{ {
target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO]; target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
info_system_id = target_system_id;
} }
else else
{ {
@ -1987,6 +2028,7 @@ static NSTimeInterval time_last_frame;
if (fpos.x != cursor_coordinates.x && fpos.y != cursor_coordinates.y) if (fpos.x != cursor_coordinates.x && fpos.y != cursor_coordinates.y)
{ {
target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO]; target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
info_system_id = target_system_id;
} }
} }
cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number]; cursor_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:target_system_id inGalaxy:galaxy_number];
@ -2012,11 +2054,66 @@ static NSTimeInterval time_last_frame;
chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0; chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0;
chart_cursor_coordinates.x = (3.0*chart_cursor_coordinates.x + cursor_coordinates.x)/4.0; chart_cursor_coordinates.x = (3.0*chart_cursor_coordinates.x + cursor_coordinates.x)/4.0;
chart_cursor_coordinates.y = (3.0*chart_cursor_coordinates.y + cursor_coordinates.y)/4.0; chart_cursor_coordinates.y = (3.0*chart_cursor_coordinates.y + cursor_coordinates.y)/4.0;
chart_focus_coordinates.x = (3.0*chart_focus_coordinates.x + target_chart_focus.x)/4.0;
chart_focus_coordinates.y = (3.0*chart_focus_coordinates.y + target_chart_focus.y)/4.0;
if (cursor_moving || dragging) [self setGuiToChartScreenFrom: gui_screen]; // update graphics if (cursor_moving || dragging) [self setGuiToChartScreenFrom: gui_screen]; // update graphics
cursor_moving = moving; cursor_moving = moving;
} }
break;
case GUI_SCREEN_SYSTEM_DATA: case GUI_SCREEN_SYSTEM_DATA:
if ([gameView isDown: key_gui_arrow_right])
{
if (!next_planet_info_pressed)
{
[self nextInfoSystem];
[self setGuiToSystemDataScreen];
next_planet_info_pressed = YES;
}
}
else
{
next_planet_info_pressed = NO;
}
if ([gameView isDown: key_gui_arrow_left])
{
if (!previous_planet_info_pressed)
{
[self previousInfoSystem];
[self setGuiToSystemDataScreen];
previous_planet_info_pressed = YES;
}
}
else
{
previous_planet_info_pressed = NO;
}
if ([gameView isDown: gvHomeKey])
{
if (!home_info_pressed)
{
[self homeInfoSystem];
[self setGuiToSystemDataScreen];
home_info_pressed = YES;
}
}
else
{
home_info_pressed = NO;
}
if ([gameView isDown: gvEndKey])
{
if (!target_info_pressed)
{
[self targetInfoSystem];
[self setGuiToSystemDataScreen];
target_info_pressed = YES;
}
}
else
{
target_info_pressed = NO;
}
break; break;
#if OO_USE_CUSTOM_LOAD_SAVE #if OO_USE_CUSTOM_LOAD_SAVE

View File

@ -2747,13 +2747,13 @@ static int shipsFound;
return NO; // 0........... 1 2 3 return NO; // 0........... 1 2 3
// sunlight position for F7 screen is chosen pseudo randomly from 4 different positions. // sunlight position for F7 screen is chosen pseudo randomly from 4 different positions.
if (target_system_id & 8) if (info_system_id & 8)
{ {
_sysInfoLight = (target_system_id & 2) ? (Vector){ -10000.0, 4000.0, -10000.0 } : (Vector){ -12000.0, -5000.0, -10000.0 }; _sysInfoLight = (info_system_id & 2) ? (Vector){ -10000.0, 4000.0, -10000.0 } : (Vector){ -12000.0, -5000.0, -10000.0 };
} }
else else
{ {
_sysInfoLight = (target_system_id & 2) ? (Vector){ 6000.0, -5000.0, -10000.0 } : (Vector){ 6000.0, 4000.0, -10000.0 }; _sysInfoLight = (info_system_id & 2) ? (Vector){ 6000.0, -5000.0, -10000.0 } : (Vector){ 6000.0, 4000.0, -10000.0 };
} }
[UNIVERSE setMainLightPosition:_sysInfoLight]; // set light origin [UNIVERSE setMainLightPosition:_sysInfoLight]; // set light origin
@ -2766,7 +2766,7 @@ static int shipsFound;
} }
else else
{ {
originalPlanet = [[[OOPlanetEntity alloc] initAsMainPlanetForSystem:target_system_id] autorelease]; originalPlanet = [[[OOPlanetEntity alloc] initAsMainPlanetForSystem:info_system_id] autorelease];
} }
OOPlanetEntity *doppelganger = [originalPlanet miniatureVersion]; OOPlanetEntity *doppelganger = [originalPlanet miniatureVersion];
if (doppelganger == nil) return NO; if (doppelganger == nil) return NO;

View File

@ -117,6 +117,7 @@ static NSString * const kGuiChartLabelReachableColor = @"chart_labelreachable_co
static NSString * const kGuiChartRangeColor = @"chart_range_color"; static NSString * const kGuiChartRangeColor = @"chart_range_color";
static NSString * const kGuiChartCrosshairColor = @"chart_crosshair_color"; static NSString * const kGuiChartCrosshairColor = @"chart_crosshair_color";
static NSString * const kGuiChartCursorColor = @"chart_cursor_color"; static NSString * const kGuiChartCursorColor = @"chart_cursor_color";
static NSString * const kGuiChartInfoMarkerColor = @"chart_info_marker_color";
static NSString * const kGuiChartMatchBoxColor = @"chart_match_box_color"; static NSString * const kGuiChartMatchBoxColor = @"chart_match_box_color";
static NSString * const kGuiChartMatchLabelColor = @"chart_match_label_color"; static NSString * const kGuiChartMatchLabelColor = @"chart_match_label_color";
static NSString * const kGuiChartConnectionColor = @"chart_connection_color"; static NSString * const kGuiChartConnectionColor = @"chart_connection_color";

View File

@ -1660,6 +1660,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
NSPoint chart_centre_coordinates = [player adjusted_chart_centre]; NSPoint chart_centre_coordinates = [player adjusted_chart_centre];
NSPoint galaxy_coordinates = [player galaxy_coordinates]; NSPoint galaxy_coordinates = [player galaxy_coordinates];
NSPoint cursor_coordinates = [player cursor_coordinates]; NSPoint cursor_coordinates = [player cursor_coordinates];
NSPoint info_system_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem: [player infoSystemID] inGalaxy: [player galaxyNumber]];
OOLongRangeChartMode chart_mode = [player longRangeChartMode]; OOLongRangeChartMode chart_mode = [player longRangeChartMode];
OOGalaxyID galaxy_id = [player galaxyNumber]; OOGalaxyID galaxy_id = [player galaxyNumber];
GLfloat r = 1.0, g = 1.0, b = 1.0; GLfloat r = 1.0, g = 1.0, b = 1.0;
@ -2199,6 +2200,12 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
cu = NSMakePoint((float)(hscale*cursor_coordinates.x+hoffset),(float)(vscale*cursor_coordinates.y+voffset)); cu = NSMakePoint((float)(hscale*cursor_coordinates.x+hoffset),(float)(vscale*cursor_coordinates.y+voffset));
[self drawCrossHairsWithSize:7 x:x + cu.x y:y + cu.y z:z]; [self drawCrossHairsWithSize:7 x:x + cu.x y:y + cu.y z:z];
// draw planet info circle
OOGL(GLScaledLineWidth(2.0f));
[self setGLColorFromSetting: kGuiChartInfoMarkerColor defaultValue:[OOColor blueColor] alpha:alpha];
cu = NSMakePoint((float)(hscale*info_system_coordinates.x+hoffset),(float)(vscale*info_system_coordinates.y+voffset));
GLDrawOval(x + cu.x, y + cu.y, z, NSMakeSize(8.0f, 8.0f), 5);
// disable draw clipping // disable draw clipping
OOGL(glDisable(GL_SCISSOR_TEST)); OOGL(glDisable(GL_SCISSOR_TEST));
@ -2336,7 +2343,6 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
} }
// Advanced Navigation Array -- galactic chart route mapping - contributed by Nikos Barkas (another_commander). // Advanced Navigation Array -- galactic chart route mapping - contributed by Nikos Barkas (another_commander).
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(OORouteType) optimizeBy zoom: (OOScalar) zoom - (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(OORouteType) optimizeBy zoom: (OOScalar) zoom
{ {

View File

@ -61,19 +61,6 @@ enum
}; };
@interface OOPlanetTextureGenerator (Private)
- (NSString *) cacheKeyForType:(NSString *)type;
- (OOTextureGenerator *) normalMapGenerator; // Must be called before generator is enqueued for rendering.
- (OOTextureGenerator *) atmosphereGenerator; // Must be called before generator is enqueued for rendering.
#if DEBUG_DUMP_RAW
- (void) dumpNoiseBuffer:(float *)noise;
#endif
@end
/* The planet generator actually generates two textures when shaders are /* The planet generator actually generates two textures when shaders are
active, but the texture loader interface assumes we only load/generate active, but the texture loader interface assumes we only load/generate
one texture per loader. Rather than complicate that, we use a mock one texture per loader. Rather than complicate that, we use a mock
@ -82,6 +69,7 @@ enum
@interface OOPlanetNormalMapGenerator: OOTextureGenerator @interface OOPlanetNormalMapGenerator: OOTextureGenerator
{ {
@private @private
BOOL _enqueued;
NSString *_cacheKey; NSString *_cacheKey;
RANROTSeed _seed; RANROTSeed _seed;
} }
@ -90,6 +78,8 @@ enum
- (void) completeWithData:(void *)data width:(unsigned)width height:(unsigned)height; - (void) completeWithData:(void *)data width:(unsigned)width height:(unsigned)height;
- (BOOL) enqueued;
@end @end
@ -97,6 +87,7 @@ enum
@interface OOPlanetAtmosphereGenerator: OOTextureGenerator @interface OOPlanetAtmosphereGenerator: OOTextureGenerator
{ {
@private @private
BOOL _enqueued;
NSString *_cacheKey; NSString *_cacheKey;
RANROTSeed _seed; RANROTSeed _seed;
OOPlanetTextureGenerator *_parent; OOPlanetTextureGenerator *_parent;
@ -106,6 +97,21 @@ enum
- (void) completeWithData:(void *)data width:(unsigned)width height:(unsigned)height; - (void) completeWithData:(void *)data width:(unsigned)width height:(unsigned)height;
- (BOOL) enqueued;
@end
@interface OOPlanetTextureGenerator (Private)
- (NSString *) cacheKeyForType:(NSString *)type;
- (OOPlanetNormalMapGenerator *) normalMapGenerator; // Must be called before generator is enqueued for rendering.
- (OOPlanetAtmosphereGenerator *) atmosphereGenerator; // Must be called before generator is enqueued for rendering.
#if DEBUG_DUMP_RAW
- (void) dumpNoiseBuffer:(float *)noise;
#endif
@end @end
@ -215,13 +221,13 @@ enum
OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease]; OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease];
if (diffuseGen == nil) return NO; if (diffuseGen == nil) return NO;
OOTextureGenerator *atmoGen = [diffuseGen atmosphereGenerator]; OOPlanetAtmosphereGenerator *atmoGen = [diffuseGen atmosphereGenerator];
if (atmoGen == nil) return NO; if (atmoGen == nil) return NO;
*atmosphere = [OOTexture textureWithGenerator:atmoGen]; *atmosphere = [OOTexture textureWithGenerator:atmoGen];
if (*atmosphere == nil) return NO; if (*atmosphere == nil) return NO;
*texture = [OOTexture textureWithGenerator:diffuseGen]; *texture = [OOTexture textureWithGenerator:diffuseGen enqueue: [atmoGen enqueued]];
return *texture != nil; return *texture != nil;
} }
@ -230,20 +236,23 @@ enum
+ (BOOL) generatePlanetTexture:(OOTexture **)texture secondaryTexture:(OOTexture **)secondaryTexture withInfo:(NSDictionary *)planetInfo + (BOOL) generatePlanetTexture:(OOTexture **)texture secondaryTexture:(OOTexture **)secondaryTexture withInfo:(NSDictionary *)planetInfo
{ {
NSParameterAssert(texture != NULL); NSParameterAssert(texture != NULL);
BOOL enqueue = NO;
OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease]; OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease];
if (diffuseGen == nil) return NO; if (diffuseGen == nil) return NO;
if (secondaryTexture != NULL) if (secondaryTexture != NULL)
{ {
OOTextureGenerator *normalGen = [diffuseGen normalMapGenerator]; OOPlanetNormalMapGenerator *normalGen = [diffuseGen normalMapGenerator];
if (normalGen == nil) return NO; if (normalGen == nil) return NO;
*secondaryTexture = [OOTexture textureWithGenerator:normalGen]; *secondaryTexture = [OOTexture textureWithGenerator:normalGen];
if (*secondaryTexture == nil) return NO; if (*secondaryTexture == nil) return NO;
enqueue = [normalGen enqueued];
} }
*texture = [OOTexture textureWithGenerator:diffuseGen]; *texture = [OOTexture textureWithGenerator:diffuseGen enqueue: enqueue];
return *texture != nil; return *texture != nil;
} }
@ -253,19 +262,22 @@ enum
{ {
NSParameterAssert(texture != NULL); NSParameterAssert(texture != NULL);
BOOL enqueue = NO;
OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease]; OOPlanetTextureGenerator *diffuseGen = [[[self alloc] initWithPlanetInfo:planetInfo] autorelease];
if (diffuseGen == nil) return NO; if (diffuseGen == nil) return NO;
if (secondaryTexture != NULL) if (secondaryTexture != NULL)
{ {
OOTextureGenerator *normalGen = [diffuseGen normalMapGenerator]; OOPlanetNormalMapGenerator *normalGen = [diffuseGen normalMapGenerator];
if (normalGen == nil) return NO; if (normalGen == nil) return NO;
*secondaryTexture = [OOTexture textureWithGenerator:normalGen]; *secondaryTexture = [OOTexture textureWithGenerator:normalGen];
if (*secondaryTexture == nil) return NO; if (*secondaryTexture == nil) return NO;
enqueue = [normalGen enqueued];
} }
OOTextureGenerator *atmoGen = [diffuseGen atmosphereGenerator]; OOPlanetAtmosphereGenerator *atmoGen = [diffuseGen atmosphereGenerator];
if (atmoGen == nil) return NO; if (atmoGen == nil) return NO;
*atmosphere = [OOTexture textureWithGenerator:atmoGen]; *atmosphere = [OOTexture textureWithGenerator:atmoGen];
@ -276,10 +288,11 @@ enum
} }
return NO; return NO;
} }
enqueue = enqueue || [atmoGen enqueued];
OOLog(@"texture.planet.generate",@"Generator %@ has atmosphere %@",diffuseGen,*atmosphere); OOLog(@"texture.planet.generate",@"Generator %@ has atmosphere %@",diffuseGen,*atmosphere);
*texture = [OOTexture textureWithGenerator:diffuseGen]; *texture = [OOTexture textureWithGenerator:diffuseGen enqueue: enqueue];
return *texture != nil; return *texture != nil;
} }
@ -325,7 +338,7 @@ enum
} }
- (OOTextureGenerator *) normalMapGenerator - (OOPlanetNormalMapGenerator *) normalMapGenerator
{ {
if (_nMapGenerator == nil) if (_nMapGenerator == nil)
{ {
@ -335,7 +348,7 @@ enum
} }
- (OOTextureGenerator *) atmosphereGenerator - (OOPlanetAtmosphereGenerator *) atmosphereGenerator
{ {
if (_atmoGenerator == nil) if (_atmoGenerator == nil)
{ {
@ -1178,6 +1191,7 @@ static void SetMixConstants(OOPlanetTextureGeneratorInfo *info, float temperatur
// AllowCubeMap not used yet but might be in future // AllowCubeMap not used yet but might be in future
if ((self = [super initWithPath:[NSString stringWithFormat:@"OOPlanetNormalTexture@%p", self] options:kOOTextureAllowCubeMap])) if ((self = [super initWithPath:[NSString stringWithFormat:@"OOPlanetNormalTexture@%p", self] options:kOOTextureAllowCubeMap]))
{ {
_enqueued = NO;
_cacheKey = [cacheKey copy]; _cacheKey = [cacheKey copy];
_seed = seed; _seed = seed;
} }
@ -1212,10 +1226,17 @@ static void SetMixConstants(OOPlanetTextureGeneratorInfo *info, float temperatur
(The alternative would be for it to block a work thread waiting for (The alternative would be for it to block a work thread waiting for
the real generator to complete, which seemed silly.) the real generator to complete, which seemed silly.)
*/ */
_enqueued = YES;
return YES; return YES;
} }
- (BOOL) enqueued
{
return _enqueued;
}
- (void) loadTexture - (void) loadTexture
{ {
// Do nothing. // Do nothing.
@ -1259,6 +1280,7 @@ static void SetMixConstants(OOPlanetTextureGeneratorInfo *info, float temperatur
_cacheKey = [cacheKey copy]; _cacheKey = [cacheKey copy];
_seed = seed; _seed = seed;
_parent = [parent retain]; _parent = [parent retain];
_enqueued = NO;
} }
return self; return self;
} }
@ -1286,10 +1308,17 @@ static void SetMixConstants(OOPlanetTextureGeneratorInfo *info, float temperatur
- (BOOL) enqueue - (BOOL) enqueue
{ {
_enqueued = YES;
return YES; return YES;
} }
- (BOOL) enqueued
{
return _enqueued;
}
- (void) loadTexture - (void) loadTexture
{ {
// Do nothing. // Do nothing.

View File

@ -169,6 +169,8 @@ typedef OOPixMapFormat OOTextureDataFormat;
*/ */
+ (id) textureWithGenerator:(OOTextureGenerator *)generator; + (id) textureWithGenerator:(OOTextureGenerator *)generator;
// Load a texture from a generator with option to force an enqueue
+ (id) textureWithGenerator:(OOTextureGenerator *)generator enqueue:(BOOL) enqueue;
/* Bind the texture to the current texture unit. /* Bind the texture to the current texture unit.
This will block until loading is completed. This will block until loading is completed.

View File

@ -215,12 +215,18 @@ static NSString *sGlobalTraceContext = nil;
+ (id) textureWithGenerator:(OOTextureGenerator *)generator + (id) textureWithGenerator:(OOTextureGenerator *)generator
{
return [self textureWithGenerator:generator enqueue: NO];
}
+ (id) textureWithGenerator:(OOTextureGenerator *)generator enqueue:(BOOL) enqueue
{ {
if (generator == nil) return nil; if (generator == nil) return nil;
#ifndef OOTEXTURE_NO_CACHE #ifndef OOTEXTURE_NO_CACHE
OOTexture *existing = [OOTexture existingTextureForKey:[generator cacheKey]]; OOTexture *existing = [OOTexture existingTextureForKey:[generator cacheKey]];
if (existing != nil) return [[existing retain] autorelease]; if (existing != nil && !enqueue) return [[existing retain] autorelease];
#endif #endif
if (![generator enqueue]) if (![generator enqueue])

View File

@ -270,7 +270,7 @@ extern int debug;
- (BOOL) isAlphabetKeyDown; - (BOOL) isAlphabetKeyDown;
- (void) supressKeysUntilKeyUp; // DJS - (void) supressKeysUntilKeyUp; // DJS
- (BOOL) isDown: (int) key; - (BOOL) isDown: (int) key;
- (BOOL) isOptDown; - (BOOL) isOptDown; // opt == alt key
- (BOOL) isCtrlDown; - (BOOL) isCtrlDown;
- (BOOL) isCommandDown; - (BOOL) isCommandDown;
- (BOOL) isShiftDown; - (BOOL) isShiftDown;

View File

@ -1836,6 +1836,11 @@ if (shift) { keys[a] = YES; keys[b] = NO; } else { keys[a] = NO; keys[b] = YES;
case SDLK_RCTRL: case SDLK_RCTRL:
ctrl = YES; ctrl = YES;
break; break;
case SDLK_LALT:
case SDLK_RALT:
opt = YES;
break;
case SDLK_F12: case SDLK_F12:
[self toggleScreenMode]; [self toggleScreenMode];
@ -2021,6 +2026,11 @@ keys[a] = NO; keys[b] = NO; \
case SDLK_RCTRL: case SDLK_RCTRL:
ctrl = NO; ctrl = NO;
break; break;
case SDLK_LALT:
case SDLK_RALT:
opt = NO;
break;
case SDLK_ESCAPE: case SDLK_ESCAPE:
keys[27] = NO; keys[27] = NO;