SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel Class Reference

ViewModel managing menu options UI state and accessibility strings. More...

+ Collaboration diagram for fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel:

Public Member Functions

 MenuOptionsViewModel (AudioService audioService, AsyncFileProcessorService asyncFileProcessorService, PlayerStateHolder playerStateHolder, OptionsService optionsService, ToasterService toasterService)
 
void applyAndPersistBackgroundImage (File selectedFile, SpinnerGridPane spinner, GridPane sudokuFX)
 Applies a background image to the specified GridPane and persists its path in the current player's options.
 
void applyAndPersistOptionsColor (GridPane sudokuFX, Color color)
 Applies the given color as the background of the specified GridPane and persists it in the current player's options if it has changed.
 
BooleanProperty gridOpacityProperty ()
 
void init (GridPane sudokuFX, ColorPicker menuOptionsButtonColor, SpinnerGridPane spinner)
 Initializes the menu options UI state for the current player, including:
 
StringBinding optionsAccessibleTextProperty ()
 
StringBinding optionsClearSongAccessibleTextProperty ()
 
StringBinding optionsClearSongRoleDescriptionProperty ()
 
StringBinding optionsClearSongTooltipProperty ()
 
StringBinding optionsColorAccessibleTextProperty ()
 
StringBinding optionsColorRoleDescriptionProperty ()
 
StringBinding optionsColorTooltipProperty ()
 
StringBinding optionsImageAccessibleTextProperty ()
 
StringBinding optionsImageRoleDescriptionProperty ()
 
StringBinding optionsImageTextProperty ()
 
StringBinding optionsImageTooltipProperty ()
 
StringBinding optionsMenuMaxiAccessibleTextProperty ()
 
StringBinding optionsMenuMaxiRoleDescriptionProperty ()
 
StringBinding optionsMenuMaxiTextProperty ()
 
StringBinding optionsMenuMaxiTooltipProperty ()
 
StringBinding optionsMuteAccessibleTextProperty ()
 
StringBinding optionsMuteIconProperty ()
 
StringBinding optionsMuteRoleDescriptionProperty ()
 
StringBinding optionsMuteTextProperty ()
 
StringBinding optionsMuteTooltipProperty ()
 
StringBinding optionsOpacityAccessibleTextProperty ()
 
StringBinding optionsOpacityIconProperty ()
 
StringBinding optionsOpacityRoleDescriptionProperty ()
 
StringBinding optionsOpacityTextProperty ()
 
StringBinding optionsOpacityTooltipProperty ()
 
StringBinding optionsReduceAccessibleTextProperty ()
 
StringBinding optionsReduceTextProperty ()
 
StringBinding optionsReduceTooltipProperty ()
 
StringBinding optionsRoleDescriptionProperty ()
 
StringBinding optionsSongAccessibleTextProperty ()
 
StringBinding optionsSongRoleDescriptionProperty ()
 
StringBinding optionsSongTextProperty ()
 
StringBinding optionsSongTooltipProperty ()
 
StringBinding optionsTextProperty ()
 
StringBinding optionsTooltipProperty ()
 
void resetSongPath ()
 Resets the song path by clearing the current selection, persisting the change, and showing a toast notification.
 
void saveSong (File file)
 Saves the provided song file path to the database and shows a confirmation toast.
 
BooleanProperty songIsBlankProperty ()
 
boolean toggleGridOpacityAndPersist ()
 Toggles the grid opacity mode, persists the new state in the database, updates
gridOpacityProperty
, and returns the actual updated value.
 
void toggleMuteAndPersist ()
 Toggles the audio mute state, persists the new value in OptionsDto, updates the AudioService, and reflects the change in muteProperty.
 

Static Public Attributes

static final int HEXCOLOR_BEGIN_INDEX = 2
 
static final int HEXCOLOR_END_INDEX = 10
 
static final String SUDOKU_FX_MUST_NOT_BE_NULL = "sudokuFX must not be null"
 

Private Member Functions

void checkInitialized ()
 Checks whether the MenuOptionsViewModel has been initialized via init(GridPane, ColorPicker, SpinnerGridPane).
 
Observable[] concatDependencies (Observable... dependencies)
 Utility: always observe the locale in addition to custom dependencies.
 
StringBinding createFormattedAndConcatenatedBinding (Supplier< String > keySupplier, Supplier< String > argSupplier, String suffixKey, Observable... dependencies)
 Creates a localized binding combining a formatted message and a suffix.
 
