clear up problems with over-long delivery reports

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@625 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Giles Williams 2006-06-28 23:49:16 +00:00
parent a86b63530a
commit 678bc322ec
5 changed files with 109 additions and 18 deletions

View File

@ -1372,6 +1372,7 @@ static BOOL volumeControlPressed;
static int oldSelection;
static BOOL selectPressed;
static BOOL queryPressed;
static BOOL spacePressed;
// DJS + aegidian : Moved from the big switch/case block in pollGuiArrowKeyControls
- (BOOL) handleGUIUpDownArrowKeys
@ -2065,10 +2066,16 @@ static BOOL queryPressed;
case GUI_SCREEN_REPORT :
if ([gameView isDown:32]) // spacebar
{
if (!spacePressed)
{
[gui click];
[self setGuiToStatusScreen];
}
spacePressed = YES;
}
else
spacePressed = NO;
break;
case GUI_SCREEN_SHIPYARD :
@ -2439,10 +2446,16 @@ static BOOL switching_equipship_screens;
{
MyOpenGLView *gameView = (MyOpenGLView *)[universe gameView];
if ([gameView isDown:32]) // look for the spacebar
{
if (!spacePressed)
{
[universe displayMessage:@"" forCount:1.0];
shot_time = 31.0; // force restart
}
spacePressed = YES;
}
else
spacePressed = NO;
}
static BOOL toggling_music;
@ -2622,16 +2635,20 @@ static BOOL toggling_music;
{
// NSLog(@"GUI_SCREEN_MISSION looking for spacebar");
if ([gameView isDown:32]) // '<space>'
{
if (!spacePressed)
{
[self setStatus:STATUS_DOCKED];
[universe removeDemoShips];
[gui setBackgroundImage:nil];
[self setGuiToStatusScreen];
if (missionMusic)
{
[missionMusic stop];
}
spacePressed = YES;
}
else
spacePressed = NO;
}
else
{

View File

@ -102,6 +102,7 @@ Your fair use and other rights are in no way affected by the above.
- (void) setGuiToManifestScreen;
- (void) setGuiToDeliveryReportScreenWithText:(NSString*) report;
- (void) setGuiToDockingReportScreen;
// ---------------------------------------------------------------------- //

View File

@ -1014,6 +1014,66 @@ Your fair use and other rights are in no way affected by the above.
[universe setViewDirection: VIEW_GUI_DISPLAY];
}
- (void) setGuiToDockingReportScreen
{
GuiDisplayGen* gui = [universe gui];
int text_row = 1;
[dockingReport setString:[dockingReport stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
// GUI stuff
{
[gui clear];
[gui setTitle:[universe expandDescription:@"[arrival-report-title]" forSystem:system_seed]];
//
// dockingReport might be a multi-line message
//
while (([dockingReport length] > 0)&&(text_row < 18))
{
if ([dockingReport rangeOfString:@"\n"].location != NSNotFound)
{
while (([dockingReport rangeOfString:@"\n"].location != NSNotFound)&&(text_row < 18))
{
int line_break = [dockingReport rangeOfString:@"\n"].location;
NSString* line = [dockingReport substringToIndex:line_break];
[dockingReport deleteCharactersInRange: NSMakeRange( 0, line_break + 1)];
text_row = [gui addLongText:line startingAtRow:text_row align:GUI_ALIGN_LEFT];
}
[dockingReport setString:[dockingReport stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
else
{
text_row = [gui addLongText:[NSString stringWithString:dockingReport] startingAtRow:text_row align:GUI_ALIGN_LEFT];
[dockingReport setString:@""];
}
}
[gui setText:[NSString stringWithFormat:@"Cash:\t%.1f Cr.\t\tLoad %d of %d t.\tPassengers %d of %d berths.", 0.1*credits, current_cargo, max_cargo, [passengers count], max_passengers] forRow: GUI_ROW_MARKET_CASH];
//
[gui setText:@"Press Space Commander" forRow:21 align:GUI_ALIGN_CENTER];
[gui setColor:[OOColor yellowColor] forRow:21];
[gui setShowTextCursor:NO];
}
/* ends */
if (lastTextKey)
{
[lastTextKey release];
lastTextKey = nil;
}
gui_screen = GUI_SCREEN_REPORT;
[self setShowDemoShips: NO];
[universe setDisplayText: YES];
[universe setDisplayCursor: NO];
[universe setViewDirection: VIEW_GUI_DISPLAY];
}
// ---------------------------------------------------------------------- //
static NSMutableDictionary* currentShipyard = nil;

View File

@ -497,6 +497,9 @@ enum
int currentWeaponFacing; // decoupled from view direction
// docking reports
NSMutableString* dockingReport;
/* -- */
#ifdef GNUSTEP

View File

@ -908,6 +908,8 @@ static Quaternion quaternion_identity = { (GLfloat)1.0, (GLfloat)0.0, (GLfloat)0
//
target_memory_index = 0;
//
dockingReport = [[NSMutableString string] retain];
//
return self;
}
@ -1161,6 +1163,8 @@ static Quaternion quaternion_identity = { (GLfloat)1.0, (GLfloat)0.0, (GLfloat)0
suppressTargetLost = NO;
scoopsActive = NO;
[dockingReport setString:@""];
}
- (void) setUpShipFromDictionary:(NSDictionary *) dict
@ -1509,6 +1513,8 @@ static Quaternion quaternion_identity = { (GLfloat)1.0, (GLfloat)0.0, (GLfloat)0
if (custom_views) [custom_views release];
if (dockingReport) [dockingReport release];
[self destroySound];
int i;
@ -3746,7 +3752,7 @@ double scoopSoundPlayTime = 0.0;
- (void) docked
{
NSMutableString *deliveryReport = [NSMutableString string];
// NSMutableString *dockingReport = [NSMutableString string];
status = STATUS_DOCKED;
[universe setViewDirection:VIEW_GUI_DISPLAY];
@ -3789,14 +3795,14 @@ double scoopSoundPlayTime = 0.0;
NSString* escapepodReport = [self processEscapePods];
if ([escapepodReport length])
[deliveryReport appendString: escapepodReport];
[dockingReport appendString: escapepodReport];
[self unloadCargoPods]; // fill up the on-ship commodities before...
// check contracts
NSString* passengerReport = [self checkPassengerContracts];
if (passengerReport)
[deliveryReport appendFormat:@"\n\n%@", passengerReport];
[dockingReport appendFormat:@"\n\n%@", passengerReport];
[universe setDisplayText:YES];
@ -3810,7 +3816,7 @@ double scoopSoundPlayTime = 0.0;
}
// time to check the script!
if ((!being_fined)&&([deliveryReport length] < 1))
if (!being_fined)
[self checkScript];
// if we've not switched to the mission screen then proceed normally..
@ -3820,9 +3826,6 @@ double scoopSoundPlayTime = 0.0;
if (being_fined)
[self getFined];
if ([deliveryReport length])
[self setGuiToDeliveryReportScreenWithText:deliveryReport];
else
[self setGuiToStatusScreen];
}
@ -4331,6 +4334,13 @@ double scoopSoundPlayTime = 0.0;
- (void) setGuiToStatusScreen
{
// intercept any docking messages
if ([dockingReport length] > 0)
{
[self setGuiToDockingReportScreen]; // go here instead!
return;
}
NSDictionary* descriptions = [universe descriptions];
NSString* systemName;
NSString* targetSystemName;