本文整理汇总了C++中atlas::message::Element::isMap方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::isMap方法的具体用法?C++ Element::isMap怎么用?C++ Element::isMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atlas::message::Element
的用法示例。
在下文中一共展示了Element::isMap方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AdapterBase
TerrainModAdapter::TerrainModAdapter(const ::Atlas::Message::Element& element, CEGUI::PushButton* showButton, EmberEntity* entity, CEGUI::Combobox* posTypeCombobox, CEGUI::Combobox* modTypeCombobox, CEGUI::Editbox* heightTextbox)
: AdapterBase(element), mEntity(entity), mPolygonAdapter(0), mHeightTextbox(heightTextbox), mTerrainModsBinder(modTypeCombobox), mPositioningsBinder(posTypeCombobox)
{
if (element.isMap()) {
const ::Atlas::Message::MapType& areaData(element.asMap());
::Atlas::Message::MapType::const_iterator I = areaData.find("shape");
if (I != areaData.end()) {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(I->second, showButton, entity));
} else {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(::Atlas::Message::Element(), showButton, entity));
}
} else {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(::Atlas::Message::Element(), showButton, entity));
}
if (heightTextbox) {
addGuiEventConnection(heightTextbox->subscribeEvent(CEGUI::Window::EventTextChanged, CEGUI::Event::Subscriber(&TerrainModAdapter::heightTextbox_TextChanged, this)));
}
mTerrainModsBinder.addType("levelmod", "Level", LevelTerrainMod());
mTerrainModsBinder.addType("adjustmod", "Adjust", AdjustTerrainMod());
mPositioningsBinder.addType("height", "Fixed", FixedPositioning());
mPositioningsBinder.addType("heightoffset", "Relative", RelativePositioning());
updateGui(element);
}
示例2: submitChanges
void EntityEditor::submitChanges()
{
if (mRootAdapter->hasChanges()) {
Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements();
if (rootElement.isMap()) {
std::map<std::string, ::Atlas::Message::Element> attributes(rootElement.asMap());
if (attributes.size()) {
std::stringstream ss;
Atlas::Message::QueuedDecoder decoder;
Atlas::Codecs::XML codec(ss, decoder);
Atlas::Formatter formatter(ss, codec);
Atlas::Message::Encoder encoder(formatter);
formatter.streamBegin();
encoder.streamMessageElement(attributes);
formatter.streamEnd();
S_LOG_VERBOSE("Sending attribute update to server:\n" << ss.str());
EmberServices::getSingleton().getServerService().setAttributes(&mEntity, attributes);
}
}
}
}
示例3: updateGui
void TerrainModAdapter::updateGui(const ::Atlas::Message::Element& element)
{
mPositioningsBinder.sync();
mTerrainModsBinder.sync();
if (element.isMap()) {
const ::Atlas::Message::MapType& mapElement = element.asMap();
::Atlas::Message::MapType::const_iterator I = mapElement.find("height");
float height = 0;
if (I != mapElement.end()) {
mPositioningsBinder.select("height");
if (I->second.isNum()) {
height = I->second.asNum();
}
} else {
I = mapElement.find("heightoffset");
if (I != mapElement.end()) {
mPositioningsBinder.select("heightoffset");
if (I->second.isNum()) {
height = I->second.asNum();
}
}
}
std::stringstream ss;
ss << height;
mHeightTextbox->setText(ss.str());
I = mapElement.find("type");
if (I != mapElement.end() && I->second.isString()) {
mTerrainModsBinder.select(I->second.asString());
}
}
}
示例4: mLayer
AreaAdapter::AreaAdapter(const ::Atlas::Message::Element& element, CEGUI::PushButton* showButton, CEGUI::Combobox* layerWindow, EmberEntity* entity) :
AdapterBase(element), mLayer(0), mLayerWindow(layerWindow), mEntity(entity), mPolygonAdapter(nullptr)
{
if (element.isMap()) {
const ::Atlas::Message::MapType& areaData(element.asMap());
::Atlas::Message::MapType::const_iterator shapeI = areaData.find("shape");
if (shapeI != areaData.end()) {
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(shapeI->second, showButton, entity));
} else {
::Atlas::Message::MapType defaultShape;
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(getDefaultPolygon().toAtlas(), showButton, entity));
}
WFMath::Polygon<2> poly;
Terrain::TerrainAreaParser parser;
parser.parseArea(areaData, poly, mLayer);
} else {
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(getDefaultPolygon().toAtlas(), showButton, entity));
}
if (mLayerWindow) {
addGuiEventConnection(mLayerWindow->subscribeEvent(CEGUI::Combobox::EventListSelectionChanged, CEGUI::Event::Subscriber(&AreaAdapter::layerWindow_ListSelectionChanged, this)));
}
updateGui(mOriginalValue);
}
示例5: parseTerrain
TerrainDefPointStore TerrainParser::parseTerrain(const Atlas::Message::Element& terrain, const WFMath::Point<3>& offset) const
{
//_fpreset();
if (!terrain.isMap()) {
S_LOG_FAILURE("Terrain is not a map");
}
const Atlas::Message::MapType & tmap = terrain.asMap();
Atlas::Message::MapType::const_iterator I = tmap.find("points");
if (I == tmap.end()) {
S_LOG_FAILURE("No terrain points");
}
Terrain::TerrainDefPointStore pointStore;
if (I->second.isList()) {
// Legacy support for old list format.
const Atlas::Message::ListType& plist = I->second.asList();
Atlas::Message::ListType::const_iterator J = plist.begin();
for (; J != plist.end(); ++J) {
if (!J->isList()) {
S_LOG_INFO("Non list in points");
continue;
}
const Atlas::Message::ListType & point = J->asList();
if (point.size() != 3) {
S_LOG_INFO("Point without 3 nums.");
continue;
}
Terrain::TerrainDefPoint defPoint(static_cast<int> (point[0].asNum() + offset.x()), static_cast<int> (point[1].asNum() + offset.y()), static_cast<float> (point[3].asNum() + offset.z()));
pointStore.push_back(defPoint);
}
} else if (I->second.isMap()) {
const Atlas::Message::MapType& plist = I->second.asMap();
Atlas::Message::MapType::const_iterator J = plist.begin();
for (; J != plist.end(); ++J) {
if (!J->second.isList()) {
S_LOG_INFO("Non list in points.");
continue;
}
const Atlas::Message::ListType & point = J->second.asList();
if (point.size() != 3) {
S_LOG_INFO("Point without 3 nums.");
continue;
}
int x = static_cast<int> (point[0].asNum());
int y = static_cast<int> (point[1].asNum());
float z = point[2].asNum();
Terrain::TerrainDefPoint defPoint(x + offset.x(), y + offset.y(), z + offset.z());
pointStore.push_back(defPoint);
}
} else {
S_LOG_FAILURE("Terrain is the wrong type");
}
return pointStore;
}
示例6: entityTerrainModAttrChanged
void TerrainEntityManager::entityTerrainModAttrChanged(EmberEntity& entity, const Atlas::Message::Element& value)
{
if (value.isMap() && mTerrainMods.find(&entity) == mTerrainMods.end()) {
Terrain::TerrainMod* mod = new Terrain::TerrainMod(entity, value.Map());
mod->init();
mTerrainMods.insert(std::make_pair(&entity, mod));
mTerrainHandler.addTerrainMod(mod);
entity.BeingDeleted.connect(sigc::bind(sigc::mem_fun(*this, &TerrainEntityManager::entityBeingDeletedTerrainMod), &entity));
}
}
示例7: value
void MapProvider::value(Atlas::Message::Element& value, const Atlas::Message::Element& parent_element) const
{
if (!parent_element.isMap()) {
return;
}
auto I = parent_element.Map().find(m_attribute_name);
if (I == parent_element.Map().end()) {
return;
}
if (m_consumer) {
m_consumer->value(value, I->second);
} else {
value = I->second;
}
}
示例8: parseArea
bool TerrainArea::parseArea()
{
if (!mEntity.hasAttr("area")) {
S_LOG_FAILURE("TerrainArea created for entity with no area attribute");
return false;
}
const Atlas::Message::Element areaElem(mEntity.valueOfAttr("area"));
if (!areaElem.isMap()) {
S_LOG_FAILURE("TerrainArea element ('area') must be of map type.");
return false;
}
const Atlas::Message::MapType& areaData(areaElem.asMap());
int layer = 0;
WFMath::Polygon<2> poly;
TerrainAreaParser parser;
if (parser.parseArea(areaData, poly, layer)) {
if (!mArea) {
mArea = new Mercator::Area(layer, false);
} else {
//A bit of an ugly hack here since the Mercator system doesn't support changing the layer. We need to swap the old area for a new one if the layer has changed.
if (mArea->getLayer() != layer) {
mOldArea = mArea;
mArea = new Mercator::Area(layer, false);
}
}
// transform polygon into terrain coords
WFMath::Vector<3> xVec = WFMath::Vector<3>(1.0, 0.0, 0.0).rotate(mEntity.getOrientation());
double theta = atan2(xVec.y(), xVec.x()); // rotation about Z
WFMath::RotMatrix<2> rm;
poly.rotatePoint(rm.rotation(theta), WFMath::Point<2>(0, 0));
poly.shift(WFMath::Vector<2>(mEntity.getPosition().x(), mEntity.getPosition().y()));
mArea->setShape(poly);
return true;
} else {
return false;
}
}
示例9: resolveEntityReferences
void EntityImporterBase::resolveEntityReferences(Atlas::Message::Element& element)
{
if (element.isMap()) {
auto entityRefI = element.asMap().find("$eid");
if (entityRefI != element.asMap().end() && entityRefI->second.isString()) {
auto I = mEntityIdMap.find(entityRefI->second.asString());
if (I != mEntityIdMap.end()) {
entityRefI->second = I->second;
}
}
//If it's a map we need to process all child elements too
for (auto& I : element.asMap()) {
resolveEntityReferences(I.second);
}
} else if (element.isList()) {
//If it's a list we need to process all child elements too
for (auto& I : element.asList()) {
resolveEntityReferences(I);
}
}
}
示例10: parse
void TerrainArea::parse(const Atlas::Message::Element& value, Mercator::Area** area)
{
if (!value.isMap()) {
S_LOG_FAILURE("TerrainArea element ('area') must be of map type.");
return;
}
const Atlas::Message::MapType& areaData = value.Map();
TerrainAreaParser parser;
if (!parser.parseArea(areaData, mParsedPoly, mParsedLayer)) {
return;
} else {
WFMath::Polygon<2> poly = mParsedPoly;
if (!placeArea(poly)) {
return;
}
//TODO: handle holes
*area = new Mercator::Area(mParsedLayer, false);
(*area)->setShape(poly);
}
}
示例11: set
void OutfitProperty::set(const Atlas::Message::Element & val)
{
// INT id?
if (!val.isMap()) {
debug(std::cout << "Value of outfit is not a map" << std::endl << std::flush;);