Skip to content

Commit

Permalink
Only display the "Map Display" columns for the number of maps configu…
Browse files Browse the repository at this point in the history
…red in settings
  • Loading branch information
dpaulat committed Nov 6, 2023
1 parent ed8574d commit 1c5199d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scwx-qt/source/scwx/qt/ui/layer_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_layer_dialog.h"

#include <scwx/qt/model/layer_model.hpp>
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/util/logger.hpp>

#include <QPushButton>
Expand Down Expand Up @@ -33,6 +34,7 @@ class LayerDialogImpl
~LayerDialogImpl() = default;

void ConnectSignals();
void UpdateMapDisplayColumns();
void UpdateMoveButtonsEnabled();

std::vector<int> GetSelectedRows();
Expand Down Expand Up @@ -73,6 +75,8 @@ LayerDialog::LayerDialog(QWidget* parent) :
ui->moveDownButton->setEnabled(false);
ui->moveBottomButton->setEnabled(false);

p->UpdateMapDisplayColumns();

p->ConnectSignals();
}

Expand All @@ -81,6 +85,25 @@ LayerDialog::~LayerDialog()
delete ui;
}

void LayerDialogImpl::UpdateMapDisplayColumns()
{
auto& generalSettings = settings::GeneralSettings::Instance();
std::int64_t gridWidth = generalSettings.grid_width().GetValue();
std::int64_t gridHeight = generalSettings.grid_height().GetValue();
int mapCount = static_cast<int>(gridWidth * gridHeight);

int displayMap1Column =
static_cast<int>(model::LayerModel::Column::DisplayMap1);

// For each 0-based map index, 1-3 (excluding 0, always displayed)
for (int mapIndex = 1; mapIndex < 4; ++mapIndex)
{
const int column = displayMap1Column + mapIndex;
const bool hide = mapIndex >= mapCount;
self_->ui->layerTreeView->setColumnHidden(column, hide);
}
}

void LayerDialogImpl::ConnectSignals()
{
QObject::connect(
Expand Down

0 comments on commit 1c5199d

Please sign in to comment.