|
|
|
|
@ -33,18 +33,6 @@
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
const char* PyGetCVar(const char* pName)
|
|
|
|
|
{
|
|
|
|
|
ICVar* pCVar = GetIEditor()->GetSystem()->GetIConsole()->GetCVar(pName);
|
|
|
|
|
if (!pCVar)
|
|
|
|
|
{
|
|
|
|
|
Warning("PyGetCVar: Attempt to access non-existent CVar '%s'", pName ? pName : "(null)");
|
|
|
|
|
throw std::logic_error((QString("\"") + pName + "\" is an invalid cvar.").toUtf8().data());
|
|
|
|
|
}
|
|
|
|
|
return pCVar->GetString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
const char* PyGetCVarAsString(const char* pName)
|
|
|
|
|
{
|
|
|
|
|
@ -212,52 +200,6 @@ namespace
|
|
|
|
|
return GetIEditor()->IsInSimulationMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
QString PyNewObject(const char* typeName, const char* fileName, const char* name, float x, float y, float z)
|
|
|
|
|
{
|
|
|
|
|
CBaseObject* object = GetIEditor()->NewObject(typeName, fileName, name, x, y, z);
|
|
|
|
|
if (object)
|
|
|
|
|
{
|
|
|
|
|
return object->GetName();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
QString PyNewObjectAtCursor(const char* typeName, const char* fileName, const char* name)
|
|
|
|
|
{
|
|
|
|
|
CUndo undo("Create new object");
|
|
|
|
|
|
|
|
|
|
Vec3 pos(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
QPoint p = QCursor::pos();
|
|
|
|
|
CViewport* viewport = GetIEditor()->GetViewManager()->GetViewportAtPoint(p);
|
|
|
|
|
if (viewport)
|
|
|
|
|
{
|
|
|
|
|
viewport->ScreenToClient(p);
|
|
|
|
|
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
|
|
|
|
|
{
|
|
|
|
|
pos = viewport->MapViewToCP(p);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Snap to terrain.
|
|
|
|
|
bool hitTerrain;
|
|
|
|
|
pos = viewport->ViewToWorld(p, &hitTerrain);
|
|
|
|
|
if (hitTerrain)
|
|
|
|
|
{
|
|
|
|
|
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y) + 1.0f;
|
|
|
|
|
}
|
|
|
|
|
pos = viewport->SnapToGrid(pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PyNewObject(typeName, fileName, name, pos.x, pos.y, pos.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void PyRunConsole(const char* text)
|
|
|
|
|
{
|
|
|
|
|
|