diff --git a/Release/com.f00d4tehg0dz.cookieclicker.streamDeckPlugin b/Release/com.f00d4tehg0dz.cookieclicker.streamDeckPlugin index 9914cae..2024bca 100644 Binary files a/Release/com.f00d4tehg0dz.cookieclicker.streamDeckPlugin and b/Release/com.f00d4tehg0dz.cookieclicker.streamDeckPlugin differ diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/cookieclicker.html b/com.f00d4tehg0dz.cookieclicker.sdPlugin/cookieclicker.html index 7df4124..85f0644 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/cookieclicker.html +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/cookieclicker.html @@ -4,54 +4,80 @@ com.f00d4tehg0dz.cookieclicker - - - + + +
+
+
Enter Name for LeaderBoard
+ + +
+
+
LeaderBoard
+ +
Instructions

Click the cookie to make more cookies
- Cookie Title upgrades as you reach cookie clicker milestones

-

You can learn more about this plugin by visiting its Github - page by clicking here. + Cookie Title upgrades and inserts multiplier as you reach cookie clicker milestones +
You can learn more about this plugin by visiting its

+
+ +
- + + diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/index.html b/com.f00d4tehg0dz.cookieclicker.sdPlugin/index.html index f4327ea..df75a7e 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/index.html +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/index.html @@ -9,11 +9,11 @@ bg image - - - - - + + + + + diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/app.js b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/app.js index b448569..2a159e2 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/app.js +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/app.js @@ -1,6 +1,15 @@ if ($SD) { const actionName = "com.f00d4tehg0dz.cookieclicker.action"; var num = 0; + if (localStorage.getItem("score") === null) { + var scores = 0; + localStorage.setItem("score", scores.toString()); + localStorage.score = 0 + } + else { + num = localStorage.score + } + $SD.on("connected", function(jsonObj) { console.log("Connected!"); @@ -8,14 +17,19 @@ if ($SD) { $SD.on(actionName + ".willAppear", function(jsonObj) { let settings = jsonObj.payload.settings; + if (settings.automaticRefresh) { initiateStatus(jsonObj.context, jsonObj.payload.settings); } + }); $SD.on(actionName + ".sendToPlugin", function(jsonObj) { - $SD.api.setSettings(jsonObj.context, jsonObj.payload); - initiateStatus(jsonObj.context, jsonObj.payload); + let uuid = jsonObj.context; + let settings = jsonObj.payload; + setLeaderBoardScore(settings, uuid); + //$SD.api.setSettings(jsonObj.context, jsonObj.payload); + //initiateStatus(jsonObj.context, jsonObj.payload); }); // When pressed, Cookie Clicker Activates! @@ -24,6 +38,8 @@ if ($SD) { console.log(); }); + + function initiateStatus(context, settings) { // Initial call for the first time @@ -48,7 +64,6 @@ if ($SD) { $SD.api.setTitle(context, "Updating"); getResults(result => resultCallback(result, context, settings)); } - function numbersBoard(result) { var resultString = result.number; @@ -60,6 +75,58 @@ if ($SD) { // ctx.fillText(resultString , (canvas.width/2) - (textWidth / 2), 80); } + function setLeaderBoardScore(settings,uuid) { + // Set up our HTTP request + var xhr = new XMLHttpRequest(); + + // Setup our listener to process completed requests + xhr.onload = function () { + + // Process our return data + if (xhr.status >= 200 && xhr.status < 300) { + // Runs when the request is successful + xhr.open("PUT", `https://f00d.me/api/leaderboard/${uuid}`); + + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json"); + + xhr.onload = () => console.log(xhr.responseText); + const name = settings.nameKey; + let data = `{ + "_id": "${uuid}", + "name": "${name}", + "score": ${localStorage.score} + }`; + + xhr.send(data); + console.log(xhr.responseText); + } else { + // Runs when it's not + xhr.open("POST", "https://f00d.me/api/leaderboard"); + + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json"); + const name = settings.nameKey; + xhr.onload = () => console.log(xhr.responseText); + let data = `{ + "_id": "${uuid}", + "name": "${name}", + "score": ${localStorage.score} + }`; + + xhr.send(data); + console.log(xhr.responseText); + } + + }; + + // Create and send a GET request + // The first argument is the post type (GET, POST, PUT, DELETE, etc.) + // The second argument is the endpoint URL + xhr.open('GET', `https://f00d.me/api/leaderboard/${uuid}`); + xhr.send(); + } + function titleBoard(result) { var resultString = result.title; ctx.font = 'bold 30px Arial'; @@ -121,49 +188,54 @@ if ($SD) { function getResults(updateTitleFn) { // 1x - if (num >= 0) { - num += 1; + if (localStorage.score >= 0) { + var scores = (parseInt(localStorage.getItem("score"))+1); + localStorage.setItem("score", scores.toString()); updateTitleFn(JSON.parse(JSON.stringify({ - "number": num, + "number": localStorage.score, "title": "Grandma", }))); } // 2x - if (num >= 30) { - num += 2; + if (localStorage.score >= 30) { + var scores = (parseInt(localStorage.getItem("score"))+2); + localStorage.setItem("score", scores.toString()); updateTitleFn(JSON.parse(JSON.stringify({ - "number": num, + "number": localStorage.score, "title": "Baker", }))); } // 10x - if (num >= 500) { - num += 10; + if (localStorage.score >= 500) { + var scores = (parseInt(localStorage.getItem("score"))+10); + localStorage.setItem("score", scores.toString()); updateTitleFn(JSON.parse(JSON.stringify({ - "number": num, + "number": localStorage.score, "title": "Factory", }))); } // 30x - if (num >= 1000) { - num += 30; + if (localStorage.score >= 1000) { + var scores = (parseInt(localStorage.getItem("score"))+50); + localStorage.setItem("score", scores.toString()); updateTitleFn(JSON.parse(JSON.stringify({ - "number": num, + "number": localStorage.score, "title": "Plant", }))); } // 1000x - if (num >= 100000) { - num += 1000; + if (localStorage.score >= 100000) { + var scores = (parseInt(localStorage.getItem("score"))+1000); + localStorage.setItem("score", scores.toString()); updateTitleFn(JSON.parse(JSON.stringify({ - "number": num, + "number": localStorage.score, "title": "S. Plant", }))); - } + } } } \ No newline at end of file diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/jquery-3.3.1.js b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/jquery-3.3.1.js index 9b5206b..01b858f 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/jquery-3.3.1.js +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/jquery-3.3.1.js @@ -10361,4 +10361,4 @@ if ( !noGlobal ) { return jQuery; -} ); +} ); \ No newline at end of file diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/moment.js b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/moment.js index 1b12971..69ace73 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/moment.js +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/js/moment.js @@ -4599,4 +4599,4 @@ return hooks; -}))); +}))); \ No newline at end of file diff --git a/com.f00d4tehg0dz.cookieclicker.sdPlugin/manifest.json b/com.f00d4tehg0dz.cookieclicker.sdPlugin/manifest.json index b6b84c8..14dcf3b 100644 --- a/com.f00d4tehg0dz.cookieclicker.sdPlugin/manifest.json +++ b/com.f00d4tehg0dz.cookieclicker.sdPlugin/manifest.json @@ -5,7 +5,10 @@ "Name": "CookieClicker", "States": [ { - "Image": "icon" + "Image": "icon", + "TitleAlignment": "middle", + "FontSize": "9", + "ShowTitle": true } ], "SupportedInMultiActions": false, @@ -15,15 +18,13 @@ ], "SDKVersion": 2, "Author": "Adrian Chrysanthou", - "Category": "Cookie Clicker [f00d4tehg0dz]", - "CategoryIcon": "icons/category-icon", "CodePath": "index.html", - "Description": "A CookieClicker Status plugin developed by Adrian Chrysanthou. You can find more information about this plugin at https://github.com/f00d4tehg0dz/Doge-Coin-Plugin-for-Eglato-Streamdeck. Please report any issues you see on the project's Github page. I welcome any feedback.", + "Description": "A CookieClicker Status plugin developed by Adrian Chrysanthou. You can find more information about this plugin at https://github.com/f00d4tehg0dz/elgato-streamdeck-cookie-clicker. Please report any issues you see on the project's Github page. I welcome any feedback.", "Name": "CookieClicker Status", "Icon": "icon", - "URL": "https://github.com/f00d4tehg0dz/Cookie-Clicker-Plugin-for-Eglato-Streamdeck", + "URL": "https://github.com/f00d4tehg0dz/elgato-streamdeck-cookie-clicker", "PropertyInspectorPath": "cookieclicker.html", - "Version": "2.3", + "Version": "3.1", "OS": [ { "Platform": "mac", diff --git a/elgatogif_AME/elgatogif.gif b/elgatogif_AME/elgatogif.gif index 516a3e4..2788f4b 100644 Binary files a/elgatogif_AME/elgatogif.gif and b/elgatogif_AME/elgatogif.gif differ diff --git a/elgatogif_AME/elgatogif.mp4 b/elgatogif_AME/elgatogif.mp4 deleted file mode 100644 index ebdc9a3..0000000 Binary files a/elgatogif_AME/elgatogif.mp4 and /dev/null differ diff --git a/elgatogif_AME/elgatomp4.mp4 b/elgatogif_AME/elgatomp4.mp4 new file mode 100644 index 0000000..8e64f7a Binary files /dev/null and b/elgatogif_AME/elgatomp4.mp4 differ diff --git a/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24.aep b/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24.aep deleted file mode 100644 index dfd5cac..0000000 Binary files a/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24.aep and /dev/null differ diff --git a/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24_1.aep b/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24_1.aep deleted file mode 100644 index b0fd78b..0000000 Binary files a/elgatogif_AME/tmpAEtoAMEProject-2022-01-30_00-39-24_1.aep and /dev/null differ