Skip to content

Commit 84aabfa

Browse files
authored
Merge pull request #3502 from only-meeps/master
8ball: add app and change boxclk to use clockbackgrounds app
2 parents c75a31a + 2c4e52d commit 84aabfa

12 files changed

+118
-13
lines changed

apps/8ball/8ball.png

983 Bytes
Loading

apps/8ball/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.01: New App!

apps/8ball/app-icon.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/8ball/app.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
var keyboard = "textinput";
2+
var Name = "";
3+
Bangle.setLCDTimeout(0);
4+
var menuOpen = 1;
5+
var answers = new Array("no", "yes","WHAT????","What do you think", "That was a bad question", "YES!!!", "NOOOOO!!", "nope","100%","yup","why should I answer that?","think for yourself","ask again later, I'm busy", "what Was that horrible question","how dare you?","you wanted to hear yes? okay, yes", "Don't get angry when I say no","you are 100% wrong","totally, for sure","hmmm... I'll ponder it and get back to you later","wow, you really have a lot of questions", "NOPE","is the sky blue, hmmm...","I don't have time to answer","How many more questions before you change my name?","theres this thing called wikipedia","hmm... I don't seem to be able to reach the internet right now","if you phrase it like that, yes","Huh, never thought so hard in my life","The winds of time say no");
6+
var consonants = new Array("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z");
7+
var vowels = new Array("a","e","i","o","u");
8+
try {keyboard = require(keyboard);} catch(e) {keyboard = null;}
9+
function generateName()
10+
{
11+
Name = "";
12+
var nameLength = Math.round(Math.random()*5);
13+
for(var i = 0; i < nameLength; i++){
14+
var cosonant = consonants[Math.round(Math.random()*consonants.length/2)];
15+
var vowel = vowels[Math.round(Math.random()*vowels.length/2)];
16+
Name = Name + cosonant + vowel;
17+
if(Name == "")
18+
{
19+
generateName();
20+
}
21+
}
22+
}
23+
generateName();
24+
function menu()
25+
{
26+
g.clear();
27+
E.showMenu();
28+
menuOpen = 1;
29+
E.showMenu({
30+
"" : { title : Name },
31+
"< Back" : () => menu(),
32+
"Start" : () => {
33+
E.showMenu();
34+
g.clear();
35+
menuOpen = 0;
36+
Drawtext("ask " + Name + " a yes or no question");
37+
},
38+
"regenerate name" : () => {
39+
menu();
40+
generateName();
41+
},
42+
"show answers" : () => {
43+
var menu = new Array([]);
44+
for(var i = 0; i < answers.length; i++){
45+
menu.push({title : answers[i]});
46+
}
47+
E.showMenu(menu);
48+
49+
50+
},
51+
52+
"Add answer" : () => {
53+
E.showMenu();
54+
keyboard.input({}).then(result => {if(result != ""){answers.push(result);} menu();});
55+
},
56+
"Edit name" : () => {
57+
E.showMenu();
58+
keyboard.input({}).then(result => {if(result != ""){Name = result;} menu();});
59+
60+
},
61+
"Exit" : () => load(),
62+
});
63+
}
64+
menu();
65+
66+
var answer;
67+
function Drawtext(text)
68+
{
69+
g.clear();
70+
g.setFont("Vector", 20);
71+
g.drawString(g.wrapString(text, g.getWidth(), -20).join("\n"));
72+
}
73+
function WriteAnswer()
74+
{
75+
if (menuOpen == 0)
76+
{
77+
var randomnumber = Math.round(Math.random()*answers.length);
78+
answer = answers[randomnumber];
79+
Drawtext(answer);
80+
setTimeout(function() {
81+
Drawtext("ask " + Name + " a yes or no question");
82+
}, 3000);
83+
84+
}
85+
86+
}
87+
setWatch(function() {
88+
menu();
89+
90+
}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true, edge:"falling"});
91+
92+
Bangle.on('touch', function(button, xy) { WriteAnswer(); });

apps/8ball/metadata.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{ "id": "8ball",
2+
"name": "Magic 8 ball",
3+
"shortName":"8ball",
4+
"icon": "8ball.png",
5+
"version":"0.01",
6+
"screenshots": [
7+
{"url":"screenshot.png"},
8+
{"url":"screenshot-1.png"},
9+
{"url":"screenshot-2.png"}
10+
],
11+
"allow_emulator": true,
12+
"description": "A very sarcastic magic 8ball",
13+
"tags": "game",
14+
"supports": ["BANGLEJS2"],
15+
"storage": [
16+
{"name":"8ball.app.js","url":"app.js"},
17+
{"name":"8ball.img","url":"app-icon.js","evaluate":true}
18+
]
19+
}

apps/8ball/screenshot-1.png

2.02 KB
Loading

apps/8ball/screenshot-2.png

2.11 KB
Loading

apps/8ball/screenshot.png

2.73 KB
Loading

apps/boxclk/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
0.03: Allows showing the month in short or long format by setting `"shortMonth"` to true or false
44
0.04: Improves touchscreen drag handling for background apps such as Pattern Launcher
55
0.05: Fixes step count not resetting after a new day starts
6+
0.06 Added clockbackground app functionality

apps/boxclk/app.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* ---------------------------------------------------------------
66
*/
77

8+
let background = require("clockbg");
89
let storage = require("Storage");
910
let locale = require("locale");
1011
let widgets = require("widget_utils");
1112
let date = new Date();
12-
let bgImage;
1313
let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0;
1414
let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json';
1515
// Add a condition to check if the file exists, if it does not, default to 'boxclk.json'
@@ -71,14 +71,6 @@
7171
* ---------------------------------------------------------------
7272
*/
7373

74-
for (let key in boxesConfig) {
75-
if (key === 'bg' && boxesConfig[key].img) {
76-
bgImage = storage.read(boxesConfig[key].img);
77-
} else if (key !== 'selectedConfig') {
78-
boxes[key] = Object.assign({}, boxesConfig[key]);
79-
}
80-
}
81-
8274
let boxKeys = Object.keys(boxes);
8375

8476
boxKeys.forEach((key) => {
@@ -224,9 +216,7 @@
224216
return function(boxes) {
225217
date = new Date();
226218
g.clear();
227-
if (bgImage) {
228-
g.drawImage(bgImage, 0, 0);
229-
}
219+
background.fillRect(Bangle.appRect);
230220
if (boxes.time) {
231221
boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0));
232222
updatePerMinute = isBool(boxes.time.short, true);
@@ -412,4 +402,4 @@
412402
widgets.swipeOn();
413403
modSetColor();
414404
setup();
415-
}
405+
}

apps/boxclk/boxclk.space.img

-30.3 KB
Binary file not shown.

apps/boxclk/metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "0.05",
55
"description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background",
66
"icon": "app.png",
7+
"dependencies" : { "clockbg":"module" },
78
"screenshots": [
89
{"url":"screenshot.png"},
910
{"url":"screenshot-1.png"},

0 commit comments

Comments
 (0)