Main view class of the Sudoku application. More...
Public Member Functions | |
| MainView (ActiveMenuOrSubmenuViewModel activeMenuOrSubmenuViewModel, Coordinator coordinator, HelpViewModel helpViewModel, MenuHiddenViewModel menuHiddenViewModel, MenuMiniViewModel menuMiniViewModel, MenuLevelViewModel menuLevelViewModel, MenuMaxiViewModel menuMaxiViewModel, MenuPlayerViewModel menuPlayerViewModel, MenuSaveViewModel menuSaveViewModel, MenuSolveViewModel menuSolveViewModel, MenuOptionsViewModel menuOptionsViewModel, MenuNewViewModel menuNewViewModel, GridViewModel gridViewModel, AudioService audioService, FileChooserService fileChooserService, BindingConfigurator bindingConfigurator, GenericListViewFactory genericListViewFactory, ToasterService toasterService, LevelInteractionHandler levelInteractionHandler, SpinnerService spinnerService) | |
Constructs a new MainView with all required view-models, services, and navigation components. | |
| void | handleMenuBackupShow () |
| Activates the BACKUP menu, refreshes the backup list to ensure the displayed data is up-to-date, and sets focus on the save button to facilitate keyboard navigation and accessibility. | |
| void | handleMenuHelpShow () |
| Displays the Help menu dialog with game rules and the application log path. | |
| void | handleMenuMaxiShow (ActionEvent event) |
| Activates the MAXI menu and sets focus on the corresponding button based on the event source. | |
| void | handleMenuMiniShow () |
| Activates the MINI menu and starts a timer to auto-hide it after N seconds if it remains active and the "menuMiniButtonShow" button still has focus. | |
| void | handleMenuNewPlayer () |
| Make the name field editable in order to create a new player if that name doesn't exist. | |
| void | handleMenuNewShow () |
| Opens GitHub releases URL via the Coordinator. | |
| void | handleMenuOptionsShow () |
| Activates the OPTIONS menu and sets focus on the options button. | |
| void | handleMenuPlayerShow () |
| Activates the PLAYER menu, refreshes the player list to reflect potential localization changes, and sets focus on the player button to assist keyboard and accessibility navigation. | |
| void | handleMenuSolveShow () |
| Activates the SOLVE menu, focuses the solve button, and updates the selected level if a solved grid is available. | |
| void | handleMute () |
| Called when the mute button is pressed. | |
| void | handleRestoreGridAndMenuMaxiShow (ActionEvent event) |
| Restores the grid and shows the MAXI menu. | |
| void | handleRestoreGridAndMenuMiniShow () |
| Restores the grid and shows the MINI menu. | |
| void | handleSolveClearGrid () |
| Clear the grid in solve submenu. | |
| void | handleSongClear () |
| Clears the song, shows a toast, and refocuses the song button. | |
| void | handleToggleLanguage () |
| Switches language. | |
| void | openingMainStage (final ISplashScreenView iSplashScreenView) |
| Opens the main stage and handles the transition from splash screen to full menu. | |
Private Member Functions | |
| void | activeMenuManagerInitialization () |
| Initializes bindings between each menu pane's visibility and managed state and the corresponding value of the active menu from ActiveMenuOrSubmenuViewModel. | |
| void | applyOpaqueMode (boolean opaque) |
Applies opaque or transparent styling to the sudoku grid and its cells by setting the pseudo-class. | |
| void | bindLevel (DifficultyLevel level, PossibilityStarsHBox starsBox, Button maxi, Label label, Button mini) |
| Binds UI components related to a specific difficulty level in both the maxi and mini menus. | |
| void | bindLevelAccessibility (DifficultyLevel level, PossibilityStarsHBox starsBox, Button maxi, Button mini) |
| Binds accessibility properties (accessible text and role description) for the specified difficulty level's buttons. | |
| void | bindLevelLabelText (DifficultyLevel level, Label label) |
| Binds the label's text to the localized name of the specified difficulty level. | |
| void | bindLevelSelectedStyling (DifficultyLevel level, Button maxi, Button mini) |
| Binds the pseudo-class ":selected" state of the given buttons to the specified difficulty level. | |
| void | bindLevelStarsVisibility (DifficultyLevel level, PossibilityStarsHBox starsBox) |
| Binds the visibility of the stars box to whether the specified difficulty level is selected. | |
| void | bindLevelTooltipText (DifficultyLevel level, PossibilityStarsHBox starsBox, Button maxi, Button mini) |
| Binds the tooltip text properties of both buttons to the accessible text corresponding to the specified difficulty level to ensure consistency and improve user experience. | |
| void | bindVisibleAndManaged (Region menu, ActiveMenuOrSubmenuViewModel.ActiveMenu menuType) |
| void | clearStatusPseudoClasses () |
| Removes all validation-related pseudo-classes from the new player button. | |
| void | gridInitialization () |
| Initializes the 9x9 Sudoku grid UI and loads the current grid values from the model if they exist. | |
| void | handleFileImageChooser () |
| Opens a file chooser for a background image and passes the selected file to the ViewModel for asynchronous loading. | |
| void | handleFileSongChooser () |
| Opens a file chooser for a song and passes the selected file to the ViewModel for saving the path. | |
| void | handleGridOpacity () |
| Handles grid transparency toggle button action. | |
| void | handleLevelAction (InputEvent event) |
Dispatches level-related interaction events to the LevelInteractionHandler. | |
| void | hiddenMenuInitialization () |
| Initializes the hidden menu by binding its show button's accessible text and tooltip to the ViewModel. | |
| Timeline | hideMiniMenuTimelineInitialization () |
Initializes a Timeline that hides the MINI menu after milliseconds if it is still active and the "menuMiniButtonShow" button retains focus. | |
| void | initialize () |
| Initializes the main view. | |
| void | levelsMenuInitialization () |
| Initializes each difficulty level section in the menu by binding UI components to ViewModel properties for EASY, MEDIUM, and DIFFICULT levels. | |
| void | maxiMenuInitialization () |
| Initializes the maxi menu components by binding their labels, accessible texts, and tooltips to the corresponding properties in the ViewModel. | |
| void | miniMenuInitialization () |
| Initializes the mini menu by binding all buttons' texts and tooltips to their respective ViewModel properties. | |
| void | newMenuInitialization () |
| Binds "New" menu UI elements to the ViewModel for text, accessibility, visibility, and tooltips, and shows toast notifications on status message updates. | |
| void | openingConfigureStage () |
| Configures the primary stage for the full menu view. | |
| void | openingFadeIn (final Node node) |
| Applies a fade-in effect to the given node. | |
| void | openingMaximizePrimaryStage () |
| Maximizes the primary stage to fill the primary screen. | |
| void | openingShowStage () |
| Shows the primary stage. | |
| void | optionsMenuInitialization () |
Initializes and binds all UI components of the options menu to the MenuOptionsViewModel. | |
| void | playerMenuInitialization () |
| Initializes all player menu components by configuring JavaFX property bindings, event handlers, and input lifecycle listeners. | |
| void | restoreCurrentGridLevelFromModel () |
| Synchronizes the menu UI with the current game model state. | |
| void | saveMenuInitialization () |
| Initializes bindings and event listeners for the save menu components. | |
| void | solveMenuInitialization () |
| Sets up bindings between the solve menu UI components and menuSolveViewModel. | |
| void | spinnerInitialization () |
| Establishes a unidirectional binding between the SpinnerGridPane visibility and the SpinnerViewModel loading state. | |
| void | stopAudioOnExitInitialization () |
| Registers a listener on the primary stage to stop all audio when the application window is closed. | |
| void | synchronizeUIAfterPlayerSwitch () |
| Synchronizes the user interface with the current player's profile data. | |
| void | toasterInitialization () |
| Initializes the toaster by subscribing to the ToasterService. | |
| void | updatePlayerNamePseudoClasses (PlayerNameStatus status) |
| Updates the CSS pseudo-classes of the new player button based on the provided validation status. | |
Static Private Attributes | |
| static final int | AUTO_HIDE_MINI_MENU_DELAY_MS = 5_000 |
| static final PseudoClass | DIFFICULTY_LEVEL_PSEUDO_SELECTED |
| static final double | FADE_IN_IN_SECONDS_AFTER_SPLASHSCREEN = 0.3 |
| static final Set< KeyCode > | LEVEL_VALID_KEYS = Set.of(KeyCode.ENTER, KeyCode.SPACE) |
| static final Logger | LOG = LoggerFactory.getLogger(MainView.class) |
| static final int | MAX_STARS_PERCENTAGE = 100 |
| static final PseudoClass | NAME_PSEUDO_FOCUSED |
| static final PseudoClass | NAME_PSEUDO_INVALID |
| static final PseudoClass | NAME_PSEUDO_UNAVAILABLE |
| static final PseudoClass | NAME_PSEUDO_VALID = PseudoClass.getPseudoClass("name-valid") |
| static final PseudoClass | OPAQUE_MODE_PSEUDO_SELECTED |
| static final PseudoClass | REDUCED_SONG_PSEUDO_SELECTED |
Main view class of the Sudoku application.
This class is responsible for displaying and managing the UI.
| fr.softsf.sudokufx.view.main.MainView.MainView | ( | ActiveMenuOrSubmenuViewModel | activeMenuOrSubmenuViewModel, |
| Coordinator | coordinator, | ||
| HelpViewModel | helpViewModel, | ||
| MenuHiddenViewModel | menuHiddenViewModel, | ||
| MenuMiniViewModel | menuMiniViewModel, | ||
| MenuLevelViewModel | menuLevelViewModel, | ||
| MenuMaxiViewModel | menuMaxiViewModel, | ||
| MenuPlayerViewModel | menuPlayerViewModel, | ||
| MenuSaveViewModel | menuSaveViewModel, | ||
| MenuSolveViewModel | menuSolveViewModel, | ||
| MenuOptionsViewModel | menuOptionsViewModel, | ||
| MenuNewViewModel | menuNewViewModel, | ||
| GridViewModel | gridViewModel, | ||
| AudioService | audioService, | ||
| FileChooserService | fileChooserService, | ||
| BindingConfigurator | bindingConfigurator, | ||
| GenericListViewFactory | genericListViewFactory, | ||
| ToasterService | toasterService, | ||
| LevelInteractionHandler | levelInteractionHandler, | ||
| SpinnerService | spinnerService ) |
Constructs a new MainView with all required view-models, services, and navigation components.
Initializes the central hub for the application UI, ensuring all dependencies are injected for proper view binding and event orchestration.
| activeMenuOrSubmenuViewModel | the view-model for active menu state management |
| coordinator | the navigation coordinator for the application |
| helpViewModel | the view-model for help content |
| menuHiddenViewModel | the view-model for the hidden menu state |
| menuMiniViewModel | the view-model for the mini menu state |
| menuLevelViewModel | the view-model for level selection |
| menuMaxiViewModel | the view-model for the expanded menu state |
| menuPlayerViewModel | the view-model for player management |
| menuSaveViewModel | the view-model for saved game management |
| menuSolveViewModel | the view-model for solver functionality |
| menuOptionsViewModel | the view-model for application settings |
| menuNewViewModel | the view-model for new game creation |
| gridViewModel | the view-model for the Sudoku grid state |
| audioService | the service for audio playback management |
| fileChooserService | the service for file selection dialogs |
| bindingConfigurator | the utility for configuring UI bindings |
| genericListViewFactory | the factory for creating specialized list views |
| toasterService | the service for displaying UI notifications |
| levelInteractionHandler | the handler for level interaction events |
| spinnerService | the service for managing loading spinners |
|
private |
Initializes bindings between each menu pane's visibility and managed state and the corresponding value of the active menu from ActiveMenuOrSubmenuViewModel.
Ensures that only the currently active menu is visible and participates in layout calculations.
|
private |
Applies opaque or transparent styling to the sudoku grid and its cells by setting the pseudo-class.
OPAQUE_MODE_PSEUDO_SELECTED
| opaque | true for opaque styling, false for transparent |
|
private |
Binds UI components related to a specific difficulty level in both the maxi and mini menus.
This method sets up the following behaviors:
| level | the difficulty level to bind |
| starsBox | the UI component displaying possibility stars for this level |
| maxi | the button in the maxi menu for this level |
| label | the label showing the difficulty level name in the maxi menu |
| mini | the button in the mini menu for this level |
|
private |
Binds accessibility properties (accessible text and role description) for the specified difficulty level's buttons.
| level | the difficulty level whose accessibility properties are bound |
| starsBox | the stars box used for calculating accessible text |
| maxi | the button in the maxi menu |
| mini | the button in the mini menu |
|
private |
Binds the label's text to the localized name of the specified difficulty level.
| level | the difficulty level whose label text to bind |
| label | the label to bind |
|
private |
Binds the pseudo-class ":selected" state of the given buttons to the specified difficulty level.
Updates styling immediately and whenever the selected level changes.
| level | the difficulty level to track |
| maxi | the button in the maxi menu |
| mini | the button in the mini menu |
|
private |
Binds the visibility of the stars box to whether the specified difficulty level is selected.
| level | the difficulty level whose selection state controls visibility |
| starsBox | the stars box to show or hide |
|
private |
Binds the tooltip text properties of both buttons to the accessible text corresponding to the specified difficulty level to ensure consistency and improve user experience.
| level | the difficulty level whose tooltip text is bound |
| starsBox | the stars UI component used to compute accessible text |
| maxi | the button in the maxi menu |
| mini | the button in the mini menu |
|
private |
|
private |
Removes all validation-related pseudo-classes from the new player button.
Resets the visual state of the button to its default appearance by clearing the valid, invalid, and unavailable status indicators.
|
private |
Initializes the 9x9 Sudoku grid UI and loads the current grid values from the model if they exist.
|
private |
Opens a file chooser for a background image and passes the selected file to the ViewModel for asynchronous loading.
|
private |
Opens a file chooser for a song and passes the selected file to the ViewModel for saving the path.
|
private |
Handles grid transparency toggle button action.
|
private |
Dispatches level-related interaction events to the LevelInteractionHandler.
Acts as a central router for UI events, mapping physical interactions to business logic in the handler while maintaining visual encapsulation via the opacity callback.
| event | the mouse or keyboard event captured from the UI |
| void fr.softsf.sudokufx.view.main.MainView.handleMenuBackupShow | ( | ) |
Activates the BACKUP menu, refreshes the backup list to ensure the displayed data is up-to-date, and sets focus on the save button to facilitate keyboard navigation and accessibility.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuHelpShow | ( | ) |
Displays the Help menu dialog with game rules and the application log path.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuMaxiShow | ( | ActionEvent | event | ) |
Activates the MAXI menu and sets focus on the corresponding button based on the event source.
Stops the MINI menu auto-hide timer if running.
| event | the event triggered by a submenu button click |
| void fr.softsf.sudokufx.view.main.MainView.handleMenuMiniShow | ( | ) |
Activates the MINI menu and starts a timer to auto-hide it after N seconds if it remains active and the "menuMiniButtonShow" button still has focus.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuNewPlayer | ( | ) |
Make the name field editable in order to create a new player if that name doesn't exist.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuNewShow | ( | ) |
Opens GitHub releases URL via the Coordinator.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuOptionsShow | ( | ) |
Activates the OPTIONS menu and sets focus on the options button.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuPlayerShow | ( | ) |
Activates the PLAYER menu, refreshes the player list to reflect potential localization changes, and sets focus on the player button to assist keyboard and accessibility navigation.
| void fr.softsf.sudokufx.view.main.MainView.handleMenuSolveShow | ( | ) |
Activates the SOLVE menu, focuses the solve button, and updates the selected level if a solved grid is available.
| void fr.softsf.sudokufx.view.main.MainView.handleMute | ( | ) |
Called when the mute button is pressed.
Toggles the audio mute state via the ViewModel.
| void fr.softsf.sudokufx.view.main.MainView.handleRestoreGridAndMenuMaxiShow | ( | ActionEvent | event | ) |
Restores the grid and shows the MAXI menu.
| void fr.softsf.sudokufx.view.main.MainView.handleRestoreGridAndMenuMiniShow | ( | ) |
Restores the grid and shows the MINI menu.
| void fr.softsf.sudokufx.view.main.MainView.handleSolveClearGrid | ( | ) |
Clear the grid in solve submenu.
| void fr.softsf.sudokufx.view.main.MainView.handleSongClear | ( | ) |
Clears the song, shows a toast, and refocuses the song button.
| void fr.softsf.sudokufx.view.main.MainView.handleToggleLanguage | ( | ) |
Switches language.
|
private |
Initializes the hidden menu by binding its show button's accessible text and tooltip to the ViewModel.
|
private |
Initializes a Timeline that hides the MINI menu after milliseconds if it is still active and the "menuMiniButtonShow" button retains focus.
AUTO_HIDE_MINI_MENU_DELAY_MS
Timeline responsible for automatically hiding the MINI menu
|
private |
Initializes the main view.
This method is automatically called by JavaFX after loading the FXML. It performs the following actions:
|
private |
Initializes each difficulty level section in the menu by binding UI components to ViewModel properties for EASY, MEDIUM, and DIFFICULT levels.
|
private |
Initializes the maxi menu components by binding their labels, accessible texts, and tooltips to the corresponding properties in the ViewModel.
|
private |
Initializes the mini menu by binding all buttons' texts and tooltips to their respective ViewModel properties.
|
private |
Binds "New" menu UI elements to the ViewModel for text, accessibility, visibility, and tooltips, and shows toast notifications on status message updates.
|
private |
Configures the primary stage for the full menu view.
|
private |
Applies a fade-in effect to the given node.
| node | The node to apply the fade-in effect to |
| void fr.softsf.sudokufx.view.main.MainView.openingMainStage | ( | final ISplashScreenView | iSplashScreenView | ) |
Opens the main stage and handles the transition from splash screen to full menu.
| iSplashScreenView | The splash screen view interface |
Implements fr.softsf.sudokufx.common.interfaces.IMainView.
|
private |
Maximizes the primary stage to fill the primary screen.
|
private |
Shows the primary stage.
|
private |
Initializes and binds all UI components of the options menu to the MenuOptionsViewModel.
This method performs the following tasks:
|
private |
Initializes all player menu components by configuring JavaFX property bindings, event handlers, and input lifecycle listeners.
This method sets up the following structural behaviors:
|
private |
Synchronizes the menu UI with the current game model state.
Resets the grid view and level selection, then retrieves the active grid from the model to update the UI with the corresponding level and completion percentage. Finally, synchronizes the grid opacity mode to ensure visual consistency.
|
private |
Initializes bindings and event listeners for the save menu components.
Binds accessibility texts, tooltips, and labels to the ViewModel. Synchronizes the selected backup between the ListView and the ViewModel. Sets up the ListView with custom backup cells and refreshes UI state.
|
private |
Sets up bindings between the solve menu UI components and menuSolveViewModel.
Binds accessibility texts, tooltips, role descriptions, and labels, and synchronizes stars percentage from menuLevelViewModel to menuSolveViewModel (bindBidirectional).
|
private |
Establishes a unidirectional binding between the SpinnerGridPane visibility and the SpinnerViewModel loading state.
|
private |
Registers a listener on the primary stage to stop all audio when the application window is closed.
|
private |
Synchronizes the user interface with the current player's profile data.
Updates the application locale, restores the grid level state, applies specific player options (such as background and colors), and adjusts the grid opacity mode based on the new player's configuration.
|
private |
Initializes the toaster by subscribing to the ToasterService.
When a new fr.softsf.sudokufx.dto.ToastData is published via ToasterService#toastRequestProperty(), this method adds the toast to the ToasterVBox. It also listens to ToasterService#removeToastRequestProperty() to remove the currently displayed toast when requested.
|
private |
Updates the CSS pseudo-classes of the new player button based on the provided validation status.
Clears existing status pseudo-classes before applying the one corresponding to the given PlayerNameStatus.
| status | the current validation status to reflect in the UI; if null, no state is applied |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |