Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp
/* Copyright (C) 2020 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 15 Lines | |||||
#include "AtlasObject/AtlasObject.h" | #include "AtlasObject/AtlasObject.h" | ||||
#include "AtlasObject/AtlasObjectText.h" | #include "AtlasObject/AtlasObjectText.h" | ||||
#include "General/Datafile.h" | #include "General/Datafile.h" | ||||
#ifdef __WXMAC__ | #ifdef __WXMAC__ | ||||
#include <ApplicationServices/ApplicationServices.h> | #include <ApplicationServices/ApplicationServices.h> | ||||
#endif | #endif | ||||
#include "wx/file.h" | #include "wx/file.h" | ||||
BEGIN_EVENT_TABLE(ActorEditor, AtlasWindow) | BEGIN_EVENT_TABLE(ActorEditor, AtlasWindow) | ||||
Lint: unknownMacro: There is an unknown macro here somewhere. Configuration is required. If BEGIN_EVENT_TABLE is a… | |||||
EVT_MENU(ID_CreateEntity, ActorEditor::OnCreateEntity) | EVT_MENU(ID_CreateEntity, ActorEditor::OnCreateEntity) | ||||
END_EVENT_TABLE() | END_EVENT_TABLE() | ||||
ActorEditor::ActorEditor(wxWindow* parent) | ActorEditor::ActorEditor(wxWindow* parent) | ||||
: AtlasWindow(parent, _("Actor Editor"), wxSize(1024, 450)) | : AtlasWindow(parent, _("Actor Editor"), wxSize(1024, 450)) | ||||
{ | { | ||||
SetIcon(wxIcon(_T("ICON_ActorEditor"))); | SetIcon(wxIcon(_T("ICON_ActorEditor"))); | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | static AtObj ConvertToLatestFormat(AtObj in) | ||||
// Determine the file format version | // Determine the file format version | ||||
long version; | long version; | ||||
if (in["Object"].defined()) | if (in["Object"].defined()) | ||||
{ | { | ||||
// old-style actor format | // old-style actor format | ||||
version = -1; | version = -1; | ||||
} | } | ||||
else if (in["qualitylevels"].defined()) | |||||
{ | |||||
// New-style, multiple-quality-levels actor. | |||||
wxLogError(_("Cannot edit actors with multiple quality levels. If you want to use the actor editor, use the `<actor file=\"\">` format and edit the referenced files.")); | |||||
return AtObj(); | |||||
} | |||||
else if (in["actor"].defined()) | else if (in["actor"].defined()) | ||||
version = (in["actor"]["@version"].defined()) ? (*in["actor"]["@version"]).getLong() : 0; | version = (in["actor"]["@version"].defined()) ? (*in["actor"]["@version"]).getLong() : 0; | ||||
else | else | ||||
{ | { | ||||
wxLogError(_("Failed to determine actor file format version")); | wxLogError(_("Failed to determine actor file format version")); | ||||
return AtObj(); | return AtObj(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | void ActorEditor::ImportData(AtObj& in) | ||||
if (! data.defined()) | if (! data.defined()) | ||||
return; | return; | ||||
// Copy the data into the appropriate UI controls: | // Copy the data into the appropriate UI controls: | ||||
AtObj actor (*data["actor"]); | AtObj actor (*data["actor"]); | ||||
m_ActorEditorListCtrl->ImportData(actor); | m_ActorEditorListCtrl->ImportData(actor); | ||||
m_Actor = actor; | |||||
m_CastShadows->SetValue(actor["castshadow"].defined()); | m_CastShadows->SetValue(actor["castshadow"].defined()); | ||||
m_Float->SetValue(actor["float"].defined()); | m_Float->SetValue(actor["float"].defined()); | ||||
m_Material->SetValue((wxString)actor["material"]); | m_Material->SetValue((wxString)actor["material"]); | ||||
} | } | ||||
AtObj ActorEditor::ExportData() | AtObj ActorEditor::ExportData() | ||||
{ | { | ||||
// Export the group/variant/etc data | // Export the group/variant/etc data | ||||
AtObj actor (m_ActorEditorListCtrl->ExportData()); | AtObj actor (m_ActorEditorListCtrl->ExportData()); | ||||
actor.set("@version", "1"); | actor.set("@version", "1"); | ||||
if (m_CastShadows->IsChecked()) | |||||
AtObj castShadow = *m_Actor["castshadow"]; | |||||
if (m_CastShadows->IsChecked() && castShadow.defined()) | |||||
actor.set("castshadow", castShadow); | |||||
else if (m_CastShadows->IsChecked()) | |||||
actor.set("castshadow", ""); | actor.set("castshadow", ""); | ||||
if (m_Float->IsChecked()) | AtObj floatObj = *m_Actor["float"]; | ||||
if (m_Float->IsChecked() && floatObj) | |||||
actor.set("float", floatObj); | |||||
else if (m_Float->IsChecked()) | |||||
actor.set("float", ""); | actor.set("float", ""); | ||||
AtObj material = *m_Actor["material"]; | |||||
actor.set("material", material); | |||||
if (m_Material->GetValue().length()) | if (m_Material->GetValue().length()) | ||||
actor.set("material", m_Material->GetValue()); | actor.set("material", m_Material->GetValue()); | ||||
AtObj out; | AtObj out; | ||||
out.set("actor", actor); | out.set("actor", actor); | ||||
return out; | return out; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
There is an unknown macro here somewhere. Configuration is required. If BEGIN_EVENT_TABLE is a macro then please configure it.