Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #116 from casd82/ui-update
Browse files Browse the repository at this point in the history
UI updates (7/25)
  • Loading branch information
jenpaff committed Aug 11, 2017
2 parents 4e7734e + 20bfb57 commit 59f97b3
Show file tree
Hide file tree
Showing 32 changed files with 130 additions and 139 deletions.
34 changes: 19 additions & 15 deletions Powerup/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1808" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="landscape">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -12,22 +15,23 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powerup" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splash_screen" translatesAutoresizingMaskIntoConstraints="NO" id="yal-qA-ygZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
<constraint firstAttribute="bottom" secondItem="yal-qA-ygZ" secondAttribute="bottom" id="4qj-bY-0o4"/>
<constraint firstItem="yal-qA-ygZ" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="MHU-T3-Myd"/>
<constraint firstAttribute="trailing" secondItem="yal-qA-ygZ" secondAttribute="trailing" id="axT-AP-u0c"/>
<constraint firstItem="yal-qA-ygZ" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="kYN-lv-A2T"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
<point key="canvasLocation" x="312" y="400"/>
</view>
</objects>
<resources>
<image name="splash_screen" width="1024" height="576"/>
</resources>
</document>
115 changes: 48 additions & 67 deletions Powerup/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

38 changes: 23 additions & 15 deletions Powerup/CustomizeAvatarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ class CustomizeAvatarViewController: UIViewController {
customFaceView.image = faceImage
}

/** Save the avatar to the database. If successful, return true. Otherwise, return false. */
func saveAvatar() -> Bool {
do {
try dataSource.createAvatar(avatar)
} catch _ {
let alert = UIAlertController(title: "Warning", message: "Failed to save avatar, please retry this action. If that doesn't help, try restaring or reinstalling the app.", preferredStyle: .alert)

// Unwind to Start View when Ok Button is pressed.
let okButton = UIAlertAction(title: "OK", style: .cancel, handler: {action in
self.performSegue(withIdentifier: "unwindToStartScene", sender: self)
})
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)

return false
}

return true
}

// MARK: Actions
@IBAction func eyesLeftButtonTouched(_ sender: UIButton) {
let totalCount = eyes.count
Expand Down Expand Up @@ -139,22 +159,10 @@ class CustomizeAvatarViewController: UIViewController {
}

@IBAction func continueButtonTouched(_ sender: UIButton) {
// Save the current configuration to database.
do {
try dataSource.createAvatar(avatar)
} catch _ {
let alert = UIAlertController(title: "Warning", message: "Failed to save avatar, please retry this action. If that doesn't help, try restaring or reinstalling the app.", preferredStyle: .alert)

// Dismiss the modal VC (so the app is back to Start View) when Ok Button is pressed.
let okButton = UIAlertAction(title: "OK", style: .cancel, handler: {action in self.dismiss(animated: true, completion: nil)})
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)

return
if saveAvatar() {
// Perform Push segue to map scene.
performSegue(withIdentifier: "toMapScene", sender: self)
}

// Dismiss the modal VC
self.dismiss(animated: true, completion: nil)
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions Powerup/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"idiom" : "iphone",
"filename" : "40px.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"idiom" : "iphone",
"filename" : "60px.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "58px.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "87px.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "80px.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "120px.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "120px-1.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "180px.png",
"scale" : "3x"
},
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Powerup/Images.xcassets/buttons.imageset/buttons.png
Binary file not shown.
21 changes: 0 additions & 21 deletions Powerup/Images.xcassets/logo.imageset/Contents.json

This file was deleted.

Binary file removed Powerup/Images.xcassets/logo.imageset/logo.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "buttons.png"
"filename" : "replay button.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "replay button-2.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "replay button-1.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "buttons 3.png"
"filename" : "splash screen.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "splash screen-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "splash screen-2.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "background.png"
"filename" : "start screen.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "start screen-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "start screen-2.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions Powerup/ScenarioViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class ScenarioViewController: UIViewController {
if let initQuestionID = (questions.min {a, b in a.key < b.key}?.key) {
currQuestionID = initQuestionID
}

resetQuestionAndChoices()
}

// MARK: Actions
Expand Down Expand Up @@ -188,5 +186,10 @@ class ScenarioViewController: UIViewController {
}
}


// Replay the scenario.
@IBAction func unwindToScenario(unwindSegue: UIStoryboardSegue) {
initializeQuestions()

resetQuestionAndChoices()
}
}
8 changes: 5 additions & 3 deletions Powerup/StartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ class StartViewController: UIViewController {
performSegue(withIdentifier: "toMapView", sender: self)
} else {
// Remind players to create an avatar first.
let alert = UIAlertController(title: "Warning", message: "You should create a new avatar first!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
let alert = UIAlertController(title: "Warning", message: "Create your avatar to start the game!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: {action in
self.performSegue(withIdentifier: "toNewAvatar", sender: self)
}))
self.present(alert, animated: true)
}
}

@IBAction func newAvatarButtonTouched(_ sender: UIButton) {
// If previous avatar exists, warns the player that previous data will be lost.
if dataSource.avatarExists() {
let alert = UIAlertController(title: "Warning", message: "Sure you want to create a new avatar? Previous data will be lost!", preferredStyle: .alert)
let alert = UIAlertController(title: "Are you sure?", message: "If you start a new game, previous data and all Karma points will be lost!", preferredStyle: .alert)
let okButton = UIAlertAction(title: "Create New Avatar", style: .destructive, handler: {(action) -> Void in self.performSegue(withIdentifier: "toNewAvatar", sender: self)})
let cancelButton = UIAlertAction(title: "Cancel", style: .cancel)

Expand Down
2 changes: 1 addition & 1 deletion PowerupTests/CustomizeAvatarViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CustomizeAvatarViewControllerTests: XCTestCase {
customizeAvatarViewController.hairRightButtonTouched(UIButton())

// Press continue button (save avatar).
customizeAvatarViewController.continueButtonTouched(UIButton())
XCTAssertTrue(customizeAvatarViewController.saveAvatar())

// Then (Check if the correct accessory id is configured and saved).
XCTAssertEqual(mockData.createdAvatar!.clothes.id, 3)
Expand Down

0 comments on commit 59f97b3

Please sign in to comment.