mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:40:05 +00:00
parent
effe78e1be
commit
6000abdeb3
7 changed files with 120 additions and 7 deletions
|
|
@ -113,6 +113,7 @@ public:
|
|||
|
||||
void AsyncSetup();
|
||||
void ConfigureMapLayout();
|
||||
void ConfigureMapStyles();
|
||||
void ConnectAnimationSignals();
|
||||
void ConnectMapSignals();
|
||||
void ConnectOtherSignals();
|
||||
|
|
@ -275,6 +276,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||
}
|
||||
|
||||
p->PopulateMapStyles();
|
||||
p->ConfigureMapStyles();
|
||||
p->ConnectMapSignals();
|
||||
p->ConnectAnimationSignals();
|
||||
p->ConnectOtherSignals();
|
||||
|
|
@ -597,6 +599,39 @@ void MainWindowImpl::ConfigureMapLayout()
|
|||
SetActiveMap(maps_.at(0));
|
||||
}
|
||||
|
||||
void MainWindowImpl::ConfigureMapStyles()
|
||||
{
|
||||
const auto& mapProviderInfo = map::GetMapProviderInfo(mapProvider_);
|
||||
auto& mapSettings = manager::SettingsManager::map_settings();
|
||||
|
||||
for (std::size_t i = 0; i < maps_.size(); i++)
|
||||
{
|
||||
std::string styleName = mapSettings.map_style(i).GetValue();
|
||||
|
||||
if (std::find_if(mapProviderInfo.mapStyles_.cbegin(),
|
||||
mapProviderInfo.mapStyles_.cend(),
|
||||
[&](const auto& mapStyle) {
|
||||
return mapStyle.name_ == styleName;
|
||||
}) != mapProviderInfo.mapStyles_.cend())
|
||||
{
|
||||
// Initialize map style from settings
|
||||
maps_.at(i)->SetInitialMapStyle(styleName);
|
||||
|
||||
// Update the active map's style
|
||||
if (maps_[i] == activeMap_)
|
||||
{
|
||||
UpdateMapStyle(styleName);
|
||||
}
|
||||
}
|
||||
else if (!mapProviderInfo.mapStyles_.empty())
|
||||
{
|
||||
// Stage first valid map style from map provider
|
||||
mapSettings.map_style(i).StageValue(
|
||||
mapProviderInfo.mapStyles_.at(0).name_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowImpl::ConnectMapSignals()
|
||||
{
|
||||
for (const auto& mapWidget : maps_)
|
||||
|
|
@ -621,7 +656,13 @@ void MainWindowImpl::ConnectMapSignals()
|
|||
connect(mapWidget,
|
||||
&map::MapWidget::MapStyleChanged,
|
||||
this,
|
||||
&MainWindowImpl::UpdateMapStyle);
|
||||
[&](const std::string& mapStyle)
|
||||
{
|
||||
if (mapWidget == activeMap_)
|
||||
{
|
||||
UpdateMapStyle(mapStyle);
|
||||
}
|
||||
});
|
||||
|
||||
connect(
|
||||
mapWidget,
|
||||
|
|
@ -758,7 +799,21 @@ void MainWindowImpl::ConnectOtherSignals()
|
|||
&QComboBox::currentTextChanged,
|
||||
mainWindow_,
|
||||
[&](const QString& text)
|
||||
{ activeMap_->SetMapStyle(text.toStdString()); });
|
||||
{
|
||||
activeMap_->SetMapStyle(text.toStdString());
|
||||
|
||||
// Update settings for active map
|
||||
for (std::size_t i = 0; i < maps_.size(); ++i)
|
||||
{
|
||||
if (maps_[i] == activeMap_)
|
||||
{
|
||||
auto& mapSettings =
|
||||
manager::SettingsManager::map_settings();
|
||||
mapSettings.map_style(i).StageValue(text.toStdString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(level2ProductsWidget_,
|
||||
&ui::Level2ProductsWidget::RadarProductSelected,
|
||||
mainWindow_,
|
||||
|
|
@ -925,6 +980,17 @@ void MainWindowImpl::UpdateMapStyle(const std::string& styleName)
|
|||
if (index != -1)
|
||||
{
|
||||
mainWindow_->ui->mapStyleComboBox->setCurrentIndex(index);
|
||||
|
||||
// Update settings for active map
|
||||
for (std::size_t i = 0; i < maps_.size(); ++i)
|
||||
{
|
||||
if (maps_[i] == activeMap_)
|
||||
{
|
||||
auto& mapSettings = manager::SettingsManager::map_settings();
|
||||
mapSettings.map_style(i).StageValue(styleName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue