Skip to content

Commit

Permalink
Fix: update sidewindow
Browse files Browse the repository at this point in the history
  • Loading branch information
Manticore-007 committed Nov 29, 2023
1 parent e433978 commit a79aded
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/gameActions/peepRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function removePeep(peep: Staff | Guest): void
isDisabled: false,
onClick: () => {
ui.getWindow(removePeepWindow).close();
ui.getWindow(sideWindow).close();
sideWindow.close();
ui.getWindow(windowId).findWidget<LabelWidget>("label-peep-name").text = `{RED} No peep selected`;
resetViewport();
setLabelPeepName();
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/allGuestsSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { windowId } from "./windowProperties";
export function activateAllGuests(): void
{
const mainWindow = ui.getWindow(windowId);
const sideWin = ui.getWindow(sideWindow);

if (mainWindow.findWidget<ButtonWidget>("button-picker").isPressed)
{
Expand All @@ -26,7 +25,7 @@ export function activateAllGuests(): void
{
btn.disable("button-delete");
mainWindow.findWidget<LabelWidget>("label-peep-name").text = `{RED} No peep selected`;
sideWin.close();
sideWindow.close();
}
btn.toggle("button-all-guests");
}
11 changes: 5 additions & 6 deletions src/helpers/peepSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ export function setLabelPeepName(): void

function getColourGuest(guest: Guest): void
{
const window = ui.getWindow(sideWindow);
window.findWidget<ColourPickerWidget>("colourpicker-tshirt").colour = guest.tshirtColour;
window.findWidget<ColourPickerWidget>("colourpicker-trousers").colour = guest.trousersColour;
window.findWidget<ColourPickerWidget>("colourpicker-balloon").colour = guest.balloonColour;
window.findWidget<ColourPickerWidget>("colourpicker-hat").colour = guest.hatColour;
window.findWidget<ColourPickerWidget>("colourpicker-umbrella").colour = guest.umbrellaColour;
sideWindow.findWidget<ColourPickerWidget>("colourpicker-tshirt").colour = guest.tshirtColour;
sideWindow.findWidget<ColourPickerWidget>("colourpicker-trousers").colour = guest.trousersColour;
sideWindow.findWidget<ColourPickerWidget>("colourpicker-balloon").colour = guest.balloonColour;
sideWindow.findWidget<ColourPickerWidget>("colourpicker-hat").colour = guest.hatColour;
sideWindow.findWidget<ColourPickerWidget>("colourpicker-umbrella").colour = guest.umbrellaColour;
}
20 changes: 8 additions & 12 deletions src/helpers/staffGetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ export function getFreeze(staff: Staff): void

export function getColourStaff(staff: Staff): void
{
const window = ui.getWindow(sideWindow);
const widget = window.findWidget<ColourPickerWidget>("colourpicker-staff");
const widget = sideWindow.findWidget<ColourPickerWidget>("colourpicker-staff");
widget.colour = staff.colour;
}

export function getCostume(staff: Staff): void
{
const dropdown = ui.getWindow(sideWindow).findWidget<DropdownWidget>("dropdown-costume");
const dropdown = sideWindow.findWidget<DropdownWidget>("dropdown-costume");
if (staff.staffType === "entertainer") {
dropdown.selectedIndex = selectedStaffCostume;
if (staff.costume > 251) {
Expand All @@ -47,27 +46,25 @@ export function getCostume(staff: Staff): void

export function getStaffType(peep: Staff): void
{
const dropdown = ui.getWindow(sideWindow).findWidget<DropdownWidget>("dropdown-staff-type");
const dropdown = sideWindow.findWidget<DropdownWidget>("dropdown-staff-type");
dropdown.text = staffTypeLabel[peep.staffType];
dropdown.selectedIndex = selectedStaffType;
}

export function getCoordinates(staff: Staff): void
{
disableUpdateCoordinates();
const window = ui.getWindow(sideWindow);
updateCoordinates(context.subscribe("interval.tick", () => {
window.findWidget<SpinnerWidget>("spinner-x-position").text = staff.x.toString();
window.findWidget<SpinnerWidget>("spinner-y-position").text = staff.y.toString();
window.findWidget<SpinnerWidget>("spinner-z-position").text = staff.z.toString();
sideWindow.findWidget<SpinnerWidget>("spinner-x-position").text = staff.x.toString();
sideWindow.findWidget<SpinnerWidget>("spinner-y-position").text = staff.y.toString();
sideWindow.findWidget<SpinnerWidget>("spinner-z-position").text = staff.z.toString();
}));
}

export function getLblColourStaff(staff: Staff): void
{
disableUpdateStaffColour();
const window = ui.getWindow(sideWindow);
const widget = window.findWidget<LabelWidget>("textbox-staff-colour");
const widget = sideWindow.findWidget<LabelWidget>("textbox-staff-colour");
updateStaffColour(context.subscribe("interval.tick", () => {
widget.text = `${colourList[staff.colour]}`;
}));
Expand All @@ -76,8 +73,7 @@ export function getLblColourStaff(staff: Staff): void
export function getEnergy(staff: Staff): void
{
disableUpdateEnergy();
const window = ui.getWindow(sideWindow);
updateEnergy(context.subscribe("interval.tick", () => {
window.findWidget<SpinnerWidget>("spinner-energy").text = staff.energy.toString();
sideWindow.findWidget<SpinnerWidget>("spinner-energy").text = staff.energy.toString();
}));
}
10 changes: 4 additions & 6 deletions src/ui/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,15 @@ export class PeepEditorWindow {
btnAbout
],
onClose: () => {
const _sideWindow = ui.getWindow(sideWindow);
if (_sideWindow) { _sideWindow.close(); }
if (sideWindow) { sideWindow.close(); }
disableUpdateViewport();
ui.tool?.cancel();
},
onUpdate: () => {
const window = ui.getWindow(windowId);
const _sidewindow = ui.getWindow(sideWindow);
if (_sidewindow) {
_sidewindow.x = window.x + window.width;
_sidewindow.y = window.y;
if (sideWindow) {
sideWindow.x = window.x + window.width;
sideWindow.y = window.y;
}
}
});
Expand Down
13 changes: 6 additions & 7 deletions src/ui/sideWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import { disableUpdateCoordinates, disableUpdateEnergy, disableUpdateSideWindowP
import { windowColour, windowId } from "../helpers/windowProperties";
import { resetColours } from "./allGuestWidgets";

export const sideWindow = "side-window";
export let sideWindow: Window;

export function openSideWindow(title: string): void
{
const window = ui.getWindow(sideWindow);
const mainWindow = ui.getWindow(windowId);
if (window && window.title === title) {
if (sideWindow && sideWindow.title === title) {
debug(`${title} window is already shown`);
window.bringToFront();
sideWindow.bringToFront();
}
else {
if (window) {window.close();}
ui.openWindow({
classification: sideWindow,
if (sideWindow) {sideWindow.close();}
sideWindow = ui.openWindow({
classification: "side-window",
title: title,
width: 200,
height: mainWindow.height,
Expand Down

0 comments on commit a79aded

Please sign in to comment.