Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for menu and number of sets #39

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Keeps track of padel match score.
* Unlimited sets
* Save game score in activity details
* display current hearth rate
* Configure number of sets

Not yet supported:

* advantages support - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/1)
* Super tie break - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/3)
* Configure number of sets - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/17)
* advantages support - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/1)
* Display who should be serving - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/6)
* Revert scores - [github issue](https://github.com/pedrorijo91/garmin-padel/issues/5)

Expand All @@ -28,7 +28,11 @@ After starting the application, the initial screen will show up:

<p align="center"><img src="screenshots/initial.jpeg" width="300"></p>

Just click any button and the score screen will display:
Just click the `Enter` button to enter the menu where you can configure the match settings. See the corresponding section for more details on available game options. // FIXME add link

Use the `Up` and `Down` buttons on your device to scroll on each configuration, and use the `Enter`button to select.

After selecting all the options the score screen will display:

<p align="center"><img src="screenshots/score0.jpeg" width="300"></p>

Expand All @@ -38,9 +42,27 @@ Now you can control the score by clicking the `Up` and `Down` buttons on your de

<p align="center"><img src="screenshots/scoreTie.jpeg" width="300"></p>

To finish the activity, just click the `Back` button.
If you selected a limited amount of sets (current options are 3, 5, or unlimited sets), when the game is over you'll see a final screen with the game summary:

<p align="center"><img src="screenshots/end.jpeg" width="300"></p>

If you select unlimited sets, to finish the activity at any moment, just click the `Back` button and confirm you wish to finish it:

<p align="center"><img src="screenshots/exit_confirmation.jpeg" width="300"></p>

After syncing with your Garmin Connect account, you'll be able to see some custom information about the match, such as game result.

## Available Game Configurations

### number of sets

This app allows to configure the number of sets for your game:

* 3 sets
* 5 sets
* unlimited sets, useful for friendly matches that don't have a limited number of sets.

After syncing with your Garmin Connect accountm you'll be able to see some custom information about the match.
<p align="center"><img src="screenshots/menu_sets.jpeg" width="300"></p>

## List of supported devices

Expand Down
5 changes: 5 additions & 0 deletions resources/layouts/endOfMatchLayout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<layout id="EndOfMatchLayout">
<label x="center" y="55" text="Game Ended" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" />
<label id="resultLabel" x="center" y="135" color="Graphics.COLOR_WHITE" font="Graphics.FONT_SMALL" justification="Graphics.TEXT_JUSTIFY_CENTER" />
<label x="center" y="195" text="\@pedrorijo91" color="Graphics.COLOR_WHITE" font="Graphics.FONT_XTINY" justification="Graphics.TEXT_JUSTIFY_CENTER" />
</layout>
2 changes: 1 addition & 1 deletion resources/layouts/layout.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<layout id="MainLayout">
<layout id="InitialLayout">
<label x="center" y="55" text="Padel Score" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" />
<label x="center" y="135" text="\@pedrorijo91" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" />
<label id="versionLabel" x="center" y="195" color="Graphics.COLOR_WHITE" font="Graphics.FONT_XTINY" justification="Graphics.TEXT_JUSTIFY_CENTER" />
Expand Down
4 changes: 0 additions & 4 deletions resources/menus/menu.xml

This file was deleted.

5 changes: 5 additions & 0 deletions resources/menus/setsMenu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<menu id="SetsMenu" title="Sets">
<menu-item id="sets_unlimited" label="Unlimited" />
<menu-item id="sets_3" label="3" />
<menu-item id="sets_5" label="5" />
</menu>
7 changes: 0 additions & 7 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<strings>
<string id="AppName">Padel Score</string>

<string id="prompt">Padel app</string>
<string id="prompt2">Scores</string>

<string id="menu_label_1">Item 1</string>
<string id="menu_label_2">Item 2</string>

<string id="fit_score_label">Game Score</string>
<string id="namaste_graph_label">Namastes</string>
<string id="fit_score_units">points</string>
</strings>
Binary file added screenshots/end.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/exit_confirmation.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/initial.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/menu_sets.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/old/initial.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/old/score0.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/old/scoreMid.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/old/scoreTie.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/score0.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/scoreMid.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/scoreTie.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions source/delegates/endOfMatchDelegate.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Toybox.Lang;
import Toybox.WatchUi;

class endOfMatchDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
}

function onKey(keyEvent as WatchUi.KeyEvent) as Boolean {

switch (keyEvent.getKey()) {
case KEY_ESC: {}
case KEY_ENTER: {
var message = "Finish Activity?";
var dialog = new WatchUi.Confirmation(message);
WatchUi.pushView(
dialog,
new FinishConfirmationDelegate(),
WatchUi.SLIDE_IMMEDIATE
);
}
}

return true;
}

}
26 changes: 0 additions & 26 deletions source/delegates/garminpadelDelegate.mc

