Feature #339 ยป 0039-Ruledit-Add-terrain-flag-editing.patch
tools/ruledit/edit_terrain.cpp | ||
---|---|---|
#include "edit_terrain.h"
|
||
#define FLAGROWS 15
|
||
/**********************************************************************//**
|
||
Setup edit_terrain object
|
||
**************************************************************************/
|
||
... | ... | |
QGridLayout *ter_layout = new QGridLayout();
|
||
QLabel *label;
|
||
int row = 0;
|
||
int rowcount;
|
||
int column;
|
||
ui = ui_in;
|
||
ter = ter_in;
|
||
natives_layout = new QGridLayout();
|
||
flag_layout = new QGridLayout();
|
||
setWindowTitle(QString::fromUtf8(terrain_rule_name(ter)));
|
||
... | ... | |
natives_layout->addWidget(check, i + 1, 1);
|
||
}
|
||
rowcount = 0;
|
||
column = 0;
|
||
for (int i = 0; i < TER_USER_LAST; i++) {
|
||
enum terrain_flag_id flag = (enum terrain_flag_id)i;
|
||
QCheckBox *check = new QCheckBox();
|
||
label = new QLabel(terrain_flag_id_name(flag));
|
||
flag_layout->addWidget(label, rowcount, column + 1);
|
||
check->setChecked(BV_ISSET(ter->flags, flag));
|
||
flag_layout->addWidget(check, rowcount, column);
|
||
if (++rowcount >= FLAGROWS) {
|
||
column += 2;
|
||
rowcount = 0;
|
||
}
|
||
}
|
||
refresh();
|
||
main_layout->addLayout(ter_layout);
|
||
main_layout->addLayout(natives_layout);
|
||
main_layout->addLayout(flag_layout);
|
||
setLayout(main_layout);
|
||
}
|
||
... | ... | |
**************************************************************************/
|
||
void edit_terrain::closeEvent(QCloseEvent *cevent)
|
||
{
|
||
int rowcount;
|
||
int column;
|
||
// Save values from text fields.
|
||
gfx_tag_given();
|
||
gfx_tag_alt_given();
|
||
... | ... | |
}
|
||
}
|
||
BV_CLR_ALL(ter->flags);
|
||
rowcount = 0;
|
||
column = 0;
|
||
for (int i = 0; i < TER_USER_LAST; i++) {
|
||
QCheckBox *check = static_cast<QCheckBox *>(flag_layout->itemAtPosition(rowcount, column)->widget());
|
||
if (check->isChecked()) {
|
||
BV_SET(ter->flags, i);
|
||
}
|
||
if (++rowcount >= FLAGROWS) {
|
||
rowcount = 0;
|
||
column += 2;
|
||
}
|
||
}
|
||
ter->ruledit_dlg = nullptr;
|
||
}
|
||
tools/ruledit/edit_terrain.h | ||
---|---|---|
QLineEdit *gfx_tag_alt2;
|
||
QGridLayout *natives_layout;
|
||
QGridLayout *flag_layout;
|
||
protected:
|
||
void closeEvent(QCloseEvent *cevent);
|