internal static void LoadSingleSchematic() { var schematic = schematicsToLoad.Dequeue(); int id = (int)schematic["id"]; string name = (string)schematic["name"]; int rating = (int)schematic["rating"]; int vote = (int)schematic["vote"]; string tiledata = (string)schematic["tiledata"]; try { Tile[,] tiles = LoadTilesFromBase64(tiledata); if (tiles.GetLength(0) > 0) { var paintToolsSlot = new PaintToolsSlot(GetStampInfo(tiles)); paintToolsSlot.browserID = id; paintToolsSlot.browserName = name; paintToolsSlot.rating = rating; paintToolsSlot.vote = vote; CheatSheet.instance.paintToolsUI.view.AddEndDontSelect(paintToolsSlot); } } catch { } CheatSheet.instance.numberOnlineToLoad--; if (schematicsToLoad.Count == 0) { schematicsToLoad = null; } }
internal static void GetSchematicsComplete(object sender, UploadValuesCompletedEventArgs e) { if (!e.Cancelled) { string response = Encoding.UTF8.GetString(e.Result); JObject jsonObject = new JObject(); try { jsonObject = JObject.Parse(response); } catch (Exception ex) { Main.NewText("Bad JSON: " + response); } string message = (string)jsonObject["message"]; if (message != null) { Main.NewText(message); } JArray schematicslist = (JArray)jsonObject["schematics"]; if (schematicslist != null) { List <PaintToolsSlot> list = new List <PaintToolsSlot>(); foreach (JObject schematic in schematicslist.Children <JObject>()) { int id = (int)schematic["id"]; string name = (string)schematic["name"]; int rating = (int)schematic["rating"]; int vote = (int)schematic["vote"]; string tiledata = (string)schematic["tiledata"]; try { Tile[,] tiles = LoadTilesFromBase64(tiledata); if (tiles.GetLength(0) > 0) { var paintToolsSlot = new PaintToolsSlot(GetStampInfo(tiles)); paintToolsSlot.browserID = id; paintToolsSlot.browserName = name; paintToolsSlot.rating = rating; paintToolsSlot.vote = vote; list.Add(paintToolsSlot); } } catch { } } if (list.Count > 0) { CheatSheet.instance.paintToolsUI.view.Add(list.ToArray()); } } } else { Main.NewText("Schematics Server problem 2"); } waiting = false; }