aa
This commit is contained in:
1 parent
661f99c595
commit
badede4b8f
222 files changed
+14221
-4877
No files matched your search
-176
@@ -1,176 +0,0 @@
|
||||
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(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-7
@@ -1,8 +1,2 @@
|
||||
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?;
|
||||
import Toybox.WatchUi;
|
||||
@@ -27,23 +27,6 @@ public function setColourTheme(id as Number) as Void {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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:
|
||||
System.exit();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Graphics;
|
||||
import Toybox.Time;
|
||||
|
||||
public enum enCard{
|
||||
RED = "RED",
|
||||
YELLOW = "YELLOW",
|
||||
GREEN = "GREEN"
|
||||
}
|
||||
public enum enGoal{
|
||||
PC = "PC",
|
||||
PS = "PS",
|
||||
FG = "FG"
|
||||
}
|
||||
public enum enTeam{
|
||||
HOME = "Home",
|
||||
AWAY = "Away"
|
||||
}
|
||||
public enum enPeriod{
|
||||
PLAY,
|
||||
BREAK
|
||||
}
|
||||
public enum enAction{
|
||||
GOAL,
|
||||
CARD,
|
||||
QUIT
|
||||
}
|
||||
public enum enGame{
|
||||
PREGAME,
|
||||
INGAME,
|
||||
POSTGAME
|
||||
}
|
||||
|
||||
// Menus
|
||||
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?;
|
||||
|
||||
public var gScore as String = "0-0";
|
||||
public var gMatch as Match?;
|
||||
|
||||
public var gX as Number?;
|
||||
public var gR as Float?;
|
||||
public var gH as Number?;
|
||||
public var gW as Number?;
|
||||
public var gY as Number?;
|
||||
public var gTitleArc as Float = 25.0;
|
||||
public var gPenWidth as Float = 6.0;
|
||||
public var gPeriodArc as Float = gTitleArc;
|
||||
public var gFilledArc as Float?;
|
||||
public var gStartAngle as Float?;
|
||||
public var gEndAngle as Float?;
|
||||
public var gMM as Number = 0;
|
||||
public var gSS as Number = 0;
|
||||
public var gTM as String = "00:00";
|
||||
public var gFontTimer = WatchUi.loadResource($.Rez.Fonts.SevenSegment);
|
||||
public var gFontCards = WatchUi.loadResource($.Rez.Fonts.font40);
|
||||
public var gFontClock = WatchUi.loadResource($.Rez.Fonts.led_small);
|
||||
public var gFontScore = WatchUi.loadResource($.Rez.Fonts.font40);
|
||||
|
||||
public var gInfo as Time.Gregorian.Info?;
|
||||
public var gTime as String?;
|
||||
|
||||
public var gPlay = WatchUi.loadResource($.Rez.Drawables.play);
|
||||
public var gPause = WatchUi.loadResource($.Rez.Drawables.pause);
|
||||
public var gPlus = WatchUi.loadResource($.Rez.Drawables.plus);
|
||||
public var gTextCard as String?;
|
||||
@@ -8,21 +8,28 @@ class hockeyTimerApp extends Application.AppBase {
|
||||
AppBase.initialize();
|
||||
}
|
||||
|
||||
// onStart() is called on application start up
|
||||
function onStart(state as Dictionary?) as Void {
|
||||
reloadSettings();
|
||||
}
|
||||
|
||||
// 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() ];
|
||||
return [new mainView(), new mainDelegate()];
|
||||
}
|
||||
|
||||
function onSettingsChanged() as Void {
|
||||
reloadSettings();
|
||||
}
|
||||
}
|
||||
public function reloadSettings() as Void{
|
||||
var s = Application.Properties.getValue("color_theme") as Number;
|
||||
|
||||
setColourTheme(s);
|
||||
WatchUi.requestUpdate();
|
||||
|
||||
}
|
||||
|
||||
function getApp() as hockeyTimerApp {
|
||||
return Application.getApp() as hockeyTimerApp;
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
import Toybox.Graphics;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Lang;
|
||||
import Toybox.Timer;
|
||||
import Toybox.Time;
|
||||
|
||||
class mainView extends WatchUi.View {
|
||||
private var _timer as Timer.Timer = new Timer.Timer();
|
||||
private var _tick as Number = 0;
|
||||
private var _mm as Number = 0;
|
||||
private var _ss as Number = 0;
|
||||
private var _tm as String = "00:00";
|
||||
|
||||
function initialize() {
|
||||
View.initialize();
|
||||
_timer.start(method(:timerTick), 100, true);
|
||||
$.gMatch = new Match();
|
||||
$.gMatch.recordCard(HOME,GREEN,22,1);
|
||||
$.gMatch.recordCard(AWAY,YELLOW,10,2);
|
||||
// $.gFontTimer = Application.loadResource($.Rez.Fonts.SevenSegment);
|
||||
// var image = Application.loadResource( Rez.Drawables.play ) as BitmapResource;
|
||||
// image.setColor(Graphics.COLOR_GREEN);
|
||||
|
||||
}
|
||||
|
||||
function timerTick() as Void{
|
||||
_tick++;
|
||||
$.gMatch.period.update();
|
||||
if (_tick % 10 == 0){
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
function onLayout(dc as Dc) as Void {
|
||||
$.gW = dc.getWidth();
|
||||
System.println($.gW);
|
||||
$.gH = dc.getHeight();
|
||||
$.gX = $.gW / 2;
|
||||
$.gY = $.gH / 2;
|
||||
$.gR = $.gX - ($.gPenWidth / 2);
|
||||
$.gPeriodArc = (360.0 - $.gTitleArc - ($.gMatch.breakCount * $.gTitleArc)) / $.gMatch.playCount;
|
||||
}
|
||||
|
||||
function onShow() as Void {
|
||||
|
||||
}
|
||||
|
||||
function onUpdate(dc as Dc) as Void {
|
||||
var _colourBG = $.gColours[background] ;
|
||||
var _colourText = $.gColours[timer];
|
||||
|
||||
dc.setColor(_colourText, _colourBG);
|
||||
dc.clear();
|
||||
// drawTest(dc);
|
||||
drawPeriodName(dc);
|
||||
drawMatchProgress(dc);
|
||||
drawPeriodTimer(dc);
|
||||
drawMatchScore(dc);
|
||||
drawCurrentTime(dc);
|
||||
drawButtons(dc);
|
||||
drawActiveCards(dc);
|
||||
}
|
||||
|
||||
function onHide() as Void {
|
||||
|
||||
}
|
||||
|
||||
private function drawTest(dc as Dc){
|
||||
_ss = $.gMatch.period.remaining%60;
|
||||
_mm = $.gMatch.period.remaining/60;
|
||||
|
||||
// var Info = Time.Gregorian.info(Time.now(), Time.FORMAT_LONG);
|
||||
// var Time = Lang.format("$1$:$2$", [Info.hour.format("%02d"), Info.min.format("%02d")]);
|
||||
_tm = Lang.format("$1$:$2$", [_mm.format("%02d"), _ss.format("%02d")]);
|
||||
var a = "oops";
|
||||
switch($.gMatch.state){
|
||||
case PREGAME:
|
||||
a = "Pre-Game";
|
||||
break;
|
||||
case INGAME:
|
||||
a = $.gMatch.period.name;
|
||||
break;
|
||||
case POSTGAME:
|
||||
a = "Game-Over";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
dc.setColor(Graphics.COLOR_DK_RED, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(dc.getWidth()/2,
|
||||
dc.getHeight()/2,
|
||||
Graphics.FONT_MEDIUM,
|
||||
_tm,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
dc.drawText(dc.getWidth()/2,
|
||||
dc.getHeight()/4,
|
||||
Graphics.FONT_MEDIUM,
|
||||
$.gMatch.elapsed,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
dc.drawText(dc.getWidth()/2,
|
||||
3*dc.getHeight()/4,
|
||||
Graphics.FONT_MEDIUM,
|
||||
a,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
|
||||
private function drawPeriodName(dc as Dc){
|
||||
var FontClock = $.gFontScore;
|
||||
var a = "oops";
|
||||
switch($.gMatch.state){
|
||||
case PREGAME:
|
||||
a = "Pre-Game";
|
||||
break;
|
||||
case INGAME:
|
||||
a = $.gMatch.period.name.toUpper();
|
||||
break;
|
||||
case POSTGAME:
|
||||
a = "Game-Over";
|
||||
break;
|
||||
}
|
||||
dc.setColor($.gColours[timer], Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText($.gX, $.gY - 145, FontClock, a, Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
|
||||
private function drawMatchProgress(dc as Dc){
|
||||
dc.setPenWidth($.gPenWidth);
|
||||
$.gStartAngle = 90.0 - ($.gTitleArc / 2);
|
||||
for (var i = 0; i < $.gMatch.periods.size(); i++) {
|
||||
if ($.gMatch.periods[i].type == PLAY){
|
||||
dc.setColor($.gColours[timerBg], Graphics.COLOR_TRANSPARENT);
|
||||
$.gEndAngle = $.gStartAngle - $.gPeriodArc;
|
||||
dc.drawArc($.gX, $.gY, $.gR, Graphics.ARC_CLOCKWISE, $.gStartAngle, $.gEndAngle);
|
||||
$.gFilledArc = ($.gMatch.periods[i].elapsed.toFloat() / $.gMatch.periods[i].duration.toFloat()) * $.gPeriodArc;
|
||||
if ($.gFilledArc > 0.0) {
|
||||
dc.setColor($.gColours[timer], Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawArc($.gX, $.gY, $.gR, Graphics.ARC_CLOCKWISE, $.gStartAngle, $.gStartAngle - $.gFilledArc);
|
||||
}
|
||||
$.gStartAngle = $.gEndAngle - $.gTitleArc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function drawPeriodTimer(dc as Dc){
|
||||
$.gMM = $.gMatch.period.remaining/60;
|
||||
$.gSS = $.gMatch.period.remaining%60;
|
||||
$.gTM = Lang.format("$1$:$2$", [$.gMM.format("%02d"), $.gSS.format("%02d")]);
|
||||
// dc.setColor($.gColours[timerBg], Graphics.COLOR_TRANSPARENT);
|
||||
// dc.drawText($.gX, $.gY, $.gFontTimer, "88:88", Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
dc.setColor($.gColours[timer], Graphics.COLOR_TRANSPARENT);
|
||||
dc.setPenWidth(2);
|
||||
dc.drawLine(50, $.gY - 55, 340, $.gY - 55);
|
||||
dc.drawLine(50, $.gY + 56, 340, $.gY + 56);
|
||||
dc.drawText($.gX, $.gY, $.gFontTimer, $.gTM, Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
|
||||
private function drawMatchScore(dc as Dc){
|
||||
// var FontScore = Graphics.FONT_MEDIUM;
|
||||
$.gScore = Lang.format("$1$-$2$", [$.gMatch.homeScore, $.gMatch.awayScore]);
|
||||
// dc.setColor($.gColours[timerBg], Graphics.COLOR_TRANSPARENT);
|
||||
// dc.drawText($.gX, $.gY - 90, FontScore, "###" , Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
dc.setColor($.gColours[timer], Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText($.gX, $.gY - 90, $.gFontScore, $.gScore , Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
|
||||
private function drawCurrentTime(dc as Dc){
|
||||
// var FontClock1 = Application.loadResource($.Rez.Fonts.ms);
|
||||
|
||||
$.gInfo = Time.Gregorian.info(Time.now(), Time.FORMAT_LONG);
|
||||
$.gTime = Lang.format("$1$:$2$", [$.gInfo.hour.format("%02d"), $.gInfo.min.format("%02d")]);
|
||||
dc.setColor($.gColours[timer], Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText($.gX, 0, $.gFontClock, $.gTime, Graphics.TEXT_JUSTIFY_CENTER);
|
||||
|
||||
}
|
||||
|
||||
private function drawButtons(dc as Dc){
|
||||
|
||||
var q = $.gMatch.period.play ? $.gPause : $.gPlay;
|
||||
dc.drawText (330,$.gY-13 - 80, $.gFontCards, "'", Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
// dc.drawBitmap(330,$.gY-13 - 80,q);
|
||||
dc.drawBitmap(330,$.gY-13 + 80 ,$.gPlus);
|
||||
|
||||
}
|
||||
|
||||
private function drawActiveCards(dc as Dc){
|
||||
// var f32 = Graphics.FONT_SMALL;
|
||||
// var f34 = Application.loadResource($.Rez.Fonts.Bahnschrift34);
|
||||
// var f36 = Application.loadResource($.Rez.Fonts.Bahnschrift36);
|
||||
// var f38 = Application.loadResource($.Rez.Fonts.calibri40);
|
||||
// var f40 = Application.loadResource($.Rez.Fonts.font40);
|
||||
// // var textCard = "The quick brown fox jumps over the lazy dog";
|
||||
// var textCard = " TaqSAjTjTjTjTjTjT";
|
||||
// textCard = 128.toChar().toString() + 129.toChar().toString() + 130.toChar().toString() + 131.toChar().toString() + 132.toChar().toString() + "SdrTHC";
|
||||
// // dc.drawText($.gX, $.gY, f40, textCard ,Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
// // dc.drawText($.gX, $.gY + 40, f32, textCard ,Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
// dc.drawText($.gX, $.gY + 80, f40, textCard ,Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
// dc.drawText($.gX, $.gY + 120, f38, textCard ,Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
// dc.drawText($.gX, $.gY + 166, f40, textCard ,Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
// System.println(textCard);
|
||||
|
||||
|
||||
|
||||
var j = 0;
|
||||
for (var i = 0; i < $.gMatch.cards.size(); i++){
|
||||
if ($.gMatch.cards[i].isActive){
|
||||
var w = $.gMatch.cards[i].remaining;
|
||||
$.gMM = w/60;
|
||||
$.gSS = w%60;
|
||||
|
||||
$.gTextCard = Lang.format( "!$1$($2$)$3$:$4$",
|
||||
["H", $.gMatch.cards[i].player.format("%02d"), $.gMM.format("%02d"), $.gSS.format("%02d")]);
|
||||
|
||||
var e = dc.getTextWidthInPixels($.gTextCard, $.gFontCards);
|
||||
dc.drawText($.gX, $.gY, $.gFontCards, $.gTextCard ,Graphics.TEXT_JUSTIFY_LEFT);
|
||||
// dc.drawBitmap($.gX - 10 - e / 2, $.gY + (j * 35) + 70, WatchUi.loadResource(Rez.Drawables.redCard));
|
||||
// dc.drawBitmap($.gX -26, $.gY, WatchUi.loadResource(Rez.Drawables.redCard));
|
||||
// dc.drawBitmap($.gX -26, $.gY -26, WatchUi.loadResource(Rez.Drawables.redCard));
|
||||
// dc.drawBitmap($.gX, $.gY -26, WatchUi.loadResource(Rez.Drawables.redCard));
|
||||
// dc.drawBitmap($.gX, $.gY, WatchUi.loadResource(Rez.Drawables.redCard));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.Graphics;
|
||||
import Toybox.Application;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
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);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Time;
|
||||
import Toybox.Timer;
|
||||
import Toybox.System;
|
||||
|
||||
public 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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Time;
|
||||
import Toybox.Timer;
|
||||
import Toybox.System;
|
||||
|
||||
class Match {
|
||||
private var _datetime as Number?;
|
||||
private var _startTime as Number?;
|
||||
private var _period as Number = 0;
|
||||
|
||||
public var periods as Array<Period> = [];
|
||||
public var period as Period?;
|
||||
public var goals as Array<Goal> = [];
|
||||
public var cards as Array<Card> = [];
|
||||
|
||||
public var playCount as Number = 0;
|
||||
public var breakCount as Number = 0;
|
||||
public var periodCount as Number = 0;
|
||||
public var homeScore as Number = 0;
|
||||
public var awayScore as Number = 0;
|
||||
public var completed as Number = 0;
|
||||
public var duration as Number = 0;
|
||||
public var remaining as Number = 0;
|
||||
public var elapsed as Number = 0;
|
||||
|
||||
public var timerMM as Number = 0;
|
||||
public var timerSS as Number = 0;
|
||||
public var display as String?;
|
||||
public var state as $.enGame;
|
||||
|
||||
function initialize() {
|
||||
_datetime = Time.now().value();
|
||||
state = PREGAME;
|
||||
|
||||
periods.add(new Period("1st Quarter", PLAY, 100));
|
||||
periods.add(new Period("1/4 Break" , BREAK, 2));
|
||||
periods.add(new Period("2nd Quarter", PLAY, 100));
|
||||
periods.add(new Period("1/2 Break" , BREAK, 2));
|
||||
periods.add(new Period("3rd Quarter", PLAY, 100));
|
||||
periods.add(new Period("3/4 Break" , BREAK, 2));
|
||||
periods.add(new Period("4th Quarter", PLAY, 100));
|
||||
period = periods[_period];
|
||||
|
||||
for(var i = 0; i< periods.size(); i++){
|
||||
periodCount++;
|
||||
switch (periods[i].type){
|
||||
case PLAY:
|
||||
duration += periods[i].duration;
|
||||
playCount++;
|
||||
break;
|
||||
case BREAK:
|
||||
breakCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nextPeriod(){
|
||||
if (period.type == PLAY){
|
||||
completed += period.elapsed;
|
||||
}
|
||||
_period++;
|
||||
|
||||
if (_period < periods.size()){
|
||||
period = periods[_period];
|
||||
}
|
||||
else{
|
||||
state = POSTGAME;
|
||||
}
|
||||
}
|
||||
function recordCard(team as enTeam,
|
||||
type as enCard,
|
||||
player as Number,
|
||||
duration as Number)
|
||||
{
|
||||
cards.add(new Card(team, type, player , duration, me.elapsed));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Time;
|
||||
import Toybox.Timer;
|
||||
import Toybox.System;
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Time;
|
||||
import Toybox.Timer;
|
||||
import Toybox.System;
|
||||
|
||||
class Period{
|
||||
public var name as String?;
|
||||
public var type as enPeriod?;
|
||||
public var duration as Number?;
|
||||
public var remaining as Number?;
|
||||
public var elapsed as Number?;
|
||||
|
||||
public var play as Boolean = false;
|
||||
private var _dur as Number = 0;
|
||||
private var _acc as Number = 0;
|
||||
private var _start as Number = 0;
|
||||
|
||||
function initialize(Name as String, Type as enPeriod, Duration as Number){
|
||||
name = Name;
|
||||
type = Type;
|
||||
duration = Duration;
|
||||
remaining = Duration;
|
||||
elapsed = 0;
|
||||
}
|
||||
|
||||
function playPause() as Void{
|
||||
play = !play;
|
||||
if (play){
|
||||
$.gMatch.state = INGAME;
|
||||
_start = System.getTimer();
|
||||
}
|
||||
else{
|
||||
_acc += System.getTimer() - _start;
|
||||
}
|
||||
}
|
||||
|
||||
function update() as Void{
|
||||
if (play){
|
||||
_dur = System.getTimer() - _start + _acc;
|
||||
elapsed = _dur / 1000;
|
||||
remaining = duration - elapsed;
|
||||
|
||||
if (type == PLAY){
|
||||
$.gMatch.elapsed = $.gMatch.completed + elapsed;
|
||||
}
|
||||
|
||||
if (remaining <= 0) {
|
||||
play = false;
|
||||
$.gMatch.method(:nextPeriod).invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
|
||||
public var kjr as String?;
|
||||
|
||||
class MyInputDelegate extends WatchUi.InputDelegate {
|
||||
|
||||
function initialize() {
|
||||
|
||||
Reference in new issue
Block a user