Move rank to middle, track edge direction
This commit is contained in:
parent
f15fd9cf20
commit
9edab1f230
|
@ -23,6 +23,7 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
|
|
||||||
let grid = ["Office off", "Office 1/2", "Office on", "Kitchen off", "Kitchen 1/2", "Kitchen on", "Window off", "Window 1/2", "Window on", "LStairs off", "LStairs 1/2", "LStairs on", "Nook off", "Nook 1/2", "Nook on", "SideEnt off", "SideEnt 1/2", "SideEnt on", "Theatre off", "Theatre 1/2", "Theatre on", "FPot off", "FPot 1/2", "FPot on", "SPot off", "SPot 1/2", "SPot on", "GuestBth off", "GuestBth 1/2", "GuestBth on"];
|
let grid = ["Office off", "Office 1/2", "Office on", "Kitchen off", "Kitchen 1/2", "Kitchen on", "Window off", "Window 1/2", "Window on", "LStairs off", "LStairs 1/2", "LStairs on", "Nook off", "Nook 1/2", "Nook on", "SideEnt off", "SideEnt 1/2", "SideEnt on", "Theatre off", "Theatre 1/2", "Theatre on", "FPot off", "FPot 1/2", "FPot on", "SPot off", "SPot 1/2", "SPot on", "GuestBth off", "GuestBth 1/2", "GuestBth on"];
|
||||||
let gridNum = -1;
|
let gridNum = -1;
|
||||||
|
let gridDir = -1;
|
||||||
|
|
||||||
let paintFace = function() {
|
let paintFace = function() {
|
||||||
var x = g.getWidth() / 2;
|
var x = g.getWidth() / 2;
|
||||||
|
@ -100,6 +101,7 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
let x = g.getWidth() / 2;
|
let x = g.getWidth() / 2;
|
||||||
let y = g.getHeight() / 2;
|
let y = g.getHeight() / 2;
|
||||||
let text = "";
|
let text = "";
|
||||||
|
let rank = "";
|
||||||
|
|
||||||
g.reset().clearRect(Bangle.appRect);
|
g.reset().clearRect(Bangle.appRect);
|
||||||
|
|
||||||
|
@ -107,28 +109,35 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
truncY = Math.floor(touchY/15);
|
truncY = Math.floor(touchY/15);
|
||||||
|
|
||||||
gridNum = -1;
|
gridNum = -1;
|
||||||
|
gridDir = -1;
|
||||||
|
|
||||||
if (!grid) {
|
if (!grid) {
|
||||||
text = "Grid missing";
|
text = "Grid missing";
|
||||||
} else if (truncX < 2) {
|
} else if (truncX < 2) {
|
||||||
text = "left";
|
text = "left";
|
||||||
|
gridDir = "left";
|
||||||
} else if (truncX > 10) {
|
} else if (truncX > 10) {
|
||||||
text = "right";
|
text = "right";
|
||||||
|
gridDir = "right";
|
||||||
} else if (truncY < 2) {
|
} else if (truncY < 2) {
|
||||||
text = "top";
|
text = "top";
|
||||||
|
gridDir = "top";
|
||||||
} else if (truncY > 10) {
|
} else if (truncY > 10) {
|
||||||
text = "bottom";
|
text = "Cancel";
|
||||||
|
gridDir = "bottom";
|
||||||
} else {
|
} else {
|
||||||
const gridX = truncX - 2;
|
const gridX = truncX - 2;
|
||||||
const gridY = truncY - 2;
|
const gridY = truncY - 2;
|
||||||
|
|
||||||
gridNum = gridY * 9 + gridX;
|
gridNum = gridY * 9 + gridX;
|
||||||
const rank = "ABCDEFGHI"[gridY];
|
rank = "ABCDEFGHI"[gridY];
|
||||||
text = rank + " " + grid[gridNum];
|
text = grid[gridNum];
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(text, x, y-45);
|
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(text, x, y-45);
|
||||||
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(text, x, y+70);
|
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(text, x, y+70);
|
||||||
|
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(rank, x-65, y+15);
|
||||||
|
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(rank, x+65, y+15);
|
||||||
};
|
};
|
||||||
|
|
||||||
let handleDrag = function(e) {
|
let handleDrag = function(e) {
|
||||||
|
@ -159,7 +168,6 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
|
|
||||||
if (gridNum >= 0 && grid[gridNum]) {
|
if (gridNum >= 0 && grid[gridNum]) {
|
||||||
myMessage = grid[gridNum];
|
myMessage = grid[gridNum];
|
||||||
if (paintFace) paintFace();
|
|
||||||
|
|
||||||
if (Bangle.http){
|
if (Bangle.http){
|
||||||
const options = {timeout:3000, method: "post", body: gridNum};
|
const options = {timeout:3000, method: "post", body: gridNum};
|
||||||
|
@ -172,9 +180,12 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
gridNum = -1;
|
gridNum = -1;
|
||||||
} else {
|
} else if (gridDir == "bottom") {
|
||||||
if (paintFace) paintFace();
|
myMessage = "Cancelled";
|
||||||
|
Bangle.setLocked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paintFace) paintFace();
|
||||||
} else if (watchState == STATE_GRID_OPEN && pressed) {
|
} else if (watchState == STATE_GRID_OPEN && pressed) {
|
||||||
drawMenu(touchX, touchY);
|
drawMenu(touchX, touchY);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +217,9 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
gridTimer = undefined;
|
gridTimer = undefined;
|
||||||
if (lockTimer) clearTimeout(lockTimer);
|
if (lockTimer) clearTimeout(lockTimer);
|
||||||
lockTimer = undefined;
|
lockTimer = undefined;
|
||||||
|
|
||||||
delete Graphics.prototype.setFontAnton;
|
delete Graphics.prototype.setFontAnton;
|
||||||
|
paintFace = undefined; // http request may resolve after font's been unloaded, so unset
|
||||||
}});
|
}});
|
||||||
// Load widgets
|
// Load widgets
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user