StringBinding createFormattedBinding (String key, String suffixKey)
 Creates a StringBinding that returns the concatenation of two localized strings (main key and suffix key), updating automatically when the locale changes.
 
StringBinding createFormattedBinding (Supplier< String > keySupplier, Supplier< String > argSupplier, Observable... dependencies)
 Creates a formatted localized binding with one dynamic argument.
 
StringBinding createStringBinding (String key)
 Creates a StringBinding that returns the localized string for the given key, updating automatically when the locale changes.
 
String gridOpacityText (boolean isOpaque)
 Returns the localized text corresponding to the grid opacity state.
 
StringBinding initMuteAccessibleText ()
 Creates the accessibility label for the mute button, based on the current mute state.
 
StringBinding initMuteIcon ()
 Creates the icon name for the mute button, depending on whether mute is active or not.
 
StringBinding initMuteText ()
 Creates the visible label for the mute button, reflecting the current mute state.
 
StringBinding initMuteTooltip ()
 Creates the tooltip for the mute button, combining dynamic mute info and submenu role.
 
StringBinding initOpacityAccessibleText ()
 Creates the accessibility label for the opacity button, based on the inverse of the current grid opacity state.
 
StringBinding initOpacityIcon ()
 Creates the icon name for the opacity button, depending on whether opacity is enabled or not.
 
StringBinding initOpacityText ()
 Creates the visible label for the opacity button, reflecting the current grid opacity value.
 
StringBinding initOpacityTooltip ()
 Creates the tooltip for the opacity button, combining dynamic label and submenu role.
 
StringBinding initSongAccessibleText ()
 Creates the accessibility label for the song button, depending on whether the song field is empty.
 
StringBinding initSongText ()
 Creates the visible label for the song button, adapting to whether a song is present or not.
 
StringBinding initSongTooltip ()
 Creates the tooltip for the song button, combining dynamic song info and submenu role.
 
String muteInfo (boolean isMuted)
 Returns the localized information about the current mute state.
 
String muteText (boolean isMuted)
 Returns the localized text corresponding to the mute state.
 
void persistImagePath (String imagePath)
 Persists the given image path in the current player's OptionsDto if it differs from the existing path, then refreshes the player.
 
void persistSongPath (String absolutePath, String name)
 Persists the audio file path (songPath) in the current player's options.
 
void setColorFromModel (GridPane sudokuFX, ColorPicker menuOptionsButtonColor, String colorValueFromModel)
 Sets the background color of the GridPane and updates the ColorPicker based on the color value retrieved from the model.
 

Private Attributes

final AsyncFileProcessorService asyncFileProcessorService
 
final AudioService audioService
 
final AudioUtils audioUtils
 
final BooleanProperty gridOpacityProperty = new SimpleBooleanProperty(false)
 
final ImageUtils imageUtils
 
boolean initialized = false
 
final BooleanProperty muteProperty = new SimpleBooleanProperty(true)
 
final StringBinding optionsAccessibleText
 
final StringBinding optionsClearSongAccessibleText
 
final StringBinding optionsClearSongRoleDescription
 
final StringBinding optionsClearSongTooltip
 
final StringBinding optionsColorAccessibleText
 
final StringBinding optionsColorRoleDescription
 
final StringBinding optionsColorTooltip
 
final StringBinding optionsImageAccessibleText
 
final StringBinding optionsImageRoleDescription
 
final StringBinding optionsImageText
 
final StringBinding optionsImageTooltip
 
final StringBinding optionsMenuMaxiAccessibleText
 
final StringBinding optionsMenuMaxiRoleDescription
 
final StringBinding optionsMenuMaxiText
 
final StringBinding optionsMenuMaxiTooltip
 
final StringBinding optionsMuteAccessibleText
 
final StringBinding optionsMuteIcon
 
final StringBinding optionsMuteRoleDescription
 
final StringBinding optionsMuteText
 
final StringBinding optionsMuteTooltip
 
final StringBinding optionsOpacityAccessibleText
 
final StringBinding optionsOpacityIcon
 
final StringBinding optionsOpacityRoleDescription
 
final StringBinding optionsOpacityText
 
final StringBinding optionsOpacityTooltip
 
final StringBinding optionsReduceAccessibleText
 
final StringBinding optionsReduceText
 
final StringBinding optionsReduceTooltip
 
final StringBinding optionsRoleDescription
 
final OptionsService optionsService
 
final StringBinding optionsSongAccessibleText
 
final StringBinding optionsSongRoleDescription
 
final StringBinding optionsSongText
 
final StringBinding optionsSongTooltip
 
final StringBinding optionsText
 
final StringBinding optionsTooltip
 
final PlayerStateHolder playerStateHolder
 
final BooleanProperty songIsBlankProperty = new SimpleBooleanProperty(true)
 
final SimpleStringProperty songProperty = new SimpleStringProperty("")
 
final ToasterService toasterService
 

Static Private Attributes

static final int HEX_RADIX = 16
 
static final String ICON_MUTE_OFF = "\ue04f"
 
static final String ICON_MUTE_ON = "\ue050"
 
static final String ICON_OPACITY_OFF = "\ue0c4"
 
static final String ICON_OPACITY_ON = "\ue891"
 
static final Logger LOG = LoggerFactory.getLogger(MenuOptionsViewModel.class)
 
static final String ROLE_CLOSED = "menu.accessibility.role.description.closed"
 
static final String ROLE_OPENED = "menu.accessibility.role.description.opened"
 
static final String ROLE_SUBMENU_OPTION
 

Detailed Description

ViewModel managing menu options UI state and accessibility strings.

Provides localized StringBindings for button labels, tooltips, and roles, updating automatically on locale changes. Supports options color and image initialization and updates, including asynchronous image loading with user feedback.

Constructor & Destructor Documentation

◆ MenuOptionsViewModel()

fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.MenuOptionsViewModel ( AudioService audioService,
AsyncFileProcessorService asyncFileProcessorService,
PlayerStateHolder playerStateHolder,
OptionsService optionsService,
ToasterService toasterService )
+ Here is the call graph for this function:

Member Function Documentation

◆ applyAndPersistBackgroundImage()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.applyAndPersistBackgroundImage ( File selectedFile,
SpinnerGridPane spinner,
GridPane sudokuFX )

Applies a background image to the specified GridPane and persists its path in the current player's options.

If a valid image file is provided, it is loaded, resized, and converted asynchronously via AsyncFileProcessorService, applied to the GridPane, and persisted. An info toast is shown on success.

If the file is null, invalid, or missing, no background is applied, an empty path is persisted, and an error toast is displayed.

Parameters
selectedFilethe image file to load; may be null
spinnerthe spinner to indicate loading; must not be null
sudokuFXthe GridPane to update; must not be null
Exceptions
NullPointerExceptionif spinner or sudokuFX is null
+ Here is the call graph for this function:

◆ applyAndPersistOptionsColor()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.applyAndPersistOptionsColor ( GridPane sudokuFX,
Color color )

Applies the given color as the background of the specified GridPane and persists it in the current player's options if it has changed.

The color is converted to a hex string including alpha (RRGGBBAA) and stored in a copy of the current OptionsDto with an empty image path. If the color is identical to the currently persisted value, no database update occurs.

On successful persistence, the GridPane background is updated. On failure, the exception is logged and an error toast is shown to the user.

Parameters
sudokuFXthe GridPane to update; must not be null
colorthe color to apply and persist; must not be null
Exceptions
NullPointerExceptionif sudokuFX or color is null
+ Here is the call graph for this function:

◆ checkInitialized()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.checkInitialized ( )
private

Checks whether the MenuOptionsViewModel has been initialized via init(GridPane, ColorPicker, SpinnerGridPane).

If the menu options have not been initialized, this method throws an exception to prevent operations on an uninitialized state.

Exceptions
IllegalStateExceptionif init(GridPane, ColorPicker, SpinnerGridPane) has not been called

◆ concatDependencies()

Observable[] fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.concatDependencies ( Observable... dependencies)
private

Utility: always observe the locale in addition to custom dependencies.

◆ createFormattedAndConcatenatedBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createFormattedAndConcatenatedBinding ( Supplier< String > keySupplier,
Supplier< String > argSupplier,
String suffixKey,
Observable... dependencies )
private

Creates a localized binding combining a formatted message and a suffix.

Updates when locale or any of the given dependencies change.

+ Here is the call graph for this function:

◆ createFormattedBinding() [1/2]

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createFormattedBinding ( String key,
String suffixKey )
private

Creates a StringBinding that returns the concatenation of two localized strings (main key and suffix key), updating automatically when the locale changes.

Parameters
keythe main i18n translation key
suffixKeythe suffix i18n translation key to append
Returns
a StringBinding with the concatenated localized string value

◆ createFormattedBinding() [2/2]

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createFormattedBinding ( Supplier< String > keySupplier,
Supplier< String > argSupplier,
Observable... dependencies )
private

Creates a formatted localized binding with one dynamic argument.

Updates when locale or any of the given dependencies change.

+ Here is the call graph for this function:

◆ createStringBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createStringBinding ( String key)
private

Creates a StringBinding that returns the localized string for the given key, updating automatically when the locale changes.

Parameters
keythe i18n translation key
Returns
a StringBinding with the localized string value

◆ gridOpacityProperty()

BooleanProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.gridOpacityProperty ( )

◆ gridOpacityText()

String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.gridOpacityText ( boolean isOpaque)
private

Returns the localized text corresponding to the grid opacity state.

Parameters
isOpaquetrue for "opaque" text, false for "transparent" text
Returns
localized string for the given opacity state

◆ init()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.init ( GridPane sudokuFX,
ColorPicker menuOptionsButtonColor,
SpinnerGridPane spinner )

Initializes the menu options UI state for the current player, including:

  • Background color or image
  • Grid opacity mode
  • Audio mute state
  • Selected song

This method synchronizes the UI components with the current player's options and prepares the necessary properties for bindings. The ViewModel is marked as initialized at the start of this method to allow called methods (like applyAndPersistBackgroundImage) to safely check the initialization state.

Parameters
sudokuFXthe GridPane to apply background settings; must not be null
menuOptionsButtonColorthe ColorPicker to synchronize with the current color; must not be null
spinnerthe spinner component to indicate loading state; must not be null
Exceptions
NullPointerExceptionif any of the parameters are null
+ Here is the call graph for this function:

◆ initMuteAccessibleText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initMuteAccessibleText ( )
private

Creates the accessibility label for the mute button, based on the current mute state.

+ Here is the call graph for this function:

◆ initMuteIcon()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initMuteIcon ( )
private

Creates the icon name for the mute button, depending on whether mute is active or not.

◆ initMuteText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initMuteText ( )
private

Creates the visible label for the mute button, reflecting the current mute state.

+ Here is the call graph for this function:

◆ initMuteTooltip()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initMuteTooltip ( )
private

Creates the tooltip for the mute button, combining dynamic mute info and submenu role.

+ Here is the call graph for this function:

◆ initOpacityAccessibleText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initOpacityAccessibleText ( )
private

Creates the accessibility label for the opacity button, based on the inverse of the current grid opacity state.

+ Here is the call graph for this function:

◆ initOpacityIcon()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initOpacityIcon ( )
private

Creates the icon name for the opacity button, depending on whether opacity is enabled or not.

◆ initOpacityText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initOpacityText ( )
private

Creates the visible label for the opacity button, reflecting the current grid opacity value.

+ Here is the call graph for this function:

◆ initOpacityTooltip()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initOpacityTooltip ( )
private

Creates the tooltip for the opacity button, combining dynamic label and submenu role.

+ Here is the call graph for this function:

◆ initSongAccessibleText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initSongAccessibleText ( )
private

Creates the accessibility label for the song button, depending on whether the song field is empty.

+ Here is the call graph for this function:

◆ initSongText()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initSongText ( )
private

Creates the visible label for the song button, adapting to whether a song is present or not.

+ Here is the call graph for this function:

◆ initSongTooltip()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initSongTooltip ( )
private

Creates the tooltip for the song button, combining dynamic song info and submenu role.

+ Here is the call graph for this function:

◆ muteInfo()

String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.muteInfo ( boolean isMuted)
private

Returns the localized information about the current mute state.

This text is intended for tooltips or accessibility purposes, indicating whether the audio is currently muted or unmuted.

Parameters
isMutedtrue if audio is currently muted, false if unmuted
Returns
localized string representing the current audio state

◆ muteText()

String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.muteText ( boolean isMuted)
private

Returns the localized text corresponding to the mute state.

Parameters
isMutedtrue for "muted" audio, false for "unmuted" audio
Returns
localized string for the given mute state

◆ optionsAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsAccessibleTextProperty ( )

◆ optionsClearSongAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongAccessibleTextProperty ( )

◆ optionsClearSongRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongRoleDescriptionProperty ( )

◆ optionsClearSongTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongTooltipProperty ( )

◆ optionsColorAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorAccessibleTextProperty ( )

◆ optionsColorRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorRoleDescriptionProperty ( )

◆ optionsColorTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorTooltipProperty ( )

◆ optionsImageAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageAccessibleTextProperty ( )

◆ optionsImageRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageRoleDescriptionProperty ( )

◆ optionsImageTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageTextProperty ( )

◆ optionsImageTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageTooltipProperty ( )

◆ optionsMenuMaxiAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiAccessibleTextProperty ( )

◆ optionsMenuMaxiRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiRoleDescriptionProperty ( )

◆ optionsMenuMaxiTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiTextProperty ( )

◆ optionsMenuMaxiTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiTooltipProperty ( )

◆ optionsMuteAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteAccessibleTextProperty ( )

◆ optionsMuteIconProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteIconProperty ( )

◆ optionsMuteRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteRoleDescriptionProperty ( )

◆ optionsMuteTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteTextProperty ( )

◆ optionsMuteTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteTooltipProperty ( )

◆ optionsOpacityAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityAccessibleTextProperty ( )

◆ optionsOpacityIconProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityIconProperty ( )

◆ optionsOpacityRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityRoleDescriptionProperty ( )

◆ optionsOpacityTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityTextProperty ( )

◆ optionsOpacityTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityTooltipProperty ( )

◆ optionsReduceAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceAccessibleTextProperty ( )

◆ optionsReduceTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceTextProperty ( )

◆ optionsReduceTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceTooltipProperty ( )

◆ optionsRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsRoleDescriptionProperty ( )

◆ optionsSongAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongAccessibleTextProperty ( )

◆ optionsSongRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongRoleDescriptionProperty ( )

◆ optionsSongTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongTextProperty ( )

◆ optionsSongTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongTooltipProperty ( )

◆ optionsTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsTextProperty ( )

◆ optionsTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsTooltipProperty ( )

◆ persistImagePath()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.persistImagePath ( String imagePath)
private

Persists the given image path in the current player's OptionsDto if it differs from the existing path, then refreshes the player.

If persisting the path succeeds, the current player is refreshed. If an exception occurs, the error is logged and an error toast is displayed to the user.

Parameters
imagePaththe image path to persist; may be empty to indicate no background image

◆ persistSongPath()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.persistSongPath ( String absolutePath,
String name )
private

Persists the audio file path (songPath) in the current player's options.

A copy of the current OptionsDto is created with the new path and persisted via OptionsService#updateOptions(OptionsDto). On success, the current player is refreshed, songProperty is updated, and an info toast is shown. On failure, the exception is logged and an error toast with details is displayed.

Parameters
absolutePaththe new audio file absolute path
namethe file name, used in toast messages

◆ resetSongPath()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.resetSongPath ( )

Resets the song path by clearing the current selection, persisting the change, and showing a toast notification.

+ Here is the call graph for this function:

◆ saveSong()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.saveSong ( File file)

Saves the provided song file path to the database and shows a confirmation toast.

The method validates that the file is non-null, exists, and has a supported audio format (MP3, WAV, AAC, M4A, AIF, AIFF). If valid, it updates the database and songProperty; otherwise, it logs an error and shows an error toast via ToasterVBox.

Parameters
filethe audio file to save; must not be null, must exist, and be a valid audio file
+ Here is the call graph for this function:

◆ setColorFromModel()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.setColorFromModel ( GridPane sudokuFX,
ColorPicker menuOptionsButtonColor,
String colorValueFromModel )
private

Sets the background color of the GridPane and updates the ColorPicker based on the color value retrieved from the model.

Parameters
sudokuFXthe GridPane to update (must not be null)
menuOptionsButtonColorthe ColorPicker to update (must not be null)
colorValueFromModelthe hex color string from the model (must not be null or blank, e.g., "99b3ffcd")
Exceptions
NullPointerExceptionif any parameter is null
IllegalArgumentExceptionif colorValueFromModel is blank
NumberFormatExceptionif colorValueFromModel is not a valid hex number or too large for an int

◆ songIsBlankProperty()

BooleanProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.songIsBlankProperty ( )

◆ toggleGridOpacityAndPersist()

boolean fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.toggleGridOpacityAndPersist ( )

Toggles the grid opacity mode, persists the new state in the database, updates
gridOpacityProperty
, and returns the actual updated value.

On success, an info toast indicates the new state. On failure, the exception is logged, an error toast is shown, and the property is restored to its previous value.

Returns
true if opaque mode is now active, false if transparent
+ Here is the call graph for this function:

◆ toggleMuteAndPersist()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.toggleMuteAndPersist ( )

Toggles the audio mute state, persists the new value in OptionsDto, updates the AudioService, and reflects the change in muteProperty.

