Package com.csse3200.game.services
Class DialogService
java.lang.Object
com.csse3200.game.services.DialogService
Service for managing dialog components throughout the game. Provides convenient methods for
creating and displaying different types of dialogs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum for the different types of dialogs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionachievement
(String name, String description, int skillPoints, String tier) Creates and shows an achievement dialog.Creates and shows an error dialog.error
(String title, String message, Consumer<DialogComponent> onClose) Creates and shows an error dialog with a close callback.int
Gets the number of currently active dialogs.Gets a copy of the list of active dialogs.boolean
Checks if there are any active dialogs.void
Hides all active dialogs.Creates and shows an info dialog.info
(String title, String message, Consumer<DialogComponent> onClose) Creates and shows an info dialog with a close callback.void
resize()
Handles window resize by re-centering all active dialogs.Creates and shows a skill dialog.skill
(String title, String message, Consumer<DialogComponent> onUnlock, Consumer<DialogComponent> onClose) Creates and shows a skill dialog with callbacks.Creates and shows a warning dialog.warning
(String title, String message, Consumer<DialogComponent> onConfirm, Consumer<DialogComponent> onCancel) Creates and shows a warning dialog with callbacks.
-
Constructor Details
-
DialogService
public DialogService()Creates a new dialog service.
-
-
Method Details
-
info
Creates and shows an info dialog.- Parameters:
title
- the dialog titlemessage
- the dialog message- Returns:
- the created dialog component
-
info
Creates and shows an info dialog with a close callback.- Parameters:
title
- the dialog titlemessage
- the dialog messageonClose
- callback when dialog is closed- Returns:
- the created dialog component
-
warning
Creates and shows a warning dialog.- Parameters:
title
- the dialog titlemessage
- the dialog message- Returns:
- the created dialog component
-
warning
public DialogComponent warning(String title, String message, Consumer<DialogComponent> onConfirm, Consumer<DialogComponent> onCancel) Creates and shows a warning dialog with callbacks.- Parameters:
title
- the dialog titlemessage
- the dialog messageonConfirm
- callback when user confirms/continuesonCancel
- callback when user cancels- Returns:
- the created dialog component
-
error
Creates and shows an error dialog.- Parameters:
title
- the dialog titlemessage
- the dialog message- Returns:
- the created dialog component
-
error
Creates and shows an error dialog with a close callback.- Parameters:
title
- the dialog titlemessage
- the dialog messageonClose
- callback when dialog is closed- Returns:
- the created dialog component
-
skill
Creates and shows a skill dialog.- Parameters:
title
- the dialog titlemessage
- the dialog message- Returns:
- the created dialog component
-
skill
public DialogComponent skill(String title, String message, Consumer<DialogComponent> onUnlock, Consumer<DialogComponent> onClose) Creates and shows a skill dialog with callbacks.- Parameters:
title
- the dialog titlemessage
- the dialog messageonUnlock
- callback when user unlocks the skillonClose
- callback when user closes the dialog- Returns:
- the created dialog component
-
hideAllDialogs
public void hideAllDialogs()Hides all active dialogs. -
getActiveDialogCount
public int getActiveDialogCount()Gets the number of currently active dialogs.- Returns:
- the number of active dialogs
-
hasActiveDialogs
public boolean hasActiveDialogs()Checks if there are any active dialogs.- Returns:
- true if there are active dialogs, false otherwise
-
getActiveDialogs
Gets a copy of the list of active dialogs.- Returns:
- list of active dialog components
-
resize
public void resize()Handles window resize by re-centering all active dialogs. -
achievement
public AchievementDialogComponent achievement(String name, String description, int skillPoints, String tier) Creates and shows an achievement dialog.- Parameters:
name
- the name of the achievementdescription
- the description of the achievementskillPoints
- the skill points of the achievementtier
- the tier of the achievement- Returns:
- the created achievement dialog component
-