Mouse support for New Commander screen

This commit is contained in:
cim 2013-12-03 12:34:25 +00:00
parent 0c8259f804
commit 74659d6966
3 changed files with 44 additions and 10 deletions

View File

@ -3537,7 +3537,7 @@ static BOOL autopilot_pause;
case GUI_SCREEN_NEWGAME:
if (!selectPressed)
{
if ([gameView isDown:13]) // enter
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // enter
{
if (![self startScenario])
{
@ -3550,17 +3550,32 @@ static BOOL autopilot_pause;
{
if (!upDownKeyPressed)
{
[self selectScenario:1];
[self selectScenario:1 relative:YES];
}
}
if ([gameView isDown:key_gui_arrow_up]) // '-->'
else if ([gameView isDown:key_gui_arrow_up]) // '-->'
{
if (!upDownKeyPressed)
{
[self selectScenario:-1];
[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];
}
break;

View File

@ -70,7 +70,7 @@ MA 02110-1301, USA.
- (void) setGuiToScenarioScreen;
- (void) addScenarioModel:(NSString *)shipKey;
- (BOOL) startScenario;
- (void) selectScenario:(NSInteger)delta;
- (void) selectScenario:(NSInteger)delta relative:(BOOL)relative;
#if OO_USE_CUSTOM_LOAD_SAVE

View File

@ -233,6 +233,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
{
[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];
}
for (i = page*n_rows ; i < count && row < start_row + n_rows ; i++)
@ -247,9 +248,17 @@ 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];
++row;
}
if (page > 0)
{
[gui setSelectableRange:NSMakeRange(start_row - 1,1 + row - start_row)];
}
else
{
[gui setSelectableRange:NSMakeRange(start_row,row - start_row)];
}
[gui setSelectableRange:NSMakeRange(start_row,row - start_row)];
[gui setSelectedRow:start_row + (missionTextRow%n_rows)];
scenario = [[UNIVERSE scenarios] objectAtIndex:missionTextRow];
@ -269,7 +278,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
gui_screen = GUI_SCREEN_NEWGAME;
[UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
[UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
}
- (void) addScenarioModel:(NSString *)shipKey
@ -332,9 +341,19 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
}
- (void) selectScenario:(NSInteger)delta
- (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)
{
@ -348,7 +367,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
{
[self playMenuNavigationDown];
}
else
else if (delta < 0)
{
[self playMenuNavigationUp];
}