mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
Start working with appearance
This commit is contained in:
parent
50dbf9a254
commit
682bd1b4a3
@ -74,8 +74,14 @@ void Initializer::initialize(CGTownInstance * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
o->builtBuildings.insert(BuildingID::FORT);
|
||||
const std::vector<std::string> castleLevels{"village", "fort", "citadel", "castle", "capitol"};
|
||||
int lvl = vstd::find_pos(castleLevels, o->appearance.stringID);
|
||||
o->builtBuildings.insert(BuildingID::DEFAULT);
|
||||
if(lvl > -1) o->builtBuildings.insert(BuildingID::TAVERN);
|
||||
if(lvl > 0) o->builtBuildings.insert(BuildingID::FORT);
|
||||
if(lvl > 1) o->builtBuildings.insert(BuildingID::CITADEL);
|
||||
if(lvl > 2) o->builtBuildings.insert(BuildingID::CASTLE);
|
||||
if(lvl > 3) o->builtBuildings.insert(BuildingID::CAPITOL);
|
||||
|
||||
for(auto spell : VLC->spellh->objects) //add all regular spells to town
|
||||
{
|
||||
|
@ -133,6 +133,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
//loading objects
|
||||
loadObjectsTree();
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
||||
show();
|
||||
}
|
||||
@ -624,6 +626,8 @@ void MainWindow::on_toolBrush_clicked(bool 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)
|
||||
@ -638,6 +642,8 @@ void MainWindow::on_toolBrush2_clicked(bool checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Brush2;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
|
||||
@ -653,6 +659,8 @@ void MainWindow::on_toolBrush4_clicked(bool 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)
|
||||
@ -667,6 +675,8 @@ void MainWindow::on_toolArea_clicked(bool checked)
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::Area;
|
||||
else
|
||||
ui->mapView->selectionTool = MapView::SelectionTool::None;
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionErase_triggered()
|
||||
@ -680,6 +690,7 @@ void MainWindow::on_toolErase_clicked()
|
||||
{
|
||||
controller.commitObjectErase(mapLevel);
|
||||
}
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::preparePreview(const QModelIndex &index, bool createNew)
|
||||
@ -760,8 +771,10 @@ void MainWindow::on_actionFill_triggered()
|
||||
controller.commitObstacleFill(mapLevel);
|
||||
}
|
||||
|
||||
void MainWindow::loadInspector(CGObjectInstance * obj)
|
||||
void MainWindow::loadInspector(CGObjectInstance * obj, bool switchTab)
|
||||
{
|
||||
if(switchTab)
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
Inspector inspector(controller.map(), obj, ui->inspectorWidget);
|
||||
inspector.updateProperties();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ private slots:
|
||||
public slots:
|
||||
|
||||
void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
|
||||
void loadInspector(CGObjectInstance * obj);
|
||||
void loadInspector(CGObjectInstance * obj, bool switchTab);
|
||||
void mapChanged();
|
||||
void enableUndo(bool enable);
|
||||
void enableRedo(bool enable);
|
||||
|
@ -258,7 +258,12 @@ void MapController::commitObstacleFill(int level)
|
||||
|
||||
void MapController::commitObjectChange(int level)
|
||||
{
|
||||
//for(auto * o : _scenes[level]->selectionObjectsView.getSelection())
|
||||
if(_scenes[level]->selectionObjectsView.getSelection().size() == 1)
|
||||
{
|
||||
auto * obj = *_scenes[level]->selectionObjectsView.getSelection().begin();
|
||||
if(auto * town = dynamic_cast<CGTownInstance*>(obj))
|
||||
town->updateAppearance();
|
||||
}
|
||||
//_mapHandler->invalidate(o);
|
||||
_scenes[level]->objectsView.draw();
|
||||
_scenes[level]->selectionObjectsView.draw();
|
||||
|
@ -303,6 +303,7 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
if(event->button() == Qt::RightButton)
|
||||
break;
|
||||
//switch position
|
||||
bool tab = false;
|
||||
if(sc->selectionObjectsView.selectionMode == 2 && !sc->selectionObjectsView.shift.isNull())
|
||||
{
|
||||
controller->commitObjectShiftOrCreate(sc->level);
|
||||
@ -312,12 +313,13 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
sc->selectionObjectsView.selectionMode = 0;
|
||||
sc->selectionObjectsView.shift = QPoint(0, 0);
|
||||
sc->selectionObjectsView.draw();
|
||||
tab = true;
|
||||
//check if we have only one object
|
||||
auto selection = sc->selectionObjectsView.getSelection();
|
||||
if(selection.size() == 1)
|
||||
{
|
||||
emit openObjectProperties(*selection.begin());
|
||||
}
|
||||
}
|
||||
auto selection = sc->selectionObjectsView.getSelection();
|
||||
if(selection.size() == 1)
|
||||
{
|
||||
emit openObjectProperties(*selection.begin(), tab);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public slots:
|
||||
void cameraChanged(const QPointF & pos);
|
||||
|
||||
signals:
|
||||
void openObjectProperties(CGObjectInstance *);
|
||||
void openObjectProperties(CGObjectInstance *, bool switchTab);
|
||||
//void viewportChanged(const QRectF & rect);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user