1818
1919/**
2020 * Main menu controller — wired to mainmenu.fxml
21+ * Handles navigation from the main menu, displays the current user, and
22+ * provides a helper to load other FXML views while attempting to pass runtime
23+ * data to their controllers via an {@code initData(User, AuthenticationService)}
24+ * method when present.
2125 */
2226public class MainMenuController implements Initializable {
2327
@@ -34,7 +38,14 @@ public class MainMenuController implements Initializable {
3438
3539 private AuthenticationService authService ;
3640 private User currentUser ;
37-
41+ /**
42+ * Initialize UI bindings and button handlers.
43+ * Sets up background image scaling, populates the welcome label if a
44+ * current user is present, and wires navigation actions for menu buttons.
45+ * Also attempts to clear per-user saved state on logout.
46+ * @param location not used
47+ * @param resources not used
48+ */
3849 @ Override
3950 public void initialize (URL location , ResourceBundle resources ) {
4051
@@ -108,7 +119,9 @@ public void initialize(URL location, ResourceBundle resources) {
108119 }
109120
110121 /**
111- * Called by the loader after FXMLLoader.load() to pass runtime data
122+ * Called by the loader after FXMLLoader.load() to pass runtime data.
123+ * @param user the current application user (may be null)
124+ * @param auth the authentication service instance (may be null)
112125 */
113126 public void initData (User user , AuthenticationService auth ) {
114127 this .currentUser = user ;
@@ -129,6 +142,11 @@ public void initData(User user, AuthenticationService auth) {
129142
130143 /**
131144 * Helper to load a target FXML and switch the current Scene root.
145+ * Searches a list of candidate paths for the FXML resource, loads it,
146+ * attempts to invoke {@code initData(User, AuthenticationService)} on the
147+ * loaded controller if present, and then replaces the current scene root.
148+ * Errors are logged but do not throw.
149+ * @param baseName base name of the FXML (e.g. "login", "difficulty")
132150 */
133151 private void loadAndSwitch (String baseName ) {
134152 String [] candidates = new String [] {
0 commit comments