# pragma region License
/*
License ( OLC - 3 )
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Copyright 2024 Joshua Sigona < sigonasr2 @ gmail . com >
Redistribution and use in source and binary forms , with or without modification ,
are permitted provided that the following conditions are met :
1. Redistributions or derivations of source code must retain the above copyright
notice , this list of conditions and the following disclaimer .
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice . This list of conditions and the following disclaimer must be
reproduced in the documentation and / or other materials provided with the distribution .
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND ANY
EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT ,
INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED
TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR
BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN
CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE .
Portions of this software are copyright © 2024 The FreeType
Project ( www . freetype . org ) . Please see LICENSE_FT . txt for more information .
All rights reserved .
*/
# pragma endregion
# include "AdventuresInLestoria.h"
# include "DEFINES.h"
# include "Menu.h"
# include "EncountersSpawnListScrollableWindowComponent.h"
# include "MenuLabel.h"
# include "MenuComponent.h"
# include "State_OverworldMap.h"
# include "Map.h"
# include "Unlock.h"
# include "Tutorial.h"
INCLUDE_game
INCLUDE_MONSTER_DATA
using A = Attribute ;
void Menu : : InitializeOverworldMapLevelWindow ( ) {
vf2d windowSize = { game - > GetScreenSize ( ) . x / 3.f - 24 , float ( game - > GetScreenSize ( ) . y ) - 48 } ;
Menu * levelSelectWindow = CreateMenu ( OVERWORLD_LEVEL_SELECT , { game - > GetScreenSize ( ) . x - game - > GetScreenSize ( ) . x / 3.f , 24 } , windowSize ) ;
levelSelectWindow - > ADD ( " Panel 1 Back " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 0 } , { windowSize . x - 1 , 44 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : OUTLINE ) END ;
levelSelectWindow - > ADD ( " Chapter Label " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 4 } , { windowSize . x , 16 } } , " Chapter " , 1 , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) DEPTH - 1 END ;
levelSelectWindow - > ADD ( " Stage Label " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 24 } , { windowSize . x , 16 } } , " Stage " , 1 , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) DEPTH - 1 END ;
levelSelectWindow - > ADD ( " Panel 2 Back " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 52 } , { windowSize . x - 1 , 96 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : OUTLINE ) END ;
levelSelectWindow - > ADD ( " Encounters Label " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 52 } , { windowSize . x - 1 , 12 } } , " Encounters: " , 1 , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
levelSelectWindow - > ADD ( " Spawns List " , EncountersSpawnListScrollableWindowComponent ) ( geom2d : : rect < float > { { 1 , 64 } , { windowSize . x - 2 , 84 } } , ComponentAttr : : BACKGROUND ) END ;
levelSelectWindow - > ADD ( " Enter Button " , MenuComponent ) ( geom2d : : rect < float > { { 0 , 166 } , { windowSize . x - 1 , 16 } } , " Enter " , [ ] ( MenuFuncData data ) {
if ( State_OverworldMap : : GetCurrentConnectionPoint ( ) . map = = " HUB " & & Unlock : : IsUnlocked ( " STORY_1_2 " ) & & ! Tutorial : : TaskIsComplete ( TutorialTaskName : : BLACKSMITH ) ) {
Tutorial : : SetNextTask ( TutorialTaskName : : BLACKSMITH ) ;
}
game - > RestockLoadoutItems ( ) ;
if ( game - > MAP_DATA [ State_OverworldMap : : GetCurrentConnectionPoint ( ) . map ] . skipLoadoutScreen | |
State_OverworldMap : : GetCurrentConnectionPoint ( ) . type . starts_with ( " STORY " ) ) {
State_OverworldMap : : StartLevel ( ) ;
} else {
if ( ! Tutorial : : TaskIsComplete ( TutorialTaskName : : SET_LOADOUT_ITEM ) ) {
Tutorial : : SetNextTask ( TutorialTaskName : : SET_LOADOUT_ITEM ) ;
}
Component < MenuLabel > ( ITEM_LOADOUT , " Loadout Map Name Label " ) - > SetLabel ( std : : format ( " About to Enter: #FFFF00{} " , State_OverworldMap : : GetCurrentConnectionPoint ( ) . name ) ) ;
Menu : : OpenMenu ( ITEM_LOADOUT ) ;
}
return true ;
} ) END ;
# pragma region Keyboard Navigation Rules
levelSelectWindow - > SetupKeyboardNavigation (
[ ] ( MenuType type , Data & returnData ) { /*On Open*/ } ,
{ //Button Key
{ { game - > KEY_MENU } , { " Game Menu " , [ ] ( MenuType type ) {
Menu : : OpenMenu ( OVERWORLD_MENU ) ;
} } } ,
{ { game - > KEY_CONFIRM } , { " Start Stage " , [ ] ( MenuType type ) {
if ( ! Menu : : UsingMouseNavigation ( ) ) {
Component < MenuComponent > ( type , " Enter Button " ) - > Click ( ) ;
}
} } } ,
{ { game - > KEY_SHOULDER , Pressed } , { " Scroll Encounters " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( - 1.0f ) ;
} } } ,
{ { game - > KEY_FASTSCROLLUP , Held , InputEngageGroup : : NOT_VISIBLE } , { " Scroll Encounters " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( - 1.0f ) ;
} } } ,
{ { game - > KEY_FASTSCROLLDOWN , Held , InputEngageGroup : : NOT_VISIBLE } , { " Scroll Encounters " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( 1.0f ) ;
} } } ,
{ { game - > KEY_SCROLLVERT_R , Analog , InputEngageGroup : : NOT_VISIBLE } , { " Scroll Encounters " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( game - > KEY_SCROLLVERT . Analog ( ) ) ;
} } } ,
{ { game - > KEY_SCROLLUP , Held } , { " " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( 1.f ) ;
} } } ,
{ { game - > KEY_SCROLLDOWN , Held } , { " " , [ ] ( MenuType type ) {
Component < EncountersSpawnListScrollableWindowComponent > ( type , " Spawns List " ) - > Scroll ( - 1.f ) ;
} } } ,
}
, { //Button Navigation Rules
} ) ;
# pragma endregion
}