Esempio n. 1
0
void QSPCallBacks::SaveGameStatus(QSPString file)
{
	if (m_frame->IsQuit()) return;
	if (file.Str)
		QSPSaveGame(file, QSP_FALSE);
	else
	{
		wxFileDialog dialog(m_frame, _("Select file to save"), wxEmptyString, wxEmptyString, _("Saved game files (*.sav)|*.sav"), wxFD_SAVE);
		m_frame->EnableControls(false);
		int res = dialog.ShowModal();
		m_frame->EnableControls(true);
		if (res == wxID_OK)
		{
			wxString path(dialog.GetPath());
			QSPSaveGame(qspStringFromLen(path.c_str(), path.Length()), QSP_FALSE);
		}
	}
}
void FastQSPWindow::quicksave()
{
  QString filename = gameDirectory + "save/quicksave.sav";
  QSPSaveGame(filename.toStdWString().c_str(), true);
//  qspJack.saveGameStatus(gameDirectory + "save/quicksave.json"); // New save system
  savestatus->setPlainText("Game is saved.");
  savestatus->setVisible(true);
  QTimer::singleShot(1000, this, SLOT(hideSaveStatus()));
//  connect(&savestatus_timeout, SIGNAL(timeout()), savestatus, SLOT(hide()));
//  savestatus_timeout.start(1000);
}
Esempio n. 3
0
void *QSPThreadProc(void *ptr)
{
// (QSPEvent != QSP_EVT_EXIT)
  while (true) {
    //pthread_mutex_lock(&qsp_mutex);
    while (!qsp_events.empty()) {
      QspEvent ev = qsp_events.front();
      switch (ev.type) {
      case QSP_EVT_EXIT:
        return 0;
      case QSP_EVT_OPENGAME:
        if (!QSPLoadGameWorld(ev.p_str.c_str()))
          ShowError();
        else {
          chdir(GetQuestPath().c_str());
          QSPRestartGame(QSP_TRUE);
        }
        break;
      case QSP_EVT_RESTART:
        if (!QSPRestartGame(QSP_TRUE))
          ShowError();
        break;
      case QSP_EVT_SAVEGAME:
        if (!QSPSaveGame((QSP_CHAR *) ev.p_str.c_str(), QSP_FALSE))
          ShowError();
        break;
      case QSP_EVT_OPENSAVEDGAME:
        if (!QSPOpenSavedGame((QSP_CHAR *) ev.p_str.c_str(), QSP_TRUE))
          ShowError();
        break;
      case QSP_EVT_EXECSTRING:
        if (!QSPExecString((const QSP_CHAR *)ev.p_str.c_str(), QSP_TRUE))
          ShowError();
        else if(ev.p_str.find("OPENQST")!=ev.p_str.npos){
          chdir(GetQuestPath().c_str());
        }
        break;
      case QSP_EVT_EXECSELACTION:
        if (!QSPExecuteSelActionCode(QSP_TRUE))
          ShowError();
        break;
      case QSP_EVT_SETOBJINDEX:
        if (!QSPSetSelObjectIndex(ev.p_int, QSP_TRUE))
          ShowError();
        break;
      case QSP_EVT_SETUSERINPUT:
        QSPSetInputStrText(ev.p_str.c_str());
        break;
      case QSP_EVT_EXECUSERINPUT:
        if (!QSPExecUserInput(QSP_TRUE))
          ShowError();
        break;
      case QSP_EVT_DONEMENU:
        QSPSelectMenuItem(ev.p_int);
        break;
      default:
        usleep(500);
      }
      qsp_events.pop();
    }
    QSPEventProcessed = true;
    //pthread_mutex_unlock(&qsp_mutex);
    usleep(500);
  }
  return 0;
}
void FastQSPWindow::saveGame(const QString &filename) {
//  qDebug() << "Saving game to" << filename;
  if (!filename.isEmpty())
    QSPSaveGame(filename.toStdWString().c_str(), true);
}