Fix bug with emscripten involving bad references to other map items in InputHelper groupData? This makes zero sense and only occurs in the emscripten build, a clear fixes it.

mac-build
sigonasr2 9 months ago
parent d33d5bb4f0
commit a4bc56b457
  1. 22
      Adventures in Lestoria/InputHelper.cpp
  2. 2
      Adventures in Lestoria/TODO.txt

@ -48,6 +48,9 @@ INCLUDE_WINDOW_SIZE
InputHelper::InputHelper(){} InputHelper::InputHelper(){}
void InputHelper::Initialize(MenuInputGroups&inputGroups){ void InputHelper::Initialize(MenuInputGroups&inputGroups){
groupData.clear(); //HACK ALERT: WTF, somehow we must clear this map because there are references to things that are mixed up where they shouldn't be
// ONLY for the emscripten build. Clearing this map ensures that we start with fresh copies to things and it appears that emscripten
// likes this...?
groupData=inputGroups; groupData=inputGroups;
} }
@ -70,25 +73,24 @@ void InputHelper::Draw(){
#pragma region Populate all buttons to display #pragma region Populate all buttons to display
inputGroups.clear(); inputGroups.clear();
groupedInputs.clear(); groupedInputs.clear();
for(auto&data:groupData){ for(auto&[group,action]:groupData){
if(data.first.GetLabelVisible()){ //If the label is not visible, we don't care to include it in our list. if(group.GetLabelVisible()){ //If the label is not visible, we don't care to include it in our list.
if(std::holds_alternative<ButtonName>(data.second.first)){ if(std::holds_alternative<ButtonName>(action.first)){
const ButtonName&name=std::get<ButtonName>(data.second.first); const ButtonName&name=std::get<ButtonName>(action.first);
groupedInputs[name].push_back(data.first.GetGroup()); groupedInputs[name].push_back(group.GetGroup());
if(groupedInputs[name].size()>1)continue; //Skip adding to the list of input groups because this input already has been added. if(groupedInputs[name].size()>1)continue; //Skip adding to the list of input groups because this input already has been added.
}else }else
if(std::holds_alternative<std::function<std::string(MenuFuncData)>>(data.second.first)){ if(std::holds_alternative<std::function<std::string(MenuFuncData)>>(action.first)){
std::weak_ptr<ScrollableWindowComponent>parentComponent; std::weak_ptr<ScrollableWindowComponent>parentComponent;
if(!Menu::stack.back()->GetSelection().expired()){ if(!Menu::stack.back()->GetSelection().expired()){
parentComponent=Menu::stack.back()->GetSelection().lock()->parentComponent; parentComponent=Menu::stack.back()->GetSelection().lock()->parentComponent;
} }
std::string name=std::get<std::function<std::string(MenuFuncData)>>(data.second.first)(MenuFuncData{*Menu::stack.back(),game,Menu::stack.back()->GetSelection(),parentComponent}); std::string name=std::get<std::function<std::string(MenuFuncData)>>(action.first)(MenuFuncData{*Menu::stack.back(),game,Menu::stack.back()->GetSelection(),parentComponent});
groupedInputs[name].push_back(data.first.GetGroup()); groupedInputs[name].push_back(group.GetGroup());
if(groupedInputs[name].size()>1)continue; //Skip adding to the list of input groups because this input already has been added. if(groupedInputs[name].size()>1)continue; //Skip adding to the list of input groups because this input already has been added.
} }
this->inputGroups[data.first.GetGroup()]=data.second.first; this->inputGroups[group.GetGroup()]=action.first;
} }
} }
for(auto&[group,display]:inputGroups){ for(auto&[group,display]:inputGroups){

@ -36,5 +36,3 @@ Original Nico Sprite
Story I-I should not unlock Stage I-II. Story I-I should not unlock Stage I-II.
Initial Gold Crafting costs does not get subtracted properly. Initial Gold Crafting costs does not get subtracted properly.
Menu controls are not properly saved in system settings (only for emscripten?) Menu controls are not properly saved in system settings (only for emscripten?)
The keyboard display controls for the merchant are messed up?
Loading…
Cancel
Save