#pragma once #include "anm2.h" #include "kage_graphics.h" #include "menu_game.h" #include "menu_save.h" #include "menu_title.h" #include #include // The menus MenuManager shows, by REPENTOGON's MainMenuType, each at its own place on the menu sheet. enum MenuState : int { MENU_NONE, MENU_TITLE, MENU_SAVE, MENU_GAME, MENU_DAILY_RUN, MENU_CHARACTER, MENU_SPECIAL_SEEDS, MENU_CHALLENGE, MENU_COLLECTION, MENU_STATS, MENU_OPTIONS, MENU_CONTROLLER_SELECT, MENU_KEY_CONFIG, MENU_CUTSCENES, MENU_BESTIARY, MENU_CUSTOM_CHALLENGE, MENU_MODS, MENU_ONLINE_LOBBY, MENU_ONLINE_LOBBY_LIST, MENU_ONLINE, MENU_ONLINE_OPTIONS, MENU_CREATE_LOBBY, MENU_ONLINE_AWARDS, MENU_COUNT }; // The game's input actions (Lua's ButtonAction), each bound to up to four buttons or keys of every device. enum ButtonAction : int { ACTION_LEFT, ACTION_RIGHT, ACTION_UP, ACTION_DOWN, ACTION_SHOOT_LEFT, ACTION_SHOOT_RIGHT, ACTION_SHOOT_UP, ACTION_SHOOT_DOWN, ACTION_BOMB, ACTION_ITEM, ACTION_PILL_CARD, ACTION_DROP, ACTION_PAUSE, ACTION_MAP, ACTION_MENU_CONFIRM, ACTION_MENU_BACK, ACTION_FULLSCREEN, ACTION_MUTE, ACTION_RESTART, ACTION_JOIN_MULTIPLAYER, ACTION_MENU_LEFT, ACTION_MENU_RIGHT, ACTION_MENU_UP, ACTION_MENU_DOWN, ACTION_MENU_LB, ACTION_MENU_RB, ACTION_MENU_LT, ACTION_MENU_RT, ACTION_MENU_TAB, ACTION_MENU_EX, ACTION_EMOTES }; // How an action is asked about: held now, or pressed this frame. enum ActionTest { ACTION_PRESSED, ACTION_TRIGGERED }; // Whether SetState keeps the menu history or rebuilds the one leading to the new menu. enum MenuHistory { HISTORY_KEEP, HISTORY_REBUILD }; // Whether a menu switch also resets the special seeds when it enters them. Leaving them always does. enum SeedsEntry { SEEDS_ENTRY_KEEP, SEEDS_ENTRY_RESET }; constexpr const char* ANIMATION_IDLE = "Idle"; constexpr float MENU_HEIGHT = 270; constexpr float MENU_WIDTH = 480; constexpr int DEVICE_NONE = -1; constexpr int POPUP_POSITION_CENTERED = -1; constexpr int SOUND_BOOK_PAGE_TURN_12 = 8; constexpr int SOUND_MENU_SCROLL = 282; constexpr int SOUND_MENU_NOTE_APPEAR = 283; constexpr int SOUND_MENU_NOTE_HIDE = 284; constexpr ColorModState COLOR_MOD_NONE = {1, 1, 1, 0, 0, 1}; // The main menu (g_menuManager): every menu laid out on one sheet the view scrolls across, the history of menus // opened, the fades, the fly, the shadow and overlay over everything, and the color modifier it all renders through. // The menus not taken over yet keep their generated types. Copies are never made. class MenuManager { public: std::array viewPositionSet{}; std::vector menuStateHistory; ColorModState currentColorModState = COLOR_MOD_NONE; ColorModState lerpColorModState = COLOR_MOD_NONE; ColorModState targetColorModState = COLOR_MOD_NONE; KColor fadeInColor{}; Seeds seedsObject{}; Vector specialSeedsViewPosition{}; Vector viewPosition{}; KAGE::Graphics::ImagePtr emptyScreenImage; KAGE::Graphics::ImagePtr menuOverlayImage; ANM2 flySprite; ANM2 menuShadowSprite; ANM2 onlineStatsMenuSprite; Menu_Title menuTitle; Menu_Save menuSave; Menu_Game menuGame; Menu_Bestiary menuBestiary{}; Menu_Challenge menuChallenge{}; Menu_Character menuCharacter{}; Menu_Collection menuCollection{}; Menu_ControllerSelect menuControllerSelect{}; Menu_CreateLobby menuCreateLobby{}; Menu_CustomChallenge menuCustomChallenge{}; Menu_Cutscenes menuCutscenes{}; Menu_DailyChallenge menuDailyChallenge{}; Menu_KeyConfig menuKeyConfig{}; Menu_Mods menuMods{}; Menu_Online menuOnline{}; Menu_OnlineLobby menuOnlineLobby{}; Menu_OnlineLobbyList menuOnlineLobbyList{}; Menu_Options menuOptions{}; Menu_Options onlineOptions{}; Menu_SpecialSeeds menuSpecialSeeds{}; Menu_Stats menuStats{}; Vector onlineAwardsPosition{}; float backWidgetOffsetY = 0; float fadeInProgress = 0; float fadeOutProgress = 0; float scrollInterpolationX = 0; float scrollInterpolationY = 0; float selectWidgetOffsetY = 0; float vignetteIntensity = 0; int onlineAwardsCursor = 0; MenuState selectedMenuId = MENU_NONE; bool isColorModLerping = false; bool isFadeInActive = false; bool isFadeOutActive = false; bool isPopupButtonsShown = false; bool isViewMoving = false; MenuManager(); ~MenuManager(); MenuManager(const MenuManager&) = delete; void Init(); void LoadGraphics(); void unload_graphics(); void Update(); void Render(); void SetState(MenuState state, MenuHistory history); void push_menu(MenuState menu); void pop_menu(); void scroll_options_menu(MenuState menu, int selectedRow, int rowCount); void start_game(KColor fadeColor); Vector menu_position_get(MenuState menu); SpriteDraw menu_draw_get(Vector position); private: Vector view_target_get(MenuState menu); void view_update(); void fly_update(); void controller_update(); void menu_update(); void color_mod_update(); void history_rebuild(MenuState state); SeedsEntry transition_apply(MenuState previous, MenuState state); SeedsEntry transition_other_apply(MenuState previous, MenuState state); void popup_buttons_place(); void vignette_update(); void overlay_render(); void color_mod_render(); void fades_render(); }; extern KAGE::Graphics::ImagePtr menuColorModSurface; KColor kcolor_make(float red, float green, float blue, float alpha); KColor kcolor_argb(uint32_t argb); Vector vector_add(Vector a, Vector b); bool is_action(ButtonAction action, ActionTest test, int* deviceIndex = nullptr); bool is_key_repeat(int heldFrames); void menu_sound_play(int sound, int frameDelay); void shader_select(std::string_view shaderName); void color_mod_surface_create();