Skip to content

Commit

Permalink
finished main functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehasawii committed May 3, 2023
1 parent ac1ec7b commit c584b8f
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 68 deletions.
4 changes: 4 additions & 0 deletions SoundboardQuiz.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
2A9093D329F72D3D002DBA4F /* ImageCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A9093D229F72D3D002DBA4F /* ImageCollectionView.swift */; };
2A9093D529F72D49002DBA4F /* SoundCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A9093D429F72D49002DBA4F /* SoundCollectionView.swift */; };
2A9093D729F73564002DBA4F /* MainGameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A9093D629F73564002DBA4F /* MainGameViewController.swift */; };
2A9F5AB12A02BF0700EA876A /* Sound.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A9F5AB02A02BF0700EA876A /* Sound.swift */; };
2AC1DDC129F6D292001253C3 /* SoundCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC1DDC029F6D292001253C3 /* SoundCollectionViewCell.swift */; };
2AC1DDC329F6D2A8001253C3 /* ImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC1DDC229F6D2A8001253C3 /* ImageCollectionViewCell.swift */; };
2AC1DDC929F6E1A2001253C3 /* TestTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC1DDC829F6E1A2001253C3 /* TestTableViewCell.swift */; };
Expand Down Expand Up @@ -71,6 +72,7 @@
2A9093D229F72D3D002DBA4F /* ImageCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ImageCollectionView.swift; path = SoundboardQuiz/ImageCollectionView.swift; sourceTree = "<group>"; };
2A9093D429F72D49002DBA4F /* SoundCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SoundCollectionView.swift; path = SoundboardQuiz/SoundCollectionView.swift; sourceTree = "<group>"; };
2A9093D629F73564002DBA4F /* MainGameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MainGameViewController.swift; path = SoundboardQuiz/MainGameViewController.swift; sourceTree = "<group>"; };
2A9F5AB02A02BF0700EA876A /* Sound.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Sound.swift; path = SoundboardQuiz/Sound.swift; sourceTree = "<group>"; };
2AC1DDC029F6D292001253C3 /* SoundCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SoundCollectionViewCell.swift; path = SoundboardQuiz/SoundCollectionViewCell.swift; sourceTree = "<group>"; };
2AC1DDC229F6D2A8001253C3 /* ImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ImageCollectionViewCell.swift; path = SoundboardQuiz/ImageCollectionViewCell.swift; sourceTree = "<group>"; };
2AC1DDC829F6E1A2001253C3 /* TestTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -108,6 +110,7 @@
2A0ACEE629F19CE7001E5D03 = {
isa = PBXGroup;
children = (
2A9F5AB02A02BF0700EA876A /* Sound.swift */,
2AEE28262A001CA800DEFFAC /* Sounds */,
2AC1DDC829F6E1A2001253C3 /* TestTableViewCell.swift */,
2A0ACF0A29F1A02E001E5D03 /* AppDelegate.swift */,
Expand Down Expand Up @@ -266,6 +269,7 @@
buildActionMask = 2147483647;
files = (
2A9093D729F73564002DBA4F /* MainGameViewController.swift in Sources */,
2A9F5AB12A02BF0700EA876A /* Sound.swift in Sources */,
2A0ACF1E29F1A02F001E5D03 /* CategoryTableViewCell.swift in Sources */,
2A0ACF2329F1A02F001E5D03 /* SceneDelegate.swift in Sources */,
2A2B750F29F2F0130089DE69 /* SquareCollectionViewController.swift in Sources */,
Expand Down
16 changes: 15 additions & 1 deletion SoundboardQuiz/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {
public lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
Expand Down Expand Up @@ -161,6 +161,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}

// func applicationDidEnterBackground(_ application: UIApplication) {
//
// }
func applicationWillTerminate(_ application: UIApplication) {
do{
try MainGameViewController.attemptSaveState()
} catch{
print(error.localizedDescription)
// We are not currently in the middle of a game, so we can safely exit
UserDefaults.standard.removeObject(forKey: "lastState")
}

}



Expand Down
26 changes: 17 additions & 9 deletions SoundboardQuiz/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="t26-Si-8kE">
<rect key="frame" x="-11" y="164" width="393" height="641"/>
<rect key="frame" x="-12" y="163" width="394" height="641"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="categoryCell" id="N0p-1K-NE1" customClass="CategoryCellTableViewCell" customModule="SoundboardQuiz" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="393" height="43.666667938232422"/>
<rect key="frame" x="0.0" y="50" width="394" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="N0p-1K-NE1" id="Y9C-qI-fgd">
<rect key="frame" x="0.0" y="0.0" width="393" height="43.666667938232422"/>
<rect key="frame" x="0.0" y="0.0" width="394" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3NR-GS-yw4">
Expand Down Expand Up @@ -120,23 +120,26 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VUY-3M-0xL">
<rect key="frame" x="56" y="354.66666666666669" width="280" height="95.666666666666686"/>
<rect key="frame" x="56" y="354.66666666666669" width="280" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="LAm-eY-bzi"/>
</constraints>
<color key="tintColor" systemColor="systemRedColor"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Resume (TODO)" cornerStyle="dynamic">
<buttonConfiguration key="configuration" style="filled" title="Resume" cornerStyle="dynamic">
<backgroundConfiguration key="background" cornerRadius="13" imageContentMode="left">
<color key="backgroundColor" systemColor="systemRedColor"/>
<imageReference key="image" image="arrow.forward" catalog="system" symbolScale="large" renderingMode="original" variableValue="1"/>
</backgroundConfiguration>
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
<directionalEdgeInsets key="contentInsets" top="0.0" leading="30" bottom="0.0" trailing="10"/>
</buttonConfiguration>
<connections>
<segue destination="tXV-QY-UTS" kind="show" identifier="directGameViewSegue" id="WQn-BQ-bGV"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2We-Bk-sxh">
<rect key="frame" x="56" y="727.33333333333337" width="280" height="48"/>
<rect key="frame" x="56" y="658.66666666666663" width="280" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="rhm-w8-BaR"/>
</constraints>
Expand All @@ -157,7 +160,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZMn-IS-d62">
<rect key="frame" x="56" y="548.33333333333337" width="280" height="51.333333333333371"/>
<rect key="frame" x="56" y="490.99999999999994" width="280" height="51.333333333333314"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="Fbp-bM-DPN"/>
</constraints>
Expand Down Expand Up @@ -238,11 +241,13 @@
<outlet property="delegate" destination="BBh-RV-B99" id="uPL-6W-6Ob"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="Vzd-VX-nCI"/>
<navigationItem key="navigationItem" id="Vzd-VX-nCI">
<barButtonItem key="backBarButtonItem" title="Exit" id="fs4-fn-5YZ"/>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="J2l-7l-fcn" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2061.8320610687024" y="29.577464788732396"/>
<point key="canvasLocation" x="2905" y="-347"/>
</scene>
<!--High Scores View Controller-->
<scene sceneID="co0-ym-JTk">
Expand Down Expand Up @@ -636,6 +641,9 @@
<point key="canvasLocation" x="4737" y="-487"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="WQn-BQ-bGV"/>
</inferredMetricsTieBreakers>
<resources>
<image name="arrow.forward" catalog="system" width="128" height="95"/>
<image name="play.fill" catalog="system" width="117" height="128"/>
Expand Down
1 change: 1 addition & 0 deletions SoundboardQuiz/GameOverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class GameOverViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.hidesBackButton = true
UserDefaults.standard.removeObject(forKey: "lastState")
if let score, let categoryName {
scoreLabel.text = "Score: \(score)"
let defaults = UserDefaults.standard
Expand Down
1 change: 1 addition & 0 deletions SoundboardQuiz/HighScoresViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class HighScoresViewController: UIViewController {
override func viewDidLoad() {
scoreArray = [score1, score2, score3, score4, score5]
super.viewDidLoad()
print("Entered High Scores View Controller")
// let defaults = UserDefaults.standard
//let highScoresArr: Array<(String, Int)>? = defaults.array(forKey: "highScores") as? Array<(String, Int)>
let fetchedData = UserDefaults.standard.data(forKey: "highScores")!
Expand Down
2 changes: 2 additions & 0 deletions SoundboardQuiz/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationExitsOnSuspend</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
Loading

0 comments on commit c584b8f

Please sign in to comment.