Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions libs/s25main/desktops/dskGameLobby.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

Expand All @@ -8,6 +8,7 @@
#include "ILobbyClient.hpp"
#include "JoinPlayerInfo.h"
#include "Loader.h"
#include "RTTR_Assert.h"
#include "WindowManager.h"
#include "animation/BlinkButtonAnim.h"
#include "controls/ctrlBaseColor.h"
Expand Down Expand Up @@ -43,6 +44,7 @@
#include "libsiedler2/prototypen.h"
#include "s25util/Log.h"
#include "s25util/MyTime.h"
#include <array>
#include <memory>
#include <mygettext/mygettext.h>
#include <set>
Expand Down Expand Up @@ -106,6 +108,21 @@ constexpr T nextEnumValue(T value)
{
return T((rttr::enum_cast(value) + 1) % helpers::NumEnumValues_v<T>);
}

std::array NATION_ORDER = {
Nation::Romans, Nation::Vikings, Nation::Japanese, Nation::Africans, Nation::Babylonians,
};
static_assert(NATION_ORDER.size() == helpers::NumEnumValues_v<Nation>);

Nation nextNation(const Nation value)
{
// NOLINTNEXTLINE(readability-qualified-auto)
auto it = helpers::find(NATION_ORDER, value);
RTTR_Assert(it != NATION_ORDER.end());
if(++it == NATION_ORDER.end())
it = NATION_ORDER.begin();
return *it;
}
} // namespace

dskGameLobby::dskGameLobby(ServerType serverType, std::shared_ptr<GameLobby> gameLobby, unsigned playerId,
Expand Down Expand Up @@ -457,11 +474,11 @@ void dskGameLobby::UpdatePlayerRow(const unsigned row)
}

if(allowNationChange)
group->AddTextButton(ID_btNation, DrawPoint(215, cy), Extent(95, 22), tc, _(NationNames[Nation::Romans]),
group->AddTextButton(ID_btNation, DrawPoint(215, cy), Extent(95, 22), tc, _(NationNames[NATION_ORDER[0]]),
NormalFont);
else
group->AddTextDeepening(ID_btNation, DrawPoint(215, cy), Extent(95, 22), tc, _(NationNames[Nation::Romans]),
NormalFont, COLOR_YELLOW);
group->AddTextDeepening(ID_btNation, DrawPoint(215, cy), Extent(95, 22), tc,
_(NationNames[NATION_ORDER[0]]), NormalFont, COLOR_YELLOW);

const auto& portrait = Portraits[player.portraitIndex];
if(allowPortraitChange)
Expand Down Expand Up @@ -554,7 +571,7 @@ void dskGameLobby::Msg_Group_ButtonClick(const unsigned group_id, const unsigned
if(playerId == localPlayerId_ || gameLobby_->isHost())
{
JoinPlayerInfo& player = gameLobby_->getPlayer(playerId);
player.nation = nextEnumValue(player.nation);
player.nation = nextNation(player.nation);
if(gameLobby_->isHost())
lobbyController->SetNation(playerId, player.nation);
else
Expand Down
Loading