Skip to content

Commit

Permalink
Changed Names
Browse files Browse the repository at this point in the history
  • Loading branch information
LSinzker committed Jun 8, 2017
1 parent 903b329 commit 452d34b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/main/scala/GoL/PopupError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import scalafx.scene.control.Alert.AlertType
/**
* Created by Avell 1513 on 08/06/2017.
*/

class PopupError (path: String) {

new Alert(AlertType.Error) {
Expand Down
8 changes: 1 addition & 7 deletions src/main/scala/GoL/PopupSearch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import scalafx.scene.control._
/**
* Created by Avell 1513 on 08/06/2017.
*/

class PopupSearch {

val dialog = new TextInputDialog(){
Expand All @@ -26,13 +27,6 @@ class PopupSearch {
try {
val fileContents = Source.fromFile(filePath).getLines.mkString
println(fileContents)
println(fileContents(0))
println(fileContents(0).asDigit)
println(fileContents(1))
println(fileContents(1).asDigit)
println(fileContents(2))
println(fileContents(2).asDigit)

GameEngine.rule = new NewSetup(fileContents(0).asDigit, fileContents(1).asDigit, fileContents(2).asDigit)
} catch {
case ex: Exception => {val ppError = new PopupError(filePath)}
Expand Down
25 changes: 11 additions & 14 deletions src/main/scala/GoL/PopupW.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import scalafx.scene.control.ButtonBar.ButtonData
import scalafx.scene.control._
import scalafx.scene.layout.GridPane


class PopupW {

case class Result(letslive: String, kills: String, revives: String)
Expand All @@ -17,44 +16,42 @@ class PopupW {
initOwner(View.stage)
title = "Your rule"
headerText = "Number of Neighbours to:"
contentText = "Stay Alive: "
contentText = "Revive: "
}

val finishButtonType = new ButtonType("Finish", ButtonData.OKDone)
dialog.dialogPane().getButtonTypes.addAll(finishButtonType, ButtonType.Cancel)

val toLive = new TextField(){promptText = "Stay Alive"}
val toDie = new TextField(){promptText = "Die"}
val minLive = new TextField(){promptText = "Minimum"}
val maxLive = new TextField(){promptText = "Maximum"}
val toRevive = new TextField(){promptText = "Revive"}

val grid = new GridPane() {
hgap = 10
vgap = 10
padding = Insets(30, 100, 10, 10)

add(new Label("Stay Alive:"), 0, 0)
add(toLive, 1, 0)
add(new Label("Die:"), 0, 1)
add(toDie, 1, 1)
add(new Label("Minimum to Stay Alive:"), 0, 0)
add(minLive, 1, 0)
add(new Label("Maximum to Stay Alive:"), 0, 1)
add(maxLive, 1, 1)
add(new Label("Revive:"), 0, 2)
add(toRevive, 1, 2)
}

dialog.dialogPane().setContent(grid)

Platform.runLater(toLive.requestFocus())
Platform.runLater(minLive.requestFocus())

dialog.resultConverter = dialogButton =>
if (dialogButton == finishButtonType) Result(toLive.text(), toDie.text(), toRevive.text())
if (dialogButton == finishButtonType) Result(minLive.text(), maxLive.text(), toRevive.text())
else null

val result = dialog.showAndWait()

result match {
case Some(Result(live, die, revive)) => {
println("Stay Alive: " + live + " Dies: " + die + " Revive: " + revive)
GameEngine.rule = new NewSetup(live.toInt, die.toInt, revive.toInt)
case Some(Result(min, max, revive)) => {
println("Minimum: " + min + " Maximum: " + max + " Revive: " + revive)
GameEngine.rule = new NewSetup(min.toInt, max.toInt, revive.toInt)
}
case _ => println("Cancel or closed")
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/Rules/rules.txt

This file was deleted.

0 comments on commit 452d34b

Please sign in to comment.