Skip to content

Commit

Permalink
chore: include resources in jar
Browse files Browse the repository at this point in the history
Loads images as project resources instead
of loading them as files. This makes it possible
to include them in jar file. Doing so will solve
problem with absent images (previously
they weren't found in the runtime)
  • Loading branch information
TodorovicSrdjan committed Sep 18, 2022
1 parent 1d8a816 commit 14d7f91
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions src/main/scala/gui/Gui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class Gui(app: JFXApp3, engine: Engine, appName: String, numOfBlocks: Int = 4) {
private val LabelGridGap = 25
private val LabelMaxChars = 6
private val ChoiceGroupsOpacity = 0.35
private val ArrowsImagePath = "resources/images/arrows.png"
private val LogoImagePath = "resources/images/logo.png"
private val ArrowsImagePath = "/images/arrows.png"
private val LogoImagePath = "/images/logo.png"

private var BlockList: IndexedSeq[Node] = null
private var MainButton: Circle = null
Expand All @@ -82,7 +82,7 @@ class Gui(app: JFXApp3, engine: Engine, appName: String, numOfBlocks: Int = 4) {
alwaysOnTop = true
}
app.stage.centerOnScreen()
app.stage.icons += new Image(new File(LogoImagePath).toURI.toString)
app.stage.icons += new Image(classOf[Gui].getResourceAsStream(LogoImagePath)) //new Image(new File(LogoImagePath).toURI.toString)
}

private def createScene(): Scene = {
Expand Down Expand Up @@ -143,7 +143,7 @@ class Gui(app: JFXApp3, engine: Engine, appName: String, numOfBlocks: Int = 4) {
selectedChoicesGrid.setMouseTransparent(true)

// Create layer for direction indicators
ArrowsImage = Option(new ImageView(new Image(new File(ArrowsImagePath).toURI.toString)))
ArrowsImage = Option(new ImageView(new Image(classOf[Gui].getResourceAsStream(ArrowsImagePath))))
ArrowsImage.get.setMouseTransparent(true)
ArrowsImage.get.visible = false

Expand Down

0 comments on commit 14d7f91

Please sign in to comment.