This commit is contained in:
kejaro committed 2026-09-29 15:27:22 +01:00
commit 13f4132d3c
58 files changed
+6291

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;
class hockeyTimerApp extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state as Dictionary?) as Void {
}
// onStop() is called when your application is exiting
function onStop(state as Dictionary?) as Void {
}
// Return the initial view of your application here
function getInitialView() as [Views] or [Views, InputDelegates] {
return [ new hockeyTimerView(), new MyInputDelegate() ];
}
}
function getApp() as hockeyTimerApp {
return Application.getApp() as hockeyTimerApp;
}
+176
View File
@@ -0,0 +1,176 @@
import Toybox.Lang;
import Toybox.WatchUi;
import Toybox.Time;
import Toybox.Timer;
import Toybox.System;
public enum enCard{
RED,
YELLOW,
GREEN
}
public enum enGoal{
PC,
PS,
FG
}
public enum enTeam{
HOME,
AWAY
}
// public enum enState{
// PREGAME,
// STARTGAME,
// PREPLAY,
// PLAY,
// POSTPLAY,
// BREAK,
// POSTBREAK,
// PLAYPAUSED,
// GAMEOVER
// }
public enum enAction{
GOAL,
CARD,
QUIT
}
public enum enPeriod{
PLAY,
BREAK
}
var gameDuration as Number?;
var gameElapsed as Number?;
var gamePeriod as Number?;
class goal {
private var _team as enTeam;
private var _type as enGoal;
private var _time as Number;
private var _player as Number;
private var _datetime as Number;
function initialize(team as enTeam, type as enGoal, player as Number, time as Number) {
_team = team;
_type = type;
_time = time;
_player = player;
_datetime = Time.now().value();
}
function toDict() as Dictionary {
return {
"team" => _team,
"type" => _type,
"time" => _time,
"player" => _player,
"datetime" => _datetime
};
}
}
class card {
public var team as enTeam;
public var card as enCard;
public var player as Number;
public var remaining as Number;
public var isActive as Boolean;
private var start as Number?;
private var end as Number?;
private var duration as Number?;
private var _datetime as Number?;
// public var display as String?;
function initialize(tm as enTeam, cd as enCard, pl as Number, dn as Number, st as Number){
team = tm;
card = cd;
start = st;
duration = dn * 60;
remaining = duration;
end = start + duration;
player = pl;
isActive = true;
_datetime = Time.now().value();
// display = Lang.format("T:$1$-P:$2$-C:G",[_team, _player]);
}
// public function timeRemaining(el as Number) as Number{
// return end - el;
// }
public function dummy(q as Boolean) as Void{}
public function update(el as Number) as Void{
remaining = end - el;
if(end - el == 0){
// WatchUi.pushView(new menuConfirmationDelegate(Lang.format("Card: $1$ Over",[player.format("%02d")]), false), new ConfirmationDelegate(method(:dummy)), WatchUi.SLIDE_LEFT);
System.println(Lang.format("Card: $1$ Over",[player.format("%02d")]));
isActive = false;
}
}
function toDict() as Dictionary {
return {
"team" => team,
"start" => start,
"end" => end,
"card" => card,
"player" => player,
"duration" => duration,
"datetime" => _datetime
};
}
}
class match {
function initialize() {
}
}
class period{
// private var _timer;
public var display as String?;
public var type as enPeriod?;
// public var isOver as Boolean = false;
public var duration as Number?;
public var remaining as Number?;
// public var elapsed as Number = 0;
// private var _acc as Number = 0;
// private var _start as Number = 0;
// private var _dur as Number = 0;
function initialize(Display as String, Type as enPeriod, Duration as Number){//}, callBack as Method) {
display = Display;
type = Type;
duration = Duration;
remaining = Duration;
// _timer = new Timer.Timer();
}
// public function playPause(play as Boolean){
// if (play){
// _start = System.getTimer();
// _timer.start(method(:tick), 100, true);
// }
// else{
// _timer.stop();
// _acc += System.getTimer() - _start;
// }
// }
public function elapsed(){
}
}
+8
View File
@@ -0,0 +1,8 @@
import Toybox.Lang;
import Toybox.WatchUi;
public var gMenuTeams as WatchUi.Menu2?;
public var gMenuActions as WatchUi.Menu2?;
public var gMenuGoals as WatchUi.Menu2?;
public var gMenuCards as WatchUi.Menu2?;
public var gMenuApp as WatchUi.Menu2?;
+49
View File
@@ -0,0 +1,49 @@
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Time;
import Toybox.UserProfile;
public enum colourThemes {
background = 0,
timer,
timerBg,
timerBreak,
timerPause,
progress,
text
}
public var gColours as Array = [];
public function setColourTheme(id as Number) as Void {
switch(id) { //background, timer, timerBg, timerBreak,timerPause,progress, text, date, dateDim, notif, stress, bodybatt, moon
case 0: $.gColours = [0x000000, 0xFFFF00, 0x005555, 0xFF0000, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFFF00, 0xa98753, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Yellow on turquoise MIP
case 1: $.gColours = [0x000000, 0xFFFF00, 0x005555, 0xFF0000, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFFF00, 0xa98753, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Yellow on turquoise MIP
case 2: $.gColours = [0x000000, 0xFFFF00, 0x005555, 0xFF0000, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFFF00, 0xa98753, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Yellow on turquoise MIP
case 3: $.gColours = [0x000000, 0xFFFF00, 0x005555, 0xFF0000, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFFF00, 0xa98753, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Yellow on turquoise MIP
case 4: $.gColours = [0x000000, 0xFF55AA, 0x005555, 0xFF55AA, 0xFFFFFF, 0x005555, 0xAA55AA, 0xFFFFFF, 0xa95399, 0xFF55AA, 0xFF55AA, 0x00FFAA, 0xFFFFFF]; break;// Hot pink MIP
case 5: $.gColours = [0x000000, 0x00FFFF, 0x0055AA, 0x00FFFF, 0xFFFFFF, 0x0055AA, 0x55AAAA, 0x00FFFF, 0x5ca28f, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Blueish green MIP
case 6: $.gColours = [0x000000, 0x00FF00, 0x005500, 0x00FF00, 0xFFFFFF, 0x005500, 0x00AA55, 0x00FF00, 0x5ca28f, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// Very green MIP
case 7: $.gColours = [0x000000, 0xFFFFFF, 0x005555, 0xFFFFFF, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFFFFF, 0x114a5a, 0xAAAAAA, 0xFFAA55, 0x55AAFF, 0xFFFFFF]; break;// White on turquoise MIP
case 8: $.gColours = [0x000000, 0xFF5500, 0x5500AA, 0xFF5500, 0xFFFFFF, 0x5500AA, 0xFFAAAA, 0xFFAAAA, 0xaa6e56, 0xFFFFFF, 0xFF5555, 0x00AAFF, 0xFFFFFF]; break;// Peachy Orange MIP
case 9: $.gColours = [0x000000, 0xFFFFFF, 0xAA0000, 0xFFFFFF, 0xFFFFFF, 0xAA0000, 0xFF0000, 0xFFFFFF, 0xAA0000, 0xFF0000, 0xAA0000, 0x00AAFF, 0xFFFFFF]; break;// Red and White MIP
case 10: $.gColours = [0x000000, 0xFFFFFF, 0x0055AA, 0xFFFFFF, 0xFFFFFF, 0x0055AA, 0x0055AA, 0xFFFFFF, 0x0055AA, 0x55AAFF, 0xFFAA00, 0x55AAFF, 0xFFFFFF]; break;// White on Blue MIP
case 11: $.gColours = [0x000000, 0xFFAA00, 0x002424, 0xFFAA00, 0xFFFFFF, 0x005555, 0x55AAAA, 0xFFAA55, 0x555555, 0x55AAAA, 0xFFAA00, 0x55AAAA, 0xFFFFFF]; break;// Orange on Teal MIP
case 12: $.gColours = [0x000000, 0xFFFFFF, 0xaa5500, 0xFFFFFF, 0xFFFFFF, 0xaa5500, 0xFF5500, 0xFFFFFF, 0xAA5500, 0x00AAFF, 0xFFAA00, 0x00AAFF, 0xFFFFFF]; break;// White and Orange MIP
case 13: $.gColours = [0x000000, 0x0055AA, 0x000055, 0x0055AA, 0xFFFFFF, 0x555555, 0x0055AA, 0xFFFFFF, 0x0055AA, 0x55AAFF, 0xFFAA00, 0x55AAFF, 0xFFFFFF]; break;// Blue MIP
case 14: $.gColours = [0x000000, 0xFFAA00, 0x555555, 0xFFAA00, 0xFFFFFF, 0x555555, 0xFFAA00, 0xFFFFFF, 0x555555, 0x55AAFF, 0xFFAA00, 0x55AAFF, 0xFFFFFF]; break;// Orange MIP
case 15: $.gColours = [0x000000, 0xFFFFFF, 0x555555, 0xFFFFFF, 0xFFFFFF, 0x555555, 0xFFFFFF, 0xFFFFFF, 0x555555, 0x55AAFF, 0xFFAA00, 0x55AAFF, 0xFFFFFF]; break;// White on black MIP
case 16: $.gColours = [0xFFFFFF, 0x000000, 0xAAAAAA, 0x000000, 0x000000, 0xAAAAAA, 0x000000, 0x000000, 0x555555, 0x000000, 0xFFAA00, 0x55AAFF, 0x555555]; break;// Black on White MIP
case 17: $.gColours = [0xFFFFFF, 0xAA0000, 0xAAAAAA, 0xAA0000, 0x000000, 0xAAAAAA, 0xAA0000, 0x000000, 0x555555, 0x000000, 0xFFAA00, 0x55AAFF, 0x555555]; break;// Red on White MIP
case 18: $.gColours = [0xFFFFFF, 0x0000AA, 0xAAAAAA, 0x0000AA, 0x000000, 0xAAAAAA, 0x0000AA, 0x000000, 0x555555, 0x000000, 0xFFAA00, 0x55AAFF, 0x555555]; break;// Blue on White MIP
case 19: $.gColours = [0xFFFFFF, 0x00AA00, 0xAAAAAA, 0x00AA00, 0x000000, 0xAAAAAA, 0x00AA00, 0x000000, 0x555555, 0x000000, 0xFFAA00, 0x55AAFF, 0x555555]; break;// Green on White MIP
case 20: $.gColours = [0xFFFFFF, 0xFF5500, 0xAAAAAA, 0xFF5500, 0x000000, 0xAAAAAA, 0x555555, 0x000000, 0x555555, 0x000000, 0xFF5500, 0x55AAFF, 0x555555]; break;// Orange on White MIP
case 21: $.gColours = [0x000000, 0xFF5500, 0x005500, 0xFF5500, 0x00FF00, 0x005500, 0xFF5500, 0x00FF00, 0x5ca28f, 0x55FF55, 0xFF5500, 0x00AAFF, 0xFFFFFF]; break;// Green and Orange MIP
case 22: $.gColours = [0x000000, 0xAAAA55, 0x005500, 0xAAAA55, 0x00FF00, 0x005500, 0xAAAA00, 0xAAAA55, 0x546a36, 0x00FF55, 0xAAAA55, 0x00FF00, 0xFFFFFF]; break;// Green Camo MIP
case 23: $.gColours = [0x000000, 0xFF0000, 0x555555, 0xFF0000, 0xFFFFFF, 0x555555, 0xFF0000, 0xFFFFFF, 0x555555, 0x55AAFF, 0xFF5555, 0x55AAFF, 0xFFFFFF]; break;// Red on Black MIP
case 24: $.gColours = [0xFFFFFF, 0xAA00FF, 0xAAAAAA, 0xAA00FF, 0x000000, 0xAAAAAA, 0xAA00FF, 0x000000, 0x555555, 0x000000, 0xFF5500, 0x55AAFF, 0x555555]; break;// Purple on White MIP
case 25: $.gColours = [0x000000, 0xAA00FF, 0x555555, 0xAA00FF, 0xFFFFFF, 0x555555, 0xAA00FF, 0xFFFFFF, 0x555555, 0x55AAFF, 0xFFAA00, 0x55AAFF, 0xFFFFFF]; break;// Purple on black MIP
case 26: $.gColours = [0x000000, 0xFFAA00, 0x555555, 0xFFAA00, 0xFFAA55, 0x555555, 0xFFAA00, 0xFFAA55, 0x555555, 0x55AAAA, 0xFFAA00, 0x55AAAA, 0xFFFFFF]; break;// Amber MIP
default: $.gColours = [0xff0000, 0x00ff00, 0x0000ff, 0x550000, 0x005500, 0x000055, 0xff00ff, 0x00ffff, 0xffff00, 0x005555, 0x550055, 0x555500, 0xffffff]; break;// error case
}
}
+19
View File
@@ -0,0 +1,19 @@
import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;
class hockeyTimerMenuDelegate extends WatchUi.MenuInputDelegate {
function initialize() {
MenuInputDelegate.initialize();
}
function onMenuItem(item as Symbol) as Void {
if (item == :item_1) {
System.println("item 1");
} else if (item == :item_2) {
System.println("item 2");
}
}
}
+58
View File
@@ -0,0 +1,58 @@
import Toybox.Graphics;
import Toybox.WatchUi;
import Toybox.Lang;
public var kjr as String = "88:88";
class hockeyTimerView extends WatchUi.View {
function initialize() {
View.initialize();
}
// Load your resources here
function onLayout(dc as Dc) as Void {
// setLayout($.Rez.Layouts.MainLayout(dc));
$.setColourTheme(1);
}
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() as Void {
}
// Update the view
function onUpdate(dc as Dc) as Void {
var _colourBG = $.gColours[background] ;
// var _colourTextBG = $.gColours[timerBg];
var _colourText = $.gColours[timer];
dc.setColor(_colourText, _colourBG);
dc.clear();
dc.drawText(dc.getWidth()/2, dc.getHeight()/3, Graphics.FONT_MEDIUM, kjr, Graphics.TEXT_JUSTIFY_CENTER);
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() as Void {
}
// private function drawPeriodTimer(dc as Dc){
// _MM = $.gMatch.periods[$.gMatch.period].remaining/60;
// _SS = $.gMatch.periods[$.gMatch.period].remaining%60;
// _TM = Lang.format("$1$:$2$",[_MM.format("%02d"),_SS.format("%02d")]);
// dc.setColor(_colourTextBG, Graphics.COLOR_TRANSPARENT);
// dc.drawText($.gX, $.gY, $.gFontTimer, "88:88", Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
// dc.setColor(_colourText, Graphics.COLOR_TRANSPARENT);
// dc.setPenWidth(2);
// dc.drawLine(60,$.gY - 55,330,$.gY - 55);
// dc.drawLine(60,$.gY + 56,330,$.gY + 56);
// dc.drawText($.gX, $.gY, $.gFontTimer, _TM, Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
// }
}
+125
View File
@@ -0,0 +1,125 @@
import Toybox.Lang;
import Toybox.WatchUi;
class MyInputDelegate extends WatchUi.InputDelegate {
function initialize() {
InputDelegate.initialize();
}
function onDrag(dragEvent as WatchUi.DragEvent) as Lang.Boolean {
$.kjr = "on-Drag";
System.println(dragEvent.getType());
WatchUi.requestUpdate();
return true;
}
function onFlick(flickEvent as WatchUi.FlickEvent) as Lang.Boolean {
$.kjr = "onFlick";
System.println(flickEvent.getDirection());
WatchUi.requestUpdate();
return true;
}
function onHold(clickEvent as WatchUi.ClickEvent) as Lang.Boolean {
$.kjr = "onHold";
System.println(clickEvent.getType());
WatchUi.requestUpdate();
return true;
}
function onKey(keyEvent as WatchUi.KeyEvent) as Lang.Boolean {
$.kjr = "onKey";
System.println(keyEvent.getKey());
WatchUi.requestUpdate();
return true;
}
function onKeyPressed(keyEvent as WatchUi.KeyEvent) as Lang.Boolean {
$.kjr = "onKeyPressed";
System.println(keyEvent.getKey());
WatchUi.requestUpdate();
return true;
}
function onKeyReleased(keyEvent as WatchUi.KeyEvent) as Lang.Boolean {
$.kjr = "onKeyReleased";
System.println(keyEvent.getKey());
WatchUi.requestUpdate();
return true;
}
function onRelease(clickEvent as WatchUi.ClickEvent) as Lang.Boolean {
$.kjr = "onRelease";
System.println(clickEvent.getType());
WatchUi.requestUpdate();
return true;
}
function onSelectable(selectableEvent as WatchUi.SelectableEvent) as Lang.Boolean {
$.kjr = "onSelectable";
WatchUi.requestUpdate();
return true;
}
function onSwipe(swipeEvent as WatchUi.SwipeEvent) as Lang.Boolean {
$.kjr = "onSwipe";
System.println(swipeEvent.getDirection());
WatchUi.requestUpdate();
return true;
}
function onTap(clickEvent as WatchUi.ClickEvent) as Lang.Boolean {
$.kjr = "onTap";
System.println(clickEvent.getType());
WatchUi.requestUpdate();
return true;
}
}
class MyBehaviorDelegate extends WatchUi.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
}
function onMenu() as Boolean {
$.kjr = "OnMenu";
WatchUi.requestUpdate();
return true;
}
function onActionMenu() as Boolean {
$.kjr = "onActionMenu";
WatchUi.requestUpdate();
return true;
}
function onBack() as Boolean {
$.kjr = "onBack";
WatchUi.requestUpdate();
return true;
}
function onNextMode() as Lang.Boolean {
$.kjr = "onNextMode";
WatchUi.requestUpdate();
return true;
}
function onNextPage() as Lang.Boolean {
$.kjr = "onNextPage";
WatchUi.requestUpdate();
return true;
}
function onPreviousMode() as Lang.Boolean {
$.kjr = "onPreviousMode";
WatchUi.requestUpdate();
return true;
}
function onPreviousPage() as Lang.Boolean {
$.kjr = "onPreviousPage";
WatchUi.requestUpdate();
return true;
}
function onSelect() as Lang.Boolean{
$.kjr = "onSelect";
WatchUi.requestUpdate();
return true;
}
}