public void LoadFromLevel(string level, int datas) { //errors = false; //EEditor.Properties.Settings.Default.LevelPass = levelPassTextBox.Text; try { if (MainForm.accs[MainForm.selectedAcc].loginMethod == 0 && MainForm.accs.ContainsKey(MainForm.selectedAcc)) { client = PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null); } else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 1 && MainForm.accs.ContainsKey(MainForm.selectedAcc)) { client = PlayerIO.QuickConnect.FacebookOAuthConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, null, null); } else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 2 && MainForm.accs.ContainsKey(MainForm.selectedAcc)) { client = PlayerIO.QuickConnect.KongregateConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null); } else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 3 && MainForm.accs.ContainsKey(MainForm.selectedAcc)) { client = PlayerIO.Authenticate(bdata.gameID, "secure", new Dictionary <string, string> { { "userId", MainForm.accs[MainForm.selectedAcc].login }, { "authToken", MainForm.accs[MainForm.selectedAcc].password } }, null); } else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 4 && MainForm.accs.ContainsKey(MainForm.selectedAcc)) { PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null, delegate(Client cli) { cli.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>() { { "type", "Link" } }, delegate(Connection con1) { con1.OnMessage += delegate(object sender1, PlayerIOClient.Message m) { if (m.Type == "auth") { client = PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "linked", new Dictionary <string, string>() { { "userId", m.GetString(0) }, { "auth", m.GetString(1) } }, null); s1.Release(); } }; }, delegate(PlayerIOError error) { MessageBox.Show(error.Message, "Error"); }); }, delegate(PlayerIOError error) { MessageBox.Show(error.Message, "Error"); }); s1.WaitOne(); } if (datas == 0) { if (MainForm.userdata.level.StartsWith("OW")) { client.Multiplayer.ListRooms("Everybodyedits" + client.BigDB.Load("config", "config")["version"], null, 0, 0, delegate(RoomInfo[] rinfo) { foreach (var val in rinfo) { if (val.Id.StartsWith("OW")) { if (val.Id.StartsWith(MainForm.userdata.level.Substring(0, 4))) { MainForm.userdata.level = val.Id; Connection = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null); Connection.OnMessage += OnMessage; Connection.Send("init"); NeedsInit = false; break; } } } }, delegate(PlayerIOError error) { Console.WriteLine(error.Message); }); s.WaitOne(); } else { if (client != null) { Connection = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null); Connection.OnMessage += OnMessage; Connection.Send("init"); NeedsInit = false; s.WaitOne(); } else { MessageBox.Show("Client is null"); } } } else if (datas == 1) { int w = 0; int h = 0; DatabaseObject dbo = client.BigDB.Load("Worlds", MainForm.userdata.level); if (dbo != null) { var name = dbo.Contains("name") ? dbo["name"].ToString() : "Untitled World"; owner = dbo.Contains("owner") ? dbo["owner"].ToString() : null; if (dbo.Contains("width") && dbo.Contains("height") && dbo.Contains("worlddata")) { uid2name(owner, name, Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"])); MapFrame = new Frame(Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"])); } else { if (dbo.Contains("type")) { switch ((int)dbo["type"]) { case 1: w = 50; h = 50; break; case 2: w = 100; h = 100; break; default: case 3: w = 200; h = 200; break; case 4: w = 400; h = 50; break; case 5: w = 400; h = 200; break; case 6: w = 100; h = 400; break; case 7: w = 636; h = 50; break; case 8: w = 110; h = 110; break; case 11: w = 300; h = 300; break; case 12: w = 250; h = 150; break; case 13: w = 150; h = 150; break; } if (dbo.Contains("worlddata")) { MapFrame = new Frame(w, h); uid2name(owner, name, w, h); } } else { uid2name(owner, name, 200, 200); MapFrame = new Frame(200, 200); } } if (dbo.Contains("worlddata")) { MapFrame = Frame.FromMessage2(dbo); SizeWidth = MapFrame.Width; SizeHeight = MapFrame.Height; NeedsInit = false; DialogResult = System.Windows.Forms.DialogResult.OK; } else { notsaved = true; DialogResult = System.Windows.Forms.DialogResult.Cancel; } Close(); } } else if (datas == 2) { int w = 0; int h = 0; DatabaseObject dbo = client.BigDB.Load("Worlds", MainForm.userdata.level); if (dbo != null) { var name = dbo.Contains("name") ? dbo["name"].ToString() : "Untitled World"; owner = dbo.Contains("owner") ? dbo["owner"].ToString() : null; if (dbo.Contains("width") && dbo.Contains("height") && dbo.Contains("worlddata")) { uid2name(owner, name, Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"])); MapFrame = new Frame(Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"])); } else { if (dbo.Contains("type")) { switch ((int)dbo["type"]) { case 1: w = 50; h = 50; break; case 2: w = 100; h = 100; break; default: case 3: w = 200; h = 200; break; case 4: w = 400; h = 50; break; case 5: w = 400; h = 200; break; case 6: w = 100; h = 400; break; case 7: w = 636; h = 50; break; case 8: w = 110; h = 110; break; case 11: w = 300; h = 300; break; case 12: w = 250; h = 150; break; case 13: w = 150; h = 150; break; } MapFrame = new Frame(w, h); uid2name(owner, name, w, h); } else { uid2name(owner, name, 200, 200); MapFrame = new Frame(200, 200); } } MapFrame.Reset(false); SizeWidth = MapFrame.Width; SizeHeight = MapFrame.Height; NeedsInit = false; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } } } catch (PlayerIOError error) { MessageBox.Show("An error occurred:" + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }