From 9216d3eac0f55d42347223648030f8429794a7f4 Mon Sep 17 00:00:00 2001 From: Stephan Spengler Date: Sat, 20 Aug 2022 17:46:18 +0200 Subject: [PATCH] fix #5 (manual notification does not work) and update readme --- readme.md | 10 ++++------ soft-guest-cap-calculator.js | 27 ++++++++++++--------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/readme.md b/readme.md index 155c10c..cf4628a 100644 --- a/readme.md +++ b/readme.md @@ -11,13 +11,11 @@ For detailed information, look at [this guide by Deurklink](https://forums.openr ## Installation -1. Make sure that your OpenRCT2 version is up-to-date. You need at least version `0.3.4` (as of June 2021: not yet released) or a recent development version. -2. Go to the [releases](https://github.com/Sadret/openrct2-soft-guest-cap-calculator/releases) page and download the `soft-guest-cap-calculator-2.0.0.js` file from the latest release. Save it in the `plugin` subfolder of your OpenRCT2 user directory.\ +1. Make sure that your OpenRCT2 version is up-to-date. You need at least version `0.3.4` (released July 2021). +2. Go to the [releases](https://github.com/Sadret/openrct2-soft-guest-cap-calculator/releases) page and download the `openrct2-soft-guest-cap-calculator-2.0.2.js` file from the latest release. Save it in the `plugin` subfolder of your OpenRCT2 user directory.\ On Windows, this is usually at `C:Users\{User}\Documents\OpenRCT2\plugin`. 3. Start OpenRCT2 and open a scenario. -**Attention:** If you are on OpenRCT2 version `0.3.3` (as of June 2021: latest stable build), you need to use an earlier release, which you can get [here](https://github.com/Sadret/openrct2-soft-guest-cap-calculator/releases/tag/1.1.0). - ## Usage Each in-game day, the plug-in queries the soft guest cap from the game. If it has changed since the last time, the user will be notified by an in-game message.\ @@ -47,12 +45,12 @@ If you find any bugs or if you have any ideas for improvements, you can open an If you like this plug-in, please leave a star on GitHub. -If you really want to support me, you can [buy me a coffee](https://www.BuyMeACoffee.com/SadretGaming). +If you really want to support me, you can [buy me a coffee](https://ko-fi.com/sadret). ## Thanks to - @Mar-Koeh: Current guest cap as percentage of needed guests to meet scenario objective. ## Copyright and License -Copyright (c) 2020-2021 Sadret\ +Copyright (c) 2020-2022 Sadret\ The OpenRCT2 plug-in "Soft Guest Cap Calculator" is licensed under the GNU General Public License version 3. diff --git a/soft-guest-cap-calculator.js b/soft-guest-cap-calculator.js index d5cd0d6..31d4ba9 100644 --- a/soft-guest-cap-calculator.js +++ b/soft-guest-cap-calculator.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2020-2021 Sadret + * Copyright (c) 2020-2022 Sadret * * The OpenRCT2 plug-in "Soft Guest Cap Calculator" is licensed * under the GNU General Public License version 3. @@ -12,17 +12,17 @@ var notifyOnDecrease = context.sharedStorage.get("soft_guest_cap_calculator.noti var last = 0; -var prepareNotify = function(forceNotify) { +function prepareNotify(forceNotify) { var sgc = park.suggestedGuestMaximum; - if (sgc > last && notifyOnIncrease) + if (sgc > last && (notifyOnIncrease || forceNotify)) return notify("increased to", sgc); - if (sgc < last && notifyOnDecrease) + if (sgc < last && (notifyOnDecrease || forceNotify)) return notify("decreased to", sgc); - if (sgc === last && forceNotify) + if (forceNotify) return notify("is", sgc); } -var notify = function(wording, sgc) { +function notify(wording, sgc) { var text = "soft guest cap " + wording + " " + sgc; if (scenario.objective.type === "guestsBy" || scenario.objective.type === "guestsAndRating") text += " (" + Math.floor(100 * sgc / scenario.objective.guests) + "%)"; @@ -34,10 +34,9 @@ var notify = function(wording, sgc) { } var handle = undefined; -var openWindow = function() { - if (handle !== undefined) - return; - handle = ui.openWindow({ + +function openWindow() { + handle |= ui.openWindow({ classification: "soft-guest-cap-calculator", width: 128, height: 92, @@ -92,7 +91,7 @@ var openWindow = function() { registerPlugin({ name: "soft guest cap calculator", - version: "2.0.1", + version: "2.0.2", authors: ["Sadret", "Mar-Koeh"], type: "local", licence: "GPL-3.0", @@ -114,9 +113,7 @@ registerPlugin({ ); ui.registerMenuItem( "Soft Guest Cap Calculator", - function() { - openWindow(); - } + openWindow ); }, -}); \ No newline at end of file +});