XML changes
This commit is contained in:
@@ -1079,6 +1079,7 @@ void readEditorStateFromXml(ticpp::Document&& data, cScenario& scenario) {
|
|||||||
Iterator<Attribute> attr;
|
Iterator<Attribute> attr;
|
||||||
Iterator<Element> elem;
|
Iterator<Element> elem;
|
||||||
|
|
||||||
|
Iterator<Element> child;
|
||||||
std::string child_type;
|
std::string child_type;
|
||||||
short num;
|
short num;
|
||||||
location section;
|
location section;
|
||||||
@@ -1096,31 +1097,25 @@ void readEditorStateFromXml(ticpp::Document&& data, cScenario& scenario) {
|
|||||||
}else if(type == "editing-town"){
|
}else if(type == "editing-town"){
|
||||||
editor_state.editing_town = str_to_bool(elem->GetText());
|
editor_state.editing_town = str_to_bool(elem->GetText());
|
||||||
}else if(type == "town-view-state"){
|
}else if(type == "town-view-state"){
|
||||||
Element* child = elem->FirstChildElement();
|
num = std::stoi(elem->GetAttribute("num"));
|
||||||
while(child != nullptr){
|
for(child = child.begin(elem.Get()); child != child.end(); child++){
|
||||||
child->GetValue(&child_type);
|
child->GetValue(&child_type);
|
||||||
if(child_type == "num"){
|
if(child_type == "center"){
|
||||||
child->GetText(&num);
|
|
||||||
}else if(child_type == "center"){
|
|
||||||
center = readLocFromXml(*child);
|
center = readLocFromXml(*child);
|
||||||
}else if(child_type == "viewing-mode"){
|
}else if(child_type == "viewing-mode"){
|
||||||
child->GetText(&viewing_mode);
|
child->GetText(&viewing_mode);
|
||||||
}
|
}
|
||||||
child = child->NextSiblingElement(false);
|
|
||||||
}
|
}
|
||||||
editor_state.town_view_state[num] = {center, viewing_mode};
|
editor_state.town_view_state[num] = {center, viewing_mode};
|
||||||
}else if(type == "out-view-state"){
|
}else if(type == "out-view-state"){
|
||||||
Element* child = elem->FirstChildElement();
|
section = readLocFromXml(*elem);
|
||||||
while(child != nullptr){
|
for(child = child.begin(elem.Get()); child != child.end(); child++){
|
||||||
child->GetValue(&child_type);
|
child->GetValue(&child_type);
|
||||||
if(child_type == "section"){
|
if(child_type == "center"){
|
||||||
section = readLocFromXml(*child);
|
|
||||||
}else if(child_type == "center"){
|
|
||||||
center = readLocFromXml(*child);
|
center = readLocFromXml(*child);
|
||||||
}else if(child_type == "viewing-mode"){
|
}else if(child_type == "viewing-mode"){
|
||||||
child->GetText(&viewing_mode);
|
child->GetText(&viewing_mode);
|
||||||
}
|
}
|
||||||
child = child->NextSiblingElement(false);
|
|
||||||
}
|
}
|
||||||
editor_state.out_view_state[section] = {center, viewing_mode};
|
editor_state.out_view_state[section] = {center, viewing_mode};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ void writeEditorStateToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|||||||
data.PushElement("last-town", cur_town);
|
data.PushElement("last-town", cur_town);
|
||||||
for(auto pair : scenario.editor_state.town_view_state){
|
for(auto pair : scenario.editor_state.town_view_state){
|
||||||
data.OpenElement("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("center", pair.second.center);
|
||||||
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
|
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
|
||||||
data.CloseElement("town-view-state");
|
data.CloseElement("town-view-state");
|
||||||
@@ -142,7 +142,8 @@ void writeEditorStateToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|||||||
data.PushElement("last-out-section", cur_out);
|
data.PushElement("last-out-section", cur_out);
|
||||||
for(auto pair : scenario.editor_state.out_view_state){
|
for(auto pair : scenario.editor_state.out_view_state){
|
||||||
data.OpenElement("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("center", pair.second.center);
|
||||||
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
|
data.PushElement("viewing-mode", pair.second.cur_viewing_mode);
|
||||||
data.CloseElement("out-view-state");
|
data.CloseElement("out-view-state");
|
||||||
|
|||||||
Reference in New Issue
Block a user