-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResults.scala
63 lines (55 loc) · 1.63 KB
/
Results.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import FxApp._
import Projeto.BoardState
import javafx.fxml.{FXML, FXMLLoader}
import javafx.scene.{Parent, Scene}
import javafx.scene.control.Label
import javafx.scene.layout.AnchorPane
import javafx.stage.Stage
class Results {
var mainMenu : Stage = _
var result : String = _
@FXML private var title: Label = _
@FXML private var anchor: AnchorPane = _
def setMainMenu(stage: Stage): Unit = {
mainMenu = stage
}
def setResult(res: String): Unit = {
result = res
title.setText(res)
}
def menuClicked(): Unit = {
menu.clearFocus()
mainMenu.show()
boardState = BoardState.defineBoard(5)
history = List.empty[BoardState]
moves = List.empty[(Int, Int)]
anchor.getScene.getWindow.asInstanceOf[Stage].close()
}
def playClicked(): Unit = {
boardState = BoardState.defineBoard(5)
history = List.empty[BoardState]
moves = List.empty[(Int, Int)]
playing = starting
var secondaryStage = new Stage();
secondaryStage.setTitle("HexGame")
val fxmlLoader = new FXMLLoader(getClass.getResource("Game.fxml"))
val mainViewRoot: Parent = fxmlLoader.load()
val controller: Game = fxmlLoader.getController
controller.setMainMenu(mainMenu)
val scene = new Scene(mainViewRoot)
secondaryStage.setScene(scene)
secondaryStage.setResizable(false)
secondaryStage.show()
controller.clearFocus()
if (gameType != 1 && !playing) {
playing = true
controller.checkHist = true
controller.playCPU()
}
controller.setColors()
title.getScene.getWindow.asInstanceOf[Stage].close()
}
def clearFocus(): Unit = {
anchor.requestFocus()
}
}