diff --git a/Resources/iDOS-Info.plist b/Resources/iDOS-Info.plist index fa8ac2de..09bdfc4e 100644 --- a/Resources/iDOS-Info.plist +++ b/Resources/iDOS-Info.plist @@ -40,7 +40,7 @@ CFBundleSignature ???? CFBundleVersion - 20201001.2211 + $(CURRENT_PROJECT_VERSION) LSApplicationCategoryType public.app-category.utilities LSRequiresIPhoneOS diff --git a/dospad/Shared/AppDelegate.h b/dospad/Shared/AppDelegate.h index a887644e..dbfca7cb 100755 --- a/dospad/Shared/AppDelegate.h +++ b/dospad/Shared/AppDelegate.h @@ -22,9 +22,7 @@ @interface AppDelegate : SDLUIKitDelegate { - UINavigationController *navController; SDL_uikitopenglview *screenView; - DOSPadEmulator * emuThread; int cycles; int frameskip; int maxPercent; diff --git a/dospad/Shared/AppDelegate.m b/dospad/Shared/AppDelegate.m index d6de77fa..02be877e 100755 --- a/dospad/Shared/AppDelegate.m +++ b/dospad/Shared/AppDelegate.m @@ -24,6 +24,13 @@ #import "ZipArchive.h" #import "UIViewController+Alert.h" +@interface AppDelegate () +{ + DOSPadBaseViewController *_emulatorController; +} +@end + + @implementation AppDelegate @synthesize frameskip; @synthesize cycles; @@ -71,7 +78,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url { // TODO: show alert can not open while it's running // quick first. - [navController alert:@"Busy" + [_emulatorController alert:@"Busy" message:@"Can not launch the iDOS package while emulator is running. Please terminate the app first."]; return NO; } @@ -100,18 +107,7 @@ - (void)applicationWillResignActive:(UIApplication *)application - (void)applicationDidBecomeActive:(UIApplication *)application { - // Only when we have a DOSPadBaseViewController on the stack - // that we resume the emulator - NSArray *controllers=[navController viewControllers]; - for (int i = 0; i < [controllers count]; i++) - { - UIViewController *ctrl=[controllers objectAtIndex:i]; - if ([ctrl isKindOfClass:[DOSPadBaseViewController class]]) - { - dospad_resume(); - break; - } - } + dospad_resume(); } - (void)applicationDidEnterBackground:(UIApplication *)application @@ -209,12 +205,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( error: &activationErr]; screenView = [[SDL_uikitopenglview alloc] initWithFrame:CGRectMake(0,0,640,400)]; - DOSPadBaseViewController *dospad = [DOSPadBaseViewController dospadController]; - dospad.screenView = screenView; - navController = [[UINavigationController alloc] initWithRootViewController:dospad]; - navController.navigationBar.barStyle = UIBarStyleBlack; - navController.navigationBar.translucent=YES; - uiwindow.rootViewController = navController; + _emulatorController = [DOSPadBaseViewController dospadController]; + _emulatorController.screenView = screenView; + uiwindow.rootViewController = _emulatorController; [uiwindow makeKeyAndVisible]; [super applicationDidFinishLaunching:application]; #ifdef THREADED @@ -241,28 +234,14 @@ -(void)setWindowTitle:(char *)title sprintf(buf, "%4d", cycles); maxPercent = 0; } - NSArray *controllers=[navController viewControllers]; - for (int i = 0; i < [controllers count]; i++) { - UIViewController *ctrl=[controllers objectAtIndex:i]; - if ([ctrl respondsToSelector:@selector(updateCpuCycles:)]) { - [ctrl performSelector:@selector(updateCpuCycles:) withObject:@(buf)]; - } - if ([ctrl respondsToSelector:@selector(updateFrameskip:)]) { - [ctrl performSelector:@selector(updateFrameskip:) - withObject:[NSNumber numberWithInt:frameskip]]; - } - } + + [_emulatorController updateCpuCycles:@(buf)]; + [_emulatorController updateFrameskip:@(frameskip)]; } -(void)onLaunchExit { - NSArray *controllers=[navController viewControllers]; - for (int i = 0; i < [controllers count]; i++) { - UIViewController *ctrl=[controllers objectAtIndex:i]; - if ([ctrl respondsToSelector:@selector(onLaunchExit)]) { - [ctrl performSelectorOnMainThread:@selector(onLaunchExit) withObject:nil waitUntilDone:NO]; - } - } + [_emulatorController onLaunchExit]; } @end diff --git a/dospad/Shared/DOSPadBaseViewController.h b/dospad/Shared/DOSPadBaseViewController.h index e13f6418..612e10e5 100755 --- a/dospad/Shared/DOSPadBaseViewController.h +++ b/dospad/Shared/DOSPadBaseViewController.h @@ -97,4 +97,8 @@ typedef enum { - (void)createMouseButtons; - (void)createPianoKeyboard; - (CGRect)putScreen:(CGRect)availRect; +-(void)updateFrameskip:(NSNumber*)skip; +-(void)updateCpuCycles:(NSString*)title; +- (void)updateScreen; + @end diff --git a/dospad/Shared/DOSPadBaseViewController.m b/dospad/Shared/DOSPadBaseViewController.m index ae130dad..8b2af86f 100755 --- a/dospad/Shared/DOSPadBaseViewController.m +++ b/dospad/Shared/DOSPadBaseViewController.m @@ -42,6 +42,20 @@ @implementation DOSPadBaseViewController @synthesize autoExit; @synthesize screenView; +- (void)updateScreen +{ + NSAssert(FALSE, @"Must be implemented by subclass"); +} + + +// MARK: opengles view delegate +// Screen Resize +-(void)onResize:(CGSize)sizeNew +{ + self.screenView.bounds = CGRectMake(0, 0, sizeNew.width, sizeNew.height); + [self updateScreen]; +} + // scale the screen view to fill the available rect, // and keep it at 4:3 unless it's a wide screen (16:10). // Return the occupied rect. @@ -65,8 +79,8 @@ - (CGRect)putScreen:(CGRect)availRect { h = w * 3 / 4; } - self.screenView.center = CGPointMake(cx, cy); self.screenView.transform = CGAffineTransformMakeScale(w/sw,h/sh); + self.screenView.center = CGPointMake(cx, cy); return CGRectMake(cx-w/2, cy-h/2, w, h); } @@ -150,14 +164,7 @@ - (void)viewDidLoad holdIndicator = [[HoldIndicator alloc] initWithFrame:CGRectMake(0,0,100,100)]; holdIndicator.alpha = 0; //holdIndicator.transform = CGAffineTransformMakeScale(1.5, 1.5); - [self.view addSubview:holdIndicator]; - -#ifdef IDOS - self.title = @"iDOS"; -#else - self.title = @"DOSpad"; -#endif - + // [self.view addSubview:holdIndicator]; /* TODO: LITCHIE commented out by TVD vk = [[VKView alloc] initWithFrame:CGRectMake(0,0,1,1)]; @@ -310,11 +317,6 @@ - (MouseRightClickMode)currentRightClickMode } } --(void)onResize:(CGSize)sizeNew -{ - NSLog(@"Warning: onResize not implemented"); -} - -(void)updateFrameskip:(NSNumber*)skip { NSLog(@"Warning: updateFrameSkip not implemented"); @@ -652,6 +654,10 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto // MARK: DOSEmulatorDelegate +- (void)emulatorWillStart:(DOSPadEmulator *)emulator +{ +} + - (void)emulator:(DOSPadEmulator *)emulator saveScreenshot:(NSString *)path { UIImage *image = [self.screenView capture]; diff --git a/dospad/Shared/DOSPadEmulator.h b/dospad/Shared/DOSPadEmulator.h index 3b3ce3db..1703a4c7 100755 --- a/dospad/Shared/DOSPadEmulator.h +++ b/dospad/Shared/DOSPadEmulator.h @@ -20,6 +20,7 @@ @protocol DOSPadEmulatorDelegate +- (void)emulatorWillStart:(DOSPadEmulator*)emulator; - (void)emulator:(DOSPadEmulator*)emulator saveScreenshot:(NSString*)path; - (void)emulator:(DOSPadEmulator *)emulator open:(NSString*)path; diff --git a/dospad/Shared/DOSPadEmulator.m b/dospad/Shared/DOSPadEmulator.m index cded1594..d02dd11b 100755 --- a/dospad/Shared/DOSPadEmulator.m +++ b/dospad/Shared/DOSPadEmulator.m @@ -128,6 +128,11 @@ - (void)start // Initalize command history dospad_init_history(); + if (_delegate) + { + [_delegate emulatorWillStart:self]; + } + //NSLog(@"Start dosbox in new thread"); started = YES; [NSThread detachNewThreadSelector:@selector(run) toTarget:self withObject:nil]; diff --git a/dospad/iPad/DosPadViewController.m b/dospad/iPad/DosPadViewController.m index 112b4647..2d25e518 100755 --- a/dospad/iPad/DosPadViewController.m +++ b/dospad/iPad/DosPadViewController.m @@ -391,29 +391,28 @@ - (GamePadView*)createGamepadHelper:(GamePadMode)mod [gpad insertSubview:right atIndex:0]; } - // Make adjustment for screen sizes that are not 768x1024 or 1024x768 - // Shift all down towards the bottom, - // and pull right part towards the right edge. - #if 0 - CGPoint leftPartOffset = CGPointMake(0, self.view.bounds.size.height - 1024); - CGPoint rightPartOffset = CGPointMake(self.view.bounds.size.width - 768, - self.view.bounds.size.height - 1024); - for (UIView *v in gpad.subviews) - { - if (v.center.x < (isPortrait?768:1024)/2) // left - { - v.frame = CGRectOffset(v.frame, leftPartOffset.x, leftPartOffset.y); - } - else - { - v.frame = CGRectOffset(v.frame, rightPartOffset.x, rightPartOffset.y); - } - } - #endif gpad.mode = mod; if (isPortrait) { + // Make adjustment for screen sizes that are not 768x1024 or 1024x768 + // Shift all down towards the bottom, + // and pull right part towards the right edge. + CGPoint leftPartOffset = CGPointMake(0, self.view.bounds.size.height - 1024); + CGPoint rightPartOffset = CGPointMake(self.view.bounds.size.width - 768, + self.view.bounds.size.height - 1024); + for (UIView *v in gpad.subviews) + { + if (v.center.x < (isPortrait?768:1024)/2) // left + { + v.frame = CGRectOffset(v.frame, leftPartOffset.x, leftPartOffset.y); + } + else + { + v.frame = CGRectOffset(v.frame, rightPartOffset.x, rightPartOffset.y); + } + } + [self.view addSubview:gpad]; } else @@ -469,6 +468,16 @@ - (void)updateBackground [self updateBackground:self.interfaceOrientation]; } +- (void)updateScreen +{ + CGFloat vw = self.view.bounds.size.width; + CGFloat vh = self.view.bounds.size.height; + + if ([self isFullscreen]) + [self putScreen:CGRectMake(0, 0, vw, shouldShrinkScreen ? vh-260 : vh)]; + else + [self putScreen:CGRectMake(64, 78, 640, 480)]; +} - (void)updateUI { @@ -502,8 +511,8 @@ - (void)updateUI [baseView insertSubview:self.screenView atIndex:0]; baseView.alpha = 1; // Scaling baseView to fill self.view as much as possible - if (baseView.bounds.size.width != self.view.bounds.size.width || - baseView.bounds.size.height != self.view.bounds.size.height) +// if (baseView.bounds.size.width != self.view.bounds.size.width || +// baseView.bounds.size.height != self.view.bounds.size.height) { float scaleX = self.view.bounds.size.width/baseView.bounds.size.width; float scaleY = self.view.bounds.size.height/baseView.bounds.size.height; @@ -539,10 +548,7 @@ - (void)updateUI -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self updateBackground]; - [self updateAlpha]; - [self onResize:self.screenView.bounds.size]; - [self refreshFullscreenPanel]; + [self updateUI]; //[vk becomeFirstResponder]; TODO Litchie commented out by tvd } @@ -624,14 +630,6 @@ - (void)viewDidUnload { // e.g. self.myOutlet = nil; } - - --(void)onResize:(CGSize)sizeNew -{ - self.screenView.bounds = CGRectMake(0, 0, sizeNew.width, sizeNew.height); - [self updateUI]; -} - - (void)didFloatingView:(FloatingView *)fltView { if ([fltView tag] == TAG_CMD) { diff --git a/dospad/iPhone/DosPadViewController_iPhone.m b/dospad/iPhone/DosPadViewController_iPhone.m index 44be018a..eb75277b 100755 --- a/dospad/iPhone/DosPadViewController_iPhone.m +++ b/dospad/iPhone/DosPadViewController_iPhone.m @@ -166,12 +166,12 @@ - (void)initUI banner.textColor = [UIColor whiteColor]; banner.textAlignment = NSTextAlignmentCenter; banner.alpha = 0; - [_rootContainer addSubview:banner]; + // [_rootContainer addSubview:banner]; //--------------------------------------------------- // 8. Navigation Bar Show Button //--------------------------------------------------- -#ifdef IDOS +#if 0 if (!autoExit) { UIButton *btnTop = [[UIButton alloc] initWithFrame:CGRectMake(0,0,viewRect.size.width,30)]; @@ -467,6 +467,7 @@ - (GamePadView*)createGamepadHelper:(GamePadMode)mod if (r.size.height - grect.origin.y > maxHeight) grect.origin.y = r.size.height - maxHeight; gpad.frame = grect; + NSAssert(toolPanel.superview == _rootContainer, @"Bad tool panel state"); [_rootContainer insertSubview:gpad belowSubview:toolPanel]; } else @@ -558,18 +559,31 @@ - (void)updateUI [self updateAlpha]; } +- (void)emulatorWillStart:(DOSPadEmulator *)emulator +{ + [self updateUI]; +} + +// Place toolpanel right below the screen view +- (void)updateToolpanel +{ + CGRect screenRect = [_rootContainer convertRect:self.screenView.frame fromView:self.view]; + CGFloat scale = screenRect.size.width / toolPanel.bounds.size.width; + CGFloat cx = CGRectGetMidX(screenRect); + CGFloat cy = CGRectGetMaxY(screenRect) + toolPanel.bounds.size.height*scale/2; + toolPanel.center = CGPointMake(cx,cy); + toolPanel.transform = CGAffineTransformMakeScale(scale,scale); + toolPanel.alpha = 1; +} + -(void)updateScreen { CGRect viewRect = [self safeRootRect]; - if ([self isPortrait]) { CGRect screenRect = [self putScreen:CGRectMake(viewRect.origin.x, viewRect.origin.y, viewRect.size.width, viewRect.size.width*3/4)]; - CGRect rect = toolPanel.frame ; - rect.origin.x = viewRect.origin.x + (viewRect.size.width-rect.size.width)/2; - rect.origin.y = viewRect.origin.y + screenRect.size.height; - toolPanel.frame = rect; + [self updateToolpanel]; } else {