Skip to content

Commit

Permalink
squashed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
f00d4tehg0dz committed Aug 22, 2022
1 parent c6ad79e commit e12d19b
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 30 deletions.
Binary file modified Release/com.f00d4tehg0dz.cookieclicker.streamDeckPlugin
Binary file not shown.
51 changes: 32 additions & 19 deletions com.f00d4tehg0dz.cookieclicker.sdPlugin/cookieclicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<meta charset="utf-8"/>
<meta charset="utf-8" />
<title>com.f00d4tehg0dz.cookieclicker</title>
<link rel="stylesheet" href="./css/sdpi.css">
<script src="./js/jquery-3.3.1.js"></script>
Expand All @@ -12,19 +12,19 @@
<body>
<div class="sdpi-wrapper">
<div class="sdpi-item">
<div class="sdpi-item-label">Enter Name for LeaderBoard</div>
<input class="sdpi-item-value" id="nameKey" required>

<div class="sdpi-item-label">Name</div>
<input class="sdpi-item-value" id="nameKey" >
<button class="sdpi-item-value" id="saveButton">💾</button>
</div>
<div class="sdpi-item">
<div class="sdpi-item-label">LeaderBoard</div>
<button onclick="openLeaderBoard()">View</button >
<button onclick="openLeaderBoard()">View</button>
</div>
<div class="sdpi-item">
<div class="sdpi-item-label">Instructions</div>
<details class="sdpi-item-value">
<p>Click the cookie to make more cookies<br>
Cookie Title upgrades and inserts multiplier as you reach cookie clicker milestones
Cookie titles upgrade and X a multiplier as you reach cookie clicker milestones<br>
<br>You can learn more about this plugin by visiting its <button onclick="openGithub()">Github
page</button></p>
</details>
Expand All @@ -47,26 +47,24 @@
}

let settings = $SD.actionInfo.payload.settings;

if (settings.nameKey) {
$("#nameKey").val(settings.nameKey);
}
if (settings.nameKey == null) {
$("#nameKey").val(null);
}
});
}

function openGithub() {
console.log("hel")
$SD.api.openUrl($SD.actionInfo.context,
"https://github.com/f00d4tehg0dz/elgato-streamdeck-cookie-clicker")
}

function openLeaderBoard() {
$SD.api.openUrl($SD.actionInfo.context,
"https://cookie-clicker-leader-board-react.vercel.app/")
}

$SD.api.openUrl($SD.actionInfo.context,
"https://github.com/f00d4tehg0dz/elgato-streamdeck-cookie-clicker")
}

function openLeaderBoard() {
$SD.api.openUrl($SD.actionInfo.context,
"https://cookie-clicker-leader-board-react.vercel.app/")
}
$(document).ready(function () {


$("#updateButton").click(function () {
let nameKey = $("#nameKey").val();
Expand All @@ -80,6 +78,21 @@
$SD.api.sendToPlugin(uuid, actionName, payload);
}
});

$("#saveButton").click(function () {
let nameKey = $("#nameKey").val();

if (!$("#nameKey").val()) {
return;
}
if ($SD && $SD.connection) {
let payload = {};
let saveBtn = true;
payload.nameKey = nameKey;
payload.saveBtn = saveBtn;
$SD.api.sendToPlugin(uuid,actionName, payload);
}
});
});
</script>

Expand Down
73 changes: 65 additions & 8 deletions com.f00d4tehg0dz.cookieclicker.sdPlugin/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ if ($SD) {
});

$SD.on(actionName + ".willAppear", function(jsonObj) {
let settings = jsonObj.payload.settings;

if (settings.automaticRefresh) {
let uuid = jsonObj.context;
let settings = jsonObj.payload;
//setLeaderBoardScore(settings, uuid);
if (settings.nameKey) {
initiateStatus(jsonObj.context, jsonObj.payload.settings);
}

Expand All @@ -27,14 +28,24 @@ if ($SD) {
$SD.on(actionName + ".sendToPlugin", function(jsonObj) {
let uuid = jsonObj.context;
let settings = jsonObj.payload;
setLeaderBoardScore(settings, uuid);
//$SD.api.setSettings(jsonObj.context, jsonObj.payload);
//initiateStatus(jsonObj.context, jsonObj.payload);

if (!settings.saveBtn == true) {
$SD.api.setSettings(jsonObj.context, jsonObj.payload);
setLeaderBoardScore(settings, uuid);
initiateStatus(jsonObj.context, jsonObj.payload);
}
else {
initiateStatus(jsonObj.context, jsonObj.payload.settings);
$SD.api.setSettings(jsonObj.context, jsonObj.payload);
}

});


// When pressed, Cookie Clicker Activates!
$SD.on(actionName + ".keyUp", function(jsonObj) {
initiateStatus(jsonObj.context, jsonObj.payload.settings);
setLeaderBoardScore(settings, uuid);
setNumberIncrease(jsonObj.context, jsonObj.payload.settings)
console.log();
});

Expand Down Expand Up @@ -65,6 +76,10 @@ if ($SD) {
getResults(result => resultCallback(result, context, settings));
}

function setNumberIncrease(context, settings) {
$SD.api.setTitle(context, "Updating");
getResultsIncrease(result => resultCallback(result, context, settings));
}
function numbersBoard(result) {
var resultString = result.number;
ctx.font = 'bold 48px Arial';
Expand Down Expand Up @@ -190,7 +205,7 @@ if ($SD) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
}

function getResults(updateTitleFn) {
function getResultsIncrease(updateTitleFn) {

// 1x
if (localStorage.score >= 0) {
Expand Down Expand Up @@ -243,4 +258,46 @@ if ($SD) {
}

}
function getResults(updateTitleFn) {

// 1x
if (localStorage.score >= 0) {
updateTitleFn(JSON.parse(JSON.stringify({
"number": localStorage.score,
"title": "Grandma",
})));
}

// 2x
if (localStorage.score >= 30) {
updateTitleFn(JSON.parse(JSON.stringify({
"number": localStorage.score,
"title": "Baker",
})));
}

// 10x
if (localStorage.score >= 500) {
updateTitleFn(JSON.parse(JSON.stringify({
"number": localStorage.score,
"title": "Factory",
})));
}

// 30x
if (localStorage.score >= 1000) {
updateTitleFn(JSON.parse(JSON.stringify({
"number": localStorage.score,
"title": "Plant",
})));
}
// 1000x
if (localStorage.score >= 100000) {
updateTitleFn(JSON.parse(JSON.stringify({
"number": localStorage.score,
"title": "S. Plant",
})));
}
}

}
6 changes: 3 additions & 3 deletions com.f00d4tehg0dz.cookieclicker.sdPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
],
"SDKVersion": 2,
"Author": "Adrian Chrysanthou",
"Category": "Cookie Clicker [f00d4tehg0dz]",
"Category": "Cookie Clicker",
"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/elgato-streamdeck-cookie-clicker. 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. Please report any issues you see on the project's Github page. I welcome any feedback.",
"Name": "Cookie Clicker",
"Icon": "icon",
"URL": "https://github.com/f00d4tehg0dz/elgato-streamdeck-cookie-clicker",
"PropertyInspectorPath": "cookieclicker.html",
"Version": "3.4",
"Version": "3.3",
"OS": [
{
"Platform": "mac",
Expand Down

0 comments on commit e12d19b

Please sign in to comment.