Пример #1
0
void cRunningScript::launch (int fcState)
{
  // Register the script as started, even if it's actually delayed by flow
  // control.  This prevents multiple instances of a single instance script.
  script->scriptIsStarting ();
  
  if (!flowcontrol)
    doLaunch ();
  else
  {
    //we'll launch when flow control reaches the current point
    launchAfter = fcState;
    if (fcState == 0)
      doLaunch ();
  }
}
Пример #2
0
void MainWindow::on_actionLaunchInstanceOffline_triggered()
{
	if (m_selectedInstance)
	{
		NagUtils::checkJVMArgs(m_selectedInstance->settings().get("JvmArgs").toString(), this);
		doLaunch(false);
	}
}
Пример #3
0
//improvements here by Alex Bache
void cRunningScript::sendCommandToScript (const QString &command, char type)
{
  actuallySent = false;
  
  if (process == 0)
    return;

  //are we waiting for flow control?
  if (launchAfter)
  {
    launchAfter--;
    if (launchAfter == 0)
      //we're in sync - start the script!
      doLaunch ();
    //do not send current line... if we have started the script
    //now, next line will be the first one that it will get
    return;
  }

  if ((type == USERCOMMAND) && (!sendusercommands))
      //type = user command, user commands are not sent
    return;
/*  no, we'll send prompt even if there's no adv.comm
  if ((type == PROMPT) && (!useadvcomm))
      //prompt only sent if using adv.communication
    return;
*/
  
  // don't send anything if the script is in the process of shutting down
  if (scriptDying)
    return;
  
  QString txt = command;
  //advanced communication?
  if (useadvcomm)
  {
    QString beg = QChar (type);
    beg += QChar (' ');
    txt = beg + txt;
  }
  
  //send it if nothing else in progress
  
  if (sendInProgress)
  {
    stdinBuffer.append(txt);
  } // endif must buffer for later
  else
  {
    stdinSending   = txt;
    sendInProgress = true;
    actuallySent   = true;
    process->write (stdinSending.toLocal8Bit());
  } // endelse able to send immediately
  if (flowcontrol)
    emit textAccepted ();
}
Пример #4
0
void MainWindow::updateToolsMenu()
{
	if (ui->actionLaunchInstance->menu())
	{
		ui->actionLaunchInstance->menu()->deleteLater();
	}
	QMenu *launchMenu = new QMenu(this);
	QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
	connect(normalLaunch, &QAction::triggered, [this](){doLaunch();});
	launchMenu->addSeparator()->setText(tr("Profilers"));
	for (auto profiler : MMC->profilers().values())
	{
		QAction *profilerAction = launchMenu->addAction(profiler->name());
		QString error;
		if (!profiler->check(&error))
		{
			profilerAction->setDisabled(true);
			profilerAction->setToolTip(tr("Profiler not setup correctly. Go into settings, \"External Tools\"."));
		}
		else
		{
			connect(profilerAction, &QAction::triggered, [this, profiler](){doLaunch(true, profiler.get());});
		}
	}
	launchMenu->addSeparator()->setText(tr("Tools"));
	for (auto tool : MMC->tools().values())
	{
		QAction *toolAction = launchMenu->addAction(tool->name());
		QString error;
		if (!tool->check(&error))
		{
			toolAction->setDisabled(true);
			toolAction->setToolTip(tr("Tool not setup correctly. Go into settings, \"External Tools\"."));
		}
		else
		{
			connect(toolAction, &QAction::triggered, [this, tool]()
			{
				tool->createDetachedTool(m_selectedInstance, this)->run();
			});
		}
	}
	ui->actionLaunchInstance->setMenu(launchMenu);
}
Пример #5
0
// This function will calculate launche parameters and save them in the launch struct to be processed by calling object
void GameObj::rangedAttack(b2Vec2 nearest) {				// Ranged attack
	// Check timer
	t_launch.Calculate_Ellapsed_Time();
	if(t_launch.TotalTime() < (1 / goSettings._RoF)) {
		return;
	}


	std::srand( time(NULL));
	float accuracy = 75.0;							// TEMP - This should be a GoSettings variable 
	if(accuracy > 100) accuracy = 100;				// Accuracy from 0-100 (percent)  95 means it will hit approx 95/100 times
	int randomAdj =  (100-accuracy)*2;		// double to account for +/-
	double adjustment = rand() % randomAdj - randomAdj/2;
	int maxRange = (pow(goSettings._LAUNCH_MAX_VEL, 2) * sin((Util::PI/4)*2))/9.8;					// (v_0^2 sin(theta)) / g
	
	// Closest enemy is out of range    (maybe don't bother shooting?)
	if(maxRange < abs(getPos().x - nearest.x)) { 
		// launch at max velocity  +  45 + (45* (adjustment/100))
		// to do
		// need a way to launch arrows... (preload??) 

		// Don't shoot until in range!
		//launch.angle = 45.0 + (45.0 * (adjustment/100.0));
		//launch.velocity.Set(goSettings._LAUNCH_MAX_VEL * cos(Util::deg2Rad(launch.angle)), goSettings._LAUNCH_MAX_VEL * sin(Util::deg2Rad(launch.angle)));
		//launch.ammo = goSettings.ammo;
		//launch.launchTriggered = true;
	}
	// ENEMY IN RANGE
	// Need to add random adjustment to velocity AND angle.
	else {
		// ANGLE
		float angle = 45.0 + (45.0 * (adjustment/100.0));					// Take angle with random adjustment
		if(angle > goSettings._LAUNCH_MAX_ANGLE) angle = goSettings._LAUNCH_MAX_ANGLE;
		if(angle < goSettings._LAUNCH_MIN_ANGLE) angle = goSettings._LAUNCH_MIN_ANGLE;		
		launch.angle = angle;
		
		// VELOCITY
		// Use angle to calculate a launch velocity to get "near" the target     v = sqrt( (R*g) / sin(2theta))
		float range = Util::pixel2Meter(abs(nearest.x - body->GetPosition().x));	// meters to enemy
		int v0 = sqrt( (range * 9.8) / sin(Util::deg2Rad(2 * launch.angle)));
		v0 += (v0 * adjustment);
		if(v0 > goSettings._LAUNCH_MAX_VEL) v0 = goSettings._LAUNCH_MAX_VEL;
		if(v0 < goSettings._LAUNCH_MIN_VEL) v0 = goSettings._LAUNCH_MIN_VEL;
		launch.velocity.Set(v0 * cos(Util::deg2Rad(launch.angle)), v0 * sin(Util::deg2Rad(launch.angle)));
		
		launch.ammo = goSettings.ammo; // TODO - Need to add ammo selection for objects with more than 1 type of ammo?
		launch.launchTriggered = true;

		// FIRE!
		doLaunch();

	}

	t_launch.Reset(0.0);
}
Пример #6
0
/*
void MainWindow::on_instanceView_customContextMenuRequested(const QPoint &pos)
{
	QMenu *instContextMenu = new QMenu("Instance", this);

	// Add the actions from the toolbar to the context menu.
	instContextMenu->addActions(ui->instanceToolBar->actions());

	instContextMenu->exec(view->mapToGlobal(pos));
}
*/
void MainWindow::instanceActivated(QModelIndex index)
{
	if (!index.isValid())
		return;

	BaseInstance *inst =
		(BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>();

	NagUtils::checkJVMArgs(inst->settings().get("JvmArgs").toString(), this);

	doLaunch();
}
Пример #7
0
/*
void MainWindow::on_instanceView_customContextMenuRequested(const QPoint &pos)
{
	QMenu *instContextMenu = new QMenu("Instance", this);

	// Add the actions from the toolbar to the context menu.
	instContextMenu->addActions(ui->instanceToolBar->actions());

	instContextMenu->exec(view->mapToGlobal(pos));
}
*/
void MainWindow::instanceActivated(QModelIndex index)
{
	if (!index.isValid())
		return;
    QString id = index.data(InstanceList::InstanceIDRole).toString();
	InstancePtr inst = MMC->instances()->getInstanceById(id);
    if(!inst)
        return;

	NagUtils::checkJVMArgs(inst->settings().get("JvmArgs").toString(), this);

	doLaunch();
}
Пример #8
0
void ItemHandle::doLaunch(Helper::ItemLaunchHelperI* helper)
{
	char magicBytes[5] = {0};
	UserCore::Item::Misc::ExeInfoI* ei = getItemInfo()->getActiveExe();
	
	const char* exe = ei->getExe();
	const char* args = getUserCore()->getCVarValue("gc_linux_launch_globalargs");
	gcString globalExe = getUserCore()->getCVarValue("gc_linux_launch_globalbin");
	
	if (globalExe.size() > 0)
	{
		if (!UTIL::FS::isValidFile(globalExe.c_str()))
		{
			Warning(gcString("Couldn't find global exe [{0}], ignoring.\n", globalExe));
			globalExe = "";
			exe = ei->getExe();
		}
		else
		{
			exe = globalExe.c_str();
		}
	}
	
	try
	{
		UTIL::FS::FileHandle fh(exe, UTIL::FS::FILE_READ);
		fh.read(magicBytes, 5);
	}
	catch (gcException& e)
	{
		throw gcException(ERR_LAUNCH, e.getSecErrId(), gcString("Failed to read [{0}]: {1}\n", exe, e));
	}

	UTIL::LIN::BinType type = UTIL::LIN::getFileType(magicBytes, 5);

	if (type == UTIL::LIN::BT_WIN && helper)
		helper->showWinLaunchDialog();
	
	//if we are not using globalExe set exe to Null so that we use the proper exe
	if (globalExe.size() == 0 || type == UTIL::LIN::BT_UNKNOWN)
		exe = NULL;

	doLaunch(type == UTIL::LIN::BT_UNKNOWN, exe, args);
}