예제 #1
0
std::string MapcrafterConfigHelper::generateTemplateJavascript() const {
	std::string js = "";

	auto maps = config.getMaps();
	for (auto it = maps.begin(); it != maps.end(); ++it) {
		auto world = config.getWorld(it->getWorld());

		js += "\"" + it->getShortName() + "\" : {\n";
		js += "\tname: \"" + it->getLongName() + "\",\n";
		js += "\tworld: \"" + it->getWorld() + "\",\n";
		js += "\tworldName: \"" + world.getWorldName() + "\",\n";
		js += "\ttextureSize: " + util::str(it->getTextureSize()) + ",\n";
		js += "\ttileSize: " + util::str(32 * it->getTextureSize()) + ",\n";
		js += "\tmaxZoom: " + util::str(getMapZoomlevel(it->getShortName())) + ",\n";
		js += "\timageFormat: \"" + it->getImageFormatSuffix() + "\",\n";

		js += "\trotations: [";
		auto rotations = it->getRotations();
		for (auto it2 = rotations.begin(); it2 != rotations.end(); ++it2)
			js += util::str(*it2) + ",";
		js += "],\n";

		std::string tile_offsets = "[";
		auto offsets = world_tile_offsets.at(it->getWorld());
		for (auto it2 = offsets.begin(); it2 != offsets.end(); ++it2)
			tile_offsets += "[" + util::str(it2->getX()) + ", " + util::str(it2->getY()) + "], ";
		tile_offsets += "]";

		js += "\ttileOffsets: " + tile_offsets + ",\n";

		if (!world.getDefaultView().empty())
			js += "\tdefaultView: [" + world.getDefaultView() + "],\n";
		if (world.getDefaultZoom() != 0)
			js += "\tdefaultZoom: " + util::str(world.getDefaultZoom()) + ",\n";
		if (world.getDefaultRotation() != -1)
			js += "\tdefaultRotation: " + util::str(world.getDefaultRotation()) + ",\n";

		js += "},";
	}

	return js;
}
예제 #2
0
파일: Clump.cpp 프로젝트: bisclavret/openrw
ModelFramePtr ModelFrame::cloneHierarchy() const {
    auto self = std::make_shared<ModelFrame>(getIndex(), getDefaultRotation(),
                                             getDefaultTranslation());
    self->setName(getName());
    for (const auto& child : getChildren()) {
        auto childclone = child->cloneHierarchy();
        self->addChild(childclone);
    }

    return self;
}