WIP : first cut at MainMenu popup

This commit is contained in:
Aaron Culliney 2015-12-06 23:23:51 -08:00
parent 97f52ef2ff
commit e7e6af1335
6 changed files with 317 additions and 2 deletions

View File

@ -231,6 +231,8 @@
77E1C0B719D72700004344E0 /* imageUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E1C0B019D72700004344E0 /* imageUtil.m */; };
77EB316C1A27A9AF00DC5A8A /* blank.dsk.gz in Resources */ = {isa = PBXBuildFile; fileRef = 4ADC523019E8D3F600186B36 /* blank.dsk.gz */; };
77EB316D1A27A9AF00DC5A8A /* blank.nib.gz in Resources */ = {isa = PBXBuildFile; fileRef = 4ADC523119E8D3F600186B36 /* blank.nib.gz */; };
93206C781C14E14000668153 /* Apple2iOS.strings in Resources */ = {isa = PBXBuildFile; fileRef = 93206C761C14E14000668153 /* Apple2iOS.strings */; };
93206C851C156BD300668153 /* A2IXPopupChoreographer.m in Sources */ = {isa = PBXBuildFile; fileRef = 93206C841C156BD300668153 /* A2IXPopupChoreographer.m */; };
935C55131C12B61D0013166D /* EmulatorGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 935C55041C12B61D0013166D /* EmulatorGLView.m */; };
935C55141C12B61D0013166D /* EmulatorDiskController.m in Sources */ = {isa = PBXBuildFile; fileRef = 935C55061C12B61D0013166D /* EmulatorDiskController.m */; };
935C55151C12B61D0013166D /* EmulatorFullscreenWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 935C55081C12B61D0013166D /* EmulatorFullscreenWindow.m */; };
@ -466,6 +468,9 @@
77E1C0B119D72700004344E0 /* imageUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imageUtil.h; path = video_util/imageUtil.h; sourceTree = "<group>"; };
77E1C0B219D72700004344E0 /* glUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glUtil.h; path = video_util/glUtil.h; sourceTree = "<group>"; };
77E1C0C719D736EB004344E0 /* glvideo.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = glvideo.c; sourceTree = "<group>"; };
93206C771C14E14000668153 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Apple2iOS.strings; sourceTree = "<group>"; };
93206C831C156BD300668153 /* A2IXPopupChoreographer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = A2IXPopupChoreographer.h; path = Classes/iOS/A2IXPopupChoreographer.h; sourceTree = SOURCE_ROOT; };
93206C841C156BD300668153 /* A2IXPopupChoreographer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = A2IXPopupChoreographer.m; path = Classes/iOS/A2IXPopupChoreographer.m; sourceTree = SOURCE_ROOT; };
935C55031C12B61D0013166D /* EmulatorGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulatorGLView.h; path = Classes/OSX/EmulatorGLView.h; sourceTree = SOURCE_ROOT; };
935C55041C12B61D0013166D /* EmulatorGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EmulatorGLView.m; path = Classes/OSX/EmulatorGLView.m; sourceTree = SOURCE_ROOT; };
935C55051C12B61D0013166D /* EmulatorDiskController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulatorDiskController.h; path = Classes/OSX/EmulatorDiskController.h; sourceTree = SOURCE_ROOT; };
@ -880,6 +885,8 @@
children = (
935C55471C12BE510013166D /* AppDelegate.h */,
935C55481C12BE510013166D /* AppDelegate.m */,
93206C831C156BD300668153 /* A2IXPopupChoreographer.h */,
93206C841C156BD300668153 /* A2IXPopupChoreographer.m */,
935C55491C12BE510013166D /* EAGLView.h */,
935C554A1C12BE510013166D /* EAGLView.m */,
);
@ -889,6 +896,7 @@
935C55291C12BA5F0013166D /* Apple2iOS */ = {
isa = PBXGroup;
children = (
93206C761C14E14000668153 /* Apple2iOS.strings */,
935C55421C12BCFD0013166D /* Apple2iOS-Info.plist */,
935C55361C12BA5F0013166D /* Assets.xcassets */,
935C55441C12BE110013166D /* LaunchScreen.xib */,
@ -1232,6 +1240,7 @@
935C55351C12BA5F0013166D /* Main.storyboard in Resources */,
935C55921C1371AD0013166D /* Basic.vsh in Resources */,
935C55911C1371AD0013166D /* Basic.fsh in Resources */,
93206C781C14E14000668153 /* Apple2iOS.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1623,6 +1632,7 @@
935C55621C136E070013166D /* misc.c in Sources */,
935C55691C136E070013166D /* glvideo.c in Sources */,
935C558A1C1370800013166D /* gltouchjoy_joy.c in Sources */,
93206C851C156BD300668153 /* A2IXPopupChoreographer.m in Sources */,
935C558B1C1370800013166D /* gltouchjoy_kpad.c in Sources */,
935C558C1C1370800013166D /* gltouchjoy.c in Sources */,
935C55561C136DF40013166D /* soundcore.c in Sources */,
@ -1716,6 +1726,14 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
93206C761C14E14000668153 /* Apple2iOS.strings */ = {
isa = PBXVariantGroup;
children = (
93206C771C14E14000668153 /* Base */,
);
name = Apple2iOS.strings;
sourceTree = "<group>";
};
935C55331C12BA5F0013166D /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (

View File

@ -0,0 +1,11 @@
// Main Menu titles
"Emulator settings" = "Emulator settings";
"Load disk image" = "Load disk image";
"Save & restore" = "Save & restore";
"Reboot or quit emulator" = "Reboot or quit emulator";
// Main Menu subtitles
"General, CPU, Joystick" = "General, CPU, Joystick";
"Insert a Disk ][ image file" = "Insert a Disk ][ image file";
"Quick save and restore" = "Quick save and restore";

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8121.20" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9060" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8101.16"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<scenes>
<!--View Controller-->
@ -22,5 +22,136 @@
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
<!--View Controller-->
<scene sceneID="7d6-Zt-X84">
<objects>
<viewController storyboardIdentifier="MainMenu" id="jav-c9-0Cp" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="rug-Qe-ZFP"/>
<viewControllerLayoutGuide type="bottom" id="AMI-9h-byD"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="dd9-aM-r2j">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Iqo-Ye-Tu9">
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
<connections>
<segue destination="VUl-eb-yCA" kind="embed" id="vqh-we-VEz"/>
</connections>
</containerView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3aI-5Q-HSv" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1058" y="605"/>
</scene>
<!--Table View Controller-->
<scene sceneID="JXG-Ww-kyb">
<objects>
<tableViewController id="VUl-eb-yCA" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="oOG-fc-WLa">
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<sections>
<tableViewSection id="6eB-rK-vSc">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="U1j-AP-Luf">
<rect key="frame" x="0.0" y="0.0" width="640" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="U1j-AP-Luf" id="rJ2-oE-iBp">
<rect key="frame" x="0.0" y="0.0" width="640" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Emulator settings" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mbz-lM-DIP">
<rect key="frame" x="8" y="8" width="329" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="General, CPU, Joystick" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HSF-ji-5WS">
<rect key="frame" x="8" y="22" width="315" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="oOH-E6-lMK">
<rect key="frame" x="0.0" y="44" width="640" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="oOH-E6-lMK" id="Fmr-bG-eyO">
<rect key="frame" x="0.0" y="0.0" width="640" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Load disk image" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gOe-OR-ycd">
<rect key="frame" x="8" y="8" width="329" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Insert a Disk ][ image file" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c93-nC-i3L">
<rect key="frame" x="8" y="22" width="315" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="ITu-uc-66C">
<rect key="frame" x="0.0" y="88" width="640" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ITu-uc-66C" id="gFu-ft-Q65">
<rect key="frame" x="0.0" y="0.0" width="640" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Save &amp; restore" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fJA-S4-XoG">
<rect key="frame" x="8" y="8" width="329" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Quick save and restore" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="t5D-5L-z8k">
<rect key="frame" x="8" y="22" width="315" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="3WS-Nv-AcH">
<rect key="frame" x="0.0" y="132" width="640" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="3WS-Nv-AcH" id="4iZ-VH-juB">
<rect key="frame" x="0.0" y="0.0" width="640" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Reboot or quit emulator" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0WI-e2-xoP">
<rect key="frame" x="8" y="8" width="329" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="VUl-eb-yCA" id="ZxH-uO-kk0"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zT7-oi-1y7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1058" y="1349"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,22 @@
/*
* Apple // emulator for *ix
*
* This software package is subject to the GNU General Public License
* version 3 or later (your choice) as published by the Free Software
* Foundation.
*
* Copyright 2015 Aaron Culliney
*
*/
#import <Foundation/Foundation.h>
@interface A2IXPopupChoreographer : NSObject
+ (A2IXPopupChoreographer *)sharedInstance;
- (void)showMainMenuFromView:(UIView *)view;
- (void)dismissMainMenu;
@end

View File

@ -0,0 +1,129 @@
/*
* Apple // emulator for *ix
*
* This software package is subject to the GNU General Public License
* version 3 or later (your choice) as published by the Free Software
* Foundation.
*
* Copyright 2015 Aaron Culliney
*
*/
#import "A2IXPopupChoreographer.h"
@interface A2IXPopupChoreographer () <UIPopoverControllerDelegate, UITableViewDelegate>
@property (nonatomic, retain) UIPopoverController *popover;
@property (nonatomic, retain) UIViewController *mainMenuVC;
@end
@implementation A2IXPopupChoreographer
+ (A2IXPopupChoreographer *)sharedInstance
{
static A2IXPopupChoreographer *mainMenuChoreographer = nil;
static dispatch_once_t onceToken = 0L;
dispatch_once(&onceToken, ^{
mainMenuChoreographer = [[A2IXPopupChoreographer alloc] init];
});
return mainMenuChoreographer;
}
- (instancetype)init
{
self = [super init];
if (self)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
self.mainMenuVC = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MainMenu"];
}
return self;
}
- (void)dealloc
{
self.popover = nil;
self.mainMenuVC = nil;
[super dealloc];
}
- (void)showMainMenuFromView:(UIView *)view
{
@synchronized(self) {
if (!self.popover)
{
// TODO : pause emulation
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:self.mainMenuVC];
[pop setDelegate:self];
self.popover = pop;
[pop release];
CGRect aRect = CGRectMake(0, 0, 640, 480);
[pop presentPopoverFromRect:aRect inView:view permittedArrowDirections:UIPopoverArrowDirectionUnknown animated:YES];
UITableViewController *tableVC = self.mainMenuVC.childViewControllers.firstObject;
tableVC.tableView.delegate = self;
}
}
}
- (void)dismissMainMenu
{
@synchronized(self) {
[self.popover dismissPopoverAnimated:YES];
[self popoverControllerDidDismissPopover:nil];
}
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
NSLog(@"Show emulator settings ...");
break;
case 1:
NSLog(@"Show load disk image ...");
break;
case 2:
NSLog(@"Show save/restore ...");
break;
case 3:
NSLog(@"Show reboot/quit ...");
break;
default:
NSAssert(false, @"This should not happen ...");
break;
}
}
#pragma mark - UIPopoverControllerDelegate
/* Called on the delegate when the popover controller will dismiss the popover. Return NO to prevent the dismissal of the view.
*/
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return YES;
}
/* Called on the delegate when the user has taken action to dismiss the popover. This is not called when -dismissPopoverAnimated: is called directly.
*/
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
@synchronized(self) {
self.popover = nil;
// TODO : restart emulation
}
}
/* -popoverController:willRepositionPopoverToRect:inView: is called on your delegate when the popover may require a different view or rectangle
*/
- (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView **)view
{
}
@end

View File

@ -13,6 +13,8 @@
#import "common.h"
#import "modelUtil.h"
#import "A2IXPopupChoreographer.h"
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
@ -238,6 +240,7 @@ static inline void _handleTouch(EAGLView *self, SEL _cmd, UITouch *touch, interf
if ((flags & TOUCH_FLAGS_REQUEST_HOST_MENU) != 0)
{
// requested host menu
[[A2IXPopupChoreographer sharedInstance] showMainMenuFromView:self];
}
if ((flags & TOUCH_FLAGS_KEY_TAP) != 0)
@ -247,6 +250,7 @@ static inline void _handleTouch(EAGLView *self, SEL _cmd, UITouch *touch, interf
if ((flags & TOUCH_FLAGS_MENU) == 0)
{
// touch menu was tapped
break;
}