1
0
forked from 0ad/0ad

Update actor editor for data driven textures. From zoot. Refs #1493.

This was SVN commit r12184.
This commit is contained in:
Jonathan Waller 2012-07-23 22:51:20 +00:00
parent f598101c34
commit 1f15257987
4 changed files with 149 additions and 3 deletions

View File

@ -24,6 +24,10 @@
<item>props_fancy</item> <item>props_fancy</item>
</attachpoints> </attachpoints>
<textures>
<item>baseTex</item>
</textures>
<animations> <animations>
<item>idle </item> <item>idle </item>
<item>walk </item> <item>walk </item>

View File

@ -20,6 +20,7 @@
#include "ActorEditorListCtrl.h" #include "ActorEditorListCtrl.h"
#include "AnimListEditor.h" #include "AnimListEditor.h"
#include "TexListEditor.h"
#include "PropListEditor.h" #include "PropListEditor.h"
#include "AtlasObject/AtlasObject.h" #include "AtlasObject/AtlasObject.h"
@ -48,7 +49,7 @@ ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent)
AddColumnType(_("Variant"), 90, "@name", new FieldEditCtrl_Text()); AddColumnType(_("Variant"), 90, "@name", new FieldEditCtrl_Text());
AddColumnType(_("Ratio"), 50, "@frequency", new FieldEditCtrl_Text()); AddColumnType(_("Ratio"), 50, "@frequency", new FieldEditCtrl_Text());
AddColumnType(_("Model"), 140, "mesh", new FieldEditCtrl_File(_T("art/meshes/"), _("Mesh files (*.pmd, *.dae)|*.pmd;*.dae|All files (*.*)|*.*"))); AddColumnType(_("Model"), 140, "mesh", new FieldEditCtrl_File(_T("art/meshes/"), _("Mesh files (*.pmd, *.dae)|*.pmd;*.dae|All files (*.*)|*.*")));
AddColumnType(_("Texture"), 140, "texture", new FieldEditCtrl_File(_T("art/textures/skins/"), _("All files (*.*)|*.*"))); // could be dds, or tga, or png, or bmp, etc, so just allow * AddColumnType(_("Textures"), 250, "textures", new FieldEditCtrl_Dialog(&TexListEditor::Create));
AddColumnType(_("Animations"), 250, "animations", new FieldEditCtrl_Dialog(&AnimListEditor::Create)); AddColumnType(_("Animations"), 250, "animations", new FieldEditCtrl_Dialog(&AnimListEditor::Create));
AddColumnType(_("Props"), 220, "props", new FieldEditCtrl_Dialog(&PropListEditor::Create)); AddColumnType(_("Props"), 220, "props", new FieldEditCtrl_Dialog(&PropListEditor::Create));
AddColumnType(_("Colour"), 80, "colour", new FieldEditCtrl_Colour()); AddColumnType(_("Colour"), 80, "colour", new FieldEditCtrl_Colour());
@ -108,7 +109,7 @@ wxListItemAttr* ActorEditorListCtrl::OnGetItemAttr(long item) const
if (row["mesh"].hasContent()) if (row["mesh"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Model[item%2]); return const_cast<wxListItemAttr*>(&m_ListItemAttr_Model[item%2]);
else if (row["texture"].hasContent()) else if (row["textures"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Texture[item%2]); return const_cast<wxListItemAttr*>(&m_ListItemAttr_Texture[item%2]);
else if (row["animations"].hasContent()) else if (row["animations"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Anim[item%2]); return const_cast<wxListItemAttr*>(&m_ListItemAttr_Anim[item%2]);

View File

@ -0,0 +1,84 @@
/* Copyright (C) 2009 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#include "precompiled.h"
#include "TexListEditor.h"
#include "EditableListCtrl/FieldEditCtrl.h"
#include "AtlasObject/AtlasObject.h"
//////////////////////////////////////////////////////////////////////////
TexListEditor::TexListEditor(wxWindow* parent)
: AtlasDialog(parent, _("Texture editor"), wxSize(480, 280))
{
m_MainListBox = new TexListEditorListCtrl(m_MainPanel);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_MainListBox,
wxSizerFlags().Proportion(1).Expand().Border(wxALL, 5));
m_MainPanel->SetSizer(sizer);
}
void TexListEditor::ThawData(AtObj& in)
{
m_MainListBox->ThawData(in);
}
AtObj TexListEditor::FreezeData()
{
return m_MainListBox->FreezeData();
}
void TexListEditor::ImportData(AtObj& in)
{
m_MainListBox->ImportData(in);
}
AtObj TexListEditor::ExportData()
{
return m_MainListBox->ExportData();
}
//////////////////////////////////////////////////////////////////////////
TexListEditorListCtrl::TexListEditorListCtrl(wxWindow* parent)
: DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL)
{
AddColumnType(_("Tex name"), 100, "@name", new FieldEditCtrl_List("textures"));
AddColumnType(_("File"), 200, "@file", new FieldEditCtrl_File(_T("art/textures/skins/"), _("All files (*.*)|*.*"))); // could be dds, or tga, or png, or bmp, etc, so just allow *
}
void TexListEditorListCtrl::DoImport(AtObj& in)
{
for (AtIter prop = in["texture"]; prop.defined(); ++prop)
AddRow(prop);
UpdateDisplay();
}
AtObj TexListEditorListCtrl::DoExport()
{
AtObj out;
for (size_t i = 0; i < m_ListData.size(); ++i)
out.add("texture", m_ListData[i]);
return out;
}

View File

@ -0,0 +1,57 @@
/* Copyright (C) 2009 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Windows/AtlasDialog.h"
#include "DraggableListCtrl/DraggableListCtrl.h"
class TexListEditorListCtrl;
//////////////////////////////////////////////////////////////////////////
class TexListEditor : public AtlasDialog
{
public:
TexListEditor(wxWindow* parent);
static AtlasDialog* Create(wxWindow* parent) { return new TexListEditor(parent); }
protected:
AtObj FreezeData();
void ThawData(AtObj& in);
AtObj ExportData();
void ImportData(AtObj& in);
private:
TexListEditorListCtrl* m_MainListBox;
};
//////////////////////////////////////////////////////////////////////////
class TexListEditorListCtrl : public DraggableListCtrl
{
friend class TexListEditor;
public:
TexListEditorListCtrl(wxWindow* parent);
void OnUpdate(wxCommandEvent& event);
void DoImport(AtObj& in);
AtObj DoExport();
};