public override void Render(float dt) { if (game.reconnect) { game.Dispose(); menu.StartGame(singleplayer, singleplayerSavePath, connectData); return; } if (game.exitToMainMenu) { game.Dispose(); if (game.GetRedirect() != null) { //Query new server for public key QueryClient qclient = new QueryClient(); qclient.SetPlatform(platform); qclient.PerformQuery(game.GetRedirect().GetIP(), game.GetRedirect().GetPort()); if (qclient.queryPerformed && !qclient.querySuccess) { //Query did not succeed. Back to main menu platform.MessageBoxShowError(qclient.GetServerMessage(), "Redirection error"); menu.StartMainMenu(); return; } QueryResult qresult = qclient.GetResult(); //Get auth hash for new server LoginClientCi lic = new LoginClientCi(); LoginData lidata = new LoginData(); string token = platform.StringSplit(qresult.PublicHash, "=", new IntRef())[1]; lic.Login(platform, connectData.Username, "", token, platform.GetPreferences().GetString("Password", ""), new LoginResultRef(), lidata); while (lic.loginResult.value == LoginResult.Connecting) { lic.Update(platform); } //Check if login was successful if (!lidata.ServerCorrect) { //Invalid server adress platform.MessageBoxShowError("Invalid server address!", "Redirection error!"); menu.StartMainMenu(); } else if (!lidata.PasswordCorrect) { //Authentication failed menu.StartLogin(token, null, 0); } else if (lidata.ServerAddress != null && lidata.ServerAddress != "") { //Finally switch to the new server menu.ConnectToGame(lidata, connectData.Username); } } else { menu.StartMainMenu(); } return; } game.OnRenderFrame(dt); }
public MainMenu() { one = 1; textures = new DictionaryStringInt1024(); textTextures = new TextTexture[256]; textTexturesCount = 0; screen = new ScreenMain(); screen.menu = this; loginClient = new LoginClientCi(); assets = new AssetList(); assetsLoadProgress = new FloatRef(); }
public override void Render(float dt) { if (game.reconnect) { game.Dispose(); menu.StartGame(singleplayer, singleplayerSavePath, connectData); return; } if (game.exitToMainMenu) { game.Dispose(); if (game.GetRedirect() != null) { //Query new server for public key QueryClient qclient = new QueryClient(); qclient.SetPlatform(platform); qclient.PerformQuery(game.GetRedirect().GetIP(), game.GetRedirect().GetPort()); QueryResult qresult = qclient.GetResult(); if (qresult == null) { //If query fails show error message and go back to main menu platform.MessageBoxShowError(qclient.GetServerMessage(), "Redirection error"); menu.StartMainMenu(); return; } //Get auth hash for new server LoginClientCi lic = new LoginClientCi(); LoginData lidata = new LoginData(); string token = platform.StringSplit(qresult.PublicHash, "=", new IntRef())[1]; lic.Login(platform, connectData.Username, "", token, platform.GetPreferences().GetString("Password", ""), new LoginResultRef(), lidata); while (lic.loginResult.value == LoginResult.Connecting) { lic.Update(platform); } //Check if login was successful if (!lidata.ServerCorrect) { //Invalid server adress platform.MessageBoxShowError("Invalid server address!", "Redirection error!"); menu.StartMainMenu(); } else if (!lidata.PasswordCorrect) { //Authentication failed menu.StartLogin(token, null, 0); } else if (lidata.ServerAddress != null && lidata.ServerAddress != "") { //Finally switch to the new server menu.ConnectToGame(lidata, connectData.Username); } } else { menu.StartMainMenu(); } return; } game.OnRenderFrame(dt); }