really REALLY REALLY hoping this works

This commit is contained in:
Max Hunt 2019-06-15 16:51:18 +01:00
parent a3c3c2261a
commit 25d9a6934b
5 changed files with 217 additions and 11 deletions

View File

@ -351,7 +351,7 @@
<action selector="headingBtnPressed:" destination="Ovf-sw-BKp" eventType="touchUpInside" id="ZlX-6a-RgF"/> <action selector="headingBtnPressed:" destination="Ovf-sw-BKp" eventType="touchUpInside" id="ZlX-6a-RgF"/>
</connections> </connections>
</button> </button>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="J48-J9-3Mc"> <view alpha="0.0" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="J48-J9-3Mc">
<rect key="frame" x="-34" y="-24" width="347" height="489"/> <rect key="frame" x="-34" y="-24" width="347" height="489"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
@ -517,6 +517,13 @@
</subviews> </subviews>
<color key="backgroundColor" white="0.0" alpha="0.50644798801369861" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.50644798801369861" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view> </view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Debug Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ng7-cY-plH">
<rect key="frame" x="0.0" y="44" width="414" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" red="1" green="0.1748579502" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<nil key="highlightedColor"/>
</label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="Ut7-03-t0b"/> <viewLayoutGuide key="safeArea" id="Ut7-03-t0b"/>
@ -524,6 +531,7 @@
<connections> <connections>
<outlet property="arrivedAtDestinationBtn" destination="6OI-Da-e6l" id="uWB-lr-dUL"/> <outlet property="arrivedAtDestinationBtn" destination="6OI-Da-e6l" id="uWB-lr-dUL"/>
<outlet property="cancelBtn" destination="AjN-o6-SNx" id="oAt-yu-hp4"/> <outlet property="cancelBtn" destination="AjN-o6-SNx" id="oAt-yu-hp4"/>
<outlet property="debugLbl" destination="ng7-cY-plH" id="A7B-fr-2Qc"/>
<outlet property="dismissBtn" destination="efK-Gw-gxB" id="upX-k6-K16"/> <outlet property="dismissBtn" destination="efK-Gw-gxB" id="upX-k6-K16"/>
<outlet property="etaLabel" destination="TUX-4j-j4B" id="jfr-9U-oct"/> <outlet property="etaLabel" destination="TUX-4j-j4B" id="jfr-9U-oct"/>
<outlet property="etaView" destination="wbi-cI-xnq" id="pXR-sx-Wgh"/> <outlet property="etaView" destination="wbi-cI-xnq" id="pXR-sx-Wgh"/>

View File

