/// <summary> /// Create required infrastructure for a new world /// </summary> public static void CreateWorld(string path, ServerInfo server) { var dir = new DirectoryInfo(path); string worldName = dir.Name; if (!dir.Exists) { dir.Create(); } // world.xml var worldInfo = WorldConfiguration.LoadFromFile(Path.Combine(WorldTemplateDirectory, WorldXmlTemplateString)); worldInfo.Name = worldName; if (server.TwStatsPrefix.ToLowerInvariant() != System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName) { using (var timeZoneSetter = new TimeZoneForm()) { if (timeZoneSetter.ShowDialog() == DialogResult.OK) { worldInfo.Offset = timeZoneSetter.ServerOffset.TotalSeconds.ToString(CultureInfo.InvariantCulture); } } } TwWorldSettings twWorldSettings = DownloadWorldSettings(worldName, server.ServerUrl); worldInfo.Speed = twWorldSettings.Speed.ToString(CultureInfo.InvariantCulture); worldInfo.UnitSpeed = twWorldSettings.UnitSpeed.ToString(CultureInfo.InvariantCulture); worldInfo.WorldDatScenery = ((int)twWorldSettings.MapScenery).ToString(CultureInfo.InvariantCulture); worldInfo.Church = twWorldSettings.Church ? "1" : "0"; // Fix URIs worldInfo.Server = ReplaceServerAndWorld(worldInfo.Server, worldName, server); worldInfo.DataVillage = ReplaceServerAndWorld(worldInfo.DataVillage, worldName, server); worldInfo.DataPlayer = ReplaceServerAndWorld(worldInfo.DataPlayer, worldName, server); worldInfo.DataTribe = ReplaceServerAndWorld(worldInfo.DataTribe, worldName, server); worldInfo.GameVillage = ReplaceServerAndWorld(worldInfo.GameVillage, worldName, server); worldInfo.GuestPlayer = ReplaceServerAndWorld(worldInfo.GuestPlayer, worldName, server); worldInfo.GuestTribe = ReplaceServerAndWorld(worldInfo.GuestTribe, worldName, server); worldInfo.TWStatsGeneral = ReplaceServerAndWorld(worldInfo.TWStatsGeneral, worldName, server); worldInfo.TWStatsPlayer = ReplaceServerAndWorld(worldInfo.TWStatsPlayer, worldName, server); worldInfo.TWStatsPlayerGraph = ReplaceServerAndWorld(worldInfo.TWStatsPlayerGraph, worldName, server); worldInfo.TWStatsTribe = ReplaceServerAndWorld(worldInfo.TWStatsTribe, worldName, server); worldInfo.TWStatsTribeGraph = ReplaceServerAndWorld(worldInfo.TWStatsTribeGraph, worldName, server); worldInfo.TWStatsVillage = ReplaceServerAndWorld(worldInfo.TWStatsVillage, worldName, server); worldInfo.Units.Clear(); worldInfo.Units.AddRange(GetWorldUnitSettings(worldName, server)); worldInfo.SaveToFile(Path.Combine(path, WorldXmlString)); // default.sets Directory.CreateDirectory(Path.Combine(path, DirectorySettingsString)); var settingsTemplatePath = Path.Combine(WorldTemplateDirectory, DefaultSettingsString); string targetPath = Path.Combine(path, DirectorySettingsString, DefaultSettingsString); File.Copy(settingsTemplatePath, targetPath); }
private void MenuFileSynchronizeTime_Click(object sender, EventArgs e) { if (World.Default.HasLoaded) { using (var timeSetter = new TimeZoneForm()) { timeSetter.ServerOffset = World.Default.Settings.ServerOffset; var result = timeSetter.ShowDialog(); if (result == DialogResult.OK) { World.Default.Settings.ServerOffset = timeSetter.ServerOffset; World.Default.SaveSettings(); } } } }