コード例 #1
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::del()
{
    _test.removeQuestion(_currentQ);
    if (_currentQ != 0)
        --_currentQ;
    setQuestion(_currentQ);
}
コード例 #2
0
ファイル: QuitCmd.C プロジェクト: juddy/edcde
QuitCmd::QuitCmd ( char *name, char *label, int active, MainWindow *mywindow) : 
                 WarnNoUndoCmd ( name, label, active ) 
{
    _mywindow = mywindow;
    _dialogParentWidget = _mywindow->baseWidget();
    setQuestion ( GETMSG(catd, 1, 9, "Close this folder?") );
}
コード例 #3
0
 void Opcode811E::_run() {
     Logger::debug("SCRIPT") << "[811E] [=] void gSay_Reply(int msg_file_num, int msg_num)" << std::endl;
     auto dialog = dynamic_cast<State::CritterDialog *>(Game::getInstance()->topState());
     dialog->deleteAnswers();
     if (_script->dataStack()->top().type() == StackValue::Type::STRING) {
         auto question = _script->dataStack()->popString();
         dialog->setQuestion(question);
     } else {
         auto msg_num = _script->dataStack()->popInteger();
         auto msg_file_num = _script->dataStack()->popInteger();
         dialog->setQuestion(_script->msgMessage(msg_file_num, msg_num));
         auto speech = _script->msgSpeech(msg_file_num, msg_num);
         if (speech != "") {
             if (auto interact = dynamic_cast<State::CritterInteract *>(Game::getInstance()->topState(1))) {
                 interact->playSpeech(speech);
             }
         }
     }
 }
