コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: 1285done/cuberite
void MainWindow::createWorldActions()
{
	QDir mc(m_MinecraftPath);
	if (!mc.cd("saves"))
	{
		return;
	}

	QDirIterator it(mc);
	int key = 1;
	while (it.hasNext())
	{
		it.next();
		if (!it.fileInfo().isDir())
		{
			continue;
		}
		QString name = getWorldName(it.filePath().toStdString());
		if (name.isEmpty())
		{
			continue;
		}
		QAction * w = new QAction(this);
		w->setText(name);
		w->setData(it.filePath() + "/region");
		if (key < 10)
		{
			w->setShortcut("Ctrl+" + QString::number(key));
			key++;
		}
		connect(w, SIGNAL(triggered()), this, SLOT(openVanillaWorld()));
		m_WorldActions.append(w);
	}
}
コード例 #2
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;
}