Adding secondary toolbar for editing mode + fix climb max value ( confirm ?? )
This commit is contained in:
@@ -225,18 +225,20 @@ void MapView::set_editing_mode(editing_mode mode)
|
|||||||
_viewport_overlay_ui->gizmoBar->hide();
|
_viewport_overlay_ui->gizmoBar->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_left_sec_toolbar->setCurrentMode(this, mode);
|
||||||
|
|
||||||
if (context() && context()->isValid())
|
if (context() && context()->isValid())
|
||||||
{
|
{
|
||||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_areaid_overlay = false;
|
_world->renderer()->getTerrainParamsUniformBlock()->draw_areaid_overlay = false;
|
||||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_impass_overlay = false;
|
_world->renderer()->getTerrainParamsUniformBlock()->draw_impass_overlay = false;
|
||||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = false;
|
_world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = _left_sec_toolbar->showUnpaintableChunk();
|
||||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_selection_overlay = false;
|
_world->renderer()->getTerrainParamsUniformBlock()->draw_selection_overlay = false;
|
||||||
_minimap->use_selection(nullptr);
|
_minimap->use_selection(nullptr);
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case editing_mode::ground:
|
case editing_mode::ground:
|
||||||
if (terrainTool->_edit_type != eTerrainType_Vertex || terrainTool->_edit_type != eTerrainType_Script && terrainTool->getImageMaskSelector()->isEnabled())
|
if (terrainTool->_edit_type != eTerrainType_Vertex || (terrainTool->_edit_type != eTerrainType_Script && terrainTool->getImageMaskSelector()->isEnabled()))
|
||||||
{
|
{
|
||||||
terrainTool->updateMaskImage();
|
terrainTool->updateMaskImage();
|
||||||
}
|
}
|
||||||
@@ -246,10 +248,6 @@ void MapView::set_editing_mode(editing_mode mode)
|
|||||||
{
|
{
|
||||||
texturingTool->updateMaskImage();
|
texturingTool->updateMaskImage();
|
||||||
}
|
}
|
||||||
if (texturingTool->show_unpaintable_chunks())
|
|
||||||
{
|
|
||||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case editing_mode::mccv:
|
case editing_mode::mccv:
|
||||||
if (shaderTool->getImageMaskSelector()->isEnabled())
|
if (shaderTool->getImageMaskSelector()->isEnabled())
|
||||||
@@ -1048,13 +1046,20 @@ void MapView::setupToolbars()
|
|||||||
auto right_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->leftToolbarHolder);
|
auto right_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->leftToolbarHolder);
|
||||||
right_toolbar_layout->addWidget( _toolbar);
|
right_toolbar_layout->addWidget( _toolbar);
|
||||||
right_toolbar_layout->setDirection(QBoxLayout::LeftToRight);
|
right_toolbar_layout->setDirection(QBoxLayout::LeftToRight);
|
||||||
right_toolbar_layout->setContentsMargins(0, 5, 0,5);
|
right_toolbar_layout->setContentsMargins(0, 5, 0, 5);
|
||||||
connect (this, &QObject::destroyed, _toolbar, &QObject::deleteLater);
|
connect (this, &QObject::destroyed, _toolbar, &QObject::deleteLater);
|
||||||
|
|
||||||
|
auto left_sec_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->leftSecondaryToolbarHolder);
|
||||||
|
left_sec_toolbar_layout->setContentsMargins(5, 0, 5, 0);
|
||||||
|
|
||||||
|
_left_sec_toolbar = new Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar(this, terrainMode);
|
||||||
|
connect(this, &QObject::destroyed, _left_sec_toolbar, &QObject::deleteLater);
|
||||||
|
left_sec_toolbar_layout->addWidget( _left_sec_toolbar);
|
||||||
|
|
||||||
auto top_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->upperToolbarHolder);
|
auto top_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->upperToolbarHolder);
|
||||||
top_toolbar_layout->setContentsMargins(5, 0, 5, 0);
|
top_toolbar_layout->setContentsMargins(5, 0, 5, 0);
|
||||||
auto sec_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->secondaryToolbarHolder);
|
auto sec_toolbar_layout = new QVBoxLayout(_viewport_overlay_ui->secondaryToolbarHolder);
|
||||||
sec_toolbar_layout->setContentsMargins(0, 0, 0, 0);
|
sec_toolbar_layout->setContentsMargins(5, 0, 5, 0);
|
||||||
|
|
||||||
_viewport_overlay_ui->secondaryToolbarHolder->hide();
|
_viewport_overlay_ui->secondaryToolbarHolder->hide();
|
||||||
_secondary_toolbar = new Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar(this);
|
_secondary_toolbar = new Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar(this);
|
||||||
@@ -4301,7 +4306,7 @@ void MapView::draw_map()
|
|||||||
, terrainMode == editing_mode::mccv ? shaderTool->shaderColor() : cursor_color
|
, terrainMode == editing_mode::mccv ? shaderTool->shaderColor() : cursor_color
|
||||||
, _cursorType
|
, _cursorType
|
||||||
, radius
|
, radius
|
||||||
, texturingTool->show_unpaintable_chunks()
|
, _left_sec_toolbar->showUnpaintableChunk()
|
||||||
, inner_radius
|
, inner_radius
|
||||||
, ref_pos
|
, ref_pos
|
||||||
, angle
|
, angle
|
||||||
@@ -5256,6 +5261,11 @@ QWidget* MapView::getSecondaryToolBar()
|
|||||||
return _viewport_overlay_ui->secondaryToolbarHolder;
|
return _viewport_overlay_ui->secondaryToolbarHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* MapView::getLeftSecondaryToolbar()
|
||||||
|
{
|
||||||
|
return _viewport_overlay_ui->leftSecondaryToolbarHolder;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* MapView::getActiveStampModeItem()
|
QWidget* MapView::getActiveStampModeItem()
|
||||||
{
|
{
|
||||||
auto item = stampTool->getActiveBrushItem();
|
auto item = stampTool->getActiveBrushItem();
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ private:
|
|||||||
Noggit::Ui::toolbar* _toolbar;
|
Noggit::Ui::toolbar* _toolbar;
|
||||||
Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar* _view_toolbar;
|
Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar* _view_toolbar;
|
||||||
Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar* _secondary_toolbar;
|
Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar* _secondary_toolbar;
|
||||||
|
Noggit::Ui::Tools::ViewToolbar::Ui::ViewToolbar* _left_sec_toolbar;
|
||||||
|
|
||||||
void save(save_mode mode);
|
void save(save_mode mode);
|
||||||
|
|
||||||
@@ -277,6 +278,9 @@ public:
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
QWidget *getSecondaryToolBar();
|
QWidget *getSecondaryToolBar();
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
QWidget *getLeftSecondaryToolbar();
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
QWidget* getActiveStampModeItem();
|
QWidget* getActiveStampModeItem();
|
||||||
|
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ void WorldRender::draw (glm::mat4x4 const& model_view
|
|||||||
|
|
||||||
if (angled_mode && terrainMode == editing_mode::flatten_blur)
|
if (angled_mode && terrainMode == editing_mode::flatten_blur)
|
||||||
{
|
{
|
||||||
if (angle > 57.2958f) // 1 radian
|
if (angle > 49.0f) // 0.855 radian
|
||||||
{
|
{
|
||||||
color.x = 1.f;
|
color.x = 1.f;
|
||||||
color.y = 0.f;
|
color.y = 0.f;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>924</width>
|
<width>967</width>
|
||||||
<height>141</height>
|
<height>520</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@@ -63,6 +63,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
@@ -89,7 +92,43 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
<height>20</height>
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="leftSecondaryToolbarHolder" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
@@ -115,8 +154,8 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>0</width>
|
||||||
<height>20</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace Noggit
|
|||||||
)
|
)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, _brush_level(255)
|
, _brush_level(255)
|
||||||
, _show_unpaintable_chunks(false)
|
|
||||||
, _spray_size(1.0f)
|
, _spray_size(1.0f)
|
||||||
, _spray_pressure(2.0f)
|
, _spray_pressure(2.0f)
|
||||||
, _anim_prop(true)
|
, _anim_prop(true)
|
||||||
@@ -107,16 +106,6 @@ namespace Noggit
|
|||||||
_brush_level_spin->setSingleStep(5);
|
_brush_level_spin->setSingleStep(5);
|
||||||
slider_layout_right->addWidget(_brush_level_spin);
|
slider_layout_right->addWidget(_brush_level_spin);
|
||||||
|
|
||||||
_show_unpaintable_chunks_cb = new QCheckBox("Show unpaintable chunks", tool_widget);
|
|
||||||
_show_unpaintable_chunks_cb->setChecked(false);
|
|
||||||
tool_layout->addWidget(_show_unpaintable_chunks_cb);
|
|
||||||
|
|
||||||
connect(_show_unpaintable_chunks_cb, &QCheckBox::toggled, [=](bool checked)
|
|
||||||
{
|
|
||||||
_map_view->getWorld()->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
|
|
||||||
_map_view->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
|
||||||
});
|
|
||||||
|
|
||||||
// spray
|
// spray
|
||||||
_spray_mode_group = new QGroupBox("Spray", tool_widget);
|
_spray_mode_group = new QGroupBox("Spray", tool_widget);
|
||||||
_spray_mode_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
_spray_mode_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||||
@@ -246,13 +235,6 @@ namespace Noggit
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
connect ( _show_unpaintable_chunks_cb, &QCheckBox::stateChanged
|
|
||||||
, [&] (int state)
|
|
||||||
{
|
|
||||||
_show_unpaintable_chunks = state;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
connect ( _spray_size_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
connect ( _spray_size_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
||||||
, [&] (double v)
|
, [&] (double v)
|
||||||
{
|
{
|
||||||
@@ -492,11 +474,6 @@ namespace Noggit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool texturing_tool::show_unpaintable_chunks() const
|
|
||||||
{
|
|
||||||
return _show_unpaintable_chunks && _texturing_mode == texturing_mode::paint;
|
|
||||||
}
|
|
||||||
|
|
||||||
void texturing_tool::paint (World* world, glm::vec3 const& pos, float dt, scoped_blp_texture_reference texture)
|
void texturing_tool::paint (World* world, glm::vec3 const& pos, float dt, scoped_blp_texture_reference texture)
|
||||||
{
|
{
|
||||||
if (TabletManager::instance()->isActive())
|
if (TabletManager::instance()->isActive())
|
||||||
@@ -602,7 +579,6 @@ namespace Noggit
|
|||||||
json["radius"] = _radius_slider->rawValue();
|
json["radius"] = _radius_slider->rawValue();
|
||||||
json["brush_level"] = _brush_level_spin->value();
|
json["brush_level"] = _brush_level_spin->value();
|
||||||
json["texturing_mode"] = static_cast<int>(_texturing_mode);
|
json["texturing_mode"] = static_cast<int>(_texturing_mode);
|
||||||
json["show_unpaintable_chunks"] = _show_unpaintable_chunks_cb->isChecked();
|
|
||||||
|
|
||||||
json["anim"] = _anim_prop.get();
|
json["anim"] = _anim_prop.get();
|
||||||
json["anim_speed"] = static_cast<int>(_anim_speed_prop.get());
|
json["anim_speed"] = static_cast<int>(_anim_speed_prop.get());
|
||||||
@@ -637,7 +613,6 @@ namespace Noggit
|
|||||||
_brush_level_spin->setValue(json["brush_level"].toInt());
|
_brush_level_spin->setValue(json["brush_level"].toInt());
|
||||||
|
|
||||||
tabs->setCurrentIndex(json["texturing_mode"].toInt());
|
tabs->setCurrentIndex(json["texturing_mode"].toInt());
|
||||||
_show_unpaintable_chunks_cb->setChecked(json["show_unpaintable_chunks"].toBool());
|
|
||||||
|
|
||||||
_anim_prop.set(json["anim"].toBool());
|
_anim_prop.set(json["anim"].toBool());
|
||||||
_anim_speed_prop.set(json["anim_speed"].toInt());
|
_anim_speed_prop.set(json["anim_speed"].toInt());
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ namespace Noggit
|
|||||||
|
|
||||||
float brush_radius() const;
|
float brush_radius() const;
|
||||||
float hardness() const;
|
float hardness() const;
|
||||||
bool show_unpaintable_chunks() const;
|
|
||||||
|
|
||||||
void set_brush_level (float level);
|
void set_brush_level (float level);
|
||||||
|
|
||||||
@@ -106,7 +105,6 @@ namespace Noggit
|
|||||||
Brush _spray_brush;
|
Brush _spray_brush;
|
||||||
|
|
||||||
int _brush_level;
|
int _brush_level;
|
||||||
bool _show_unpaintable_chunks;
|
|
||||||
|
|
||||||
float _spray_size;
|
float _spray_size;
|
||||||
float _spray_pressure;
|
float _spray_pressure;
|
||||||
@@ -125,8 +123,6 @@ namespace Noggit
|
|||||||
Noggit::Ui::Tools::UiCommon::ExtendedSlider* _pressure_slider;
|
Noggit::Ui::Tools::UiCommon::ExtendedSlider* _pressure_slider;
|
||||||
QSpinBox* _brush_level_spin;
|
QSpinBox* _brush_level_spin;
|
||||||
|
|
||||||
QCheckBox* _show_unpaintable_chunks_cb;
|
|
||||||
|
|
||||||
QGroupBox* _spray_mode_group;
|
QGroupBox* _spray_mode_group;
|
||||||
QWidget* _spray_content;
|
QWidget* _spray_content;
|
||||||
QCheckBox* _inner_radius_cb;
|
QCheckBox* _inner_radius_cb;
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ ViewToolbar::ViewToolbar(MapView* mapView)
|
|||||||
|
|
||||||
CheckBoxAction* climb_use_output_color_angle = new CheckBoxAction(tr("Display all angle color"));
|
CheckBoxAction* climb_use_output_color_angle = new CheckBoxAction(tr("Display all angle color"));
|
||||||
climb_use_output_color_angle->checkbox()->setChecked(false);
|
climb_use_output_color_angle->checkbox()->setChecked(false);
|
||||||
connect(climb_use_output_color_angle->checkbox(), &QCheckBox::stateChanged, [mapView, climb_use_output_color_angle]()
|
connect(climb_use_output_color_angle->checkbox(), &QCheckBox::toggled, [mapView](bool checked)
|
||||||
{
|
{
|
||||||
mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->climb_use_output_angle = climb_use_output_color_angle->checkbox()->isChecked();
|
mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->climb_use_output_angle = checked;
|
||||||
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
||||||
});
|
});
|
||||||
|
|
||||||
CheckBoxAction* climb_use_smooth_interpolation = new CheckBoxAction(tr("Smooth"));
|
CheckBoxAction* climb_use_smooth_interpolation = new CheckBoxAction(tr("Smooth"));
|
||||||
climb_use_smooth_interpolation->setChecked(false);
|
climb_use_smooth_interpolation->setChecked(false);
|
||||||
connect(climb_use_smooth_interpolation->checkbox(), &QCheckBox::stateChanged, [mapView, climb_use_smooth_interpolation]()
|
connect(climb_use_smooth_interpolation->checkbox(), &QCheckBox::toggled, [mapView](bool checked)
|
||||||
{
|
{
|
||||||
mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->climb_use_smooth_interpolation = climb_use_smooth_interpolation->checkbox()->isChecked();
|
mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->climb_use_smooth_interpolation = checked;
|
||||||
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ ViewToolbar::ViewToolbar(MapView* mapView)
|
|||||||
PushButtonAction* climb_reset_slider = new PushButtonAction(tr("Reset"));
|
PushButtonAction* climb_reset_slider = new PushButtonAction(tr("Reset"));
|
||||||
connect(climb_reset_slider->pushbutton(), &QPushButton::clicked, [climb_value]()
|
connect(climb_reset_slider->pushbutton(), &QPushButton::clicked, [climb_value]()
|
||||||
{
|
{
|
||||||
climb_value->slider()->setValue(1000);
|
climb_value->slider()->setValue(855);
|
||||||
});
|
});
|
||||||
|
|
||||||
_climb_secondary_tool.push_back(climb_icon);
|
_climb_secondary_tool.push_back(climb_icon);
|
||||||
@@ -54,44 +54,9 @@ ViewToolbar::ViewToolbar(MapView* mapView)
|
|||||||
_climb_secondary_tool.push_back(climb_reset_slider);
|
_climb_secondary_tool.push_back(climb_reset_slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewToolbar::add_tool_icon(MapView* mapView,
|
|
||||||
Noggit::BoolToggleProperty* view_state,
|
|
||||||
const QString& name,
|
|
||||||
const FontNoggit::Icons& icon,
|
|
||||||
ViewToolbar* sec_tool_bar,
|
|
||||||
QVector<QWidgetAction*> sec_action_bar)
|
|
||||||
{
|
|
||||||
auto action = addAction(FontNoggitIcon{icon}, name);
|
|
||||||
connect (action, &QAction::triggered, [action, view_state] () {
|
|
||||||
action->setChecked(!view_state->get());
|
|
||||||
view_state->set(!view_state->get());
|
|
||||||
});
|
|
||||||
|
|
||||||
connect (action, &QAction::hovered, [mapView, sec_tool_bar, sec_action_bar] () {
|
|
||||||
sec_tool_bar->clear();
|
|
||||||
mapView->getSecondaryToolBar()->hide();
|
|
||||||
|
|
||||||
if (sec_action_bar.size() > 0)
|
|
||||||
{
|
|
||||||
sec_tool_bar->setupWidget(sec_action_bar);
|
|
||||||
mapView->getSecondaryToolBar()->show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
connect (view_state, &Noggit::BoolToggleProperty::changed, [action, view_state] () {
|
|
||||||
action->setChecked(view_state->get());
|
|
||||||
});
|
|
||||||
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(view_state->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
||||||
: _tool_group(this)
|
: _tool_group(this)
|
||||||
{
|
{
|
||||||
Q_UNUSED(tb);
|
|
||||||
|
|
||||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
||||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||||
@@ -165,6 +130,90 @@ ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewToolbar::ViewToolbar(MapView* mapView, editing_mode mode)
|
||||||
|
: _tool_group(this)
|
||||||
|
, current_mode(mode)
|
||||||
|
{
|
||||||
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
||||||
|
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||||
|
mapView->getLeftSecondaryToolbar()->hide();
|
||||||
|
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* TEXTURE PAINTER SECONDARY TOOL
|
||||||
|
*/
|
||||||
|
|
||||||
|
IconAction* _icon = new IconAction(FontNoggitIcon{FontNoggit::TOOL_TEXTURE_PAINT});
|
||||||
|
|
||||||
|
CheckBoxAction* _unpaintable_chunk = new CheckBoxAction(tr("Unpaintable chunk"));
|
||||||
|
_unpaintable_chunk->setChecked(false);
|
||||||
|
connect(_unpaintable_chunk->checkbox(), &QCheckBox::toggled, [mapView](bool checked)
|
||||||
|
{
|
||||||
|
mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
|
||||||
|
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
||||||
|
});
|
||||||
|
|
||||||
|
_texture_secondary_tool.push_back(_icon);
|
||||||
|
_texture_secondary_tool.push_back(_unpaintable_chunk); unpaintable_chunk_index = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewToolbar::setCurrentMode(MapView* mapView, editing_mode mode)
|
||||||
|
{
|
||||||
|
mapView->getLeftSecondaryToolbar()->hide();
|
||||||
|
current_mode = mode;
|
||||||
|
|
||||||
|
switch (current_mode)
|
||||||
|
{
|
||||||
|
case editing_mode::ground:
|
||||||
|
break;
|
||||||
|
case editing_mode::flatten_blur:
|
||||||
|
break;
|
||||||
|
case editing_mode::paint:
|
||||||
|
if (_texture_secondary_tool.size() > 0)
|
||||||
|
{
|
||||||
|
setupWidget(_texture_secondary_tool);
|
||||||
|
mapView->getLeftSecondaryToolbar()->show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewToolbar::add_tool_icon(MapView* mapView,
|
||||||
|
Noggit::BoolToggleProperty* view_state,
|
||||||
|
const QString& name,
|
||||||
|
const FontNoggit::Icons& icon,
|
||||||
|
ViewToolbar* sec_tool_bar,
|
||||||
|
QVector<QWidgetAction*> sec_action_bar)
|
||||||
|
{
|
||||||
|
auto action = addAction(FontNoggitIcon{icon}, name);
|
||||||
|
connect (action, &QAction::triggered, [action, view_state] () {
|
||||||
|
action->setChecked(!view_state->get());
|
||||||
|
view_state->set(!view_state->get());
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (action, &QAction::hovered, [mapView, sec_tool_bar, sec_action_bar] () {
|
||||||
|
sec_tool_bar->clear();
|
||||||
|
mapView->getSecondaryToolBar()->hide();
|
||||||
|
|
||||||
|
if (sec_action_bar.size() > 0)
|
||||||
|
{
|
||||||
|
sec_tool_bar->setupWidget(sec_action_bar);
|
||||||
|
mapView->getSecondaryToolBar()->show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (view_state, &Noggit::BoolToggleProperty::changed, [action, view_state] () {
|
||||||
|
action->setChecked(view_state->get());
|
||||||
|
});
|
||||||
|
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(view_state->get());
|
||||||
|
}
|
||||||
|
|
||||||
void ViewToolbar::setupWidget(QVector<QWidgetAction *> _to_setup)
|
void ViewToolbar::setupWidget(QVector<QWidgetAction *> _to_setup)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
@@ -174,3 +223,13 @@ void ViewToolbar::setupWidget(QVector<QWidgetAction *> _to_setup)
|
|||||||
(i == _to_setup.size() - 1) ? NULL : addSeparator();
|
(i == _to_setup.size() - 1) ? NULL : addSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewToolbar::showUnpaintableChunk()
|
||||||
|
{
|
||||||
|
if ((unpaintable_chunk_index >= _texture_secondary_tool.size()) ||
|
||||||
|
(unpaintable_chunk_index < 0) ||
|
||||||
|
(current_mode != editing_mode::paint))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return _texture_secondary_tool[unpaintable_chunk_index];
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,12 +21,24 @@ namespace Noggit
|
|||||||
public:
|
public:
|
||||||
ViewToolbar(MapView* mapView);
|
ViewToolbar(MapView* mapView);
|
||||||
ViewToolbar(MapView* mapView, ViewToolbar* tb);
|
ViewToolbar(MapView* mapView, ViewToolbar* tb);
|
||||||
|
ViewToolbar(MapView* mapView, editing_mode mode);
|
||||||
|
|
||||||
|
void setCurrentMode(MapView* mapView, editing_mode mode);
|
||||||
void setupWidget(QVector<QWidgetAction*> _to_setup);
|
void setupWidget(QVector<QWidgetAction*> _to_setup);
|
||||||
|
|
||||||
|
/*secondary top tool*/
|
||||||
QVector<QWidgetAction*> _climb_secondary_tool;
|
QVector<QWidgetAction*> _climb_secondary_tool;
|
||||||
|
|
||||||
|
/*secondary left tool*/
|
||||||
|
bool showUnpaintableChunk();
|
||||||
|
QVector<QWidgetAction*> _texture_secondary_tool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QActionGroup _tool_group;
|
QActionGroup _tool_group;
|
||||||
|
editing_mode current_mode;
|
||||||
|
|
||||||
|
int unpaintable_chunk_index = -1;
|
||||||
|
|
||||||
void add_tool_icon(MapView* mapView,
|
void add_tool_icon(MapView* mapView,
|
||||||
Noggit::BoolToggleProperty* view_state,
|
Noggit::BoolToggleProperty* view_state,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
@@ -45,13 +57,13 @@ namespace Noggit
|
|||||||
QWidget* _widget = new QWidget(NULL);
|
QWidget* _widget = new QWidget(NULL);
|
||||||
QHBoxLayout* _layout = new QHBoxLayout();
|
QHBoxLayout* _layout = new QHBoxLayout();
|
||||||
QLabel* _label = new QLabel(title);
|
QLabel* _label = new QLabel(title);
|
||||||
QLabel* _display = new QLabel(tr("57 degrees"));
|
QLabel* _display = new QLabel(tr("49 degrees"));
|
||||||
|
|
||||||
_slider = new QSlider(NULL);
|
_slider = new QSlider(NULL);
|
||||||
_slider->setOrientation(Qt::Horizontal);
|
_slider->setOrientation(Qt::Horizontal);
|
||||||
_slider->setMinimum(0);
|
_slider->setMinimum(0);
|
||||||
_slider->setMaximum(1570);
|
_slider->setMaximum(1570);
|
||||||
_slider->setValue(1000);
|
_slider->setValue(855);
|
||||||
|
|
||||||
connect(_slider, &QSlider::valueChanged, [_display](int value)
|
connect(_slider, &QSlider::valueChanged, [_display](int value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user