5d2c9f2...bdbcef4

commit bdbcef41bfbc42beeb2d942e7db431b8ab627f1c
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 13:31:02 2019 +0200

    Simplify the sprite related commands.

commit 49c8e1cd01953ae31cff99bf35432ab887b45d62
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 13:05:20 2019 +0200

    Rename "Reload Texture" button as "Reload Sprite", because it actually reloads both the xml and the texture. Add the button text into the localization file.

commit 84f58d9e0bb46f29412f936d569348e46227c9d5
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 12:50:51 2019 +0200

    Add the option to reload xml/texture/both for items when they are hovered over with the mouse. dry.

commit 732084c044e6a2c220cee8d5c1d9b5e4ce05587d
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 12:48:49 2019 +0200

    Fix the sprite name of the right hand in the assistant job gear.

commit 30344369d7e87a17312cc839f195c36c77c4a3b2
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 12:26:20 2019 +0200

    Fix ReloadXML failing when multiple source elements are found.

commit ddb6fb48b6e0789b18a1ea889dcdf408fcbb5b12
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 11:47:13 2019 +0200

    Fix damagemodifier multiplier not applied on particles if no sound is played.

commit 41206013be41d240b12dad48f4ddaba9b072742b
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Mar 7 11:46:22 2019 +0200

    Fix engigear lower arm sprite name.

commit 8ce938305206ca65aeb00515639e799d9f2fd526
Merge: e6166d2ef 61703e8af
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Wed Mar 6 18:53:36 2019 +0200

    Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev

commit e6166d2ef24489bac6f217211849884013dbf4e6
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Wed Mar 6 18:53:30 2019 +0200

    Implement husk sprite overlays as wearables. Add new husk injector (wip).

commit 367c4f5b3784c65c3c26807dd6c10e837960c6bb
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Wed Mar 6 18:52:15 2019 +0200

    Add console commands for changing the gender and race of the character.

commit 61703e8af274c8f5d9e05575ebaf13c9bde8855f
Author: Iiro Enges <iiro@fakefish.fi>
Date:   Wed Mar 6 17:47:09 2019 +0200

    Refined environment item scales and colors
