From 1806ffcb6af2e4ecd1e40dc8f3b04e5533599bbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5vard=20Daleng?=
 <142524365+MrMarHVD@users.noreply.github.com>
Date: Fri, 17 May 2024 11:27:47 +0200
Subject: [PATCH] Made working solution for description combo box. Still need
 to add different descriptions and potentially replace the radio button system
 entirely.

---
 .../stud/chaosgame/controller/game/GuiButtonController.java | 6 +++---
 .../java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java     | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java
index ca8b5e0..6c43421 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java
@@ -175,7 +175,7 @@ public class GuiButtonController {
   /**
    * Clear the image view.
    */
-  public void clearImageView() {
+  public void clearCanvas() {
     chaosCanvas.clearCanvas();
     GraphicsContext gc = gui.getCanvas().getGraphicsContext2D();
     gc.clearRect(0, 0, gui.getCanvas().getWidth(), gui.getCanvas().getHeight());
@@ -197,7 +197,7 @@ public class GuiButtonController {
     gui.getStartButton().setOnAction(event -> startGame());
     gui.getStopButton().setOnAction(event -> stopGame());
 
-    gui.getClearButton().setOnAction(event -> clearImageView());
+    gui.getClearButton().setOnAction(event -> clearCanvas());
 
     gui.getQuitButton().setOnAction(event -> quitGame());
     gui.getColorCheckBox().setOnAction(event -> game.setUseColor(gui.getColorCheckBox().isSelected()));
@@ -219,7 +219,7 @@ public class GuiButtonController {
     chaosCanvas.clearCanvas();
     gui.getCanvas().getGraphicsContext2D().clearRect(0, 0, gui.getCanvas().getGraphicsContext2D().
             getCanvas().getWidth(), gui.getCanvas().getGraphicsContext2D().getCanvas().getHeight());
-    clearImageView();
+    clearCanvas();
     chaosCanvas.clearCanvas();
 
     // Get the new description and create a new ChaosCanvas
diff --git a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
index c6f3aba..9ec860a 100644
--- a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
+++ b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
@@ -339,6 +339,7 @@ public class ChaosGameGui implements ChaosGameObserver {
     descriptionComboBox.getSelectionModel().selectedItemProperty()
         .addListener((observable, oldValue, newValue) -> {
       for (int i = 0; i < factory.getDescriptions().size(); i++) {
+        ChaosGameDescription description = factory.getDescriptions().get(i);
         if (description.getName().equals(newValue)) {
           controller.updateDescription(i);
           break;
-- 
GitLab