@ -30,6 +30,8 @@ class GameLearnViewController: UIViewController, AVAudioPlayerDelegate {
var player = AVAudioPlayer() var player = AVAudioPlayer()
let defaults = UserDefaults.standard
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -55,10 +57,52 @@ class GameLearnViewController: UIViewController, AVAudioPlayerDelegate {
self.fileName = "guibe_wrongdirection" self.fileName = "guibe_wrongdirection"
case 4: case 4:
turnRight() turnRight()
self.fileName = "guibe_right" let var1 = "guibe_right"
let var2 = "guibe_left"
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var1
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var2
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var2
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var1
}
else { errorMsg() }
}
else { errorMsg() }
case 5: case 5:
turnLeft() turnLeft()
self.fileName = "guibe_left" let var1 = "guibe_left"
let var2 = "guibe_right"
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var1
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var2
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var2
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var1
}
else { errorMsg() }
}
else { errorMsg() }
case 6: case 6:
showDone() showDone()
self.fileName = "guibe_arrived" self.fileName = "guibe_arrived"
@ -131,6 +175,22 @@ class GameLearnViewController: UIViewController, AVAudioPlayerDelegate {
} }
} }
func errorMsg() {
let alert = UIAlertController(title: "Playback Error", message: "Error in either keyValues or filename", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.dismiss(animated: true, completion: nil)
case .cancel:
return
case .destructive:
return
}}))
self.present(alert, animated: true, completion: nil)
}
} }
extension UIView { extension UIView {

View File

@ -71,7 +71,8 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
@IBOutlet weak var naviFinishedView: UIView! @IBOutlet weak var naviFinishedView: UIView!
@IBOutlet weak var arrivedAtDestinationBtn: UIButton! @IBOutlet weak var arrivedAtDestinationBtn: UIButton!
// OUTLETS--------------OUTLETS @IBOutlet weak var debugLbl: UILabel!
// OUTLETS--------------OUTLETS
// ACTIONS--------------ACTIONS // ACTIONS--------------ACTIONS
@IBAction func menuBtnPressed(_ sender: Any) { @IBAction func menuBtnPressed(_ sender: Any) {
@ -109,6 +110,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
UIView.animate(withDuration: 0.5, animations: {self.startNaviImg.alpha = 1.0}) UIView.animate(withDuration: 0.5, animations: {self.startNaviImg.alpha = 1.0})
DispatchQueue.main.asyncAfter(deadline: .now() + 3) { DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
UIView.animate(withDuration: 0.5, animations: {self.startNaviImg.alpha = 0.0}) UIView.animate(withDuration: 0.5, animations: {self.startNaviImg.alpha = 0.0})
self.playStart()
} }
} }
@IBAction func xNaviPressed(_ sender: Any) { @IBAction func xNaviPressed(_ sender: Any) {
@ -125,6 +127,8 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
self.cancelBtn.alpha = 0.0 self.cancelBtn.alpha = 0.0
self.persEtaView.alpha = 0.0 self.persEtaView.alpha = 0.0
}) })
self.debugLbl.text = ""
} }
@IBAction func keybDismissBtnPressed(_ sender: Any) { @IBAction func keybDismissBtnPressed(_ sender: Any) {
@ -377,6 +381,7 @@ extension MainViewController: CLLocationManagerDelegate {
func playStart(){ func playStart(){
let path = Bundle.main.path(forResource: "guibe_begin", ofType : "mp3")! let path = Bundle.main.path(forResource: "guibe_begin", ofType : "mp3")!
self.debugLbl.text = String(path.suffix(15))
let url = URL(fileURLWithPath : path) let url = URL(fileURLWithPath : path)
do { do {
player = try AVAudioPlayer(contentsOf: url) player = try AVAudioPlayer(contentsOf: url)
@ -387,24 +392,78 @@ extension MainViewController: CLLocationManagerDelegate {
func playRight(){ func playRight(){
// currentStepLbl.text = "COM: RIGHT" // currentStepLbl.text = "COM: RIGHT"
let path = Bundle.main.path(forResource: "guibe_long_right", ofType : "mp3")!
let var1 = "guibe_long_left"
let var2 = "guibe_long_right"
var path: String = ""
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
path = Bundle.main.path(forResource: var1, ofType : "mp3")!
}
else if defaults.integer(forKey: "bigSide") == 2 {
path = Bundle.main.path(forResource: var2, ofType : "mp3")!
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
path = Bundle.main.path(forResource: var2, ofType : "mp3")!
}
else if defaults.integer(forKey: "bigSide") == 2 {
path = Bundle.main.path(forResource: var1, ofType : "mp3")!
}
else { errorMsg() }
}
else { errorMsg() }
self.debugLbl.text = String(path.suffix(15))
let url = URL(fileURLWithPath : path) let url = URL(fileURLWithPath : path)
do { do {
player = try AVAudioPlayer(contentsOf: url) player = try AVAudioPlayer(contentsOf: url)
player.delegate = self player.delegate = self
player.play() player.play()
} catch {} } catch { errorMsg() }
} }
func playLeft(){ func playLeft(){
// currentStepLbl.text = "COM: LEFT" // currentStepLbl.text = "COM: LEFT"
let path = Bundle.main.path(forResource: "guibe_long_left", ofType : "mp3")!
let var1 = "guibe_long_right"
let var2 = "guibe_long_left"
var path: String = ""
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
path = Bundle.main.path(forResource: var1, ofType : "mp3")!
}
else if defaults.integer(forKey: "bigSide") == 2 {
path = Bundle.main.path(forResource: var2, ofType : "mp3")!
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
path = Bundle.main.path(forResource: var2, ofType : "mp3")!
}
else if defaults.integer(forKey: "bigSide") == 2 {
path = Bundle.main.path(forResource: var1, ofType : "mp3")!
}
else { errorMsg() }
}
else { errorMsg() }
self.debugLbl.text = String(path.suffix(15))
let url = URL(fileURLWithPath : path) let url = URL(fileURLWithPath : path)
do { do {
player = try AVAudioPlayer(contentsOf: url) player = try AVAudioPlayer(contentsOf: url)
player.delegate = self player.delegate = self
player.play() player.play()
} catch {} } catch { errorMsg() }
} }
func playErr(){ func playErr(){
@ -415,6 +474,7 @@ extension MainViewController: CLLocationManagerDelegate {
func playTurnArd(){ func playTurnArd(){
// currentStepLbl.text = "COM: UTURN" // currentStepLbl.text = "COM: UTURN"
let path = Bundle.main.path(forResource: "guibe_wrongdirection", ofType : "mp3")! let path = Bundle.main.path(forResource: "guibe_wrongdirection", ofType : "mp3")!
self.debugLbl.text = String(path.suffix(15))
let url = URL(fileURLWithPath : path) let url = URL(fileURLWithPath : path)
do { do {
player = try AVAudioPlayer(contentsOf: url) player = try AVAudioPlayer(contentsOf: url)
@ -426,6 +486,7 @@ extension MainViewController: CLLocationManagerDelegate {
func playDone(){ func playDone(){
// currentStepLbl.text = "COM: DONE" // currentStepLbl.text = "COM: DONE"
let path = Bundle.main.path(forResource: "guibe_arrived", ofType : "mp3")! let path = Bundle.main.path(forResource: "guibe_arrived", ofType : "mp3")!
self.debugLbl.text = String(path.suffix(15))
let url = URL(fileURLWithPath : path) let url = URL(fileURLWithPath : path)
do { do {
player = try AVAudioPlayer(contentsOf: url) player = try AVAudioPlayer(contentsOf: url)
@ -433,6 +494,22 @@ extension MainViewController: CLLocationManagerDelegate {
player.play() player.play()
} catch {} } catch {}
} }
func errorMsg() {
let alert = UIAlertController(title: "Playback Error", message: "Error in either keyValues or filename", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.dismiss(animated: true, completion: nil)
case .cancel:
return
case .destructive:
return
}}))
self.present(alert, animated: true, completion: nil)
}
} }

View File

@ -34,6 +34,8 @@ class SecondGameLearnViewController: UIViewController, AVAudioPlayerDelegate {
var player = AVAudioPlayer() var player = AVAudioPlayer()
let defaults = UserDefaults.standard
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -58,10 +60,52 @@ class SecondGameLearnViewController: UIViewController, AVAudioPlayerDelegate {
self.fileName = "guibe_wrongdirection" self.fileName = "guibe_wrongdirection"
case 4: case 4:
turnRight() turnRight()
self.fileName = "guibe_right" let var1 = "guibe_right"
let var2 = "guibe_left"
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var1
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var2
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var2
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var1
}
else { errorMsg() }
}
else { errorMsg() }
case 5: case 5:
turnLeft() turnLeft()
self.fileName = "guibe_left" let var1 = "guibe_left"
let var2 = "guibe_right"
if defaults.integer(forKey: "handSide") == 1{
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var1
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var2
}
else { errorMsg() }
}
else if defaults.integer(forKey: "handSide") == 2 {
if defaults.integer(forKey: "bigSide") == 1{
self.fileName = var2
}
else if defaults.integer(forKey: "bigSide") == 2 {
self.fileName = var1
}
else { errorMsg() }
}
else { errorMsg() }
case 6: case 6:
showDone() showDone()
self.fileName = "guibe_arrived" self.fileName = "guibe_arrived"
@ -132,4 +176,20 @@ class SecondGameLearnViewController: UIViewController, AVAudioPlayerDelegate {
} }
} }
func errorMsg() {
let alert = UIAlertController(title: "Playback Error", message: "Error in either keyValues or filename", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.dismiss(animated: true, completion: nil)
case .cancel:
return
case .destructive:
return
}}))
self.present(alert, animated: true, completion: nil)
}
} }

View File

@ -41,7 +41,8 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
cell.textLabel?.text = "Then in \(focusDistance)m, \(focusInstruction)" } cell.textLabel?.text = "Then in \(focusDistance)m, \(focusInstruction)" }
if indexPath.row == currentStep { if indexPath.row == currentStep {
cell.backgroundColor = .green cell.backgroundColor = .green
cell.accessibilityLabel = "\(cell.textLabel?.text), current step" let txt = (cell.textLabel?.text)!
cell.accessibilityLabel = "\(txt), current step"
} }
else { else {
cell.accessibilityLabel = cell.textLabel?.text cell.accessibilityLabel = cell.textLabel?.text