diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index 15b4e466f..b8c7f8fee 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -1090,9514 +1090,6 @@ namespace Barotrauma })); #endif - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - GameMain.Config.SaveNewPlayerConfig(); - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - }, isCheat: false)); -#endif - - commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.xml"; - var doc = XMLExtensions.TryLoadXml(filePath); - if (doc?.Root == null) return; - List lines = new List(); - foreach (XElement element in doc.Root.Elements()) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - }, isCheat: false)); -#endif - commands.Add(new Command("cleanbuild", "", (string[] args) => { GameMain.Config.MusicVolume = 0.5f; diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index 180dccbc3..6732dcef2 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -656,28 +656,6 @@ namespace Barotrauma msg.Timer -= deltaTime; msg.Pos += msg.Velocity * deltaTime; } - - foreach (GUIMessage msg in messages) - { - if (!msg.WorldSpace) continue; - msg.Timer -= deltaTime; - msg.Pos += msg.Velocity * deltaTime; - } - - foreach (GUIMessage msg in messages) - { - if (!msg.WorldSpace) continue; - msg.Timer -= deltaTime; - msg.Pos += msg.Velocity * deltaTime; - } - - foreach (GUIMessage msg in messages) - { - if (!msg.WorldSpace) continue; - msg.Timer -= deltaTime; - msg.Pos += msg.Velocity * deltaTime; - } - } messages.RemoveAll(m => m.Timer <= 0.0f); } @@ -751,10 +729,6 @@ namespace Barotrauma Vector2 textSize = font.MeasureString(text); DrawRectangle(sb, pos - Vector2.One * backgroundPadding, textSize + Vector2.One * 2.0f * backgroundPadding, (Color)backgroundColor, true); } - else - { - sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth); - sb.Draw(t, new Rectangle(rect.X + thickness, rect.Y + rect.Height - thickness, rect.Width - thickness * 2, thickness), null, clr, 0.0f, Vector2.Zero, SpriteEffects.None, depth); font.DrawString(sb, text, pos, color); } diff --git a/Barotrauma/BarotraumaClient/Source/GUI/VideoPlayer.cs b/Barotrauma/BarotraumaClient/Source/GUI/VideoPlayer.cs index d2ac6b876..45bb4a52b 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/VideoPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/VideoPlayer.cs @@ -74,7 +74,7 @@ namespace Barotrauma videoFrame = new GUIFrame(new RectTransform(new Point(width + borderSize, height + borderSize), background.RectTransform, Anchor.Center, Pivot.Center) { AbsoluteOffset = new Point((int)(-100 / (GUI.Scale * 0.6f)), 0) }, "SonarFrame"); //videoFrame.RectTransform.AbsoluteOffset = new Point(-borderSize, 0); - textFrame = new GUIFrame(new RectTransform(new Point(width + borderSize, height + borderSize * 2), videoFrame.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft), "SonarFrame"); + textFrame = new GUIFrame(new RectTransform(new Point(width + borderSize, height + borderSize * 2), videoFrame.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft), "TextFrame"); textFrame.RectTransform.AbsoluteOffset = new Point(borderSize + videoFrame.Rect.Width, 0); videoView = new GUICustomComponent(new RectTransform(new Point(width, height), videoFrame.RectTransform, Anchor.Center), diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs index f006a8df1..574b97e2e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs @@ -467,11 +467,7 @@ namespace Barotrauma { itemsText.Text += TextManager.Get("None"); } - }; - new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY")) - { - ToolTip = TextManager.Get("MirrorEntityYToolTip"), - OnClicked = (button, data) => + else { for (int i = 0; i < AllowedLinks.Count; i++) { diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs index 62440dcd0..e5a21433b 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs @@ -38,12 +38,6 @@ namespace Barotrauma this.isMultiplayer = isMultiplayer; this.newGameContainer = newGameContainer; this.loadGameContainer = loadGameContainer; - - var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: true) - { - Stretch = true, - RelativeSpacing = 0.05f - }; var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: true) { diff --git a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index f09171b13..326df08c3 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -332,8 +332,7 @@ namespace Barotrauma.Networking } } - //too many events for one packet - if (eventsToSync.Count > 200) + if (client.NeedsMidRoundSync) { msg.Write((byte)ServerNetObject.ENTITY_EVENT_INITIAL); msg.Write(client.UnreceivedEntityEventCount); @@ -341,8 +340,7 @@ namespace Barotrauma.Networking Write(msg, eventsToSync, out sentEvents, client); } - - foreach (NetEntityEvent entityEvent in sentEvents) + else { msg.Write((byte)ServerNetObject.ENTITY_EVENT); Write(msg, eventsToSync, out sentEvents, client); @@ -353,7 +351,6 @@ namespace Barotrauma.Networking (entityEvent as ServerEntityEvent).Sent = true; client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; } - sentEvents = eventsToSync; } /// diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 7a17ce1f2..be6ca7fcb 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -813,7 +813,6 @@ namespace Barotrauma if (closestBody.UserData is Structure wall && wall.Submarine != null) { int sectionIndex = wall.FindSectionIndex(ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition)); - int passableHoleCount = GetMinimumPassableHoleCount(); float sectionDamage = wall.SectionDamage(sectionIndex); for (int i = sectionIndex - 2; i <= sectionIndex + 2; i++) @@ -1011,7 +1010,7 @@ namespace Barotrauma string targetingTag = null; if (targetCharacter != null) { - if (targetCharacter.Submarine != null && Character.Submarine == null) + if (targetCharacter.IsDead) { targetingTag = "dead"; if (targetCharacter.Submarine != Character.Submarine) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index cff0b6a1c..c45253b0b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1894,8 +1894,6 @@ namespace Barotrauma } speechImpedimentSet = false; - - if (needsAir) { bool protectedFromPressure = PressureProtection > 0.0f; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs index aeae1644d..8dcf98fce 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs @@ -804,7 +804,8 @@ namespace Barotrauma var newItem = Item.Load(itemElement, inventory.Owner.Submarine, createNetworkEvent: true); if (newItem == null) { continue; } - if (!MathUtils.NearlyEqual(newItem.Condition, newItem.MaxCondition)) + if (!MathUtils.NearlyEqual(newItem.Condition, newItem.MaxCondition) && + GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer) { GameMain.NetworkMember.CreateEntityEvent(newItem, new object[] { NetEntityEvent.Type.Status }); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs index 233e30f68..3bd5416bb 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerTransfer.cs @@ -180,7 +180,8 @@ namespace Barotrauma.Items.Components #endif //items in a bad condition are more sensitive to overvoltage - float maxOverVoltage = MathHelper.Lerp(Math.Min(OverloadVoltage, 1.0f), OverloadVoltage, item.Condition / item.MaxCondition); + float maxOverVoltage = MathHelper.Lerp(OverloadVoltage * 0.75f, OverloadVoltage, item.Condition / item.MaxCondition); + maxOverVoltage = Math.Max(OverloadVoltage, 1.0f); //if the item can't be fixed, don't allow it to break if (!item.Repairables.Any() || !CanBeOverloaded) continue; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index ad34272f1..11c413b9b 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1286,11 +1286,7 @@ namespace Barotrauma LastSentSignalRecipients.Clear(); if (connections == null) return; - public List GetConnectedComponentsRecursive(Connection c) where T : ItemComponent - { - List connectedComponents = new List(); - List alreadySearched = new List() { this }; - GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents); + stepsTaken++; if (!connections.TryGetValue(connectionName, out Connection c)) return; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs b/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs index 5c2a35a8c..e397d485f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs @@ -129,7 +129,7 @@ namespace Barotrauma availableMissions.RemoveAll(m => m.Completed); } - public void Remove() + private string RandomName(LocationType type) { baseName = type.GetRandomName(); nameFormatIndex = Rand.Int(type.NameFormats.Count, Rand.RandSync.Server);