mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Add line and fill brushes
This commit is contained in:
parent
55900ceb66
commit
788147a897
BIN
mapeditor/icons/brush-0.png
Normal file
BIN
mapeditor/icons/brush-0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
mapeditor/icons/brush-6.png
Normal file
BIN
mapeditor/icons/brush-6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
mapeditor/icons/brush-7.png
Normal file
BIN
mapeditor/icons/brush-7.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -833,99 +833,12 @@ void MainWindow::changeBrushState(int idx)
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_toolBrush_clicked(bool checked)
|
||||
{
|
||||
//ui->toolBrush->setChecked(false);
|
||||
ui->toolBrush2->setChecked(false);
|
||||
ui->toolBrush4->setChecked(false);
|
||||
ui->toolArea->setChecked(false);
|
||||
ui->toolLasso->setChecked(false);
|
||||
|
||||
if(checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_toolBrush2_clicked(bool checked)
|
||||
{
|
||||
ui->toolBrush->setChecked(false);
|
||||
//ui->toolBrush2->setChecked(false);
|
||||
ui->toolBrush4->setChecked(false);
|
||||
ui->toolArea->setChecked(false);
|
||||
ui->toolLasso->setChecked(false);
|
||||
|
||||
if(checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush2;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolBrush4_clicked(bool checked)
|
||||
{
|
||||
ui->toolBrush->setChecked(false);
|
||||
ui->toolBrush2->setChecked(false);
|
||||
//ui->toolBrush4->setChecked(false);
|
||||
ui->toolArea->setChecked(false);
|
||||
ui->toolLasso->setChecked(false);
|
||||
|
||||
if(checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush4;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_toolArea_clicked(bool checked)
|
||||
{
|
||||
ui->toolBrush->setChecked(false);
|
||||
ui->toolBrush2->setChecked(false);
|
||||
ui->toolBrush4->setChecked(false);
|
||||
//ui->toolArea->setChecked(false);
|
||||
ui->toolLasso->setChecked(false);
|
||||
|
||||
if(checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Area;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_toolLasso_clicked(bool checked)
|
||||
{
|
||||
ui->toolBrush->setChecked(false);
|
||||
ui->toolBrush2->setChecked(false);
|
||||
ui->toolBrush4->setChecked(false);
|
||||
ui->toolArea->setChecked(false);
|
||||
//ui->toolLasso->setChecked(false);
|
||||
|
||||
if(checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Lasso;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionErase_triggered()
|
||||
{
|
||||
on_toolErase_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::on_toolErase_clicked()
|
||||
{
|
||||
if(controller.map())
|
||||
{
|
||||
controller.commitObjectErase(mapLevel);
|
||||
}
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::preparePreview(const QModelIndex &index)
|
||||
@ -949,11 +862,7 @@ void MainWindow::preparePreview(const QModelIndex &index)
|
||||
|
||||
void MainWindow::treeViewSelected(const QModelIndex & index, const QModelIndex & deselected)
|
||||
{
|
||||
ui->toolBrush->setChecked(false);
|
||||
ui->toolBrush2->setChecked(false);
|
||||
ui->toolBrush4->setChecked(false);
|
||||
ui->toolArea->setChecked(false);
|
||||
ui->toolLasso->setChecked(false);
|
||||
ui->toolSelect->setChecked(true);
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
preparePreview(index);
|
||||
@ -1114,7 +1023,6 @@ void MainWindow::onSelectionMade(int level, bool anythingSelected)
|
||||
if (level == mapLevel)
|
||||
{
|
||||
ui->actionErase->setEnabled(anythingSelected);
|
||||
ui->toolErase->setEnabled(anythingSelected);
|
||||
}
|
||||
}
|
||||
void MainWindow::displayStatus(const QString& message, int timeout /* = 2000 */)
|
||||
@ -1346,3 +1254,83 @@ void MainWindow::on_actionZoom_reset_triggered()
|
||||
ui->mapView->centerOn(center);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolLine_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Line;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolBrush2_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush2;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolBrush_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolBrush4_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush4;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolLasso_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Lasso;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolArea_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Area;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolFill_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Fill;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_toolSelect_toggled(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,28 +76,16 @@ private slots:
|
||||
|
||||
void on_actionGrid_triggered(bool checked);
|
||||
|
||||
void on_toolBrush_clicked(bool checked);
|
||||
|
||||
void on_toolArea_clicked(bool checked);
|
||||
|
||||
void terrainButtonClicked(TerrainId terrain);
|
||||
void roadOrRiverButtonClicked(ui8 type, bool isRoad);
|
||||
void currentCoordinatesChanged(int x, int y);
|
||||
|
||||
void on_toolErase_clicked();
|
||||
|
||||
void on_terrainFilterCombo_currentIndexChanged(int index);
|
||||
|
||||
void on_filter_textChanged(const QString &arg1);
|
||||
|
||||
void on_actionFill_triggered();
|
||||
|
||||
void on_toolBrush2_clicked(bool checked);
|
||||
|
||||
void on_toolBrush4_clicked(bool checked);
|
||||
|
||||
void on_toolLasso_clicked(bool checked);
|
||||
|
||||
void on_inspectorWidget_itemChanged(QTableWidgetItem *item);
|
||||
|
||||
void on_actionMapSettings_triggered();
|
||||
@ -134,6 +122,22 @@ private slots:
|
||||
|
||||
void on_actionZoom_reset_triggered();
|
||||
|
||||
void on_toolLine_toggled(bool checked);
|
||||
|
||||
void on_toolBrush2_toggled(bool checked);
|
||||
|
||||
void on_toolBrush_toggled(bool checked);
|
||||
|
||||
void on_toolBrush4_toggled(bool checked);
|
||||
|
||||
void on_toolLasso_toggled(bool checked);
|
||||
|
||||
void on_toolArea_toggled(bool checked);
|
||||
|
||||
void on_toolFill_toggled(bool checked);
|
||||
|
||||
void on_toolSelect_toggled(bool checked);
|
||||
|
||||
public slots:
|
||||
|
||||
void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
|
||||
|
@ -442,12 +442,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>192</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
|
||||
</property>
|
||||
@ -478,289 +472,361 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolBrush">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-1.png</normaloff>icons:brush-1.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolBrush2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-2.png</normaloff>icons:brush-2.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolBrush4">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-4.png</normaloff>icons:brush-4.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolLasso">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-3.png</normaloff>icons:brush-3.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Brush</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="toolBrush">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-1.png</normaloff>icons:brush-1.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="toolBrush2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-2.png</normaloff>icons:brush-2.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="toolBrush4">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-4.png</normaloff>icons:brush-4.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="toolArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-5.png</normaloff>icons:brush-5.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="toolLasso">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-3.png</normaloff>icons:brush-3.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="toolErase">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-clear.png</normaloff>icons:edit-clear.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolLine">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-7.png</normaloff>icons:brush-7.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-5.png</normaloff>icons:brush-5.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolFill">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-6.png</normaloff>icons:brush-6.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolSelect">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-0.png</normaloff>icons:brush-0.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -818,7 +884,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>90</height>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -861,7 +927,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>90</height>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -897,7 +963,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>90</height>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -151,6 +151,60 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
sc->selectionTerrainView.draw();
|
||||
break;
|
||||
|
||||
case MapView::SelectionTool::Line:
|
||||
{
|
||||
assert(tile.z == tileStart.z);
|
||||
const auto diff = tile - tileStart;
|
||||
if(diff == int3{})
|
||||
break;
|
||||
|
||||
const int edge = std::max(abs(diff.x), abs(diff.y));
|
||||
int distMin = std::numeric_limits<int>::max();
|
||||
int3 dir;
|
||||
|
||||
for(auto & d : int3::getDirs())
|
||||
{
|
||||
if(tile.dist2d(d * edge + tileStart) < distMin)
|
||||
{
|
||||
distMin = tile.dist2d(d * edge + tileStart);
|
||||
dir = d;
|
||||
}
|
||||
}
|
||||
|
||||
assert(dir != int3{});
|
||||
|
||||
if(mouseEvent->buttons() == Qt::LeftButton)
|
||||
{
|
||||
for(auto & ts : temporaryTiles)
|
||||
sc->selectionTerrainView.erase(ts);
|
||||
|
||||
for(auto ts = tileStart; ts.dist2d(tileStart) < edge; ts += dir)
|
||||
{
|
||||
if(!controller->map()->isInTheMap(ts))
|
||||
break;
|
||||
if(!sc->selectionTerrainView.selection().count(ts))
|
||||
temporaryTiles.insert(ts);
|
||||
sc->selectionTerrainView.select(ts);
|
||||
}
|
||||
}
|
||||
if(mouseEvent->buttons() == Qt::RightButton)
|
||||
{
|
||||
for(auto & ts : temporaryTiles)
|
||||
sc->selectionTerrainView.select(ts);
|
||||
|
||||
for(auto ts = tileStart; ts.dist2d(tileStart) < edge; ts += dir)
|
||||
{
|
||||
if(!controller->map()->isInTheMap(ts))
|
||||
break;
|
||||
if(sc->selectionTerrainView.selection().count(ts))
|
||||
temporaryTiles.insert(ts);
|
||||
sc->selectionTerrainView.erase(ts);
|
||||
}
|
||||
}
|
||||
sc->selectionTerrainView.draw();
|
||||
break;
|
||||
}
|
||||
|
||||
case MapView::SelectionTool::Lasso:
|
||||
if(mouseEvent->buttons() == Qt::LeftButton)
|
||||
{
|
||||
@ -205,6 +259,7 @@ void MapView::mousePressEvent(QMouseEvent *event)
|
||||
switch(selectionTool)
|
||||
{
|
||||
case MapView::SelectionTool::Brush:
|
||||
case MapView::SelectionTool::Line:
|
||||
sc->selectionObjectsView.clear();
|
||||
sc->selectionObjectsView.draw();
|
||||
|
||||
@ -262,6 +317,55 @@ void MapView::mousePressEvent(QMouseEvent *event)
|
||||
sc->selectionObjectsView.clear();
|
||||
sc->selectionObjectsView.draw();
|
||||
break;
|
||||
|
||||
case MapView::SelectionTool::Fill:
|
||||
{
|
||||
if(event->button() != Qt::RightButton && event->button() != Qt::LeftButton)
|
||||
break;
|
||||
|
||||
std::vector<int3> queue;
|
||||
queue.push_back(tileStart);
|
||||
|
||||
const std::array<int3, 4> dirs{ int3{1, 0, 0}, int3{-1, 0, 0}, int3{0, 1, 0}, int3{0, -1, 0} };
|
||||
|
||||
while(!queue.empty())
|
||||
{
|
||||
auto tile = queue.back();
|
||||
queue.pop_back();
|
||||
if(event->button() == Qt::LeftButton)
|
||||
sc->selectionTerrainView.select(tile);
|
||||
else
|
||||
sc->selectionTerrainView.erase(tile);
|
||||
for(auto & d : dirs)
|
||||
{
|
||||
auto tilen = tile + d;
|
||||
if(!controller->map()->isInTheMap(tilen))
|
||||
continue;
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
if(controller->map()->getTile(tile).roadType
|
||||
&& controller->map()->getTile(tile).roadType != controller->map()->getTile(tilen).roadType)
|
||||
continue;
|
||||
else if(controller->map()->getTile(tile).riverType
|
||||
&& controller->map()->getTile(tile).riverType != controller->map()->getTile(tilen).riverType)
|
||||
continue;
|
||||
else if(controller->map()->getTile(tile).terType != controller->map()->getTile(tilen).terType)
|
||||
continue;
|
||||
}
|
||||
if(event->button() == Qt::LeftButton && sc->selectionTerrainView.selection().count(tilen))
|
||||
continue;
|
||||
if(event->button() == Qt::RightButton && !sc->selectionTerrainView.selection().count(tilen))
|
||||
continue;
|
||||
queue.push_back(tilen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sc->selectionTerrainView.draw();
|
||||
sc->selectionObjectsView.clear();
|
||||
sc->selectionObjectsView.draw();
|
||||
break;
|
||||
}
|
||||
|
||||
case MapView::SelectionTool::None:
|
||||
sc->selectionTerrainView.clear();
|
||||
@ -401,6 +505,10 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
break;
|
||||
}
|
||||
|
||||
case MapView::SelectionTool::Line:
|
||||
temporaryTiles.clear();
|
||||
break;
|
||||
|
||||
case MapView::SelectionTool::None:
|
||||
if(event->button() == Qt::RightButton)
|
||||
break;
|
||||
|
@ -89,7 +89,7 @@ class MapView : public QGraphicsView
|
||||
public:
|
||||
enum class SelectionTool
|
||||
{
|
||||
None, Brush, Brush2, Brush4, Area, Lasso
|
||||
None, Brush, Brush2, Brush4, Area, Lasso, Line, Fill
|
||||
};
|
||||
|
||||
public:
|
||||
@ -124,6 +124,8 @@ private:
|
||||
int3 tileStart;
|
||||
int3 tilePrev;
|
||||
bool pressedOnSelected;
|
||||
|
||||
std::set<int3> temporaryTiles;
|
||||
};
|
||||
|
||||
class MinimapView : public QGraphicsView
|
||||
|
Loading…
Reference in New Issue
Block a user