2023-11-20 23:25:36 -06:00
|
|
|
#pragma region License
|
2023-11-14 18:11:32 -06:00
|
|
|
/*
|
|
|
|
License (OLC-3)
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
2024-01-02 00:46:32 -06:00
|
|
|
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
2023-11-14 18:11:32 -06:00
|
|
|
|
|
|
|
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.
|
2023-11-29 00:50:00 -06:00
|
|
|
|
2024-01-30 14:48:49 +00:00
|
|
|
Portions of this software are copyright © 2024 The FreeType
|
2023-11-29 00:50:00 -06:00
|
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
|
|
All rights reserved.
|
2023-11-14 18:11:32 -06:00
|
|
|
*/
|
2023-11-20 23:25:36 -06:00
|
|
|
#pragma endregion
|
2024-01-04 05:21:56 -06:00
|
|
|
#include "AdventuresInLestoria.h"
|
2023-10-20 22:49:12 -05:00
|
|
|
#include "DEFINES.h"
|
|
|
|
#include "Menu.h"
|
2024-02-29 03:55:15 -06:00
|
|
|
#include "FloatingMenuComponent.h"
|
2024-01-01 07:48:57 -06:00
|
|
|
#include "SaveFile.h"
|
2024-01-27 06:43:09 -06:00
|
|
|
#include "util.h"
|
2023-10-20 22:49:12 -05:00
|
|
|
|
|
|
|
INCLUDE_game
|
2024-01-27 06:43:09 -06:00
|
|
|
INCLUDE_DATA
|
2023-12-05 23:07:49 -06:00
|
|
|
using A=Attribute;
|
2023-10-20 22:49:12 -05:00
|
|
|
|
|
|
|
void Menu::InitializeMainMenuWindow(){
|
2024-01-04 07:58:45 -06:00
|
|
|
Menu*mainMenuWindow=CreateMenu(MAIN_MENU,vi2d{132,120},vi2d{96,96});
|
2024-01-01 01:59:41 -06:00
|
|
|
|
2024-02-20 05:49:51 -06:00
|
|
|
auto newGameButton=mainMenuWindow->ADD("New Game Button",MenuComponent)(geom2d::rect<float>{{12,4},{72,20}},"New Game",[&](MenuFuncData data){
|
2024-01-27 06:43:09 -06:00
|
|
|
std::string randomName=DATA["Player"]["Default Female Name"].GetString(util::random()%DATA["Player"]["Default Female Name"].GetValueCount());
|
|
|
|
|
|
|
|
SaveFile::SetSaveFileName(randomName); //Randomize a default name.
|
|
|
|
Menu::OpenMenu(CLASS_SELECTION);
|
2024-01-01 01:59:41 -06:00
|
|
|
return true;
|
|
|
|
})END;
|
2024-02-20 05:49:51 -06:00
|
|
|
auto loadGameButton=mainMenuWindow->ADD("Load Game Button",MenuComponent)(geom2d::rect<float>{{12,28},{72,20}},"Load Game",[](MenuFuncData data){
|
2024-01-27 10:34:56 -06:00
|
|
|
SaveFile::UpdateSaveGameData([](){Menu::OpenMenu(LOAD_GAME);}); //This function also opens the menu in emscripten.
|
2024-01-01 07:48:57 -06:00
|
|
|
return true;
|
|
|
|
})END;
|
2024-02-20 05:49:51 -06:00
|
|
|
mainMenuWindow->ADD("Settings Button",MenuComponent)(geom2d::rect<float>{{12,52},{72,20}},"Settings",[](MenuFuncData data){
|
|
|
|
Menu::OpenMenu(SETTINGS);
|
|
|
|
return true;
|
|
|
|
})END;
|
|
|
|
mainMenuWindow->ADD("Quit Game Button",MenuComponent)(geom2d::rect<float>{{12,76},{72,20}},"Quit Game",[](MenuFuncData data){
|
2024-01-01 07:48:57 -06:00
|
|
|
game->EndGame();
|
|
|
|
return true;
|
|
|
|
})END;
|
2024-02-29 03:55:15 -06:00
|
|
|
mainMenuWindow->ADD("Credits Button",FloatingMenuComponent)(geom2d::rect<float>{{game->ScreenWidth()-74.f,game->ScreenHeight()-38.f},{72.f,20.f}},"Credits",[](MenuFuncData data){
|
|
|
|
Menu::OpenMenu(CREDITS);
|
|
|
|
return true;
|
|
|
|
})END;
|
2024-01-16 18:21:22 -06:00
|
|
|
|
2024-01-16 20:14:43 -06:00
|
|
|
mainMenuWindow->SetupKeyboardNavigation(
|
2024-01-17 19:32:51 -06:00
|
|
|
[](MenuType type,Data&returnData){ //On Open
|
2024-01-17 21:00:51 +00:00
|
|
|
if(SaveFile::GetSaveFileCount()>0){
|
2024-01-17 19:32:51 -06:00
|
|
|
returnData="Load Game Button";
|
2024-01-17 21:00:51 +00:00
|
|
|
}else{
|
2024-01-17 19:32:51 -06:00
|
|
|
returnData="New Game Button";
|
2024-01-17 21:00:51 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ //Button Key
|
2024-02-09 23:41:39 -06:00
|
|
|
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
|
2024-03-03 01:58:40 -06:00
|
|
|
{game->KEY_MENU,{"Credits",[](MenuType type){
|
|
|
|
Component<FloatingMenuComponent>(type,"Credits Button")->Click();
|
|
|
|
}}},
|
2024-01-16 20:14:43 -06:00
|
|
|
}
|
2024-01-17 21:00:51 +00:00
|
|
|
,{ //Button Navigation Rules
|
2024-01-16 20:14:43 -06:00
|
|
|
{"New Game Button",{
|
|
|
|
.up="Quit Game Button",
|
2024-02-29 03:55:15 -06:00
|
|
|
.down="Load Game Button",
|
|
|
|
.left="Credits Button",
|
|
|
|
.right="Credits Button",}},
|
2024-01-16 20:14:43 -06:00
|
|
|
{"Load Game Button",{
|
|
|
|
.up="New Game Button",
|
2024-02-29 03:55:15 -06:00
|
|
|
.down="Settings Button",
|
|
|
|
.left="Credits Button",
|
|
|
|
.right="Credits Button",}},
|
2024-02-20 05:49:51 -06:00
|
|
|
{"Settings Button",{
|
|
|
|
.up="Load Game Button",
|
2024-02-29 03:55:15 -06:00
|
|
|
.down="Quit Game Button",
|
|
|
|
.left="Credits Button",
|
|
|
|
.right="Credits Button",}},
|
2024-01-16 20:14:43 -06:00
|
|
|
{"Quit Game Button",{
|
2024-02-20 05:49:51 -06:00
|
|
|
.up="Settings Button",
|
2024-02-29 03:55:15 -06:00
|
|
|
.down="New Game Button",
|
|
|
|
.left="Credits Button",
|
|
|
|
.right="Credits Button",}},
|
|
|
|
{"Credits Button",{
|
|
|
|
.up="Load Game Button",
|
|
|
|
.down="Quit Game Button",
|
|
|
|
.left=[](MenuType type,Data&returnData){
|
|
|
|
if(SaveFile::GetSaveFileCount()>0){
|
|
|
|
returnData="Load Game Button";
|
|
|
|
}else{
|
|
|
|
returnData="New Game Button";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.right=[](MenuType type,Data&returnData){
|
|
|
|
if(SaveFile::GetSaveFileCount()>0){
|
|
|
|
returnData="Load Game Button";
|
|
|
|
}else{
|
|
|
|
returnData="New Game Button";
|
|
|
|
}
|
|
|
|
},}},
|
2024-01-16 20:14:43 -06:00
|
|
|
});
|
2023-10-20 22:49:12 -05:00
|
|
|
}
|