Scenario loading screen

(unfinished: scenarios not yet present)
master
cim 2013-12-01 18:29:08 +00:00
parent 4dc16316af
commit 6fbcf75363
11 changed files with 241 additions and 15 deletions

View File

@ -33,6 +33,7 @@ after-all::
$(CP) $(CP_FLAGS) Resources/InfoPlist.strings $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/AIs $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/Config $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/Scenarios $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/Scripts $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/Shaders $(PROGDIR)/Resources
$(CP) $(CP_FLAGS) Resources/Binary/Images $(PROGDIR)/Resources

View File

@ -1014,9 +1014,20 @@
"oolite-start-option-3" = "3. View ship library";
"oolite-start-option-4" = "4. Manage expansion packs"; // not yet used
"oolite-newgame-title" = "New Game";
"oolite-ship-library-title" = "Ship Library";
"oolite-ship-library-exit" = "Press space to exit ship library";
"oolite-scenario-standard-name" = "Normal start";
"oolite-scenario-strict-name" = "Strict game";
"oolite-scenario-tutorial-name" = "Tutorial";
"oolite-scenario-standard-description" = "Start with a Cobra Mk III and 100 credits at Lave station, and try to make a living.";
"oolite-scenario-strict-description" = "Like the normal start, but all expansion packs are disabled for this save game.";
"oolite-scenario-tutorial-description" = "Take a standard Cooperative flight training course, including simulated combat and docking practice.";
// Loading screen (currently Mac only), also logged under start.progress
"loading-ships" = "Loading ship data";
"populating-space" = "Populating space";

View File

@ -0,0 +1,20 @@
(
{
"file" = "oolite-standard.oolite-save";
"name" = "[oolite-scenario-standard-name]";
"description" = "[oolite-scenario-standard-description]";
"model" = "cobra3-trader";
},
{
"file" = "oolite-tutorial.oolite-save";
"name" = "[oolite-scenario-tutorial-name]";
"description" = "[oolite-scenario-tutorial-description]";
"model" = "coriolis-station";
},
{
"file" = "oolite-strict.oolite-save";
"name" = "[oolite-scenario-strict-name]";
"description" = "[oolite-scenario-strict-description]";
"model" = "cobra3-trader";
}
)

View File

@ -126,11 +126,14 @@ enum
GUI_ROW_MARKET_KEY = 1,
GUI_ROW_MARKET_START = 2,
GUI_ROW_MARKET_CASH = 20,
GUI_ROW_INTERFACES_HEADING = 1,
GUI_ROW_INTERFACES_START = 3,
GUI_ROW_INTERFACES_HEADING = 1,
GUI_ROW_INTERFACES_START = 3,
GUI_MAX_ROWS_INTERFACES = 12,
GUI_ROW_INTERFACES_DETAIL = GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES + 1,
GUI_ROW_NO_INTERFACES = 3
GUI_ROW_NO_INTERFACES = 3,
GUI_ROW_SCENARIOS_START = 3,
GUI_MAX_ROWS_SCENARIOS = 12,
GUI_ROW_SCENARIOS_DETAIL = GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS + 2,
};
#if GUI_FIRST_ROW() < 0

View File

