Increased mumber of supported joysticks to 4. Adjustments to the stick mapper screen to be able to list more than two joysticks.

This commit is contained in:
AnotherCommander 2018-05-20 18:03:36 +02:00
parent d650b61b62
commit 4206592804
2 changed files with 33 additions and 6 deletions

View File

@ -28,6 +28,7 @@ MA 02110-1301, USA.
#import "OOJoystickManager.h"
#import "OOTexture.h"
#import "OOCollectionExtractors.h"
#import "HeadUpDisplay.h"
@interface PlayerEntity (StickMapperInternal)
@ -52,7 +53,8 @@ MA 02110-1301, USA.
{
GuiDisplayGen *gui = [UNIVERSE gui];
OOJoystickManager *stickHandler = [OOJoystickManager sharedStickHandler];
NSArray *stickList = [stickHandler listSticks];
NSArray *stickList = [stickHandler listSticks];
unsigned stickCount = [stickList count];
unsigned i;
OOGUITabStop tabStop[GUI_MAX_COLUMNS];
@ -65,11 +67,36 @@ MA 02110-1301, USA.
[gui clear];
[gui setTitle:[NSString stringWithFormat:@"Configure Joysticks"]];
for(i=0; i < [stickList count]; i++)
{
for(i=0; i < stickCount; i++)
{
NSString *stickNameForThisRow = [NSString stringWithFormat: @"Stick %d %@", i+1, [stickList objectAtIndex: i]];
// for more than 2 sticks, the stick name rows are populated by more than one name if needed
NSString *stickNameAdditional = nil;
if (stickCount > 2 && OOStringWidthInEm(stickNameForThisRow) > 18.0)
{
// string is too long, truncate it until its length gets below threshold
do {
stickNameForThisRow = [[stickNameForThisRow substringToIndex:[stickNameForThisRow length] - 5]
stringByAppendingString:@"..."];
} while (OOStringWidthInEm(stickNameForThisRow) > 18.0);
}
unsigned j = i + 2;
if (j < stickCount)
{
stickNameAdditional = [NSString stringWithFormat: @"Stick %d %@", j+1, [stickList objectAtIndex: j]];
if (OOStringWidthInEm(stickNameAdditional) > 11.0)
{
// string is too long, truncate it until its length gets below threshold
do {
stickNameAdditional = [[stickNameAdditional substringToIndex:[stickNameAdditional length] - 5]
stringByAppendingString:@"..."];
} while (OOStringWidthInEm(stickNameAdditional) > 11.0);
}
}
[gui setArray:[NSArray arrayWithObjects:
[NSString stringWithFormat: @"Stick %d", i+1],
[stickList objectAtIndex: i],
stickNameForThisRow,
@"", // skip one column
stickNameAdditional,
nil]
forRow:i + GUI_ROW_STICKNAME];
}

View File

@ -102,7 +102,7 @@ enum {
};
// Stick constants
#define MAX_STICKS 2
#define MAX_STICKS 4
#define MAX_AXES 16
#define MAX_REAL_BUTTONS 64
#define MAX_HATS 4