mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:16:51 +02:00
Join lobby on startup
This commit is contained in:
parent
6b861e680f
commit
7ec2f98cf2
3 changed files with 42 additions and 21 deletions
|
@ -3224,6 +3224,14 @@ void Application::init() {
|
||||||
addressLookupString = arguments().value(urlIndex + 1);
|
addressLookupString = arguments().value(urlIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when +connect_lobby in command line, join steam lobby
|
||||||
|
const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
|
||||||
|
int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);
|
||||||
|
if (lobbyIndex != -1) {
|
||||||
|
QString lobbyId = arguments().value(lobbyIndex + 1);
|
||||||
|
SteamClient::joinLobby(lobbyId);
|
||||||
|
}
|
||||||
|
|
||||||
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
||||||
if (addressLookupString.isEmpty() && firstRun.get()) {
|
if (addressLookupString.isEmpty() && firstRun.get()) {
|
||||||
qDebug() << "First run and no URL passed... attempting to go to Home or Entry...";
|
qDebug() << "First run and no URL passed... attempting to go to Home or Entry...";
|
||||||
|
|
|
@ -165,9 +165,7 @@ SteamCallbackManager::SteamCallbackManager() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamCallbackManager::onGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t* pCallback) {
|
void parseUrlAndGo(QString url) {
|
||||||
auto url = QString::fromLocal8Bit(pCallback->m_rgchConnect);
|
|
||||||
|
|
||||||
if (url.startsWith(CONNECT_PREFIX) && url.endsWith(CONNECT_SUFFIX)) {
|
if (url.startsWith(CONNECT_PREFIX) && url.endsWith(CONNECT_SUFFIX)) {
|
||||||
url.remove(0, CONNECT_PREFIX.size());
|
url.remove(0, CONNECT_PREFIX.size());
|
||||||
url.remove(-CONNECT_SUFFIX.size(), CONNECT_SUFFIX.size());
|
url.remove(-CONNECT_SUFFIX.size(), CONNECT_SUFFIX.size());
|
||||||
|
@ -176,40 +174,50 @@ void SteamCallbackManager::onGameRichPresenceJoinRequested(GameRichPresenceJoinR
|
||||||
qDebug() << "Joining Steam Friend at:" << url;
|
qDebug() << "Joining Steam Friend at:" << url;
|
||||||
auto mimeData = new QMimeData();
|
auto mimeData = new QMimeData();
|
||||||
mimeData->setUrls(QList<QUrl>() << QUrl(url));
|
mimeData->setUrls(QList<QUrl>() << QUrl(url));
|
||||||
auto event = new QDropEvent(QPointF(0,0), Qt::MoveAction, mimeData, Qt::LeftButton, Qt::NoModifier);
|
auto event = new QDropEvent(QPointF(0, 0), Qt::MoveAction, mimeData, Qt::LeftButton, Qt::NoModifier);
|
||||||
|
|
||||||
QCoreApplication::postEvent(qApp, event);
|
QCoreApplication::postEvent(qApp, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamCallbackManager::onGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t* pCallback) {
|
||||||
|
auto url = QString::fromLocal8Bit(pCallback->m_rgchConnect);
|
||||||
|
|
||||||
|
parseUrlAndGo(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SteamCallbackManager::onLobbyCreated(LobbyCreated_t* pCallback) {
|
void SteamCallbackManager::onLobbyCreated(LobbyCreated_t* pCallback) {
|
||||||
qDebug() << pCallback->m_eResult << pCallback->m_ulSteamIDLobby;
|
qDebug() << pCallback->m_eResult << pCallback->m_ulSteamIDLobby;
|
||||||
if (pCallback->m_eResult == k_EResultOK) {
|
if (pCallback->m_eResult == k_EResultOK) {
|
||||||
qDebug() << "Inviting steam friends";
|
qDebug() << "Inviting steam friends";
|
||||||
|
|
||||||
SteamMatchmaking()->SetLobbyData(pCallback->m_ulSteamIDLobby, "connect",
|
auto url = SteamFriends()->GetFriendRichPresence(SteamUser()->GetSteamID(), "connect");
|
||||||
SteamFriends()->GetFriendRichPresence(SteamUser()->GetSteamID(), "connect"));
|
SteamMatchmaking()->SetLobbyData(pCallback->m_ulSteamIDLobby, "connect", url);
|
||||||
SteamMatchmaking()->SetLobbyMemberData(pCallback->m_ulSteamIDLobby,
|
SteamMatchmaking()->SetLobbyMemberData(pCallback->m_ulSteamIDLobby, "creator", "true");
|
||||||
"Creator", "true");
|
|
||||||
SteamFriends()->ActivateGameOverlayInviteDialog(pCallback->m_ulSteamIDLobby);
|
SteamFriends()->ActivateGameOverlayInviteDialog(pCallback->m_ulSteamIDLobby);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamCallbackManager::onGameLobbyJoinRequested(GameLobbyJoinRequested_t* pCallback) {
|
void SteamCallbackManager::onGameLobbyJoinRequested(GameLobbyJoinRequested_t* pCallback) {
|
||||||
qDebug() << "onGameLobbyJoinRequested";
|
qDebug() << "Joining Steam lobby";
|
||||||
SteamMatchmaking()->JoinLobby(pCallback->m_steamIDLobby);
|
SteamMatchmaking()->JoinLobby(pCallback->m_steamIDLobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamCallbackManager::onLobbyEnter(LobbyEnter_t* pCallback) {
|
void SteamCallbackManager::onLobbyEnter(LobbyEnter_t* pCallback) {
|
||||||
qDebug() << "onLobbyEnter";
|
if (pCallback->m_EChatRoomEnterResponse != k_EChatRoomEnterResponseSuccess) {
|
||||||
auto creator = SteamMatchmaking()->GetLobbyMemberData(pCallback->m_ulSteamIDLobby, SteamUser()->GetSteamID(), "creator");
|
qWarning() << "An error occured while joing the Steam lobby:" << pCallback->m_EChatRoomEnterResponse;
|
||||||
if (strcmp(creator, "true") == 0) {
|
return;
|
||||||
qDebug() << "Created lobby";
|
|
||||||
SteamMatchmaking()->LeaveLobby(pCallback->m_ulSteamIDLobby);
|
|
||||||
} else if (pCallback->m_EChatRoomEnterResponse == k_EChatRoomEnterResponseSuccess) {
|
|
||||||
qDebug() << "Success";
|
|
||||||
auto connectValue = SteamMatchmaking()->GetLobbyData(pCallback->m_ulSteamIDLobby, "connect");
|
|
||||||
qDebug() << connectValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto creator = SteamMatchmaking()->GetLobbyMemberData(pCallback->m_ulSteamIDLobby,
|
||||||
|
SteamUser()->GetSteamID(), "creator");
|
||||||
|
if (strcmp(creator, "true") != 0) {
|
||||||
|
auto url = SteamMatchmaking()->GetLobbyData(pCallback->m_ulSteamIDLobby, "connect");
|
||||||
|
parseUrlAndGo(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamMatchmaking()->LeaveLobby(pCallback->m_ulSteamIDLobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,9 +226,6 @@ static SteamCallbackManager steamCallbackManager;
|
||||||
|
|
||||||
|
|
||||||
bool SteamClient::isRunning() {
|
bool SteamClient::isRunning() {
|
||||||
if (!initialized) {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,3 +297,10 @@ void SteamClient::openInviteOverlay() {
|
||||||
static const int MAX_LOBBY_SIZE = 20;
|
static const int MAX_LOBBY_SIZE = 20;
|
||||||
SteamMatchmaking()->CreateLobby(k_ELobbyTypePrivate, MAX_LOBBY_SIZE);
|
SteamMatchmaking()->CreateLobby(k_ELobbyTypePrivate, MAX_LOBBY_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SteamClient::joinLobby(QString lobbyIdStr) {
|
||||||
|
qDebug() << "Trying to join Steam lobby:" << lobbyIdStr;
|
||||||
|
CSteamID lobbyId(lobbyIdStr.toULongLong());
|
||||||
|
SteamMatchmaking()->JoinLobby(lobbyId);
|
||||||
|
}
|
|
@ -35,6 +35,7 @@ public:
|
||||||
static void requestTicket(TicketRequestCallback callback);
|
static void requestTicket(TicketRequestCallback callback);
|
||||||
static void updateLocation(QString status, QUrl locationUrl);
|
static void updateLocation(QString status, QUrl locationUrl);
|
||||||
static void openInviteOverlay();
|
static void openInviteOverlay();
|
||||||
|
static void joinLobby(QString lobbyId);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue