Ticket #2324: actoreditorpatch.patch

File actoreditorpatch.patch, 6.0 KB (added by wraitii, 10 years ago)
  • source/tools/atlas/AtlasObject/AtlasObjectXML.cpp

     
    182182        size_t last = obj->value.find_last_not_of(whitespace);
    183183        obj->value = obj->value.substr(first, 1+last-first);
    184184    }
    185 
     185   
     186    obj->name = fromXmlChar(node->name);
     187   
    186188    return obj;
    187189}
    188190
  • source/tools/atlas/AtlasObject/AtlasObjectImpl.h

     
    1818#include "AtlasObject.h"
    1919
    2020#include <string>
     21#include <vector>
    2122
    2223#ifdef _MSC_VER
    2324 // Avoid complaints about unreachable code; the optimiser is realising
     
    5859            // time with dozens of friends)
    5960
    6061    std::wstring value;
     62    std::wstring name;
    6163
    6264    typedef std::multimap<const std::string, const AtNode::Ptr> child_maptype;
    6365    typedef std::pair<const std::string, const AtNode::Ptr> child_pairtype;
  • source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp

     
    9999    m_Material = new wxComboBox(materialsPanel, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, materials);
    100100    materialsSizer->Add(m_Material, wxSizerFlags().Border(wxALL, 2));
    101101
     102    Show(true);
     103
    102104}
    103105
    104106void ActorEditor::ThawData(AtObj& in)
     
    261263                var.add("texture", varit["texture"]);
    262264
    263265                AtObj anims;
    264                 for (AtIter animit = varit["animations"]["animation"]; animit.defined(); ++animit)
     266                for (AtIter stateit = varit["animations"]; stateit.defined(); ++stateit)
    265267                {
    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                    }
    272280                }
    273281                var.add("animations", anims);
    274282
     
    291299        actor.set("@version", L"1");
    292300        in.set("actor", actor);
    293301    }
    294     else if (version == 1)
     302    else if (version >= 1)
    295303    {
    296304        // current format
    297305    }
     
    326334    // Export the group/variant/etc data
    327335    AtObj actor (m_ActorEditorListCtrl->ExportData());
    328336
    329     actor.set("@version", L"1");
     337    actor.set("@version", L"2");
    330338
    331339    if (m_CastShadows->IsChecked())
    332340        actor.set("castshadow", L"");
  • source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp

     
    1515 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
    1616 */
    1717
    18 #include "precompiled.h"
    19 
    2018#include "AnimListEditor.h"
    2119
    2220#include "EditableListCtrl/FieldEditCtrl.h"
    2321#include "AtlasObject/AtlasObject.h"
     22#include "AtlasObject/AtlasObjectImpl.h"
    2423
    2524//////////////////////////////////////////////////////////////////////////
    2625
     
    6261: DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    6362                    wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL)
    6463{
     64    AddColumnType(_("State name"), 100, "@statename",  new FieldEditCtrl_Text());
    6565    AddColumnType(_("Anim name"), 100, "@name",  new FieldEditCtrl_List("animations"));
    6666    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());
    6768    AddColumnType(_("Speed"),     50,  "@speed", new FieldEditCtrl_Text());
    6869    AddColumnType(_("Load"),      40,  "@load",  new FieldEditCtrl_Text());
    6970    AddColumnType(_("Event"),     40,  "@event", new FieldEditCtrl_Text());
     
    7172
    7273void AnimListEditorListCtrl::DoImport(AtObj& in)
    7374{
    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    }
    7790    UpdateDisplay();
    7891}
    7992
     
    8194{
    8295    AtObj out;
    8396    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    }
    85110    return out;
    86111}