Exemple #1
0
	QScriptValue File::move(QScriptContext *context, QScriptEngine *engine)
	{
		QString source, destination;
		bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;

		if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
			movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);

		return engine->undefinedValue();
	}
Exemple #2
0
	void Piece::updatePrivate(void)
	{
		if(movePrivate(MoveDown))
		{
			Game::instance()->getLogger()->getBuffer() << "Piece is stuck!";
			Game::instance()->getLogger()->debug(5);
			mStuck = true;
			return;
		}
	}
Exemple #3
0
	QScriptValue File::renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
	{
		Q_UNUSED(engine)

#ifdef Q_OS_LINUX
		movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
#endif
#ifdef Q_OS_WIN
		Q_UNUSED(createDestinationDirectory)

		QDir sourceDir(source);
		QDir destinationDir(destination);

		std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
		wideSource += L'\0';

		std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
		wideDestination += L'\0';

		SHFILEOPSTRUCT shFileOpStruct;
		shFileOpStruct.hwnd = 0;
		shFileOpStruct.wFunc = FO_RENAME;
		shFileOpStruct.pFrom = wideSource.c_str();
		shFileOpStruct.pTo = wideDestination.c_str();
		shFileOpStruct.fFlags = 0;
		shFileOpStruct.fAnyOperationsAborted = false;
		shFileOpStruct.lpszProgressTitle = 0;
		shFileOpStruct.hNameMappings = 0;

		if(noErrorDialog)
			shFileOpStruct.fFlags |= FOF_NOERRORUI;
		if(noConfirmDialog)
			shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
		if(noProgressDialog)
			shFileOpStruct.fFlags |= FOF_SILENT;
		if(allowUndo)
			shFileOpStruct.fFlags |= FOF_ALLOWUNDO;

		int result = SHFileOperation(&shFileOpStruct);
		if(result != 0)
		{
			throwError(context, engine, "RenameError", tr("Rename failed: %1").arg(getErrorString(result)));
			return context->thisObject();
		}

		if(shFileOpStruct.fAnyOperationsAborted)
		{
			throwError(context, engine, "RenameAbortedError", tr("Rename failed: aborted"));
			return context->thisObject();
		}
#endif

		return context->thisObject();
	}
Exemple #4
0
	QScriptValue File::move(const QString &destination, const QScriptValue &options)
	{
		mFile.close();
	
		bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;

		if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
			return movePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
		else
			return false;
	}
Exemple #5
0
	void Piece::update(void)
	{
		Game::ActionContainer::const_iterator iter = Game::instance()->getActions().cbegin();
		for(; iter != Game::instance()->getActions().cend(); ++iter)
		{
			if((*iter)->getId() == "tick")
			{
				updatePrivate();
				Game::instance()->getLogger()->getBuffer() << "Piece is " << mType << " and knows it has to update.";
				Game::instance()->getLogger()->debug(5);
				break;
			}
		}

		// move with player input
		if(!mStuck)
		{
			if(Game::instance()->getInput()->isKeyReleased(InputSystem::Keyboard::Right))
			{
				movePrivate(MoveRight);
			}
			if(Game::instance()->getInput()->isKeyReleased(InputSystem::Keyboard::Left))
			{
				movePrivate(MoveLeft);
			}
			if(Game::instance()->getInput()->isKeyPressed(InputSystem::Keyboard::Down))
			{
				movePrivate(MoveDown);
			}
			if(Game::instance()->getInput()->isKeyReleased(InputSystem::Keyboard::A))
			{
				rotatePrivate(CCW);
			}
			if(Game::instance()->getInput()->isKeyReleased(InputSystem::Keyboard::S))
			{
				rotatePrivate(CW);
			}
		}
	}