tidy up of chart code, remove some double labeling, make zoom in from long range mode switch to short range

This commit is contained in:
Kevin Anthoney 2014-07-20 15:27:27 +01:00
parent c7d7def633
commit 0698ee01f9
8 changed files with 60 additions and 161 deletions

View File

@ -374,8 +374,6 @@ typedef enum
OOMatrix playerRotMatrix;
BOOL showingLongRangeChart;
// For OO-GUI based save screen
NSString *commanderNameString;
NSMutableArray *cdrDetailArray;
@ -877,7 +875,6 @@ typedef enum
- (void) setGuiToSystemDataScreen;
- (NSDictionary *) markedDestinations;
- (void) setGuiToLongRangeChartScreen;
- (void) setGuiToShortRangeChartScreen;
- (void) setGuiToLoadSaveScreen;
- (void) setGuiToGameOptionsScreen;

View File

@ -2922,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:
@ -7502,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];
@ -11360,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

@ -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)
{
@ -1606,7 +1606,6 @@ static NSTimeInterval time_last_frame;
switch (gui_screen)
{
case GUI_SCREEN_SHORT_RANGE_CHART:
case GUI_SCREEN_LONG_RANGE_CHART:
if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
{
@ -1703,22 +1702,12 @@ static NSTimeInterval time_last_frame;
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);
}
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;
}
[gameView resetTypedString];
moving = YES;
}
if ([gameView isDown:gvMouseDoubleClick])
{
[gameView clearMouse];
showingLongRangeChart = (gui_screen == GUI_SCREEN_LONG_RANGE_CHART);
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];
}
@ -1739,13 +1728,19 @@ static NSTimeInterval time_last_frame;
}
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])
{
@ -2825,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
{
@ -2871,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];
}
@ -3292,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];
}
@ -3917,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

@ -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)
{
@ -1576,7 +1575,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
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 );
GUI_ROW_CHART_SYSTEM*MAIN_GUI_ROW_HEIGHT*pixelRatio);
Random_Seed target = [PLAYER target_system_seed];
NSString *targetName = [UNIVERSE getSystemName:target];
@ -1603,7 +1602,6 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
// Caching code submitted by Y A J, 20091022
static Random_Seed saved_galaxy_seed;
static NSPoint saved_centre_coordinates;
static struct saved_system
{
Random_Seed seed;
@ -1613,9 +1611,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
} nearby_systems[ 256 ];
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,30 +1623,23 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
g_seed = [UNIVERSE systemSeedForSystemNumber:i];
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))
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++;
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];
saved_centre_coordinates = chart_centre_coordinates;
}
if (showAdvancedNavArray)
@ -1665,13 +1654,23 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
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];
NSDictionary *routeInfo = [UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode];
// 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
@ -1710,6 +1709,11 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
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;
@ -1828,9 +1832,12 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
if (i == foundIndex || n_matches == 1)
{
if (n_matches == 1) foundSystem = 0;
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));
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));
@ -1850,6 +1857,11 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
{
sys = nearby_systems + i;
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?
@ -2006,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;
@ -2405,8 +2417,11 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
}
}
// 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

@ -191,7 +191,6 @@ void GLDrawBallBillboard(GLfloat radius, GLfloat step, GLfloat z_distance);
*/
void GLDrawOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step);
void GLDrawFilledOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step);
void GLDrawClippedOval(GLfloat x, GLfloat y, GLfloat z, NSSize size, GLfloat step, NSRect clip);
/* GLDrawPoints(), GLDrawFilledPoints()
Draw array of points, as outline and fill respectively.

View File

@ -171,46 +171,6 @@ void GLDrawFilledOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat step)
OOGLEND();
}
void GLDrawClippedOval(GLfloat x, GLfloat y, GLfloat z, NSSize size, GLfloat step, NSRect clip)
{
NSPoint p;
BOOL clipped = YES;
GLfloat ww = 0.5 * size.width;
GLfloat hh = 0.5 * size.height;
GLfloat theta;
GLfloat delta = step * M_PI / 180.0f;
OO_ENTER_OPENGL();
for (theta = 0.0; theta <= 2*M_PI; theta += delta )
{
p.x = x + ww * cos(theta);
p.y = y + hh * sin(theta);
if (p.x >= clip.origin.x && p.x <= clip.origin.x + clip.size.width && p.y >= clip.origin.y && p.y <= clip.origin.y + clip.size.height)
{
if(clipped)
{
OOGLBEGIN(GL_LINE_STRIP);
clipped = NO;
}
glVertex3f(p.x, p.y, z);
}
else
{
if(!clipped)
{
OOGLEND();
clipped = YES;
}
}
}
if(!clipped)
{
OOGLEND();
}
return;
}
void GLDrawPoints(OOGLVector *points, int n)
{
int i;

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)