-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
352 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<menu id="MainMenu" title="@Strings.MainMenuTitle"> | ||
<menu-item id="selectHole" label="@Strings.MenuSelectHole"></menu-item> | ||
<menu-item id="changePar" label="@Strings.MenuPar"></menu-item> | ||
<menu-item id="numberOfHoles" label="@Strings.NumberOfHoles"></menu-item> | ||
<menu-item id="newGame" label="@Strings.MenuNewGame"></menu-item> | ||
<menu-item id="scorecard" label="@Strings.MenuScorecard"></menu-item> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Toybox.WatchUi as Ui; | ||
|
||
class SelectNumberOfHolesDelegate extends Ui.BehaviorDelegate{ | ||
|
||
hidden var mController; | ||
hidden var relatedView; | ||
|
||
function initialize(view, controller) { | ||
BehaviorDelegate.initialize(); | ||
relatedView = view; | ||
mController = controller; | ||
} | ||
|
||
function onCancel() { | ||
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE); | ||
} | ||
|
||
function onKey(keyEvent) { | ||
var key = keyEvent.getKey(); | ||
|
||
switch(key){ | ||
case Ui.KEY_UP: | ||
relatedView.addHole(); | ||
break; | ||
case Ui.KEY_DOWN: | ||
relatedView.removeHole(); | ||
break; | ||
case Ui.KEY_ENTER: | ||
relatedView.setHole(); | ||
Ui.popView(Ui.SLIDE_IMMEDIATE); | ||
return false; | ||
break; | ||
} | ||
relatedView.requestUpdate(); | ||
return false; | ||
} | ||
|
||
function onTap(keyEvent){ | ||
|
||
if(tapUp(keyEvent)){ | ||
relatedView.addHole(); | ||
} | ||
if(tapDown(keyEvent)){ | ||
relatedView.removeHole(); | ||
} | ||
relatedView.requestUpdate(); | ||
|
||
return false; | ||
} | ||
|
||
hidden function tapDown(keyEvent) { | ||
var coordinates = keyEvent.getCoordinates(); | ||
var gui = relatedView.gui; | ||
var tapDown = gui.tapBoxDown; | ||
|
||
return coordinates[0] > tapDown[0] && coordinates[0] < tapDown[0] + gui.TAP_BOX_WIDTH | ||
&& coordinates[1] > tapDown[1] && coordinates[1] < tapDown[1] + gui.TAP_BOX_HEIGHT; | ||
|
||
} | ||
|
||
hidden function tapUp(keyEvent) { | ||
var coordinates = keyEvent.getCoordinates(); | ||
var gui = relatedView.gui; | ||
var tapUp = gui.tapBoxUp; | ||
|
||
return coordinates[0] > tapUp[0] && coordinates[0] < tapUp[0] + gui.TAP_BOX_WIDTH | ||
&& coordinates[1] > tapUp[1] && coordinates[1] < tapUp[1] + gui.TAP_BOX_HEIGHT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
module Gui{ | ||
class SelectNumberOfHoles extends CommonGui{ | ||
|
||
var tapBoxUp; | ||
var tapBoxDown; | ||
|
||
hidden var numberPos; | ||
hidden var arrowPos; | ||
hidden var numberOfHoles; | ||
|
||
function initialize(dc, controller){ | ||
CommonGui.initialize(dc, controller); | ||
numberPos = [ width/2, height/2 ]; | ||
|
||
tapBoxUp = [numberPos[0] - 25, numberPos[1] - 75]; | ||
tapBoxDown = [numberPos[0] - 25, numberPos[1] + 25]; | ||
|
||
numberOfHoles = controller.getGame().getCourse().getNumberOfHoles(); | ||
} | ||
|
||
|
||
function setNumberOfHoles(n){ | ||
numberOfHoles = n; | ||
} | ||
|
||
function getNumberOfHoles(){ | ||
return numberOfHoles; | ||
} | ||
|
||
function update(){ | ||
setColor(); | ||
updateNumber(); | ||
} | ||
|
||
hidden function updateNumber(){ | ||
drawArrows(); | ||
drawNumber(); | ||
} | ||
|
||
hidden function drawNumber(){ | ||
drawText(numberOfHoles,numberPos, LARGE_FONT, CENTER_TEXT); | ||
} | ||
|
||
hidden function drawArrows() { | ||
var up = [UP_ARROW[0], UP_ARROW[1], UP_ARROW[2]]; | ||
var down = [DOWN_ARROW[0], DOWN_ARROW[1], DOWN_ARROW[2]]; | ||
|
||
var pos = [numberPos[0] - 15, numberPos[1] - 10]; | ||
|
||
setArrowPos(up, down, pos); | ||
|
||
mDc.fillPolygon(up); | ||
mDc.fillPolygon(down); | ||
|
||
resetArrowPos(up, down, pos); | ||
} | ||
|
||
hidden function setArrowPos(up, down, pos) { | ||
for(var i = 0; i < up.size(); i++){ | ||
up[i][0] += pos[0]; | ||
up[i][1] += pos[1] - 50; | ||
} | ||
|
||
for(var i = 0; i < down.size(); i++){ | ||
down[i][0] += pos[0]; | ||
down[i][1] += pos[1] + 50; | ||
} | ||
} | ||
|
||
hidden function resetArrowPos(up, down, pos) { | ||
for(var i = 0; i < up.size(); i++){ | ||
up[i][0] -= pos[0]; | ||
up[i][1] -= pos[1] - 50; | ||
} | ||
|
||
for(var i = 0; i < down.size(); i++){ | ||
down[i][0] -= pos[0]; | ||
down[i][1] -= pos[1] + 50; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.