30 lines
746 B
Scala
30 lines
746 B
Scala
package fmon.battle
|
|
|
|
import javafx.fxml.FXML
|
|
import javafx.scene.{control => jfxsc}
|
|
|
|
import scalafx.Includes._
|
|
import scalafx.scene.control._
|
|
|
|
import fmon.stat.Monster
|
|
import fmon.stat._
|
|
|
|
class InfoWidget extends javafx.scene.layout.GridPane {
|
|
@FXML var name: jfxsc.Label = _
|
|
@FXML var status: jfxsc.Label = _
|
|
@FXML var health: jfxsc.Label = _
|
|
@FXML var healthBar: jfxsc.ProgressBar = _
|
|
|
|
def update(mon: Monster): Unit = {
|
|
name.text = mon.name
|
|
mon.status match {
|
|
case Some(s) => status.text = s.name
|
|
case None => status.text = s"Lv. ${mon.level}"
|
|
}
|
|
|
|
health.text = s"${mon.hp}/${mon.maxhp}"
|
|
val percent = mon.hp \\ mon.maxhp
|
|
healthBar.progress = percent.toDouble
|
|
// TODO : Change bar color
|
|
}
|
|
} |