Skip to content

Commit

Permalink
Allow disabling explode messages in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-hologram committed Aug 18, 2024
1 parent 56a35ae commit bebd643
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
23 changes: 20 additions & 3 deletions out/bad-thoughts-explode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
var isBadThoughtsExplodePluginEnabled = false;
var areExplodeMessagesDisabled = false;
var explodedCount = 0;
var badThoughts = [
"cant_afford_ride",
Expand Down Expand Up @@ -80,7 +81,7 @@ var togglePluginWindow = function () {
classification: "bad_thoughts_explode",
title: "Bad Thoughts Explode",
width: 200,
height: 65,
height: 90,
widgets: [
{
type: "checkbox",
Expand All @@ -95,11 +96,25 @@ var togglePluginWindow = function () {
isBadThoughtsExplodePluginEnabled = isChecked;
},
},
{
type: "checkbox",
name: "disable_messages",
x: 10,
y: 40,
width: 280,
height: 20,
text: "Disable messages",
tooltip: "Disable showing messages when guests are marked to be exploded. This is just to reduce spam.",
isChecked: areExplodeMessagesDisabled,
onChange: function (isChecked) {
areExplodeMessagesDisabled = isChecked;
},
},
{
type: "label",
name: "exploded_count",
x: 10,
y: 40,
y: 70,
width: 280,
height: 20,
text: "Exploded guests: ".concat(explodedCount),
Expand Down Expand Up @@ -132,7 +147,9 @@ var getGuestsWithBadThoughts = function () {
var badThoughts_1 = getBadThoughtsFromGuest(guest);
if (badThoughts_1.length > 0 && guest.id) {
unhappyGuests.push(guest);
park.postMessage({ text: "".concat(guest.name, " will explode for thinking ").concat(badThoughts_1[0].toString()), type: "peep", subject: guest.id });
if (!areExplodeMessagesDisabled) {
park.postMessage({ text: "".concat(guest.name, " will explode for thinking ").concat(badThoughts_1[0].toString()), type: "peep", subject: guest.id });
}
}
}
}
Expand Down
23 changes: 20 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let isBadThoughtsExplodePluginEnabled = false;
let areExplodeMessagesDisabled = false;

let explodedCount = 0;

Expand Down Expand Up @@ -82,7 +83,7 @@ const togglePluginWindow = (): void => {
classification: "bad_thoughts_explode",
title: "Bad Thoughts Explode",
width: 200,
height: 65,
height: 90,
widgets: [
{
type: "checkbox",
Expand All @@ -97,11 +98,25 @@ const togglePluginWindow = (): void => {
isBadThoughtsExplodePluginEnabled = isChecked;
},
},
{
type: "checkbox",
name: "disable_messages",
x: 10,
y: 40,
width: 280,
height: 20,
text: "Disable messages",
tooltip: "Disable showing messages when guests are marked to be exploded. This is just to reduce spam.",
isChecked: areExplodeMessagesDisabled,
onChange(isChecked) {
areExplodeMessagesDisabled = isChecked;
},
},
{
type: "label",
name: "exploded_count",
x: 10,
y: 40,
y: 70,
width: 280,
height: 20,
text: `Exploded guests: ${explodedCount}`,
Expand Down Expand Up @@ -145,7 +160,9 @@ const getGuestsWithBadThoughts = (): Guest[] => {
if (badThoughts.length > 0 && guest.id) {
unhappyGuests.push(guest);

park.postMessage({ text: `${guest.name} will explode for thinking ${badThoughts[0].toString()}`, type: "peep", subject: guest.id });
if (!areExplodeMessagesDisabled) {
park.postMessage({ text: `${guest.name} will explode for thinking ${badThoughts[0].toString()}`, type: "peep", subject: guest.id });
}
}
}
}
Expand Down

0 comments on commit bebd643

Please sign in to comment.