mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
Code style fixes.
This commit is contained in:
parent
30fa2c6699
commit
95da46c153
24 changed files with 538 additions and 529 deletions
|
@ -9,34 +9,30 @@
|
|||
|
||||
@implementation AppDelegate
|
||||
|
||||
-(BOOL)application: (UIApplication*)application didFinishLaunchingWithOptions: (NSDictionary*)launchOption
|
||||
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOption
|
||||
{
|
||||
[EmulatorViewController registerPreferences];
|
||||
CGSH_OpenGL::RegisterPreferences();
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)applicationWillResignActive: (UIApplication*)application
|
||||
- (void)applicationWillResignActive:(UIApplication*)application
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)applicationDidEnterBackground: (UIApplication*)application
|
||||
- (void)applicationDidEnterBackground:(UIApplication*)application
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)applicationWillEnterForeground: (UIApplication*)application
|
||||
- (void)applicationWillEnterForeground:(UIApplication*)application
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)applicationDidBecomeActive: (UIApplication*)application
|
||||
- (void)applicationDidBecomeActive:(UIApplication*)application
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)applicationWillTerminate: (UIApplication*)application
|
||||
- (void)applicationWillTerminate:(UIApplication*)application
|
||||
{
|
||||
StopSimulateDebugger();
|
||||
}
|
||||
|
|
|
@ -11,21 +11,22 @@
|
|||
@implementation BackgroundLayer
|
||||
|
||||
//Blue gradient background
|
||||
+ (CAGradientLayer*) blueGradient {
|
||||
|
||||
UIColor *colorOne = [UIColor colorWithRed:(21/255.0) green:(169/255.0) blue:(207/255.0) alpha:1.0];
|
||||
UIColor *colorTwo = [UIColor colorWithRed:(69/255.0) green:(67/255.0) blue:(142/255.0) alpha:1.0];
|
||||
|
||||
NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];
|
||||
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
|
||||
NSNumber *stopTwo = [NSNumber numberWithFloat:1.0];
|
||||
|
||||
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, nil];
|
||||
|
||||
CAGradientLayer *headerLayer = [CAGradientLayer layer];
|
||||
+ (CAGradientLayer*)blueGradient
|
||||
{
|
||||
|
||||
UIColor* colorOne = [UIColor colorWithRed:(21 / 255.0) green:(169 / 255.0) blue:(207 / 255.0) alpha:1.0];
|
||||
UIColor* colorTwo = [UIColor colorWithRed:(69 / 255.0) green:(67 / 255.0) blue:(142 / 255.0) alpha:1.0];
|
||||
|
||||
NSArray* colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];
|
||||
NSNumber* stopOne = [NSNumber numberWithFloat:0.0];
|
||||
NSNumber* stopTwo = [NSNumber numberWithFloat:1.0];
|
||||
|
||||
NSArray* locations = [NSArray arrayWithObjects:stopOne, stopTwo, nil];
|
||||
|
||||
CAGradientLayer* headerLayer = [CAGradientLayer layer];
|
||||
headerLayer.colors = colors;
|
||||
headerLayer.locations = locations;
|
||||
|
||||
|
||||
return headerLayer;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,28 +2,28 @@
|
|||
|
||||
@implementation CoverViewCell
|
||||
|
||||
-(id)initWithFrame: (CGRect)frame
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame: frame];
|
||||
|
||||
self = [super initWithFrame:frame];
|
||||
|
||||
if(self)
|
||||
{
|
||||
// Initialization code
|
||||
NSArray* arrayOfViews = [[NSBundle mainBundle] loadNibNamed: @"coverCell" owner: self options: nil];
|
||||
|
||||
NSArray* arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"coverCell" owner:self options:nil];
|
||||
|
||||
if([arrayOfViews count] < 1)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if(![[arrayOfViews objectAtIndex: 0] isKindOfClass: [UICollectionViewCell class]])
|
||||
|
||||
if(![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
self = [arrayOfViews objectAtIndex: 0];
|
||||
|
||||
self = [arrayOfViews objectAtIndex:0];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,26 +15,26 @@
|
|||
|
||||
static NSString* const reuseIdentifier = @"coverCell";
|
||||
|
||||
-(void)awakeFromNib
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
|
||||
ScanBootables(Framework::PathUtils::GetPersonalDataPath());
|
||||
ScanBootables("/private/var/mobile");
|
||||
PurgeInexistingFiles();
|
||||
FetchGameTitles();
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
|
||||
assert(_bootables == nullptr);
|
||||
_bootables = new BootableArray(BootablesDb::CClient::GetInstance().GetBootables());
|
||||
|
||||
CAGradientLayer* bgLayer = [BackgroundLayer blueGradient];
|
||||
bgLayer.frame = self.view.bounds;
|
||||
[self.view.layer insertSublayer: bgLayer atIndex: 0];
|
||||
[self.view.layer insertSublayer:bgLayer atIndex:0];
|
||||
|
||||
self.collectionView.allowsMultipleSelection = NO;
|
||||
if(@available(iOS 11.0, *))
|
||||
|
@ -43,21 +43,21 @@ static NSString* const reuseIdentifier = @"coverCell";
|
|||
}
|
||||
}
|
||||
|
||||
-(void)viewDidUnload
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
assert(_bootables != nullptr);
|
||||
delete _bootables;
|
||||
|
||||
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
-(void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration: (NSTimeInterval)duration
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
||||
{
|
||||
// resize your layers based on the view’s new bounds
|
||||
[[[self.view.layer sublayers] objectAtIndex: 0] setFrame: self.view.bounds];
|
||||
[[[self.view.layer sublayers] objectAtIndex:0] setFrame:self.view.bounds];
|
||||
}
|
||||
|
||||
-(BOOL)shouldAutorotate
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
if([self isViewLoaded] && self.view.window)
|
||||
{
|
||||
|
@ -71,55 +71,55 @@ static NSString* const reuseIdentifier = @"coverCell";
|
|||
|
||||
#pragma mark <UICollectionViewDataSource>
|
||||
|
||||
-(NSInteger)numberOfSectionsInCollectionView: (UICollectionView*)collectionView
|
||||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(NSString*)collectionView: (UICollectionView*)collectionView titleForHeaderInSection: (NSInteger)section
|
||||
- (NSString*)collectionView:(UICollectionView*)collectionView titleForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return @"";
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView: (UICollectionView*)collectionView numberOfItemsInSection: (NSInteger)section
|
||||
- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
return _bootables->size();
|
||||
}
|
||||
|
||||
-(UICollectionViewCell*)collectionView: (UICollectionView*)collectionView cellForItemAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
CoverViewCell* cell = (CoverViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier: reuseIdentifier forIndexPath: indexPath];
|
||||
|
||||
CoverViewCell* cell = (CoverViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
|
||||
|
||||
auto bootable = (*_bootables)[indexPath.row];
|
||||
UIImage* placeholder = [UIImage imageNamed: @"boxart.png"];
|
||||
cell.nameLabel.text = [NSString stringWithUTF8String: bootable.title.c_str()];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage: placeholder];
|
||||
|
||||
UIImage* placeholder = [UIImage imageNamed:@"boxart.png"];
|
||||
cell.nameLabel.text = [NSString stringWithUTF8String:bootable.title.c_str()];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:placeholder];
|
||||
|
||||
if(!bootable.coverUrl.empty())
|
||||
{
|
||||
NSString* coverUrl = [NSString stringWithUTF8String: bootable.coverUrl.c_str()];
|
||||
[(UIImageView*)cell.backgroundView sd_setImageWithURL: [NSURL URLWithString: coverUrl] placeholderImage: placeholder];
|
||||
NSString* coverUrl = [NSString stringWithUTF8String:bootable.coverUrl.c_str()];
|
||||
[(UIImageView*)cell.backgroundView sd_setImageWithURL:[NSURL URLWithString:coverUrl] placeholderImage:placeholder];
|
||||
}
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark <UICollectionViewDelegate>
|
||||
|
||||
-(void)prepareForSegue: (UIStoryboardSegue*)segue sender: (id)sender
|
||||
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
|
||||
{
|
||||
if([segue.identifier isEqualToString: @"showEmulator"])
|
||||
if([segue.identifier isEqualToString:@"showEmulator"])
|
||||
{
|
||||
NSIndexPath* indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex: 0];
|
||||
NSIndexPath* indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];
|
||||
auto bootable = (*_bootables)[indexPath.row];
|
||||
BootablesDb::CClient::GetInstance().SetLastBootedTime(bootable.path, time(nullptr));
|
||||
EmulatorViewController* emulatorViewController = segue.destinationViewController;
|
||||
emulatorViewController.bootablePath = [NSString stringWithUTF8String: bootable.path.native().c_str()];
|
||||
[self.collectionView deselectItemAtIndexPath: indexPath animated: NO];
|
||||
emulatorViewController.bootablePath = [NSString stringWithUTF8String:bootable.path.native().c_str()];
|
||||
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)onExit: (id)sender
|
||||
- (IBAction)onExit:(id)sender
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -23,37 +23,46 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
|
||||
@implementation EmulatorViewController
|
||||
|
||||
+(void)registerPreferences
|
||||
+ (void)registerPreferences
|
||||
{
|
||||
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREFERENCE_UI_SHOWFPS, false);
|
||||
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD, true);
|
||||
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT, true);
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
if ([[GCController controllers] count] == 1) {
|
||||
[self toggleHardwareController:YES];
|
||||
}
|
||||
}];
|
||||
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
if (![[GCController controllers] count]) {
|
||||
[self toggleHardwareController:NO];
|
||||
}
|
||||
}];
|
||||
|
||||
if ([[GCController controllers] count]) {
|
||||
[self toggleHardwareController:YES];
|
||||
}
|
||||
|
||||
self.iCadeReader = [[iCadeReaderView alloc] init];
|
||||
[self.view addSubview:self.iCadeReader];
|
||||
self.iCadeReader.delegate = self;
|
||||
self.iCadeReader.active = YES;
|
||||
self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification* note) {
|
||||
if([[GCController controllers] count] == 1)
|
||||
{
|
||||
[self toggleHardwareController:YES];
|
||||
}
|
||||
}];
|
||||
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification* note) {
|
||||
if(![[GCController controllers] count])
|
||||
{
|
||||
[self toggleHardwareController:NO];
|
||||
}
|
||||
}];
|
||||
|
||||
if([[GCController controllers] count])
|
||||
{
|
||||
[self toggleHardwareController:YES];
|
||||
}
|
||||
|
||||
self.iCadeReader = [[iCadeReaderView alloc] init];
|
||||
[self.view addSubview:self.iCadeReader];
|
||||
self.iCadeReader.delegate = self;
|
||||
self.iCadeReader.active = YES;
|
||||
}
|
||||
|
||||
-(void)viewDidAppear: (BOOL)animated
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
assert(g_virtualMachine == nullptr);
|
||||
g_virtualMachine = new CPS2VM();
|
||||
|
@ -61,12 +70,12 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
g_virtualMachine->CreateGSHandler(CGSH_OpenGLiOS::GetFactoryFunction((CAEAGLLayer*)self.view.layer));
|
||||
|
||||
g_virtualMachine->CreatePadHandler(CPH_Generic::GetFactoryFunction());
|
||||
|
||||
|
||||
if(CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT))
|
||||
{
|
||||
g_virtualMachine->CreateSoundHandler(&CSH_OpenAL::HandlerFactory);
|
||||
}
|
||||
|
||||
|
||||
auto screenBounds = [[UIScreen mainScreen] bounds];
|
||||
if(@available(iOS 11, *))
|
||||
{
|
||||
|
@ -77,16 +86,16 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
if(CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD))
|
||||
{
|
||||
auto padHandler = static_cast<CPH_Generic*>(g_virtualMachine->GetPadHandler());
|
||||
self.virtualPadView = [[VirtualPadView alloc] initWithFrame: screenBounds padHandler: padHandler];
|
||||
[self.view addSubview: self.virtualPadView];
|
||||
[self.view sendSubviewToBack: self.virtualPadView];
|
||||
self.virtualPadView = [[VirtualPadView alloc] initWithFrame:screenBounds padHandler:padHandler];
|
||||
[self.view addSubview:self.virtualPadView];
|
||||
[self.view sendSubviewToBack:self.virtualPadView];
|
||||
}
|
||||
|
||||
if(CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWFPS))
|
||||
{
|
||||
[self setupFpsCounterWithBounds: screenBounds];
|
||||
[self setupFpsCounterWithBounds:screenBounds];
|
||||
}
|
||||
|
||||
|
||||
g_virtualMachine->Pause();
|
||||
g_virtualMachine->Reset();
|
||||
|
||||
|
@ -105,7 +114,7 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
g_virtualMachine->Resume();
|
||||
}
|
||||
|
||||
-(void)viewDidDisappear: (BOOL)animated
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[self.fpsCounterTimer invalidate];
|
||||
self.fpsCounterTimer = nil;
|
||||
|
@ -119,7 +128,7 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
#endif
|
||||
}
|
||||
|
||||
-(void)toggleHardwareController: (BOOL)useHardware
|
||||
- (void)toggleHardwareController:(BOOL)useHardware
|
||||
{
|
||||
if(useHardware)
|
||||
{
|
||||
|
@ -127,62 +136,72 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
if(self.gController.extendedGamepad)
|
||||
{
|
||||
[self.gController.extendedGamepad setValueChangedHandler:
|
||||
^(GCExtendedGamepad* gamepad, GCControllerElement* element)
|
||||
{
|
||||
auto padHandler = static_cast<CPH_Generic*>(g_virtualMachine->GetPadHandler());
|
||||
if(!padHandler) return;
|
||||
if (element == gamepad.buttonA) padHandler->SetButtonState(PS2::CControllerInfo::CROSS, gamepad.buttonA.pressed);
|
||||
else if(element == gamepad.buttonB) padHandler->SetButtonState(PS2::CControllerInfo::CIRCLE, gamepad.buttonB.pressed);
|
||||
else if(element == gamepad.buttonX) padHandler->SetButtonState(PS2::CControllerInfo::SQUARE, gamepad.buttonX.pressed);
|
||||
else if(element == gamepad.buttonY) padHandler->SetButtonState(PS2::CControllerInfo::TRIANGLE, gamepad.buttonY.pressed);
|
||||
else if(element == gamepad.leftShoulder) padHandler->SetButtonState(PS2::CControllerInfo::L1, gamepad.leftShoulder.pressed);
|
||||
else if(element == gamepad.rightShoulder) padHandler->SetButtonState(PS2::CControllerInfo::R1, gamepad.rightShoulder.pressed);
|
||||
else if(element == gamepad.leftTrigger) padHandler->SetButtonState(PS2::CControllerInfo::L2, gamepad.leftTrigger.pressed);
|
||||
else if(element == gamepad.rightTrigger) padHandler->SetButtonState(PS2::CControllerInfo::R2, gamepad.rightTrigger.pressed);
|
||||
else if(element == gamepad.dpad)
|
||||
{
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_UP, gamepad.dpad.up.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_DOWN, gamepad.dpad.down.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_LEFT, gamepad.dpad.left.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_RIGHT, gamepad.dpad.right.pressed);
|
||||
}
|
||||
else if(element == gamepad.leftThumbstick)
|
||||
{
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_X, gamepad.leftThumbstick.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_Y, -gamepad.leftThumbstick.yAxis.value);
|
||||
}
|
||||
else if(element == gamepad.rightThumbstick)
|
||||
{
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_RIGHT_X, gamepad.rightThumbstick.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_RIGHT_Y, -gamepad.rightThumbstick.yAxis.value);
|
||||
}
|
||||
}
|
||||
];
|
||||
^(GCExtendedGamepad* gamepad, GCControllerElement* element) {
|
||||
auto padHandler = static_cast<CPH_Generic*>(g_virtualMachine->GetPadHandler());
|
||||
if(!padHandler) return;
|
||||
if(element == gamepad.buttonA)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::CROSS, gamepad.buttonA.pressed);
|
||||
else if(element == gamepad.buttonB)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::CIRCLE, gamepad.buttonB.pressed);
|
||||
else if(element == gamepad.buttonX)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::SQUARE, gamepad.buttonX.pressed);
|
||||
else if(element == gamepad.buttonY)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::TRIANGLE, gamepad.buttonY.pressed);
|
||||
else if(element == gamepad.leftShoulder)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::L1, gamepad.leftShoulder.pressed);
|
||||
else if(element == gamepad.rightShoulder)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::R1, gamepad.rightShoulder.pressed);
|
||||
else if(element == gamepad.leftTrigger)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::L2, gamepad.leftTrigger.pressed);
|
||||
else if(element == gamepad.rightTrigger)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::R2, gamepad.rightTrigger.pressed);
|
||||
else if(element == gamepad.dpad)
|
||||
{
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_UP, gamepad.dpad.up.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_DOWN, gamepad.dpad.down.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_LEFT, gamepad.dpad.left.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_RIGHT, gamepad.dpad.right.pressed);
|
||||
}
|
||||
else if(element == gamepad.leftThumbstick)
|
||||
{
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_X, gamepad.leftThumbstick.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_Y, -gamepad.leftThumbstick.yAxis.value);
|
||||
}
|
||||
else if(element == gamepad.rightThumbstick)
|
||||
{
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_RIGHT_X, gamepad.rightThumbstick.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_RIGHT_Y, -gamepad.rightThumbstick.yAxis.value);
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if(self.gController.gamepad)
|
||||
{
|
||||
[self.gController.gamepad setValueChangedHandler:
|
||||
^(GCGamepad* gamepad, GCControllerElement* element)
|
||||
{
|
||||
auto padHandler = static_cast<CPH_Generic*>(g_virtualMachine->GetPadHandler());
|
||||
if(!padHandler) return;
|
||||
if (element == gamepad.buttonA) padHandler->SetButtonState(PS2::CControllerInfo::CROSS, gamepad.buttonA.pressed);
|
||||
else if(element == gamepad.buttonB) padHandler->SetButtonState(PS2::CControllerInfo::CIRCLE, gamepad.buttonB.pressed);
|
||||
else if(element == gamepad.buttonX) padHandler->SetButtonState(PS2::CControllerInfo::SQUARE, gamepad.buttonX.pressed);
|
||||
else if(element == gamepad.buttonY) padHandler->SetButtonState(PS2::CControllerInfo::TRIANGLE, gamepad.buttonY.pressed);
|
||||
else if(element == gamepad.leftShoulder) padHandler->SetButtonState(PS2::CControllerInfo::L1, gamepad.leftShoulder.pressed);
|
||||
else if(element == gamepad.rightShoulder) padHandler->SetButtonState(PS2::CControllerInfo::R1, gamepad.rightShoulder.pressed);
|
||||
else if(element == gamepad.dpad)
|
||||
{
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_UP, gamepad.dpad.up.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_DOWN, gamepad.dpad.down.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_LEFT, gamepad.dpad.left.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_RIGHT, gamepad.dpad.right.pressed);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_X, gamepad.dpad.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_Y, -gamepad.dpad.yAxis.value);
|
||||
}
|
||||
}
|
||||
];
|
||||
^(GCGamepad* gamepad, GCControllerElement* element) {
|
||||
auto padHandler = static_cast<CPH_Generic*>(g_virtualMachine->GetPadHandler());
|
||||
if(!padHandler) return;
|
||||
if(element == gamepad.buttonA)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::CROSS, gamepad.buttonA.pressed);
|
||||
else if(element == gamepad.buttonB)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::CIRCLE, gamepad.buttonB.pressed);
|
||||
else if(element == gamepad.buttonX)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::SQUARE, gamepad.buttonX.pressed);
|
||||
else if(element == gamepad.buttonY)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::TRIANGLE, gamepad.buttonY.pressed);
|
||||
else if(element == gamepad.leftShoulder)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::L1, gamepad.leftShoulder.pressed);
|
||||
else if(element == gamepad.rightShoulder)
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::R1, gamepad.rightShoulder.pressed);
|
||||
else if(element == gamepad.dpad)
|
||||
{
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_UP, gamepad.dpad.up.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_DOWN, gamepad.dpad.down.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_LEFT, gamepad.dpad.left.pressed);
|
||||
padHandler->SetButtonState(PS2::CControllerInfo::DPAD_RIGHT, gamepad.dpad.right.pressed);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_X, gamepad.dpad.xAxis.value);
|
||||
padHandler->SetAxisState(PS2::CControllerInfo::ANALOG_LEFT_Y, -gamepad.dpad.yAxis.value);
|
||||
}
|
||||
}];
|
||||
//Add controller pause handler here
|
||||
}
|
||||
}
|
||||
|
@ -192,122 +211,124 @@ CPS2VM::ProfileFrameDoneSignal::Connection g_profileFrameDoneConnection;
|
|||
}
|
||||
}
|
||||
|
||||
-(void)setupFpsCounterWithBounds: (CGRect)screenBounds
|
||||
- (void)setupFpsCounterWithBounds:(CGRect)screenBounds
|
||||
{
|
||||
self.fpsCounterLabel = [[UILabel alloc] initWithFrame: screenBounds];
|
||||
self.fpsCounterLabel = [[UILabel alloc] initWithFrame:screenBounds];
|
||||
self.fpsCounterLabel.textColor = [UIColor whiteColor];
|
||||
[self.view addSubview: self.fpsCounterLabel];
|
||||
|
||||
[self.view addSubview:self.fpsCounterLabel];
|
||||
|
||||
#ifdef PROFILE
|
||||
self.profilerStatsLabel = [[UILabel alloc] initWithFrame: screenBounds];
|
||||
self.profilerStatsLabel = [[UILabel alloc] initWithFrame:screenBounds];
|
||||
self.profilerStatsLabel.textColor = [UIColor whiteColor];
|
||||
self.profilerStatsLabel.font = [UIFont fontWithName: @"Courier" size: 10.f];
|
||||
self.profilerStatsLabel.font = [UIFont fontWithName:@"Courier" size:10.f];
|
||||
self.profilerStatsLabel.numberOfLines = 0;
|
||||
[self.view addSubview: self.profilerStatsLabel];
|
||||
[self.view addSubview:self.profilerStatsLabel];
|
||||
#endif
|
||||
|
||||
|
||||
g_newFrameConnection = g_virtualMachine->GetGSHandler()->OnNewFrame.Connect(std::bind(&CStatsManager::OnNewFrame, &CStatsManager::GetInstance(), std::placeholders::_1));
|
||||
#ifdef PROFILE
|
||||
g_profileFrameDoneConnection = g_virtualMachine->ProfileFrameDone.Connect(std::bind(&CStatsManager::OnProfileFrameDone, &CStatsManager::GetInstance(), g_virtualMachine, std::placeholders::_1));
|
||||
#endif
|
||||
self.fpsCounterTimer = [NSTimer scheduledTimerWithTimeInterval: 1 target: self selector: @selector(updateFpsCounter) userInfo: nil repeats: YES];
|
||||
self.fpsCounterTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateFpsCounter) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
-(void)updateFpsCounter
|
||||
- (void)updateFpsCounter
|
||||
{
|
||||
uint32 drawCallCount = CStatsManager::GetInstance().GetDrawCalls();
|
||||
uint32 frames = CStatsManager::GetInstance().GetFrames();
|
||||
uint32 dcpf = (frames != 0) ? (drawCallCount / frames) : 0;
|
||||
self.fpsCounterLabel.text = [NSString stringWithFormat: @"%d f/s, %d dc/f", frames, dcpf];
|
||||
self.fpsCounterLabel.text = [NSString stringWithFormat:@"%d f/s, %d dc/f", frames, dcpf];
|
||||
[self.fpsCounterLabel sizeToFit];
|
||||
#ifdef PROFILE
|
||||
self.profilerStatsLabel.text = [NSString stringWithUTF8String: CStatsManager::GetInstance().GetProfilingInfo().c_str()];
|
||||
self.profilerStatsLabel.text = [NSString stringWithUTF8String:CStatsManager::GetInstance().GetProfilingInfo().c_str()];
|
||||
#endif
|
||||
CStatsManager::GetInstance().ClearStats();
|
||||
}
|
||||
|
||||
-(void)onLoadStateButtonClick
|
||||
- (void)onLoadStateButtonClick
|
||||
{
|
||||
auto statePath = g_virtualMachine->GenerateStatePath(0);
|
||||
g_virtualMachine->LoadState(statePath);
|
||||
NSLog(@"Loaded state from '%s'.", statePath.string().c_str());
|
||||
}
|
||||
|
||||
-(void)onSaveStateButtonClick
|
||||
- (void)onSaveStateButtonClick
|
||||
{
|
||||
auto statePath = g_virtualMachine->GenerateStatePath(0);
|
||||
g_virtualMachine->SaveState(statePath);
|
||||
NSLog(@"Saved state to '%s'.", statePath.string().c_str());
|
||||
}
|
||||
|
||||
-(void)onExitButtonClick
|
||||
- (void)onExitButtonClick
|
||||
{
|
||||
[self dismissViewControllerAnimated: YES completion: nil];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(IBAction)onPauseButtonClick: (id)sender
|
||||
- (IBAction)onPauseButtonClick:(id)sender
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle: nil message: nil preferredStyle: UIAlertControllerStyleActionSheet];
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
alert.popoverPresentationController.sourceView = self.view;
|
||||
alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2, 0, 0);
|
||||
|
||||
|
||||
//Load State
|
||||
{
|
||||
UIAlertAction* action = [UIAlertAction
|
||||
actionWithTitle: @"Load State"
|
||||
style: UIAlertActionStyleDefault
|
||||
handler: ^(UIAlertAction*) { [self onLoadStateButtonClick]; }
|
||||
];
|
||||
[alert addAction: action];
|
||||
actionWithTitle:@"Load State"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction*) {
|
||||
[self onLoadStateButtonClick];
|
||||
}];
|
||||
[alert addAction:action];
|
||||
}
|
||||
|
||||
//Save State
|
||||
{
|
||||
UIAlertAction* action = [UIAlertAction
|
||||
actionWithTitle: @"Save State"
|
||||
style: UIAlertActionStyleDefault
|
||||
handler: ^(UIAlertAction*) { [self onSaveStateButtonClick]; }
|
||||
];
|
||||
[alert addAction: action];
|
||||
actionWithTitle:@"Save State"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction*) {
|
||||
[self onSaveStateButtonClick];
|
||||
}];
|
||||
[alert addAction:action];
|
||||
}
|
||||
|
||||
//Resume
|
||||
{
|
||||
UIAlertAction* action = [UIAlertAction
|
||||
actionWithTitle: @"Resume"
|
||||
style: UIAlertActionStyleCancel
|
||||
handler: nil
|
||||
];
|
||||
[alert addAction: action];
|
||||
actionWithTitle:@"Resume"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[alert addAction:action];
|
||||
}
|
||||
|
||||
|
||||
//Exit
|
||||
{
|
||||
UIAlertAction* action = [UIAlertAction
|
||||
actionWithTitle: @"Exit"
|
||||
style: UIAlertActionStyleDestructive
|
||||
handler: ^(UIAlertAction*) { [self onExitButtonClick]; }
|
||||
];
|
||||
[alert addAction: action];
|
||||
actionWithTitle:@"Exit"
|
||||
style:UIAlertActionStyleDestructive
|
||||
handler:^(UIAlertAction*) {
|
||||
[self onExitButtonClick];
|
||||
}];
|
||||
[alert addAction:action];
|
||||
}
|
||||
|
||||
[self presentViewController: alert animated: YES completion: nil];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(BOOL)prefersStatusBarHidden
|
||||
- (BOOL)prefersStatusBarHidden
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||
{
|
||||
return UIInterfaceOrientationMaskLandscape;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.connectObserver];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.disconnectObserver];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.connectObserver];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self.disconnectObserver];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
|
||||
@implementation GlEsView
|
||||
|
||||
+(Class)layerClass
|
||||
+ (Class)layerClass
|
||||
{
|
||||
return [CAEAGLLayer class];
|
||||
}
|
||||
|
||||
-(void)initView
|
||||
- (void)initView
|
||||
{
|
||||
hasRetinaDisplay = NO;
|
||||
if([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")])
|
||||
if([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")])
|
||||
{
|
||||
if([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")])
|
||||
if([self respondsToSelector:NSSelectorFromString(@"contentScaleFactor")])
|
||||
{
|
||||
float scale = [[UIScreen mainScreen] scale];
|
||||
self.contentScaleFactor = scale;
|
||||
|
@ -23,30 +23,30 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAEAGLLayer* eaglLayer = (CAEAGLLayer*)self.layer;
|
||||
|
||||
|
||||
eaglLayer.opaque = TRUE;
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool: FALSE], kEAGLDrawablePropertyRetainedBacking,
|
||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
|
||||
nil];
|
||||
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
|
||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
|
||||
nil];
|
||||
}
|
||||
|
||||
-(id)initWithFrame: (CGRect)frame
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame: frame];
|
||||
self = [super initWithFrame:frame];
|
||||
if(self)
|
||||
{
|
||||
[self initView];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithCoder: (NSCoder*)decoder
|
||||
- (id)initWithCoder:(NSCoder*)decoder
|
||||
{
|
||||
self = [super initWithCoder: decoder];
|
||||
self = [super initWithCoder:decoder];
|
||||
if(self)
|
||||
{
|
||||
[self initView];
|
||||
|
@ -54,7 +54,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(BOOL)hasRetinaDisplay
|
||||
- (BOOL)hasRetinaDisplay
|
||||
{
|
||||
return hasRetinaDisplay;
|
||||
}
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
@implementation ResolutionFactorSelectorViewController
|
||||
|
||||
-(void)viewDidAppear: (BOOL)animated
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
int index = log2(self.factor);
|
||||
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath: [NSIndexPath indexPathForRow: index inSection: 0]];
|
||||
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
|
||||
if(cell != nil)
|
||||
{
|
||||
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
self.factor = 1 << [indexPath row];
|
||||
[tableView deselectRowAtIndexPath: indexPath animated: YES];
|
||||
[self performSegueWithIdentifier: @"returnToSettings" sender: self];
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
[self performSegueWithIdentifier:@"returnToSettings" sender:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -6,55 +6,55 @@
|
|||
|
||||
@implementation SettingsViewController
|
||||
|
||||
-(void)updateResolutionFactorLabel
|
||||
- (void)updateResolutionFactorLabel
|
||||
{
|
||||
int factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
|
||||
[resolutionFactor setText: [NSString stringWithFormat: @"%dx", factor]];
|
||||
[resolutionFactor setText:[NSString stringWithFormat:@"%dx", factor]];
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[showFpsSwitch setOn: CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWFPS)];
|
||||
[showVirtualPadSwitch setOn: CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD)];
|
||||
[showFpsSwitch setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWFPS)];
|
||||
[showVirtualPadSwitch setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD)];
|
||||
|
||||
[self updateResolutionFactorLabel];
|
||||
[forceBilinearFiltering setOn: CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES)];
|
||||
|
||||
[enableAudioOutput setOn: CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT)];
|
||||
[forceBilinearFiltering setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES)];
|
||||
|
||||
NSString* versionString = [NSString stringWithFormat: @"%s - %s", PLAY_VERSION, __DATE__];
|
||||
[enableAudioOutput setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT)];
|
||||
|
||||
NSString* versionString = [NSString stringWithFormat:@"%s - %s", PLAY_VERSION, __DATE__];
|
||||
versionInfoLabel.text = versionString;
|
||||
}
|
||||
|
||||
-(void)viewDidDisappear: (BOOL)animated
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_UI_SHOWFPS, showFpsSwitch.isOn);
|
||||
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD, showVirtualPadSwitch.isOn);
|
||||
|
||||
|
||||
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, forceBilinearFiltering.isOn);
|
||||
|
||||
|
||||
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT, enableAudioOutput.isOn);
|
||||
|
||||
|
||||
CAppConfig::GetInstance().Save();
|
||||
}
|
||||
|
||||
-(void)tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
[tableView deselectRowAtIndexPath: indexPath animated: YES];
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
|
||||
-(void)prepareForSegue: (UIStoryboardSegue*)segue sender: (id)sender
|
||||
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
|
||||
{
|
||||
if([segue.destinationViewController isKindOfClass: [ResolutionFactorSelectorViewController class]])
|
||||
if([segue.destinationViewController isKindOfClass:[ResolutionFactorSelectorViewController class]])
|
||||
{
|
||||
ResolutionFactorSelectorViewController* selector = (ResolutionFactorSelectorViewController*)segue.destinationViewController;
|
||||
selector.factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)returnToSettings: (UIStoryboardSegue*)segue
|
||||
- (IBAction)returnToSettings:(UIStoryboardSegue*)segue
|
||||
{
|
||||
if([segue.sourceViewController isKindOfClass: [ResolutionFactorSelectorViewController class]])
|
||||
if([segue.sourceViewController isKindOfClass:[ResolutionFactorSelectorViewController class]])
|
||||
{
|
||||
ResolutionFactorSelectorViewController* selector = (ResolutionFactorSelectorViewController*)segue.sourceViewController;
|
||||
CAppConfig::GetInstance().SetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR, selector.factor);
|
||||
|
|
|
@ -2,42 +2,42 @@
|
|||
|
||||
@implementation VirtualPadButton
|
||||
|
||||
-(void)draw: (CGContextRef)context
|
||||
- (void)draw:(CGContextRef)context
|
||||
{
|
||||
[self.image drawInRect: self.bounds];
|
||||
[self.image drawInRect:self.bounds];
|
||||
if(self.pressed)
|
||||
{
|
||||
CGContextSaveGState(context);
|
||||
CGContextSetBlendMode(context, kCGBlendModePlusDarker);
|
||||
[self.image drawInRect: self.bounds];
|
||||
[self.image drawInRect:self.bounds];
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
|
||||
if([self.caption length] != 0)
|
||||
{
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
||||
NSDictionary* attributes =
|
||||
@{
|
||||
NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSForegroundColorAttributeName: [UIColor whiteColor]
|
||||
};
|
||||
|
||||
CGSize textSize = [self.caption sizeWithAttributes: attributes];
|
||||
@{
|
||||
NSParagraphStyleAttributeName : paragraphStyle,
|
||||
NSForegroundColorAttributeName : [UIColor whiteColor]
|
||||
};
|
||||
|
||||
CGSize textSize = [self.caption sizeWithAttributes:attributes];
|
||||
CGRect textRect = CGRectOffset(self.bounds, 0, (self.bounds.size.height - textSize.height) / 2);
|
||||
|
||||
[self.caption drawInRect: textRect withAttributes: attributes];
|
||||
|
||||
[self.caption drawInRect:textRect withAttributes:attributes];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)onPointerDown: (CGPoint)position
|
||||
- (void)onPointerDown:(CGPoint)position
|
||||
{
|
||||
self.pressed = YES;
|
||||
self.padHandler->SetButtonState(self.code, true);
|
||||
[super onPointerDown: position];
|
||||
[super onPointerDown:position];
|
||||
}
|
||||
|
||||
-(void)onPointerUp
|
||||
- (void)onPointerUp
|
||||
{
|
||||
self.pressed = NO;
|
||||
self.padHandler->SetButtonState(self.code, false);
|
||||
|
|
|
@ -2,24 +2,20 @@
|
|||
|
||||
@implementation VirtualPadItem
|
||||
|
||||
-(void)draw: (CGContextRef)context
|
||||
- (void)draw:(CGContextRef)context
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)onPointerDown: (CGPoint)position
|
||||
- (void)onPointerDown:(CGPoint)position
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)onPointerMove: (CGPoint)position
|
||||
- (void)onPointerMove:(CGPoint)position
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void)onPointerUp
|
||||
- (void)onPointerUp
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,35 +2,35 @@
|
|||
|
||||
@implementation VirtualPadStick
|
||||
|
||||
-(void)draw: (CGContextRef)context
|
||||
- (void)draw:(CGContextRef)context
|
||||
{
|
||||
auto offsetBounds = CGRectOffset(self.bounds, self.offset.x, self.offset.y);
|
||||
[self.image drawInRect: offsetBounds];
|
||||
[self.image drawInRect:offsetBounds];
|
||||
}
|
||||
|
||||
-(void)onPointerDown: (CGPoint)position
|
||||
- (void)onPointerDown:(CGPoint)position
|
||||
{
|
||||
self.pressPosition = position;
|
||||
self.offset = CGPointMake(0, 0);
|
||||
[super onPointerDown: position];
|
||||
[super onPointerDown:position];
|
||||
}
|
||||
|
||||
-(void)onPointerMove: (CGPoint)position
|
||||
- (void)onPointerMove:(CGPoint)position
|
||||
{
|
||||
float radius = self.bounds.size.width;
|
||||
float offsetX = position.x - self.pressPosition.x;
|
||||
float offsetY = position.y - self.pressPosition.y;
|
||||
offsetX = std::min<float>(offsetX, radius);
|
||||
offsetX = std::min<float>(offsetX, radius);
|
||||
offsetX = std::max<float>(offsetX, -radius);
|
||||
offsetY = std::min<float>(offsetY, radius);
|
||||
offsetY = std::min<float>(offsetY, radius);
|
||||
offsetY = std::max<float>(offsetY, -radius);
|
||||
self.offset = CGPointMake(offsetX, offsetY);
|
||||
self.padHandler->SetAxisState(self.codeX, offsetX / radius);
|
||||
self.padHandler->SetAxisState(self.codeY, offsetY / radius);
|
||||
[super onPointerMove: position];
|
||||
[super onPointerMove:position];
|
||||
}
|
||||
|
||||
-(void)onPointerUp
|
||||
- (void)onPointerUp
|
||||
{
|
||||
self.pressPosition = CGPointMake(0, 0);
|
||||
self.offset = CGPointMake(0, 0);
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
|
||||
@implementation VirtualPadView
|
||||
|
||||
-(id)initWithFrame: (CGRect)frame padHandler: (CPH_Generic*)padHandler
|
||||
- (id)initWithFrame:(CGRect)frame padHandler:(CPH_Generic*)padHandler
|
||||
{
|
||||
self = [super initWithFrame: frame];
|
||||
self = [super initWithFrame:frame];
|
||||
if(self)
|
||||
{
|
||||
NSMutableDictionary<NSString*, UIImage*>* itemImages = [[NSMutableDictionary alloc] init];
|
||||
[itemImages setObject: [UIImage imageNamed: @"select.png"] forKey: @"select"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"start.png"] forKey: @"start"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"up.png"] forKey: @"up"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"down.png"] forKey: @"down"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"left.png"] forKey: @"left"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"right.png"] forKey: @"right"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"triangle.png"] forKey: @"triangle"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"cross.png"] forKey: @"cross"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"circle.png"] forKey: @"circle"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"square.png"] forKey: @"square"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"lr.png"] forKey: @"lr"];
|
||||
[itemImages setObject: [UIImage imageNamed: @"analogstick.png"] forKey: @"analogStick"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"select.png"] forKey:@"select"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"start.png"] forKey:@"start"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"up.png"] forKey:@"up"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"down.png"] forKey:@"down"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"left.png"] forKey:@"left"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"right.png"] forKey:@"right"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"triangle.png"] forKey:@"triangle"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"cross.png"] forKey:@"cross"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"circle.png"] forKey:@"circle"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"square.png"] forKey:@"square"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"lr.png"] forKey:@"lr"];
|
||||
[itemImages setObject:[UIImage imageNamed:@"analogstick.png"] forKey:@"analogStick"];
|
||||
self.itemImages = itemImages;
|
||||
|
||||
|
||||
self.opaque = NO;
|
||||
self.multipleTouchEnabled = YES;
|
||||
_padHandler = padHandler;
|
||||
|
@ -33,7 +33,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(void)rebuildPadItems
|
||||
- (void)rebuildPadItems
|
||||
{
|
||||
auto frame = self.frame;
|
||||
auto padItems = CVirtualPad::GetItems(frame.size.width, frame.size.height);
|
||||
|
@ -54,40 +54,40 @@
|
|||
{
|
||||
auto button = [[VirtualPadButton alloc] init];
|
||||
button.code = padItem.code0;
|
||||
button.caption = [NSString stringWithUTF8String: padItem.caption.c_str()];
|
||||
button.caption = [NSString stringWithUTF8String:padItem.caption.c_str()];
|
||||
item = button;
|
||||
}
|
||||
item.image = [self.itemImages objectForKey: [NSString stringWithUTF8String: padItem.imageName.c_str()]];
|
||||
item.image = [self.itemImages objectForKey:[NSString stringWithUTF8String:padItem.imageName.c_str()]];
|
||||
item.padHandler = _padHandler;
|
||||
item.bounds = CGRectMake(padItem.x1, padItem.y1, itemWidth, itemHeight);
|
||||
[items addObject: item];
|
||||
[items addObject:item];
|
||||
}
|
||||
self.items = items;
|
||||
}
|
||||
|
||||
-(void)drawRect: (CGRect)rect
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
[super drawRect: rect];
|
||||
|
||||
[super drawRect:rect];
|
||||
|
||||
auto context = UIGraphicsGetCurrentContext();
|
||||
|
||||
|
||||
for(VirtualPadItem* item in self.items)
|
||||
{
|
||||
[item draw: context];
|
||||
[item draw:context];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)touchesBegan: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
|
||||
- (void)touchesBegan:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event
|
||||
{
|
||||
for(UITouch* touch in touches)
|
||||
{
|
||||
auto touchPos = [touch locationInView: self];
|
||||
auto touchPos = [touch locationInView:self];
|
||||
for(VirtualPadItem* item in self.items)
|
||||
{
|
||||
if(CGRectContainsPoint(item.bounds, touchPos))
|
||||
{
|
||||
item.touch = touch;
|
||||
[item onPointerDown: touchPos];
|
||||
[item onPointerDown:touchPos];
|
||||
[self setNeedsDisplay];
|
||||
break;
|
||||
}
|
||||
|
@ -95,16 +95,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)touchesMoved: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
|
||||
- (void)touchesMoved:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event
|
||||
{
|
||||
for(UITouch* touch in touches)
|
||||
{
|
||||
auto touchPos = [touch locationInView: self];
|
||||
auto touchPos = [touch locationInView:self];
|
||||
for(VirtualPadItem* item in self.items)
|
||||
{
|
||||
if(item.touch == touch)
|
||||
{
|
||||
[item onPointerMove: touchPos];
|
||||
[item onPointerMove:touchPos];
|
||||
[self setNeedsDisplay];
|
||||
break;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)endOrCancelTouches: (NSSet<UITouch*>*)touches
|
||||
- (void)endOrCancelTouches:(NSSet<UITouch*>*)touches
|
||||
{
|
||||
for(UITouch* touch in touches)
|
||||
{
|
||||
|
@ -129,14 +129,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)touchesEnded: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
|
||||
- (void)touchesEnded:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event
|
||||
{
|
||||
[self endOrCancelTouches: touches];
|
||||
[self endOrCancelTouches:touches];
|
||||
}
|
||||
|
||||
-(void)touchesCancelled: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
|
||||
- (void)touchesCancelled:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event
|
||||
{
|
||||
[self endOrCancelTouches: touches];
|
||||
[self endOrCancelTouches:touches];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#import "AppDelegate.h"
|
||||
#include "DebuggerSimulator.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
StartSimulateDebugger();
|
||||
@autoreleasepool
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
@synthesize window;
|
||||
|
||||
-(void)applicationDidFinishLaunching: (UIApplication*)application
|
||||
- (void)applicationDidFinishLaunching:(UIApplication*)application
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -25,38 +25,38 @@ enum
|
|||
|
||||
@synthesize delegate;
|
||||
|
||||
-(void)setTags: (const CPsfTags&)tags
|
||||
- (void)setTags:(const CPsfTags&)tags
|
||||
{
|
||||
m_tags = tags;
|
||||
m_rawTags.clear();
|
||||
|
||||
|
||||
for(CPsfTags::ConstTagIterator tagIterator(m_tags.GetTagsBegin());
|
||||
tagIterator != m_tags.GetTagsEnd(); tagIterator++)
|
||||
tagIterator != m_tags.GetTagsEnd(); tagIterator++)
|
||||
{
|
||||
std::string rawTag;
|
||||
rawTag = tagIterator->first + ": " + tagIterator->second;
|
||||
m_rawTags.push_back(rawTag);
|
||||
}
|
||||
|
||||
|
||||
[m_tagsTable reloadData];
|
||||
}
|
||||
|
||||
-(void)setTrackTitle: (NSString*)trackTitle
|
||||
- (void)setTrackTitle:(NSString*)trackTitle
|
||||
{
|
||||
m_trackTitleLabel.text = trackTitle;
|
||||
}
|
||||
|
||||
-(void)setTrackTime: (NSString*)trackTime
|
||||
- (void)setTrackTime:(NSString*)trackTime
|
||||
{
|
||||
m_trackTimeLabel.text = trackTime;
|
||||
}
|
||||
|
||||
-(void)setPlayButtonText: (NSString*)playButtonText
|
||||
- (void)setPlayButtonText:(NSString*)playButtonText
|
||||
{
|
||||
[m_playButton setTitle: playButtonText forState: UIControlStateNormal];
|
||||
[m_playButton setTitle:playButtonText forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
-(IBAction)onPlayButtonPress: (id)sender
|
||||
- (IBAction)onPlayButtonPress:(id)sender
|
||||
{
|
||||
if(delegate != nil)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ enum
|
|||
}
|
||||
}
|
||||
|
||||
-(IBAction)onPrevButtonPress: (id)sender
|
||||
- (IBAction)onPrevButtonPress:(id)sender
|
||||
{
|
||||
if(delegate != nil)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ enum
|
|||
}
|
||||
}
|
||||
|
||||
-(IBAction)onNextButtonPress: (id)sender
|
||||
- (IBAction)onNextButtonPress:(id)sender
|
||||
{
|
||||
if(delegate != nil)
|
||||
{
|
||||
|
@ -80,101 +80,101 @@ enum
|
|||
}
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView: (UITableView*)tableView
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
|
||||
{
|
||||
return SECTION_COUNT;
|
||||
}
|
||||
|
||||
-(NSInteger)tableView: (UITableView*)tableView numberOfRowsInSection: (NSInteger)section
|
||||
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
NSInteger rowCount = 0;
|
||||
switch(section)
|
||||
{
|
||||
case SECTION_INFO:
|
||||
rowCount = INFO_SECTION_COUNT;
|
||||
break;
|
||||
case SECTION_RAWTAGS:
|
||||
rowCount = m_rawTags.size();
|
||||
break;
|
||||
case SECTION_INFO:
|
||||
rowCount = INFO_SECTION_COUNT;
|
||||
break;
|
||||
case SECTION_RAWTAGS:
|
||||
rowCount = m_rawTags.size();
|
||||
break;
|
||||
}
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
-(NSString*)tableView: (UITableView*)tableView titleForHeaderInSection: (NSInteger)section
|
||||
- (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
NSString *sectionHeader = nil;
|
||||
|
||||
NSString* sectionHeader = nil;
|
||||
|
||||
switch(section)
|
||||
{
|
||||
case SECTION_INFO:
|
||||
sectionHeader = @"Info";
|
||||
break;
|
||||
case SECTION_RAWTAGS:
|
||||
sectionHeader = @"Raw Tags";
|
||||
break;
|
||||
case SECTION_INFO:
|
||||
sectionHeader = @"Info";
|
||||
break;
|
||||
case SECTION_RAWTAGS:
|
||||
sectionHeader = @"Raw Tags";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return sectionHeader;
|
||||
}
|
||||
|
||||
-(NSString*)infoDisplayTextForItem: (const char*)itemName withTag: (const char*)tagName
|
||||
- (NSString*)infoDisplayTextForItem:(const char*)itemName withTag:(const char*)tagName
|
||||
{
|
||||
NSString* itemValue = @"";
|
||||
if(m_tags.HasTag(tagName))
|
||||
{
|
||||
itemValue = stringWithWchar(m_tags.GetTagValue(tagName));
|
||||
}
|
||||
return [NSString stringWithFormat: @"%s: %@", itemName, itemValue];
|
||||
return [NSString stringWithFormat:@"%s: %@", itemName, itemValue];
|
||||
}
|
||||
|
||||
-(UITableViewCell*)tableView: (UITableView*)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
static NSString* CellIdentifier = @"Cell";
|
||||
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
|
||||
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if(cell == nil)
|
||||
{
|
||||
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease];
|
||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
||||
}
|
||||
|
||||
|
||||
cell.textLabel.adjustsFontSizeToFitWidth = YES;
|
||||
|
||||
|
||||
if(indexPath.section == SECTION_INFO)
|
||||
{
|
||||
switch(indexPath.row)
|
||||
{
|
||||
case INFO_SECTION_TITLE:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Title" withTag: "title"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Title" withTag:"title"];
|
||||
break;
|
||||
case INFO_SECTION_ARTIST:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Artist" withTag: "artist"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Artist" withTag:"artist"];
|
||||
break;
|
||||
case INFO_SECTION_GAME:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Game" withTag: "game"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Game" withTag:"game"];
|
||||
break;
|
||||
case INFO_SECTION_YEAR:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Year" withTag: "year"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Year" withTag:"year"];
|
||||
break;
|
||||
case INFO_SECTION_GENRE:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Genre" withTag: "genre"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Genre" withTag:"genre"];
|
||||
break;
|
||||
case INFO_SECTION_COMMENT:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Comment" withTag: "comment"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Comment" withTag:"comment"];
|
||||
break;
|
||||
case INFO_SECTION_COPYRIGHT:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Copyright" withTag: "copyright"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Copyright" withTag:"copyright"];
|
||||
break;
|
||||
case INFO_SECTION_PSFBY:
|
||||
cell.textLabel.text = [self infoDisplayTextForItem: "Psf by" withTag: "psfby"];
|
||||
cell.textLabel.text = [self infoDisplayTextForItem:"Psf by" withTag:"psfby"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(indexPath.section == SECTION_RAWTAGS)
|
||||
{
|
||||
std::string rawTag = m_rawTags[indexPath.row];
|
||||
cell.textLabel.text = [NSString stringWithUTF8String: rawTag.c_str()];
|
||||
cell.textLabel.text = [NSString stringWithUTF8String:rawTag.c_str()];
|
||||
}
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#import <MediaPlayer/MediaPlayer.h>
|
||||
#import "NSStringUtils.h"
|
||||
|
||||
#define PLAY_STRING @"Play"
|
||||
#define PAUSE_STRING @"Pause"
|
||||
#define PLAY_STRING @"Play"
|
||||
#define PAUSE_STRING @"Pause"
|
||||
|
||||
@implementation MainTabBarController
|
||||
|
||||
-(void)onAudioSessionInterruption: (NSNotification*)notification
|
||||
- (void)onAudioSessionInterruption:(NSNotification*)notification
|
||||
{
|
||||
NSNumber* interruptionType = [notification.userInfo valueForKey: AVAudioSessionInterruptionTypeKey];
|
||||
NSNumber* interruptionType = [notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey];
|
||||
if([interruptionType intValue] == AVAudioSessionInterruptionTypeBegan)
|
||||
{
|
||||
if(m_playing)
|
||||
|
@ -24,25 +24,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)onAudioSessionRouteChanged: (NSNotification*)notification
|
||||
- (void)onAudioSessionRouteChanged:(NSNotification*)notification
|
||||
{
|
||||
//Pause if we're moving away from any output port that's not the built-in speaker
|
||||
//to prevent playback from continuing when disconnecting headphones and other devices
|
||||
AVAudioSessionRouteDescription* route = [notification.userInfo valueForKey: AVAudioSessionRouteChangePreviousRouteKey];
|
||||
AVAudioSessionRouteDescription* route = [notification.userInfo valueForKey:AVAudioSessionRouteChangePreviousRouteKey];
|
||||
if([route.outputs count] > 0)
|
||||
{
|
||||
AVAudioSessionPortDescription* port = [route.outputs objectAtIndex: 0];
|
||||
if([port.portType compare: AVAudioSessionPortBuiltInSpeaker] != NSOrderedSame)
|
||||
AVAudioSessionPortDescription* port = [route.outputs objectAtIndex:0];
|
||||
if([port.portType compare:AVAudioSessionPortBuiltInSpeaker] != NSOrderedSame)
|
||||
{
|
||||
if(m_playing)
|
||||
{
|
||||
[self performSelectorOnMainThread: @selector(onPlayButtonPress) withObject: nil waitUntilDone: NO];
|
||||
[self performSelectorOnMainThread:@selector(onPlayButtonPress) withObject:nil waitUntilDone:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void)remoteControlReceivedWithEvent: (UIEvent*)receivedEvent
|
||||
- (void)remoteControlReceivedWithEvent:(UIEvent*)receivedEvent
|
||||
{
|
||||
if(receivedEvent.type == UIEventTypeRemoteControl)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)reset
|
||||
- (void)reset
|
||||
{
|
||||
m_ready = false;
|
||||
m_playing = false;
|
||||
|
@ -80,74 +80,74 @@
|
|||
m_volumeAdjust = 1.0f;
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
m_playlist = nullptr;
|
||||
m_currentPlaylistItem = 0;
|
||||
m_repeatMode = PLAYLIST_REPEAT;
|
||||
|
||||
|
||||
m_virtualMachine = new CPsfVm();
|
||||
m_OnNewFrameConnection = m_virtualMachine->OnNewFrame.Connect(ObjCMemberFunctionPointer(self, sel_getUid("onNewFrame")));
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval: 0.20 target: self selector: @selector(onUpdateTrackTimeTimer) userInfo: nil repeats: YES];
|
||||
[NSTimer scheduledTimerWithTimeInterval: 0.05 target: self selector: @selector(onUpdateFadeTimer) userInfo: nil repeats: YES];
|
||||
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.20 target:self selector:@selector(onUpdateTrackTimeTimer) userInfo:nil repeats:YES];
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onUpdateFadeTimer) userInfo:nil repeats:YES];
|
||||
|
||||
[self reset];
|
||||
|
||||
|
||||
m_virtualMachine->Pause();
|
||||
m_virtualMachine->Reset();
|
||||
|
||||
|
||||
//Force all views to be loaded
|
||||
for(UIViewController* viewController in self.viewControllers)
|
||||
{
|
||||
viewController.view;
|
||||
}
|
||||
|
||||
|
||||
m_playlistViewController = (PlaylistViewController*)self.viewControllers[0];
|
||||
m_playlistViewController.delegate = self;
|
||||
|
||||
|
||||
m_fileInfoViewController = (FileInfoViewController*)self.viewControllers[1];
|
||||
m_fileInfoViewController.delegate = self;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(onAudioSessionInterruption:) name: AVAudioSessionInterruptionNotification object: nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(onAudioSessionRouteChanged:) name: AVAudioSessionRouteChangeNotification object: nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAudioSessionRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];
|
||||
NSError* setCategoryErr = nil;
|
||||
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr];
|
||||
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&setCategoryErr];
|
||||
|
||||
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
|
||||
[self becomeFirstResponder];
|
||||
}
|
||||
|
||||
-(void)onPlayButtonPress
|
||||
- (void)onPlayButtonPress
|
||||
{
|
||||
if(!m_ready) return;
|
||||
if(m_playing)
|
||||
{
|
||||
[m_fileInfoViewController setPlayButtonText: PLAY_STRING];
|
||||
[m_fileInfoViewController setPlayButtonText:PLAY_STRING];
|
||||
m_virtualMachine->Pause();
|
||||
m_playing = false;
|
||||
|
||||
|
||||
m_virtualMachine->SetSpuHandler(nullptr);
|
||||
|
||||
|
||||
NSError* activationErr = nil;
|
||||
BOOL success = [[AVAudioSession sharedInstance] setActive: NO error: &activationErr];
|
||||
BOOL success = [[AVAudioSession sharedInstance] setActive:NO error:&activationErr];
|
||||
assert(success == YES);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSError* activationErr = nil;
|
||||
BOOL success = [[AVAudioSession sharedInstance] setActive: YES error: &activationErr];
|
||||
BOOL success = [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
|
||||
assert(success == YES);
|
||||
|
||||
|
||||
m_virtualMachine->SetSpuHandler(&CSH_OpenAL::HandlerFactory);
|
||||
|
||||
[m_fileInfoViewController setPlayButtonText: PAUSE_STRING];
|
||||
|
||||
[m_fileInfoViewController setPlayButtonText:PAUSE_STRING];
|
||||
m_virtualMachine->Resume();
|
||||
m_playing = true;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)onPrevButtonPress
|
||||
- (void)onPrevButtonPress
|
||||
{
|
||||
if(!m_playlist) return;
|
||||
if(m_playlist->GetItemCount() == 0) return;
|
||||
|
@ -167,10 +167,10 @@
|
|||
m_currentPlaylistItem = m_playlist->GetItemCount() - 1;
|
||||
}
|
||||
}
|
||||
[self onPlaylistItemSelected: m_currentPlaylistItem];
|
||||
[self onPlaylistItemSelected:m_currentPlaylistItem];
|
||||
}
|
||||
|
||||
-(void)onNextButtonPress
|
||||
- (void)onNextButtonPress
|
||||
{
|
||||
if(!m_playlist) return;
|
||||
if(m_playlist->GetItemCount() == 0) return;
|
||||
|
@ -191,39 +191,39 @@
|
|||
m_currentPlaylistItem = 0;
|
||||
}
|
||||
}
|
||||
[self onPlaylistItemSelected: m_currentPlaylistItem];
|
||||
[self onPlaylistItemSelected:m_currentPlaylistItem];
|
||||
}
|
||||
|
||||
-(void)onPlaylistSelected: (CPlaylist*)playlist
|
||||
- (void)onPlaylistSelected:(CPlaylist*)playlist
|
||||
{
|
||||
m_playlist = playlist;
|
||||
[self onPlaylistItemSelected: 0];
|
||||
[self onPlaylistItemSelected:0];
|
||||
}
|
||||
|
||||
-(void)onPlaylistItemSelected: (unsigned int)itemIndex
|
||||
- (void)onPlaylistItemSelected:(unsigned int)itemIndex
|
||||
{
|
||||
const auto& playlistItem(m_playlist->GetItem(itemIndex));
|
||||
|
||||
|
||||
//Initialize UI
|
||||
[self reset];
|
||||
[m_fileInfoViewController setPlayButtonText: PLAY_STRING];
|
||||
|
||||
[m_fileInfoViewController setPlayButtonText:PLAY_STRING];
|
||||
|
||||
unsigned int archiveId = playlistItem.archiveId;
|
||||
|
||||
|
||||
m_virtualMachine->Pause();
|
||||
m_virtualMachine->Reset();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
CPsfBase::TagMap tags;
|
||||
CPsfLoader::LoadPsf(
|
||||
*m_virtualMachine,
|
||||
playlistItem.path,
|
||||
(archiveId == 0) ? nullptr : m_playlist->GetArchive(archiveId),
|
||||
&tags);
|
||||
*m_virtualMachine,
|
||||
playlistItem.path,
|
||||
(archiveId == 0) ? nullptr : m_playlist->GetArchive(archiveId),
|
||||
&tags);
|
||||
m_virtualMachine->SetReverbEnabled(true);
|
||||
m_virtualMachine->Resume();
|
||||
|
||||
|
||||
CPsfTags psfTags(tags);
|
||||
NSString* title = @"PsfPlayer";
|
||||
if(psfTags.HasTag("title"))
|
||||
|
@ -235,7 +235,7 @@
|
|||
{
|
||||
gameName = stringWithWchar(psfTags.DecodeTagValue(psfTags.GetRawTagValue("game").c_str()));
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
m_volumeAdjust = std::stof(psfTags.GetTagValue("volume"));
|
||||
|
@ -243,18 +243,17 @@
|
|||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[m_fileInfoViewController setTrackTitle: title];
|
||||
[m_fileInfoViewController setTrackTime: @"00:00"];
|
||||
[m_fileInfoViewController setTags: psfTags];
|
||||
|
||||
NSArray* keys = [NSArray arrayWithObjects: MPMediaItemPropertyAlbumTitle, MPMediaItemPropertyTitle, nil];
|
||||
NSArray* values = [NSArray arrayWithObjects: gameName, title, nil];
|
||||
|
||||
[m_fileInfoViewController setTrackTitle:title];
|
||||
[m_fileInfoViewController setTrackTime:@"00:00"];
|
||||
[m_fileInfoViewController setTags:psfTags];
|
||||
|
||||
NSArray* keys = [NSArray arrayWithObjects:MPMediaItemPropertyAlbumTitle, MPMediaItemPropertyTitle, nil];
|
||||
NSArray* values = [NSArray arrayWithObjects:gameName, title, nil];
|
||||
NSDictionary* mediaInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys];
|
||||
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = mediaInfo;
|
||||
|
||||
|
||||
if(m_repeatMode != TRACK_REPEAT)
|
||||
{
|
||||
double fade = 10.f;
|
||||
|
@ -265,7 +264,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
m_trackLength = 60.f * 60.f; //1 minute default length
|
||||
m_trackLength = 60.f * 60.f; //1 minute default length
|
||||
}
|
||||
if(psfTags.HasTag("fade"))
|
||||
{
|
||||
|
@ -277,7 +276,7 @@
|
|||
|
||||
m_ready = true;
|
||||
m_currentPlaylistItem = itemIndex;
|
||||
[m_playlistViewController setPlayingItemIndex: itemIndex];
|
||||
[m_playlistViewController setPlayingItemIndex:itemIndex];
|
||||
[self onPlayButtonPress];
|
||||
}
|
||||
catch(const std::exception& exception)
|
||||
|
@ -286,19 +285,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)onUpdateTrackTimeTimer
|
||||
- (void)onUpdateTrackTimeTimer
|
||||
{
|
||||
const int fps = 60;
|
||||
|
||||
|
||||
int time = m_frames / fps;
|
||||
int seconds = time % 60;
|
||||
int minutes = time / 60;
|
||||
|
||||
NSString* timeString = [NSString stringWithFormat: @"%0.2d:%0.2d", minutes, seconds];
|
||||
[m_fileInfoViewController setTrackTime: timeString];
|
||||
|
||||
NSString* timeString = [NSString stringWithFormat:@"%0.2d:%0.2d", minutes, seconds];
|
||||
[m_fileInfoViewController setTrackTime:timeString];
|
||||
}
|
||||
|
||||
-(void)onUpdateFadeTimer
|
||||
- (void)onUpdateFadeTimer
|
||||
{
|
||||
if(m_trackLength != 0)
|
||||
{
|
||||
|
@ -315,7 +314,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void)onNewFrame
|
||||
- (void)onNewFrame
|
||||
{
|
||||
m_frames++;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
NSString* stringWithWchar(const std::wstring& input)
|
||||
{
|
||||
NSString* result = [[NSString alloc] initWithBytes: input.data()
|
||||
length: input.length() * sizeof(wchar_t)
|
||||
encoding: NSUTF32LittleEndianStringEncoding];
|
||||
NSString* result = [[NSString alloc] initWithBytes:input.data()
|
||||
length:input.length() * sizeof(wchar_t)
|
||||
encoding:NSUTF32LittleEndianStringEncoding];
|
||||
[result autorelease];
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -4,98 +4,98 @@
|
|||
|
||||
@synthesize delegate;
|
||||
|
||||
-(void)dealloc
|
||||
- (void)dealloc
|
||||
{
|
||||
[m_archives release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
|
||||
NSString* path = [@"~" stringByExpandingTildeInPath];
|
||||
NSFileManager* localFileManager = [[NSFileManager alloc] init];
|
||||
|
||||
NSDirectoryEnumerator* dirEnum = [localFileManager enumeratorAtPath: path];
|
||||
|
||||
|
||||
NSDirectoryEnumerator* dirEnum = [localFileManager enumeratorAtPath:path];
|
||||
|
||||
NSMutableArray* archives = [[NSMutableArray alloc] init];
|
||||
|
||||
|
||||
NSString* file = nil;
|
||||
while(file = [dirEnum nextObject])
|
||||
{
|
||||
if([[file pathExtension] isEqualToString: @"zip"])
|
||||
if([[file pathExtension] isEqualToString:@"zip"])
|
||||
{
|
||||
[archives addObject: file];
|
||||
[archives addObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[localFileManager release];
|
||||
|
||||
m_archives = [archives sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
|
||||
|
||||
|
||||
m_archives = [archives sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
|
||||
[m_archives retain];
|
||||
[archives release];
|
||||
}
|
||||
|
||||
-(void)viewDidDisappear: (BOOL)animated
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewDidDisappear: animated];
|
||||
[super viewDidDisappear:animated];
|
||||
//[self.tableView deselectRowAtIndexPath: [self.tableView indexPathForSelectedRow] animated:NO];
|
||||
}
|
||||
|
||||
-(IBAction)onCancel: (id)sender
|
||||
- (IBAction)onCancel:(id)sender
|
||||
{
|
||||
[self dismissViewControllerAnimated: YES completion: nil];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView: (UITableView*)tableView
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section
|
||||
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [m_archives count];
|
||||
}
|
||||
|
||||
-(NSString*)tableView: (UITableView*)tableView titleForHeaderInSection: (NSInteger)section
|
||||
- (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return @"";
|
||||
}
|
||||
|
||||
-(UITableViewCell*)tableView: (UITableView*)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
static NSString *CellIdentifier = @"Cell";
|
||||
static NSString* CellIdentifier = @"Cell";
|
||||
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if(cell == nil)
|
||||
{
|
||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease];
|
||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
|
||||
}
|
||||
|
||||
|
||||
assert(indexPath.row < [m_archives count]);
|
||||
NSString* playlistPath = [m_archives objectAtIndex: indexPath.row];
|
||||
|
||||
NSString* playlistPath = [m_archives objectAtIndex:indexPath.row];
|
||||
|
||||
cell.textLabel.text = [playlistPath lastPathComponent];
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
assert(indexPath.row < [m_archives count]);
|
||||
|
||||
NSString* playlistPath = [m_archives objectAtIndex: indexPath.row];
|
||||
|
||||
NSString* playlistPath = [m_archives objectAtIndex:indexPath.row];
|
||||
NSString* homeDirPath = [@"~" stringByExpandingTildeInPath];
|
||||
NSString* absolutePath = [homeDirPath stringByAppendingPathComponent: playlistPath];
|
||||
|
||||
NSString* absolutePath = [homeDirPath stringByAppendingPathComponent:playlistPath];
|
||||
|
||||
if(self.delegate != nil)
|
||||
{
|
||||
[self.delegate onPlaylistSelected: absolutePath];
|
||||
[self.delegate onPlaylistSelected:absolutePath];
|
||||
}
|
||||
|
||||
[self dismissViewControllerAnimated: YES completion: nil];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,32 +9,32 @@
|
|||
|
||||
@synthesize delegate;
|
||||
|
||||
-(void)viewDidLoad
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
m_playlist = nullptr;
|
||||
m_playlistDiscoveryService = new CPlaylistDiscoveryService();
|
||||
m_playingItemIndex = -1;
|
||||
[NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(onUpdateDiscoveryItems) userInfo: nil repeats: YES];
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(onUpdateDiscoveryItems) userInfo:nil repeats:YES];
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
-(void)onOpenPlaylist: (id)sender
|
||||
- (void)onOpenPlaylist:(id)sender
|
||||
{
|
||||
PlaylistSelectViewController* vc = (PlaylistSelectViewController*)[self.storyboard instantiateViewControllerWithIdentifier: @"PlaylistSelectViewController"];
|
||||
PlaylistSelectViewController* vc = (PlaylistSelectViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"PlaylistSelectViewController"];
|
||||
vc.delegate = self;
|
||||
[self presentViewController:vc animated: YES completion: nil];
|
||||
[self presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(void)onPlaylistSelected: (NSString*)selectedPlaylistPath
|
||||
- (void)onPlaylistSelected:(NSString*)selectedPlaylistPath
|
||||
{
|
||||
delete m_playlist;
|
||||
m_playlist = new CPlaylist();
|
||||
m_playlistDiscoveryService->ResetRun();
|
||||
|
||||
|
||||
{
|
||||
auto path = fs::path([selectedPlaylistPath fileSystemRepresentation]);
|
||||
auto archive(CPsfArchive::CreateFromPath(path));
|
||||
|
||||
|
||||
unsigned int archiveId = m_playlist->InsertArchive(path.wstring().c_str());
|
||||
for(const auto& file : archive->GetFiles())
|
||||
{
|
||||
|
@ -48,37 +48,36 @@
|
|||
newItem.length = 0;
|
||||
newItem.archiveId = archiveId;
|
||||
unsigned int itemId = m_playlist->InsertItem(newItem);
|
||||
|
||||
|
||||
m_playlistDiscoveryService->AddItemInRun(filePath, path, itemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[m_tableView reloadData];
|
||||
[m_tableView setContentOffset: CGPointZero animated: NO];
|
||||
|
||||
[m_tableView setContentOffset:CGPointZero animated:NO];
|
||||
|
||||
if(self.delegate != nil)
|
||||
{
|
||||
[self.delegate onPlaylistSelected: m_playlist];
|
||||
[self.delegate onPlaylistSelected:m_playlist];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setPlayingItemIndex: (unsigned int)playingItemIndex
|
||||
- (void)setPlayingItemIndex:(unsigned int)playingItemIndex
|
||||
{
|
||||
m_playingItemIndex = playingItemIndex;
|
||||
[m_tableView reloadData];
|
||||
}
|
||||
|
||||
-(void)onUpdateDiscoveryItems
|
||||
- (void)onUpdateDiscoveryItems
|
||||
{
|
||||
if(m_playlist)
|
||||
{
|
||||
bool hasUpdate = false;
|
||||
auto onItemUpdateConnection = m_playlist->OnItemUpdate.Connect(
|
||||
[&hasUpdate](unsigned int itemId, const CPlaylist::ITEM& item)
|
||||
{
|
||||
hasUpdate = true;
|
||||
});
|
||||
[&hasUpdate](unsigned int itemId, const CPlaylist::ITEM& item) {
|
||||
hasUpdate = true;
|
||||
});
|
||||
m_playlistDiscoveryService->ProcessPendingItems(*m_playlist);
|
||||
onItemUpdateConnection.reset();
|
||||
//NSLog(@"Updating %d", hasUpdate);
|
||||
|
@ -89,12 +88,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView: (UITableView *)tableView
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(NSInteger)tableView: (UITableView*)tableView numberOfRowsInSection: (NSInteger)section
|
||||
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
if(m_playlist == NULL)
|
||||
{
|
||||
|
@ -107,42 +106,42 @@
|
|||
}
|
||||
|
||||
// Customize the appearance of table view cells.
|
||||
-(UITableViewCell*)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
static NSString *CellIdentifier = @"Cell";
|
||||
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if (cell == nil)
|
||||
static NSString* CellIdentifier = @"Cell";
|
||||
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if(cell == nil)
|
||||
{
|
||||
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: CellIdentifier] autorelease];
|
||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
|
||||
}
|
||||
|
||||
|
||||
if(m_playlist != NULL)
|
||||
{
|
||||
const CPlaylist::ITEM& item(m_playlist->GetItem(indexPath.row));
|
||||
std::string titleString = Framework::Utf8::ConvertTo(item.title);
|
||||
std::string lengthString = TimeToString<std::string>(item.length);
|
||||
cell.textLabel.text = [NSString stringWithUTF8String: titleString.c_str()];
|
||||
cell.textLabel.text = [NSString stringWithUTF8String:titleString.c_str()];
|
||||
if(m_playingItemIndex == indexPath.row)
|
||||
{
|
||||
[cell.textLabel setFont: [UIFont boldSystemFontOfSize: 16]];
|
||||
[cell.textLabel setFont:[UIFont boldSystemFontOfSize:16]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell.textLabel setFont: [UIFont systemFontOfSize: 16]];
|
||||
[cell.textLabel setFont:[UIFont systemFontOfSize:16]];
|
||||
}
|
||||
cell.detailTextLabel.text = [NSString stringWithUTF8String: lengthString.c_str()];
|
||||
cell.detailTextLabel.text = [NSString stringWithUTF8String:lengthString.c_str()];
|
||||
}
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
assert(indexPath.row < m_playlist->GetItemCount());
|
||||
if(self.delegate != nil)
|
||||
{
|
||||
[self.delegate onPlaylistItemSelected: indexPath.row];
|
||||
[self.delegate onPlaylistItemSelected:indexPath.row];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
|
|
|
@ -17,14 +17,14 @@ string GetTagValue(const CPsfBase::TagMap& tags, const char* tagName)
|
|||
|
||||
@implementation ApplicationDelegate
|
||||
|
||||
-(id)init
|
||||
- (id)init
|
||||
{
|
||||
m_virtualMachine = new CPsfVm();
|
||||
m_virtualMachine->SetSpuHandler(&CSH_OpenAL::HandlerFactory);
|
||||
return [super init];
|
||||
}
|
||||
|
||||
-(void)OnFileOpen: (id)sender
|
||||
- (void)OnFileOpen:(id)sender
|
||||
{
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
NSArray* fileTypes = [NSArray arrayWithObjects:@"psf", @"psf2", @"minipsf", @"minipsf2", nil];
|
||||
|
@ -33,26 +33,26 @@ string GetTagValue(const CPsfBase::TagMap& tags, const char* tagName)
|
|||
return;
|
||||
}
|
||||
NSString* fileName = [openPanel filename];
|
||||
[self LoadPsf: fileName];
|
||||
[self LoadPsf:fileName];
|
||||
}
|
||||
|
||||
-(void)LoadPsf : (NSString*)fileName
|
||||
{
|
||||
- (void)LoadPsf:(NSString*)fileName
|
||||
{
|
||||
m_virtualMachine->Pause();
|
||||
m_virtualMachine->Reset();
|
||||
try
|
||||
{
|
||||
CPsfBase::TagMap tags;
|
||||
CPsfLoader::LoadPsf(*m_virtualMachine, std::string([fileName fileSystemRepresentation]), "", &tags);
|
||||
NSString* game = [[NSString alloc] initWithUTF8String: GetTagValue(tags, "game").c_str()];
|
||||
NSString* title = [[NSString alloc] initWithUTF8String: GetTagValue(tags, "title").c_str()];
|
||||
NSString* length = [[NSString alloc] initWithUTF8String: GetTagValue(tags, "length").c_str()];
|
||||
PlaylistItem* item = [[PlaylistItem alloc] init: fileName game: game title: title length: length];
|
||||
NSString* game = [[NSString alloc] initWithUTF8String:GetTagValue(tags, "game").c_str()];
|
||||
NSString* title = [[NSString alloc] initWithUTF8String:GetTagValue(tags, "title").c_str()];
|
||||
NSString* length = [[NSString alloc] initWithUTF8String:GetTagValue(tags, "length").c_str()];
|
||||
PlaylistItem* item = [[PlaylistItem alloc] init:fileName game:game title:title length:length];
|
||||
[game release];
|
||||
[title release];
|
||||
[length release];
|
||||
[m_playlist addItem: item];
|
||||
[m_playListView reloadData];
|
||||
[m_playlist addItem:item];
|
||||
[m_playListView reloadData];
|
||||
m_virtualMachine->Resume();
|
||||
}
|
||||
catch(const exception& excep)
|
||||
|
@ -61,5 +61,5 @@ string GetTagValue(const CPsfBase::TagMap& tags, const char* tagName)
|
|||
NSRunCriticalAlertPanel(@"PSF load error:", errorMessage, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,50 +10,49 @@
|
|||
|
||||
@implementation Playlist
|
||||
|
||||
-(Playlist*)init
|
||||
- (Playlist*)init
|
||||
{
|
||||
m_playList = [[NSMutableArray alloc] init];
|
||||
return [super init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
- (void)dealloc
|
||||
{
|
||||
[m_playList release];
|
||||
[m_playList release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void)save
|
||||
- (void)save
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(int)numberOfRowsInTableView: (NSTableView*)tableView
|
||||
- (int)numberOfRowsInTableView:(NSTableView*)tableView
|
||||
{
|
||||
return [m_playList count];
|
||||
}
|
||||
|
||||
-(id)tableView: (NSTableView*)tableView objectValueForTableColumn:(NSTableColumn*)tableColumn row:(int)row
|
||||
- (id)tableView:(NSTableView*)tableView objectValueForTableColumn:(NSTableColumn*)tableColumn row:(int)row
|
||||
{
|
||||
if(row >= [m_playList count]) return @"";
|
||||
PlaylistItem* item = [m_playList objectAtIndex: row];
|
||||
if([[tableColumn identifier] isEqualToString: @"game"])
|
||||
PlaylistItem* item = [m_playList objectAtIndex:row];
|
||||
if([[tableColumn identifier] isEqualToString:@"game"])
|
||||
{
|
||||
return [item game];
|
||||
}
|
||||
else if([[tableColumn identifier] isEqualToString: @"title"])
|
||||
else if([[tableColumn identifier] isEqualToString:@"title"])
|
||||
{
|
||||
return [item title];
|
||||
}
|
||||
else if([[tableColumn identifier] isEqualToString: @"length"])
|
||||
else if([[tableColumn identifier] isEqualToString:@"length"])
|
||||
{
|
||||
return [item length];
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
-(void)addItem: (PlaylistItem*)item
|
||||
- (void)addItem:(PlaylistItem*)item
|
||||
{
|
||||
[m_playList addObject: item];
|
||||
[m_playList addObject:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,19 +8,18 @@
|
|||
|
||||
#import "PlaylistItem.h"
|
||||
|
||||
|
||||
@implementation PlaylistItem
|
||||
|
||||
-(id)init: (NSString*)path game: (NSString*)game title: (NSString*)title length: (NSString*)length
|
||||
- (id)init:(NSString*)path game:(NSString*)game title:(NSString*)title length:(NSString*)length
|
||||
{
|
||||
m_path = [[NSString alloc] initWithString: path];
|
||||
m_game = [[NSString alloc] initWithString: game];
|
||||
m_title = [[NSString alloc] initWithString: title];
|
||||
m_length = [[NSString alloc] initWithString: length];
|
||||
m_path = [[NSString alloc] initWithString:path];
|
||||
m_game = [[NSString alloc] initWithString:game];
|
||||
m_title = [[NSString alloc] initWithString:title];
|
||||
m_length = [[NSString alloc] initWithString:length];
|
||||
return [super init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
- (void)dealloc
|
||||
{
|
||||
[m_path release];
|
||||
[m_game release];
|
||||
|
@ -29,17 +28,17 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
-(NSString*)game
|
||||
- (NSString*)game
|
||||
{
|
||||
return m_game;
|
||||
}
|
||||
|
||||
-(NSString*)title
|
||||
- (NSString*)title
|
||||
{
|
||||
return m_title;
|
||||
}
|
||||
|
||||
-(NSString*)length
|
||||
- (NSString*)length
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
return NSApplicationMain(argc, (const char**)argv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue