Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
matrix:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
os: [ubuntu-latest, windows-latest, macos-latest]
jdk: [11]
jdk: [11, 17, 21]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Upload jar as artifact
uses: actions/upload-artifact@v4
with:
name: software-challenge-gui-${{ github.sha }}-${{ matrix.os }}
name: software-challenge-gui-${{ github.sha }}-j${{ matrix.jdk }}-${{ matrix.os }}
path: build/*.jar
release:
needs: [build, build-arm]
Expand All @@ -64,7 +64,7 @@ jobs:
steps:
- uses: actions/download-artifact@v4 # https://github.com/actions/download-artifact
with:
pattern: software-challenge-gui-${{ github.sha }}-*
pattern: software-challenge-gui-${{ github.sha }}-j11-*
path: build
merge-multiple: true
- name: Release ${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
path = backend
url = https://github.com/software-challenge/backend
shallow = true
branch = plugin/4-gewinnt
[submodule ".idea"]
path = .idea
url = https://github.com/software-challenge/idea-config
Expand Down
Empty file.
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## <a target="_blank" rel="noopener noreferrer" href="https://www.software-challenge.de"><img width="128" src="https://software-challenge.de/site/themes/freebird/img/logo.png" alt="Software-Challenge Logo"></a> Grafischer Spieleserver der Software-Challenge Germany ![.github/workflows/gradle.yml](https://github.com/software-challenge/gui/workflows/.github/workflows/gradle.yml/badge.svg)

Dies ist die Grafische Oberfläche für die Software-Challenge Germany,
seit Saison 2020/21 in Kotlin TornadoFX aufbauend auf JavaFX.
seit Saison 2020/21 in Kotlin TornadoFX, aufbauend auf JavaFX.

Nutzerdokumentation: https://docs.software-challenge.de/server.html

Expand All @@ -23,15 +23,15 @@ wird der Server auf diesem Port Verbindungen von Spielern erwarten.
### Kollaboration

Unsere Commit-Messages folgen dem Muster `type(scope): summary`
(siehe [Karma Runner Konvention](http://karma-runner.github.io/6.2/dev/git-commit-msg.html)),
(siehe [Karma Runner Konvention](http://karma-runner.github.io/6.4/dev/git-commit-msg.html)),
wobei die gängigen Scopes in [.dev/scopes.txt](.dev/scopes.txt) definiert werden.
Nach dem Klonen mit git sollte dazu der hook aktiviert werden:

git config core.hooksPath .dev/githooks

Um bei den Branches die Übersicht zu behalten,
sollten diese ebenfalls nach der Konvention benannt werden,
z. B. könnte ein Branch mit einem Release-Fix für Gradle `chore/gradle/release-fix` heißen
z. B. könnte ein Branch mit einem Release-Fix für Gradle `build/gradle/release-fix` heißen
und ein Branch, der ein neues Login-Feature zur GUI hinzufügt, `feat/gui-login`.

Wenn die einzelnen Commits eines Pull Requests eigenständig funktionieren,
Expand All @@ -40,15 +40,4 @@ ansonsten (gerade bei experimentier-Branches) ein squash merge,
wobei der Titel des Pull Requests der Commit-Message entsprechen sollte.

Detaillierte Informationen zu unserem Kollaborations-Stil
findet ihr in der [Kull Konvention](https://kull.jfischer.org).

### Java-Versionen und Abhängigkeiten

Aktuell können die Backend-docs nur mit JDK 8 gebaut werden,
dieses Projekt braucht jedoch für [tornadofx](https://github.com/edvin/tornadofx2)
mindestens Java 11.
Daher müssen die Releases separat gebaut werden.

Tornadofx wird leider seit einigen Jahren nicht mehr entwickelt.
Wir schauen gerade wie es da weitergeht.
Eventuell ein eigener Fork.
findet ihr in der [Kull Konvention](https://kull.jfischer.org).
2 changes: 1 addition & 1 deletion backend
Submodule backend updated 167 files
59 changes: 34 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Properties

val minJavaVersion = JavaVersion.VERSION_11
val targetJavaVersion = JavaVersion.current() // minJavaVersion can be set for compatibility
plugins {
val minJavaVersion = JavaVersion.VERSION_11 // Declared twice because plugins block has its own scope
require(JavaVersion.current() >= minJavaVersion) {
"Building requires at least JDK $minJavaVersion - please look into the README"
}

application
kotlin("jvm") version "1.9.25"
kotlin("jvm") version "2.3.0"
id("idea")
id("org.openjfx.javafxplugin") version "0.1.0"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("com.gradleup.shadow") version "9.1.0"

id("com.github.ben-manes.versions") version "0.47.0"
id("se.patrikerdes.use-latest-versions") version "0.2.18"
id("com.github.ben-manes.versions") version "0.53.0"
id("se.patrikerdes.use-latest-versions") version "0.2.19"
}

idea {
Expand All @@ -34,7 +36,7 @@ val versionFromBackend by lazy {
arrayOf("year", "minor", "patch").map { versions["socha.version.$it"].toString().toInt() }.joinToString(".") + suffix
}

group = "sc.gui"
group = "software-challenge"
version = try {
Runtime.getRuntime().exec(arrayOf("git", "describe", "--tags"))
.inputStream.reader().readText().trim().ifEmpty { null }
Expand All @@ -44,7 +46,7 @@ version = try {
println("Current version: $version (Java version: ${JavaVersion.current()})")

application {
mainClassName = "sc.gui.GuiAppKt" // needs shadow-update which needs gradle update to 7.0
mainClass.set("sc.gui.GuiAppKt")
}

repositories {
Expand All @@ -55,34 +57,39 @@ repositories {
maven("https://jitpack.io")
}

// ./gradlew run -Pdebug for debug tools and logging
val debug = project.hasProperty("debug")

dependencies {
implementation(kotlin("stdlib-jdk8"))

implementation(kotlin("reflect"))


implementation(files("./gradle/tornadofx2-21e933fd41.jar"))
// implementation("no.tornado", "tornadofx", "2.0.0-SNAPSHOT") { exclude("org.jetbrains.kotlin", "kotlin-reflect") }
// implementation("com.github.software-challenge.tornadofx2", "tornadofx2", "2.0.0")
// implementation("com.github.edvin", "tornadofx2", "master-SNAPSHOT")
// implementation("com.github.edvin", "tornadofx2", "21e933fd41")
implementation(files("./gradle/tornadofx2-21e933fd41.jar"))

implementation("ch.qos.logback", "logback-classic", "1.5.18")
implementation("io.github.oshai", "kotlin-logging-jvm", "6.0.9") // TODO version 7 with kotlin 2
implementation("ch.qos.logback", "logback-classic", "1.5.32")
implementation("io.github.oshai", "kotlin-logging-jvm", "8.0.01")

implementation("software-challenge", "server")
implementation("software-challenge", "plugin2023")
implementation("software-challenge", "plugin2024")
implementation("software-challenge", "plugin2025")
implementation("software-challenge", "plugin")
implementation("software-challenge", "plugin2026")
implementation("software-challenge", "plugin2098")

if(debug)
if(debug) {
// hold Ctrl to view component hierarchy and bounds
implementation("com.tangorabox", "component-inspector-fx", "1.1.0")
}
}

tasks {
compileJava {
options.release.set(minJavaVersion.majorVersion.toInt())
options.release.set(targetJavaVersion.majorVersion.toInt())
}
processResources {
if(!debug)
Expand All @@ -92,28 +99,29 @@ tasks {
}
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = minJavaVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString()))
//freeCompilerArgs.addAll("-jvm-default=all")
}
}

withType<Jar> {
manifest.attributes["Main-Class"] = application.mainClassName
manifest.attributes["Main-Class"] = application.mainClass.get()
}

javafx {
version = "17.0.15"
val mods = mutableListOf(
"javafx.base", "javafx.controls", "javafx.fxml",
"javafx.web", "javafx.media", "javafx.swing"
) // included because of tornadofx already
)
// included because of tornadofx already
// if(debug) mods.addAll(listOf("javafx.swing"))
modules = mods
}

shadowJar {
destinationDirectory.set(buildDir)
destinationDirectory.set(layout.buildDirectory.asFile.get())
archiveClassifier.set(
"${
OperatingSystem.current().familyName.replace(
Expand All @@ -140,24 +148,25 @@ tasks {

run.configure {
dependsOn(backend.task(":server:makeRunnable"))
workingDir(buildDir.resolve("run"))
workingDir(layout.buildDirectory.asFile.get().resolve("run"))
doFirst {
workingDir.mkdirs()
}
args = System.getProperty("args", "").split(" ")
}

val release by creating {
val release by registering {
dependsOn(clean, check)
group = "distribution"
description = "Create and push a tagged commit matching the backend version"
doLast {
val desc = project.properties["m"]?.toString()
?: throw InvalidUserDataException("Das Argument -Pm=\"Beschreibung dieser Version\" wird benötigt")
exec { commandLine("git", "add", "CHANGELOG.md") }
exec { commandLine("git", "commit", "-m", "release: v$versionFromBackend") }
exec { commandLine("git", "tag", versionFromBackend, "-m", desc) }
exec { commandLine("git", "push", "--follow-tags", "--recurse-submodules=on-demand") }

providers.exec { commandLine("git", "add", "CHANGELOG.md") }
providers.exec { commandLine("git", "commit", "-m", "release: v$versionFromBackend") }
providers.exec { commandLine("git", "tag", versionFromBackend, "-m", desc) }
providers.exec { commandLine("git", "push", "--follow-tags", "--recurse-submodules=on-demand") }
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 1 addition & 15 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
rootProject.name = "software-challenge-gui"

includeBuild("backend/gradle/custom-tasks")
includeBuild("backend") {
// https://publicobject.com/2021/03/11/includebuild
dependencySubstitution {
substitute(module("software-challenge:plugin2024"))
.with(project(":plugin"))
substitute(module("software-challenge:plugin2025"))
.with(project(":plugin2025"))
substitute(module("software-challenge:plugin"))
.with(project(":plugin2026"))
substitute(module("software-challenge:server"))
.with(project(":server"))
}
}
includeBuild("backend")
33 changes: 31 additions & 2 deletions src/main/kotlin/sc/gui/AppStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import javafx.scene.text.FontWeight
import javafx.scene.text.TextAlignment
import sc.api.plugins.Team
import sc.gui.model.AppModel
import sc.plugin2098.util.Connect4Constants
import tornadofx.*

class AppStyle: Stylesheet() {
Expand All @@ -22,7 +23,7 @@ class AppStyle: Stylesheet() {

const val pieceOpacity = 1.0

val fontSizeUnscaled = Font.getDefault().also { logger.debug("System Font: $it") }.size.pt
val fontSizeUnscaled = Font.getDefault().also { logger.debug { "System Font: $it" } }.size.pt
val fontSizeRegular = fontSizeUnscaled * AppModel.scaling.value
val fontSizeSmall = fontSizeRegular * 0.6
val fontSizeBig = fontSizeRegular * 1.5
Expand Down Expand Up @@ -157,7 +158,35 @@ class AppStyle: Stylesheet() {
prefWidth = 100.percent
}

piranhasStyles()
connect4Styles()
}

fun connect4Styles() {
background {
opacity = 0.7
backgroundColor += c("#88DAF7")
backgroundImage += resources.url("/piranhas/water_b.png").toURI()
backgroundRepeat += BackgroundRepeat.REPEAT to BackgroundRepeat.REPEAT
}

(1..3).forEach { size ->
Team.entries.forEach { team ->
".${team}_${size}" {
image = resources.url("/piranhas/${team.color}_${(96 + size).toChar()}.png")
.toURI()
}
}
}

".one-chip" { image = resources.url("/connect4/chip-rot.png").toURI() }
".two-chip" { image = resources.url("/connect4/chip-gelb.png").toURI() }
".one-chip-winning" { image = resources.url("/connect4/chip-rot-winning.png").toURI() }
".two-chip-winning" { image = resources.url("/connect4/chip-gelb-winning.png").toURI() }
".cell" { image = resources.url("/connect4/cell-debug.png").toURI() }
".grid" {
backgroundImage += resources.url("/connect4/board.png").toURI()
backgroundSize += BackgroundSize(1.0, 1.0, true, true, false, false)
}
}

fun piranhasStyles() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/sc/gui/controller/ServerController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sc.gui.controller

import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.core.util.StatusPrinter
import ch.qos.logback.core.util.StatusPrinter2
import org.slf4j.LoggerFactory
import sc.server.Configuration
import sc.server.Lobby
Expand All @@ -13,7 +13,7 @@ class ServerController : Controller() {
fun startServer() {
// output logback diagnostics to see if a logback.xml config was found
val lc = LoggerFactory.getILoggerFactory() as LoggerContext
StatusPrinter.print(lc)
StatusPrinter2().print(lc)

Configuration.loadServerProperties()
Configuration.set(Configuration.SAVE_REPLAY, true)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/sc/gui/view/AppView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class AppView: View("Software-Challenge Germany") {
// TODO help menus keep disappearing and is offset
menu(graphic = sochaIcon) {
item("Beenden", "Shortcut+Q").action {
logger.debug("Quitting!")
logger.debug { "Quitting!" }
Platform.exit()
}
item("Neues Spiel", "Shortcut+N") {
enableWhen(controller.model.currentView.isNotEqualTo(ViewType.GAME_CREATION))
action {
logger.debug("New Game!")
logger.debug { "New Game!" }
if(controller.model.currentView.get() == ViewType.GAME) {
confirm(
header = "Neues Spiel anfangen",
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/sc/gui/view/ControlView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ControlView: View() {
}
}
val prev = button {
if(logger.isTraceEnabled)
if(logger.isTraceEnabled())
hoverProperty().listenImmediately {
logger.trace { "$this: $padding on hover $it" }
}
Expand Down Expand Up @@ -86,7 +86,7 @@ class ControlView: View() {
)
}
button {
if(logger.isTraceEnabled)
if(logger.isTraceEnabled())
hoverProperty().listenImmediately {
logger.trace { "$this: $padding on hover $it" }
}
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/sc/gui/view/PieceImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class PieceImage(private val sizeProperty: ObservableDoubleValue, val content: S
}

fun addChild(graphic: String, index: Int? = null) {
//logger.trace { "$this: Adding $graphic" }
children.add(index ?: children.size, ResizableImageView(sizeProperty).apply {
addClass(graphic)
if(graphic == "penguin")
Expand Down
Loading
Loading