ols 7 SevenSegment
This commit is contained in:
1 parent
badede4b8f
commit
f7bcbc53ef
131 files changed
+5624
-6412
No files matched your search
+97
-117
@@ -7,9 +7,11 @@ 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 _mm as Number?; // = 0;
|
||||
private var _ss as Number?; // = 0;
|
||||
private var _rr as Float?;
|
||||
private var _tm as String = "00:00";
|
||||
private var _aa as String = "oops";
|
||||
|
||||
function initialize() {
|
||||
View.initialize();
|
||||
@@ -17,10 +19,7 @@ class mainView extends WatchUi.View {
|
||||
$.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);
|
||||
|
||||
$.gMatch.recordCard(AWAY,RED,10,0);
|
||||
}
|
||||
|
||||
function timerTick() as Void{
|
||||
@@ -33,18 +32,13 @@ class mainView extends WatchUi.View {
|
||||
|
||||
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);
|
||||
_rr = $.gX - ($.gPeriodWidth / 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];
|
||||
@@ -60,80 +54,52 @@ class mainView extends WatchUi.View {
|
||||
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";
|
||||
_aa = "Pre-Game";
|
||||
break;
|
||||
case INGAME:
|
||||
a = $.gMatch.period.name.toUpper();
|
||||
_aa = $.gMatch.period.name;
|
||||
break;
|
||||
case POSTGAME:
|
||||
a = "Game-Over";
|
||||
_aa = "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);
|
||||
dc.drawText($.gX,
|
||||
$.gY - 145,
|
||||
FontClock,
|
||||
_aa,
|
||||
Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
|
||||
private function drawMatchProgress(dc as Dc){
|
||||
dc.setPenWidth($.gPenWidth);
|
||||
dc.setPenWidth($.gPeriodWidth);
|
||||
$.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);
|
||||
dc.drawArc($.gX,
|
||||
$.gY,
|
||||
_rr,
|
||||
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);
|
||||
dc.drawArc($.gX,
|
||||
$.gY,
|
||||
_rr,
|
||||
Graphics.ARC_CLOCKWISE,
|
||||
$.gStartAngle,
|
||||
$.gStartAngle - $.gFilledArc);
|
||||
}
|
||||
$.gStartAngle = $.gEndAngle - $.gTitleArc;
|
||||
}
|
||||
@@ -141,87 +107,101 @@ class mainView extends WatchUi.View {
|
||||
}
|
||||
|
||||
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);
|
||||
_mm = $.gMatch.period.remaining/60;
|
||||
_ss = $.gMatch.period.remaining%60;
|
||||
_tm = Lang.format("$1$:$2$", [_mm.format("%02d"), _ss.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);
|
||||
dc.drawText($.gX,
|
||||
$.gY,
|
||||
$.gFontTimer,
|
||||
_tm,
|
||||
Graphics.TEXT_JUSTIFY_VCENTER | Graphics.TEXT_JUSTIFY_CENTER);
|
||||
|
||||
var c = 5 + Graphics.getFontHeight($.gFontTimer) / 2;
|
||||
var w = 5 + dc.getTextWidthInPixels(_tm, $.gFontTimer) / 2;
|
||||
dc.setPenWidth(1);
|
||||
dc.drawLine($.gY - w, $.gY - c, $.gY + w, $.gY - c);
|
||||
dc.drawLine($.gY - w, $.gY + c, $.gY + w, $.gY + c);
|
||||
}
|
||||
|
||||
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.drawText($.gX,
|
||||
// $.gY - 90,
|
||||
// $.gFontScore,
|
||||
// "###",
|
||||
// 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);
|
||||
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);
|
||||
|
||||
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);
|
||||
if($.gMatch.period.play){
|
||||
dc.drawText(340,
|
||||
$.gY + gFontCardsX - 100,
|
||||
$.gFontCards,
|
||||
$.gPlay,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
else{
|
||||
dc.drawText(340,
|
||||
$.gY + gFontCardsX - 100,
|
||||
$.gFontCards,
|
||||
$.gPause,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
|
||||
dc.drawText(340,
|
||||
$.gY - gFontCardsX + 100,
|
||||
$.gFontCards,
|
||||
$.gPlus,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
|
||||
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;
|
||||
_mm = w/60;
|
||||
_ss = w%60;
|
||||
|
||||
$.gTextCard = Lang.format( "$1$ $2$($3$)$4$:$5$", [$.gCards[$.gMatch.cards[i].card.toNumber()] ,"H", $.gMatch.cards[i].player.format("%02d"), _mm.format("%02d"), _ss.format("%02d")]);
|
||||
|
||||
$.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++;
|
||||
dc.drawText($.gX,
|
||||
$.gY + (i * 35) + 55,
|
||||
$.gFontCards,
|
||||
$.gTextCard,
|
||||
Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user