This file was deleted.

22 changes: 0 additions & 22 deletions source/delegates/garminpadelMenuDelegate.mc

This file was deleted.

23 changes: 23 additions & 0 deletions source/delegates/initialScreenDelegate.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Toybox.Lang;
import Toybox.WatchUi;

class initialScreenDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
}

function onKey(keyEvent as WatchUi.KeyEvent) as Boolean {

switch (keyEvent.getKey()) {
case KEY_ESC: {}
case KEY_ENTER: {
WatchUi.pushView(new Rez.Menus.SetsMenu(), new menuNumberSetsDelegate(), WatchUi.SLIDE_BLINK);
break;
}
}

return true;
}

}
36 changes: 36 additions & 0 deletions source/delegates/menuNumberSetsDelegate.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;

class menuNumberSetsDelegate extends WatchUi.MenuInputDelegate {

function initialize() {
MenuInputDelegate.initialize();
}

function onMenuItem(item as Symbol) as Void {

var nbrSets = matchConfig.UNLIMITED_SETS;

switch (item) {
case :sets_unlimited: {
break;
}
case :sets_5: {
nbrSets = 5;
break;
}
case :sets_3: {
nbrSets = 3;
break;
}
}

Application.getApp().getMatchConfig().setNumberOfSets(nbrSets);


Application.getApp().initMatch();
WatchUi.pushView(new scoreView(), new scoreDelegate(), WatchUi.SLIDE_UP);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Toybox.Lang;
import Toybox.WatchUi;
import Toybox.ActivityMonitor;

class garminpadelScoreDelegate extends WatchUi.InputDelegate {
class scoreDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
Expand All @@ -14,11 +14,21 @@ class garminpadelScoreDelegate extends WatchUi.InputDelegate {

switch (keyEvent.getKey()) {
case KEY_UP: {
match.incP1();
var endOfMatch = match.incP1();

if (endOfMatch) {
WatchUi.pushView(new endView(), new endOfMatchDelegate(), WatchUi.SLIDE_UP);
}

break;
}
case KEY_DOWN: {
match.incP2();
var endOfMatch = match.incP2();

if (endOfMatch) {
WatchUi.pushView(new endView(), new endOfMatchDelegate(), WatchUi.SLIDE_UP);
}

break;
}
case KEY_ENTER: {
Expand Down
38 changes: 24 additions & 14 deletions source/garminpadelApp.mc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import Toybox.WatchUi;

class garminpadelApp extends Application.AppBase {

private var matchConfig;
private var match;
private var session;

function initialize() {
AppBase.initialize();

match = new padelMatch();
session = ActivityRecording.createSession({:sport => Activity.SPORT_RACKET, :subSport => Activity.SUB_SPORT_PADEL, :name => "Padel match"});
session.start();
matchConfig = new matchConfig();
}

// onStart() is called on application start up
Expand All @@ -25,16 +23,26 @@ class garminpadelApp extends Application.AppBase {

// Return the initial view of your application here
function getInitialView() as Array<Views or InputDelegates>? {
return [ new garminpadelView(), new garminpadelDelegate() ] as Array<Views or InputDelegates>;
return [ new initialView(), new initialScreenDelegate() ] as Array<Views or InputDelegates>;
}

// TODO kinda meh that we allow everyone to update the matchConfig and we realy it's on a valid state at this moment
function initMatch() as Void {
self.match = new padelMatch(self.matchConfig);

self.session = ActivityRecording.createSession({:sport => Activity.SPORT_RACKET, :subSport => Activity.SUB_SPORT_PADEL, :name => "Padel match"});
self.session.start();
}

function getMatch() as padelMatch {
return self.match;
}

function saveSession() as Void {
var field = session.createField("game_score", 0, FitContributor.DATA_TYPE_STRING, {:mesgType => FitContributor.MESG_TYPE_SESSION, :units => "points", :count => 50});

function getMatchConfig() as matchConfig {
return self.matchConfig;
}

function getScoreString() as String {
var score = "";
var historicalScores = self.match.getHistoricalScores();
for(var i = 0; i < historicalScores.size(); i++ ) {
Expand All @@ -43,15 +51,17 @@ class garminpadelApp extends Application.AppBase {
if(historicalScores.size() > 0) {
score = score.substring(0, score.length() - 3);
}

return score;
}

function saveSession() as Void {
var field = session.createField("game_score", 0, FitContributor.DATA_TYPE_STRING, {:mesgType => FitContributor.MESG_TYPE_SESSION, :units => "points", :count => 50});

var score = self.getScoreString();
field.setData(score);

self.session.stop();
self.session.save();
}
}



function getApp() as garminpadelApp {
return Application.getApp() as garminpadelApp;
}
Loading