Skip to content

Commit

Permalink
Small code improvements (#47)
Browse files Browse the repository at this point in the history
* move files around

* renamed classes
  • Loading branch information
pedrorijo91 authored Jun 21, 2023
1 parent 6c3bccb commit e0bfdd5
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"request": "launch",
"name": "Run App",
"stopAtLaunch": false,
"device": "${command:GetTargetDevice}"
"device": "fr945"
// "device": "${command:GetTargetDevice}"

},
{
"type": "monkeyc",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/delegates/endOfMatchDelegate.mc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Toybox.Lang;
import Toybox.WatchUi;

class endOfMatchDelegate extends WatchUi.InputDelegate {
class EndOfMatchDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
Expand Down
4 changes: 2 additions & 2 deletions source/delegates/initialScreenDelegate.mc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Toybox.Lang;
import Toybox.WatchUi;

class initialScreenDelegate extends WatchUi.InputDelegate {
class InitialScreenDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
Expand All @@ -12,7 +12,7 @@ class initialScreenDelegate extends WatchUi.InputDelegate {
switch (keyEvent.getKey()) {
case KEY_ESC: {}
case KEY_ENTER: {
WatchUi.pushView(new Rez.Menus.SetsMenu(), new menuNumberSetsDelegate(), WatchUi.SLIDE_BLINK);
WatchUi.pushView(new Rez.Menus.SetsMenu(), new MenuNumberSetsDelegate(), WatchUi.SLIDE_BLINK);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;

class menuNumberSetsDelegate extends WatchUi.MenuInputDelegate {
class MenuNumberSetsDelegate extends WatchUi.MenuInputDelegate {

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

function onMenuItem(item as Symbol) as Void {

var nbrSets = matchConfig.UNLIMITED_SETS;
var nbrSets = MatchConfig.UNLIMITED_SETS;

switch (item) {
case :sets_unlimited: {
Expand All @@ -29,11 +29,11 @@ class menuNumberSetsDelegate extends WatchUi.MenuInputDelegate {
Application.getApp().getMatchConfig().setNumberOfSets(nbrSets);

// if not unlimited sets, lets ask about super tie config
if (nbrSets != matchConfig.UNLIMITED_SETS) {
WatchUi.pushView(new Rez.Menus.SuperTieMenu(), new menuSuperTieDelegate(), WatchUi.SLIDE_BLINK);
if (nbrSets != MatchConfig.UNLIMITED_SETS) {
WatchUi.pushView(new Rez.Menus.SuperTieMenu(), new MenuSuperTieDelegate(), WatchUi.SLIDE_BLINK);
} else {
Application.getApp().initMatch();
WatchUi.pushView(new scoreView(), new scoreDelegate(), WatchUi.SLIDE_UP);
WatchUi.pushView(new ScoreView(), new ScoreDelegate(), WatchUi.SLIDE_UP);
}
}

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

class menuSuperTieDelegate extends WatchUi.MenuInputDelegate {
class MenuSuperTieDelegate extends WatchUi.MenuInputDelegate {

function initialize() {
MenuInputDelegate.initialize();
Expand All @@ -19,7 +19,7 @@ class menuSuperTieDelegate extends WatchUi.MenuInputDelegate {

Application.getApp().getMatchConfig().setSuperTie(superTie);
Application.getApp().initMatch();
WatchUi.pushView(new scoreView(), new scoreDelegate(), WatchUi.SLIDE_UP);
WatchUi.pushView(new ScoreView(), new ScoreDelegate(), WatchUi.SLIDE_UP);
}

}
6 changes: 3 additions & 3 deletions source/delegates/scoreDelegate.mc
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 scoreDelegate extends WatchUi.InputDelegate {
class ScoreDelegate extends WatchUi.InputDelegate {

function initialize() {
InputDelegate.initialize();
Expand All @@ -17,7 +17,7 @@ class scoreDelegate extends WatchUi.InputDelegate {
var endOfMatch = match.incP1();

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

break;
Expand All @@ -26,7 +26,7 @@ class scoreDelegate extends WatchUi.InputDelegate {
var endOfMatch = match.incP2();

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

break;
Expand Down
10 changes: 5 additions & 5 deletions source/garminpadelApp.mc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class garminpadelApp extends Application.AppBase {

function initialize() {
AppBase.initialize();
matchConfig = new matchConfig();
matchConfig = new MatchConfig();
}

function onStart(state as Dictionary?) as Void {
Expand All @@ -20,22 +20,22 @@ class garminpadelApp extends Application.AppBase {
}

function getInitialView() as Array<Views or InputDelegates>? {
return [ new initialView(), new initialScreenDelegate() ] 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 rely it's on a valid state at this moment
function initMatch() as Void {
self.match = new padelMatch(self.matchConfig);
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 {
function getMatch() as PadelMatch {
return self.match;
}

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

Expand Down
6 changes: 3 additions & 3 deletions source/model/match.mc → source/model/PadelMatch.mc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Toybox.Lang;

class padelMatch {
class PadelMatch {

private var numberOfSets;
private var superTie;
Expand All @@ -9,12 +9,12 @@ class padelMatch {

private var matchStatus;

function initialize(config as matchConfig) {
function initialize(config as MatchConfig) {

numberOfSets = config.getNumberOfSets();
superTie = config.getSuperTie();

matchStatus = new matchStatus();
matchStatus = new MatchStatus();

historicalScores = [];
}
Expand Down
2 changes: 1 addition & 1 deletion source/model/matchConfig.mc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Toybox.Lang;

class matchConfig {
class MatchConfig {

public static const UNLIMITED_SETS = 10;

Expand Down
2 changes: 1 addition & 1 deletion source/model/matchStatus.mc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class matchStatus {
class MatchStatus {

static const AVAILABLE_POINTS = [0, 15, 30, 40];

Expand Down
2 changes: 1 addition & 1 deletion source/views/endView.mc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Toybox.Graphics;
import Toybox.WatchUi;

class endView extends WatchUi.View {
class EndView extends WatchUi.View {

function initialize() {
View.initialize();
Expand Down
2 changes: 1 addition & 1 deletion source/views/initialView.mc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Toybox.Graphics;
import Toybox.WatchUi;

class initialView extends WatchUi.View {
class InitialView extends WatchUi.View {

function initialize() {
View.initialize();
Expand Down
2 changes: 1 addition & 1 deletion source/views/scoreView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Toybox.Graphics;
using Toybox.Time;
using Toybox.Time.Gregorian;

class scoreView extends WatchUi.View {
class ScoreView extends WatchUi.View {

function initialize() {
View.initialize();
Expand Down

0 comments on commit e0bfdd5

Please sign in to comment.