Out of bounds warning
This commit is contained in:
parent
8d757e96be
commit
10ddcc51a2
3 changed files with 50 additions and 6 deletions
|
|
@ -52,18 +52,37 @@ void MainWindow::onGridUpdated()
|
|||
{
|
||||
if (iter->size() > 1)
|
||||
{
|
||||
QString warningTitle = QString("Color \"%1\" is used by several lines:").arg(iter.key());
|
||||
QStringList warningDescription{};
|
||||
QString title = QString("Color \"%1\" is used by several lines:").arg(iter.key());
|
||||
QStringList description{};
|
||||
|
||||
for(int i = 0; i < iter->size(); i++)
|
||||
{
|
||||
warningDescription.push_back(QString("Line #%1").arg(iter->at(i)));
|
||||
description.push_back(QString("Line #%1").arg(iter->at(i)));
|
||||
}
|
||||
|
||||
throwWarning(warningTitle, warningDescription);
|
||||
throwWarning(title, description);
|
||||
}
|
||||
}
|
||||
ui->treeWarnings->expandAll();
|
||||
|
||||
const QList<PointProbe> outOfBounds = ui->gridPreview->pointsOutOfBounds();
|
||||
|
||||
for (auto iter = outOfBounds.begin(); iter != outOfBounds.end(); iter++)
|
||||
{
|
||||
const Line &line = ui->gridPreview->getLine(iter->ownerIndex);
|
||||
const QPoint &point = iter->isStart ? line.getStart() : line.getEnd();
|
||||
|
||||
QString pointType = iter->isStart ? QString("Start") : QString("End");
|
||||
QString title = QString("%1 point of Line #%2 is out of bounds:").arg(pointType).arg(iter->ownerIndex + 1);
|
||||
QStringList description {
|
||||
QString("Point located at (%1, %2) while grid size is %3x%4")
|
||||
.arg(point.x())
|
||||
.arg(point.y())
|
||||
.arg(ui->gridPreview->getWidth())
|
||||
.arg(ui->gridPreview->getHeight())
|
||||
};
|
||||
|
||||
throwWarning(title, description);
|
||||
}
|
||||
|
||||
PointProbe pp = ui->gridPreview->getCapturedProbe();
|
||||
|
||||
|
|
@ -127,12 +146,13 @@ void MainWindow::throwWarning(const QString &title, const QStringList &descripti
|
|||
titleItem->addChild(descriptionItem);
|
||||
}
|
||||
ui->treeWarnings->addTopLevelItem(titleItem);
|
||||
ui->treeWarnings->expandItem(titleItem);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_buttonSave_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save grid"), ".", "Lua source code (*.lua)");
|
||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save grid"), "level.lua", "Lua source code (*.lua)");
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue