Menu Handler
src.controller.menu_handler
¶
Menu input controller for player setup and configuration screens.
This module handles low-level Pygame events for the start menu, player-name entry, hero selection, and display settings. It stores the temporary selection state that is later consumed by the main game initialization.
The documentation follows Google-style docstrings so tools such as pdoc, Sphinx Napoleon, or MkDocs-based pipelines can expose parameters, return values, and side effects in a consistent HTML API reference.
MenuHandler
¶
Stateful controller for menu interactions.
The handler receives Pygame events from the menu view and updates temporary menu state such as the current player name, selected heroes, and selected marker positions. Once two valid teams have been selected, it returns the selection data used to initialize the game.
Attributes:
| Name | Type | Description |
|---|---|---|
selected_units |
dict[str, list[str]]
|
Hero selections grouped by player. |
player_names |
list[str]
|
Names entered by players. |
current_player |
int
|
Index of the player currently being configured. |
Notes
This class is documented as part of the public project API and is intended to be readable in generated HTML documentation.
Source code in src\controller\menu_handler.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
select_units(event, erza_rect, gray_rect, natsu_rect, gowther_rect, kansuke_rect, heisuke_rect)
¶
Handle mouse-based hero selection for the current player.
The method toggles a hero in the current player's selection and stores the coordinates used to draw the selection marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Pygame event to process. |
required | |
erza_rect
|
Clickable rectangle associated with the Erza hero button. |
required | |
gray_rect
|
Clickable rectangle associated with the Gray hero button. |
required | |
natsu_rect
|
Clickable rectangle associated with the Natsu hero button. |
required | |
gowther_rect
|
Clickable rectangle associated with the Gowther hero button. |
required | |
kansuke_rect
|
Clickable rectangle associated with the Kansuke hero button. |
required | |
heisuke_rect
|
Clickable rectangle associated with the Heisuke hero button. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Updates the current player selection and menu state.
Source code in src\controller\menu_handler.py
get_player_name(event, input_rect, text, active)
¶
Handle text input for the current player name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Pygame event to process. |
required | |
input_rect
|
Text input rectangle used for player-name editing. |
required | |
text
|
Multiline text content to render. |
required | |
active
|
Whether the text input currently has keyboard focus. |
required |
Returns:
| Type | Description |
|---|---|
|
tuple[str, bool]: Updated text value and focus state. |
Side Effects
Processes input focus and text content for player names.
Source code in src\controller\menu_handler.py
submit(event, ok_rect)
¶
Validate the current selection when the confirmation button is pressed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Pygame event to process. |
required | |
ok_rect
|
Clickable rectangle used to confirm the current selection. |
required |
Returns:
| Type | Description |
|---|---|
|
bool | None: Submission status when the confirmation action is processed. |
Side Effects
Validates selection state and advances menu progression when valid.
Source code in src\controller\menu_handler.py
start(clock)
¶
Run the menu loop and return the selected units once setup is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clock
|
Pygame clock used to regulate the menu loop. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
The value produced by the menu or game loop, when one is returned by the underlying flow. |
Side Effects
Runs menu or game loops and may initialize runtime state.
Source code in src\controller\menu_handler.py
menu(pressed, banner, clock, screen)
¶
Handle events and screen transitions on the main menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pressed
|
Current keyboard state returned by Pygame. |
required | |
banner
|
Menu banner surface or rectangle used by the menu screen. |
required | |
clock
|
Pygame clock used to regulate the menu loop. |
required | |
screen
|
Pygame surface or screen wrapper used as the drawing target. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Handles menu events, screen transitions, and display refresh.
Source code in src\controller\menu_handler.py
choose_player(screen, banner)
¶
Handle player naming and unit selection events on the team selection screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Pygame surface or screen wrapper used as the drawing target. |
required | |
banner
|
Menu banner surface or rectangle used by the menu screen. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Processes player naming, hero selection, and confirmation events.
Source code in src\controller\menu_handler.py
display_settings()
¶
Handle events on the settings screen.
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Applies settings-screen events and may update display resolution.