mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-06 15:29:02 +00:00
Changed: #1301 Improved appearance of landscape editor.
This commit is contained in:
parent
2df08d6548
commit
2d01de7207
5 changed files with 110 additions and 64 deletions
|
@ -56,7 +56,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
m_landscapeScene = new LandscapeScene(this);
|
m_landscapeScene = new LandscapeScene(160, this);
|
||||||
|
|
||||||
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
||||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
|
@ -69,6 +69,9 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
||||||
|
m_ui.zonesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_LANDSCAPE_ZONES));
|
||||||
|
m_ui.landscapesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_ZONE_ITEM));
|
||||||
|
|
||||||
m_ui.deleteLandAction->setEnabled(false);
|
m_ui.deleteLandAction->setEnabled(false);
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
|
@ -85,6 +88,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand()));
|
connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand()));
|
||||||
connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand()));
|
connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand()));
|
||||||
connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand()));
|
connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand()));
|
||||||
|
connect(m_ui.transitionModeAction, SIGNAL(toggled(bool)), m_landscapeScene, SLOT(setTransitionMode(bool)));
|
||||||
|
|
||||||
connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu()));
|
connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu()));
|
||||||
m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -353,23 +357,27 @@ void LandscapeEditorWindow::createToolBars()
|
||||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
//QAction *action = menuManager->action(Core::Constants::NEW);
|
//QAction *action = menuManager->action(Core::Constants::NEW);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
QAction *action = menuManager->action(Core::Constants::OPEN);
|
|
||||||
m_ui.fileToolBar->addAction(m_ui.newLandAction);
|
|
||||||
m_ui.fileToolBar->addAction(action);
|
|
||||||
m_ui.fileToolBar->addAction(m_ui.saveAction);
|
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::UNDO);
|
|
||||||
if (action != 0)
|
|
||||||
m_ui.undoToolBar->addAction(action);
|
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::REDO);
|
|
||||||
if (action != 0)
|
|
||||||
m_ui.undoToolBar->addAction(action);
|
|
||||||
|
|
||||||
//action = menuManager->action(Core::Constants::SAVE);
|
//action = menuManager->action(Core::Constants::SAVE);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
//action = menuManager->action(Core::Constants::SAVE_AS);
|
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
|
QAction *action = menuManager->action(Core::Constants::OPEN);
|
||||||
|
m_ui.fileToolBar->addAction(m_ui.newLandAction);
|
||||||
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
m_ui.fileToolBar->addAction(m_ui.saveAction);
|
||||||
|
m_ui.fileToolBar->addSeparator();
|
||||||
|
|
||||||
|
action = menuManager->action(Core::Constants::UNDO);
|
||||||
|
if (action != 0)
|
||||||
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
|
action = menuManager->action(Core::Constants::REDO);
|
||||||
|
if (action != 0)
|
||||||
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
|
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.landscapesDockWidget->toggleViewAction());
|
||||||
|
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.zonesDockWidget->toggleViewAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::readSettings()
|
void LandscapeEditorWindow::readSettings()
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
<rectf>
|
<rectf>
|
||||||
<x>0.000000000000000</x>
|
<x>0.000000000000000</x>
|
||||||
<y>0.000000000000000</y>
|
<y>0.000000000000000</y>
|
||||||
<width>99999.000000000000000</width>
|
<width>0.000000000000000</width>
|
||||||
<height>99999.000000000000000</height>
|
<height>0.000000000000000</height>
|
||||||
</rectf>
|
</rectf>
|
||||||
</property>
|
</property>
|
||||||
<property name="dragMode">
|
<property name="dragMode">
|
||||||
|
@ -65,7 +65,11 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="dockWidget">
|
<widget class="QDockWidget" name="zonesDockWidget">
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_zones.png</normaloff>:/icons/ic_nel_zones.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Zones</string>
|
<string>Zones</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -74,18 +78,11 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="LandscapeEditor::ListZonesWidget" name="zoneListWidget"/>
|
<widget class="LandscapeEditor::ListZonesWidget" name="zoneListWidget"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="undoToolBar">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>toolBar_2</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
<widget class="QDockWidget" name="landscapesDockWidget">
|
<widget class="QDockWidget" name="landscapesDockWidget">
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_zone.png</normaloff>:/icons/ic_nel_zone.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Landscapes</string>
|
<string>Landscapes</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -116,9 +113,10 @@
|
||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<addaction name="transitionModeAction"/>
|
||||||
|
<addaction name="enableGridAction"/>
|
||||||
<addaction name="projectSettingsAction"/>
|
<addaction name="projectSettingsAction"/>
|
||||||
<addaction name="snapshotAction"/>
|
<addaction name="snapshotAction"/>
|
||||||
<addaction name="enableGridAction"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="projectSettingsAction">
|
<action name="projectSettingsAction">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
|
@ -136,6 +134,10 @@
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_grid.png</normaloff>:/icons/ic_grid.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>EnableGrid</string>
|
<string>EnableGrid</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -147,6 +149,10 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="snapshotAction">
|
<action name="snapshotAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_snapshot.png</normaloff>:/icons/ic_snapshot.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>snapshot</string>
|
<string>snapshot</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -200,6 +206,22 @@
|
||||||
<string>Create new landscape</string>
|
<string>Create new landscape</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="transitionModeAction">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_landscape_item.png</normaloff>
|
||||||
|
<normalon>:/icons/ic_nel_transition_land.png</normalon>:/icons/ic_nel_landscape_item.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Transition mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enable transition mode</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -59,9 +59,7 @@ bool LandscapeView::isVisibleGrid() const
|
||||||
void LandscapeView::setVisibleGrid(bool visible)
|
void LandscapeView::setVisibleGrid(bool visible)
|
||||||
{
|
{
|
||||||
m_visibleGrid = visible;
|
m_visibleGrid = visible;
|
||||||
|
scene()->update();
|
||||||
// hack for repaint view
|
|
||||||
translate(0.0001, 0.0001);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::wheelEvent(QWheelEvent *event)
|
void LandscapeView::wheelEvent(QWheelEvent *event)
|
||||||
|
@ -117,33 +115,44 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
if (!m_visibleGrid)
|
if (!m_visibleGrid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal scaleFactor = transform().m11();
|
|
||||||
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
||||||
|
drawGrid(painter, rect);
|
||||||
|
|
||||||
// draw grid
|
|
||||||
qreal left = m_cellSize * floor(rect.left() / m_cellSize);
|
|
||||||
qreal top = m_cellSize * floor(rect.top() / m_cellSize);
|
|
||||||
|
|
||||||
// draw vertical lines
|
|
||||||
while (left < rect.right())
|
|
||||||
{
|
|
||||||
painter->drawLine(int(left), int(rect.bottom()), int(left), int(rect.top()));
|
|
||||||
left += m_cellSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw horizontal lines
|
|
||||||
while (top < rect.bottom())
|
|
||||||
{
|
|
||||||
painter->drawLine(int(rect.left()), int(top), int(rect.right()), int(top));
|
|
||||||
top += m_cellSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render text (slow!)
|
|
||||||
if (m_numSteps > -m_maxSteps / 4)
|
if (m_numSteps > -m_maxSteps / 4)
|
||||||
{
|
{
|
||||||
painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine));
|
painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine));
|
||||||
|
|
||||||
//painter->setFont(QFont("Helvetica [Cronyx]", 12));
|
//painter->setFont(QFont("Helvetica [Cronyx]", 12));
|
||||||
|
drawZoneNames(painter, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::drawGrid(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
qreal left = m_cellSize * floor(rect.left() / m_cellSize);
|
||||||
|
qreal top = m_cellSize * floor(rect.top() / m_cellSize);
|
||||||
|
|
||||||
|
QVector<QLine> lines;
|
||||||
|
|
||||||
|
// Calculate vertical lines
|
||||||
|
while (left < rect.right())
|
||||||
|
{
|
||||||
|
lines.push_back(QLine(int(left), int(rect.bottom()), int(left), int(rect.top())));
|
||||||
|
left += m_cellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate horizontal lines
|
||||||
|
while (top < rect.bottom())
|
||||||
|
{
|
||||||
|
lines.push_back(QLine(int(rect.left()), int(top), int(rect.right()), int(top)));
|
||||||
|
top += m_cellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw lines
|
||||||
|
painter->drawLines(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::drawZoneNames(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
int leftSide = int(floor(rect.left() / m_cellSize));
|
int leftSide = int(floor(rect.left() / m_cellSize));
|
||||||
int rightSide = int(floor(rect.right() / m_cellSize));
|
int rightSide = int(floor(rect.right() / m_cellSize));
|
||||||
int topSide = int(floor(rect.top() / m_cellSize));
|
int topSide = int(floor(rect.top() / m_cellSize));
|
||||||
|
@ -158,6 +167,5 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||||
virtual void drawForeground(QPainter *painter, const QRectF &rect);
|
virtual void drawForeground(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
void drawGrid(QPainter *painter, const QRectF &rect);
|
||||||
|
void drawZoneNames(QPainter *painter, const QRectF &rect);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_visibleGrid;
|
bool m_visibleGrid;
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Snapshot</string>
|
<string>Snapshot</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_snapshot.png</normaloff>:/icons/ic_snapshot.png</iconset>
|
||||||
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
@ -136,7 +140,9 @@
|
||||||
<tabstop>keepRatioCheckBox</tabstop>
|
<tabstop>keepRatioCheckBox</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="landscape_editor.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
|
Loading…
Reference in a new issue