[Client] Send game invites from the user context menu via a private message

The user context menu gains an "Invite to Game" submenu listing the
inviteable games in the room (the inviter's own games, honoring the
buddy-only setting). Picking one opens a private message to the target
user with a cockatrice://joingame link naming the game, so the target
gets a clickable invite instead of a raw URL. Multi-game rooms offer a
picker; a single inviteable game sends directly. Sending a message to
an offline user no longer swallows the draft — it reports that the
user is offline and keeps the typed text.

Took 1 minute
This commit is contained in:
Lukas Brübach 2026-08-16 21:46:30 +02:00
parent 765ebf8fb1
commit 38e6c53333
3 changed files with 9 additions and 2 deletions

View file

@ -128,6 +128,12 @@ bool TabMessage::isUserOnline() const
return userOnline; return userOnline;
} }
void TabMessage::sendInviteMessage(const QString &text)
{
sayEdit->setText(text);
sendMessage();
}
void TabMessage::messageSent(const Response &response, void TabMessage::messageSent(const Response &response,
const CommandContainer & /*commandContainer*/, const CommandContainer & /*commandContainer*/,
const QVariant &extraData) const QVariant &extraData)

View file

@ -66,6 +66,7 @@ public:
[[nodiscard]] bool isUserOnline() const; [[nodiscard]] bool isUserOnline() const;
void sendPrivateMessage(const QString &text); void sendPrivateMessage(const QString &text);
void sendInviteMessage(const QString &text);
private: private:
bool shouldShowSystemPopup(const Event_UserMessage &event); bool shouldShowSystemPopup(const Event_UserMessage &event);

View file

@ -993,8 +993,8 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
void TabSupervisor::sendInviteToUser(const QString &userName, const QString &inviteText) void TabSupervisor::sendInviteToUser(const QString &userName, const QString &inviteText)
{ {
TabMessage *tab = addMessageTab(userName, true); TabMessage *tab = addMessageTab(userName, true);
if (tab && tab->isUserOnline()) { if (tab) {
tab->sendPrivateMessage(inviteText); tab->sendInviteMessage(inviteText);
} }
} }