Merge pull request #99 from OoliteProject/scrolling-chart

Combine long range and short range charts into one zoomable chart
This commit is contained in:
AnotherCommander 2014-07-20 17:26:36 +02:00
commit 57dea06c1f
7 changed files with 528 additions and 275 deletions

View File

@ -97,6 +97,16 @@ typedef enum
OOLRC_MODE_TECHLEVEL = 3
} OOLongRangeChartMode;
#define CHART_WIDTH_AT_MAX_ZOOM 64.0
#define CHART_HEIGHT_AT_MAX_ZOOM 64.0
// Galaxy width / width of chart area at max zoom
#define CHART_MAX_ZOOM (256.0/CHART_WIDTH_AT_MAX_ZOOM)
//start scrolling when cursor is this number of units away from centre
#define CHART_SCROLL_AT_X 20.0
#define CHART_SCROLL_AT_Y 31.0
#define CHART_ZOOM_SHOW_LABELS 2.0
// OO_RESOLUTION_OPTION: true if full screen resolution can be changed.
#if OOLITE_MAC_OS_X && OOLITE_64_BIT
#define OO_RESOLUTION_OPTION 0
@ -138,7 +148,8 @@ enum
GUI_ROW_SCENARIOS_START = 3,
GUI_MAX_ROWS_SCENARIOS = 12,
GUI_ROW_SCENARIOS_DETAIL = GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS + 2,
GUI_ROW_CHART_SYSTEM = 18,
GUI_ROW_PLANET_FINDER = 19
};
#if GUI_FIRST_ROW() < 0
# error Too many items in OPTIONS list!
@ -224,6 +235,12 @@ typedef enum
PLAYER_FLEEING_LIKELY = 3
} OOPlayerFleeingStatus;
typedef enum
{
CHART_MODE_SHORT_RANGE,
CHART_MODE_LONG_RANGE
} OOChartMode;
#define ECM_ENERGY_DRAIN_FACTOR 20.0f
#define ECM_DURATION 2.5f
@ -357,8 +374,6 @@ typedef enum
OOMatrix playerRotMatrix;
BOOL showingLongRangeChart;
// For OO-GUI based save screen
NSString *commanderNameString;
NSMutableArray *cdrDetailArray;
@ -404,6 +419,14 @@ typedef enum
NSPoint cursor_coordinates;
NSPoint chart_centre_coordinates;
// where we want the chart centre to be - used for smooth transitions
NSPoint target_chart_centre;
// 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.
OOScalar chart_zoom;
OOScalar target_chart_zoom;
OOScalar saved_chart_zoom;
OOChartMode chart_mode;
OOTimeDelta witchspaceCountdown;
// player commander data
@ -661,6 +684,8 @@ typedef enum
- (void) setGalaxyCoordinates:(NSPoint)newPosition;
- (NSPoint) cursor_coordinates;
- (NSPoint) chart_centre_coordinates;
- (OOScalar) chart_zoom;
- (NSPoint) chart_centre_for_zoom: (OOScalar) zoom;
- (Random_Seed) system_seed;
- (void) setSystem_seed:(Random_Seed) s_seed;
@ -850,7 +875,6 @@ typedef enum
- (void) setGuiToSystemDataScreen;
- (NSDictionary *) markedDestinations;
- (void) setGuiToLongRangeChartScreen;
- (void) setGuiToShortRangeChartScreen;
- (void) setGuiToLoadSaveScreen;
- (void) setGuiToGameOptionsScreen;

View File

