Exemplo n.º 1
0
void RotaryKnob::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
    if(isEditMode()) {
        PanelItem::mouseReleaseEvent(event);
    } else {
        update();
    }
}
Exemplo n.º 2
0
KEXPORT void bootUnlockRect(IDirect3DTexture8* self, UINT Level) 
{
    DWORD oldEBP;
    __asm mov oldEBP,ebp;

    static int count = 0;

    int levels = self->GetLevelCount();
    D3DSURFACE_DESC desc;
    if (SUCCEEDED(self->GetLevelDesc(0, &desc))) {
        if (((desc.Width==512 && desc.Height==256 && Level==0) 
                    || (desc.Width==128 && desc.Height==64 && Level==0))
                && *(DWORD*)(oldEBP+0x3c)==0 
                && *(DWORD*)(oldEBP+0x34) + 8 == *(DWORD*)(oldEBP+0x38)
                && (*(WORD*)(*(DWORD*)(oldEBP+0x2c)) & 0xfff0)==0x0510
                ) {

            WORD playerId = 0xffff;
            if (isEditMode()) {
                if (isEditBootsMode()) {
                    return; // no replacement in Edit Boots
                }
                // edit player
                if (desc.Width==512) {
                    playerId = *(WORD*)data[EDITPLAYER_ID];
                    // check boot-type: don't replace the texture if boot-type
                    // is not "editable". That may have some undesirable effects later
                    // if the texture becomes cached.
                    if (data[EDITMODE_CURRPLAYER_MOD]) { //PES6
                        DWORD* pBaseCopy = (DWORD*)data[EDITMODE_CURRPLAYER_MOD];
                        if (*pBaseCopy) {
                            BYTE bootType = *(BYTE*)(*pBaseCopy + 0x61) & data[BOOTTYPE_TEST_MASK];
                            if (bootType!=0) return;
                        }
                    } else if (data[EDITMODE_CURRPLAYER_MOD_DIRECT]) {  //PES5/WE9/WE9LE
                        DWORD pBaseCopy = data[EDITMODE_CURRPLAYER_MOD_DIRECT];
                        BYTE bootType = *(BYTE*)(pBaseCopy + 0x63) & data[BOOTTYPE_TEST_MASK];
                        if (bootType!=0) return;
                    }
                }
            } else {
                // match or training
                int pos = getPosition(*(DWORD*)(oldEBP+0x30));
                playerId = getPlayerId(pos);
            }
            //DumpTexture(self);
            //LogWithNumber(&k_boot, "bootUnlockRect: playerId = %d", playerId);

            bool isBig = desc.Width==512;
            IDirect3DTexture8* bootTexture = getBootTexture(playerId, isBig, &desc, levels);
            if (bootTexture) {
                // replace the texture
                ReplaceTextureLevel(self, bootTexture, 0);
            }
        }

    } else {
        Log(&k_boot, "GetLevelDesc FAILED");
    }
}
Exemplo n.º 3
0
void GaugeCover::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
    setupPainter(painter);

    // Draw the cover image when not editing
    if(!isEditMode()) painter->drawImage(QPoint(0,0),_coverImage);

    PanelItem::paint(painter, option, widget);
}
Exemplo n.º 4
0
void RotaryKnob::mousePressEvent ( QGraphicsSceneMouseEvent * event ) {
    if(isEditMode()) {
        PanelItem::mousePressEvent(event);
    } else {
        dragStartPoint = event->pos();
        _valueStartPoint = _value;
    }
}
Exemplo n.º 5
0
void Switch::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
    if(isEditMode()) {
        PanelItem::mouseReleaseEvent(event);
    } else if(event->pos().x() < switchWidth) {
        _value = !_value;
        _ref->setValue(_value ? 1 : 0);
        update();
    }
}
Exemplo n.º 6
0
void RotaryKnob::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
    if(isEditMode()) {
        PanelItem::mouseMoveEvent(event);
    } else {
        double changeAmount = (event->pos() - dragStartPoint).x();
        // DEBUG << event->pos() - dragStartPoint;
        _value = _valueStartPoint + changeAmount * _change;
        if(_ref) _ref->setValue(QString::number(_value));
        update();
    }
}
Exemplo n.º 7
0
void Allocations::itemSelected(const QModelIndex &current, const QModelIndex &previous)
{
    ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(current.isValid());
    if(isEditMode()) return;
    if(current.isValid()){     
        if(items_model){
            QSqlRecord record = items_model->record(current.row());
            if(!record.isEmpty()){
                ui->from_location_lineEdit->setText(record.value("location").toString());
                ui->from_operator_lineEdit->setText(record.value("name").toString());
            }
            else{
                //current_id = 0;
            }
        }
    }
    else{
        ui->from_location_lineEdit->clear();
        ui->from_operator_lineEdit->clear();
    }
}
Exemplo n.º 8
0
bool Allocations::saveAllocation()
{
    if(ui->to_operator_comboBox->currentText() != ui->to_operator_comboBox->itemModelText() || ui->to_operator_comboBox->itemModelId() < 1){
        ui->to_operator_comboBox->showPopup(2);
        ui->to_operator_comboBox->showTip( tr("Please, choose a valid operator"));
        return false;
    }
    if(ui->to_location_comboBox->currentText() != ui->to_location_comboBox->itemModelText() || ui->to_location_comboBox->itemModelId() < 1){
        ui->to_location_comboBox->showPopup(2);
        ui->to_location_comboBox->showTip(tr("Please, choose a valid location"));
        return false;
    }
    if(!(ui->to_location_comboBox->checkData() & ui->to_operator_comboBox->checkData()
         )){
        int ret = QMessageBox::question(0, tr("Allocations"),
                                        tr("You have blank fields.\n"
                                           "Do you want to continue?\n"),
                                            QMessageBox::Ok | QMessageBox::Cancel);
        if(ret == QMessageBox::Cancel) return false;
    }
    if(isEditMode()){
        if(!getAllocationId()){
            qDebug() << "Unknown allocation id!";
            return false;
        }
        if(!locations_model || !operators_model){
            qDebug() << "Incomplete data for saving. Interrupt ...";
            return false;
        }
        QString info;
        QSqlQuery* query = new QSqlQuery(QSqlDatabase::database());
        if(logger){
            if(!query->exec(QString("SELECT * FROM allocations WHERE `id`=%1").arg(getAllocationId()))){
                logger->writeLog(Logger::Error, Logger::Allocations,
                                 tr("Can not load allocation data.\n%1").arg(query->lastError().text())
                                 );
            }
            else info = logger->infoLog(query);
        }
        if(!query->exec(QString("UPDATE allocations SET `to_location_id`='%1',`to_operator_id`='%2',"
                                "`date`='%3',`note`='%4' WHERE `id`='%5'")
                        .arg(locations_model->data(locations_model->index(ui->to_location_comboBox->currentIndex(), locations_model->fieldIndex("id"))).toInt())
                        .arg(operators_model->data(operators_model->index(ui->to_operator_comboBox->currentIndex(), operators_model->fieldIndex("id"))).toInt())
                        .arg(ui->dateEdit->dateTime().toString("yyyy-MM-dd HH:mm"))
                        .arg(ui->note_textEdit->toPlainText())
                        .arg(getAllocationId())
                        )){
            if(logger) logger->writeLog(Logger::Error, Logger::Allocations,
                                        tr("Can not save data.\n%1").arg(query->lastError().text())
                                        );
            return false;
        }
        if(!query->exec(QString("UPDATE items SET `location_id`='%1',"
                                "`operator_id`='%2' WHERE `id`='%3'")
                        .arg(locations_model->data(locations_model->index(ui->to_location_comboBox->currentIndex(), locations_model->fieldIndex("id"))).toInt())
                        .arg(operators_model->data(operators_model->index(ui->to_operator_comboBox->currentIndex(), operators_model->fieldIndex("id"))).toInt())
                        .arg(getItemId())
                        )){
            if(logger) logger->writeLog(Logger::Error, Logger::Allocations,
                                        tr("Can not save item data.\n%1").arg(query->lastError().text())
                                        );
            return false;
        }
        if(logger) logger->writeLog(Logger::Edit, Logger::Allocations,
                                    tr("Save changes into allocation.\nOld data:\n%1")
                                    .arg(info)
                                    );

    }
    else{
        if(!items_model || !locations_model || !operators_model){
            qDebug() << "Incomplete data for saving. Interrupt ...";
            return false;
        }
        QModelIndex itemIndex = ui->item_treeView->selectionModel()->currentIndex();
        if(!itemIndex.isValid()){
            return false;
        }
        QSqlRecord record = items_model->record(itemIndex.row());
        QSqlQuery* query = new QSqlQuery(QSqlDatabase::database());
        if(!query->exec(QString("SELECT `operator_id`, `location_id` FROM items WHERE `id`=%1")
                        .arg(record.value("id").toInt()))){
            if(logger) logger->writeLog(Logger::Error, Logger::Allocations,
                                        tr("Can not get item data from database.\n%1").arg(query->lastError().text())
                                        );
            return false;
        }
        if(!query->first()){
            qDebug() << "No item with id: " << record.value("id").toInt();
            return false;
        }
        QSqlRecord itemRecord = query->record();
        if(!query->exec(QString("INSERT INTO allocations (`item_id`,`from_operator_id`,`from_location_id`,`to_operator_id`,`to_location_id`,`date`,`note`) "
                                "VALUES ('%1', '%2', '%3', '%4', '%5', '%6', '%7')")
                        .arg(record.value("id").toInt())
                        .arg(itemRecord.value("operator_id").toInt())
                        .arg(itemRecord.value("location_id").toInt())
                        .arg(operators_model->data(operators_model->index(ui->to_operator_comboBox->currentIndex(), operators_model->fieldIndex("id"))).toInt())
                        .arg(locations_model->data(locations_model->index(ui->to_location_comboBox->currentIndex(), locations_model->fieldIndex("id"))).toInt())
                        .arg(ui->dateEdit->dateTime().toString("yyyy-MM-dd HH:mm"))
                        .arg(ui->note_textEdit->toPlainText())
                        )){
            if(logger) logger->writeLog(Logger::Error, Logger::Allocations,
                                        tr("Can not save data.\n%1").arg(query->lastError().text())
                                        );
            return false;
        }
        if(!query->exec(QString("UPDATE items SET `location_id`='%1',"
                                "`operator_id`='%2' WHERE `id`='%3'")
                        .arg(locations_model->data(locations_model->index(ui->to_location_comboBox->currentIndex(), locations_model->fieldIndex("id"))).toInt())
                        .arg(operators_model->data(operators_model->index(ui->to_operator_comboBox->currentIndex(), operators_model->fieldIndex("id"))).toInt())
                        .arg(record.value("id").toInt())
                        )){
            if(logger) logger->writeLog(Logger::Error, Logger::Allocations,
                                        tr("Can not save data.\n%1").arg(query->lastError().text())
                                        );
        }
        if(logger) logger->writeLog(Logger::Add, Logger::Allocations, tr("Defined allocation with id: %1")
                                    .arg(query->lastInsertId().toInt())
                                    );
    }
    return true;
}
Exemplo n.º 9
0
void GaugeCover::setEditMode(bool em) {
    PanelItem::setEditMode(em);
    if(!isEditMode()) drawCoverImage();
    update();
}
Exemplo n.º 10
0
void GaugeCover::itemSizeChanged(float w, float h) {
    Q_UNUSED(w);
    Q_UNUSED(h);
    if(!isEditMode()) drawCoverImage();
    update();
}
Exemplo n.º 11
0
void Switch::mousePressEvent ( QGraphicsSceneMouseEvent * event ) {
    if(isEditMode()) {
        PanelItem::mousePressEvent(event);
    }
}