示例#1
0
/*
	Called once per loop iteration with a delta time to update each process.
	If any processes die, their children are attached to the manager and fired.
*/
void dtn::ProcessManager::update(float dt)
{
	if (!m_paused)
	{
		size_t loopCount = 0;
		for (std::vector<std::shared_ptr<dtn::Process>>::iterator it = m_processes.begin();
			it != m_processes.end();)
		{
			if ((*it)->update(dt))
			{
				if ((*it)->m_child != NULL)
				{
					attachProcess((*it)->m_child);
					it = m_processes.begin() + loopCount;
				}
				(*it)->onDeath();
				it = m_processes.erase(it);
			}
			else
			{
				++it;
			}
			loopCount++;
		}
	}
}
/*!
 * \param pParent
 */
AttachToProcessDialog::AttachToProcessDialog(QWidget *pParent)
  : QDialog(pParent)
{
  setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::attachToRunningProcess));
  setAttribute(Qt::WA_DeleteOnClose);
  resize(500, 400);
  // attach to process id
  mpAttachToProcessIDLabel = new Label(tr("Attach to Process ID:"));
  mpAttachToProcessIDTextBox = new QLineEdit;
  // filter
  mpFilterProcessesTextBox = new QLineEdit;
  mpFilterProcessesTextBox->setPlaceholderText(tr("Filter Processes"));
  // processes tree view model & proxy
  mpProcessListModel = new ProcessListModel;
  mProcessListFilterModel.setSourceModel(mpProcessListModel);
  mProcessListFilterModel.setFilterRegExp(mpFilterProcessesTextBox->text());
  // processes tree view
  mpProcessesTreeView = new QTreeView;
  mpProcessesTreeView->setItemDelegate(new ItemDelegate(mpProcessesTreeView));
  mpProcessesTreeView->setModel(&mProcessListFilterModel);
  mpProcessesTreeView->setTextElideMode(Qt::ElideMiddle);
  mpProcessesTreeView->setIndentation(0);
  mpProcessesTreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
  mpProcessesTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
  mpProcessesTreeView->setUniformRowHeights(true);
  //mpProcessesTreeView->setRootIsDecorated(false);
  mpProcessesTreeView->setSortingEnabled(true);
  mpProcessesTreeView->header()->setDefaultSectionSize(100);
  mpProcessesTreeView->header()->setStretchLastSection(true);
  mpProcessesTreeView->sortByColumn(1, Qt::AscendingOrder);
  // Create the buttons
  mpOkButton = new QPushButton(Helper::ok);
  mpOkButton->setEnabled(false);
  connect(mpOkButton, SIGNAL(clicked()), SLOT(attachProcess()));
  mpRefreshButton = new QPushButton(Helper::refresh);
  connect(mpRefreshButton, SIGNAL(clicked()), SLOT(updateProcessList()));
  mpCancelButton = new QPushButton(Helper::cancel);
  connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
  // create buttons box
  mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
  mpButtonBox->addButton(mpOkButton, QDialogButtonBox::ActionRole);
  mpButtonBox->addButton(mpRefreshButton, QDialogButtonBox::ActionRole);
  mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);

  connect(mpAttachToProcessIDTextBox, SIGNAL(textChanged(QString)), this, SLOT(processIDChanged(QString)));
  connect(mpFilterProcessesTextBox, SIGNAL(textChanged(QString)), this, SLOT(setFilterString(QString)));
  connect(mpProcessesTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(processSelected(QModelIndex)));
  connect(mpProcessesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(processClicked(QModelIndex)));
  // set the layout
  QGridLayout *pMainLayout = new QGridLayout;
  pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  pMainLayout->addWidget(mpAttachToProcessIDLabel, 0, 0);
  pMainLayout->addWidget(mpAttachToProcessIDTextBox, 0, 1);
  pMainLayout->addWidget(mpFilterProcessesTextBox, 1, 0, 1 ,2);
  pMainLayout->addWidget(mpProcessesTreeView, 2, 0, 1 ,2);
  pMainLayout->addWidget(mpButtonBox, 3, 0, 1, 2, Qt::AlignRight);
  setLayout(pMainLayout);
  // get the list of processes
  updateProcessList();
}
示例#3
0
void
attachPS3(GtkWidget *button)
{
    HINSTANCE       hLib = LoadLibrary("CCAPI.DLL");
    __cNotify       v_notifyPS3 = (__cNotify)GetProcAddress(hLib, "CCAPIVshNotify");
    GdkColor    color;

    if (SUCCESS(attachProcess(0, PPU, PRC_ID.processID)))
    {
        v_notifyPS3(PROGRESS, "Attached to PS3");
        gtk_button_set_label(GTK_BUTTON(button), "Attached");
        gdk_color_parse("green", &color);
        gtk_widget_modify_fg(button, GTK_STATE_NORMAL, &color);
    }
    else
    {
        gtk_button_set_label(GTK_BUTTON(button), "Can't attach to the default game");
        gdk_color_parse("red", &color);
        gtk_widget_modify_fg(button, GTK_STATE_NORMAL, &color);
    }
}