2023-10-17 15:15:41 +01:00
|
|
|
/**
|
2024-03-23 15:56:37 +00:00
|
|
|
* @file This file provides a UserShower class, representing a visual element for editing the length of a test.
|
2023-10-17 15:15:41 +01:00
|
|
|
* @author Arlo Filley
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2024-03-23 15:56:37 +00:00
|
|
|
* Represents a visual element for editing the length of a test.
|
|
|
|
* @class
|
2023-10-17 15:15:41 +01:00
|
|
|
*/
|
|
|
|
class UserShower {
|
2024-03-23 15:56:37 +00:00
|
|
|
/**
|
|
|
|
* Creates an instance of UserShower.
|
|
|
|
* @constructor
|
|
|
|
* @param {number} x - The x-coordinate of the UserShower.
|
|
|
|
* @param {number} y - The y-coordinate of the UserShower.
|
|
|
|
* @param {number} height - The height of the UserShower.
|
|
|
|
* @param {number} width - The width of the UserShower.
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
constructor(x, y, height, width) {
|
2024-03-23 15:56:37 +00:00
|
|
|
/**
|
|
|
|
* Represents the button associated with the UserShower.
|
|
|
|
* @type {Button}
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
this.button = new Button(x, y, height, width, "");
|
|
|
|
|
2024-03-23 15:56:37 +00:00
|
|
|
/**
|
|
|
|
* The x-coordinate of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
this.x = x;
|
2024-03-23 15:56:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The y-coordinate of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
this.y = y;
|
2024-03-23 15:56:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The height of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
this.height = height;
|
2024-03-23 15:56:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The width of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
this.width = width;
|
2024-03-23 15:56:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The horizontal center of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
this.hCenter = this.x + this.height / 2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The vertical center of the UserShower.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
this.vCenter = this.y + this.width / 2;
|
2023-10-17 15:15:41 +01:00
|
|
|
}
|
|
|
|
|
2024-03-23 15:56:37 +00:00
|
|
|
/**
|
|
|
|
* Draws the UserShower and its associated button.
|
|
|
|
*/
|
2023-10-17 15:15:41 +01:00
|
|
|
draw() {
|
|
|
|
textAlign(CENTER, CENTER);
|
|
|
|
|
2024-03-23 15:56:37 +00:00
|
|
|
// Draw the button
|
2023-10-17 15:15:41 +01:00
|
|
|
this.button.draw();
|
|
|
|
|
2024-03-23 15:56:37 +00:00
|
|
|
// Set image mode to center
|
2023-10-17 15:15:41 +01:00
|
|
|
imageMode(CENTER);
|
|
|
|
|
2024-03-23 15:56:37 +00:00
|
|
|
// Check button state and display appropriate icon
|
2023-10-17 15:15:41 +01:00
|
|
|
if (this.button.isPressed()) {
|
|
|
|
screenManager.setScreen(new AccountScreen());
|
2024-03-23 15:56:37 +00:00
|
|
|
} else if (this.button.isHovered()) {
|
|
|
|
image(accountIconBlack, this.hCenter, this.vCenter);
|
|
|
|
} else {
|
|
|
|
image(accountIconWhite, this.hCenter, this.vCenter);
|
2023-10-17 15:15:41 +01:00
|
|
|
}
|
|
|
|
}
|
2024-03-23 15:56:37 +00:00
|
|
|
}
|