Merge pull request #245 from phkb/page_updown_handling
Adds handling of page up/down keys on most screens that can have mult…
This commit is contained in:
commit
e7bc4e71e4
@ -112,6 +112,7 @@ static BOOL speechGenderSelectKeyPressed;
|
||||
#endif
|
||||
static BOOL wait_for_key_up;
|
||||
static BOOL upDownKeyPressed;
|
||||
static BOOL pageUpDownKeyPressed;
|
||||
static BOOL leftRightKeyPressed;
|
||||
static BOOL musicModeKeyPressed;
|
||||
static BOOL volumeControlPressed;
|
||||
@ -2134,15 +2135,15 @@ static NSTimeInterval time_last_frame;
|
||||
case GUI_SCREEN_STICKMAPPER:
|
||||
[self stickMapperInputHandler: gui view: gameView];
|
||||
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right] || [gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right] || [gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey] || [gameView isDown:gvPageDownKey];
|
||||
if (leftRightKeyPressed)
|
||||
{
|
||||
NSString *key = [gui keyForRow: [gui selectedRow]];
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
key = [gui keyForRow:GUI_ROW_FUNCEND];
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
key = [gui keyForRow:GUI_ROW_FUNCSTART];
|
||||
}
|
||||
@ -2321,7 +2322,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self showInformationForSelectedUpgrade];
|
||||
}
|
||||
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2334,7 +2335,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2347,7 +2348,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
|
||||
{
|
||||
@ -2373,7 +2374,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
[self showInformationForSelectedInterface];
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2386,7 +2387,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2399,7 +2400,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
|
||||
{
|
||||
if ([gameView isDown:gvMouseDoubleClick])
|
||||
@ -2491,7 +2492,7 @@ static NSTimeInterval time_last_frame;
|
||||
break;
|
||||
case GUI_SCREEN_STATUS:
|
||||
[self handleGUIUpDownArrowKeys];
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
@ -2506,7 +2507,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
@ -2522,7 +2523,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
|
||||
{
|
||||
@ -2547,7 +2548,7 @@ static NSTimeInterval time_last_frame;
|
||||
break;
|
||||
case GUI_SCREEN_MANIFEST:
|
||||
[self handleGUIUpDownArrowKeys];
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
@ -2562,7 +2563,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
OOGUIRow nextRow = MANIFEST_SCREEN_ROW_NEXT;
|
||||
if ([[self hud] isHidden] || [[self hud] allowBigGui])
|
||||
@ -2581,7 +2582,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
|
||||
{
|
||||
@ -2611,7 +2612,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self showShipyardInfoForSelection];
|
||||
}
|
||||
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2624,7 +2625,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_right])
|
||||
if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
@ -2637,7 +2638,7 @@ static NSTimeInterval time_last_frame;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if ([gameView isDown:13]) // 'enter' NOT double-click
|
||||
{
|
||||
@ -2740,6 +2741,56 @@ static NSTimeInterval time_last_frame;
|
||||
[self handleGUIUpDownArrowKeys];
|
||||
DESTROY(marketSelectedCommodity);
|
||||
marketSelectedCommodity = [[gui selectedRowKey] retain];
|
||||
|
||||
BOOL page_up = [gameView isDown:gvPageUpKey];
|
||||
BOOL page_down = [gameView isDown:gvPageDownKey];
|
||||
if (page_up || page_down)
|
||||
{
|
||||
if ((!pageUpDownKeyPressed) || (script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
OOCommodityMarket *localMarket = [self localMarket];
|
||||
NSArray *goods = [self applyMarketSorter:[self applyMarketFilter:[localMarket goods] onMarket:localMarket] onMarket:localMarket];
|
||||
if ([goods count] > 0)
|
||||
{
|
||||
NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
|
||||
NSInteger offset1 = 0;
|
||||
NSInteger offset2 = 0;
|
||||
if ([[gui keyForRow:GUI_ROW_MARKET_START] isEqualToString:@"<<<"] == true) offset1 += 1;
|
||||
if ([[gui keyForRow:GUI_ROW_MARKET_LAST] isEqualToString:@">>>"] == true) offset2 += 1;
|
||||
if (page_up)
|
||||
{
|
||||
[self playMenuPagePrevious];
|
||||
// some edge cases
|
||||
if (goodsIndex - 16 <= 0)
|
||||
{
|
||||
offset1 = 0;
|
||||
offset2 = 0;
|
||||
}
|
||||
if (offset1 == 1 && offset2 == 0 && goodsIndex < (NSInteger)[goods count] - 1 && goodsIndex - 15 > 0) offset2 = 1;
|
||||
goodsIndex -= (16 - (offset1 + offset2));
|
||||
if (goodsIndex < 0) goodsIndex = 0;
|
||||
if ([goods count] <= 17) goodsIndex = 0;
|
||||
}
|
||||
if (page_down)
|
||||
{
|
||||
[self playMenuPageNext];
|
||||
// some edge cases
|
||||
if (offset1 == 0 && offset2 == 1 && goodsIndex > 1) offset1 = 1;
|
||||
if (offset2 == 1 && goodsIndex + 15 == (NSInteger)[goods count] - 1) offset2 = 0;
|
||||
goodsIndex += (16 - (offset1 + offset2));
|
||||
if (goodsIndex > ((NSInteger)[goods count] - 1) || [goods count] <= 17) goodsIndex = (NSInteger)[goods count] - 1;
|
||||
}
|
||||
DESTROY(marketSelectedCommodity);
|
||||
marketSelectedCommodity = [[goods oo_stringAtIndex:goodsIndex] retain];
|
||||
[self setGuiToMarketScreen];
|
||||
}
|
||||
}
|
||||
pageUpDownKeyPressed = YES;
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
else {
|
||||
pageUpDownKeyPressed = NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4349,6 +4400,34 @@ static BOOL autopilot_pause;
|
||||
[self showScenarioDetails];
|
||||
}
|
||||
|
||||
if (!pageUpDownKeyPressed)
|
||||
{
|
||||
if ([gameView isDown:gvPageUpKey])
|
||||
{
|
||||
// find the Back <<< line, select it and press it
|
||||
if ([[gui keyForRow:GUI_ROW_SCENARIOS_START - 1] hasPrefix:@"__page"])
|
||||
{
|
||||
if ([gui setSelectedRow:GUI_ROW_SCENARIOS_START - 1])
|
||||
{
|
||||
[self startScenario];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ([gameView isDown:gvPageDownKey])
|
||||
{
|
||||
// find the Next >>> line, select it and press it
|
||||
if ([[gui keyForRow:GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS] hasPrefix:@"__page"])
|
||||
{
|
||||
if ([gui setSelectedRow:GUI_ROW_SCENARIOS_START + GUI_MAX_ROWS_SCENARIOS])
|
||||
{
|
||||
[self startScenario];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pageUpDownKeyPressed = [gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if (!selectPressed)
|
||||
{
|
||||
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // enter
|
||||
@ -4388,21 +4467,21 @@ static BOOL autopilot_pause;
|
||||
// only has an effect on install/remove selection screens
|
||||
[oxzmanager showOptionsUpdate];
|
||||
}
|
||||
if ([gameView isDown:key_gui_arrow_left])
|
||||
if ([gameView isDown:key_gui_arrow_left] || [gameView isDown:gvPageUpKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed))
|
||||
{
|
||||
[oxzmanager processOptionsPrev];
|
||||
}
|
||||
}
|
||||
else if ([gameView isDown:key_gui_arrow_right])
|
||||
else if ([gameView isDown:key_gui_arrow_right] || [gameView isDown:gvPageDownKey])
|
||||
{
|
||||
if ((!leftRightKeyPressed))
|
||||
{
|
||||
[oxzmanager processOptionsNext];
|
||||
}
|
||||
}
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left];
|
||||
leftRightKeyPressed = [gameView isDown:key_gui_arrow_right]|[gameView isDown:key_gui_arrow_left]|[gameView isDown:gvPageDownKey]|[gameView isDown:gvPageUpKey];
|
||||
|
||||
if (!selectPressed)
|
||||
{
|
||||
|
@ -389,7 +389,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
|
||||
}
|
||||
|
||||
// handle page <-- and page --> keys
|
||||
if ([gameView isDown:gvArrowKeyLeft] && [[gui keyForRow:BACKROW] isEqual: GUI_KEY_OK])
|
||||
if (([gameView isDown:gvArrowKeyLeft] || [gameView isDown:gvPageUpKey]) && [[gui keyForRow:BACKROW] isEqual: GUI_KEY_OK])
|
||||
{
|
||||
currentPage--;
|
||||
[self playMenuPagePrevious];
|
||||
@ -397,7 +397,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
|
||||
[gameView supressKeysUntilKeyUp];
|
||||
}
|
||||
//
|
||||
if ([gameView isDown:gvArrowKeyRight] && [[gui keyForRow:MOREROW] isEqual: GUI_KEY_OK])
|
||||
if (([gameView isDown:gvArrowKeyRight] || [gameView isDown:gvPageDownKey]) && [[gui keyForRow:MOREROW] isEqual: GUI_KEY_OK])
|
||||
{
|
||||
currentPage++;
|
||||
[self playMenuPageNext];
|
||||
@ -495,7 +495,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
|
||||
[gui setColor:[OOColor cyanColor] forRow:INPUTROW];
|
||||
|
||||
// handle page <-- and page --> keys, and on-screen buttons
|
||||
if (((([gameView isDown:gvMouseDoubleClick] || [gameView isDown: 13]) && [gui selectedRow] == BACKROW) || [gameView isDown:gvArrowKeyLeft])
|
||||
if (((([gameView isDown:gvMouseDoubleClick] || [gameView isDown: 13]) && [gui selectedRow] == BACKROW) || ([gameView isDown:gvArrowKeyLeft] || [gameView isDown:gvPageUpKey]))
|
||||
&& [[gui keyForRow:BACKROW] isEqual: GUI_KEY_OK])
|
||||
{
|
||||
currentPage--;
|
||||
@ -503,7 +503,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
|
||||
[gameView supressKeysUntilKeyUp];
|
||||
}
|
||||
//
|
||||
if (((([gameView isDown:gvMouseDoubleClick] || [gameView isDown: 13]) && [gui selectedRow] == MOREROW) || [gameView isDown:gvArrowKeyRight])
|
||||
if (((([gameView isDown:gvMouseDoubleClick] || [gameView isDown: 13]) && [gui selectedRow] == MOREROW) || ([gameView isDown:gvArrowKeyRight] || [gameView isDown:gvPageDownKey]))
|
||||
&& [[gui keyForRow:MOREROW] isEqual: GUI_KEY_OK])
|
||||
{
|
||||
currentPage++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user