|
|
|
@@ -46,6 +46,7 @@ All rights reserved.
|
|
|
|
|
#include "ScrollableWindowComponent.h"
|
|
|
|
|
#include "LoadFileButton.h"
|
|
|
|
|
#include "Checkbox.h"
|
|
|
|
|
#include "InputDisplayComponent.h"
|
|
|
|
|
|
|
|
|
|
INCLUDE_game
|
|
|
|
|
|
|
|
|
@@ -121,6 +122,31 @@ const void SaveFile::SaveGame(){
|
|
|
|
|
saveFile["Save Name"].SetString(std::string(GetSaveFileName()));
|
|
|
|
|
saveFile["Game Time"].SetReal(game->GetRuntime());
|
|
|
|
|
saveFile["TravelingMerchant"].SetString(std::string(Merchant::GetCurrentTravelingMerchant().GetKeyName()));
|
|
|
|
|
|
|
|
|
|
#pragma region Save Keyboard/Controller mappings
|
|
|
|
|
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
|
|
|
|
|
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
|
|
|
|
|
const int menuColCount=2;
|
|
|
|
|
for(int row=0;row<menuRowCount;row++){
|
|
|
|
|
for(int col=0;col<menuColCount;col++){
|
|
|
|
|
int inputID=row*menuColCount+col;
|
|
|
|
|
if(DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==1&&col==1&&row==menuRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
|
|
|
|
|
saveFile["Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(KEY).value().GetKeyCode());
|
|
|
|
|
saveFile["Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(CONTROLLER).value().GetKeyCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const int ingameControlsRowCount=DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2+1;
|
|
|
|
|
const int ingameControlsColCount=2;
|
|
|
|
|
for(int row=0;row<ingameControlsRowCount;row++){
|
|
|
|
|
for(int col=0;col<ingameControlsColCount;col++){
|
|
|
|
|
int inputID=row*menuColCount+col;
|
|
|
|
|
if(DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==1&&col==1&&row==ingameControlsRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
|
|
|
|
|
saveFile["Gameplay Keyboard Input_"+"Inputs.Gameplay Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Gameplay Input Displayer",row,col))->GetInput().GetPrimaryKey(KEY).value().GetKeyCode());
|
|
|
|
|
saveFile["Gameplay Controller Input_"+"Inputs.Gameplay Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Gameplay Input Displayer",row,col))->GetInput().GetPrimaryKey(CONTROLLER).value().GetKeyCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
|
|
utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));
|
|
|
|
|
utils::datafile metadata;
|
|
|
|
|
if(onlineMode){
|
|
|
|
@@ -250,6 +276,46 @@ void SaveFile::LoadFile(){
|
|
|
|
|
game->GetPlayer()->RecalculateEquipStats();
|
|
|
|
|
if(loadFile.HasProperty("TravelingMerchant"))Merchant::SetTravelingMerchant(loadFile["TravelingMerchant"].GetString());
|
|
|
|
|
|
|
|
|
|
#pragma region Load Keyboard/Controller mappings
|
|
|
|
|
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
|
|
|
|
|
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
|
|
|
|
|
const int menuColCount=2;
|
|
|
|
|
for(int row=0;row<menuRowCount;row++){
|
|
|
|
|
for(int col=0;col<menuColCount;col++){
|
|
|
|
|
int inputID=row*menuColCount+col;
|
|
|
|
|
if(DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==1&&col==1&&row==menuRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
|
|
|
|
|
std::string keyName="Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID];
|
|
|
|
|
if(loadFile.HasProperty(keyName)){
|
|
|
|
|
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
|
|
|
|
|
group.SetNewPrimaryKeybind({KEY,loadFile[keyName].GetInt()});
|
|
|
|
|
}
|
|
|
|
|
keyName="Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID];
|
|
|
|
|
if(loadFile.HasProperty(keyName)){
|
|
|
|
|
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
|
|
|
|
|
group.SetNewPrimaryKeybind({CONTROLLER,loadFile[keyName].GetInt()});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const int ingameControlsRowCount=DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2+1;
|
|
|
|
|
const int ingameControlsColCount=2;
|
|
|
|
|
for(int row=0;row<ingameControlsRowCount;row++){
|
|
|
|
|
for(int col=0;col<ingameControlsColCount;col++){
|
|
|
|
|
int inputID=row*ingameControlsColCount+col;
|
|
|
|
|
if(DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==1&&col==1&&row==ingameControlsRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
|
|
|
|
|
std::string keyName="Gameplay Keyboard Input_"+"Inputs.Gameplay Input Names"_s[inputID];
|
|
|
|
|
if(loadFile.HasProperty(keyName)){
|
|
|
|
|
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Gameplay Input Displayer",row,col))->GetInput();
|
|
|
|
|
group.SetNewPrimaryKeybind({KEY,loadFile[keyName].GetInt()});
|
|
|
|
|
}
|
|
|
|
|
keyName="Gameplay Controller Input_"+"Inputs.Gameplay Input Names"_s[inputID];
|
|
|
|
|
if(loadFile.HasProperty(keyName)){
|
|
|
|
|
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Gameplay Input Displayer",row,col))->GetInput();
|
|
|
|
|
group.SetNewPrimaryKeybind({CONTROLLER,loadFile[keyName].GetInt()});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
|
|
GameState::ChangeState(States::OVERWORLD_MAP,0.5f);
|
|
|
|
|
}else{
|
|
|
|
|
std::cout<<std::format("WARNING! File {} does not exist for loading!","save_file_path"_S+std::format("save.{:04}",saveFileID))<<std::endl;
|
|
|
|
|