Ticket #2324: actoreditorpatch.patch
File actoreditorpatch.patch, 6.0 KB (added by , 10 years ago) |
---|
-
source/tools/atlas/AtlasObject/AtlasObjectXML.cpp
182 182 size_t last = obj->value.find_last_not_of(whitespace); 183 183 obj->value = obj->value.substr(first, 1+last-first); 184 184 } 185 185 186 obj->name = fromXmlChar(node->name); 187 186 188 return obj; 187 189 } 188 190 -
source/tools/atlas/AtlasObject/AtlasObjectImpl.h
18 18 #include "AtlasObject.h" 19 19 20 20 #include <string> 21 #include <vector> 21 22 22 23 #ifdef _MSC_VER 23 24 // Avoid complaints about unreachable code; the optimiser is realising … … 58 59 // time with dozens of friends) 59 60 60 61 std::wstring value; 62 std::wstring name; 61 63 62 64 typedef std::multimap<const std::string, const AtNode::Ptr> child_maptype; 63 65 typedef std::pair<const std::string, const AtNode::Ptr> child_pairtype; -
source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp
99 99 m_Material = new wxComboBox(materialsPanel, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, materials); 100 100 materialsSizer->Add(m_Material, wxSizerFlags().Border(wxALL, 2)); 101 101 102 Show(true); 103 102 104 } 103 105 104 106 void ActorEditor::ThawData(AtObj& in) … … 261 263 var.add("texture", varit["texture"]); 262 264 263 265 AtObj anims; 264 for (AtIter animit = varit["animations"]["animation"]; animit.defined(); ++animit)266 for (AtIter stateit = varit["animations"]; stateit.defined(); ++stateit) 265 267 { 266 AtObj anim; 267 anim.add("@name", animit["name"]); 268 anim.add("@file", animit["file"]); 269 anim.add("@speed", animit["speed"]); 270 271 anims.add("animation", anim); 268 AtObj state; 269 for (AtIter animit = varit["animations"]["animation"]; animit.defined(); ++animit) 270 { 271 AtObj anim; 272 anim.add("@statename", stateit["name"]); 273 anim.add("@name", animit["name"]); 274 anim.add("@file", animit["file"]); 275 anim.add("@frequency", animit["frequency"]); 276 anim.add("@speed", animit["speed"]); 277 278 anims.add("animation", anim); 279 } 272 280 } 273 281 var.add("animations", anims); 274 282 … … 291 299 actor.set("@version", L"1"); 292 300 in.set("actor", actor); 293 301 } 294 else if (version == 1)302 else if (version >= 1) 295 303 { 296 304 // current format 297 305 } … … 326 334 // Export the group/variant/etc data 327 335 AtObj actor (m_ActorEditorListCtrl->ExportData()); 328 336 329 actor.set("@version", L" 1");337 actor.set("@version", L"2"); 330 338 331 339 if (m_CastShadows->IsChecked()) 332 340 actor.set("castshadow", L""); -
source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp
15 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 17 18 #include "precompiled.h"19 20 18 #include "AnimListEditor.h" 21 19 22 20 #include "EditableListCtrl/FieldEditCtrl.h" 23 21 #include "AtlasObject/AtlasObject.h" 22 #include "AtlasObject/AtlasObjectImpl.h" 24 23 25 24 ////////////////////////////////////////////////////////////////////////// 26 25 … … 62 61 : DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 63 62 wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL) 64 63 { 64 AddColumnType(_("State name"), 100, "@statename", new FieldEditCtrl_Text()); 65 65 AddColumnType(_("Anim name"), 100, "@name", new FieldEditCtrl_List("animations")); 66 66 AddColumnType(_("File"), 200, "@file", new FieldEditCtrl_File(_T("art/animation/"), _("Animation files (*.psa, *.dae)|*.psa;*.dae|All files (*.*)|*.*"))); 67 AddColumnType(_("Frequency"), 100, "@frequency", new FieldEditCtrl_Text()); 67 68 AddColumnType(_("Speed"), 50, "@speed", new FieldEditCtrl_Text()); 68 69 AddColumnType(_("Load"), 40, "@load", new FieldEditCtrl_Text()); 69 70 AddColumnType(_("Event"), 40, "@event", new FieldEditCtrl_Text()); … … 71 72 72 73 void AnimListEditorListCtrl::DoImport(AtObj& in) 73 74 { 74 for (AtIter prop = in["animation"]; prop.defined(); ++prop) 75 AddRow(prop); 76 75 for (std::multimap<const std::string, const AtNode::Ptr>::const_iterator it = in.p->children.begin(); it != in.p->children.end(); it++) 76 { 77 for (std::multimap<const std::string, const AtNode::Ptr>::const_iterator it2 = it->second->children.begin(); it2 != it->second->children.end(); it2++) 78 { 79 AtObj newObj; 80 newObj.add("@statename",it->second->name.c_str()); 81 newObj.add("@name",*(it2->second->getChild("@name"))); 82 newObj.add("@file",*(it2->second->getChild("@file"))); 83 newObj.add("@frequency",*(it2->second->getChild("@frequency"))); 84 newObj.add("@speed",*(it2->second->getChild("@speed"))); 85 newObj.add("@load",*(it2->second->getChild("@load"))); 86 newObj.add("@event",*(it2->second->getChild("@event"))); 87 AddRow(newObj); 88 } 89 } 77 90 UpdateDisplay(); 78 91 } 79 92 … … 81 94 { 82 95 AtObj out; 83 96 for (size_t i = 0; i < m_ListData.size(); ++i) 84 out.add("animation", m_ListData[i]); 97 { 98 std::wstring statename = m_ListData[i].p->children.find("@statename")->second->value; 99 std::string str( statename.begin(), statename.end() ); 100 101 const AtNode* nnode = new AtNode(); 102 AtNode::Ptr newNode(nnode); 103 104 AtNode::child_pairtype obj = AtNode::child_pairtype(str, newNode); 105 AtNode::child_maptype(out.p->children).insert(obj); // <- segfaults here. 106 //out.add("animation", m_ListData[i]); 107 (*(out[str.c_str()])).p->addChild("animation", m_ListData[i].p); 108 // (*(out.p->getChild(str.c_str()).add("animation", m_ListData[i]); 109 } 85 110 return out; 86 111 }