Skip to content

Commit

Permalink
fix #5 (manual notification does not work) and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadret committed Aug 20, 2022
1 parent ef71ed3 commit 9216d3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
10 changes: 4 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.\
Expand Down Expand Up @@ -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.
27 changes: 12 additions & 15 deletions soft-guest-cap-calculator.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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) + "%)";
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -114,9 +113,7 @@ registerPlugin({
);
ui.registerMenuItem(
"Soft Guest Cap Calculator",
function() {
openWindow();
}
openWindow
);
},
});
});

0 comments on commit 9216d3e

Please sign in to comment.