From 30fb50c3b8fa77576c95a8fe7e9aaa9ad62c0c2c Mon Sep 17 00:00:00 2001 From: Janis Date: Fri, 10 Oct 2025 13:31:50 +0200 Subject: [PATCH] Add WebUI and ingame route, update Configuration and DefaultConfiguration for UI integration --- .../WebApplicationConfiguration.scala | 9 +++++++ .../app/controllers/HomeController.scala | 11 ++++++-- knockoutwhistweb/app/controllers/WebUI.scala | 12 +++++++++ knockoutwhistweb/app/views/index.scala.html | 2 +- knockoutwhistweb/app/views/main.scala.html | 25 ------------------- knockoutwhistweb/app/views/tui.scala.html | 1 + knockoutwhistweb/conf/routes | 1 + 7 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 knockoutwhistweb/app/components/WebApplicationConfiguration.scala create mode 100644 knockoutwhistweb/app/controllers/WebUI.scala delete mode 100644 knockoutwhistweb/app/views/main.scala.html create mode 100644 knockoutwhistweb/app/views/tui.scala.html diff --git a/knockoutwhistweb/app/components/WebApplicationConfiguration.scala b/knockoutwhistweb/app/components/WebApplicationConfiguration.scala new file mode 100644 index 0000000..5124c2b --- /dev/null +++ b/knockoutwhistweb/app/components/WebApplicationConfiguration.scala @@ -0,0 +1,9 @@ +package components + +import de.knockoutwhist.components.DefaultConfiguration + +class WebApplicationConfiguration extends DefaultConfiguration { + + + +} diff --git a/knockoutwhistweb/app/controllers/HomeController.scala b/knockoutwhistweb/app/controllers/HomeController.scala index 883c557..3fa3357 100644 --- a/knockoutwhistweb/app/controllers/HomeController.scala +++ b/knockoutwhistweb/app/controllers/HomeController.scala @@ -21,14 +21,21 @@ class HomeController @Inject()(val controllerComponents: ControllerComponents) e * will be called when the application receives a `GET` request with * a path of `/`. */ - def index() = { + def index(): Action[AnyContent] = { if (!initial) { initial = true KnockOutWhist.main(new Array[String](_length = 0)) } Action { implicit request: Request[AnyContent] => { - Ok(views.html.main.render("KnockoutWhist", views.html.index.apply())) + Ok(views.html.main.apply("KnockoutWhist")(views.html.)) } } } + + def ingame(): Action[AnyContent] = { + Action { implicit request: Request[AnyContent] => { + Ok(views.html.tui.apply()) + } + } + } \ No newline at end of file diff --git a/knockoutwhistweb/app/controllers/WebUI.scala b/knockoutwhistweb/app/controllers/WebUI.scala new file mode 100644 index 0000000..9103001 --- /dev/null +++ b/knockoutwhistweb/app/controllers/WebUI.scala @@ -0,0 +1,12 @@ +package controllers + +import de.knockoutwhist.ui.UI + +object WebUI extends UI { + + override def initial: Boolean = true + + + + +} diff --git a/knockoutwhistweb/app/views/index.scala.html b/knockoutwhistweb/app/views/index.scala.html index 68d37fb..1f2e671 100644 --- a/knockoutwhistweb/app/views/index.scala.html +++ b/knockoutwhistweb/app/views/index.scala.html @@ -1,4 +1,4 @@ -@() +@(output: String) @main("Welcome to Play") {

Welcome to Play!

diff --git a/knockoutwhistweb/app/views/main.scala.html b/knockoutwhistweb/app/views/main.scala.html deleted file mode 100644 index 808a8b8..0000000 --- a/knockoutwhistweb/app/views/main.scala.html +++ /dev/null @@ -1,25 +0,0 @@ -@* - * This template is called from the `index` template. This template - * handles the rendering of the page header and body tags. It takes - * two arguments, a `String` for the title of the page and an `Html` - * object to insert into the body of the page. - *@ -@(title: String)(content: Html) - - - - - @* Here's where we render the page title `String`. *@ - @title - - - - - - @* And here's where we render the `Html` object containing - * the page content. *@ - @content - - - - diff --git a/knockoutwhistweb/app/views/tui.scala.html b/knockoutwhistweb/app/views/tui.scala.html new file mode 100644 index 0000000..bcca00b --- /dev/null +++ b/knockoutwhistweb/app/views/tui.scala.html @@ -0,0 +1 @@ +@() \ No newline at end of file diff --git a/knockoutwhistweb/conf/routes b/knockoutwhistweb/conf/routes index 60e8169..be56278 100644 --- a/knockoutwhistweb/conf/routes +++ b/knockoutwhistweb/conf/routes @@ -5,6 +5,7 @@ # An example controller showing a sample home page GET / controllers.HomeController.index() +GET /ingame controllers.HomeController.ingame() # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)