Add the scenarios, fix some bugs

Still some more bugs to fix
This commit is contained in:
cim 2013-12-01 21:57:07 +00:00
parent 6fbcf75363
commit edfd011ecb
8 changed files with 2681 additions and 19 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1746,6 +1746,7 @@ static GLfloat sBaseMass = 0.0;
- (void) completeSetUpAndSetTarget:(BOOL)setTarget
{
[OOSoundSource stopAll];
[self setDockedStation:[UNIVERSE station]];
[self setLastAegisLock:[UNIVERSE planet]];
@ -2004,7 +2005,7 @@ static GLfloat sBaseMass = 0.0;
[self updateTrumbles:delta_t];
OOEntityStatus status = [self status];
if (EXPECT_NOT(status == STATUS_START_GAME && gui_screen != GUI_SCREEN_INTRO1 && gui_screen != GUI_SCREEN_INTRO2 && gui_screen != GUI_SCREEN_NEWGAME))
if (EXPECT_NOT(status == STATUS_START_GAME && gui_screen != GUI_SCREEN_INTRO1 && gui_screen != GUI_SCREEN_INTRO2 && gui_screen != GUI_SCREEN_NEWGAME && gui_screen != GUI_SCREEN_LOAD))
{
UPDATE_STAGE(@"setGuiToIntroFirstGo:");
[self setGuiToIntroFirstGo:YES]; //set up demo mode

View File

@ -1845,7 +1845,7 @@ static NSTimeInterval time_last_frame;
[demoShip release];
demoShip = nil;
[self loadPlayerFromFile:commanderFile];
[self loadPlayerFromFile:commanderFile asNew:NO];
}
break;
}
@ -3491,7 +3491,6 @@ static BOOL autopilot_pause;
{
[[OOMusicController sharedController] stopThemeMusic];
disc_operation_in_progress = YES;
[self setStatus:STATUS_DOCKED];
[UNIVERSE removeDemoShips];
[gui clearBackground];
if (![self loadPlayer])
@ -3509,7 +3508,11 @@ static BOOL autopilot_pause;
else if (([gameView isDown:SDLK_3]))
{
[self setGuiToIntroFirstGo:NO];
}
}
else
{
disc_operation_in_progress = NO;
}
break;
case GUI_SCREEN_INTRO2:
@ -3631,6 +3634,23 @@ static BOOL autopilot_pause;
}
break;
#if OO_USE_CUSTOM_LOAD_SAVE
// DJS: Farm off load/save screen options to LoadSave.m
case GUI_SCREEN_LOAD:
{
NSString *commanderFile = [self commanderSelector];
if(commanderFile)
{
// also release the demo ship here (see showShipyardModel and noteGUIDidChangeFrom)
[demoShip release];
demoShip = nil;
[self loadPlayerFromFile:commanderFile asNew:NO];
}
break;
}
#endif
default:
break;
}

View File

@ -81,7 +81,7 @@ MA 02110-1301, USA.
#endif
- (BOOL) loadPlayerFromFile:(NSString *)fileToOpen;
- (BOOL) loadPlayerFromFile:(NSString *)fileToOpen asNew:(BOOL)asNew;
@end

View File

@ -322,7 +322,13 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
OOLog(@"scenario.init.error",@"Game file not found for scenario %@",file);
return NO;
}
return [self loadPlayerFromFile:path];
BOOL result = [self loadPlayerFromFile:path asNew:YES];
if (!result)
{
return NO;
}
// don't drop the save game directory in
return YES;
}
@ -571,7 +577,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
#endif
- (BOOL) loadPlayerFromFile:(NSString *)fileToOpen
- (BOOL) loadPlayerFromFile:(NSString *)fileToOpen asNew:(BOOL)asNew
{
/* TODO: it would probably be better to load by creating a new
PlayerEntity, verifying that's OK, then replacing the global player.
@ -657,11 +663,14 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
if (loadedOK)
{
[save_path autorelease];
save_path = [fileToOpen retain];
if (!asNew)
{
[save_path autorelease];
save_path = [fileToOpen retain];
[[[UNIVERSE gameView] gameController] setPlayerFileToLoad:fileToOpen];
[[[UNIVERSE gameView] gameController] setPlayerFileDirectory:fileToOpen];
[[[UNIVERSE gameView] gameController] setPlayerFileToLoad:fileToOpen];
[[[UNIVERSE gameView] gameController] setPlayerFileDirectory:fileToOpen];
}
}
else
{
@ -761,7 +770,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
NSURL *url = oPanel.URL;
if (url.isFileURL)
{
return [self loadPlayerFromFile:url.path];
return [self loadPlayerFromFile:url.path asNew:NO];
}
}

View File

@ -273,7 +273,7 @@ static GameController *sSharedController = nil;
if (playerFileToLoad != nil)
{
[self logProgress:DESC(@"loading-player")];
[PLAYER loadPlayerFromFile:playerFileToLoad];
[PLAYER loadPlayerFromFile:playerFileToLoad asNew:NO];
}
}

View File

@ -2673,13 +2673,13 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
- (void) handleGameOver
{
if ([[self gameController] playerFileToLoad])
if ([[self gameController] playerFileToLoad])
{
[[self gameController] loadPlayerIfRequired];
}
else
{
[self reinitAndShowDemo:NO];
[self reinitAndShowDemo:YES];
}
}
@ -9801,7 +9801,9 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
_sessionID++; // Must be after removing old entities and before adding new ones.
[ResourceManager setUseAddOns:!strict]; // also logs the paths
// demo must not be in strict mode, or you can't load scenarios
// from OXPs if your last game was strict
[ResourceManager setUseAddOns:(!strict || showDemo)]; // also logs the paths
//[ResourceManager loadScripts]; // initialised inside [player setUp]!
// NOTE: Anything in the sharedCache is now trashed and must be
@ -9856,7 +9858,6 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
if(showDemo)
{
[player setGuiToIntroFirstGo:YES];
[player setStatus:STATUS_START_GAME];
}
else
@ -9865,9 +9866,18 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
}
[player completeSetUp];
[self populateNormalSpace];
if(showDemo)
{
[player setGuiToIntroFirstGo:YES];
}
else
{
// no need to do these if showing the demo as the only way out
// now is to load a game
[self populateNormalSpace];
[player startUpComplete];
[player startUpComplete];
}
if(!showDemo)
{