From 460f124f0c6c053b72d7450f18caa84f7dd37ae4 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 22 Oct 2024 15:03:13 +0200 Subject: [PATCH] Disable Start button until mission is selected. The mission selection map starts with nothing selected so the "Start" button does nothing on click. Disable it until something gets selected for better UX. --- libs/s25main/desktops/dskCampaignMissionSelection.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/s25main/desktops/dskCampaignMissionSelection.cpp b/libs/s25main/desktops/dskCampaignMissionSelection.cpp index c770ab0fe..3d14bc2a6 100644 --- a/libs/s25main/desktops/dskCampaignMissionSelection.cpp +++ b/libs/s25main/desktops/dskCampaignMissionSelection.cpp @@ -67,13 +67,15 @@ dskCampaignMissionSelection::dskCampaignMissionSelection(CreateServerInfo csi, c if(campaign_->selectionMapData) { constexpr Extent buttonSize(200, buttonHeight); - AddTextButton(ID_btStart, DrawPoint(300, 530), buttonSize, TextureColor::Red1, _("Start"), NormalFont); + auto* btStart = + AddTextButton(ID_btStart, DrawPoint(300, 530), buttonSize, TextureColor::Red1, _("Start"), NormalFont); AddTextButton(ID_btBack, DrawPoint(300, 530 + buttonSize.y + spacingBetweenButtons), buttonSize, TextureColor::Red1, _("Back"), NormalFont); auto* mapSelection = AddMapSelection(ID_MapSelection, DrawPoint(0, 0), Extent(800, 508), *campaign_->selectionMapData); mapSelection->setMissionsStatus(std::vector(campaign_->getNumMaps(), {true, true})); + btStart->SetEnabled(static_cast(mapSelection->getSelection())); } else { constexpr Extent buttonSize(22, buttonHeight); @@ -194,6 +196,11 @@ void dskCampaignMissionSelection::Msg_ButtonClick(unsigned ctrl_id) const auto selectedMission = GetCtrl(ID_MapSelection)->getSelection(); if(selectedMission) StartServer(*selectedMission); + } else if(ctrl_id == ID_MapSelection) + { + auto* btStart = GetCtrl(ID_btStart); + const auto* mapSelection = GetCtrl(ID_MapSelection); + btStart->SetEnabled(static_cast(mapSelection->getSelection())); } else if(ctrl_id >= ID_btFirstPage && ctrl_id <= ID_btLastPage) { switch(ctrl_id)