@ -558,11 +558,27 @@ static GLfloat sBaseMass = 0.0;
return cursor_coordinates;
}
- (NSPoint) chart_centre_coordinates
{
return chart_centre_coordinates;
}
- (OOScalar) chart_zoom
{
return chart_zoom;
}
- (NSPoint) chart_centre_for_zoom: (OOScalar) zoom
{
NSPoint p;
p.x = chart_centre_coordinates.x + (128.0 - chart_centre_coordinates.x) * (zoom - 1.0) / (CHART_MAX_ZOOM - 1.0);
p.y = chart_centre_coordinates.y + (128.0 - chart_centre_coordinates.y) * (zoom - 1.0) / (CHART_MAX_ZOOM - 1.0);
return p;
}
- (Random_Seed) system_seed
{
return system_seed;
@ -574,6 +590,7 @@ static GLfloat sBaseMass = 0.0;
system_seed = s_seed;
galaxy_coordinates = NSMakePoint(s_seed.d, s_seed.b);
chart_centre_coordinates = galaxy_coordinates;
target_chart_centre = chart_centre_coordinates;
}
@ -933,7 +950,12 @@ static GLfloat sBaseMass = 0.0;
galaxy_coordinates.x = [coord_vals oo_unsignedCharAtIndex:0];
galaxy_coordinates.y = [coord_vals oo_unsignedCharAtIndex:1];
chart_centre_coordinates = galaxy_coordinates;
target_chart_centre = chart_centre_coordinates;
cursor_coordinates = galaxy_coordinates;
chart_zoom = 1.0;
target_chart_zoom = 1.0;
saved_chart_zoom = 1.0;
chart_mode = CHART_MODE_SHORT_RANGE;
NSString *keyStringValue = [dict oo_stringForKey:@"target_coordinates"];
if (keyStringValue != nil)
@ -1705,7 +1727,13 @@ static GLfloat sBaseMass = 0.0;
market_rnd = 0;
ship_kills = 0;
chart_centre_coordinates = galaxy_coordinates;
target_chart_centre = chart_centre_coordinates;
cursor_coordinates = galaxy_coordinates;
chart_zoom = 1.0;
target_chart_zoom = 1.0;
saved_chart_zoom = 1.0;
chart_mode = CHART_MODE_SHORT_RANGE;
scripted_misjump = NO;
_scriptedMisjumpRange = 0.5;
@ -2894,7 +2922,6 @@ static GLfloat sBaseMass = 0.0;
// case GUI_SCREEN_CONTRACTS:
case GUI_SCREEN_EQUIP_SHIP:
case GUI_SCREEN_INTERFACES:
case GUI_SCREEN_LONG_RANGE_CHART:
case GUI_SCREEN_MANIFEST:
case GUI_SCREEN_SHIPYARD:
case GUI_SCREEN_SHORT_RANGE_CHART:
@ -6382,6 +6409,7 @@ static GLfloat sBaseMass = 0.0;
[[UNIVERSE station] update: 2.34375 * market_rnd]; // from 0..10 minutes
chart_centre_coordinates = galaxy_coordinates;
target_chart_centre = chart_centre_coordinates;
OOProfilerEndMarker(@"witchspace");
}
@ -7473,66 +7501,6 @@ static GLfloat sBaseMass = 0.0;
}
- (void) setGuiToLongRangeChartScreen
{
GuiDisplayGen *gui = [UNIVERSE gui];
OOGUIScreenID oldScreen = gui_screen;
gui_screen = GUI_SCREEN_LONG_RANGE_CHART;
BOOL guiChanged = (oldScreen != gui_screen);
[[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
if ((target_system_seed.d != cursor_coordinates.x)||(target_system_seed.b != cursor_coordinates.y))
target_system_seed = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
NSString *targetSystemName = [[UNIVERSE getSystemName:target_system_seed] retain]; // retained
[UNIVERSE preloadPlanetTexturesForSystem:target_system_seed];
// GUI stuff
{
[gui clearAndKeepBackground:!guiChanged];
NSString *gal_key = [NSString stringWithFormat:@"long-range-chart-title-%d", galaxy_number];
if ([[UNIVERSE descriptions] valueForKey:gal_key] == nil)
{
[gui setTitle:[NSString stringWithFormat:DESC(@"long-range-chart-title-d"), galaxy_number+1]];
}
else
{
[gui setTitle:[UNIVERSE descriptionForKey:gal_key]];
}
NSString *displaySearchString = planetSearchString ? [planetSearchString capitalizedString] : (NSString *)@"";
[gui setText:[NSString stringWithFormat:DESC(@"long-range-chart-find-planet-@"), displaySearchString] forRow:17];
[gui setColor:[OOColor cyanColor] forRow:17];
[gui setShowTextCursor:YES];
[gui setCurrentRow:17];
}
/* ends */
[[UNIVERSE gameView] clearMouse];
[targetSystemName release];
[self setShowDemoShips:NO];
[UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
if (guiChanged)
{
NSDictionary *bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:[NSString stringWithFormat:@"long_range_chart%d", galaxy_number+1]];
if (bgDescriptor == nil) bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"long_range_chart"];
[gui setBackgroundTextureDescriptor:bgDescriptor];
[gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"overlay"];
[UNIVERSE findSystemCoordinatesWithPrefix:[[UNIVERSE getSystemName:found_system_seed] lowercaseString] exactMatch:YES];
[self noteGUIDidChangeFrom:oldScreen to:gui_screen];
}
}
- (void) setGuiToShortRangeChartScreen
{
GuiDisplayGen *gui = [UNIVERSE gui];
@ -7543,40 +7511,48 @@ static GLfloat sBaseMass = 0.0;
[[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
// don't target planets outside the immediate vicinity.
//if ((abs(cursor_coordinates.x-galaxy_coordinates.x)>=20)||(abs(cursor_coordinates.y-galaxy_coordinates.y)>=38))
// cursor_coordinates = galaxy_coordinates; // home
if ((target_system_seed.d != cursor_coordinates.x)||(target_system_seed.b != cursor_coordinates.y))
{
target_system_seed = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
}
// now calculate the distance.
double distance = [self hyperspaceJumpDistance];
double estimatedTravelTime = distance * distance;
NSString *targetSystemName = [[UNIVERSE getSystemName:target_system_seed] retain]; // retained
[UNIVERSE preloadPlanetTexturesForSystem:target_system_seed];
// GUI stuff
{
[gui clearAndKeepBackground:!guiChanged];
[gui setTitle:DESC(@"short-range-chart-title")];
//[gui clearAndKeepBackground:!guiChanged];
NSString *gal_key = [NSString stringWithFormat:@"long-range-chart-title-%d", galaxy_number];
if ([[UNIVERSE descriptions] valueForKey:gal_key] == nil)
{
[gui setTitle:[NSString stringWithFormat:DESC(@"long-range-chart-title-d"), galaxy_number+1]];
}
else
{
[gui setTitle:[UNIVERSE descriptionForKey:gal_key]];
}
// refresh the short range chart cache, in case we've just loaded a save game with different local overrides, etc.
[gui refreshStarChart];
[gui setText:targetSystemName forRow:19];
//[gui setText:targetSystemName forRow:19];
// distance-f & est-travel-time-f are identical between short & long range charts in standard Oolite, however can be alterered separately via OXPs
[gui setText:[NSString stringWithFormat:OOExpandKey(@"short-range-chart-distance-f"), distance] forRow:20];
if ([self hasHyperspaceMotor]) [gui setText:(NSString *)((distance > 0.0 && distance <= (double)fuel/10.0) ? (NSString *)[NSString stringWithFormat:OOExpandKey(@"short-range-chart-est-travel-time-f"), estimatedTravelTime] : (NSString *)@"") forRow:21];
[gui setShowTextCursor:NO];
//[gui setText:[NSString stringWithFormat:OOExpandKey(@"short-range-chart-distance-f"), distance] forRow:20];
//if ([self hasHyperspaceMotor]) [gui setText:(NSString *)((distance > 0.0 && distance <= (double)fuel/10.0) ? (NSString *)[NSString stringWithFormat:OOExpandKey(@"short-range-chart-est-travel-time-f"), estimatedTravelTime] : (NSString *)@"") forRow:21];
if (chart_mode == CHART_MODE_LONG_RANGE)
{
NSString *displaySearchString = planetSearchString ? [planetSearchString capitalizedString] : (NSString *)@"";
[gui setText:[NSString stringWithFormat:DESC(@"long-range-chart-find-planet-@"), displaySearchString] forRow:GUI_ROW_PLANET_FINDER];
[gui setColor:[OOColor cyanColor] forRow:GUI_ROW_PLANET_FINDER];
[gui setShowTextCursor:YES];
[gui setCurrentRow:GUI_ROW_PLANET_FINDER];
}
else
{
[gui setShowTextCursor:NO];
}
}
/* ends */
[[UNIVERSE gameView] clearMouse];
[targetSystemName release]; // released
[self setShowDemoShips:NO];
[UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
@ -11323,7 +11299,6 @@ else _dockTarget = NO_TARGET;
_sysInfoLight.x &&
selFunctionIdx &&
stickFunctions &&
showingLongRangeChart &&
_missionAllowInterrupt &&
_missionScreenID &&
_missionTitle &&

View File

@ -1138,7 +1138,7 @@ for (unsigned i=0;i<amount;i++)
}
dest_name = [contract_info oo_stringForKey:CONTRACT_KEY_DESTINATION_NAME];
[self setGuiToLongRangeChartScreen];
[self setGuiToShortRangeChartScreen];
[UNIVERSE findSystemCoordinatesWithPrefix:[dest_name lowercaseString] exactMatch:YES]; // if dest_name is 'Ra', make sure there's only 1 result.
[self targetNewSystem:1]; // now highlight the 1 result found.
} */

View File

@ -577,7 +577,7 @@ static NSTimeInterval time_last_frame;
MyOpenGLView *gameView = [UNIVERSE gameView];
GameController *gameController = [UNIVERSE gameController];
BOOL onTextEntryScreen = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART) || (gui_screen == GUI_SCREEN_MISSION) || (gui_screen == GUI_SCREEN_SAVE);
BOOL onTextEntryScreen = (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE) || (gui_screen == GUI_SCREEN_MISSION) || (gui_screen == GUI_SCREEN_SAVE);
@try
{
@ -1511,7 +1511,7 @@ static NSTimeInterval time_last_frame;
exceptionContext = @"pause";
// Pause game 'p'
if ([gameView isDown:key_pausebutton] && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION)// look for the 'p' key
if ([gameView isDown:key_pausebutton] && !(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE) && gui_screen != GUI_SCREEN_MISSION)// look for the 'p' key
{
if (!pause_pressed)
{
@ -1580,13 +1580,13 @@ static NSTimeInterval time_last_frame;
{
MyOpenGLView *gameView = [UNIVERSE gameView];
BOOL moving = NO;
double cursor_speed = [gameView isCtrlDown] ? 20.0 : 10.0;
double cursor_speed = ([gameView isCtrlDown] ? 20.0 : 10.0)* chart_zoom;
GameController *controller = [UNIVERSE gameController];
GuiDisplayGen *gui = [UNIVERSE gui];
GUI_ROW_INIT(gui);
// deal with string inputs as necessary
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE)
{
[gameView setStringInput: gvStringInputAlpha];
}
@ -1605,8 +1605,42 @@ static NSTimeInterval time_last_frame;
switch (gui_screen)
{
case GUI_SCREEN_LONG_RANGE_CHART:
cursor_speed *= 2.0;
case GUI_SCREEN_SHORT_RANGE_CHART:
if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
{
if ([[gameView typedString] length] > 0)
{
planetSearchString = [[[gameView typedString] lowercaseString] retain];
NSPoint search_coords = [UNIVERSE findSystemCoordinatesWithPrefix:planetSearchString];
if ((search_coords.x >= 0.0)&&(search_coords.y >= 0.0))
{
// always reset the found system index at the beginning of a new search
if ([planetSearchString length] == 1) [[UNIVERSE gui] targetNextFoundSystem:0];
// Always select the right one out of 2 overlapping systems.
[self targetNewSystem:0 whileTyping:YES];
}
else
{
found_system_seed = kNilRandomSeed;
[self clearPlanetSearchString];
}
}
else
{
if ([gameView isDown:gvDeleteKey]) // did we just delete the string ?
{
found_system_seed = kNilRandomSeed;
[UNIVERSE findSystemCoordinatesWithPrefix:@""];
}
if (planetSearchString) [planetSearchString release];
planetSearchString = nil;
}
moving |= (searchStringLength != [[gameView typedString] length]);
searchStringLength = [[gameView typedString] length];
}
if ([gameView isDown:key_advanced_nav_array]) // '^' key
{
if (!pling_pressed)
@ -1644,44 +1678,8 @@ static NSTimeInterval time_last_frame;
{
queryPressed = NO;
}
if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
{
if ([[gameView typedString] length] > 0)
{
planetSearchString = [[[gameView typedString] lowercaseString] retain];
NSPoint search_coords = [UNIVERSE findSystemCoordinatesWithPrefix:planetSearchString];
if ((search_coords.x >= 0.0)&&(search_coords.y >= 0.0))
{
// always reset the found system index at the beginning of a new search
if ([planetSearchString length] == 1) [[UNIVERSE gui] targetNextFoundSystem:0];
// Always select the right one out of 2 overlapping systems.
[self targetNewSystem:0 whileTyping:YES];
}
else
{
found_system_seed = kNilRandomSeed;
[self clearPlanetSearchString];
}
}
else
{
if ([gameView isDown:gvDeleteKey]) // did we just delete the string ?
{
found_system_seed = kNilRandomSeed;
[UNIVERSE findSystemCoordinatesWithPrefix:@""];
}
if (planetSearchString) [planetSearchString release];
planetSearchString = nil;
}
moving |= (searchStringLength != [[gameView typedString] length]);
searchStringLength = [[gameView typedString] length];
}
case GUI_SCREEN_SHORT_RANGE_CHART:
show_info_flag = ([gameView isDown:key_map_info]);
show_info_flag = ([gameView isDown:key_map_info] && chart_mode != CHART_MODE_LONG_RANGE);
// If we have entered this screen with the injectors key pressed, make sure
// that injectors switch off when we release it - Nikos.
@ -1697,20 +1695,12 @@ static NSTimeInterval time_last_frame;
NSPoint maus = [gameView virtualJoystickPosition];
if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART)
{
double vadjust = 51;
double hscale = MAIN_GUI_PIXEL_WIDTH / 64.0;
double vscale = MAIN_GUI_PIXEL_HEIGHT / 128.0;
cursor_coordinates.x = OOClamp_0_max_f(chart_centre_coordinates.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
cursor_coordinates.y = OOClamp_0_max_f(chart_centre_coordinates.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
}
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
{
double vadjust = 211;
double hadjust = MAIN_GUI_PIXEL_WIDTH / 2.0;
double hscale = MAIN_GUI_PIXEL_WIDTH / 256.0;
double vscale = MAIN_GUI_PIXEL_HEIGHT / 512.0;
cursor_coordinates.x = (maus.x * MAIN_GUI_PIXEL_WIDTH + hadjust)/ hscale;
cursor_coordinates.y = (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale;
double vadjust = 64;
double hscale = MAIN_GUI_PIXEL_WIDTH / (64.0 * chart_zoom);
double vscale = MAIN_GUI_PIXEL_HEIGHT / (128.0 * chart_zoom);
NSPoint centre = [self chart_centre_for_zoom: chart_zoom];
cursor_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
cursor_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
}
[gameView resetTypedString];
moving = YES;
@ -1718,7 +1708,6 @@ static NSTimeInterval time_last_frame;
if ([gameView isDown:gvMouseDoubleClick])
{
[gameView clearMouse];
showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];
}
@ -1726,13 +1715,32 @@ static NSTimeInterval time_last_frame;
{
[gameView resetTypedString];
cursor_coordinates = galaxy_coordinates;
chart_centre_coordinates = galaxy_coordinates;
target_chart_centre = galaxy_coordinates;
found_system_seed = kNilRandomSeed;
[UNIVERSE findSystemCoordinatesWithPrefix:@""];
moving = YES;
}
if ([gameView isDown:gvPageDownKey])
{
target_chart_zoom *=1.02;
if (target_chart_zoom > CHART_MAX_ZOOM) target_chart_zoom = CHART_MAX_ZOOM;
moving = YES;
}
if ([gameView isDown:gvPageUpKey])
{
if (chart_mode == CHART_MODE_LONG_RANGE)
{
chart_mode = CHART_MODE_SHORT_RANGE;
target_chart_zoom = CHART_MAX_ZOOM;
[gui clearAndKeepBackground: YES];
}
target_chart_zoom /= 1.02;
if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
moving = YES;
target_chart_centre = cursor_coordinates;
}
BOOL nextSystem = [gameView isShiftDown] && gui_screen == GUI_SCREEN_LONG_RANGE_CHART;
BOOL nextSystem = [gameView isShiftDown];
if ([gameView isDown:key_gui_arrow_left])
{
@ -1813,23 +1821,25 @@ static NSTimeInterval time_last_frame;
cursor_coordinates.x = target_system_seed.d;
cursor_coordinates.y = target_system_seed.b;
}
if (cursor_coordinates.x - chart_centre_coordinates.x < -19)
if (cursor_coordinates.x - target_chart_centre.x <= -CHART_SCROLL_AT_X*chart_zoom)
{
chart_centre_coordinates.x = cursor_coordinates.x + 19;
target_chart_centre.x = cursor_coordinates.x + CHART_SCROLL_AT_X*chart_zoom;
}
else if (cursor_coordinates.x - chart_centre_coordinates.x > 19)
else if (cursor_coordinates.x - target_chart_centre.x >= CHART_SCROLL_AT_X*chart_zoom)
{
chart_centre_coordinates.x = cursor_coordinates.x - 19;
target_chart_centre.x = cursor_coordinates.x - CHART_SCROLL_AT_X*chart_zoom;
}
if (cursor_coordinates.y - chart_centre_coordinates.y < -37)
if (cursor_coordinates.y - target_chart_centre.y <= -CHART_SCROLL_AT_Y*chart_zoom)
{
chart_centre_coordinates.y = cursor_coordinates.y + 37;
target_chart_centre.y = cursor_coordinates.y + CHART_SCROLL_AT_Y*chart_zoom;
}
else if (cursor_coordinates.y - chart_centre_coordinates.y > 37)
else if (cursor_coordinates.y - target_chart_centre.y >= CHART_SCROLL_AT_Y*chart_zoom)
{
chart_centre_coordinates.y = cursor_coordinates.y - 37;
target_chart_centre.y = cursor_coordinates.y - CHART_SCROLL_AT_Y*chart_zoom;
}
if ((cursor_moving)&&(gui_screen == GUI_SCREEN_LONG_RANGE_CHART)) [self setGuiToLongRangeChartScreen]; // update graphics
chart_centre_coordinates.x = (3.0*chart_centre_coordinates.x + target_chart_centre.x)/4.0;
chart_centre_coordinates.y = (3.0*chart_centre_coordinates.y + target_chart_centre.y)/4.0;
chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0;
if ((cursor_moving)&&(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART)) [self setGuiToShortRangeChartScreen]; // update graphics
cursor_moving = moving;
}
@ -2810,7 +2820,7 @@ static NSTimeInterval time_last_frame;
{
if ([[UNIVERSE gameView] isDown:key_custom_view])
{
if (!customView_pressed && [_customViews count] != 0 && gui_screen != GUI_SCREEN_LONG_RANGE_CHART)
if (!customView_pressed && [_customViews count] != 0 && !(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE))
{
if ([UNIVERSE viewDirection] == VIEW_CUSTOM) // already in custom view mode
{
@ -2856,7 +2866,7 @@ static NSTimeInterval time_last_frame;
const BOOL *joyButtonState = [stickHandler getAllButtonStates];
// view keys
if (([gameView isDown:gvFunctionKey1] || [gameView isDown:key_view_forward]) || (virtualView.y < -view_threshold)||joyButtonState[BUTTON_VIEWFORWARD] || ((([gameView isDown:key_hyperspace] && gui_screen != GUI_SCREEN_LONG_RANGE_CHART) || joyButtonState[BUTTON_HYPERDRIVE]) && [UNIVERSE displayGUI]))
if (([gameView isDown:gvFunctionKey1] || [gameView isDown:key_view_forward]) || (virtualView.y < -view_threshold)||joyButtonState[BUTTON_VIEWFORWARD] || ((([gameView isDown:key_hyperspace] && !(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE)) || joyButtonState[BUTTON_HYPERDRIVE]) && [UNIVERSE displayGUI]))
{
[self switchToThisView:VIEW_FORWARD];
}
@ -3250,10 +3260,22 @@ static NSTimeInterval time_last_frame;
if (!switching_chart_screens)
{
switching_chart_screens = YES;
if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART || (gui_screen == GUI_SCREEN_SYSTEM_DATA && showingLongRangeChart))
[self setGuiToLongRangeChartScreen];
else
[self setGuiToShortRangeChartScreen];
if (gui_screen == GUI_SCREEN_SHORT_RANGE_CHART)
{
if (chart_mode == CHART_MODE_LONG_RANGE)
{
target_chart_zoom = saved_chart_zoom;
chart_mode = CHART_MODE_SHORT_RANGE;
}
else
{
saved_chart_zoom = target_chart_zoom;
target_chart_zoom = CHART_MAX_ZOOM;
chart_mode = CHART_MODE_LONG_RANGE;
}
}
[gui clearAndKeepBackground: YES];
[self setGuiToShortRangeChartScreen];
}
}
else
@ -3265,7 +3287,6 @@ static NSTimeInterval time_last_frame;
{
if (gui_screen != GUI_SCREEN_SYSTEM_DATA)
{
showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];
}
@ -3409,7 +3430,7 @@ static BOOL autopilot_pause;
toggling_music = NO;
}
// look for the pause game, 'p' key
if ([gameView isDown:key_pausebutton] && gui_screen != GUI_SCREEN_LONG_RANGE_CHART && gui_screen != GUI_SCREEN_MISSION)
if ([gameView isDown:key_pausebutton] && !(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE) && gui_screen != GUI_SCREEN_MISSION)
{
if (!autopilot_pause)
{
@ -3457,7 +3478,7 @@ static BOOL autopilot_pause;
{
// Pause game, 'p' key
exceptionContext = @"pause key";
if ([gameView isDown:key_pausebutton] && (gui_screen != GUI_SCREEN_LONG_RANGE_CHART &&
if ([gameView isDown:key_pausebutton] && (!(gui_screen == GUI_SCREEN_SHORT_RANGE_CHART && chart_mode == CHART_MODE_LONG_RANGE) &&
gui_screen != GUI_SCREEN_MISSION && gui_screen != GUI_SCREEN_REPORT &&
gui_screen != GUI_SCREEN_SAVE) )
{
@ -3890,9 +3911,6 @@ static BOOL autopilot_pause;
case GUI_SCREEN_SHORT_RANGE_CHART:
[self setGuiToShortRangeChartScreen];
break;
case GUI_SCREEN_LONG_RANGE_CHART:
[self setGuiToLongRangeChartScreen];
break;
case GUI_SCREEN_SYSTEM_DATA:
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];

View File

@ -55,7 +55,7 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
- (void) drawSystemMarker:(NSDictionary *)marker atX:(GLfloat)x andY:(GLfloat)y andZ:(GLfloat)z withAlpha:(GLfloat)alpha andScale:(GLfloat)scale;
- (void) drawEquipmentList:(NSArray *)eqptList z:(GLfloat)z;
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) route optimizedBy:(OORouteType) optimizeBy;
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) route optimizedBy:(OORouteType) optimizeBy zoom: (OOScalar) zoom;
@end
@ -1241,8 +1241,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
[self drawStarChart:x - 0.5f * size_in_pixels.width :y - 0.5f * size_in_pixels.height :z :alpha];
}
if ([player guiScreen] == GUI_SCREEN_LONG_RANGE_CHART ||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG ||
if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG ||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST ||
backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST)
{
@ -1533,25 +1532,54 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
if (!player)
return;
NSPoint chart_centre_coordinates = [player chart_centre_coordinates];
OOScalar zoom = [player chart_zoom];
NSPoint chart_centre_coordinates = [player chart_centre_for_zoom: zoom];
NSPoint galaxy_coordinates = [player galaxy_coordinates];
NSPoint cursor_coordinates = [player cursor_coordinates];
OOLongRangeChartMode chart_mode = [player longRangeChartMode];
Random_Seed galaxy_seed = [player galaxy_seed];
GLfloat r = 1.0, g = 1.0, b = 1.0;
BOOL noNova;
NSPoint cu;
NSUInteger systemParameter;
double fuel = 35.0 * [player dialFuel];
Random_Seed g_seed;
double hcenter = size_in_pixels.width/2.0;
double vcenter = 160.0f;
double hscale = size_in_pixels.width / 64.0;
double vscale = -size_in_pixels.height / 128.0;
double hscale = size_in_pixels.width / (CHART_WIDTH_AT_MAX_ZOOM*zoom);
double vscale = -size_in_pixels.height / (2*CHART_HEIGHT_AT_MAX_ZOOM*zoom);
double vcenter = 11*MAIN_GUI_ROW_HEIGHT;
double hoffset = hcenter - chart_centre_coordinates.x*hscale;
double voffset = size_in_pixels.height - pixel_title_size.height - 5 - vcenter - chart_centre_coordinates.y*vscale;
double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y*vscale;
int i;
double distance = 0.0, time = 0.0;
NSPoint star;
OOScalar pixelRatio;
NSRect clipRect;
//if ((abs(cursor_coordinates.x-galaxy_coordinates.x)>=20)||(abs(cursor_coordinates.y-centre_coordinates.y)>=38))
// cursor_coordinates = galaxy_coordinates; // home
OORouteType advancedNavArrayMode = OPTIMIZED_BY_NONE;
BOOL routeExists = NO;
BOOL *systemsFound = [UNIVERSE systemsFound];
NSSize viewSize = [[UNIVERSE gameView] viewSize];
double aspect_ratio = viewSize.width / viewSize.height;
if (aspect_ratio > 4.0/3.0)
{
pixelRatio = viewSize.height / 480.0;
}
else
{
pixelRatio = viewSize.width / 640.0;
}
clipRect = NSMakeRect((viewSize.width - size_in_pixels.width*pixelRatio)/2.0,
(viewSize.height + size_in_pixels.height*pixelRatio)/2.0 - (pixel_title_size.height + 15 + (GUI_ROW_CHART_SYSTEM-1)*MAIN_GUI_ROW_HEIGHT) * pixelRatio,
size_in_pixels.width*pixelRatio,
GUI_ROW_CHART_SYSTEM*MAIN_GUI_ROW_HEIGHT*pixelRatio);
Random_Seed target = [PLAYER target_system_seed];
NSString *targetName = [UNIVERSE getSystemName:target];
double dx, dy;
// get a list of systems marked as contract destinations
NSDictionary* markedDestinations = [player markedDestinations];
@ -1564,59 +1592,26 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
// draw fuel range circle
OOGL(glColor4f(0.0f, 1.0f, 0.0f, alpha)); // green
OOGL(GLScaledLineWidth(2.0f));
glEnable(GL_SCISSOR_TEST);
glScissor(clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height);
GLDrawOval(x + cu.x, y + cu.y, z, NSMakeSize((float)(fuel*hscale), 2*(float)(fuel*vscale)), 5);
glDisable(GL_SCISSOR_TEST);
}
// draw marks and stars
//
OOGL(GLScaledLineWidth(1.5f));
OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha)); // pale yellow
for (i = 0; i < 256; i++)
{
g_seed = [UNIVERSE systemSeedForSystemNumber:i];
int dx, dy;
float blob_size = 4.0f + 0.5f * (g_seed.f & 15);
star.x = (float)(g_seed.d * hscale + hoffset);
star.y = (float)(g_seed.b * vscale + voffset);
dx = abs(chart_centre_coordinates.x - g_seed.d);
dy = abs(chart_centre_coordinates.y - g_seed.b);
if ((dx < 20)&&(dy < 38))
{
NSArray *markers = [markedDestinations objectForKey:[NSNumber numberWithInt:i]];
if (markers != nil) // is marked
{
GLfloat base_size = 0.5f * blob_size + 2.5f;
[self drawSystemMarkers:markers atX:x+star.x andY:y+star.y andZ:z withAlpha:alpha andScale:base_size];
OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha)); // pale yellow
}
GLDrawFilledOval(x + star.x, y + star.y, z, NSMakeSize(blob_size,blob_size), 15);
}
}
// draw names
//
// Cache nearby systems so that [UNIVERSE generateSystemData:] does not get called on every frame
// Caching code submitted by Y A J, 20091022
static Random_Seed saved_galaxy_seed;
static NSPoint saved_centre_coordinates;
static struct saved_system
{
int seed_d, seed_b;
Random_Seed seed;
int tec, eco, gov;
NSString* p_name;
BOOL nova;
} nearby_systems[ 256 ];
static int num_nearby_systems;
static int num_nearby_systems = 0;
if ( _refreshStarChart || !equal_seeds( [player galaxy_seed], saved_galaxy_seed ) ||
chart_centre_coordinates.x != saved_centre_coordinates.x ||
chart_centre_coordinates.y != saved_centre_coordinates.y )
if ( _refreshStarChart || !equal_seeds( [player galaxy_seed], saved_galaxy_seed ))
{
// saved systems are stale; recompute
_refreshStarChart = NO;
@ -1627,39 +1622,232 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
for (i = 0; i < 256; i++)
{
g_seed = [UNIVERSE systemSeedForSystemNumber:i];
int dx, dy;
dx = abs(chart_centre_coordinates.x - g_seed.d);
dy = abs(chart_centre_coordinates.y - g_seed.b);
if ((dx < 20)&&(dy < 38))
NSDictionary* sys_info = [UNIVERSE generateSystemData:g_seed];
if (EXPECT_NOT([sys_info oo_boolForKey:@"sun_gone_nova"]))
{
NSDictionary* sys_info = [UNIVERSE generateSystemData:g_seed];
if (EXPECT_NOT([sys_info oo_boolForKey:@"sun_gone_nova"]))
nearby_systems[ num_nearby_systems ].gov = -1; // Flag up nova systems!
}
else
{
nearby_systems[ num_nearby_systems ].tec = [sys_info oo_intForKey:KEY_TECHLEVEL];
nearby_systems[ num_nearby_systems ].eco = [sys_info oo_intForKey:KEY_ECONOMY];
nearby_systems[ num_nearby_systems ].gov = [sys_info oo_intForKey:KEY_GOVERNMENT];
}
nearby_systems[ num_nearby_systems ].seed = g_seed;
nearby_systems[ num_nearby_systems ].p_name = [[sys_info oo_stringForKey:KEY_NAME] retain];
nearby_systems[ num_nearby_systems ].nova = [[UNIVERSE generateSystemData:g_seed] oo_boolForKey:@"sun_gone_nova"];
num_nearby_systems++;
}
saved_galaxy_seed = [player galaxy_seed];
}
if (showAdvancedNavArray)
{
advancedNavArrayMode = [[UNIVERSE gameView] isCtrlDown] ? OPTIMIZED_BY_TIME : OPTIMIZED_BY_JUMPS;
}
else if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST)
{
advancedNavArrayMode = OPTIMIZED_BY_JUMPS;
}
else if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST)
{
advancedNavArrayMode = OPTIMIZED_BY_TIME;
}
OOSystemID savedPlanetNumber = 0;
OOSystemID savedDestNumber = 0;
static NSDictionary *routeInfo = nil;
if (advancedNavArrayMode != OPTIMIZED_BY_NONE && [player hasEquipmentItem:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
{
OOSystemID planetNumber = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
OOSystemID destNumber = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
if (routeInfo == nil || planetNumber != savedPlanetNumber || destNumber != savedDestNumber)
{
[routeInfo release];
routeInfo = [[UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode] retain];
savedPlanetNumber = planetNumber;
savedDestNumber = destNumber;
}
target = [UNIVERSE systemSeedForSystemNumber: destNumber];
// if the ANA has been activated and we are in string input mode (i.e. planet search),
// get out of it so that distance and time data can be displayed
if ([[[UNIVERSE gameView] typedString] length] > 0) [player clearPlanetSearchString];
if (routeInfo) routeExists = YES;
[self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute: (planetNumber != destNumber ? (id)routeInfo : nil) optimizedBy:advancedNavArrayMode zoom: zoom];
if (routeExists)
{
distance = [routeInfo oo_doubleForKey:@"distance"];
time = [routeInfo oo_doubleForKey:@"time"];
}
}
if (!routeExists)
{
target = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
distance = distanceBetweenPlanetPositions(target.d,target.b,galaxy_coordinates.x,galaxy_coordinates.y);
if ([player hasHyperspaceMotor] && distance <= [player fuel]/10.0)
{
time = distance * distance;
}
else
{
time = 0.0;
}
}
// draw marks and stars
//
OOGL(GLScaledLineWidth(1.5f));
OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha)); // pale yellow
for (i = 0; i < num_nearby_systems; i++)
{
g_seed = nearby_systems[i].seed;
dx = fabs(chart_centre_coordinates.x - g_seed.d);
dy = fabs(chart_centre_coordinates.y - g_seed.b);
if ((dx > zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0)||(dy > zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0))
continue;
float blob_size = (4.0f + 0.5f * (g_seed.f & 15))/zoom;
if (blob_size < 0.5) blob_size = 0.5;
star.x = (float)(g_seed.d * hscale + hoffset);
star.y = (float)(g_seed.b * vscale + voffset);
noNova = !nearby_systems[i].nova;
NSAssert1(chart_mode <= OOLRC_MODE_TECHLEVEL, @"Long range chart mode %i out of range", (int)chart_mode);
switch (chart_mode)
{
case OOLRC_MODE_ECONOMY:
if (EXPECT(noNova))
{
nearby_systems[ num_nearby_systems ].gov = -1; // Flag up nova systems!
systemParameter = nearby_systems[i].eco;
r = 0.5;
g = 0.3 + (0.1 * (GLfloat)systemParameter);
b = 1.0 - (0.1 * (GLfloat)systemParameter);
}
else
{
nearby_systems[ num_nearby_systems ].tec = [sys_info oo_intForKey:KEY_TECHLEVEL];
nearby_systems[ num_nearby_systems ].eco = [sys_info oo_intForKey:KEY_ECONOMY];
nearby_systems[ num_nearby_systems ].gov = [sys_info oo_intForKey:KEY_GOVERNMENT];
r = g = b = 0.3;
}
nearby_systems[ num_nearby_systems ].seed_d = g_seed.d;
nearby_systems[ num_nearby_systems ].seed_b = g_seed.b;
nearby_systems[ num_nearby_systems ].p_name = [[sys_info oo_stringForKey:KEY_NAME] retain];
num_nearby_systems++;
}
break;
case OOLRC_MODE_GOVERNMENT:
if (EXPECT(noNova))
{
systemParameter = nearby_systems[i].gov;
r = 1.0 - (0.1 * (GLfloat)systemParameter);
g = 0.3 + (0.1 * (GLfloat)systemParameter);
b = 0.1;
}
else
{
r = g = b = 0.3;
}
break;
case OOLRC_MODE_TECHLEVEL:
if (EXPECT(noNova))
{
systemParameter = nearby_systems[i].tec;
r = 0.6;
g = b = 0.20 + (0.05 * (GLfloat)systemParameter);
}
else
{
r = g = b = 0.3;
}
break;
case OOLRC_MODE_NORMAL:
if (EXPECT(noNova))
{
r = g = b = 1.0;
}
else
{
r = 1.0;
g = 0.2;
b = 0.0;
}
break;
}
saved_galaxy_seed = [player galaxy_seed];
saved_centre_coordinates = chart_centre_coordinates;
OOGL(glColor4f(r, g, b, alpha));
NSArray *markers = [markedDestinations objectForKey:[NSNumber numberWithInt:i]];
if (markers != nil) // is marked
{
GLfloat base_size = 0.5f * blob_size + 2.5f;
[self drawSystemMarkers:markers atX:x+star.x andY:y+star.y andZ:z withAlpha:alpha andScale:base_size];
OOGL(glColor4f(1.0f, 1.0f, 0.75f, alpha)); // pale yellow
}
GLDrawFilledOval(x + star.x, y + star.y, z, NSMakeSize(blob_size,blob_size), 15);
}
OOGL(glColor4f(1.0f, 1.0f, 0.0f, alpha)); // yellow
// draw found stars and captions
//
OOGL(GLScaledLineWidth(1.5f));
OOGL(glColor4f(0.0f, 1.0f, 0.0f, alpha));
int n_matches = 0, foundIndex = -1;
Random_Seed target = [PLAYER target_system_seed];
NSString *targetName = [UNIVERSE getSystemName:target];
for (i = 0; i < 256; i++) if (systemsFound[i])
{
if(foundSystem == n_matches) foundIndex = i;
n_matches++;
}
if (n_matches == 0)
{
foundSystem = 0;
}
else if (backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST || backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST || backgroundSpecial == GUI_BACKGROUND_SPECIAL_LONG)
{
// do nothing at this stage
}
else
{
for (i = 0; i < 256; i++)
{
BOOL mark = systemsFound[i];
float marker_size = 8.0/zoom;
g_seed = [UNIVERSE systemSeedForSystemNumber:i];
dx = fabs(chart_centre_coordinates.x - g_seed.d);
dy = fabs(chart_centre_coordinates.y - g_seed.b);
if (mark && (dx <= zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0)&&(dy <= zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0))
{
star.x = (float)(g_seed.d * hscale + hoffset);
star.y = (float)(g_seed.b * vscale + voffset);
OOGLBEGIN(GL_LINE_LOOP);
glVertex3f(x + star.x - marker_size, y + star.y - marker_size, z);
glVertex3f(x + star.x + marker_size, y + star.y - marker_size, z);
glVertex3f(x + star.x + marker_size, y + star.y + marker_size, z);
glVertex3f(x + star.x - marker_size, y + star.y + marker_size, z);
OOGLEND();
if (i == foundIndex || n_matches == 1)
{
if (n_matches == 1) foundSystem = 0;
if (zoom > CHART_ZOOM_SHOW_LABELS)
{
OOGL(glColor4f(0.0f, 1.0f, 1.0f, alpha));
OODrawString([UNIVERSE systemNameIndex:i] , x + star.x + 2.0, y + star.y - 10.0f, z, NSMakeSize(10,10));
OOGL(glColor4f(0.0f, 1.0f, 0.0f, alpha));
}
}
else if (zoom > CHART_ZOOM_SHOW_LABELS)
OODrawString([UNIVERSE systemNameIndex:i] , x + star.x + 2.0, y + star.y - 10.0f, z, NSMakeSize(10,10));
}
}
}
// draw names
//
OOGL(glColor4f(1.0f, 1.0f, 0.0f, alpha)); // yellow
int targetIdx = -1;
struct saved_system *sys;
@ -1669,31 +1857,39 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
sys = nearby_systems + i;
star.x = (float)(sys->seed_d * hscale + hoffset);
star.y = (float)(sys->seed_b * vscale + voffset);
if (sys->seed_d == target.d && sys->seed_b == target.b // same place as target system?
dx = fabs(chart_centre_coordinates.x - sys->seed.d);
dy = fabs(chart_centre_coordinates.y - sys->seed.b);
if ((dx > zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0)||(dy > zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0))
continue;
star.x = (float)(sys->seed.d * hscale + hoffset);
star.y = (float)(sys->seed.b * vscale + voffset);
if (sys->seed.d == target.d && sys->seed.b == target.b // same place as target system?
&& [sys->p_name isEqualToString:targetName]) // not overlapping twin? (example: Divees & Tezabi in galaxy 5)
{
targetIdx = i; // we have a winner!
}
if (![player showInfoFlag]) // System's name
if (zoom < CHART_ZOOM_SHOW_LABELS)
{
OODrawString(sys->p_name, x + star.x + 2.0, y + star.y, z, chSize);
}
else if (EXPECT(sys->gov >= 0)) // Not a nova? Show the info.
{
OODrawPlanetInfo(sys->gov, sys->eco, sys->tec, x + star.x + 2.0, y + star.y + 2.0, z, chSize);
if (![player showInfoFlag]) // System's name
{
OODrawString(sys->p_name, x + star.x + 2.0, y + star.y, z, chSize);
}
else if (EXPECT(sys->gov >= 0)) // Not a nova? Show the info.
{
OODrawPlanetInfo(sys->gov, sys->eco, sys->tec, x + star.x + 2.0, y + star.y + 2.0, z, chSize);
}
}
}
// highlight the name of the currently selected system
//
if( targetIdx != -1 )
if( targetIdx != -1 && zoom <= CHART_ZOOM_SHOW_LABELS)
{
sys = nearby_systems + targetIdx;
star.x = (float)(sys->seed_d * hscale + hoffset);
star.y = (float)(sys->seed_b * vscale + voffset);
star.x = (float)(sys->seed.d * hscale + hoffset);
star.y = (float)(sys->seed.b * vscale + voffset);
if (![player showInfoFlag])
{
@ -1705,11 +1901,39 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
}
}
OOGUITabSettings tab_stops;
tab_stops[0] = 0;
tab_stops[1] = 96;
tab_stops[2] = 288;
[self setTabStops:tab_stops];
targetName = [[UNIVERSE getSystemName:target] retain];
// distance-f & est-travel-time-f are identical between short & long range charts in standard Oolite, however can be alterered separately via OXPs
NSString *travelDistLine = @"";
if (distance > 0)
{
travelDistLine = [NSString stringWithFormat:OOExpandKey(@"long-range-chart-distance-f"), distance];
}
NSString *travelTimeLine = @"";
if (time > 0)
{
travelTimeLine = [NSString stringWithFormat:OOExpandKey(@"long-range-chart-est-travel-time-f"), time];
}
[self setArray:[NSArray arrayWithObjects:targetName, travelDistLine,travelTimeLine,nil] forRow:GUI_ROW_CHART_SYSTEM];
[targetName release];
// draw crosshairs over current location
//
OOGL(glColor4f(0.0f, 1.0f, 0.0f, alpha)); // green
[self drawCrossHairsWithSize:14 x:x + cu.x y:y + cu.y z:z];
dx = fabs(chart_centre_coordinates.x - galaxy_coordinates.x);
dy = fabs(chart_centre_coordinates.y - galaxy_coordinates.y);
if ((dx <= zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0)&&(dy <= zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0))
{
OOGL(glColor4f(0.0f, 1.0f, 0.0f, alpha)); // green
[self drawCrossHairsWithSize:14 x:x + cu.x y:y + cu.y z:z];
}
// draw crosshairs over cursor
//
OOGL(glColor4f(1.0f, 0.0f, 0.0f, alpha)); // red
@ -1794,7 +2018,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
- (Random_Seed) targetNextFoundSystem:(int)direction // +1 , 0 , -1
{
Random_Seed sys = [PLAYER target_system_seed];
if ([PLAYER guiScreen] != GUI_SCREEN_LONG_RANGE_CHART) return sys;
if ([PLAYER guiScreen] != GUI_SCREEN_SHORT_RANGE_CHART) return sys;
BOOL *systemsFound = [UNIVERSE systemsFound];
unsigned i, first = 0, last = 0, count = 0;
@ -1899,7 +2123,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
if (!routeInfo) routeExists = NO;
[self drawAdvancedNavArrayAtX:x y:y z:z alpha:alpha usingRoute: (planetNumber != destNumber ? (id)routeInfo : nil) optimizedBy:advancedNavArrayMode];
[self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute: (planetNumber != destNumber ? (id)routeInfo : nil) optimizedBy:advancedNavArrayMode zoom: CHART_MAX_ZOOM];
if (routeExists)
{
distance = [routeInfo oo_doubleForKey:@"distance"];
@ -2116,14 +2340,14 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
// 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
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(OORouteType) optimizeBy zoom: (OOScalar) zoom
{
PlayerEntity *player = PLAYER;
Random_Seed g_seed, g_seed2;
NSPoint chart_centre_coordinates = [player chart_centre_for_zoom: zoom];
NSUInteger i, j;
double hscale = size_in_pixels.width / 256.0;
double vscale = -1.0 * size_in_pixels.height / 512.0;
double hoffset = 0.0f;
double voffset = size_in_pixels.height - pixel_title_size.height - 5;
double hscale = size_in_pixels.width / (CHART_WIDTH_AT_MAX_ZOOM*zoom);
double vscale = -1.0 * size_in_pixels.height / (2*CHART_HEIGHT_AT_MAX_ZOOM*zoom);
NSPoint star, star2 = NSZeroPoint;
OOGL(glColor4f(0.25f, 0.25f, 0.25f, alpha));
@ -2133,11 +2357,20 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
g_seed = [UNIVERSE systemSeedForSystemNumber:i];
g_seed2 = [UNIVERSE systemSeedForSystemNumber:j];
double dx, dy;
dx = fabs(chart_centre_coordinates.x - g_seed.d);
dy = fabs(chart_centre_coordinates.y - g_seed.b);
if (dx > zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0 || dy > zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0) continue;
dx = abs(chart_centre_coordinates.x - g_seed2.d);
dy = abs(chart_centre_coordinates.y - g_seed2.b);
if (dx > zoom*CHART_HEIGHT_AT_MAX_ZOOM/2.0 || dy > zoom*CHART_WIDTH_AT_MAX_ZOOM/2.0) continue;
star.x = (float)(g_seed.d * hscale + hoffset);
star.y = (float)(g_seed.b * vscale + voffset);
star2.x = (float)(g_seed2.d * hscale + hoffset);
star2.y = (float)(g_seed2.b * vscale + voffset);
star.x = (float)(g_seed.d * hscale);
star.y = (float)(g_seed.b * vscale);
star2.x = (float)(g_seed2.d * hscale);
star2.y = (float)(g_seed2.b * vscale);
double d = distanceBetweenPlanetPositions(g_seed.d, g_seed.b, g_seed2.d, g_seed2.b);
if (d <= MAX_JUMP_RANGE) // another_commander - Default to 7.0 LY.
@ -2167,22 +2400,28 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
g_seed = [UNIVERSE systemSeedForSystemNumber:loc];
g_seed2 = [UNIVERSE systemSeedForSystemNumber:[[routeInfo objectForKey:@"route"] oo_intAtIndex:(i+1)]];
star.x = (float)(g_seed.d * hscale + hoffset);
star.y = (float)(g_seed.b * vscale + voffset);
star2.x = (float)(g_seed2.d * hscale + hoffset);
star2.y = (float)(g_seed2.b * vscale + voffset);
star.x = (float)(g_seed.d * hscale);
star.y = (float)(g_seed.b * vscale);
star2.x = (float)(g_seed2.d * hscale);
star2.y = (float)(g_seed2.b * vscale);
OOGLBEGIN(GL_LINES);
glVertex3f(x+star.x, y+star.y, z);
glVertex3f(x+star2.x, y+star2.y, z);
OOGLEND();
// Label the route.
OODrawString([UNIVERSE systemNameIndex:loc], x + star.x + 2.0, y + star.y - 8.0, z, NSMakeSize(8,8));
// Label the route, if not already labelled
if (zoom > CHART_ZOOM_SHOW_LABELS)
{
OODrawString([UNIVERSE systemNameIndex:loc], x + star.x + 2.0, y + star.y - 8.0, z, NSMakeSize(8,8));
}
}
// Label the destination, which was not included in the above loop.
loc = [[routeInfo objectForKey:@"route"] oo_intAtIndex:i];
OODrawString([UNIVERSE systemNameIndex:loc], x + star2.x + 2.0, y + star2.y - 10.0, z, NSMakeSize(10,10));
if (zoom > CHART_ZOOM_SHOW_LABELS)
{
loc = [[routeInfo objectForKey:@"route"] oo_intAtIndex:i];
OODrawString([UNIVERSE systemNameIndex:loc], x + star2.x + 2.0, y + star2.y - 10.0, z, NSMakeSize(10,10));
}
}
}

View File

@ -133,8 +133,6 @@ void GLDrawBallBillboard(GLfloat radius, GLfloat step, GLfloat z_distance)
}
static void GLDrawOvalPoints(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step);
static void GLDrawOvalPoints(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
{
GLfloat ww = 0.5 * siz.width;

View File

@ -8,7 +8,6 @@ ENTRY(GUI_SCREEN_STATUS, -1)
ENTRY(GUI_SCREEN_MANIFEST, -1)
ENTRY(GUI_SCREEN_EQUIP_SHIP, -1)
ENTRY(GUI_SCREEN_SHIPYARD, -1)
ENTRY(GUI_SCREEN_LONG_RANGE_CHART, -1)
ENTRY(GUI_SCREEN_SHORT_RANGE_CHART, -1)
ENTRY(GUI_SCREEN_SYSTEM_DATA, -1)
ENTRY(GUI_SCREEN_MARKET, -1)