private void LoadMap(string mapName) { if (mapName == string.Empty) { return; } current = new Map(Program.main.serverLocation + "/maps/" + mapName + ".json"); currentMetadata = new MapMetadata(Program.main.serverLocation + "/maps/" + mapName + ".metadata.json"); mapSize.Text = current.width + "x" + current.height; mapTilesets.Text = current.tilesets.Length.ToString(); CheckTilesets(); ExtractLayers(); if (currentMetadata.mapType != null && currentMetadata.mapType != string.Empty) { if (currentMetadata.mapType == "protected") { mapType.SelectedItem = "Protected"; } else if (currentMetadata.mapType == "neutral") { mapType.SelectedItem = "Neutral"; } } else { mapType.SelectedItem = string.Empty; } pvp.Checked = currentMetadata.pvp; if (currentMetadata.bgmSource != null) { bgmSource.Text = currentMetadata.bgmSource; } dayNight.Checked = currentMetadata.showDayNight; alwaysDark.Checked = currentMetadata.alwaysDark; }
public MapMetadata(string src) { try { if (!File.Exists(src)) { return; } MapMetadata temp = JsonConvert.DeserializeObject <MapMetadata>(File.ReadAllText(src)); mapType = temp.mapType; bgmSource = temp.bgmSource; showDayNight = temp.showDayNight; alwaysDark = temp.alwaysDark; pvp = temp.pvp; mapLayers = temp.mapLayers; mapDialogs = temp.mapDialogs; } catch (Exception exc) { Logger.Error("Could not construct map metadata instance: ", exc); } }