mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
Merge pull request #38 from M4RCK5/dev
Lobby Connect Improvements + MBTL Fix
This commit is contained in:
commit
ca66c1bf62
@ -186,7 +186,7 @@ unsigned int Steam_User_Stats::cache_leaderboard_ifneeded(const std::string &nam
|
||||
|
||||
// create a new entry in-memory and try reading the entries from disk
|
||||
struct Steam_Leaderboard new_board{};
|
||||
new_board.name = common_helpers::ascii_to_lowercase(name);
|
||||
new_board.name = name;
|
||||
new_board.sort_method = eLeaderboardSortMethod;
|
||||
new_board.display_type = eLeaderboardDisplayType;
|
||||
new_board.entries = load_leaderboard_entries(name);
|
||||
|
@ -31,9 +31,18 @@
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
void title() {
|
||||
#ifdef _WIN32
|
||||
system("cls");
|
||||
#else
|
||||
system("clear");
|
||||
#endif
|
||||
|
||||
std::cout << "\n----Lobby Connect----\n\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::string appid_str(std::to_string(LOBBY_CONNECT_APPID));
|
||||
set_env_variable("SteamAppId", appid_str);
|
||||
@ -45,17 +54,20 @@ int main() {
|
||||
|
||||
//Set appid to: LOBBY_CONNECT_APPID
|
||||
SteamAPI_RestartAppIfNecessary(LOBBY_CONNECT_APPID);
|
||||
std::cout << "This is a program to find lobbies and run the game with lobby connect parameters" << std::endl;
|
||||
std::cout << "Api initialized, ";
|
||||
top:
|
||||
std::cout << "waiting a few seconds for connections:" << std::endl;
|
||||
|
||||
refresh:
|
||||
title();
|
||||
std::cout << "Please wait...\n";
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
SteamAPI_RunCallbacks();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
}
|
||||
|
||||
int friend_count = SteamFriends()->GetFriendCount(k_EFriendFlagAll);
|
||||
std::cout << "People on the network: " << friend_count << std::endl;
|
||||
|
||||
/*
|
||||
std::cout << "People on the network: " << friend_count << "\n";
|
||||
for (int i = 0; i < friend_count; ++i) {
|
||||
CSteamID id = SteamFriends()->GetFriendByIndex(i, k_EFriendFlagAll);
|
||||
const char *name = SteamFriends()->GetFriendPersonaName(id);
|
||||
@ -64,8 +76,9 @@ top:
|
||||
SteamFriends()->GetFriendGamePlayed(id, &friend_info);
|
||||
std::cout << name << " is playing: " << friend_info.m_gameID.AppID() << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
std::cout << std::endl << "--------------Menu-------------" << std::endl << "\tappid\tname\tcommand line" << std::endl;
|
||||
title();
|
||||
|
||||
std::vector<std::pair<std::string, uint32>> arguments;
|
||||
for (int i = 0; i < friend_count; ++i) {
|
||||
@ -77,28 +90,35 @@ top:
|
||||
auto appid = friend_info.m_gameID.AppID();
|
||||
|
||||
if (strlen(connect) > 0) {
|
||||
std::cout << arguments.size() << "\t" << appid << "\t" << name << "\t" << connect << std::endl;
|
||||
std::cout << arguments.size() << " - " << name << " is playing " << appid << " (" << connect << ").\n";
|
||||
arguments.emplace_back(connect, appid);
|
||||
} else {
|
||||
if (friend_info.m_steamIDLobby != k_steamIDNil) {
|
||||
std::string connect = "+connect_lobby " + std::to_string(friend_info.m_steamIDLobby.ConvertToUint64());
|
||||
std::cout << arguments.size() << "\t" << appid << "\t" << name << "\t" << connect << std::endl;
|
||||
std::cout << arguments.size() << " - " << name << " is playing " << appid << " (" << connect << ").\n";
|
||||
arguments.emplace_back(connect, appid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << arguments.size() << ": Retry." << std::endl;
|
||||
std::cout << std::endl << "Enter the number corresponding to your choice then press Enter." << std::endl;
|
||||
std::cout << arguments.size() << " - Refresh.\n\n";
|
||||
std::cout << "Choose an option: ";
|
||||
unsigned int choice;
|
||||
std::cin >> choice;
|
||||
|
||||
if (choice >= arguments.size()) goto top;
|
||||
if (std::cin.fail() || choice >= arguments.size()) {
|
||||
std::cin.clear();
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
goto refresh;
|
||||
}
|
||||
|
||||
title();
|
||||
|
||||
auto connect = arguments[choice].first;
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _WIN32
|
||||
auto appid = arguments[choice].second;
|
||||
std::cout << "starting the game with: " << connect << std::endl;
|
||||
std::cout << "Starting the game with: " << connect << "\n";
|
||||
|
||||
char szBaseDirectory[MAX_PATH] = "";
|
||||
GetModuleFileNameA(0, szBaseDirectory, MAX_PATH);
|
||||
@ -117,7 +137,7 @@ top:
|
||||
|
||||
auto writeLobbyFile = [&lobbyFile](const std::string& data) {
|
||||
std::ofstream ofs(std::filesystem::u8path(lobbyFile));
|
||||
ofs << data << std::endl;
|
||||
ofs << data << "\n";
|
||||
};
|
||||
|
||||
auto fileExists = [](const std::string& filename) {
|
||||
@ -150,7 +170,7 @@ top:
|
||||
|
||||
std::string filename = readLobbyFile();
|
||||
if (filename.empty() || !fileExists(filename) || !joinLobby(filename)) {
|
||||
std::cout << "Please select the game exe" << std::endl;
|
||||
std::cout << "Please select the game executable.\n";
|
||||
|
||||
OPENFILENAMEA ofn;
|
||||
char szFileName[MAX_PATH] = "";
|
||||
@ -166,9 +186,11 @@ top:
|
||||
writeLobbyFile(szFileName);
|
||||
}
|
||||
}
|
||||
#else
|
||||
std::cout << "Please launch the game with these arguments: " << connect << std::endl;
|
||||
#endif
|
||||
#else
|
||||
std::cout << "Please launch the game with these arguments: " << connect << "\n\n";
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user