Merge branch 'wmo-stuff' into 'noggit-shadowlands'

editing wmo sets marks tiles for save

See merge request prophecy-rp/noggit-red!39
This commit is contained in:
Kaev
2023-05-13 10:11:26 +00:00
5 changed files with 41 additions and 33 deletions

View File

@@ -5054,6 +5054,30 @@ void MapView::mouseMoveEvent (QMouseEvent* event)
_last_mouse_pos = event->pos();
}
void MapView::change_selected_wmo_nameset(int set)
{
auto last_entry = _world->get_last_selected_model();
if (last_entry)
{
if (last_entry.value().index() != eEntry_Object)
{
return;
}
auto obj = std::get<selected_object_type>(last_entry.value());
if (obj->which() == eWMO)
{
WMOInstance* wmo = static_cast<WMOInstance*>(obj);
wmo->change_nameset(set);
_world->updateTilesWMO(wmo, model_update::none); // needed?
auto tiles = wmo->getTiles();
for (auto tile : tiles)
{
tile->changed = true;
}
}
}
}
void MapView::change_selected_wmo_doodadset(int set)
{
for (auto& selection : _world->current_selection())
@@ -5068,6 +5092,11 @@ void MapView::change_selected_wmo_doodadset(int set)
auto wmo = static_cast<WMOInstance*>(obj);
wmo->change_doodadset(set);
_world->updateTilesWMO(wmo, model_update::none);
auto tiles = wmo->getTiles();
for (auto tile : tiles)
{
tile->changed = true;
}
}
}
}

View File

@@ -262,6 +262,7 @@ public:
~MapView();
void tick (float dt);
void change_selected_wmo_nameset(int set);
void change_selected_wmo_doodadset(int set);
void saveMinimap(MinimapRenderSettings* settings);
void initMinimapSave() { saving_minimap = true; };

View File

@@ -257,6 +257,10 @@ void WMOInstance::recalcExtents()
extents[1] = wmo_aabb.max;
}
void WMOInstance::change_nameset(uint16_t name_set)
{
mNameset = name_set;
}
void WMOInstance::change_doodadset(uint16_t doodad_set)
{

View File

@@ -103,6 +103,7 @@ public:
void intersect (math::ray const&, selection_result*, bool do_exterior = true);
void recalcExtents() override;
void change_nameset(uint16_t name_set);
void ensureExtents() override;
bool finishedLoading() override { return wmo->finishedLoading(); };
virtual void updateDetails(Noggit::Ui::detail_infos* detail_widget) override;

View File

@@ -513,45 +513,18 @@ namespace Noggit
connect(_doodadSetSelector
, qOverload<int>(&QComboBox::currentIndexChanged)
, [this](int index) {
auto last_entry = _map_view->_world->get_last_selected_model();
if (last_entry)
{
if (last_entry.value().index() != eEntry_Object)
{
return;
}
auto obj = std::get<selected_object_type>(last_entry.value());
if (obj->which() == eWMO)
{
// use actions or directly call updateDetailInfos() ?
WMOInstance* wi = static_cast<WMOInstance*>(obj);
NOGGIT_ACTION_MGR->beginAction(_map_view, Noggit::ActionFlags::eOBJECTS_TRANSFORMED);
wi->change_doodadset(index);
NOGGIT_ACTION_MGR->endAction();
}
}
NOGGIT_ACTION_MGR->beginAction(_map_view, Noggit::ActionFlags::eOBJECTS_TRANSFORMED);
_map_view->change_selected_wmo_doodadset(index);
NOGGIT_ACTION_MGR->endAction();
});
connect(_nameSetSelector
, qOverload<int>(&QComboBox::currentIndexChanged)
, [this](int index) {
auto last_entry = _map_view->_world->get_last_selected_model();
if (last_entry)
{
if (last_entry.value().index() != eEntry_Object)
{
return;
}
auto obj = std::get<selected_object_type>(last_entry.value());
if (obj->which() == eWMO)
{
WMOInstance* wi = static_cast<WMOInstance*>(obj);
NOGGIT_ACTION_MGR->beginAction(_map_view, Noggit::ActionFlags::eOBJECTS_TRANSFORMED);
wi->mNameset = index;
NOGGIT_ACTION_MGR->endAction();
}
}
NOGGIT_ACTION_MGR->beginAction(_map_view, Noggit::ActionFlags::eOBJECTS_TRANSFORMED);
_map_view->change_selected_wmo_nameset(index);
NOGGIT_ACTION_MGR->endAction();
});
auto mv_pos = mapView->pos();