Пример #1
0
void createSimplePatch(const cmd::ArgumentList& args)
{
	std::size_t width = 0;
	std::size_t height = 0;
	bool removeSelectedBrush = false;

	if (args.size() == 1)
	{
		// Try to convert the arguments to actual integers and do the range checks
		width = height = checkPatchDimension(args[0].getInt());
	}
	else if (args.size() == 2)
	{
		width = checkPatchDimension(args[0].getInt());
		height = checkPatchDimension(args[1].getInt());
	}

	// Only fire the dialog if no or invalid command arguments are given
	if (width == 0 || height == 0)
	{
		ui::PatchCreateDialog dialog;

		if (dialog.run() == ui::IDialog::RESULT_OK)
		{
			width = dialog.getSelectedWidth();
			height = dialog.getSelectedHeight();
			removeSelectedBrush = dialog.getRemoveSelectedBrush();
		}
		else
		{
			return; // dialog cancelled
		}
	}

	UndoableCommand undo("patchCreatePlane");

	// Retrieve the boundaries before any delete operation
	AABB bounds = getDefaultBoundsFromSelection();

	if (removeSelectedBrush)
	{
		// Delete the selection, the should be only one brush selected
		selection::algorithm::deleteSelection();
	}

	// Call the PatchConstruct routine (GtkRadiant legacy)
	constructPrefab(bounds,
					GlobalTextureBrowser().getSelectedShader(),
					ePlane, GlobalXYWnd().getActiveViewType(),
					width, height);
}
void Doom3MapCompiler::dmapCmd(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rWarning() << "Usage: dmap <mapFile>" << std::endl;
		return;
	}

	std::string mapFile = args[0].getString();
	
	if (!boost::algorithm::iends_with(mapFile, ".map"))
	{
		mapFile.append(".map");
	}

	std::string mapPath = mapFile;

	// Find the map file
	if (!path_is_absolute(mapPath.c_str()))
	{
		mapPath = GlobalFileSystem().findFile(mapFile);

		if (mapPath.empty())
		{
			// Try again with maps/ prepended
			mapFile = "maps/" + mapFile;
			mapPath = GlobalFileSystem().findFile(mapFile);
		}

		mapPath += mapFile;
	}

	// Start the sequence
	runDmap(mapPath);
}
Пример #3
0
void nudgeSelectedCmd(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rMessage() << "Usage: nudgeSelected [up|down|left|right]" << std::endl;
		return;
	}

	UndoableCommand undo("nudgeSelected");

	std::string arg = boost::algorithm::to_lower_copy(args[0].getString());

	if (arg == "up") {
		nudgeSelected(eNudgeUp);
	}
	else if (arg == "down") {
		nudgeSelected(eNudgeDown);
	}
	else if (arg == "left") {
		nudgeSelected(eNudgeLeft);
	}
	else if (arg == "right") {
		nudgeSelected(eNudgeRight);
	}
	else {
		// Invalid argument
		rMessage() << "Usage: nudgeSelected [up|down|left|right]" << std::endl;
		return;
	}
}
Пример #4
0
void moveSelectedCmd(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rMessage() << "Usage: moveSelectionVertically [up|down]" << std::endl;
		return;
	}

	UndoableCommand undo("moveSelectionVertically");

	std::string arg = boost::algorithm::to_lower_copy(args[0].getString());

	if (arg == "up") 
	{
		moveSelectedAlongZ(GlobalGrid().getGridSize());
	}
	else if (arg == "down")
	{
		moveSelectedAlongZ(-GlobalGrid().getGridSize());
	}
	else
	{
		// Invalid argument
		rMessage() << "Usage: moveSelectionVertically [up|down]" << std::endl;
		return;
	}
}
Пример #5
0
void ScriptingSystem::runScriptCommand(const cmd::ArgumentList& args) 
{
	// Start the test script
	if (args.empty()) return;

	executeCommand(args[0].getString());
}
Пример #6
0
void brushMakeSided(const cmd::ArgumentList& args) {
	if (args.size() != 1) {
		return;
	}

	// First argument contains the number of sides
	int input = args[0].getInt();

	if (input < 0) {
		globalErrorStream() << "BrushMakeSide: invalid number of sides: " << input << std::endl;
		return;
	}

	std::size_t numSides = static_cast<std::size_t>(input);
	Scene_BrushConstructPrefab(GlobalSceneGraph(), eBrushPrism, numSides, GlobalTextureBrowser().getSelectedShader());
}
Пример #7
0
void createPrefab(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rError() << "Usage: createPatchPrefab <type>" << std::endl
			<< " with <type> being one of the following: " << std::endl
			<< "cylinder, densecylinder, verydensecylinder, squarecylinder," << std::endl
			<< "sphere, endcap, bevel, cone" << std::endl;
		return;
	}

	std::string typeStr = boost::algorithm::to_lower_copy(args[0].getString());

	if (typeStr == "cylinder")
	{
		createPrefabInternal(eCylinder, "patchCreateCylinder");
	}
	else if (typeStr == "densecylinder")
	{
		createPrefabInternal(eDenseCylinder, "patchCreateDenseCylinder");
	}
	else if (typeStr == "verydensecylinder")
	{
		createPrefabInternal(eVeryDenseCylinder, "patchCreateVeryDenseCylinder");
	}
	else if (typeStr == "squarecylinder")
	{
		createPrefabInternal(eSqCylinder, "patchCreateSquareCylinder");
	}
	else if (typeStr == "sphere")
	{
		createPrefabInternal(eSphere, "patchCreateSphere");
	}
	else if (typeStr == "endcap")
	{
		createPrefabInternal(eEndCap, "patchCreateCaps");
	}
	else if (typeStr == "bevel")
	{
		createPrefabInternal(eBevel, "patchCreateBevel");
	}
	else if (typeStr == "cone")
	{
		createPrefabInternal(eCone, "patchCreateCone");
	}
}
void Doom3MapCompiler::setDmapRenderOption(const cmd::ArgumentList& args)
{
	if (args.size() == 0)
	{
		rMessage() << "Usage: setDmapRenderOption <nodeId>" << std::endl;
		return;
	}

	if (!_debugRenderer)
	{
		_debugRenderer.reset(new DebugRenderer);
		GlobalRenderSystem().attachRenderable(*_debugRenderer);
	}

	_debugRenderer->setProcFile(_procFile);
	_debugRenderer->setActiveNode(args[0].getInt());

	GlobalSceneGraph().sceneChanged();
}
Пример #9
0
void brushMakeSided(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rError() << "Usage: BrushMakeSided <numSides>" << std::endl;
		return;
	}

	// First argument contains the number of sides
	int input = args[0].getInt();

	if (input < 0)
	{
		rError() << "BrushMakeSide: invalid number of sides: " << input << std::endl;
		return;
	}

	std::size_t numSides = static_cast<std::size_t>(input);
	selection::algorithm::constructBrushPrefabs(
		eBrushPrism, numSides, GlobalTextureBrowser().getSelectedShader());
}
Пример #10
0
void brushMakePrefab(const cmd::ArgumentList& args)
{
	if (args.size() != 1) {
		return;
	}

	if (GlobalSelectionSystem().getSelectionInfo().brushCount != 1)
	{
		// Display a modal error dialog	
		gtkutil::errorDialog(_("Exactly one brush must be selected for this operation."), GlobalMainFrame().getTopLevelWindow());
		return;
	}

	// First argument contains the number of sides
	int input = args[0].getInt();

	if (input >= eBrushCuboid && input < eNumPrefabTypes) {
		// Boundary checks passed
		EBrushPrefab type = static_cast<EBrushPrefab>(input);

		int minSides = 3;
		int maxSides = c_brushPrism_maxSides;

		switch (type)
		{
		case eBrushCuboid:
			// Cuboids don't need to query the number of sides
			Scene_BrushConstructPrefab(GlobalSceneGraph(), type, 0, GlobalTextureBrowser().getSelectedShader());
			return;

		case eBrushPrism:
			minSides = c_brushPrism_minSides;
			maxSides = c_brushPrism_maxSides;
			break;

		case eBrushCone:
			minSides = c_brushCone_minSides;
			maxSides = c_brushCone_maxSides;
			break;

		case eBrushSphere: 
			minSides = c_brushSphere_minSides;
			maxSides = c_brushSphere_maxSides;
			break;
		default:
			maxSides = 9999;
		};

		ui::QuerySidesDialog dialog(minSides, maxSides);

		int sides = dialog.queryNumberOfSides();

		if (sides != -1)
		{
			Scene_BrushConstructPrefab(GlobalSceneGraph(), type, sides, GlobalTextureBrowser().getSelectedShader());
		}
	}
	else {
		globalErrorStream() << "BrushMakePrefab: invalid prefab type. Allowed types are: " << std::endl 
			<< eBrushCuboid << " = cuboid " << std::endl
			<< eBrushPrism  << " = prism " << std::endl
			<< eBrushCone  << " = cone " << std::endl
			<< eBrushSphere << " = sphere " << std::endl;
	}
}
Пример #11
0
void brushMakePrefab(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rError() << "Usage: " << std::endl
			<< "BrushMakePrefab " << eBrushCuboid << " --> cuboid " << std::endl
			<< "BrushMakePrefab " << eBrushPrism  << " --> prism " << std::endl
			<< "BrushMakePrefab " << eBrushCone  << " --> cone " << std::endl
			<< "BrushMakePrefab " << eBrushSphere << " --> sphere " << std::endl;
		return;
	}

	if (GlobalSelectionSystem().getSelectionInfo().brushCount == 0)
	{
		// Display a modal error dialog
		gtkutil::MessageBox::ShowError(_("At least one brush must be selected for this operation."), GlobalMainFrame().getTopLevelWindow());
		return;
	}

	// First argument contains the number of sides
	int input = args[0].getInt();

	if (input >= eBrushCuboid && input < eNumPrefabTypes)
	{
		// Boundary checks passed
		EBrushPrefab type = static_cast<EBrushPrefab>(input);

		int minSides = 3;
		int maxSides = Brush::PRISM_MAX_SIDES;

		const std::string& shader = GlobalTextureBrowser().getSelectedShader();

		switch (type)
		{
		case eBrushCuboid:
			// Cuboids don't need to query the number of sides
			selection::algorithm::constructBrushPrefabs(type, 0, shader);
			return;

		case eBrushPrism:
			minSides = Brush::PRISM_MIN_SIDES;
			maxSides = Brush::PRISM_MAX_SIDES;
			break;

		case eBrushCone:
			minSides = Brush::CONE_MIN_SIDES;
			maxSides = Brush::CONE_MAX_SIDES;
			break;

		case eBrushSphere:
			minSides = Brush::SPHERE_MIN_SIDES;
			maxSides = Brush::SPHERE_MAX_SIDES;
			break;
		default:
			maxSides = 9999;
		};

		ui::QuerySidesDialog dialog(minSides, maxSides);

		int sides = dialog.queryNumberOfSides();

		if (sides != -1)
		{
			selection::algorithm::constructBrushPrefabs(type, sides, shader);
		}
	}
	else
	{
		rError() << "BrushMakePrefab: invalid prefab type. Allowed types are: " << std::endl
			<< eBrushCuboid << " = cuboid " << std::endl
			<< eBrushPrism  << " = prism " << std::endl
			<< eBrushCone  << " = cone " << std::endl
			<< eBrushSphere << " = sphere " << std::endl;
	}
}