16 #include <QtCore/qiodevice.h>
17 #include <QtCore/qfile.h>
23 QGridLayout*
layout =
new QGridLayout(
this);
26 layout->addWidget(
new QLabel(tr(
"Path where to create items:"),
this),
line, 0);
30 QPushButton*
browse =
new QPushButton(tr(
"Browse"),
this);
34 layout->addWidget(
new QLabel(tr(
"Archetype name:"),
this),
line, 0);
38 layout->addWidget(
new QLabel(tr(
"Color:"),
this),
line, 0);
43 layout->addWidget(
new QLabel(tr(
"Y position from top:"),
this),
line, 0);
48 layout->addWidget(
new QLabel(tr(
"Bar height:"),
this),
line, 0);
54 QDialogButtonBox*
box =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close, Qt::Horizontal,
this);
56 connect(
box, SIGNAL(rejected()),
this, SLOT(reject()));
59 myColor = QColor::fromRgb(255, 0, 0, 180);
62 setWindowTitle(tr(
"HP bar face generator"));
73 QMessageBox::warning(
this, tr(
"Oops"), tr(
"You must select a destination!"));
77 if (
myName->text().isEmpty())
79 QMessageBox::warning(
this, tr(
"Oops"), tr(
"You must enter a name!"));
85 if (QFile::exists(base +
".arc"))
87 if (QMessageBox::question(
this, tr(
"Confirm file overwrite"), tr(
"File %1 already exists. Overwrite it?").arg(base +
".arc"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
91 QFile arc(base +
".arc");
92 if (!arc.open(QFile::Truncate | QFile::WriteOnly))
94 QMessageBox::critical(
this, tr(
"Error"), tr(
"Error while opening the archetype file %1!").arg(arc.fileName()));
104 QString
line = QString(
"Object %1_%2\nface %1.11%3\nend\n").arg(
myName->text()).arg(
value).arg(
c);
105 arc.write(
line.toLocal8Bit());
108 pic.fill(QColor(0, 0, 0, 0));
109 QPainter device(&pic);
112 QString picName = base +
".base.11" +
c +
".png";
114 if (!pic.save(picName,
"PNG"))
116 QMessageBox::critical(
this, tr(
"Error"), tr(
"Error while saving the picture %1!").arg(picName));
124 QMessageBox::information(
this, tr(
"Bar created"), tr(
"The bar was correctly saved as %1").arg(arc.fileName()));
129 QString
dest = QFileDialog::getExistingDirectory(
this, tr(
"Select destination directory"),
"");
138 const QString
style(
"QPushButton { background-color : %1; }");
144 QColor
color = QColorDialog::getColor(
myColor,
this, tr(
"Select bar color"), QColorDialog::ShowAlphaChannel);
145 if (!
color.isValid())