@ -2004,7 +2004,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))
if (EXPECT_NOT(status == STATUS_START_GAME && gui_screen != GUI_SCREEN_INTRO1 && gui_screen != GUI_SCREEN_INTRO2 && gui_screen != GUI_SCREEN_NEWGAME))
{
UPDATE_STAGE(@"setGuiToIntroFirstGo:");
[self setGuiToIntroFirstGo:YES]; //set up demo mode
@ -2608,6 +2608,7 @@ static GLfloat sBaseMass = 0.0;
case GUI_SCREEN_MAIN:
case GUI_SCREEN_INTRO1:
case GUI_SCREEN_INTRO2:
case GUI_SCREEN_NEWGAME:
case GUI_SCREEN_MARKET:
case GUI_SCREEN_OPTIONS:
case GUI_SCREEN_GAMEOPTIONS:
@ -8116,6 +8117,7 @@ static NSString *last_outfitting_key=nil;
if (justCobra)
{
[UNIVERSE removeDemoShips];
[[OOCacheManager sharedCache] flush]; // At first startup, a lot of stuff is cached
}
[gui clear];

View File

@ -3498,19 +3498,15 @@ static BOOL autopilot_pause;
{
[self setGuiToIntroFirstGo:YES];
}
break;
}
}
if (([gameView isDown:SDLK_1]))
{
[self setStatus: STATUS_DOCKED];
[UNIVERSE removeDemoShips];
[gui clearBackground];
[[OOMusicController sharedController] stopThemeMusic];
[[UNIVERSE gameView] supressKeysUntilKeyUp]; // to prevent a missionscreen on the first page from reacting on this keypress.
[self setGuiToStatusScreen];
[self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")]; // trigger missionScreenOpportunity immediately after (re)start
}
if (([gameView isDown:SDLK_3]))
missionTextRow = 0;
[self setGuiToScenarioScreen];
}
else if (([gameView isDown:SDLK_3]))
{
[self setGuiToIntroFirstGo:NO];
}
@ -3519,7 +3515,6 @@ static BOOL autopilot_pause;
case GUI_SCREEN_INTRO2:
if ([gameView isDown:' ']) // '<space>'
{
[UNIVERSE removeDemoShips];
[self setGuiToIntroFirstGo:YES];
}
if ([gameView isDown:key_gui_arrow_left]) // '<--'
@ -3534,7 +3529,33 @@ static BOOL autopilot_pause;
}
upDownKeyPressed = (([gameView isDown:key_gui_arrow_left])||([gameView isDown:key_gui_arrow_right]));
break;
case GUI_SCREEN_NEWGAME:
if ([gameView isDown:13]) // enter
{
if (![self startScenario])
{
[self setGuiToIntroFirstGo:YES];
}
}
if ([gameView isDown:key_gui_arrow_down]) // '<--'
{
if (!upDownKeyPressed)
{
[self selectScenario:1];
}
}
if ([gameView isDown:key_gui_arrow_up]) // '-->'
{
if (!upDownKeyPressed)
{
[self selectScenario:-1];
}
}
upDownKeyPressed = (([gameView isDown:key_gui_arrow_down])||([gameView isDown:key_gui_arrow_up]));
break;
case GUI_SCREEN_MISSION:
if ([[self hud] isHidden])
{

View File

@ -67,6 +67,11 @@ MA 02110-1301, USA.
- (void) quicksavePlayer;
- (void) autosavePlayer;
- (void) setGuiToScenarioScreen;
- (void) addScenarioModel:(NSString *)shipKey;
- (BOOL) startScenario;
- (void) selectScenario:(NSInteger)delta;
#if OO_USE_CUSTOM_LOAD_SAVE
// Interface for PlayerEntityControls

View File

@ -29,7 +29,11 @@
#import "NSFileManagerOOExtensions.h"
#import "GameController.h"
#import "ResourceManager.h"
#import "OOStringExpander.h"
#import "PlayerEntityControls.h"
#import "ProxyPlayerEntity.h"
#import "ShipEntityAI.h"
#import "OOXMLExtensions.h"
#import "OOSound.h"
#import "OOColor.h"
@ -200,6 +204,144 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
- (void) setGuiToScenarioScreen
{
NSArray *scenarios = [UNIVERSE scenarios];
[UNIVERSE removeDemoShips];
// GUI stuff
{
GuiDisplayGen *gui = [UNIVERSE gui];
OOGUIRow start_row = GUI_ROW_SCENARIOS_START;
OOGUIRow row = start_row;
BOOL guiChanged = (gui_screen != GUI_SCREEN_INTERFACES);
[gui clearAndKeepBackground:!guiChanged];
[gui setTitle:DESC(@"oolite-newgame-title")];
OOGUITabSettings tab_stops;
tab_stops[0] = 0;
tab_stops[1] = -480;
[gui setTabStops:tab_stops];
unsigned n_rows = GUI_MAX_ROWS_SCENARIOS;
NSUInteger i, count = [scenarios count];
NSUInteger page = missionTextRow / n_rows;
NSDictionary *scenario = nil;
if (page > 0)
{
[gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil] forRow:start_row - 1];
[gui setColor:[OOColor greenColor] forRow:start_row - 1];
}
for (i = page*n_rows ; i < count && row < start_row + n_rows ; i++)
{
scenario = [[UNIVERSE scenarios] objectAtIndex:i];
[gui setText:OOExpand([NSString stringWithFormat:@" %@ ",[scenario oo_stringForKey:@"name"]]) forRow:row];
[gui setKey:[NSString stringWithFormat:@"Scenario:%d", i] forRow:row];
++row;
}
if ((page+1) * n_rows < count)
{
[gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil] forRow:row];
[gui setColor:[OOColor greenColor] forRow:row];
}
[gui setSelectableRange:NSMakeRange(start_row,row - start_row)];
[gui setSelectedRow:start_row + (missionTextRow%n_rows)];
scenario = [[UNIVERSE scenarios] objectAtIndex:missionTextRow];
[gui addLongText:OOExpand([scenario oo_stringForKey:@"description"]) startingAtRow:GUI_ROW_SCENARIOS_DETAIL align:GUI_ALIGN_LEFT];
NSString *shipKey = [scenario oo_stringForKey:@"model"];
if (shipKey != nil)
{
[self addScenarioModel:shipKey];
[self setShowDemoShips:YES];
}
else
{
[self setShowDemoShips:NO];
}
}
gui_screen = GUI_SCREEN_NEWGAME;
[UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
}
- (void) addScenarioModel:(NSString *)shipKey
{
Quaternion q2 = { (GLfloat)M_SQRT1_2, (GLfloat)M_SQRT1_2, (GLfloat)0.0f, (GLfloat)0.0f };
// MKW - retrieve last demo ships' orientation and release it
if( demoShip != nil )
{
q2 = [demoShip orientation];
[demoShip release];
}
NSDictionary *shipData = [[OOShipRegistry sharedRegistry] shipInfoForKey:shipKey];
ShipEntity *ship = [[ProxyPlayerEntity alloc] initWithKey:shipKey definition:shipData];
[ship wasAddedToUniverse];
GLfloat cr = [ship collisionRadius];
[ship setOrientation: q2];
[ship setPositionX:1.2 * cr y:0.8 * cr z:6.4 * cr];
[ship setScanClass: CLASS_NO_DRAW];
[ship setRoll: M_PI/10.0];
[ship setPitch: M_PI/25.0];
if([ship pendingEscortCount] > 0) [ship setPendingEscortCount:0];
[ship setAITo: @"nullAI.plist"];
id subEntStatus = [shipData objectForKey:@"subentities_status"];
// show missing subentities if there's a subentities_status key
if (subEntStatus != nil) [ship deserializeShipSubEntitiesFrom:(NSString *)subEntStatus];
[UNIVERSE addEntity: ship];
// MKW - save demo ship for its rotation
demoShip = [ship retain];
[ship setStatus: STATUS_COCKPIT_DISPLAY];
[ship release];
}
- (BOOL) startScenario
{
NSDictionary *scenario = [[UNIVERSE scenarios] objectAtIndex:missionTextRow];
NSString *file = [scenario oo_stringForKey:@"file" defaultValue:nil];
if (file == nil)
{
OOLog(@"scenario.init.error",@"No file entry found for scenario");
return NO;
}
NSString *path = [ResourceManager pathForFileNamed:file inFolder:@"Scenarios"];
if (path == nil)
{
OOLog(@"scenario.init.error",@"Game file not found for scenario %@",file);
return NO;
}
return [self loadPlayerFromFile:path];
}
- (void) selectScenario:(NSInteger)delta
{
NSArray *scenarios = [UNIVERSE scenarios];
missionTextRow += delta;
if (missionTextRow < 0)
{
missionTextRow = 0;
}
else if (missionTextRow >= [scenarios count])
{
missionTextRow = [scenarios count] - 1;
}
[self setGuiToScenarioScreen];
}
#if OO_USE_CUSTOM_LOAD_SAVE
- (NSString *)commanderSelector

