Skip to content

Commit

Permalink
Increase size and add checkbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Hopkinson committed Apr 24, 2024
1 parent 1fdfa36 commit 86cd9c6
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { button, checkbox, label, textbox, window } from "openrct2-flexui";

let suggestedGuestMaximum: number = park.suggestedGuestMaximum;
let originalGuestMaximum: number = 0;
let suggestedGuestMaximum: number = 0;
let activate: boolean = false;
let event: any;

export const allWidgets = window({
title: "OpenRCT2 Soft Guest Cap Editor",
width: { value: 200, min: 200, max: 10_000 },
height: { value: 100, min: 100, max: 10_000 },
height: { value: 117, min: 117, max: 10_000 },
onUpdate() {
originalGuestMaximum = park.suggestedGuestMaximum;
},
content: [
label({
alignment: "centred",
text: `Original Guest Cap: ${originalGuestMaximum.toString()}`,
tooltip:
"This is the maximum number of guests that will be allowed in your park",
}),
label({
alignment: "centred",
text: "Enter your desired soft guest cap",
Expand All @@ -18,7 +28,8 @@ export const allWidgets = window({
textbox({
text: suggestedGuestMaximum.toString(),
onChange: (text: string) => {
suggestedGuestMaximum = Number(text);
// @ts-ignore
suggestedGuestMaximum = Number.parseInt(text);
},
}),
checkbox({
Expand All @@ -28,10 +39,11 @@ export const allWidgets = window({
activate = checked;
if (checked) {
event = context.subscribe("park.calculateGuestCap", (e) => {
originalGuestMaximum = e.suggestedGuestMaximum;
e.suggestedGuestMaximum = suggestedGuestMaximum;
});
} else if (event) {
event.unsubscribe();
event.dispose();
event = null;
}
},
Expand All @@ -51,6 +63,9 @@ export const allWidgets = window({
export function main() {
if (typeof ui !== "undefined") {
const menuItemName = "Soft Guest Cap Editor";
ui.registerMenuItem(menuItemName, () => allWidgets.open());
ui.registerMenuItem(menuItemName, function () {
originalGuestMaximum = park.suggestedGuestMaximum;
allWidgets.open();
});
}
}

0 comments on commit 86cd9c6

Please sign in to comment.