mirror of
https://github.com/isledecomp/SIEdit.git
synced 2024-11-23 07:38:09 -05:00
app: add Flags property to MxOb
This commit is contained in:
parent
c637401d42
commit
428b2ad317
2 changed files with 96 additions and 0 deletions
|
@ -51,6 +51,65 @@ MxObPanel::MxObPanel(QWidget *parent) :
|
|||
|
||||
row++;
|
||||
|
||||
auto flag_group = new QGroupBox(tr("Flags"));
|
||||
layout()->addWidget(flag_group, row, 0, 1, 2);
|
||||
|
||||
row++;
|
||||
|
||||
{
|
||||
auto flag_layout = new QGridLayout(flag_group);
|
||||
|
||||
int flag_row = 0;
|
||||
|
||||
flag_layout->addWidget(new QLabel(tr("Value")), flag_row, 0);
|
||||
|
||||
flag_edit_ = new QLineEdit();
|
||||
flag_layout->addWidget(flag_edit_, flag_row, 1);
|
||||
|
||||
flag_row++;
|
||||
|
||||
auto loop_cache = new QCheckBox(tr("Loop from Cache"));
|
||||
loop_cache->setProperty("flag", 0x01);
|
||||
connect(loop_cache, &QCheckBox::clicked, this, &MxObPanel::FlagCheckBoxClicked);
|
||||
flag_checkboxes_.append(loop_cache);
|
||||
flag_layout->addWidget(loop_cache, flag_row, 0, 1, 2);
|
||||
|
||||
flag_row++;
|
||||
|
||||
auto no_loop = new QCheckBox(tr("No Loop"));
|
||||
no_loop->setProperty("flag", 0x02);
|
||||
connect(no_loop, &QCheckBox::clicked, this, &MxObPanel::FlagCheckBoxClicked);
|
||||
flag_checkboxes_.append(no_loop);
|
||||
flag_layout->addWidget(no_loop, flag_row, 0, 1, 2);
|
||||
|
||||
flag_row++;
|
||||
|
||||
auto loop_stream = new QCheckBox(tr("Loop from Stream"));
|
||||
loop_stream->setProperty("flag", 0x04);
|
||||
connect(loop_stream, &QCheckBox::clicked, this, &MxObPanel::FlagCheckBoxClicked);
|
||||
flag_checkboxes_.append(loop_stream);
|
||||
flag_layout->addWidget(loop_stream, flag_row, 0, 1, 2);
|
||||
|
||||
flag_row++;
|
||||
|
||||
auto transparent = new QCheckBox(tr("Transparent"));
|
||||
transparent->setProperty("flag", 0x08);
|
||||
connect(transparent, &QCheckBox::clicked, this, &MxObPanel::FlagCheckBoxClicked);
|
||||
flag_checkboxes_.append(transparent);
|
||||
flag_layout->addWidget(transparent, flag_row, 0, 1, 2);
|
||||
|
||||
flag_row++;
|
||||
|
||||
auto unknown = new QCheckBox(tr("Unknown"));
|
||||
unknown->setProperty("flag", 0x20);
|
||||
connect(unknown, &QCheckBox::clicked, this, &MxObPanel::FlagCheckBoxClicked);
|
||||
flag_checkboxes_.append(unknown);
|
||||
flag_layout->addWidget(unknown, flag_row, 0, 1, 2);
|
||||
|
||||
flag_row++;
|
||||
|
||||
}
|
||||
|
||||
layout()->addWidget(new QLabel(tr("Duration")), row, 0);
|
||||
|
||||
duration_edit_ = new QSpinBox();
|
||||
|
@ -105,6 +164,12 @@ void MxObPanel::OnOpeningData(si::Chunk *chunk)
|
|||
presenter_edit_->setText(QString(chunk->data("Presenter")));
|
||||
obj_id_edit_->setValue(chunk->data("ID"));
|
||||
|
||||
flag_edit_->setText(QString::number(chunk->data("Flags"), 16));
|
||||
|
||||
for (QCheckBox* cb : qAsConst(flag_checkboxes_)) {
|
||||
cb->setChecked(cb->property("flag").toUInt() & chunk->data("Flags"));
|
||||
}
|
||||
|
||||
duration_edit_->setValue(chunk->data("Duration"));
|
||||
loops_edit_->setValue(chunk->data("Loops"));
|
||||
|
||||
|
@ -117,6 +182,12 @@ void MxObPanel::OnClosingData(si::Chunk *chunk)
|
|||
{
|
||||
chunk->data("Type") = type_combo_->currentIndex();
|
||||
|
||||
bool ok;
|
||||
u32 flags = flag_edit_->text().toUInt(&ok, 16);
|
||||
if (ok) {
|
||||
chunk->data("Flags") = flags;
|
||||
}
|
||||
|
||||
chunk->data("Duration") = duration_edit_->value();
|
||||
chunk->data("Loops") = loops_edit_->value();
|
||||
|
||||
|
@ -124,3 +195,20 @@ void MxObPanel::OnClosingData(si::Chunk *chunk)
|
|||
chunk->data("Direction") = dir_edit_->GetValue();
|
||||
chunk->data("Up") = up_edit_->GetValue();
|
||||
}
|
||||
|
||||
void MxObPanel::FlagCheckBoxClicked(bool e)
|
||||
{
|
||||
u32 flag = sender()->property("flag").toUInt();
|
||||
bool ok;
|
||||
u32 current = flag_edit_->text().toUInt(&ok, 16);
|
||||
if (ok) {
|
||||
if (e) {
|
||||
current |= flag;
|
||||
}
|
||||
else {
|
||||
current &= ~flag;
|
||||
}
|
||||
|
||||
flag_edit_->setText(QString::number(current, 16));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef MXOBPANEL_H
|
||||
#define MXOBPANEL_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
@ -25,6 +26,8 @@ private:
|
|||
QLineEdit *filename_edit_;
|
||||
QSpinBox *obj_id_edit_;
|
||||
|
||||
QLineEdit* flag_edit_;
|
||||
|
||||
QSpinBox *duration_edit_;
|
||||
QSpinBox *loops_edit_;
|
||||
|
||||
|
@ -32,6 +35,11 @@ private:
|
|||
Vector3Edit *dir_edit_;
|
||||
Vector3Edit *up_edit_;
|
||||
|
||||
QVector<QCheckBox*> flag_checkboxes_;
|
||||
|
||||
private slots:
|
||||
void FlagCheckBoxClicked(bool e);
|
||||
|
||||
};
|
||||
|
||||
#endif // MXOBPANEL_H
|
||||
|
|
Loading…
Reference in a new issue