Added wrapping up and down functionality for load game window. Fix bug allowing the player to enter no name for a save file name, resulting in file load parsing failing completely. Remove back button in class selection window.

pull/35/head
sigonasr2 10 months ago
parent c972b33c56
commit 8512ccf51a
  1. 29
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/ClassSelectionWindow.cpp
  3. 34
      Adventures in Lestoria/LoadGameWindow.cpp
  4. 8
      Adventures in Lestoria/Menu.cpp
  5. 7
      Adventures in Lestoria/SaveFileWindow.cpp
  6. 2
      Adventures in Lestoria/Version.h
  7. 3
      Adventures in Lestoria/assets/config/configuration.txt

@ -285,17 +285,6 @@ bool AiL::OnUserUpdate(float fElapsedTime){
RenderWorld(GetElapsedTime());
GameState::STATE->Draw(this);
RenderMenu();
if(Menu::stack.size()>0){
std::weak_ptr<MenuComponent>component=Menu::stack.back()->GetSelection();
if(!component.expired()){
DrawShadowStringDecal({2,2},"Selection: "+component.lock()->GetName());
}
std::weak_ptr<MenuComponent>keyComponent=Menu::stack.back()->GetKeySelection();
if(!keyComponent.expired()){
DrawShadowStringDecal({2,14},"Key Selection: "+keyComponent.lock()->GetName());
}
}
DrawShadowStringDecal({2,26},"MOUSE NAVIGATION: "+std::to_string(Menu::MOUSE_NAVIGATION));
RenderFadeout();
RenderVersionInfo();
#ifndef __EMSCRIPTEN__
@ -2484,6 +2473,24 @@ void AiL::RenderMenu(){
menu->Draw(this);
}
}
#pragma region Menu Navigation Debug Info
#ifdef _DEBUG
if("debug_menu_navigation_info"_I){
if(Menu::stack.size()>0){
std::weak_ptr<MenuComponent>component=Menu::stack.back()->GetSelection();
if(!component.expired()){
DrawShadowStringDecal({2,2},"Selection: "+component.lock()->GetName());
}
std::weak_ptr<MenuComponent>keyComponent=Menu::stack.back()->GetKeySelection();
if(!keyComponent.expired()){
DrawShadowStringDecal({2,14},"Key Selection: "+keyComponent.lock()->GetName());
}
}
DrawShadowStringDecal({2,26},"MOUSE NAVIGATION: "+std::to_string(Menu::MOUSE_NAVIGATION));
}
#endif
#pragma endregion
}
void AiL::InitializeGraphics(){

@ -59,8 +59,6 @@ void Menu::InitializeClassSelectionWindow(){
vf2d navigationButtonSize={24*2.5f,16};
classSelectionWindow->ADD("Back Button",MenuComponent)(geom2d::rect<float>{{4+2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Back",[](MenuFuncData data){Menu::CloseMenu();return true;})END;
classSelectionWindow->ADD("Confirm",MenuComponent)(geom2d::rect<float>{{outlineSize.x+4-navigationButtonSize.x-2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Confirm",[](MenuFuncData data){
std::string selectedClass=data.component.lock()->S(A::CLASS_SELECTION);
data.game->ChangePlayerClass(classutils::StringToClass(selectedClass));

@ -59,7 +59,7 @@ void Menu::InitializeLoadGameWindow(){
{game->KEY_START,{"Load File",[](MenuType type){
Menu::menus[type]->GetSelection().lock()->Click();
}}},
{game->KEY_SELECT,{"Return to Title Screen",[](MenuType type){
{game->KEY_BACK,{"Back to Title Screen",[](MenuType type){
Component<MenuComponent>(type,"Back Button")->Click();
}}},
}
@ -75,7 +75,35 @@ void Menu::InitializeLoadGameWindow(){
returnData=*(--component);
}
},
.down="Go Back Button",}},
{"Go Back Button",{}},
.down=[](MenuType type,Data&returnData){
auto&selection=Menu::menus[type]->GetSelection();
auto&gameFilesList=Component<ScrollableWindowComponent>(type,"Game Files List")->GetComponents();
auto component=std::find_if(gameFilesList.begin(),gameFilesList.end(),[&](auto&comp){return comp.lock()==selection.lock();});
if(component==gameFilesList.end()-1){
returnData="Go Back Button";
}else{
returnData=*(++component);
}
},}},
{"Go Back Button",{
.up=[](MenuType type,Data&returnData){
auto&selection=Menu::menus[type]->GetSelection();
auto&gameFilesList=Component<ScrollableWindowComponent>(type,"Game Files List")->GetComponents();
if(gameFilesList.size()==0){
returnData="Go Back Button";
return;
}
returnData=*(gameFilesList.end()-1);
},
.down=[](MenuType type,Data&returnData){
auto&selection=Menu::menus[type]->GetSelection();
auto&gameFilesList=Component<ScrollableWindowComponent>(type,"Game Files List")->GetComponents();
if(gameFilesList.size()==0){
returnData="Go Back Button";
return;
}
returnData=*(gameFilesList.begin());
},
}},
});
}

@ -295,9 +295,11 @@ void Menu::Draw(AiL*game){
void Menu::OpenMenu(MenuType menu,bool cover){
menus[menu]->cover=cover;
Data returnData;
menus[menu]->onOpenFunc(menu,returnData);
menus[menu]->SetSelection(returnData);
if(menus[menu]->onOpenFunc){
Data returnData;
menus[menu]->onOpenFunc(menu,returnData);
menus[menu]->SetSelection(returnData);
}
stack.push_back(menus[menu]);
}

@ -43,7 +43,9 @@ All rights reserved.
void Menu::InitializeSaveFileWindow(){
Menu*saveFileWindow=CreateMenu(SAVE_FILE_NAME,CENTERED,vi2d{96,96});
saveFileWindow->ADD("Save File Name Entry Label",MenuLabel)(geom2d::rect<float>{{-8,0},{112,36}},"Save File Name:",1.0f,ComponentAttr::SHADOW)END;
saveFileWindow->ADD("Save File Name Text Entry",TextEntryLabel)(geom2d::rect<float>{{-8,36},{112,24}},TEXTCHANGE_DONOTHING,false,16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END;
saveFileWindow->ADD("Save File Name Text Entry",TextEntryLabel)(geom2d::rect<float>{{-8,36},{112,24}},[](std::string_view updatedLabel){
Component<MenuComponent>(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(updatedLabel.length()==0);
},false,16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END;
saveFileWindow->ADD("Back Button",MenuComponent)(geom2d::rect<float>{{-8,68},{48,12}},"Back",[](MenuFuncData data){Menu::CloseMenu();game->TextEntryEnable(false);return true;})END;
saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect<float>{{56,68},{48,12}},"Begin",MenuType::CLASS_SELECTION,[](MenuFuncData data){
SaveFile::SetSaveFileName(game->TextEntryGetString());
@ -51,7 +53,8 @@ void Menu::InitializeSaveFileWindow(){
game->TextEntryEnable(false);
SaveFile::SaveGame();
return true;
})END;
})END
->SetGrayedOut(true);
saveFileWindow->SetupKeyboardNavigation(

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 5997
#define VERSION_BUILD 6004
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -116,6 +116,9 @@ encrypted_font_size = Unknown,16
# Whether or not to show individual data accesses from config data structure.
debug_access_options = 0
# Shows menu navigation debug output
debug_menu_navigation_info = 0
# Shows map loading output
debug_map_load_info = 0

Loading…
Cancel
Save