Esempio n. 1
0
void boxAsker::checkAnswer()
{
	bool any, correct;
	int i;

	correct = false;	
	any = false;
	i = 0;
	while(!any && i < 4)
	{
		if (p_rb[i] -> isChecked())
		{
			any = true;
			correct = (i == p_position);
		}
		else i++;
	}
		
	if (any)
	{
		setAnswerHook(i);
		questionAnswered(correct);
		nextQuestion();
	}
}
Esempio n. 2
0
void DialogueManager::run() {

	// cache event data
	_mouseButtons = _vm->_input->getLastButtonEvent();
	_vm->_input->getCursorPos(_mousePos);
	_isKeyDown = _vm->_input->getLastKeyDown(_downKey);

	switch (_state) {
	case RUN_QUESTION:
		runQuestion();
		break;

	case NEXT_ANSWER:
		nextAnswer();
		break;

	case NEXT_QUESTION:
		nextQuestion();
		break;

	case RUN_ANSWER:
		runAnswer();
		break;

	case DIALOGUE_OVER:
		break;

	default:
		error("unknown state in DialogueManager");

	}

}
void SoloGameScene::checkBeforeNextQuestion( CCObject* pSender )
{
	//send to server
	CCArray* questResults = DataManager::sharedDataManager()->GetQuestResults();

	int isRight = (m_isRight == true) ? 1 : 0;
	int answerTime = CONF_INT(SOLO_TIME_FOR_QUESTION) - (int)(m_clockCounter);
	QuestionResult* result = new QuestionResult(m_curQuest->m_id, isRight, answerTime);
	questResults->addObject(result);
		
	if (questResults->count() >= QUEST_RESULTS_NUMBER - 1)
	{
		CCLOG("CLEAR--SEND--");
		//clear
		DataManager::sharedDataManager()->SetQuestResults(NULL);

		//send to server
		GameClientManager::sharedGameClientManager()->SendQuestResults(questResults);

	}
	else
	{
		//save again
		DataManager::sharedDataManager()->SetQuestResults(questResults);
	}

 	nextQuestion(NULL);
}
Esempio n. 4
0
void Game::checkQuestionTimeLimit()
{
	if(m_questionTimer.getElapsedTime().asSeconds() > m_maxTimePerQuestion)
	{
		nextQuestion(false, m_currentQuestion.getQuestion(), m_currentQuestion.getAnswer(), "Not Answered!");
		m_questionTimer.restart();
	}
}
Esempio n. 5
0
void boxAsker::init()
{
	p_accept -> setText(i18n("&Accept"));

	resetAnswers();
	clearAsked();
	nextQuestion();
	
	p_accept -> disconnect();
	connect(p_accept, SIGNAL(clicked()), this, SLOT(checkAnswer()));
}
Esempio n. 6
0
void MainWindow::testMode()
{
    if ( _bookmarkList->size() > 2 )
    {
        ui->glwidget->enableHitMode(true);
        QTime time = QTime::currentTime();
        qsrand((uint)time.msec());
        nextQuestion();
        ui->rightPanel->setCurrentIndex(3);
    }
    else
        statusBar()->showMessage("INFO: Ask Me! mode need two bookmarks or more.");      // Show information message.
}
void SoloGameScene::itHelp3Callback( CCObject* pSender )
{
	int diamond = DataManager::sharedDataManager()->GetDiamond();
	int diamond_for_skip = DataManager::sharedDataManager()->GetDiamondForSkip();
	if (diamond < diamond_for_skip)
	{
		PLAY_OUT_PORP_EFFECT;
		m_lbDiamond->runAction(CCSequence::createWithTwoActions(
			CCScaleTo::create(0.2f, 1.5f),
			CCScaleTo::create(0.2f, 1.0f)
			));
		return;
	}

	DataManager::sharedDataManager()->AddDiamond(- diamond_for_skip);
	m_lbDiamond->setString(CCString::createWithFormat("%d", DataManager::sharedDataManager()->GetDiamond())->getCString());
	PLAY_GET_BOMB_EFFECT;

	nextQuestion(NULL);
}
Esempio n. 8
0
void Game::handleEvents()
{
	sf::Event event;
	while (m_window->pollEvent(event))
	{
		if(event.type == sf::Event::Closed)
		{
			forceQuit();
		}

		if(event.type == sf::Event::MouseMoved)
		{
			//Buttons
			for(int i = 0; i < m_questionButtons.size(); i++)
			{
				if(m_questionButtons[i].getShape().getGlobalBounds().contains(event.mouseMove.x, event.mouseMove.y))
					m_questionButtons[i].startHover();
				else
					m_questionButtons[i].endHover();
			}
		}

		//clicks
		if(event.type == sf::Event::MouseButtonReleased)
		{
			if(event.mouseButton.button == sf::Mouse::Left)
			{
				for(int i = 1; i < m_questionButtons.size(); i++)
				{
					if(m_questionButtons[i].getShape().getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
					{
						nextQuestion(m_questionButtons[i].getString() == m_currentQuestion.getAnswer(), 
							m_currentQuestion.getQuestion(), m_currentQuestion.getAnswer(), 
							m_questionButtons[i].getString());
						
					}
				}
			}
		}
	}
}
Esempio n. 9
0
Trainer::Trainer(int minLevel, int maxLevel,
                 QString sourceLanguage, QString targetLanguage,
                 QList<Translation> wordList,
                 TextToSpeech &tts,
                 PhoneticsManager &phoneticsManager,
                 QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Trainer)
    , tts(tts)
    , sourceLanguage(sourceLanguage)
    , targetLanguage(targetLanguage)
    , trainingManager(minLevel, maxLevel, sourceLanguage, targetLanguage, phoneticsManager)
{
    ui->setupUi(this);

    connect(&trainingManager, SIGNAL(statusChanged(TrainingStatus)), SLOT(updateStatus(TrainingStatus)));
    connect(&trainingManager, SIGNAL(mistake()), SLOT(madeMistake()));
    connect(&trainingManager, SIGNAL(finished(TrainingStatus)), SLOT(trainingFinished(TrainingStatus)));
    connect(&trainingManager, SIGNAL(nextQuestion()), SLOT(gotNextQuestion()));

    connect(&tts, SIGNAL(synthesisReady(QString,QString)), SLOT(enableListen()));
    connect(&tts, SIGNAL(synthesisSuccess()), SLOT(enableListen()));

    QSettings settings;
    ui->reverseMode->setChecked(settings.value("reverseMode").value<bool>());

    trainingManager.loadWords(wordList);

    QStringList const dirs = QStringList()
            << ":/wordlists"
            << "./wordlists";

    foreach (QString const &dir, dirs)
        trainingManager.loadWords(QDir(dir));
    foreach (QString const &dir, dirs)
        trainingManager.loadHints(QDir(dir));

    trainingManager.start();
}
Esempio n. 10
0
MainWindow::MainWindow()
{
    setupUi(this);
    if (tr("LTR") == "RTL") {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }

#ifndef Q_OS_WIN32
    testPageSplitter->setPalette(this->palette());
#endif

    remainingTimeLcdNumber->setVisible(false);
    remainingTimeProgressBar->setVisible(false);
    label_minutes->setVisible(false);
    questionTextSvgSplitter->setCollapsible(0, false);
    questionTextSvgSplitter->setCollapsible(1, true);
    tcpSocket = new QTcpSocket(this);
    progress_dialog = NULL;
    current_test_use_groups = false;
    current_connection_local = false;

    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateTime()));
    QObject::connect(tbtnQuit, SIGNAL(released()), this, SLOT(close()));
    QObject::connect(tbtnAbout, SIGNAL(released()), this, SLOT(about()));
    QObject::connect(tbtnGetReady, SIGNAL(released()), this, SLOT(getReady()));
    QObject::connect(tbtnStart, SIGNAL(released()), this, SLOT(start()));
    QObject::connect(tbtnBrowse_DBPath, SIGNAL(released()), this, SLOT(browse_i()));
    QObject::connect(tbtnBrowse_savePath, SIGNAL(released()), this, SLOT(browse_o()));
    QObject::connect(tbtnLoad, SIGNAL(released()), this, SLOT(loadFile()));
    QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), savePathLineEdit, SLOT(setDisabled(bool)));
    QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), tbtnBrowse_savePath, SLOT(setDisabled(bool)));
    QObject::connect(serverNameLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableConnectButton()));
    QObject::connect(serverPortLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableConnectButton()));
    QObject::connect(DBPathLineEdit, SIGNAL(textChanged(const QString &)),
                     this, SLOT(enableLoadButton()));
    QObject::connect(tbtnConnect, SIGNAL(released()), this, SLOT(connectSocket()));
    QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readIncomingData()));
    QObject::connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
                     this, SLOT(displayError(QAbstractSocket::SocketError)));
    QObject::connect(LQListWidget, SIGNAL(currentTextChanged(QString)),
                     this, SLOT(setCurrentQuestion()));
    QObject::connect(svgDisplayWidget, SIGNAL(titleClicked(const QString &)), this, SLOT(previewSvg(const QString &)));
    QObject::connect(btnNext, SIGNAL(released()), this, SLOT(nextQuestion()));
    QObject::connect(btnLast, SIGNAL(released()), this, SLOT(lastQuestion()));
    QObject::connect(btnFinish, SIGNAL(released()), this, SLOT(finish()));
    QObject::connect(btnNewTest, SIGNAL(released()), this, SLOT(newTest()));
    QObject::connect(btnQuit, SIGNAL(released()), this, SLOT(close()));

    rbtngrpInputType = new QButtonGroup (this);
    rbtngrpInputType->addButton(rbtnNetwork);
    rbtngrpInputType->addButton(rbtnFromFile);
    QObject::connect(rbtngrpInputType, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(toggleInputType(QAbstractButton *)));

    QObject::connect(answersView, SIGNAL(buttonReleased(Question::Answers)), this, SLOT(setQuestionAnswered(Question::Answers)));

    for (int i = 0; i < 8; ++i) {
        infoTableWidget->setItem(i, 0, new QTableWidgetItem);
    }
    ITW_test_name = infoTableWidget->item(0, 0);
    ITW_test_date = infoTableWidget->item(1, 0);
    ITW_test_timestamp = infoTableWidget->item(2, 0);
    ITW_test_time = infoTableWidget->item(3, 0);
    ITW_test_qnum = infoTableWidget->item(4, 0);
    ITW_test_fnum = infoTableWidget->item(5, 0);
    ITW_test_categories = infoTableWidget->item(6, 0);
    ITW_test_passmark = infoTableWidget->item(7, 0);
    ITW_test_comments = new QTextBrowser (infoTableWidget);
    infoTableWidget->setCellWidget(8, 0, ITW_test_comments);
    infoTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    infoTableWidget->verticalHeader()->setSectionResizeMode(8, QHeaderView::Stretch);
    resultsTableWidget->setColumnCount(1);
    resultsTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    resultsTableWidget->horizontalHeader()->hide();
    
    loadSettings();
    
    // Check app args ----------------------------------------------------------
    if (qApp->arguments().count() > 2) {
        if (qApp->arguments().at(1) == "-port") {
            serverNameLineEdit->setText("Localhost");
            serverPortLineEdit->setText(qApp->arguments().at(2));
            connectSocket();
        }
    } else if (qApp->arguments().count() > 1) {
        openFile(qApp->arguments().at(1));
    }
}
Esempio n. 11
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Menu
    QMenu* modelMenu = menuBar()->addMenu("&Model");
    modelMenu->addAction("&Open model...",  this, SLOT(openModel()) );
    modelMenu->addSeparator();
    modelMenu->addAction("&Close model",    this, SLOT(closeModel()) );

    QMenu* markMenu = menuBar()->addMenu("&Bookmarks");
    markMenu->addAction("&New file...",     this, SLOT(closeBookmarksFile()) );
    markMenu->addAction("&Open file...",    this, SLOT(openBookmarksFile()) );
    markMenu->addSeparator();
    markMenu->addAction("&Close file",      this, SLOT(closeBookmarksFile()) );
    markMenu->addSeparator();
    markMenu->addAction("&Save file", this, SLOT(saveBookmarksFile()));
    markMenu->addAction("&Save file as...", this, SLOT(saveAsBookmarksFile()));

    QMenu* viewMenu = menuBar()->addMenu("&View");
    viewMenu->addAction("&View as points",    this,       SLOT(viewAsPoints()) );
    viewMenu->addAction("&View as wired",    this,       SLOT(viewAsWired()) );
    viewMenu->addAction("&View as solid",  this,        SLOT(viewAsSolid()) );
    viewMenu->addAction("&View as solid + wired",this,   SLOT(viewAsSolidWire()) );

    QMenu* modeMenu = menuBar()->addMenu("&Mode");
    modeMenu->addAction("&Viewer",    this,             SLOT(viewerMode()) );
    modeMenu->addAction("&Editor",    this,             SLOT(editorMode()) );
    modeMenu->addAction("&Ask Me!",      this,             SLOT(testMode()) );


    // Section list panel buttons.
    QObject::connect(ui->addButton, SIGNAL(clicked()), this, SLOT(showAddSectionPanel()));
    QObject::connect(ui->editButton, SIGNAL(clicked()), this, SLOT(showEditSectionPanel()));
    QObject::connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrentSection()));
    QObject::connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoSectionPanel()));
    QObject::connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
                     this, SLOT(listWidgetItemClicked(QListWidgetItem*)));

    // Add bookmark panel buttons.
    QObject::connect(ui->addModeButton, SIGNAL(clicked()), this, SLOT(setAddSelectionMode()));
    QObject::connect(ui->removeModeButton, SIGNAL(clicked()), this, SLOT(setRemoveSelectionMode()));
    QObject::connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveBookmark()));
    QObject::connect(ui->discardButton, SIGNAL(clicked()), this, SLOT(discardBookmark()));
    QObject::connect(ui->brushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int)));

    // Information panel buttons
    QObject::connect(ui->backButton, SIGNAL(clicked()), this, SLOT(showListPanel()));

    // Test panel buttons
    QObject::connect(ui->nextQuestionButton, SIGNAL(clicked()), this, SLOT(nextQuestion()));
    QObject::connect(ui->glwidget, SIGNAL(pickResult(std::set<unsigned int>)), this, SLOT(checkResponse(std::set<unsigned int>)));


    // Set window title.
    setWindowTitle("untitled.txt");

    // Initialize variables.
    _bookmarkList = new BookmarkList();
    clearBookmarkList();
    _model = new Model();
    _indexTest = 0;

    // Set viewer mode.
    viewerMode();

    // Show welcome message
    statusBar()->showMessage("Welcome to 3D Marker.");
}
bool SoloGameScene::init()
{
    if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) )
    {
        return false;
    }
	
	SoloGameScene::QUEST_RESULTS_NUMBER = CONF_INT(QUEST_RESULTS_NUMBER);

	m_curScore = DataManager::sharedDataManager()->GetSoloScore();
	m_curQuestionNumber = DataManager::sharedDataManager()->GetSoloQuestionNumber();
	m_curRightAnswer = -1;
	m_clockCounter = CONF_INT(SOLO_TIME_FOR_QUESTION);
	m_isRight = false;
	m_curDisableChoose = 4;
	m_isUsedInfiniteTime = false;

	MY_ADD_SPRITE(bg, "game_background.png", ccp(400, 640));
	
	MY_CREATE_SPRITE(defaultAvatar, "avatar.png", ccp(86, 1280-86));
	m_defaultAvatar = defaultAvatar;
	this->addChild(m_defaultAvatar);
	
	string photoPath = DataManager::sharedDataManager()->GetFbPhotoPath();
	if (photoPath.length() > 0)
	{
		MY_CREATE_SPRITE(fbAvatar, photoPath.c_str(), ccp(86, 1280-86));
		m_fbAvatar = fbAvatar;
		this->addChild(m_fbAvatar);
		m_fbAvatar->setScale((m_defaultAvatar->getContentSize().width - 7) / CONF_INT(AVATAR_SIZE));
	}
	
	string name = DataManager::sharedDataManager()->GetName();
	name = MY_LIMIT_STR(name, 22, "");
	MY_ADD_LABELTTF(lbName, name.c_str(), CONF_STR(FONT_NORMAL), 36, ccBLACK, ccp(12, 1280-195));
	m_lbName = lbName;
	m_lbName->setAnchorPoint(ANCHOR_LEFT);

	MY_ADD_SPRITE(score, "score.png", ccp(203, 1280-41));
	MY_ADD_LABELTTF(_lbScore, CCString::createWithFormat("%d", m_curScore)->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(240, 1280-46));
	_lbScore->setAnchorPoint(ANCHOR_LEFT);
	m_lbScore = _lbScore;

	MY_ADD_SPRITE(sprDiamond, "diamond.png", ccp(203, 1280-100));
	int diamond = DataManager::sharedDataManager()->GetDiamond();
	MY_ADD_LABELTTF(_lbDiamond, CCString::createWithFormat("%d", diamond)->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(240, 1280-100));
	_lbDiamond->setAnchorPoint(ANCHOR_LEFT);
	m_lbDiamond = _lbDiamond;
	
	MY_ADD_SPRITE(sprClock, "clock.png", ccp(400, 1280-200));

	MY_ADD_LABELTTF( _lbClock, CCString::createWithFormat("%d", (int)m_clockCounter)->getCString(), 
		CONF_STR(FONT_NORMAL), 64, ccBLACK, sprClock->getPosition());
	_lbClock->setAnchorPoint(ANCHOR_CENTER);
	m_lbClock = _lbClock;

	m_menu = CCMenu::create();
	m_menu->setPosition(CCPointZero);
	this->addChild(m_menu);

	MY_ADD_MENU_ITEM(itBack, "back.png", "backDown.png", "back.png", SoloGameScene::menuCallback, ccp(60, 60));
	m_itBack = itBack;

	//HELP

	MY_CREATE_MENU_ITEM(itHelp1, "help1.png", "help1Down.png", "help1Down.png", SoloGameScene::itHelp1Callback, ccp(740, 1280-60));
	m_menu->addChild(itHelp1);
	MY_CREATE_MENU_ITEM(itHelp2, "help2.png", "help2Down.png", "help2Down.png", SoloGameScene::itHelp2Callback, ccp(640, 1280-60));
	m_menu->addChild(itHelp2);
	MY_CREATE_MENU_ITEM(itHelp3, "help3.png", "help3Down.png", "help3Down.png", SoloGameScene::itHelp3Callback, ccp(540, 1280-60));
	m_menu->addChild(itHelp3);

	initQuestionItems();

	//RESULT //////////////////////////////////////////////////////////////////////////

	MY_ADD_SPRITE(_sprGameResult, "game_result.png", ccp(400, 640));
	m_sprGameResult = _sprGameResult;
	m_sprGameResult->setVisible(false);

	//+10 (-5)
	CCLabelTTF* changeScore = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 120);
	changeScore->setFontFillColor(ccBLACK);
	changeScore->setColor(ccBLACK);
	changeScore->setAnchorPoint(ANCHOR_RIGHT);
	changeScore->setPosition(ccp(380, 1280-880));
	changeScore->setTag(1);
	m_sprGameResult->addChild(changeScore);

	//Right, wrong
	CCLabelTTF* rightWrong = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 72);
	rightWrong->setFontFillColor(ccBLACK);
	rightWrong->setColor(ccBLACK);
	rightWrong->setAnchorPoint(ANCHOR_RIGHT);
	rightWrong->setPosition(ccp(380, 1280-722));
	rightWrong->setTag(2);
	m_sprGameResult->addChild(rightWrong);
	
	MY_CREATE_MENU_ITEM(itNext, "next.png", "nextDown.png", "nextDown.png", SoloGameScene::checkBeforeNextQuestion, ccp(400, 1280-879));
	itNext->setAnchorPoint(ANCHOR_LEFT);
	CCMenu* nextMenu = CCMenu::create(itNext, NULL);
	nextMenu->setPosition(CCPointZero);
	m_sprGameResult->addChild(nextMenu);

	nextQuestion(NULL);
	
	PLAY_BACKGROUND_MUSIC;
    return true;
}