Skip to content

Commit

Permalink
Disable Start button until mission is selected.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Flamefire committed Nov 7, 2024
1 parent 6d090b9 commit 460f124
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libs/s25main/desktops/dskCampaignMissionSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MissionStatus>(campaign_->getNumMaps(), {true, true}));
btStart->SetEnabled(static_cast<bool>(mapSelection->getSelection()));
} else
{
constexpr Extent buttonSize(22, buttonHeight);
Expand Down Expand Up @@ -194,6 +196,11 @@ void dskCampaignMissionSelection::Msg_ButtonClick(unsigned ctrl_id)
const auto selectedMission = GetCtrl<ctrlMapSelection>(ID_MapSelection)->getSelection();
if(selectedMission)
StartServer(*selectedMission);
} else if(ctrl_id == ID_MapSelection)
{
auto* btStart = GetCtrl<ctrlButton>(ID_btStart);
const auto* mapSelection = GetCtrl<ctrlMapSelection>(ID_MapSelection);
btStart->SetEnabled(static_cast<bool>(mapSelection->getSelection()));
} else if(ctrl_id >= ID_btFirstPage && ctrl_id <= ID_btLastPage)
{
switch(ctrl_id)
Expand Down

0 comments on commit 460f124

Please sign in to comment.