View File

@ -1,6 +1,7 @@
ENTRY(GUI_SCREEN_MAIN, -1)
ENTRY(GUI_SCREEN_INTRO1, -1)
ENTRY(GUI_SCREEN_INTRO2, -1)
ENTRY(GUI_SCREEN_NEWGAME, -1)
ENTRY(GUI_SCREEN_STATUS, -1)
ENTRY(GUI_SCREEN_MANIFEST, -1)
ENTRY(GUI_SCREEN_EQUIP_SHIP, -1)

View File

@ -239,6 +239,7 @@ enum
NSDictionary *_descriptions; // holds descriptive text for lots of stuff, loaded at initialisation
NSDictionary *customSounds; // holds descriptive audio for lots of stuff, loaded at initialisation
NSDictionary *characters; // holds descriptons of characters
NSArray *_scenarios; // game start scenarios
NSDictionary *planetInfo; // holds overrides for individual planets, keyed by "g# p#" where g# is the galaxy number 0..7 and p# the planet number 0..255
NSDictionary *missiontext; // holds descriptive text for missions, loaded at initialisation
NSArray *equipmentData; // holds data on available equipment, loaded at initialisation
@ -595,6 +596,7 @@ enum
- (NSDictionary *) descriptions;
- (NSDictionary *) characters;
- (NSDictionary *) missiontext;
- (NSArray *) scenarios;
- (NSString *)descriptionForKey:(NSString *)key; // String, or random item from array
- (NSString *)descriptionForArrayKey:(NSString *)key index:(unsigned)index; // Indexed item from array

View File

@ -209,6 +209,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
- (void) verifyDescriptions;
- (void) loadDescriptions;
- (void) loadScenarios;
- (void) verifyEntitySessionIDs;
- (float) randomDistanceWithinScanner;
@ -293,6 +294,9 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
[self loadDescriptions];
// DESC expansion is now possible!
// load starting saves
[self loadScenarios];
reducedDetail = [prefs oo_boolForKey:@"reduced-detail-graphics" defaultValue:NO];
autoSave = [prefs oo_boolForKey:@"autosave" defaultValue:NO];
wireframeGraphics = [prefs oo_boolForKey:@"wireframe-graphics" defaultValue:NO];
@ -7088,6 +7092,20 @@ static void VerifyDesc(NSString *key, id desc)
}
- (NSArray *) scenarios
{
return _scenarios;
}
- (void) loadScenarios
{
[_scenarios autorelease];
_scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
[self verifyDescriptions];
}
- (NSDictionary *) characters
{
return characters;