Feat: Game UI optimization #342
+3
-5
@@ -185,6 +185,7 @@ public class CasinoGameController {
|
|||||||
private static final int NO_BET = 0;
|
private static final int NO_BET = 0;
|
||||||
private boolean myDealerIconSizeBound;
|
private boolean myDealerIconSizeBound;
|
||||||
private java.util.List<String> lobbyPlayerNames = java.util.List.of();
|
private java.util.List<String> lobbyPlayerNames = java.util.List.of();
|
||||||
|
private static final int MAX_ANIMATED_CHIPS = 12;
|
||||||
|
|
||||||
/** Standard constructor. Used by FXML. */
|
/** Standard constructor. Used by FXML. */
|
||||||
public CasinoGameController() {
|
public CasinoGameController() {
|
||||||
@@ -1919,7 +1920,7 @@ public class CasinoGameController {
|
|||||||
bottomRow.getChildren().add(chip);
|
bottomRow.getChildren().add(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 12) {
|
if (index < MAX_ANIMATED_CHIPS) {
|
||||||
animateChipAppear(chip, index);
|
animateChipAppear(chip, index);
|
||||||
} else {
|
} else {
|
||||||
chip.setOpacity(CHIP_FADE_TO);
|
chip.setOpacity(CHIP_FADE_TO);
|
||||||
@@ -2017,10 +2018,7 @@ public class CasinoGameController {
|
|||||||
*/
|
*/
|
||||||
private void bindChipSize(ImageView view, javafx.scene.Scene scene) {
|
private void bindChipSize(ImageView view, javafx.scene.Scene scene) {
|
||||||
|
|
||||||
view.fitHeightProperty()
|
view.fitHeightProperty().bind(scene.heightProperty().multiply(CHIP_HEIGHT_RATIO));
|
||||||
.bind(
|
|
||||||
scene.heightProperty().multiply(CHIP_HEIGHT_RATIO)
|
|
||||||
);
|
|
||||||
|
|
||||||
view.fitWidthProperty().bind(scene.widthProperty().multiply(CHIP_WIDTH_RATIO));
|
view.fitWidthProperty().bind(scene.widthProperty().multiply(CHIP_WIDTH_RATIO));
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-14
@@ -11,7 +11,6 @@ import ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui.Casinomainui;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
@@ -92,6 +91,7 @@ public class TaskbarController {
|
|||||||
private int lastPotSnapshot = 0;
|
private int lastPotSnapshot = 0;
|
||||||
private int lastObservedIncrease = 0;
|
private int lastObservedIncrease = 0;
|
||||||
private int lastRaiseIncrement = 0;
|
private int lastRaiseIncrement = 0;
|
||||||
|
private static final long REFRESH_DELAY_MS = 500;
|
||||||
|
|
||||||
/** Standard constructor. Used by FXML. */
|
/** Standard constructor. Used by FXML. */
|
||||||
public TaskbarController() {
|
public TaskbarController() {
|
||||||
@@ -1030,19 +1030,18 @@ public class TaskbarController {
|
|||||||
|
|
||||||
taskbarInput.clear();
|
taskbarInput.clear();
|
||||||
|
|
||||||
javafx.application.Platform.runLater(() -> {
|
javafx.application.Platform.runLater(
|
||||||
try {
|
() -> {
|
||||||
Thread.sleep(500);
|
try {
|
||||||
} catch (InterruptedException e) {
|
Thread.sleep(REFRESH_DELAY_MS);
|
||||||
Thread.currentThread().interrupt();
|
} catch (InterruptedException e) {
|
||||||
}
|
Thread.currentThread().interrupt();
|
||||||
refreshGame();
|
}
|
||||||
});
|
refreshGame();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Disables all action buttons to prevent multiple concurrent action submissions. */
|
||||||
* Disables all action buttons to prevent multiple concurrent action submissions.
|
|
||||||
*/
|
|
||||||
private void disableAllActionButtons() {
|
private void disableAllActionButtons() {
|
||||||
if (betButton != null) {
|
if (betButton != null) {
|
||||||
betButton.setDisable(true);
|
betButton.setDisable(true);
|
||||||
@@ -1428,14 +1427,14 @@ public class TaskbarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (var iconStream = TaskbarController.class.getResourceAsStream(LOGO_PATH);
|
try (var iconStream = TaskbarController.class.getResourceAsStream(LOGO_PATH);
|
||||||
var mainLogoStream = TaskbarController.class.getResourceAsStream(LOGO_PATH_MAIN)) {
|
var mainLogoStream = TaskbarController.class.getResourceAsStream(LOGO_PATH_MAIN)) {
|
||||||
if (iconStream != null) {
|
if (iconStream != null) {
|
||||||
Image icon = new Image(iconStream);
|
Image icon = new Image(iconStream);
|
||||||
if (!icon.isError()
|
if (!icon.isError()
|
||||||
&& alert.getDialogPane() != null
|
&& alert.getDialogPane() != null
|
||||||
&& alert.getDialogPane().getScene() != null
|
&& alert.getDialogPane().getScene() != null
|
||||||
&& alert.getDialogPane().getScene().getWindow()
|
&& alert.getDialogPane().getScene().getWindow()
|
||||||
instanceof javafx.stage.Stage stage) {
|
instanceof javafx.stage.Stage stage) {
|
||||||
stage.getIcons().add(icon);
|
stage.getIcons().add(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user