Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 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 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
QUERYHANDLER(GetObjectMapSettings) | QUERYHANDLER(GetObjectMapSettings) | ||||
{ | { | ||||
std::vector<entity_id_t> ids = *msg->ids; | std::vector<entity_id_t> ids = *msg->ids; | ||||
CmpPtr<ICmpTemplateManager> cmpTemplateManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY); | CmpPtr<ICmpTemplateManager> cmpTemplateManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY); | ||||
ENSURE(cmpTemplateManager); | ENSURE(cmpTemplateManager); | ||||
XML_Start(); | XMLWriter_File exampleFile; | ||||
{ | { | ||||
XML_Element("Entities"); | XMLWriter_Element entitiesTag(exampleFile, "Entities"); | ||||
{ | { | ||||
for (entity_id_t id : ids) | for (entity_id_t id : ids) | ||||
{ | { | ||||
XML_Element("Entity"); | XMLWriter_Element entityTag(exampleFile, "Entity"); | ||||
{ | { | ||||
//Template name | //Template name | ||||
XML_Setting("Template", cmpTemplateManager->GetCurrentTemplateName(id)); | entityTag.Setting("Template", cmpTemplateManager->GetCurrentTemplateName(id)); | ||||
//Player | //Player | ||||
CmpPtr<ICmpOwnership> cmpOwnership(*g_Game->GetSimulation2(), id); | CmpPtr<ICmpOwnership> cmpOwnership(*g_Game->GetSimulation2(), id); | ||||
if (cmpOwnership) | if (cmpOwnership) | ||||
XML_Setting("Player", (int)cmpOwnership->GetOwner()); | entityTag.Setting("Player", static_cast<int>(cmpOwnership->GetOwner())); | ||||
//Adding position to make some relative position later | //Adding position to make some relative position later | ||||
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); | CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); | ||||
if (cmpPosition) | if (cmpPosition) | ||||
{ | { | ||||
CFixedVector3D pos = cmpPosition->GetPosition(); | CFixedVector3D pos = cmpPosition->GetPosition(); | ||||
CFixedVector3D rot = cmpPosition->GetRotation(); | CFixedVector3D rot = cmpPosition->GetRotation(); | ||||
{ | { | ||||
XML_Element("Position"); | XMLWriter_Element positionTag(exampleFile, "Position"); | ||||
XML_Attribute("x", pos.X); | positionTag.Attribute("x", pos.X); | ||||
XML_Attribute("z", pos.Z); | positionTag.Attribute("z", pos.Z); | ||||
// TODO: height offset etc | // TODO: height offset etc | ||||
} | } | ||||
{ | { | ||||
XML_Element("Orientation"); | XMLWriter_Element orientationTag(exampleFile, "Orientation"); | ||||
XML_Attribute("y", rot.Y); | orientationTag.Attribute("y", rot.Y); | ||||
// TODO: X, Z maybe | // TODO: X, Z maybe | ||||
} | } | ||||
} | } | ||||
// Adding actor seed | // Adding actor seed | ||||
CmpPtr<ICmpVisual> cmpVisual(*g_Game->GetSimulation2(), id); | CmpPtr<ICmpVisual> cmpVisual(*g_Game->GetSimulation2(), id); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
XML_Setting("ActorSeed", (unsigned int)cmpVisual->GetActorSeed()); | entityTag.Setting("ActorSeed", static_cast<unsigned int>(cmpVisual->GetActorSeed())); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
const CStr& data = XML_GetOutput(); | const CStr& data = exampleFile.GetOutput(); | ||||
msg->xmldata = std::wstring(data.begin(), data.end()); | msg->xmldata = std::wstring(data.begin(), data.end()); | ||||
} | } | ||||
BEGIN_COMMAND(SetObjectSettings) | BEGIN_COMMAND(SetObjectSettings) | ||||
{ | { | ||||
player_id_t m_PlayerOld, m_PlayerNew; | player_id_t m_PlayerOld, m_PlayerNew; | ||||
std::set<CStr> m_SelectionsOld, m_SelectionsNew; | std::set<CStr> m_SelectionsOld, m_SelectionsNew; | ||||
▲ Show 20 Lines • Show All 811 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator