Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 31 Lines | ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent) | ||||
COLOR(Texture, (f,e,e), (f,c,c)); | COLOR(Texture, (f,e,e), (f,c,c)); | ||||
COLOR(Anim, (e,f,e), (c,f,c)); | COLOR(Anim, (e,f,e), (c,f,c)); | ||||
COLOR(Prop, (e,e,f), (c,c,f)); | COLOR(Prop, (e,e,f), (c,c,f)); | ||||
COLOR(Color, (f,e,f), (f,c,f)); | COLOR(Color, (f,e,f), (f,c,f)); | ||||
COLOR(None, (f,f,f), (f,f,f)); | COLOR(None, (f,f,f), (f,f,f)); | ||||
#undef COLOR | #undef COLOR | ||||
AddColumnType(_("Group"), 50, "@group", new FieldEditCtrl_Boolean()); | |||||
AddColumnType(_("Variant"), 90, "@name", new FieldEditCtrl_Text()); | AddColumnType(_("Variant"), 90, "@name", new FieldEditCtrl_Text()); | ||||
AddColumnType(_("Base File"), 90, "@file", new FieldEditCtrl_File(_T("art/variants/"), _("Variants (*.xml)|*.xml|All files (*.*)|*.*"))); | AddColumnType(_("Base File"), 90, "@file", new FieldEditCtrl_File(_T("art/variants/"), _("Variants (*.xml)|*.xml|All files (*.*)|*.*"))); | ||||
AddColumnType(_("Ratio"), 50, "@frequency", new FieldEditCtrl_Text()); | AddColumnType(_("Ratio"), 50, "@frequency", new FieldEditCtrl_Text()); | ||||
AddColumnType(_("Min Quality"),50, "@minquality",new FieldEditCtrl_Text()); | |||||
AddColumnType(_("Max Quality"),50, "@maxquality",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(_("Particles"), 90, "particles", new FieldEditCtrl_File(_T("art/particles/"), _("Particle file (*.xml)|*.xml|All files (*.*)|*.*"))); | AddColumnType(_("Particles"), 90, "particles", new FieldEditCtrl_File(_T("art/particles/"), _("Particle file (*.xml)|*.xml|All files (*.*)|*.*"))); | ||||
AddColumnType(_("Textures"), 250, "textures", new FieldEditCtrl_Dialog(&TexListEditor::Create)); | 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(_("Color"), 80, "color", new FieldEditCtrl_Color()); | AddColumnType(_("Color"), 80, "color", new FieldEditCtrl_Color()); | ||||
} | } | ||||
void ActorEditorListCtrl::DoImport(AtObj& in) | void ActorEditorListCtrl::DoImport(AtObj& in) | ||||
{ | { | ||||
DeleteData(); | DeleteData(); | ||||
for (AtIter group = in["group"]; group.defined(); ++group) | for (AtIter group = in["group"]; group.defined(); ++group) | ||||
{ | { | ||||
for (AtIter variant = group["variant"]; variant.defined(); ++variant) | for (AtIter variant = group["variant"]; variant.defined(); ++variant) | ||||
AddRow(variant); | AddRow(variant); | ||||
AtObj blank; | AtObj gr = *group; | ||||
AddRow(blank); | gr.add("@group", "true"); | ||||
AddRow(gr); | |||||
} | } | ||||
UpdateDisplay(); | UpdateDisplay(); | ||||
} | } | ||||
AtObj ActorEditorListCtrl::DoExport() | AtObj ActorEditorListCtrl::DoExport() | ||||
{ | { | ||||
AtObj out; | AtObj out; | ||||
AtObj group; | AtObj group; | ||||
for (size_t i = 0; i < m_ListData.size(); ++i) | for (size_t i = 0; i < m_ListData.size(); ++i) | ||||
{ | { | ||||
if (IsRowBlank((int)i)) | if (std::string(m_ListData[i]["@group"]) == "true") | ||||
{ | { | ||||
if (group.defined()) | if (group.defined()) | ||||
{ | |||||
group.unset("@group"); | |||||
if (m_ListData[i]["@minquality"].hasContent()) | |||||
group.set("@minquality", m_ListData[i]["@minquality"]); | |||||
if (m_ListData[i]["@maxquality"].hasContent()) | |||||
group.set("@maxquality", m_ListData[i]["@maxquality"]); | |||||
out.add("group", group); | out.add("group", group); | ||||
} | |||||
group = AtObj(); | group = AtObj(); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
AtObj variant = AtlasObject::TrimEmptyChildren(m_ListData[i]); | AtObj variant = AtlasObject::TrimEmptyChildren(m_ListData[i]); | ||||
group.add("variant", variant); | group.add("variant", variant); | ||||
} | } | ||||
} | } | ||||
Show All 30 Lines |
Wildfire Games · Phabricator