From f6c1059250dd77b9cdf9cad45fa82acf0ac17477 Mon Sep 17 00:00:00 2001 From: ArloFilley Date: Fri, 4 Nov 2022 12:18:45 +0000 Subject: [PATCH] changes to textbox --- .DS_Store | Bin 10244 -> 10244 bytes src/main.rs | 6 +++--- website/.DS_Store | Bin 0 -> 6148 bytes website/index.html | 3 ++- website/ui_elements/textbox.js | 30 ++++++++++++++++++++++++++++-- website/ui_elements/timemenu.js | 5 +++++ 6 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 website/.DS_Store create mode 100644 website/ui_elements/timemenu.js diff --git a/.DS_Store b/.DS_Store index 1b16b2c5fb2ba1b77a16eb38d8c7c78609fc0231..1a42b1590e0413bd2d28dc7c44370268efb8ca7b 100644 GIT binary patch delta 356 zcmZn(XbG6$&nUVvU^hRb=wu#&Y;A6aWQJmfc!qq20)|wEJRmEDA(5fdGbcYeDJMUP zfq_AQfq_vLNY9&`BjC&!KY4?IEtnLW%p!OW!rJ^&@FpWv@TRadRFGRFiy6x75kJZV zmCulphqC6uSy!Y$dOk>b3o`>9Q^b&*R9;*FwSLEB0l`9UiRx-2OG6z6VFvcp&S@0NkB(sGL$f+B3rVtFr8^LyTUJ)&8J0H!93R^?gRin C2V(00 delta 149 zcmZn(XbG6$&nU1lU^hRbz+@hQ?8$2dEEp9g?~@Xn{6|0?%CZtX2VrfN7rMy^733F@ zh6*~0WHCdThs2LEfteDM7f8v1S*8%F$z0M<^^ diff --git a/src/main.rs b/src/main.rs index 4a39804..6902199 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,8 @@ pub mod sql; #[get("/")] fn test() -> String { sql::create_database() - .expect(&format!("couldn't create database")); - format!("Hello world") + .expect("couldn't create database"); + String::from("Hello World!") } #[derive(Deserialize)] @@ -45,5 +45,5 @@ fn rocket() -> Rocket { rocket::build() .mount("/test", routes![test]) // testing only, should return "Hello world" .mount("/api", routes![post_test]) - .mount("/", FileServer::from(relative!("website"))) // hosts the fileserver + .mount("/typing", FileServer::from(relative!("website"))) // hosts the fileserver } \ No newline at end of file diff --git a/website/.DS_Store b/website/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c2f8851655cb51a96cb3ae2c2d905d911213c136 GIT binary patch literal 6148 zcmeHKOHRW;41G>28tA4=Hb^-^C2kO^vS7^tfV349r4&&rvCN)3a0SlC3ZBQKicDdP zRAfhBS+58|nueu{ywDgIhYpkYqv#L4L8Apx2tu9M4!MzVC_e5f*sBjJ_`z;f@hYG~F0ENn(ml%ze6t zye9rR8b;K~svn70pC_K;i6@!!M9I0c+r)c-4cEM)Z$n*%nBChdGjHFR;n2kya0Z-# zy<&hlTcsEndg}~01J1yf0sTIdRK+S{YZyKqY(fb@?9m*A{qXZoEY(1)BDRLKP{cxs z7AmpCkXSp2g>$}&{;i>fL&DBnC+;kI literal 0 HcmV?d00001 diff --git a/website/index.html b/website/index.html index d2facd9..58f4341 100644 --- a/website/index.html +++ b/website/index.html @@ -11,10 +11,11 @@ + + - diff --git a/website/ui_elements/textbox.js b/website/ui_elements/textbox.js index c44873b..dfc1e85 100644 --- a/website/ui_elements/textbox.js +++ b/website/ui_elements/textbox.js @@ -1,4 +1,17 @@ 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) { this.x = pX; this.y = pY; @@ -108,13 +121,22 @@ class Textbox { this.letters = pLetters; } + /** + * takes a key and handles it in the textbox + * @param {String} pKey + * @returns + */ 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()); return; } - if (pKey === "Backspace" && this.letters.length > 1) { + if (screenManager.timer.time === 0) { + return; + } + + if (pKey === "Backspace" && this.letters.length > 0) { this.letters.pop(); return; } @@ -143,6 +165,10 @@ class Textbox { this.allowedLetters = pAllowedLetters; } + /** + * draws a Textbox + * @returns + */ draw() { // doesn't render the textbox if it should not be visible to the user. if (!this.visible) { diff --git a/website/ui_elements/timemenu.js b/website/ui_elements/timemenu.js new file mode 100644 index 0000000..2eb52ca --- /dev/null +++ b/website/ui_elements/timemenu.js @@ -0,0 +1,5 @@ +class TimeMenu { + constructor() { + + } +} \ No newline at end of file