Skip to content

Commit

Permalink
Added basic ActorEditor UI for new <textures> tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoot committed Jun 28, 2012
1 parent ce9c2ae commit 04ccb2f
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 3 deletions.
4 changes: 4 additions & 0 deletions binaries/data/tools/atlas/lists.xml
Expand Up @@ -24,6 +24,10 @@
<item>props_fancy</item>
</attachpoints>

<textures>
<item>baseTex</item>
</textures>

<animations>
<item>idle </item>
<item>walk </item>
Expand Down
Expand Up @@ -20,6 +20,7 @@
#include "ActorEditorListCtrl.h"

#include "AnimListEditor.h"
#include "TexListEditor.h"
#include "PropListEditor.h"

#include "AtlasObject/AtlasObject.h"
Expand Down Expand Up @@ -48,8 +49,8 @@ ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent)
AddColumnType(_("Variant"), 90, "@name", 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(_("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(_("Animations"), 250, "animations", new FieldEditCtrl_Dialog(&AnimListEditor::Create));
AddColumnType(_("Textures"), 250, "textures", new FieldEditCtrl_Dialog(&TexListEditor::Create));
AddColumnType(_("Animations"), 250, "animations", new FieldEditCtrl_Dialog(&AnimListEditor::Create));
AddColumnType(_("Props"), 220, "props", new FieldEditCtrl_Dialog(&PropListEditor::Create));
AddColumnType(_("Colour"), 80, "colour", new FieldEditCtrl_Colour());
}
Expand Down Expand Up @@ -108,7 +109,7 @@ wxListItemAttr* ActorEditorListCtrl::OnGetItemAttr(long item) const

if (row["mesh"].hasContent())
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]);
else if (row["animations"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Anim[item%2]);
Expand Down
83 changes: 83 additions & 0 deletions source/tools/atlas/AtlasUI/ActorEditor/TexListEditor.cpp
@@ -0,0 +1,83 @@
/* 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;
}
56 changes: 56 additions & 0 deletions source/tools/atlas/AtlasUI/ActorEditor/TexListEditor.h
@@ -0,0 +1,56 @@
/* 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();
};

0 comments on commit 04ccb2f

Please sign in to comment.