XML changes

This commit is contained in:
2025-05-10 17:34:16 -05:00
parent 59383ee02b
commit 20f26db42c
2 changed files with 10 additions and 14 deletions

View File

@@ -1079,6 +1079,7 @@ void readEditorStateFromXml(ticpp::Document&& data, cScenario& scenario) {
Iterator<Attribute> attr;
Iterator<Element> elem;
Iterator<Element> child;
std::string child_type;
short num;
location section;
@@ -1096,31 +1097,25 @@ void readEditorStateFromXml(ticpp::Document&& data, cScenario& scenario) {
}else if(type == "editing-town"){
editor_state.editing_town = str_to_bool(elem->GetText());
}else if(type == "town-view-state"){
Element* child = elem->FirstChildElement();
while(child != nullptr){
num = std::stoi(elem->GetAttribute("num"));
for(child = child.begin(elem.Get()); child != child.end(); child++){
child->GetValue(&child_type);
if(child_type == "num"){
child->GetText(&num);
}else if(child_type == "center"){
if(child_type == "center"){
center = readLocFromXml(*child);
}else if(child_type == "viewing-mode"){
child->GetText(&viewing_mode);
}
child = child->NextSiblingElement(false);
}
editor_state.town_view_state[num] = {center, viewing_mode};
}else if(type == "out-view-state"){
Element* child = elem->FirstChildElement();
while(child != nullptr){
section = readLocFromXml(*elem);
for(child = child.begin(elem.Get()); child != child.end(); child++){
child->GetValue(&child_type);
if(child_type == "section"){
section = readLocFromXml(*child);
}else if(child_type == "center"){
if(child_type == "center"){
center = readLocFromXml(*child);
}else if(child_type == "viewing-mode"){
child->GetText(&viewing_mode);
}
child = child->NextSiblingElement(false);
}
editor_state.out_view_state[section] = {center, viewing_mode};
}

View File

@@ -133,7 +133,7 @@ void writeEditorStateToXml(ticpp::Printer&& data, cScenario& scenario) {
data.PushElement("last-town", cur_town);
for(auto pair : scenario.editor_state.town_view_state){
data.OpenElement("town-view-state");
data.PushElement("num", pair.first);
data.PushAttribute("num", pair.first);
data.PushElement("center", pair.second.center);
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
data.CloseElement("town-view-state");
@@ -142,7 +142,8 @@ void writeEditorStateToXml(ticpp::Printer&& data, cScenario& scenario) {
data.PushElement("last-out-section", cur_out);
for(auto pair : scenario.editor_state.out_view_state){
data.OpenElement("out-view-state");
data.PushElement("section", pair.first);
data.PushAttribute("x", pair.first.x);
data.PushAttribute("y", pair.first.y);
data.PushElement("center", pair.second.center);
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
data.CloseElement("out-view-state");