this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

main menu refactoring

nesbox e93f9036 6815ccc7

+77 -21
+77 -21
src/studio/screens/mainmenu.c
··· 247 247 initGamepadMenu(main); 248 248 } 249 249 250 + enum 251 + { 252 + #if defined(CRT_SHADER_SUPPORT) 253 + OptionsMenu_CrtMonitorOption, 254 + #endif 255 + #if defined(BUILD_EDITORS) 256 + OptionsMenu_DevModeOption, 257 + #endif 258 + OptionsMenu_VSyncOption, 259 + OptionsMenu_FullscreenOption, 260 + OptionsMenu_IntegerScaleOption, 261 + OptionsMenu_VolumeOption, 262 + #if defined(BUILD_EDITORS) 263 + OptionsMenu_CodeEditor, 264 + #endif 265 + OptionsMenu_Gamepad, 266 + OptionsMenu_Separator, 267 + OptionsMenu_Back, 268 + }; 269 + 250 270 static const MenuItem OptionMenu[] = 251 271 { 252 272 #if defined(CRT_SHADER_SUPPORT) ··· 277 297 } 278 298 279 299 #if defined(BUILD_EDITORS) 300 + 301 + enum 302 + { 303 + CodeEditorMenu_EmacsMode, 304 + CodeEditorMenu_Separator, 305 + CodeEditorMenu_Back, 306 + }; 307 + 280 308 static const MenuItem CodeEditorMenu[] = 281 309 { 282 310 {"EMACS MODE", NULL, &EmacsModeOption, "For the cool kids only"}, ··· 289 317 StudioMainMenu* main = data; 290 318 291 319 studio_menu_init(main->menu, CodeEditorMenu, 292 - COUNT_OF(CodeEditorMenu), 0, COUNT_OF(OptionMenu)-3, showOptionsMenu, main); 320 + COUNT_OF(CodeEditorMenu), CodeEditorMenu_EmacsMode, OptionsMenu_CodeEditor, showOptionsMenu, main); 293 321 } 294 322 #endif 295 323 ··· 350 378 studio_menu_init(main->menu, main->items, main->count, 0, 0, showMainMenu, main); 351 379 } 352 380 353 - static inline s32 mainMenuStart(StudioMainMenu* menu) 381 + static inline s32 mainMenuOffset(StudioMainMenu* menu) 354 382 { 355 383 return menu->count ? 0 : 1; 356 384 } ··· 380 408 exitGame(main->studio); 381 409 } 382 410 411 + enum MainMenu 412 + { 413 + MainMenu_GameMenu, 414 + MainMenu_ResumeGame, 415 + MainMenu_ResetGame, 416 + #if defined(BUILD_EDITORS) 417 + MainMenu_CloseGame, 418 + #endif 419 + MainMenu_Options, 420 + MainMenu_Separator, 421 + MainMenu_Quit, 422 + }; 423 + 383 424 static const MenuItem MainMenu[] = 384 425 { 385 426 {"GAME MENU", showGameMenu}, ··· 398 439 StudioMainMenu* main = data; 399 440 initGameMenu(main); 400 441 401 - s32 start = mainMenuStart(main); 442 + s32 offset = mainMenuOffset(main); 402 443 403 - studio_menu_init(main->menu, MainMenu + start, COUNT_OF(MainMenu) - start, 0, 0, onResumeGame, main); 444 + studio_menu_init(main->menu, MainMenu + offset, COUNT_OF(MainMenu) - offset, 0, 0, onResumeGame, main); 404 445 } 405 446 406 447 static void showOptionsMenuPos(void* data, s32 pos) 407 448 { 408 449 StudioMainMenu* main = data; 409 450 410 - studio_menu_init(main->menu, OptionMenu, 411 - COUNT_OF(OptionMenu), pos, COUNT_OF(MainMenu) - 3 - mainMenuStart(main), showMainMenu, main); 451 + s32 offset = mainMenuOffset(main); 452 + studio_menu_init(main->menu, OptionMenu, COUNT_OF(OptionMenu), pos, MainMenu_Options - offset, showMainMenu, main); 412 453 } 413 454 414 455 static void showOptionsMenu(void* data, s32 pos) 415 456 { 416 - showOptionsMenuPos(data, COUNT_OF(OptionMenu) - 4); 417 - } 418 - 419 - static void saveGamepadMenu(void* data, s32 pos) 420 - { 421 - StudioMainMenu* main = data; 422 - 423 - main->options->mapping = main->gamepads.mapping; 424 - showOptionsMenuPos(data, COUNT_OF(OptionMenu) - 3); 457 + showOptionsMenuPos(data, OptionsMenu_VolumeOption); 425 458 } 426 459 427 460 static void resetGamepadMenu(void* data, s32 pos); ··· 440 473 "Y", 441 474 }; 442 475 443 - enum{KeyMappingStart = 2}; 476 + enum 477 + { 478 + GamepadMenu_Index, 479 + GamepadMenu_Separator, 480 + GamepadMenu_Gamepad0, 481 + GamepadMenu_Gamepad1, 482 + GamepadMenu_Gamepad2, 483 + GamepadMenu_Gamepad3, 484 + GamepadMenu_Gamepad4, 485 + GamepadMenu_Gamepad5, 486 + GamepadMenu_Gamepad6, 487 + GamepadMenu_Gamepad7, 488 + GamepadMenu_Separator2, 489 + GamepadMenu_Save, 490 + GamepadMenu_Clear, 491 + GamepadMenu_Reset, 492 + GamepadMenu_Back, 493 + }; 444 494 445 495 static void assignMapping(void* data, s32 pos) 446 496 { 447 497 StudioMainMenu* main = data; 448 498 449 - main->gamepads.key = pos - KeyMappingStart; 499 + main->gamepads.key = pos - GamepadMenu_Gamepad0; 450 500 451 501 static const char Fmt[] = "to assign to (%s) button..."; 452 502 static char str[sizeof Fmt + STRLEN("RIGHT")]; ··· 510 560 initGamepadMenu(main); 511 561 } 512 562 563 + static void saveGamepadMenu(void* data, s32 pos) 564 + { 565 + StudioMainMenu* main = data; 566 + 567 + main->options->mapping = main->gamepads.mapping; 568 + showOptionsMenuPos(data, OptionsMenu_Gamepad); 569 + } 570 + 513 571 static void initGamepadMenu(StudioMainMenu* main) 514 572 { 515 573 static const MenuItem GamepadMenu[] = ··· 535 593 536 594 initGamepadButtons(main); 537 595 538 - s32 backPos = COUNT_OF(OptionMenu) - 3; 539 - 540 596 studio_menu_init(main->menu, GamepadMenu, COUNT_OF(GamepadMenu), 541 - main->gamepads.key < 0 ? KeyMappingStart : main->gamepads.key + KeyMappingStart, 542 - backPos, showOptionsMenu, main); 597 + main->gamepads.key < 0 ? GamepadMenu_Gamepad0 : main->gamepads.key + GamepadMenu_Gamepad0, 598 + OptionsMenu_Gamepad, showOptionsMenu, main); 543 599 544 600 main->gamepads.key = -1; 545 601 }