On success, a user-friendly toast indicates the new mute state. On failure, the exception is logged and an error toast with details is displayed.

+ Here is the call graph for this function:

Member Data Documentation

◆ asyncFileProcessorService

final AsyncFileProcessorService fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.asyncFileProcessorService
private

◆ audioService

final AudioService fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.audioService
private

◆ audioUtils

final AudioUtils fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.audioUtils
private

◆ gridOpacityProperty

final BooleanProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.gridOpacityProperty = new SimpleBooleanProperty(false)
private

◆ HEX_RADIX

final int fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.HEX_RADIX = 16
staticprivate

◆ HEXCOLOR_BEGIN_INDEX

final int fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.HEXCOLOR_BEGIN_INDEX = 2
static

◆ HEXCOLOR_END_INDEX

final int fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.HEXCOLOR_END_INDEX = 10
static

◆ ICON_MUTE_OFF

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ICON_MUTE_OFF = "\ue04f"
staticprivate

◆ ICON_MUTE_ON

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ICON_MUTE_ON = "\ue050"
staticprivate

◆ ICON_OPACITY_OFF

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ICON_OPACITY_OFF = "\ue0c4"
staticprivate

◆ ICON_OPACITY_ON

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ICON_OPACITY_ON = "\ue891"
staticprivate

◆ imageUtils

final ImageUtils fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.imageUtils
private

◆ initialized

boolean fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.initialized = false
private

◆ LOG

final Logger fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.LOG = LoggerFactory.getLogger(MenuOptionsViewModel.class)
staticprivate

◆ muteProperty

final BooleanProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.muteProperty = new SimpleBooleanProperty(true)
private

◆ optionsAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsAccessibleText
private

◆ optionsClearSongAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongAccessibleText
private

◆ optionsClearSongRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongRoleDescription
private

◆ optionsClearSongTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsClearSongTooltip
private

◆ optionsColorAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorAccessibleText
private

◆ optionsColorRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorRoleDescription
private

◆ optionsColorTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsColorTooltip
private

◆ optionsImageAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageAccessibleText
private

◆ optionsImageRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageRoleDescription
private

◆ optionsImageText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageText
private

◆ optionsImageTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsImageTooltip
private

◆ optionsMenuMaxiAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiAccessibleText
private

◆ optionsMenuMaxiRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiRoleDescription
private

◆ optionsMenuMaxiText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiText
private

◆ optionsMenuMaxiTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMenuMaxiTooltip
private

◆ optionsMuteAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteAccessibleText
private

◆ optionsMuteIcon

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteIcon
private

◆ optionsMuteRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteRoleDescription
private

◆ optionsMuteText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteText
private

◆ optionsMuteTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsMuteTooltip
private

◆ optionsOpacityAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityAccessibleText
private

◆ optionsOpacityIcon

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityIcon
private

◆ optionsOpacityRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityRoleDescription
private

◆ optionsOpacityText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityText
private

◆ optionsOpacityTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsOpacityTooltip
private

◆ optionsReduceAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceAccessibleText
private

◆ optionsReduceText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceText
private

◆ optionsReduceTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsReduceTooltip
private

◆ optionsRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsRoleDescription
private

◆ optionsService

final OptionsService fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsService
private

◆ optionsSongAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongAccessibleText
private

◆ optionsSongRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongRoleDescription
private

◆ optionsSongText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongText
private

◆ optionsSongTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsSongTooltip
private

◆ optionsText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsText
private

◆ optionsTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.optionsTooltip
private

◆ playerStateHolder

final PlayerStateHolder fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.playerStateHolder
private

◆ ROLE_CLOSED

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_CLOSED = "menu.accessibility.role.description.closed"
staticprivate

◆ ROLE_OPENED

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_OPENED = "menu.accessibility.role.description.opened"
staticprivate

◆ ROLE_SUBMENU_OPTION

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_SUBMENU_OPTION
staticprivate
Initial value:
=
"menu.accessibility.role.description.submenu.option"

◆ songIsBlankProperty

final BooleanProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.songIsBlankProperty = new SimpleBooleanProperty(true)
private

◆ songProperty

final SimpleStringProperty fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.songProperty = new SimpleStringProperty("")
private

◆ SUDOKU_FX_MUST_NOT_BE_NULL

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.SUDOKU_FX_MUST_NOT_BE_NULL = "sudokuFX must not be null"
static

◆ toasterService

final ToasterService fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.toasterService
private

The documentation for this class was generated from the following file: