Improve mouse support on new game page, add return to menu option

This commit is contained in:
cim 2013-12-03 18:01:01 +00:00
parent 9052fc604e
commit d27d211575
4 changed files with 105 additions and 120 deletions

View File

@ -1021,11 +1021,12 @@
"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-exit" = "Return to Menu";
"oolite-scenario-standard-name" = "Normal Start";
"oolite-scenario-strict-name" = "Strict Mode";
"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" = "Strict games start like the normal start, but all expansion packs are permanently disabled for this save game.";
"oolite-scenario-strict-description" = "Strict Mode starts like the normal start, but all expansion packs are permanently disabled for this Commander.";
"oolite-scenario-tutorial-description" = "Take a standard Cooperative flight training course, including simulated combat and docking practice.";

View File

@ -3476,40 +3476,43 @@ static BOOL autopilot_pause;
case GUI_SCREEN_INTRO1:
[self handleGUIUpDownArrowKeys];
selectPressed = [gameView isDown:13];
int row_zero = 21;
if (!disc_operation_in_progress)
if (!selectPressed)
{
if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 2+row_zero)
if (!disc_operation_in_progress)
{
[[OOMusicController sharedController] stopThemeMusic];
disc_operation_in_progress = YES;
[UNIVERSE removeDemoShips];
[gui clearBackground];
if (![self loadPlayer])
if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 2+row_zero)
{
[self setGuiToIntroFirstGo:YES];
[[OOMusicController sharedController] stopThemeMusic];
disc_operation_in_progress = YES;
[UNIVERSE removeDemoShips];
[gui clearBackground];
if (![self loadPlayer])
{
[self setGuiToIntroFirstGo:YES];
}
break;
}
break;
}
if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 1+row_zero)
{
missionTextRow = 0;
[self setGuiToScenarioScreen:0];
}
else if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 3+row_zero)
{
[self setGuiToIntroFirstGo:NO];
}
else if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 5+row_zero)
{
[[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on start screen"];
}
else
{
disc_operation_in_progress = NO;
}
}
if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 1+row_zero)
{
missionTextRow = 0;
[self setGuiToScenarioScreen];
}
else if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 3+row_zero)
{
[self setGuiToIntroFirstGo:NO];
}
else if (([gameView isDown:gvMouseDoubleClick] || [gameView isDown:13]) && [gui selectedRow] == 5+row_zero)
{
[[UNIVERSE gameController] exitAppWithContext:@"Exit Game selected on start screen"];
}
else
{
disc_operation_in_progress = NO;
}
selectPressed = [gameView isDown:13];
if ([gameView isDown:gvMouseDoubleClick])
{
[gameView clearMouse];
@ -3535,43 +3538,23 @@ static BOOL autopilot_pause;
break;
case GUI_SCREEN_NEWGAME:
if ([self handleGUIUpDownArrowKeys])
{
[self showScenarioDetails];
}
if (!selectPressed)
{
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // enter
{
if (![self startScenario])
{
[UNIVERSE removeDemoShips];
[self setGuiToIntroFirstGo:YES];
}
}
}
selectPressed = [gameView isDown:13];
if ([gameView isDown:key_gui_arrow_down]) // '<--'
{
if (!upDownKeyPressed)
{
[self selectScenario:1 relative:YES];
}
}
else if ([gameView isDown:key_gui_arrow_up]) // '-->'
{
if (!upDownKeyPressed)
{
[self selectScenario:-1 relative:YES];
}
}
else if ([gameView isDown:gvMouseLeftButton])
{
if (UNIVERSE)
{
int click_row = UNIVERSE->cursor_row;
if ([gui setSelectedRow:click_row])
{
[self selectScenario:click_row relative:NO];
}
}
}
upDownKeyPressed = (([gameView isDown:key_gui_arrow_down])||([gameView isDown:key_gui_arrow_up]));
if ([gameView isDown:gvMouseDoubleClick] || [gameView isDown:gvMouseLeftButton])
{
[gameView clearMouse];

View File

@ -67,10 +67,11 @@ MA 02110-1301, USA.
- (void) quicksavePlayer;
- (void) autosavePlayer;
- (void) setGuiToScenarioScreen;
- (void) setGuiToScenarioScreen:(int)page;
- (void) addScenarioModel:(NSString *)shipKey;
- (void) showScenarioDetails;
- (BOOL) startScenario;
- (void) selectScenario:(NSInteger)delta relative:(BOOL)relative;
#if OO_USE_CUSTOM_LOAD_SAVE

View File

@ -204,7 +204,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
- (void) setGuiToScenarioScreen
- (void) setGuiToScenarioScreen:(int)page
{
NSArray *scenarios = [UNIVERSE scenarios];
[UNIVERSE removeDemoShips];
@ -213,7 +213,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
GuiDisplayGen *gui = [UNIVERSE gui];
OOGUIRow start_row = GUI_ROW_SCENARIOS_START;
OOGUIRow row = start_row;
BOOL guiChanged = (gui_screen != GUI_SCREEN_INTERFACES);
BOOL guiChanged = (gui_screen != GUI_SCREEN_NEWGAME);
[gui clearAndKeepBackground:!guiChanged];
[gui setTitle:DESC(@"oolite-newgame-title")];
@ -226,16 +226,22 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
unsigned n_rows = GUI_MAX_ROWS_SCENARIOS;
NSUInteger i, count = [scenarios count];
NSUInteger page = missionTextRow / n_rows;
NSDictionary *scenario = nil;
[gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-scenario-exit"), @" <----- ", nil] forRow:start_row - 2];
[gui setColor:[OOColor grayColor] forRow:start_row - 2];
[gui setKey:@"exit" forRow:start_row - 2];
if (page > 0)
{
[gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil] forRow:start_row - 1];
[gui setColor:[OOColor greenColor] forRow:start_row - 1];
[gui setKey:@"back" forRow:start_row - 1];
[gui setKey:[NSString stringWithFormat:@"__page:%lu",page-1] forRow:start_row - 1];
}
[self setShowDemoShips:NO];
for (i = page*n_rows ; i < count && row < start_row + n_rows ; i++)
{
scenario = [[UNIVERSE scenarios] objectAtIndex:i];
@ -248,33 +254,13 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
{
[gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil] forRow:row];
[gui setColor:[OOColor greenColor] forRow:row];
[gui setKey:@"next" forRow:row];
[gui setKey:[NSString stringWithFormat:@"__page:%lu",page+1] forRow:row];
++row;
}
if (page > 0)
{
[gui setSelectableRange:NSMakeRange(start_row - 1,1 + row - start_row)];
}
else
{
[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 setSelectableRange:NSMakeRange(start_row - 2,3 + row - start_row)];
[gui setSelectedRow:start_row];
[self showScenarioDetails];
}
gui_screen = GUI_SCREEN_NEWGAME;
@ -316,9 +302,55 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
- (void) showScenarioDetails
{
GuiDisplayGen* gui = [UNIVERSE gui];
NSString* key = [gui selectedRowKey];
[UNIVERSE removeDemoShips];
if ([key hasPrefix:@"Scenario"])
{
int item = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
NSDictionary *scenario = [[UNIVERSE scenarios] objectAtIndex:item];
[self setShowDemoShips:NO];
for (NSUInteger i=GUI_ROW_SCENARIOS_DETAIL;i<=27;i++)
{
[gui setText:@"" forRow:i];
}
if (scenario)
{
[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];
}
}
}
}
- (BOOL) startScenario
{
NSDictionary *scenario = [[UNIVERSE scenarios] objectAtIndex:missionTextRow];
GuiDisplayGen* gui = [UNIVERSE gui];
NSString* key = [gui selectedRowKey];
if ([key isEqualToString:@"exit"])
{
// intended to return to main menu
return NO;
}
if ([key hasPrefix:@"__page"])
{
int page = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
[self setGuiToScenarioScreen:page];
return YES;
}
int selection = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
NSDictionary *scenario = [[UNIVERSE scenarios] objectAtIndex:selection];
NSString *file = [scenario oo_stringForKey:@"file" defaultValue:nil];
if (file == nil)
{
@ -341,38 +373,6 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
- (void) selectScenario:(NSInteger)delta relative:(BOOL)relative;
{
OOLog(@"select.scenario",@"%d (rel:%d)",delta,relative);
NSArray *scenarios = [UNIVERSE scenarios];
if (!relative)
{
NSInteger current = missionTextRow;
NSUInteger page = missionTextRow / GUI_MAX_ROWS_SCENARIOS;
NSInteger new = (page * GUI_MAX_ROWS_SCENARIOS) + delta - GUI_ROW_SCENARIOS_START;
delta = new - current;
OOLog(@"select.scenario",@"%d - %d = %d (%d)",new,current,delta,page);
}
missionTextRow += delta;
if (missionTextRow < 0)
{
missionTextRow = [scenarios count] - 1;
}
else if (missionTextRow >= (NSInteger)[scenarios count])
{
missionTextRow = 0;
}
if (delta > 0)
{
[self playMenuNavigationDown];
}
else if (delta < 0)
{
[self playMenuNavigationUp];
}
[self setGuiToScenarioScreen];
}
#if OO_USE_CUSTOM_LOAD_SAVE