allow recording action with multiple parameters

This commit is contained in:
2024-07-03 21:44:49 -06:00
committed by Celtic Minstrel
parent d23d5c5857
commit a0be5abc08
2 changed files with 15 additions and 0 deletions

View File

@@ -65,6 +65,19 @@ void record_action(std::string action_type, std::string inner_text) {
log_document.SaveFile(log_file);
}
void record_action(std::string action_type, std::map<std::string,std::string> info) {
Element* root = log_document.FirstChildElement();
Element next_action(action_type);
for(auto& p : info){
Element next_child(p.first);
Text child_text(p.second);
next_child.InsertEndChild(child_text);
next_action.InsertEndChild(next_child);
}
root->InsertEndChild(next_action);
log_document.SaveFile(log_file);
}
bool has_next_action() {
Element* root = log_document.FirstChildElement();
return root->FirstChildElement(false) != NULL;

View File

@@ -3,6 +3,7 @@
#include <string>
#include <sstream>
#include <map>
#include <boost/filesystem.hpp>
// Input recording system
@@ -14,6 +15,7 @@ extern bool replaying;
extern bool init_action_log(std::string command, std::string file);
extern void record_action(std::string action_type, std::string inner_text);
extern void record_action(std::string action_type, std::map<std::string,std::string> info);
extern bool has_next_action();
extern Element* pop_next_action(std::string expected_action_type="");
extern std::string encode_file(fs::path file);