game: ensure give/pm buttons are updated as needed

state can change if a player auctions their account
This commit is contained in:
Crypto City 2023-06-24 17:19:02 +00:00
parent 34ecc634ee
commit ffdf91f8f1

View File

@ -1507,23 +1507,6 @@ UIPlayerInfoDialog::UIPlayerInfoDialog(Context *ctx, const GameState *game, uint
InitColumnsList();
HideRareFishInfo();
if (!game->playerState.has_wallet)
{
TBButton *button;
button = GetWidgetByIDAndType<TBButton>(TBIDC("give-money"));
if (button)
button->SetState(WIDGET_STATE_DISABLED, true);
button = GetWidgetByIDAndType<TBButton>(TBIDC("give-items"));
if (button)
button->SetState(WIDGET_STATE_DISABLED, true);
button = GetWidgetByIDAndType<TBButton>(TBIDC("give-land"));
if (button)
button->SetState(WIDGET_STATE_DISABLED, true);
button = GetWidgetByIDAndType<TBButton>(TBIDC("send-message"));
if (button)
button->SetState(WIDGET_STATE_DISABLED, true);
}
const bool can_auction = game->playerState.has_wallet && game->playerState.id == player_id;
GetWidgetByIDAndType<TBButton>(TBIDC("auction-account"))->SetState(WIDGET_STATE_DISABLED, !can_auction);
@ -2681,6 +2664,11 @@ void UIPlayerInfoDialog::Update(const std::shared_ptr<GameWallet> &w)
const bool unmessageable = game->playerState.id == player_id || player_id == GAME_ACCOUNT || game->is_autonomous_player(player_id);
sendMessageWidget->SetVisibility(unmessageable ? WIDGET_VISIBILITY_INVISIBLE : WIDGET_VISIBILITY_VISIBLE);
giveGoldWidget->SetState(WIDGET_STATE_DISABLED, game->playerState.id == 0);
giveItemsWidget->SetState(WIDGET_STATE_DISABLED, game->playerState.id == 0);
giveLandWidget->SetState(WIDGET_STATE_DISABLED, game->playerState.id == 0);
sendMessageWidget->SetState(WIDGET_STATE_DISABLED, game->playerState.id == 0);
if (get_ownership)
{
GetOwnership(w);