void CharCreator::closeEvent(QCloseEvent *event)
{
    // If user has edited character info
    if (ui->nameValue->text() != "" || ui->levelValue->text().toInt() > 1 || rollClicked == true) {
        // Display warning about unsaved info
        QMessageBox::StandardButton warn = QMessageBox::warning(this, "Save Character?", "Do you want to save the changes you have made to the current character?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes);
        if (warn == QMessageBox::Yes) {
            if (!on_action_Save_triggered()) {
                event->ignore();
                return;
            }
            this->sp->show();
            event->accept();
        }
        else if (warn == QMessageBox::Cancel) {
            event->ignore();
        }
        else if (warn == QMessageBox::No) {
            this->sp->show();
            event->accept();
        }
    }
    else {
        this->sp->show();
        event->accept();
    }
}
void CharCreator::on_action_Open_triggered()
{
    // If user has edited character info
    if (ui->nameValue->text() != "" || ui->levelValue->text().toInt() > 1 || rollClicked == true) {
        // Display warning about unsaved info
        QMessageBox::StandardButton warn = QMessageBox::warning(this, "Save Character?", "Do you want to save the changes you have made to the current character?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes);
        if (warn == QMessageBox::Yes) {
            if (!on_action_Save_triggered()) {
                return;
            }
            setupDefaults();
        }
        else if (warn == QMessageBox::Cancel) {
            return;
        }
        else if (warn == QMessageBox::No) {
            setupDefaults();
        }
    }
    else {
        setupDefaults();
    }
    QString charName = QFileDialog::getOpenFileName(this, tr("Open Character"), "C:/Users/chris/Documents/Visual Studio 2012/Projects/DnD_Game/characters", tr("CHARACTER Files (*.dcchar)"));
    std::string fileName = charName.toStdString();
    c->loadCharacter(fileName);
    updateGUI();
    ui->levelButton->setEnabled(true);
}
Esempio n. 3
0
int MainWindow::_Save_query()
{
    QMessageBox mssgBox;
    mssgBox.setText( ui->action_Save->whatsThis() );
    mssgBox.setStandardButtons( QMessageBox::Yes |
                                QMessageBox::No |
                                QMessageBox::Cancel );
    int ret = mssgBox.exec();

    if ( ret == QMessageBox::Yes )
    {
        on_action_Save_triggered();

        if ( _fileName.isEmpty() )
            ret = QMessageBox::Cancel;
    }

    return ret;
}
void CharCreator::on_action_New_triggered()
{
    // If user has edited character info
    if (ui->nameValue->text() != "" || ui->levelValue->text().toInt() > 1 || rollClicked == true) {
        // Display warning about unsaved info
        QMessageBox::StandardButton warn = QMessageBox::warning(this, "Save Character?", "Do you want to save the changes you have made to the current character?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes);
        if (warn == QMessageBox::Yes) {
            if (!on_action_Save_triggered()) {
                return;
            }
            c = new Fighter();
            setupDefaults();
        }
        else if (warn == QMessageBox::Cancel) {
            return;
        }
        else if (warn == QMessageBox::No) {
            c = new Fighter();
            setupDefaults();
        }
    }
}
Esempio n. 5
0
int EditorWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_actionClear_triggered(); break;
        case 1: on_action_New_triggered(); break;
        case 2: on_action_Run_File_triggered(); break;
        case 3: onEngineStarted(); break;
        case 4: onEngineStopped(); break;
        case 5: onEnginePanic((*reinterpret_cast< Atom(*)>(_a[1])),(*reinterpret_cast< Word(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4]))); break;
        case 6: on_action_Inspect_Selection_triggered(); break;
        case 7: on_action_Quit_triggered(); break;
        case 8: on_action_Save_triggered(); break;
        case 9: on_actionSave_as_triggered(); break;
        case 10: on_action_Open_triggered(); break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}