This commit is contained in:
Joonas Rikkonen
2019-03-18 22:31:14 +02:00
parent e28ec38c40
commit 110d803b78
18 changed files with 563 additions and 181 deletions
@@ -1599,6 +1599,189 @@ namespace Barotrauma
TextManager.WriteToCSV();
NPCConversation.WriteToCSV();
}));
#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<string> lines = new List<string>();
foreach (MapEntityPrefab me in MapEntityPrefab.List)
{
lines.Add("<EntityName." + me.Identifier + ">" + me.Name + "</" + me.Identifier + ".Name>");
lines.Add("<EntityDescription." + me.Identifier + ">" + me.Description + "</" + me.Identifier + ".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("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) =>
{
@@ -2181,87 +2364,18 @@ namespace Barotrauma
character.AnimController.ResetRagdoll();
}, isCheat: true));
commands.Add(new Command("reloadwearables|reloadlimbs", "Reloads the xml(s) where limbs and wearable sprites (clothing) of the controlled character are defined. Also reloads textures. Provide id or name if you want to target another character.", args =>
commands.Add(new Command("reloadwearables|reloadlimbs", "Reloads the sprites of all limbs and wearable sprites (clothing) of the controlled character. Provide id or name if you want to target another character.", args =>
{
var character = (args.Length == 0) ? Character.Controlled : FindMatchingCharacter(args, true);
if (character == null)
{
ThrowError("Not controlling any character!");
ThrowError("Not controlling any character or no matching character found with the provided arguments.");
return;
}
foreach (var limb in character.AnimController.Limbs)
{
limb.Sprite?.ReloadTexture();
limb.DamagedSprite?.ReloadTexture();
limb.DeformSprite?.Sprite.ReloadTexture();
foreach (var wearable in limb.WearingItems)
{
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
foreach (var wearable in limb.OtherWearables)
{
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
}
ReloadWearables(character);
}, isCheat: true));
commands.Add(new Command("reloadxml", "Reloads the xml definition of the selected item(s)/structure(s) (SubEditor). Can also reload sprite xmls by entity id or by the name attribute (sprite element). Example 1: reloadxml id itemid. Example 2: reloadxml name \"Sprite name\"", args =>
{
if (Screen.Selected is SpriteEditorScreen)
{
return;
}
else if (args.Length > 1)
{
TryDoActionOnSprite(args[0], args[1], s => s.ReloadXML());
}
else if (Screen.Selected is SubEditorScreen subScreen)
{
if (!MapEntity.SelectedAny)
{
ThrowError("You have to select item(s)/structure(s) first!");
}
else
{
MapEntity.SelectedList.ForEach(e => e.Sprite?.ReloadXML());
}
}
else
{
ThrowError("Please provide the mode (name or id) and the value so that I can find the sprite for you!");
}
}, isCheat: true));
commands.Add(new Command("reloadtexture|reloadtextures", "In sub editor, reloads the xml definition of the selected item(s)/structure(s). Can also reload sprite xmls by entity id or by the name attribute (sprite element). Example 1: reloadtexture id itemid. Example 2: reloadtexture name \"Sprite name\"", args =>
{
if (Screen.Selected is SpriteEditorScreen)
{
return;
}
else if (args.Length > 1)
{
TryDoActionOnSprite(args[0], args[1], s => s.ReloadTexture());
}
else if (Screen.Selected is SubEditorScreen subScreen)
{
if (!MapEntity.SelectedAny)
{
ThrowError("You have to select item(s)/structure(s) first!");
}
else
{
MapEntity.SelectedList.ForEach(e => e.Sprite?.ReloadTexture());
}
}
else
{
ThrowError("Please provide the mode (name or id) and the value so that I can find the sprite for you!");
}
}, isCheat: true));
commands.Add(new Command("reloadsprite|reloadsprites", "Reload xml and texture of the given sprite(s). In sub editor, reloads the xml definition of the selected item(s)/structure(s). Can also reload sprite xmls by entity id or by the name attribute (sprite element). Example 1: reloadsprite id itemid. Example 2: reloadsprite name \"Sprite name\"", args =>
commands.Add(new Command("reloadsprite|reloadsprites", "Reloads the sprites of the selected item(s)/structure(s) (hovering over or selecting in the subeditor) or the controlled character. Can also reload sprites by entity id or by the name attribute (sprite element). Example 1: reloadsprite id itemid. Example 2: reloadsprite name \"Sprite name\"", args =>
{
if (Screen.Selected is SpriteEditorScreen)
{
@@ -2275,31 +2389,68 @@ namespace Barotrauma
s.ReloadTexture();
});
}
else if (Screen.Selected is SubEditorScreen subScreen)
else if (Screen.Selected is SubEditorScreen)
{
if (!MapEntity.SelectedAny)
{
ThrowError("You have to select item(s)/structure(s) first!");
}
else
MapEntity.SelectedList.ForEach(e =>
{
MapEntity.SelectedList.ForEach(e =>
if (e.Sprite != null)
{
if (e.Sprite != null)
{
e.Sprite.ReloadXML();
e.Sprite.ReloadTexture();
}
});
}
e.Sprite.ReloadXML();
e.Sprite.ReloadTexture();
}
});
}
else
{
ThrowError("Please provide the mode (name or id) and the value so that I can find the sprite for you!");
var character = Character.Controlled;
if (character == null)
{
ThrowError("Please provide the mode (name or id) and the value so that I can find the sprite for you!");
return;
}
var item = character.FocusedItem;
if (item != null)
{
item.Sprite.ReloadXML();
item.Sprite.ReloadTexture();
}
else
{
ReloadWearables(character);
}
}
}, isCheat: true));
}
private static void ReloadWearables(Character character)
{
foreach (var limb in character.AnimController.Limbs)
{
limb.Sprite?.ReloadTexture();
limb.DamagedSprite?.ReloadTexture();
limb.DeformSprite?.Sprite.ReloadTexture();
foreach (var wearable in limb.WearingItems)
{
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
foreach (var wearable in limb.OtherWearables)
{
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
if (limb.HuskSprite != null)
{
limb.HuskSprite.Sprite.ReloadXML();
limb.HuskSprite.Sprite.ReloadTexture();
}
}
}
private static bool TryDoActionOnSprite(string firstArg, string secondArg, Action<Sprite> action)
{
switch (firstArg)