Some beautifies
This commit is contained in:
parent
9818fa7b21
commit
3000a11785
@ -257,7 +257,7 @@ namespace Components
|
|||||||
*substr2 = 0;
|
*substr2 = 0;
|
||||||
////DBG(("Connecting to: %s", substr));
|
////DBG(("Connecting to: %s", substr));
|
||||||
|
|
||||||
Game::Cbuf_AddText(0, Utils::VA("connect %s;", substr));
|
Command::Execute(Utils::VA("connect %s;", substr), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ConnectProtocol::InvokeConnect()
|
BOOL ConnectProtocol::InvokeConnect()
|
||||||
@ -321,12 +321,11 @@ namespace Components
|
|||||||
ConnectProtocol::ConnectProtocol()
|
ConnectProtocol::ConnectProtocol()
|
||||||
{
|
{
|
||||||
ConnectProtocol::InstallProtocol();
|
ConnectProtocol::InstallProtocol();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Send Connect Command to running iw4x instance
|
//Send Connect Command to running iw4x instance
|
||||||
BOOL CALLBACK enumWindowsProc(__in HWND hWnd, __in LPARAM lParam) {
|
BOOL CALLBACK ConnectProtocol::EnumWindowsProc(__in HWND hWnd, __in LPARAM lParam) {
|
||||||
|
|
||||||
DWORD id = GetWindowThreadProcessId(hWnd, &id);
|
DWORD id = GetWindowThreadProcessId(hWnd, &id);
|
||||||
DWORD id2 = GetWindowThreadProcessId(FindWindowFromProcessId(proc_id), &id2);
|
DWORD id2 = GetWindowThreadProcessId(FindWindowFromProcessId(proc_id), &id2);
|
||||||
@ -353,7 +352,7 @@ namespace Components
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) {
|
BOOL CALLBACK ConnectProtocol::EnumChildProc(HWND hwnd, LPARAM lParam) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
GetClassName(hwnd, (LPSTR)buffer, 255);
|
GetClassName(hwnd, (LPSTR)buffer, 255);
|
||||||
@ -375,7 +374,7 @@ namespace Components
|
|||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam) {
|
BOOL CALLBACK ConnectProtocol::EnumProc(HWND hWnd, LPARAM lParam) {
|
||||||
// Retrieve storage location for communication data
|
// Retrieve storage location for communication data
|
||||||
EnumData& ed = *(EnumData*)lParam;
|
EnumData& ed = *(EnumData*)lParam;
|
||||||
DWORD dwProcessId = 0x0;
|
DWORD dwProcessId = 0x0;
|
||||||
@ -395,7 +394,7 @@ namespace Components
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindEditHandle(__in_z LPCTSTR lpcszFileName)
|
void ConnectProtocol::FindEditHandle(__in_z LPCTSTR lpcszFileName)
|
||||||
{
|
{
|
||||||
LPDWORD lpdwProcessIds;
|
LPDWORD lpdwProcessIds;
|
||||||
LPTSTR lpszBaseName;
|
LPTSTR lpszBaseName;
|
||||||
@ -425,7 +424,7 @@ namespace Components
|
|||||||
dwProcessId = lpdwProcessIds[i];
|
dwProcessId = lpdwProcessIds[i];
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
proc_id = dwProcessId;
|
proc_id = dwProcessId;
|
||||||
EnumWindows(enumWindowsProc, NULL);
|
EnumWindows(EnumWindowsProc, NULL);
|
||||||
if (con_in != NULL)
|
if (con_in != NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -445,7 +444,7 @@ namespace Components
|
|||||||
//return dwProcessId;
|
//return dwProcessId;
|
||||||
}
|
}
|
||||||
// Main entry
|
// Main entry
|
||||||
HWND FindWindowFromProcessId(DWORD dwProcessId) {
|
HWND ConnectProtocol::FindWindowFromProcessId(DWORD dwProcessId) {
|
||||||
EnumData ed = { dwProcessId };
|
EnumData ed = { dwProcessId };
|
||||||
if (!EnumWindows(EnumProc, (LPARAM)&ed) &&
|
if (!EnumWindows(EnumProc, (LPARAM)&ed) &&
|
||||||
(GetLastError() == ERROR_SUCCESS)) {
|
(GetLastError() == ERROR_SUCCESS)) {
|
||||||
@ -454,7 +453,7 @@ namespace Components
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// Helper method for convenience
|
// Helper method for convenience
|
||||||
HWND FindWindowFromProcess(HANDLE hProcess) {
|
HWND ConnectProtocol::FindWindowFromProcess(HANDLE hProcess) {
|
||||||
return FindWindowFromProcessId(GetProcessId(hProcess));
|
return FindWindowFromProcessId(GetProcessId(hProcess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,16 @@ namespace Components
|
|||||||
ConnectProtocol();
|
ConnectProtocol();
|
||||||
void EvaluateProtocol();
|
void EvaluateProtocol();
|
||||||
static BOOL InvokeConnect();
|
static BOOL InvokeConnect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool InstallProtocol();
|
static bool InstallProtocol();
|
||||||
|
|
||||||
|
//Additional Functions for InvokeConnect
|
||||||
|
static void FindEditHandle(__in_z LPCTSTR lpcszFileName);
|
||||||
|
static BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam);
|
||||||
|
static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam);
|
||||||
|
static BOOL CALLBACK EnumWindowsProc(__in HWND hWnd, __in LPARAM lParam);
|
||||||
|
static HWND FindWindowFromProcessId(DWORD dwProcessId);
|
||||||
|
static HWND FindWindowFromProcess(HANDLE hProcess);
|
||||||
};
|
};
|
||||||
//Additional Functions for InvokeConnect
|
|
||||||
void FindEditHandle(__in_z LPCTSTR lpcszFileName);
|
|
||||||
BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam);
|
|
||||||
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam);
|
|
||||||
HWND FindWindowFromProcessId(DWORD dwProcessId);
|
|
||||||
HWND FindWindowFromProcess(HANDLE hProcess);
|
|
||||||
}
|
}
|
@ -57,6 +57,7 @@ namespace Components
|
|||||||
std::string rotation = Dvar::Var("sv_mapRotationCurrent").Get<std::string>();
|
std::string rotation = Dvar::Var("sv_mapRotationCurrent").Get<std::string>();
|
||||||
|
|
||||||
// Ignores " for now, too lazy to implement
|
// Ignores " for now, too lazy to implement
|
||||||
|
// TODO: Implement!
|
||||||
auto tokens = Utils::Explode(rotation, ' ');
|
auto tokens = Utils::Explode(rotation, ' ');
|
||||||
|
|
||||||
for (unsigned int i = 0; i < (tokens.size() - 1); i += 2)
|
for (unsigned int i = 0; i < (tokens.size() - 1); i += 2)
|
||||||
|
@ -129,18 +129,6 @@ namespace Components
|
|||||||
{
|
{
|
||||||
// TODO: Register string dvars here
|
// TODO: Register string dvars here
|
||||||
|
|
||||||
// TODO: Support multiple languages here and find a better place for this. :/
|
|
||||||
if (std::string(Game::Win_GetLanguage()) == "german")
|
|
||||||
{
|
|
||||||
Localization::Set("MP_SEARCHING_FOR_PLAYER", "Warte");
|
|
||||||
Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Auf weitere Spieler zum Teamausgleich warten");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Localization::Set("MP_SEARCHING_FOR_PLAYER", "Waiting");
|
|
||||||
Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Waiting for more players to balance teams");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Dvar::Register<const char*>(name, "Unknown Soldier", Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).Get<Game::dvar_t*>();
|
return Dvar::Register<const char*>(name, "Unknown Soldier", Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).Get<Game::dvar_t*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,13 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Utils::Hook(0x629B90, Localization::Get, HOOK_JUMP).Install()->Quick();
|
Utils::Hook(0x629B90, Localization::Get, HOOK_JUMP).Install()->Quick();
|
||||||
|
|
||||||
//Localization::Set("MENU_MULTIPLAYER_CAPS", "^5Fotze");
|
|
||||||
|
|
||||||
Localization::Set("MENU_SEARCHINGFORGAMES_100MS", "");
|
Localization::Set("MENU_SEARCHINGFORGAMES_100MS", "");
|
||||||
|
Localization::Set("MP_SEARCHING_FOR_PLAYER", "Waiting");
|
||||||
|
Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Waiting for more players to balance teams");
|
||||||
|
|
||||||
|
// Don't perform non-english localization here, do it in fastfiles instead
|
||||||
|
//Localization::Set("MP_SEARCHING_FOR_PLAYER", "Warte");
|
||||||
|
//Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Auf weitere Spieler zum Teamausgleich warten");
|
||||||
|
|
||||||
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
|
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> Menus::CustomMenus;
|
||||||
std::vector<Game::menuDef_t*> Menus::MenuList;
|
std::vector<Game::menuDef_t*> Menus::MenuList;
|
||||||
std::vector<Game::MenuList*> Menus::MenuListList;
|
std::vector<Game::MenuList*> Menus::MenuListList;
|
||||||
|
|
||||||
@ -181,12 +182,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Game::PC_ReadTokenHandle(handle, &token);
|
Game::PC_ReadTokenHandle(handle, &token);
|
||||||
|
|
||||||
std::vector<Game::menuDef_t*> newMenus = Menus::LoadMenu(Utils::VA("ui_mp\\%s.menu", token.string));
|
Utils::Merge(menus, Menus::LoadMenu(Utils::VA("ui_mp\\%s.menu", token.string)));
|
||||||
|
|
||||||
for (auto newMenu : newMenus)
|
|
||||||
{
|
|
||||||
menus.push_back(newMenu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_stricmp(token.string, "menudef"))
|
if (!_stricmp(token.string, "menudef"))
|
||||||
@ -244,22 +240,16 @@ namespace Components
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Game::menuDef_t*> newMenus = Menus::LoadMenu(menuList->menus[i]);
|
Utils::Merge(menus, Menus::LoadMenu(menuList->menus[i]));
|
||||||
|
|
||||||
for (auto newMenu : newMenus)
|
|
||||||
{
|
|
||||||
menus.push_back(newMenu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: beautify
|
// Load custom menus
|
||||||
if (!_stricmp(menuList->name, "ui_mp/code.txt"))
|
if (std::string(menuList->name) == "ui_mp/code.txt")
|
||||||
{
|
{
|
||||||
std::vector<Game::menuDef_t*> _menus = Menus::LoadMenu("ui_mp/theater_menu.menu");
|
for (auto menu : Menus::CustomMenus)
|
||||||
std::vector<Game::menuDef_t*> _menus2 = Menus::LoadMenu("ui_mp/pc_options_multi.menu");
|
{
|
||||||
|
Utils::Merge(menus, Menus::LoadMenu(menu));
|
||||||
for (auto newMenu : _menus) { menus.push_back(newMenu); }
|
}
|
||||||
for (auto newMenu : _menus2) { menus.push_back(newMenu); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate new menu list
|
// Allocate new menu list
|
||||||
@ -483,6 +473,11 @@ namespace Components
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menus::Add(std::string menu)
|
||||||
|
{
|
||||||
|
Menus::CustomMenus.push_back(menu);
|
||||||
|
}
|
||||||
|
|
||||||
Menus::Menus()
|
Menus::Menus()
|
||||||
{
|
{
|
||||||
if (Dedicated::IsDedicated()) return;
|
if (Dedicated::IsDedicated()) return;
|
||||||
@ -538,10 +533,15 @@ namespace Components
|
|||||||
Game::Menus_OpenByName(Game::uiContext, "main_text");
|
Game::Menus_OpenByName(Game::uiContext, "main_text");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Define custom menus here
|
||||||
|
Menus::Add("ui_mp/theater_menu.menu");
|
||||||
|
Menus::Add("ui_mp/pc_options_multi.menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
Menus::~Menus()
|
Menus::~Menus()
|
||||||
{
|
{
|
||||||
|
Menus::CustomMenus.clear();
|
||||||
Menus::FreeEverything();
|
Menus::FreeEverything();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,12 @@ namespace Components
|
|||||||
|
|
||||||
static void FreeEverything();
|
static void FreeEverything();
|
||||||
|
|
||||||
|
static void Add(std::string menu);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::vector<Game::menuDef_t*> MenuList;
|
static std::vector<Game::menuDef_t*> MenuList;
|
||||||
static std::vector<Game::MenuList*> MenuListList;
|
static std::vector<Game::MenuList*> MenuListList;
|
||||||
|
static std::vector<std::string> CustomMenus;
|
||||||
|
|
||||||
static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, const char* filename);
|
static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, const char* filename);
|
||||||
static Game::MenuList* LoadMenuList(Game::MenuList* menuList);
|
static Game::MenuList* LoadMenuList(Game::MenuList* menuList);
|
||||||
|
@ -139,15 +139,10 @@ namespace Components
|
|||||||
Network::Handle("getInfo", [] (Network::Address address, std::string data)
|
Network::Handle("getInfo", [] (Network::Address address, std::string data)
|
||||||
{
|
{
|
||||||
int clientCount = 0;
|
int clientCount = 0;
|
||||||
|
int maxclientCount = *Game::svs_numclients;
|
||||||
|
if (!maxclientCount) maxclientCount = Dvar::Var("sv_maxclients").Get<int>();
|
||||||
|
|
||||||
int maxClients = *Game::svs_numclients;
|
for (int i = 0; i < maxclientCount; i++)
|
||||||
|
|
||||||
if (!maxClients)
|
|
||||||
{
|
|
||||||
maxClients = Dvar::Var("sv_maxclients").Get<int>();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < maxClients; i++)
|
|
||||||
{
|
{
|
||||||
if (Game::svs_clients[i].state >= 3)
|
if (Game::svs_clients[i].state >= 3)
|
||||||
{
|
{
|
||||||
@ -155,6 +150,9 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure line break
|
||||||
|
data.append("\n");
|
||||||
|
|
||||||
Utils::InfoString info;
|
Utils::InfoString info;
|
||||||
info.Set("challenge", data.substr(0, data.find_first_of("\n")).data());
|
info.Set("challenge", data.substr(0, data.find_first_of("\n")).data());
|
||||||
info.Set("gamename", "IW4");
|
info.Set("gamename", "IW4");
|
||||||
@ -164,7 +162,7 @@ namespace Components
|
|||||||
info.Set("fs_game", Dvar::Var("fs_game").Get<const char*>());
|
info.Set("fs_game", Dvar::Var("fs_game").Get<const char*>());
|
||||||
info.Set("xuid", Utils::VA("%llX", Steam::SteamUser()->GetSteamID().Bits));
|
info.Set("xuid", Utils::VA("%llX", Steam::SteamUser()->GetSteamID().Bits));
|
||||||
info.Set("clients", Utils::VA("%i", clientCount));
|
info.Set("clients", Utils::VA("%i", clientCount));
|
||||||
info.Set("sv_maxclients", Utils::VA("%i", maxClients));
|
info.Set("sv_maxclients", Utils::VA("%i", maxclientCount));
|
||||||
info.Set("protocol", Utils::VA("%i", PROTOCOL));
|
info.Set("protocol", Utils::VA("%i", PROTOCOL));
|
||||||
info.Set("checksum", Utils::VA("%d", Game::Com_Milliseconds()));
|
info.Set("checksum", Utils::VA("%d", Game::Com_Milliseconds()));
|
||||||
|
|
||||||
|
@ -25,4 +25,12 @@ namespace Utils
|
|||||||
std::map<std::string, std::string> KeyValuePairs;
|
std::map<std::string, std::string> KeyValuePairs;
|
||||||
void Parse(std::string buffer);
|
void Parse(std::string buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T> void Merge(std::vector<T> &target, std::vector<T> &source)
|
||||||
|
{
|
||||||
|
for (auto &entry : source)
|
||||||
|
{
|
||||||
|
target.push_back(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user