コード例 #4
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::add()
{
    Question q;
    q.setText(tr("empty"));
    q.addAnswer(Answer(tr("empty"), false));
    q.addAnswer(Answer(tr("empty"), false));
    q.addAnswer(Answer(tr("empty"), false));
    _test.insertQuestion(++_currentQ, q);
    setQuestion(_currentQ);
}
コード例 #5
0
bool capitalDivisionAsker::nextBoxAskerQuestionHook(const QString &division, int i, bool isAnswer)
{
	bool b;
	if (isAnswer)
	{
		p_capital = p_map -> getDivisionCapital(division);
		p_currentAnswer.setQuestion(i18n(p_map -> getFileName().utf8(), p_capital.utf8()));
		p_currentAnswer.setCorrectAnswer(i18n(p_map -> getFileName().utf8(), division.utf8()));

		QString sw = i18n("There are two ways of dealing with the translation of \"%1 is the capital of...\". The first option simply replaces %1 with the translated name of the relevant city. If the grammar of your language allows this, choose this option by setting the translation of this message to 1, and leave untranslated the translations of \"%1 is the capital of...\" that have the placename embedded (or translate them as - if you wish to show the file as fully translated. The second option is to translate all messages in full - this is likely to be required in the case of highly-inflected languages like Russian. To choose this option, set the translation of this message to 0, and translate all the messages.", "0");
		if (sw == "1")
		{
			QString capitalName = i18n(p_map -> getFileName().utf8(), p_capital.utf8());
			QString text = i18n("%1 is the capital of...");
			setQuestion(text.arg(capitalName));
		}
		else
		{
			QString s = QString("%1 is the capital of...").arg(p_capital);
			setQuestion(i18n(p_map -> getFileName().utf8(), s.utf8()));
		}
		p_rb[i] -> setText(i18n(p_map -> getFileName().utf8(), division.utf8()));
		b = true;
	}
	else
	{
		// There are crazy countries like Norway where two different divisions
		// have the same capital, avoid asking
		// Oslo is the capital of ...
		// Oslo (true)
		// Akershus (true)
		// Buskerud
		// Hedmark
		if (p_map -> getDivisionCapital(division) != p_capital)
		{
			p_rb[i] -> setText(i18n(p_map -> getFileName().utf8(), division.utf8()));
			b = true;
		}
		else b = false;
	}
	return b;
}
コード例 #6
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::prev()
{
    _test.removeQuestion(_currentQ);
    Question q;
    q.setText(textEdit->text());
    for (int i = 0; i < ansList.size(); i++) {
        q.addAnswer(ansList[i]->answer());
    }
    _test.insertQuestion(_currentQ, q);

    if (_currentQ != 0)
        setQuestion(--_currentQ);
}
コード例 #7
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::next()
{
    _test.removeQuestion(_currentQ);
    Question q;
    q.setText(textEdit->text());
    for (int i = 0; i < ansList.size(); i++) {
        q.addAnswer(ansList[i]->answer());
    }
    _test.insertQuestion(_currentQ, q);

    if (_currentQ < _test.questions().size() - 1)
        setQuestion(++_currentQ);
}
コード例 #8
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::load(QString testName)
{
    _currentQ = 0;
    _test = Test(IOFiles::readTest(testName));
    setQuestion(_currentQ);
    ui->nameEdit->setText(_test.name());
    ui->authorEdit->setText(_test.author());
    ui->classSpinBox->setValue(_test.class_());
    ui->timeEdit->setTime(QTime(_test.time()/60,
                                _test.time()%60));
    ui->mistCB->setChecked(_test.showMistakes());
    ui->rightCB->setChecked(_test.showRightAnswers());

    ui->centralWidget->setEnabled(true);
    ui->mainToolBar->setEnabled(true);


    testProgress->setText(tr("<b>Loaded!</b> ") + testProgress->text());
}
コード例 #9
0
ファイル: BftpMaker.cpp プロジェクト: RussianBruteForce/bftp
void BftpMaker::save()
{
    _test.setName(ui->nameEdit->text());
    _test.setAuthor(ui->authorEdit->text());
    _test.setClass(ui->classSpinBox->value());
    _test.setTime(ui->timeEdit->time().minute() +
                  ui->timeEdit->time().hour()*60
                 );
    _test.setShowMistakes(ui->mistCB->isChecked());
    _test.setShowRightAnswers(ui->rightCB->isChecked());
    QString fileName;
    fileName += QString::number(_test.class_());
    fileName += ' ';
    fileName += _test.name();
    IOFiles::writeTest(fileName, _test.toJson());

    setQuestion(_currentQ);
    testProgress->setText(tr("<b>Saved!</b> ") + testProgress->text());
}
コード例 #10
0
ファイル: Quiz.cpp プロジェクト: tngoc/Wheel-Of-Fortune
int Quiz::inputQuiz(int x){
	HRESULT hr;
   CComPtr<IStream> pFileStream;
   CComPtr<IXmlReader> pReader;
   XmlNodeType nodeType;
   //const WCHAR* pwszPrefix;
   const WCHAR* pwszLocalName;
   const WCHAR* pwszValue;
   //UINT cwchPrefix;

   if (FAILED(hr = SHCreateStreamOnFile(L"file.xml", STGM_READ, &pFileStream))) {
      wprintf(L"Error creating file reader, error is %08.8lx", hr);
	   getchar();
      return -1;
   }

   if (FAILED(hr = CreateXmlReader(__uuidof(IXmlReader), (void**) &pReader, NULL))) {
      wprintf(L"Error creating xml reader, error is %08.8lx", hr);
      return -1;
   }

   if (FAILED(hr = pReader->SetProperty(XmlReaderProperty_DtdProcessing, DtdProcessing_Prohibit))) {
      wprintf(L"Error setting XmlReaderProperty_DtdProcessing, error is %08.8lx", hr);
      return -1;
   }

   if (FAILED(hr = pReader->SetInput(pFileStream))) {
      wprintf(L"Error setting input for reader, error is %08.8lx", hr);
      return -1;
   }

   int i = 0;
   while (S_OK == (hr = pReader->Read(&nodeType))) {
	   if (nodeType == XmlNodeType_Element) {
		   if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
            wprintf(L"Error getting local name, error is %08.8lx", hr);
            return -1;
		   }
		   if (wcscmp(pwszLocalName,L"entry") == 0) i++; // i la` so element trong xml
	   }
   }

   LARGE_INTEGER liBeggining = { 0 };
   pFileStream->Seek(liBeggining, STREAM_SEEK_SET, NULL);
   pReader->SetInput(pFileStream);

   int k=0,j=1;//k la` bien dem'. j bien' de? lay ra phan` tu? thu' j. j = 1 thi` lay' phan` tu? dau` tien
   
   while (S_OK == (hr = pReader->Read(&nodeType))) {
      switch (nodeType) {

      case XmlNodeType_Element: 
         if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
            wprintf(L"Error getting local name, error is %08.8lx", hr);
            return -1;
         }
		 if (wcscmp(pwszLocalName,L"entry") == 0) k++;

         if (FAILED(hr = pReader->MoveToElement())) {
            wprintf(L"Error moving to the element that owns the current attribute node, error is %08.8lx", hr);
            return -1;
         }
         if (pReader->IsEmptyElement() )
            wprintf(L" (empty element)\n");
         break;
      case XmlNodeType_EndElement:
          if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
            wprintf(L"Error getting local name, error is %08.8lx", hr);
            return -1;
         }
         break;

      case XmlNodeType_Text:

      case XmlNodeType_CDATA:
         if (FAILED(hr = pReader->GetValue(&pwszValue, NULL))) {
            wprintf(L"Error getting value, error is %08.8lx", hr);
            return -1;
         }
		 if (wcscmp(pwszLocalName,L"Question") == 0) {
			 setQuestion(strdup(narrow(pwszValue).c_str()));
		 }
		 else if (wcscmp(pwszLocalName,L"Answer") == 0) {
			 setAnswer(strdup(narrow(pwszValue).c_str()));
		 }
         break;

      case XmlNodeType_ProcessingInstruction:
         if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL))) {
            wprintf(L"Error getting name, error is %08.8lx", hr);
            return -1;
         }
         if (FAILED(hr = pReader->GetValue(&pwszValue, NULL))) {
            wprintf(L"Error getting value, error is %08.8lx", hr);
            return -1;
         }
         wprintf(L"Processing Instruction name:%S value:%S\n", pwszLocalName, pwszValue);
         break;

      case XmlNodeType_Comment:
         if (FAILED(hr = pReader->GetValue(&pwszValue, NULL))) {
            wprintf(L"Error getting value, error is %08.8lx", hr);
            return -1;
         }
         wprintf(L"Comment: %s\n", pwszValue);
         break;

      case XmlNodeType_DocumentType:
         wprintf(L"DOCTYPE is not printed\n");
         break;
      }
	  if (k > j) break;
   }
   return 0;
}