Files
2026-10-05 20:55:29 +01:00

74 lines
2.7 KiB
Mason

import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;
class mainDelegate extends WatchUi.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
gMenuTeams = new WatchUi.Menu2({:title => "Select Team"});
gMenuTeams.addItem(new WatchUi.MenuItem(HOME.toString(), null, HOME, null));
gMenuTeams.addItem(new WatchUi.MenuItem(AWAY.toString(), null, AWAY, null));
gMenuActions = new WatchUi.Menu2({:title => "Select Action"});
gMenuActions.addItem(new WatchUi.MenuItem("Record Goal", "FG, PC, or PS", GOAL, null));
gMenuActions.addItem(new WatchUi.MenuItem("Record Card", "Green, Yellow, Red", CARD, null));
gMenuActions.addItem(new WatchUi.MenuItem("Quit", "TODO:", QUIT, null));
gMenuGoals = new WatchUi.Menu2({:title => "Select Goal"});
gMenuGoals.addItem(new WatchUi.MenuItem("Field Goal", null, FG, null));
gMenuGoals.addItem(new WatchUi.MenuItem("Penaly Corner", null, PC, null));
gMenuGoals.addItem(new WatchUi.MenuItem("Penalty Stroke", null, PS, null));
gMenuCards = new WatchUi.Menu2({:title => "Select Card"});
gMenuCards.addItem(new WatchUi.MenuItem("Green Card", null, GREEN, {:icon => $.gIconGreen}));
gMenuCards.addItem(new WatchUi.MenuItem("Yellow Card", null, YELLOW, {:icon => $.gIconYellow}));
gMenuCards.addItem(new WatchUi.MenuItem("Red Card", null, RED, {:icon => $.gIconRed}));
gMenuApp = new WatchUi.Menu2({:title => "Select Action"});
gMenuApp.addItem(new WatchUi.MenuItem("New Game", null, 0, null));
gMenuApp.addItem(new WatchUi.MenuItem("Exit", null, 1, null));
}
function onKey(keyEvent as WatchUi.KeyEvent) as Boolean {
switch(keyEvent.getKey()){
case WatchUi.KEY_ENTER:
switch($.gMatch.state){
case PREGAME:
$.gMatch.state = INGAME;
case INGAME:
$.gMatch.period.playPause();
break;
case POSTGAME:
break;
}
return true;
case WatchUi.KEY_ESC:
switch($.gMatch.state){
case POSTGAME:
default:
WatchUi.pushView($.gMenuActions, new menuActionsDelegate(), WatchUi.SLIDE_UP);
return true;
}
case WatchUi.KEY_DOWN:
return true;
case WatchUi.KEY_UP:
return true;
default:
return false;
}
}
function onMenu() as Boolean {
return false;
}
}