/*If the purchase is succesful, set labels*/
bool Functions::tryPurchase(QPushButton *buyBtn, double price, QPushButton *canBtn, QLabel *errLab, double* dollars){

    QString sPrice = QString::number(price);
    QString Confirm = "Confirm?";

    //If showing price
    if(buyBtn->text() != Confirm){
        showElement(canBtn);
        buyBtn->setText(Confirm);
    }
    //If confirming purchase
    else if (buyBtn->text() != sPrice){

        //If we can afford it
        if(!(*dollars - price < 0)) {
            *dollars = *dollars - price;
            hideElement(canBtn);
            hideElement(errLab);
            setPurchased(buyBtn);
            return true;
        }
        else {
            //OUTPUT ERROR
           showElement(errLab);
           return false;
        }
    }
    return false;

}
void MainApplication::showBothEvents()
{
    showElement(giantsEventView_);
    showElement(sharksEventView_);

    double gx = giantsEventView_->property("bothX").toDouble();
    double sx = sharksEventView_->property("bothX").toDouble();

    giantsEventView_->setProperty("x", gx);
    sharksEventView_->setProperty("x", sx);
}
void MainApplication::showOneEvent(QObject* eventViewToShow)
{
    if (giantsEventView_ == eventViewToShow) {
        showElement(giantsEventView_);
        hideElement(sharksEventView_);
    }
    else {
        showElement(sharksEventView_);
        hideElement(giantsEventView_);
    }

    eventViewToShow->setProperty("x", 500./2. - 100./2.);
}
Beispiel #4
0
WizardWelcome::WizardWelcome(QWidget* parent)
    : QBookForm(parent)
    , current_widget(0)
    , m_WizardLanguage(0)
    , m_WizardDateTime(0)
    , m_elfFinishWizard(0)
{
    qDebug() << Q_FUNC_INFO;
    setupUi(this);

    connect(nextStepBtn, SIGNAL(clicked()), this, SLOT(requestConnection()));
    connect(skipBtn, SIGNAL(clicked()), this, SLOT(skipWizard()));
    nextStepBtn->setFocus();

    if(QBook::settings().value("setting/initial_lang_selection",true).toBool())
    {
        if(!m_WizardLanguage)
            m_WizardLanguage = new WizardLanguage(this);


        connect(m_WizardLanguage, SIGNAL(languageSelected()), this, SLOT(hideLanguageSettings()));
        showElement(m_WizardLanguage);
    }
    if(QBookApp::instance()->isActivated())
    {
        intro3Lbl->hide();
        welcomeTitleLbl->setText(tr("Enlazar dispositivo"));
    }else
        intro3Lbl->show();

    // Check if: 1. language selection is needed, 2. initial power on for user is set and 3. Device has not been manually deactivated because of OTA
    if(!QBook::settings().value("setting/initial_lang_selection", true).toBool()&& QBook::settings().value("setting/initial",true).toBool()
            && !QBook::settings().value("setting/activated").isValid())
    {
        if(!m_WizardDateTime)
            m_WizardDateTime = new WizardDateTime(this);

        connect(m_WizardDateTime, SIGNAL(hideMe()), this, SLOT(hideWizardDateTime()));
        showElement(m_WizardDateTime);
    }
    QFile fileSpecific(":/res/wizard_styles.qss");
    QFile fileCommons(":/res/wizard_styles_generic.qss");
    fileSpecific.open(QFile::ReadOnly);
    fileCommons.open(QFile::ReadOnly);

    QString styles = QLatin1String(fileSpecific.readAll() + fileCommons.readAll());
    setStyleSheet(styles);
}
void WizardWelcome::hideLanguageSettings()
{
        qDebug() << Q_FUNC_INFO;
        Screen::getInstance()->queueUpdates();
        m_WizardLanguage->hide();
        if(!m_WizardDateTime)
            m_WizardDateTime = new WizardDateTime(this);

        connect(m_WizardDateTime, SIGNAL(hideMe()), this, SLOT(hideWizardDateTime()));
        showElement(m_WizardDateTime);
        Screen::getInstance()->setMode(Screen::MODE_SAFE, true, FLAG_FULLSCREEN_UPDATE, Q_FUNC_INFO);
        Screen::getInstance()->setUpdateScheme(Screen::SCHEME_MERGE, true);
        Screen::getInstance()->flushUpdates();
}
/*Add currency*/
void Functions::addCurrency(QPushButton *valueBtn, QPushButton *cancelBtn ,double value, double* dollars){
    QString sValue = QString::number(value);
    QString Confirm = "Confirm";

    if(valueBtn->text() != Confirm){
        showElement(cancelBtn);
        valueBtn->setText(Confirm);
    }
    else if (valueBtn->text() != sValue){
        *dollars = *dollars + value;
        hideElement(cancelBtn);
        valueBtn->setText("$" +sValue);
    }
}
Beispiel #7
0
// Find out what minions are placed at the specified location
void whatsThere(DracView currentView, LocationID where,
				int *numTraps, int *numVamps) {
	if (where == currentView->vampLocation) {
		*numVamps = 1;
	} else {
		*numVamps = 0;
	}

	*numTraps = 0;
	for (int i = 0; i < TRAIL_SIZE; i++) {
		if (showElement(currentView->traps, i) == where) {
			*numTraps += 1;
		}
	}
	return;
}
void WizardWelcome::showRegisterFailed()
{
    qDebug() << Q_FUNC_INFO;

    ConfirmDialog* dialog = new ConfirmDialog(this,tr("Credit Card Register failed."));
    Screen::getInstance()->setMode(Screen::MODE_SAFE,true,Q_FUNC_INFO);
    dialog->exec();
    delete dialog;

    QBookApp::instance()->popForm(QBookApp::instance()->browserWizard());

    if(!m_elfFinishWizard)
    {
        m_elfFinishWizard = new WizardFinish(this);
        connect(m_elfFinishWizard, SIGNAL(closeWizard()), this, SLOT(goToCloseWizard()));
    }
    showElement(m_elfFinishWizard);
}
void WizardWelcome::goWizardFinished()
{
    qDebug() << Q_FUNC_INFO;

    disconnectWifiObserver();

    Screen::getInstance()->queueUpdates();
    QBookApp::instance()->popForm(QBookApp::instance()->browserWizard());

    if(!m_elfFinishWizard)
    {
        m_elfFinishWizard = new WizardFinish(this);
        connect(m_elfFinishWizard, SIGNAL(closeWizard()), this, SLOT(goToCloseWizard()));
    }

    showElement(m_elfFinishWizard);
    Screen::getInstance()->setMode(Screen::MODE_SAFE, true, Q_FUNC_INFO);
    Screen::getInstance()->flushUpdates();
}
Beispiel #10
0
// Creates a new DracView to summarise the current state of the game
DracView newDracView(char *pastPlays, PlayerMessage messages[]) {
	DracView dracView = malloc(sizeof(struct dracView));
	dracView->g = newGameView(pastPlays, messages);
	dracView->vampLocation = NOWHERE;
	dracView->traps = newTrail(TRAIL_SIZE);

	// If pastPlays is empty, we just return early.
	if (strcmp(pastPlays, "") == 0) {
		return dracView;
	}

	char *currentPlayMarker = pastPlays;
	char currentPlay[8] = {'\0'};
	char givenLocation[3] = {'\0'};
	LocationID currentPlace = NOWHERE;
	while (currentPlayMarker != NULL) {
		memcpy(currentPlay, currentPlayMarker, 8);

		// We isolate the location part for easy access..
		memcpy(givenLocation, currentPlay + 1, 2);

		currentPlace = abbrevToID(givenLocation);

		if (currentPlay[0] == 'D') {
			// Then we parse each of the next four characters.
			for (int i = 3; i < 6; i++) {
				if (i == 3 || i == 4) {
					switch (currentPlay[i]) {
						// TRAP PLACED
						case 'T':
							prepend(dracView->traps, currentPlace);
							break;
							// VAMPIRE PLACED
						case 'V':
							dracView->vampLocation = currentPlace;
							break;
							// NOTHING
						default:
							break;
					}
				} else if (i == 5) {
					switch (currentPlay[i]) {
						// TRAP LEAVES
						case 'M':
							while (showElement(dracView->traps, TRAIL_SIZE - 1) != NOWHERE) {
								prepend(dracView->traps, NOWHERE);
							}
							prepend(dracView->traps, NOWHERE);
							break;
							// VAMPIRE MATURES
						case 'V':
							dracView->vampLocation = NOWHERE;
							break;
							// NOTHING
						default:
							break;
					}
				}
			}
		} else {
			// Then we parse each of the next four characters.
			for (int i = 3; i < 7; i++) {
				switch (currentPlay[i]) {
					// TRAP FOUND
					case 'T':
						removeElement(dracView->traps, abbrevToID(givenLocation));
						break;
						// VAMPIRE FOUND
					case 'V':
						dracView->vampLocation = NOWHERE;
						break;
						// NOTHING
					default:
						break;
				}
			}
		}

		if (currentPlay[7] == '\0') break;
		currentPlayMarker += 8;
	}
	return dracView;
}
void pop(){
	Element *_elementA=top;
	top=top->next;
	showElement(_elementA);
}
bool ConsoleWidget::xmppStanzaOut(IXmppStream *AXmppStream, Stanza &AStanza, int AOrder)
{
	if (AOrder == XSHO_CONSOLE)
		showElement(AXmppStream,AStanza.element(),true);
	return false;
}