changes to textbox

This commit is contained in:
Arlo Filley 2022-11-04 12:18:45 +00:00
parent a36c8759c1
commit f6c1059250
6 changed files with 38 additions and 6 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -6,8 +6,8 @@ pub mod sql;
#[get("/")] #[get("/")]
fn test() -> String { fn test() -> String {
sql::create_database() sql::create_database()
.expect(&format!("couldn't create database")); .expect("couldn't create database");
format!("Hello world") String::from("Hello World!")
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -45,5 +45,5 @@ fn rocket() -> Rocket<Build> {
rocket::build() rocket::build()
.mount("/test", routes![test]) // testing only, should return "Hello world" .mount("/test", routes![test]) // testing only, should return "Hello world"
.mount("/api", routes![post_test]) .mount("/api", routes![post_test])
.mount("/", FileServer::from(relative!("website"))) // hosts the fileserver .mount("/typing", FileServer::from(relative!("website"))) // hosts the fileserver
} }

BIN
website/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -11,10 +11,11 @@
<script src="./index.js" type="text/javascript"></script> <script src="./index.js" type="text/javascript"></script>
<!-- Element Script Files --> <!-- Element Script Files -->
<script src="./ui_elements/button.js"></script>
<script src="./ui_elements/canvas.js"></script> <script src="./ui_elements/canvas.js"></script>
<script src="./ui_elements/textbox.js"></script> <script src="./ui_elements/textbox.js"></script>
<script src="./ui_elements/timemenu.js"></script>
<script src="./ui_elements/timer.js"></script> <script src="./ui_elements/timer.js"></script>
<script src="./ui_elements/button.js"></script>
<!-- Screen Files--> <!-- Screen Files-->
<script src="./screens/screenmanager.js"></script> <script src="./screens/screenmanager.js"></script>

View File

@ -1,4 +1,17 @@
class Textbox { class Textbox {
/**
* Creates a new instance of the Textbox class
* @param {int} pX
* @param {int} pY
* @param {int} pWidth
* @param {int} pHeight
* @param {int} pLayer
* @param {bool} pVisible
* @param {hexcode} pTextColor
* @param {bool} pBorder
* @param {hexcode} pBorderColor
* @param {hexcode} pBackgroundColor
*/
constructor(pX, pY, pWidth, pHeight, pLayer, pVisible, pTextColor, pBorder, pBorderColor, pBackgroundColor) { constructor(pX, pY, pWidth, pHeight, pLayer, pVisible, pTextColor, pBorder, pBorderColor, pBackgroundColor) {
this.x = pX; this.x = pX;
this.y = pY; this.y = pY;
@ -108,13 +121,22 @@ class Textbox {
this.letters = pLetters; this.letters = pLetters;
} }
/**
* takes a key and handles it in the textbox
* @param {String} pKey
* @returns
*/
letterTyped(pKey) { letterTyped(pKey) {
if (pKey === "Enter" && (screenManager.screen.constructor.name === "StartScreen" || screenManager.screen.constructor.name === "EndScreen")) { if (pKey === "Enter" && (screenManager.screen.constructor.name === "StartScreen" /* || screenManager.screen.constructor.name === "EndScreen" */)) {
screenManager.setScreen(new TestScreen()); screenManager.setScreen(new TestScreen());
return; return;
} }
if (pKey === "Backspace" && this.letters.length > 1) { if (screenManager.timer.time === 0) {
return;
}
if (pKey === "Backspace" && this.letters.length > 0) {
this.letters.pop(); this.letters.pop();
return; return;
} }
@ -143,6 +165,10 @@ class Textbox {
this.allowedLetters = pAllowedLetters; this.allowedLetters = pAllowedLetters;
} }
/**
* draws a Textbox
* @returns
*/
draw() { draw() {
// doesn't render the textbox if it should not be visible to the user. // doesn't render the textbox if it should not be visible to the user.
if (!this.visible) { if (!this.visible) {

View File

@ -0,0 +1,5 @@
class TimeMenu {
constructor() {
}
}