diff --git a/BrawlCrate/BrawlAPI/BrawlAPI.cs b/BrawlCrate/BrawlAPI/BrawlAPI.cs index 4d1cf4cdd..89b110645 100644 --- a/BrawlCrate/BrawlAPI/BrawlAPI.cs +++ b/BrawlCrate/BrawlAPI/BrawlAPI.cs @@ -90,10 +90,10 @@ static BrawlAPI() /// internal static readonly string[] DepreciatedStrings = new[] { - "BrawlBox", // BrawlBox namespace is "BrawlCrate" in this program - "bboxapi", // API system is now named "BrawlAPI" - "PluginLoader", // Renamed to better reflect what it does (loaders do not have to be parsers) - "AddLoader" // Renamed to better reflect what it does (loaders do not have to be parsers) + "BrawlBox", // BrawlBox namespace is "BrawlCrate" in this program + "bboxapi", // API system is now named "BrawlAPI" + "PluginLoader", // Renamed to better reflect what it does (loaders do not have to be parsers) + "AddLoader" // Renamed to better reflect what it does (loaders do not have to be parsers) }; /// @@ -288,7 +288,8 @@ public static void PythonInstall(bool manual = false, bool force = false) { // Search the new installation path for Python foreach (DirectoryInfo d in Directory - .CreateDirectory(Environment.SpecialFolder.ApplicationData.ToString()).GetDirectories().Reverse()) + .CreateDirectory(Environment.SpecialFolder.ApplicationData.ToString()) + .GetDirectories().Reverse()) { if (d.FullName.StartsWith( $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\Python") && @@ -440,7 +441,8 @@ private static void ResourceTree_SelectionChanged(object sender, EventArgs e) { TreeViewMS resourceTree = (TreeViewMS) sender; Type type = resourceTree.SelectedType; - if (resourceTree.SelectedNodes.Count > 1 && type != null && type.GetInterfaces().Contains(typeof(MultiSelectableWrapper))) + if (resourceTree.SelectedNodes.Count > 1 && type != null && + type.GetInterfaces().Contains(typeof(MultiSelectableWrapper))) { // Get the correct multi-select context menu ContextMenuStrip menu = type == typeof(GenericWrapper) @@ -455,7 +457,8 @@ private static void ResourceTree_SelectionChanged(object sender, EventArgs e) menu.Items.RemoveAt(menu.Items.Count - 1); } - if (menu != null && MultiSelectContextMenuHooks.ContainsKey(type) && MultiSelectContextMenuHooks[type].Length > 0) + if (menu != null && MultiSelectContextMenuHooks.ContainsKey(type) && + MultiSelectContextMenuHooks[type].Length > 0) { foreach (ToolStripMenuItem item in MultiSelectContextMenuHooks[type]) { @@ -511,7 +514,8 @@ private static void ResourceTree_SelectionChanged(object sender, EventArgs e) { // Remove plugins list as necessary while (wrapper.ContextMenuStrip != null && wrapper.ContextMenuStrip.Items.Count > 0 && - (wrapper.ContextMenuStrip.Items[wrapper.ContextMenuStrip.Items.Count - 1].Text.Equals("Plugins") || + (wrapper.ContextMenuStrip.Items[wrapper.ContextMenuStrip.Items.Count - 1].Text + .Equals("Plugins") || wrapper.ContextMenuStrip.Items[wrapper.ContextMenuStrip.Items.Count - 1] is ToolStripSeparator)) { wrapper.ContextMenuStrip.Items.RemoveAt(wrapper.ContextMenuStrip.Items.Count - 1); @@ -563,7 +567,8 @@ private static void ResourceTree_SelectionChanged(object sender, EventArgs e) } if (wrapper.ContextMenuStrip.Items.Count == 0 || - !wrapper.ContextMenuStrip.Items[wrapper.ContextMenuStrip.Items.Count - 1].Text.Equals("Plugins")) + !wrapper.ContextMenuStrip.Items[wrapper.ContextMenuStrip.Items.Count - 1].Text + .Equals("Plugins")) { if (wrapper.ContextMenuStrip.Items.Count != 0) { diff --git a/BrawlCrate/BrawlAPI/ExposedMembers.cs b/BrawlCrate/BrawlAPI/ExposedMembers.cs index 9af148a3f..4e7c2784a 100644 --- a/BrawlCrate/BrawlAPI/ExposedMembers.cs +++ b/BrawlCrate/BrawlAPI/ExposedMembers.cs @@ -732,7 +732,7 @@ public static void AddMultiSelectContextMenuItem(Type wrapper, params ToolStripM /// These should be defined as much as possible in the script itself. /// public static void AddMultiSelectContextMenuItem(Type wrapper, string subMenuName, string description, - EventHandler conditional, params ToolStripMenuItem[] items) + EventHandler conditional, params ToolStripMenuItem[] items) { if (conditional != null) { diff --git a/BrawlCrate/BrawlManagers/CostumeManager/PortraitMap.cs b/BrawlCrate/BrawlManagers/CostumeManager/PortraitMap.cs index da6354831..4a40eaba4 100644 --- a/BrawlCrate/BrawlManagers/CostumeManager/PortraitMap.cs +++ b/BrawlCrate/BrawlManagers/CostumeManager/PortraitMap.cs @@ -338,8 +338,8 @@ public int CharBustTexFor(string name) public IEnumerable GetKnownFighterNames() { return (from f in KnownFighters select f.Name) - .Concat(from f in additionalFighters select f.Name) - .Distinct(); + .Concat(from f in additionalFighters select f.Name) + .Distinct(); } public virtual bool ContainsMapping(int index) @@ -358,7 +358,8 @@ public int[] GetPortraitMappings(int charBustTexIndex) private int GetCharBustTexIndex(string name) { IEnumerable q = additionalFighters.Concat(KnownFighters) - .Where(f => string.Equals(f.Name, name, StringComparison.InvariantCultureIgnoreCase)); + .Where(f => string.Equals(f.Name, name, + StringComparison.InvariantCultureIgnoreCase)); if (!q.Any()) { throw new Exception("No known fighter found with name " + name + "."); diff --git a/BrawlCrate/BrawlManagers/SongManager/CustomSongVolumeEditor.cs b/BrawlCrate/BrawlManagers/SongManager/CustomSongVolumeEditor.cs index be450ccec..6d4bdf4df 100644 --- a/BrawlCrate/BrawlManagers/SongManager/CustomSongVolumeEditor.cs +++ b/BrawlCrate/BrawlManagers/SongManager/CustomSongVolumeEditor.cs @@ -13,7 +13,7 @@ public partial class CustomSongVolumeEditor : UserControl { private static Image SPEAKER = new Bitmap(Assembly.GetExecutingAssembly() - .GetManifestResourceStream("BrawlCrate.BrawlManagers.SongManager.speaker.png")); + .GetManifestResourceStream("BrawlCrate.BrawlManagers.SongManager.speaker.png")); public bool ChangeMadeSinceCSVLoaded { get; private set; } diff --git a/BrawlCrate/BrawlManagers/StageManager/IconsToMenumain.cs b/BrawlCrate/BrawlManagers/StageManager/IconsToMenumain.cs index 334f7b259..553664b35 100644 --- a/BrawlCrate/BrawlManagers/StageManager/IconsToMenumain.cs +++ b/BrawlCrate/BrawlManagers/StageManager/IconsToMenumain.cs @@ -46,7 +46,7 @@ public static void Copy(ResourceNode scSelmap, ResourceNode muMenumain, CustomSS else { Stream stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream("BrawlCrate.StageManager.XX.png"); + .GetManifestResourceStream("BrawlCrate.StageManager.XX.png"); if (stream != null) { Image.FromStream(stream).Save(xx_png); diff --git a/BrawlCrate/BrawlManagers/StageManager/ImagePreviewPanel.cs b/BrawlCrate/BrawlManagers/StageManager/ImagePreviewPanel.cs index 66708f93e..9a25665f2 100644 --- a/BrawlCrate/BrawlManagers/StageManager/ImagePreviewPanel.cs +++ b/BrawlCrate/BrawlManagers/StageManager/ImagePreviewPanel.cs @@ -163,7 +163,7 @@ private static Bitmap replaceBorder(Bitmap icon) else { Stream stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream("BrawlCrate.StageManager.border.png"); + .GetManifestResourceStream("BrawlCrate.StageManager.border.png"); if (stream == null) { MessageBox.Show( diff --git a/BrawlCrate/BrawlManagers/StageManager/PortraitViewer.cs b/BrawlCrate/BrawlManagers/StageManager/PortraitViewer.cs index 33a585a2a..2aac68aee 100644 --- a/BrawlCrate/BrawlManagers/StageManager/PortraitViewer.cs +++ b/BrawlCrate/BrawlManagers/StageManager/PortraitViewer.cs @@ -1375,7 +1375,8 @@ private void lblPMAlt_DragDrop(object sender, DragEventArgs e) if (overlayFile != null) { Stream stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream("BrawlCrate.StageManager." + overlayFile); + .GetManifestResourceStream( + "BrawlCrate.StageManager." + overlayFile); if (stream != null) { Image overlayImage = Image.FromStream(stream) as Bitmap; diff --git a/BrawlCrate/ColorSmash/ColorSmash.cs b/BrawlCrate/ColorSmash/ColorSmash.cs index 4641ab7ca..55de5f7ad 100644 --- a/BrawlCrate/ColorSmash/ColorSmash.cs +++ b/BrawlCrate/ColorSmash/ColorSmash.cs @@ -27,7 +27,7 @@ public static void ColorSmashTex0(object sender, EventArgs e) { if (n is TEX0Wrapper tw) { - TEX0Node t = (TEX0Node)tw.Resource; + TEX0Node t = (TEX0Node) tw.Resource; if (paletteCount < 256) { if (!t.HasPalette || t.GetPaletteNode() == null) @@ -37,11 +37,10 @@ public static void ColorSmashTex0(object sender, EventArgs e) else if (t.HasPalette && t.GetPaletteNode() != null && t.GetPaletteNode().Palette.Entries.Length > paletteCount) { - paletteCount = (short)Math.Min(t.GetPaletteNode().Palette.Entries.Length, 256); + paletteCount = (short) Math.Min(t.GetPaletteNode().Palette.Entries.Length, 256); } } } - } if (paletteCount == 0) @@ -63,7 +62,7 @@ public static void ColorSmashTex0() ColorSmashTex0(null); } - public static void ColorSmashTex0(int? paletteCount) + public static void ColorSmashTex0(int? paletteCount) { // If this was selected via keycode when it's invalid, return without error if (!CanRunColorSmash || MainForm.Instance.resourceTree.SelectedNodes.Count <= 1) @@ -127,6 +126,7 @@ public static void ColorSmashTex0(int? paletteCount) { paletteCount = 0; } + foreach (TreeNode n in MainForm.Instance.resourceTree.SelectedNodes) { // If this was selected via keycode when it's invalid, return without error diff --git a/BrawlCrate/Discord/DiscordSettings.cs b/BrawlCrate/Discord/DiscordSettings.cs index 0c2968054..289bcedc3 100644 --- a/BrawlCrate/Discord/DiscordSettings.cs +++ b/BrawlCrate/Discord/DiscordSettings.cs @@ -183,7 +183,7 @@ public static void Update() DiscordController.presence.details = WorkString + " UI"; } else if (Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\')) - .EndsWith("\\stage\\adventure")) + .EndsWith("\\stage\\adventure")) { DiscordController.presence.details = WorkString + " a subspace stage"; } @@ -201,7 +201,7 @@ public static void Update() } else if (rootName.StartsWith("home_", StringComparison.OrdinalIgnoreCase) && Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\')) - .EndsWith("\\system\\homebutton")) + .EndsWith("\\system\\homebutton")) { DiscordController.presence.details = WorkString + " the home menu"; } @@ -212,7 +212,7 @@ public static void Update() else if ((MainForm.Instance.RootNode.Name.StartsWith("Itm") || Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\')).EndsWith("\\item") || Program.RootPath.Substring(0, Program.RootPath.LastIndexOf('\\')) - .Substring(0, Program.RootPath.LastIndexOf('\\')).EndsWith("\\item")) + .Substring(0, Program.RootPath.LastIndexOf('\\')).EndsWith("\\item")) && (rootName.EndsWith("Brres") || rootName.EndsWith("Param"))) { DiscordController.presence.details = WorkString + " an item"; @@ -252,7 +252,8 @@ public static void Update() DiscordController.presence.state = string.IsNullOrEmpty(Program.RootPath) ? "" : Program.RootPath.Substring(Program.RootPath.LastIndexOf('\\') + 1, - Program.RootPath.LastIndexOf('\\') - Program.RootPath.LastIndexOf('.')); + Program.RootPath.LastIndexOf('\\') - + Program.RootPath.LastIndexOf('.')); } else { diff --git a/BrawlCrate/NodeWrappers/BaseWrapper.cs b/BrawlCrate/NodeWrappers/BaseWrapper.cs index aeeb94b50..228e2be42 100644 --- a/BrawlCrate/NodeWrappers/BaseWrapper.cs +++ b/BrawlCrate/NodeWrappers/BaseWrapper.cs @@ -133,7 +133,8 @@ public void Link(ResourceNode res) } } - SelectedImageIndex = ImageIndex = Icons.getImageIndex(res.ResourceFileType);//((int)res.ResourceFileType & 0xFF); + SelectedImageIndex = + ImageIndex = Icons.getImageIndex(res.ResourceFileType); //((int)res.ResourceFileType & 0xFF); res.SelectChild += OnSelectChild; res.ChildAdded += OnChildAdded; diff --git a/BrawlCrate/NodeWrappers/BrawlEx/CSSCWrapper.cs b/BrawlCrate/NodeWrappers/BrawlEx/CSSCWrapper.cs index ca2e0fa1b..1a22d2ded 100644 --- a/BrawlCrate/NodeWrappers/BrawlEx/CSSCWrapper.cs +++ b/BrawlCrate/NodeWrappers/BrawlEx/CSSCWrapper.cs @@ -108,8 +108,10 @@ public void NewEntry() node._name = "Fit" + BrawlLib.BrawlCrate.FighterNameGenerators.InternalNameFromID( - ((CSSCNode) _resource)._cosmeticSlot, BrawlLib.BrawlCrate.FighterNameGenerators.cosmeticIDIndex, - "+S") + node._costumeID.ToString("00") + (BrawlExColorID.Colors.Length > node._colorID + ((CSSCNode) _resource)._cosmeticSlot, + BrawlLib.BrawlCrate.FighterNameGenerators.cosmeticIDIndex, + "+S") + node._costumeID.ToString("00") + + (BrawlExColorID.Colors.Length > node._colorID ? " - " + BrawlExColorID.Colors[node._colorID].Name : ""); _resource.AddChild(node); diff --git a/BrawlCrate/NodeWrappers/CollisionObjectWrapper.cs b/BrawlCrate/NodeWrappers/CollisionObjectWrapper.cs index 84ea73aca..755f91c9e 100644 --- a/BrawlCrate/NodeWrappers/CollisionObjectWrapper.cs +++ b/BrawlCrate/NodeWrappers/CollisionObjectWrapper.cs @@ -19,14 +19,17 @@ public override void Duplicate() { return; } + string tempPath = Path.GetTempFileName(); _resource.Export(tempPath + ".coll"); - CollisionNode cNode = NodeFactory.FromFile(null, tempPath + ".coll", typeof(CollisionNode)) as CollisionNode; + CollisionNode cNode = + NodeFactory.FromFile(null, tempPath + ".coll", typeof(CollisionNode)) as CollisionNode; if (cNode == null) { MessageBox.Show("The node could not be duplicated correctly."); return; } + int n = 0; int index = _resource.Index; // Copy the name directly in cases where name isn't saved @@ -39,6 +42,7 @@ public override void Duplicate() // Set the name based on the number of duplicate nodes found cNode.Children[0].Name = $"{_resource.Name} ({++n})"; } + // Place the node in the same containing parent, after the last duplicated node. _resource.Parent.InsertChild(cNode.Children[0], true, index + 1); } diff --git a/BrawlCrate/NodeWrappers/FolderWrapper.cs b/BrawlCrate/NodeWrappers/FolderWrapper.cs index 32b66b107..c8d9a4384 100644 --- a/BrawlCrate/NodeWrappers/FolderWrapper.cs +++ b/BrawlCrate/NodeWrappers/FolderWrapper.cs @@ -45,7 +45,7 @@ public FolderWrapper() { ContextMenuStrip = _menu; } - + public override void Delete() { if (Parent == null || Form.ActiveForm != MainForm.Instance) @@ -64,4 +64,4 @@ public override void Delete() Directory.Delete(dir, true); } } -} +} \ No newline at end of file diff --git a/BrawlCrate/NodeWrappers/GenericWrapper.cs b/BrawlCrate/NodeWrappers/GenericWrapper.cs index b789e9ac6..c7224183e 100644 --- a/BrawlCrate/NodeWrappers/GenericWrapper.cs +++ b/BrawlCrate/NodeWrappers/GenericWrapper.cs @@ -228,6 +228,7 @@ public virtual void ExportSelected() { return; } + Dictionary extensions = new Dictionary(); List nodes = new List(); foreach (TreeNode tNode in MainForm.Instance.resourceTree.SelectedNodes) @@ -253,7 +254,8 @@ public virtual void ExportSelected() } } - string invalidChars = System.Text.RegularExpressions.Regex.Escape(new string(Path.GetInvalidFileNameChars())); + string invalidChars = + System.Text.RegularExpressions.Regex.Escape(new string(Path.GetInvalidFileNameChars())); string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars); foreach (ResourceNode n in nodes) { @@ -263,7 +265,8 @@ public virtual void ExportSelected() ext = ext.Insert(0, "."); } - n.Export($"{folder}\\{System.Text.RegularExpressions.Regex.Replace($"{n.Name}{ext ?? ""}", invalidRegStr, "")}"); + n.Export( + $"{folder}\\{System.Text.RegularExpressions.Regex.Replace($"{n.Name}{ext ?? ""}", invalidRegStr, "")}"); } MessageBox.Show($"{nodes.Count} nodes successfully exported to {folder}", "Export Selected"); @@ -341,6 +344,7 @@ public virtual void Duplicate() { return; } + string tempPath = Path.GetTempFileName(); _resource.Export(tempPath); ResourceNode rNode2 = NodeFactory.FromFile(null, tempPath, _resource.GetType()); @@ -349,6 +353,7 @@ public virtual void Duplicate() MessageBox.Show("The node could not be duplicated correctly."); return; } + int n = 0; int index = _resource.Index; // Copy ARCEntryNode data, which is contained in the containing ARC, not the node itself @@ -356,9 +361,10 @@ public virtual void Duplicate() { ((ARCEntryNode) rNode2).FileIndex = ((ARCEntryNode) _resource).FileIndex; ((ARCEntryNode) rNode2).FileType = ((ARCEntryNode) _resource).FileType; - ((ARCEntryNode)rNode2).GroupID = ((ARCEntryNode)_resource).GroupID; - ((ARCEntryNode)rNode2).RedirectIndex = ((ARCEntryNode)_resource).RedirectIndex; + ((ARCEntryNode) rNode2).GroupID = ((ARCEntryNode) _resource).GroupID; + ((ARCEntryNode) rNode2).RedirectIndex = ((ARCEntryNode) _resource).RedirectIndex; } + // Copy the name directly in cases where name isn't saved rNode2.Name = _resource.Name; // Set the name programatically (based on Windows' implementation) @@ -369,6 +375,7 @@ public virtual void Duplicate() // Set the name based on the number of duplicate nodes found rNode2.Name = $"{_resource.Name} ({++n})"; } + // Place the node in the same containing parent, after the last duplicated node. _resource.Parent.InsertChild(rNode2, true, index + 1); } diff --git a/BrawlCrate/NodeWrappers/MDL0/MDL0MaterialWrapper.cs b/BrawlCrate/NodeWrappers/MDL0/MDL0MaterialWrapper.cs index 71d7ba270..2c92a103a 100644 --- a/BrawlCrate/NodeWrappers/MDL0/MDL0MaterialWrapper.cs +++ b/BrawlCrate/NodeWrappers/MDL0/MDL0MaterialWrapper.cs @@ -126,7 +126,7 @@ private void ExportShader() string[] t = ShaderGenerator.GenTEVFragShader(); System.IO.File.WriteAllText(s.FileName, ShaderGenerator.CombineFragShader(m, t, mat.ActiveShaderStages) - .Replace("\n", Environment.NewLine)); + .Replace("\n", Environment.NewLine)); } ShaderGenerator.ClearTarget(); diff --git a/BrawlCrate/NodeWrappers/MDefWrapper.cs b/BrawlCrate/NodeWrappers/MDefWrapper.cs index f234eac40..1198966be 100644 --- a/BrawlCrate/NodeWrappers/MDefWrapper.cs +++ b/BrawlCrate/NodeWrappers/MDefWrapper.cs @@ -805,7 +805,8 @@ public void EditDictionaryDescription() new ActionEventInfo() { Params = new string[_resource.Children.Count], - pDescs = new string[_resource.Children.Count], _description = temp.Name, idNumber = ev + pDescs = new string[_resource.Children.Count], _description = temp.Name, + idNumber = ev }); } @@ -848,7 +849,8 @@ public void EditDictionarySyntax() new ActionEventInfo() { Params = new string[_resource.Children.Count], - pDescs = new string[_resource.Children.Count], _syntax = temp.Name, idNumber = ev + pDescs = new string[_resource.Children.Count], _syntax = temp.Name, + idNumber = ev }); } @@ -1122,9 +1124,13 @@ public void NewActionGroup() node.AddChild(new MoveDefActionNode("Entry", true, _resource)); node.AddChild(new MoveDefActionNode("Exit", true, _resource)); (_resource as MoveDefEntryNode).Root.data.actionFlags.AddChild(new MoveDefActionFlagsEntryNode() - {Name = "Action" + ((_resource as MoveDefEntryNode).Root.data.actionFlags.Children.Count + 274)}); + { + Name = "Action" + ((_resource as MoveDefEntryNode).Root.data.actionFlags.Children.Count + 274) + }); (_resource as MoveDefEntryNode).Root.data.actionPre.AddChild(new MoveDefActionPreEntryNode() - {Name = "Action" + (_resource as MoveDefEntryNode).Root.data.actionPre.Children.Count}); + { + Name = "Action" + (_resource as MoveDefEntryNode).Root.data.actionPre.Children.Count + }); } _resource.AddChild(node); diff --git a/BrawlCrate/Program.cs b/BrawlCrate/Program.cs index 2d880f302..e26489d88 100644 --- a/BrawlCrate/Program.cs +++ b/BrawlCrate/Program.cs @@ -81,7 +81,8 @@ static Program() AssemblyTitleShort = AssemblyTitleFull.Substring(0, AssemblyTitleFull.IndexOf('#') + 8); #else AssemblyTitleFull = ((AssemblyTitleAttribute) Assembly.GetExecutingAssembly() - .GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]).Title; + .GetCustomAttributes(typeof(AssemblyTitleAttribute), + false)[0]).Title; if (BrawlLib.BrawlCrate.PerSessionSettings.Birthday) { AssemblyTitleFull = AssemblyTitleFull.Replace("BrawlCrate", "PartyBrawl"); @@ -95,17 +96,17 @@ static Program() #endif AssemblyDescription = ((AssemblyDescriptionAttribute) Assembly - .GetExecutingAssembly() - .GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]) + .GetExecutingAssembly() + .GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]) .Description; AssemblyCopyright = ((AssemblyCopyrightAttribute) Assembly - .GetExecutingAssembly() - .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]) + .GetExecutingAssembly() + .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]) .Copyright; BrawlLibTitle = ((AssemblyTitleAttribute) Assembly - .GetAssembly(typeof(ResourceNode)) - .GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]) + .GetAssembly(typeof(ResourceNode)) + .GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]) .Title; _openDlg = new OpenFileDialog(); @@ -261,8 +262,10 @@ public static void Main(string[] args) if (args[0].Equals("/changelog", StringComparison.OrdinalIgnoreCase)) { string changelog = UpdateMessage.Substring(UpdateMessage.IndexOf('-'), - UpdateMessage.IndexOf("Full changelog can be found in the installation folder", - StringComparison.OrdinalIgnoreCase) - UpdateMessage.IndexOf('-')).Trim('\r', '\n', ' '); + UpdateMessage.IndexOf( + "Full changelog can be found in the installation folder", + StringComparison.OrdinalIgnoreCase) - + UpdateMessage.IndexOf('-')).Trim('\r', '\n', ' '); string fileName = $@"{AppPath}changelog-newest.txt"; using (StreamWriter file = new StreamWriter(fileName)) { @@ -306,7 +309,8 @@ public static void Main(string[] args) if (args.Length >= 2) { - ResourceNode target = ResourceNode.FindNode(RootNode, args[1], true, StringComparison.OrdinalIgnoreCase); + ResourceNode target = + ResourceNode.FindNode(RootNode, args[1], true, StringComparison.OrdinalIgnoreCase); if (target != null) { MainForm.Instance.TargetResource(target); @@ -454,22 +458,22 @@ public static bool Open(string path, bool showErrors) try { #endif - if ((_rootNode = NodeFactory.FromFile(null, _rootPath = path)) != null) + if ((_rootNode = NodeFactory.FromFile(null, _rootPath = path)) != null) + { + MainForm.Instance.Reset(); + MainForm.Instance.RecentFilesHandler.AddFile(path); + return true; + } + else + { + _rootPath = null; + if (showErrors) { - MainForm.Instance.Reset(); - MainForm.Instance.RecentFilesHandler.AddFile(path); - return true; + MessageBox.Show("Unable to recognize input file."); } - else - { - _rootPath = null; - if (showErrors) - { - MessageBox.Show("Unable to recognize input file."); - } - MainForm.Instance.Reset(); - } + MainForm.Instance.Reset(); + } #if !DEBUG } catch (Exception x) @@ -544,16 +548,14 @@ public static bool OpenFolder(string path, bool showErrors) MainForm.Instance.RecentFilesHandler.AddFile(path.EndsWith("\\") ? path : $"{path}\\"); return true; } - else - { - _rootPath = null; - if (showErrors) - { - MessageBox.Show("Unable to recognize input file."); - } - MainForm.Instance.Reset(); + _rootPath = null; + if (showErrors) + { + MessageBox.Show("Unable to recognize input file."); } + + MainForm.Instance.Reset(); #if !DEBUG } catch (Exception x) @@ -615,27 +617,28 @@ public static bool Save() try { #endif - if (_rootPath == null) - { - return SaveAs(); - } - - bool force = Control.ModifierKeys == (Keys.Control | Keys.Shift); - if (!force && !_rootNode.IsDirty) - { - MessageBox.Show("No changes have been made."); - MainForm.Instance.resourceTree_SelectionChanged(null, EventArgs.Empty); - return false; - } + if (_rootPath == null) + { + return SaveAs(); + } - if (!(_rootNode is FolderNode)) - { - _rootNode.Merge(force); - } - _rootNode.Export(_rootPath); - _rootNode.IsDirty = false; + bool force = Control.ModifierKeys == (Keys.Control | Keys.Shift); + if (!force && !_rootNode.IsDirty) + { + MessageBox.Show("No changes have been made."); MainForm.Instance.resourceTree_SelectionChanged(null, EventArgs.Empty); - return true; + return false; + } + + if (!(_rootNode is FolderNode)) + { + _rootNode.Merge(force); + } + + _rootNode.Export(_rootPath); + _rootNode.IsDirty = false; + MainForm.Instance.resourceTree_SelectionChanged(null, EventArgs.Empty); + return true; #if !DEBUG } catch (Exception x) @@ -671,18 +674,16 @@ public static int OpenFile(string filter, out string fileName, bool categorize) try { #endif - if (_openDlg.ShowDialog() == DialogResult.OK) + if (_openDlg.ShowDialog() == DialogResult.OK) + { + fileName = _openDlg.FileName; + if (categorize && _openDlg.FilterIndex == 1) { - fileName = _openDlg.FileName; - if (categorize && _openDlg.FilterIndex == 1) - { - return CategorizeFilter(_openDlg.FileName, filter); - } - else - { - return _openDlg.FilterIndex; - } + return CategorizeFilter(_openDlg.FileName, filter); } + + return _openDlg.FilterIndex; + } #if !DEBUG } catch (Exception ex) @@ -779,16 +780,16 @@ internal static bool SaveAs() try { #endif - GenericWrapper w = MainForm.Instance.RootNode as GenericWrapper; - string path = w.Export(); - if (path != null) - { - _rootPath = path; - MainForm.Instance.UpdateName(); - w.Resource.IsDirty = false; - MainForm.Instance.resourceTree_SelectionChanged(null, EventArgs.Empty); - return true; - } + GenericWrapper w = MainForm.Instance.RootNode as GenericWrapper; + string path = w.Export(); + if (path != null) + { + _rootPath = path; + MainForm.Instance.UpdateName(); + w.Resource.IsDirty = false; + MainForm.Instance.resourceTree_SelectionChanged(null, EventArgs.Empty); + return true; + } #if !DEBUG } catch (Exception x) @@ -810,7 +811,7 @@ public static bool CanRunGithubApp(bool showMessages, out string path) { if (showMessages) { - MessageBox.Show("Could not find " + path); + MessageBox.Show($"Could not find {path}"); } return false; diff --git a/BrawlCrate/Resources/IconDict.cs b/BrawlCrate/Resources/IconDict.cs index f6b6cd96d..ba84edd57 100644 --- a/BrawlCrate/Resources/IconDict.cs +++ b/BrawlCrate/Resources/IconDict.cs @@ -62,7 +62,7 @@ public static ImageList ImageList //Modules {ResourceType.REL, Resources.REL}, - + //Misc {ResourceType.CollisionDef, Resources.Coll}, {ResourceType.MSBin, Resources.MSG}, @@ -180,4 +180,4 @@ public static int getImageIndex(ResourceType resResourceFileType) return result == -1 ? 0 : result; } } -} +} \ No newline at end of file diff --git a/BrawlCrate/UI/CollisionEditor.cs b/BrawlCrate/UI/CollisionEditor.cs index 41361cc44..f5d54dd5e 100644 --- a/BrawlCrate/UI/CollisionEditor.cs +++ b/BrawlCrate/UI/CollisionEditor.cs @@ -1551,13 +1551,13 @@ protected void PopulateObjectList() lstObjects.Items.Add(obj, true); MDL0Node model = _models.Where(m => m is MDL0Node && ((ResourceNode) m).Name == obj._modelName) - .FirstOrDefault() as MDL0Node; + .FirstOrDefault() as MDL0Node; if (model != null) { MDL0BoneNode bone = model._linker.BoneCache.Where(b => b.Name == obj._boneName) - .FirstOrDefault() as MDL0BoneNode; + .FirstOrDefault() as MDL0BoneNode; if (bone != null) { obj._linkedBone = bone; diff --git a/BrawlCrate/UI/MainForm.cs b/BrawlCrate/UI/MainForm.cs index aa24728af..0bf5c66c8 100644 --- a/BrawlCrate/UI/MainForm.cs +++ b/BrawlCrate/UI/MainForm.cs @@ -720,9 +720,9 @@ public unsafe void resourceTree_SelectionChanged(object sender, EventArgs e) } if ((editToolStripMenuItem.DropDown = - Instance.resourceTree.SelectedNodes.Count > 1 - ? Instance.resourceTree.GetMultiSelectMenuStrip() - : w?.ContextMenuStrip) != null) + Instance.resourceTree.SelectedNodes.Count > 1 + ? Instance.resourceTree.GetMultiSelectMenuStrip() + : w?.ContextMenuStrip) != null) { editToolStripMenuItem.Enabled = true; } diff --git a/BrawlCrate/UI/Model Previewer/LeftPanel.cs b/BrawlCrate/UI/Model Previewer/LeftPanel.cs index f019c1b03..4c615c735 100644 --- a/BrawlCrate/UI/Model Previewer/LeftPanel.cs +++ b/BrawlCrate/UI/Model Previewer/LeftPanel.cs @@ -1109,7 +1109,7 @@ public void UpdateTextures() if (_selectedObject is MDL0ObjectNode) { foreach (MDL0MaterialRefNode tref in ((MDL0ObjectNode) _selectedObject) - ._drawCalls[0].MaterialNode.Children) + ._drawCalls[0].MaterialNode.Children) { lstTextures.Items.Add(tref.TextureNode, tref.TextureNode.Enabled); } @@ -1438,7 +1438,7 @@ private void lstTextures_SelectedValueChanged(object sender, EventArgs e) { TargetTexRef = _selectedObject != null ? ((MDL0ObjectNode) _selectedObject) - ._drawCalls[0].MaterialNode.FindChild(_selectedTexture.Name, true) as MDL0MaterialRefNode + ._drawCalls[0].MaterialNode.FindChild(_selectedTexture.Name, true) as MDL0MaterialRefNode : null; } } diff --git a/BrawlCrate/UI/ModelForm.cs b/BrawlCrate/UI/ModelForm.cs index 3a6e68e6e..a0268390d 100644 --- a/BrawlCrate/UI/ModelForm.cs +++ b/BrawlCrate/UI/ModelForm.cs @@ -199,13 +199,13 @@ protected override void OnShown(EventArgs e) } MDL0Node model = _models.Where(m => m is MDL0Node && ((ResourceNode) m).Name == obj._modelName) - .FirstOrDefault() as MDL0Node; + .FirstOrDefault() as MDL0Node; if (model != null) { MDL0BoneNode bone = model._linker.BoneCache.Where(b => b.Name == obj._boneName) - .FirstOrDefault() as MDL0BoneNode; + .FirstOrDefault() as MDL0BoneNode; if (bone != null) { obj._linkedBone = bone; diff --git a/BrawlCrate/UI/ResourceTree.cs b/BrawlCrate/UI/ResourceTree.cs index d1ee1d4e7..6ea1b5bd1 100644 --- a/BrawlCrate/UI/ResourceTree.cs +++ b/BrawlCrate/UI/ResourceTree.cs @@ -12,7 +12,6 @@ namespace BrawlCrate { public class ResourceTree : TreeViewMS { - public event EventHandler SelectionChanged; private bool _allowContextMenus = true; @@ -145,7 +144,7 @@ protected override void WndProc(ref Message m) public ContextMenuStrip GetMultiSelectMenuStrip() { - System.Collections.Generic.List nodes = SelectedNodes; + List nodes = SelectedNodes; MultiSelectableWrapper singleNode = SelectedNode as MultiSelectableWrapper; if (singleNode == null) { diff --git a/BrawlCrateTools.sln.DotSettings b/BrawlCrateTools.sln.DotSettings index e6f5c692b..3b5b1dbdc 100644 --- a/BrawlCrateTools.sln.DotSettings +++ b/BrawlCrateTools.sln.DotSettings @@ -24,4 +24,8 @@ UseExplicitType UseExplicitType UseExplicitType - True \ No newline at end of file + True + True + True + True + True \ No newline at end of file diff --git a/BrawlLib/BrawlManagerLib/GCT/ReadOnly/CNMT.cs b/BrawlLib/BrawlManagerLib/GCT/ReadOnly/CNMT.cs index 6c07cef2b..a74557759 100644 --- a/BrawlLib/BrawlManagerLib/GCT/ReadOnly/CNMT.cs +++ b/BrawlLib/BrawlManagerLib/GCT/ReadOnly/CNMT.cs @@ -51,11 +51,11 @@ public CNMT(byte[] data) int bytes = data[lineskip + 7]; byte[] byteArray = data - .Skip(lineskip) - .Skip(8) - .Take(bytes) - .TakeWhile(c => c != 0) - .ToArray(); + .Skip(lineskip) + .Skip(8) + .Take(bytes) + .TakeWhile(c => c != 0) + .ToArray(); string str = Encoding.UTF8.GetString(byteArray); if (Map.TryGetValue((ushort) songId1, out string existing) && existing != str) { diff --git a/BrawlLib/BrawlManagerLib/GCT/ReadWrite/CustomSSSCodeset.cs b/BrawlLib/BrawlManagerLib/GCT/ReadWrite/CustomSSSCodeset.cs index 076f35541..695616e0d 100644 --- a/BrawlLib/BrawlManagerLib/GCT/ReadWrite/CustomSSSCodeset.cs +++ b/BrawlLib/BrawlManagerLib/GCT/ReadWrite/CustomSSSCodeset.cs @@ -229,7 +229,9 @@ public Song GetSong(string filename, Song originalSong) if (AlternateStageLoaderData.TryGetDefinition(filename, out AlternateStageEntry entry)) { foreach (AlternateStageEntry.Alternate alt in entry.ButtonActivated.Where(b => - filename.EndsWith($"_{b.Letter}.pac", StringComparison.InvariantCultureIgnoreCase))) + filename.EndsWith($"_{b.Letter}.pac", + StringComparison + .InvariantCultureIgnoreCase))) { Song newSong = AltStageSongForcer.GetSong(stageID, alt.ButtonMask, originalSong); if (newSong.ID != originalSong.ID) diff --git a/BrawlLib/BrawlManagerLib/Songs/SongNameBar.cs b/BrawlLib/BrawlManagerLib/Songs/SongNameBar.cs index 707a51069..8ebc3a054 100644 --- a/BrawlLib/BrawlManagerLib/Songs/SongNameBar.cs +++ b/BrawlLib/BrawlManagerLib/Songs/SongNameBar.cs @@ -207,7 +207,7 @@ public string findInfoFile() // info found; try info_training in same directory string trainingpath = _currentFile.Replace("info.pac", "info_training.pac") - .Replace("info_en.pac", "info_training_en.pac"); + .Replace("info_en.pac", "info_training_en.pac"); if (trainingpath != _currentFile && new FileInfo(trainingpath).Exists) { _currentTrainingFile = trainingpath; diff --git a/BrawlLib/BrawlManagerLib/Songs/SongPanel.cs b/BrawlLib/BrawlManagerLib/Songs/SongPanel.cs index 67991a99d..220c18923 100644 --- a/BrawlLib/BrawlManagerLib/Songs/SongPanel.cs +++ b/BrawlLib/BrawlManagerLib/Songs/SongPanel.cs @@ -139,7 +139,7 @@ public void Open(FileInfo fi, string fallbackDir = null) Song song = (from s in SongIDMap.Songs where s.Filename == filename select s) - .DefaultIfEmpty(null).First(); + .DefaultIfEmpty(null).First(); if (song != null && CustomSongTitles != null && CustomSongTitles.TryGetValue(song.ID, out string name)) { songNameBar.Index = -1; diff --git a/BrawlLib/CustomLists/CustomLists.cs b/BrawlLib/CustomLists/CustomLists.cs index 041b2c55b..0d5b14633 100644 --- a/BrawlLib/CustomLists/CustomLists.cs +++ b/BrawlLib/CustomLists/CustomLists.cs @@ -71,7 +71,7 @@ public static string InternalNameFromID(int id, int idOffset, string flagToIgnor !s.ToUpper().Substring(flagIndex).StartsWith(flagToIgnore)) { string intName = s.Substring(internalNameIndex, nameIndex - internalNameIndex - 1) - .Trim(trimChars); + .Trim(trimChars); if (intName.Length > 0) { return intName; @@ -108,10 +108,10 @@ public static void GenerateDefaultList() { string resourceName = "BrawlLib.CustomLists." + (System.Threading.Thread.CurrentThread.CurrentUICulture.ToString().Substring(0, 2) - .Equals("en", StringComparison.OrdinalIgnoreCase) + .Equals("en", StringComparison.OrdinalIgnoreCase) ? "" : System.Threading.Thread.CurrentThread.CurrentUICulture.ToString() - .Substring(0, 2).ToLower() + '.') + "FighterList.txt"; + .Substring(0, 2).ToLower() + '.') + "FighterList.txt"; string listDefault = ""; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { @@ -383,10 +383,10 @@ public static void GenerateDefaultList() { string resourceName = "BrawlLib.CustomLists." + (System.Threading.Thread.CurrentThread.CurrentUICulture.ToString().Substring(0, 2) - .Equals("en", StringComparison.OrdinalIgnoreCase) + .Equals("en", StringComparison.OrdinalIgnoreCase) ? "" : System.Threading.Thread.CurrentThread.CurrentUICulture.ToString() - .Substring(0, 2).ToLower() + '.') + "StageList.txt"; + .Substring(0, 2).ToLower() + '.') + "StageList.txt"; string listDefault = ""; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { diff --git a/BrawlLib/Imaging/GIF/AnimatedGifEncoder.cs b/BrawlLib/Imaging/GIF/AnimatedGifEncoder.cs index 45a0bbc50..1bb3f8dea 100644 --- a/BrawlLib/Imaging/GIF/AnimatedGifEncoder.cs +++ b/BrawlLib/Imaging/GIF/AnimatedGifEncoder.cs @@ -54,7 +54,7 @@ public class AnimatedGifEncoder protected Color transparent = Color.Empty; // transparent color if given protected int transIndex; // transparent index in color table protected int repeat = -1; // no repeat - protected int delay; // frame delay (hundredths) + protected int delay; // frame delay (hundredths) protected bool started; // ready to output frames @@ -69,10 +69,10 @@ public class AnimatedGifEncoder protected bool[] usedEntry = new bool[256]; // active palette entries protected int palSize = 7; // color table size (bits-1) protected int dispose = -1; // disposal code (-1 = use default) - protected bool closeStream; // close stream when finished + protected bool closeStream; // close stream when finished protected bool firstFrame = true; - protected bool sizeSet; // if false, get size from first frame - protected int sample = 10; // default sample interval for quantizer + protected bool sizeSet; // if false, get size from first frame + protected int sample = 10; // default sample interval for quantizer /** * Sets the delay time between each frame, or changes it diff --git a/BrawlLib/Imaging/GIF/GifDecoder.cs b/BrawlLib/Imaging/GIF/GifDecoder.cs index b6eac95fc..b1fb2a461 100644 --- a/BrawlLib/Imaging/GIF/GifDecoder.cs +++ b/BrawlLib/Imaging/GIF/GifDecoder.cs @@ -95,7 +95,7 @@ public class GifDecoder protected Image lastImage; // previous frame protected byte[] block = new byte[256]; // current data block - protected int blockSize; // block size + protected int blockSize; // block size // last graphic control extension info protected int dispose; @@ -103,8 +103,8 @@ public class GifDecoder // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev protected int lastDispose; protected bool transparency; // use transparent color - protected int delay; // delay in milliseconds - protected int transIndex; // transparent color index + protected int delay; // delay in milliseconds + protected int transIndex; // transparent color index protected static readonly int MaxStackSize = 4096; // max decoder pixel stack size diff --git a/BrawlLib/Modeling/Collada/ColladaExporter.cs b/BrawlLib/Modeling/Collada/ColladaExporter.cs index 44b19f517..cb5675c9c 100644 --- a/BrawlLib/Modeling/Collada/ColladaExporter.cs +++ b/BrawlLib/Modeling/Collada/ColladaExporter.cs @@ -1098,10 +1098,10 @@ private static unsafe void WriteControllers(MDL0Node model, XmlWriter writer) } writer.WriteString(Array.IndexOf(bones, w.Bone) - .ToString(CultureInfo.InvariantCulture.NumberFormat)); + .ToString(CultureInfo.InvariantCulture.NumberFormat)); writer.WriteString(" "); writer.WriteString(Array.IndexOf(weightSet, w.Weight) - .ToString(CultureInfo.InvariantCulture.NumberFormat)); + .ToString(CultureInfo.InvariantCulture.NumberFormat)); } } } @@ -1121,10 +1121,10 @@ private static unsafe void WriteControllers(MDL0Node model, XmlWriter writer) } writer.WriteString(Array.IndexOf(bones, w.Bone) - .ToString(CultureInfo.InvariantCulture.NumberFormat)); + .ToString(CultureInfo.InvariantCulture.NumberFormat)); writer.WriteString(" "); writer.WriteString(Array.IndexOf(weightSet, w.Weight) - .ToString(CultureInfo.InvariantCulture.NumberFormat)); + .ToString(CultureInfo.InvariantCulture.NumberFormat)); } } } @@ -1380,8 +1380,8 @@ public static void Serialize(CHR0Node[] animations, float fps, bool bake, string writer.WriteString( (entry._index / fps).ToString(CultureInfo - .InvariantCulture - .NumberFormat)); + .InvariantCulture + .NumberFormat)); } } writer.WriteEndElement(); //float_array @@ -1444,7 +1444,7 @@ public static void Serialize(CHR0Node[] animations, float fps, bool bake, string writer.WriteString( entry._value.ToString(CultureInfo - .InvariantCulture.NumberFormat)); + .InvariantCulture.NumberFormat)); } } writer.WriteEndElement(); //float_array @@ -1494,7 +1494,7 @@ public static void Serialize(CHR0Node[] animations, float fps, bool bake, string writer.WriteString( entry._tangent.ToString(CultureInfo - .InvariantCulture.NumberFormat)); + .InvariantCulture.NumberFormat)); } } writer.WriteEndElement(); //float_array @@ -1544,7 +1544,7 @@ public static void Serialize(CHR0Node[] animations, float fps, bool bake, string writer.WriteString( entry._tangent.ToString(CultureInfo - .InvariantCulture.NumberFormat)); + .InvariantCulture.NumberFormat)); } } writer.WriteEndElement(); //float_array diff --git a/BrawlLib/Modeling/Collada/ColladaImporter.cs b/BrawlLib/Modeling/Collada/ColladaImporter.cs index 581dc5cef..570892842 100644 --- a/BrawlLib/Modeling/Collada/ColladaImporter.cs +++ b/BrawlLib/Modeling/Collada/ColladaImporter.cs @@ -441,7 +441,7 @@ public IModel ImportModel(string filePath, ImportType type) { obj.SingleBind = m.FindBone(obj.SingleBind).Parent - .Name; // Remove unecessary reference to "end" bones + .Name; // Remove unecessary reference to "end" bones } else { @@ -461,7 +461,7 @@ public IModel ImportModel(string filePath, ImportType type) { dc.VisibilityBone = m.FindBone(dc.VisibilityBone).Parent - .Name; // Remove unecessary reference to "end" bones + .Name; // Remove unecessary reference to "end" bones } else { @@ -482,7 +482,7 @@ public IModel ImportModel(string filePath, ImportType type) { obj.SingleBind = m.FindBone(obj.SingleBind).Parent - .Name; // Remove unecessary reference to "end" bones + .Name; // Remove unecessary reference to "end" bones } foreach (DrawCall dc in obj._drawCalls) @@ -494,7 +494,7 @@ public IModel ImportModel(string filePath, ImportType type) { dc.VisibilityBone = m.FindBone(dc.VisibilityBone).Parent - .Name; // Remove unecessary reference to "end" bones + .Name; // Remove unecessary reference to "end" bones } } } diff --git a/BrawlLib/Modeling/PrimitiveManager.cs b/BrawlLib/Modeling/PrimitiveManager.cs index ab3ce2801..5d054ae33 100644 --- a/BrawlLib/Modeling/PrimitiveManager.cs +++ b/BrawlLib/Modeling/PrimitiveManager.cs @@ -1917,12 +1917,12 @@ internal Facepoint[] MergeInternalFaceData() for (int i = 0; i < _pointCount; i++) { _facepoints[i]._colorIndices[x - 2] = Array - .IndexOf( - ((MDL0ObjectNode) ((MDL0Node) Collada - .CurrentModel) - ._objList[_newClrObj[x - 2]]) - ._manager.GetColors(x - 2, false), - *pIn2++).ClampMin(0); + .IndexOf( + ((MDL0ObjectNode) ((MDL0Node) Collada + .CurrentModel) + ._objList[_newClrObj[x - 2]]) + ._manager.GetColors(x - 2, false), + *pIn2++).ClampMin(0); } } } diff --git a/BrawlLib/SSBB/ResourceNodes/Archives/FolderNode.cs b/BrawlLib/SSBB/ResourceNodes/Archives/FolderNode.cs index 3f3d71089..d99909c89 100644 --- a/BrawlLib/SSBB/ResourceNodes/Archives/FolderNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Archives/FolderNode.cs @@ -18,6 +18,7 @@ public class FolderNode : ResourceNode public string Path; private string[] _directories; private string[] _files; + public override bool IsDirty { get @@ -26,6 +27,7 @@ public override bool IsDirty { return false; } + if (HasChanged) { return true; @@ -73,8 +75,8 @@ public override unsafe void Export(string outPath) c.Export(c._origPath); } } - - this.IsDirty = false; + + IsDirty = false; } public override void OnPopulate() @@ -83,23 +85,25 @@ public override void OnPopulate() { NodeFactory.FromFolder(this, s); } + foreach (string s in _files) { ResourceNode node = NodeFactory.FromFile(this, s); node._origPath = s; } + base.OnPopulate(); } public override bool OnInitialize() { - this._name = new DirectoryInfo(Path).Name; - this._directories = Directory.GetDirectories(this.Path); - this._files = Directory.GetFiles(this.Path); - this.IsDirty = false; + _name = new DirectoryInfo(Path).Name; + _directories = Directory.GetDirectories(Path); + _files = Directory.GetFiles(Path); + IsDirty = false; base.OnInitialize(); return true; } } -} +} \ No newline at end of file diff --git a/BrawlLib/SSBB/ResourceNodes/BrawlEx/CSSCNode.cs b/BrawlLib/SSBB/ResourceNodes/BrawlEx/CSSCNode.cs index dea077277..008494cff 100644 --- a/BrawlLib/SSBB/ResourceNodes/BrawlEx/CSSCNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/BrawlEx/CSSCNode.cs @@ -329,7 +329,8 @@ public override bool OnInitialize() if (_name == null) { _name = "Fit" + BrawlCrate.FighterNameGenerators.InternalNameFromID(((CSSCNode) Parent)._cosmeticSlot, - BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S") + _costumeID.ToString("00") + + BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S") + + _costumeID.ToString("00") + (BrawlExColorID.Colors.Length > _colorID ? " - " + BrawlExColorID.Colors[_colorID].Name : ""); } @@ -339,7 +340,8 @@ public override bool OnInitialize() public void regenName() { Name = "Fit" + BrawlCrate.FighterNameGenerators.InternalNameFromID(((CSSCNode) Parent)._cosmeticSlot, - BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S") + _costumeID.ToString("00") + + BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S") + + _costumeID.ToString("00") + (BrawlExColorID.Colors.Length > _colorID ? " - " + BrawlExColorID.Colors[_colorID].Name : ""); } @@ -359,8 +361,9 @@ public List GetCostumeFilePath(string currentPath) currentPath = currentPath.Substring(0, currentPath.LastIndexOf("brawlex", StringComparison.OrdinalIgnoreCase)); List internalNames = BrawlCrate.FighterNameGenerators - .InternalNameFromID(((CSSCNode) Parent)._cosmeticSlot, - BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S").Split('/').ToList(); + .InternalNameFromID(((CSSCNode) Parent)._cosmeticSlot, + BrawlCrate.FighterNameGenerators.cosmeticIDIndex, "+S") + .Split('/').ToList(); foreach (string s in internalNames) { if (File.Exists(currentPath + "fighter\\" + s + '\\' + "Fit" + s + _costumeID.ToString("00") + diff --git a/BrawlLib/SSBB/ResourceNodes/BrawlEx/FCFGNode.cs b/BrawlLib/SSBB/ResourceNodes/BrawlEx/FCFGNode.cs index d66448188..b957036c1 100644 --- a/BrawlLib/SSBB/ResourceNodes/BrawlEx/FCFGNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/BrawlEx/FCFGNode.cs @@ -1126,17 +1126,17 @@ public override bool OnInitialize() } _pacName = System.Text.Encoding.UTF8.GetString(_pacNameArray) - .Substring(0, System.Text.Encoding.UTF8.GetString(_pacNameArray).IndexOf('\0')) - .TrimEnd(new char[] {'\0'}); + .Substring(0, System.Text.Encoding.UTF8.GetString(_pacNameArray).IndexOf('\0')) + .TrimEnd(new char[] {'\0'}); _kirbyPacName = System.Text.Encoding.UTF8.GetString(_kirbyPacNameArray) - .Substring(0, System.Text.Encoding.UTF8.GetString(_kirbyPacNameArray).IndexOf('\0')) - .TrimEnd(new char[] {'\0'}); + .Substring(0, System.Text.Encoding.UTF8.GetString(_kirbyPacNameArray).IndexOf('\0')) + .TrimEnd(new char[] {'\0'}); _moduleName = System.Text.Encoding.UTF8.GetString(_moduleNameArray) - .Substring(0, System.Text.Encoding.UTF8.GetString(_moduleNameArray).IndexOf('\0')) - .TrimEnd(new char[] {'\0'}); + .Substring(0, System.Text.Encoding.UTF8.GetString(_moduleNameArray).IndexOf('\0')) + .TrimEnd(new char[] {'\0'}); _internalName = System.Text.Encoding.UTF8.GetString(_internalNameArray) - .Substring(0, System.Text.Encoding.UTF8.GetString(_internalNameArray).IndexOf('\0')) - .TrimEnd(new char[] {'\0'}); + .Substring(0, System.Text.Encoding.UTF8.GetString(_internalNameArray).IndexOf('\0')) + .TrimEnd(new char[] {'\0'}); try { if (_pacName.ToUpper().LastIndexOf(".PAC") > 0 && _pacName.ToUpper().Contains("/FIT")) @@ -1160,19 +1160,19 @@ public override bool OnInitialize() } if (System.Text.Encoding.UTF8.GetString(_kirbyPacNameArray).ToUpper().TrimEnd(new char[] {'\0'}) - .EndsWith("\0X")) + .EndsWith("\0X")) { _hasKirbyHat = false; } if (System.Text.Encoding.UTF8.GetString(_moduleNameArray).ToUpper().TrimEnd(new char[] {'\0'}) - .EndsWith("\0X")) + .EndsWith("\0X")) { _hasModule = false; } if (System.Text.Encoding.UTF8.GetString(_internalNameArray).ToUpper().TrimEnd(new char[] {'\0'}) - .EndsWith("\0X")) + .EndsWith("\0X")) { _hasInternalName = false; } diff --git a/BrawlLib/SSBB/ResourceNodes/Graphics/REFF/REFFAnimationNode.cs b/BrawlLib/SSBB/ResourceNodes/Graphics/REFF/REFFAnimationNode.cs index c793b3fde..24bdc9746 100644 --- a/BrawlLib/SSBB/ResourceNodes/Graphics/REFF/REFFAnimationNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Graphics/REFF/REFFAnimationNode.cs @@ -401,42 +401,46 @@ public override bool OnInitialize() Dictionary> values; - VoidPtr offset = (VoidPtr)Header + 0x20; + VoidPtr offset = (VoidPtr) Header + 0x20; if (KeyTableSize > 4) { - AnimCurveTableHeader* hdr = (AnimCurveTableHeader*)offset; + AnimCurveTableHeader* hdr = (AnimCurveTableHeader*) offset; AnimCurveKeyHeader* key = hdr->First; for (int i = 0; i < hdr->_count; i++, key = key->Next(enabledIndices.Count, size)) { key->GetFrameIndex(enabledIndices.Count, size); } } + offset += KeyTableSize; if (RangeTableSize > 4) { - AnimCurveTableHeader* hdr = (AnimCurveTableHeader*)offset; - + AnimCurveTableHeader* hdr = (AnimCurveTableHeader*) offset; } + offset += RangeTableSize; if (RandomTableSize > 4) { - AnimCurveTableHeader* hdr = (AnimCurveTableHeader*)offset; - + AnimCurveTableHeader* hdr = (AnimCurveTableHeader*) offset; } + offset += RandomTableSize; if (NameTableSize > 4) { - AnimCurveTableHeader* hdr = (AnimCurveTableHeader*)offset; + AnimCurveTableHeader* hdr = (AnimCurveTableHeader*) offset; _names = new List(); - bushort* addr = (bushort*)((VoidPtr)hdr + 4 + hdr->_count * 4); - for (int i = 0; i < hdr->_count; i++, addr = (bushort*)((VoidPtr)addr + 2 + *addr)) - _names.Add(new String((sbyte*)addr + 2)); + bushort* addr = (bushort*) ((VoidPtr) hdr + 4 + hdr->_count * 4); + for (int i = 0; i < hdr->_count; i++, addr = (bushort*) ((VoidPtr) addr + 2 + *addr)) + { + _names.Add(new string((sbyte*) addr + 2)); + } } + offset += NameTableSize; if (InfoTableSize > 4) { - AnimCurveTableHeader* hdr = (AnimCurveTableHeader*)offset; + AnimCurveTableHeader* hdr = (AnimCurveTableHeader*) offset; //switch ((v9AnimCurveTargetField)_hdr.kindType) //{ diff --git a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0MaterialNode.cs b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0MaterialNode.cs index 82dac8c43..b911a8af0 100644 --- a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0MaterialNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0MaterialNode.cs @@ -1958,55 +1958,55 @@ public void UseProgram(MDL0ObjectNode node, bool forceRemake = false) try { #endif - if (_programHandle > 0) + if (_programHandle > 0) + { + if (_vertexShaderHandle > 0) { - if (_vertexShaderHandle > 0) - { - DeleteShader(ref _vertexShaderHandle); - } - - if (_fragShaderHandle > 0) - { - DeleteShader(ref _fragShaderHandle); - } - - GL.DeleteProgram(_programHandle); - _programHandle = 0; + DeleteShader(ref _vertexShaderHandle); } - ShaderGenerator.SetTarget(this); - - if (updateShaderFrag) + if (_fragShaderHandle > 0) { - ShaderNode._fragShaderSource = ShaderGenerator.GenTEVFragShader(); + DeleteShader(ref _fragShaderHandle); } - if (updateVert) - { - _vertexShaderSource = ShaderGenerator.GenVertexShader(); - } + GL.DeleteProgram(_programHandle); + _programHandle = 0; + } - if (updateMatFrag) - { - _fragShaderSource = ShaderGenerator.GenMaterialFragShader(); - } + ShaderGenerator.SetTarget(this); + + if (updateShaderFrag) + { + ShaderNode._fragShaderSource = ShaderGenerator.GenTEVFragShader(); + } + + if (updateVert) + { + _vertexShaderSource = ShaderGenerator.GenVertexShader(); + } + + if (updateMatFrag) + { + _fragShaderSource = ShaderGenerator.GenMaterialFragShader(); + } - string combineFrag = ShaderGenerator.CombineFragShader( - _fragShaderSource, - ShaderNode == null ? null : ShaderNode._fragShaderSource, - ActiveShaderStages); + string combineFrag = ShaderGenerator.CombineFragShader( + _fragShaderSource, + ShaderNode == null ? null : ShaderNode._fragShaderSource, + ActiveShaderStages); - GenShader(ref _vertexShaderHandle, _vertexShaderSource, true); - GenShader(ref _fragShaderHandle, combineFrag, false); + GenShader(ref _vertexShaderHandle, _vertexShaderSource, true); + GenShader(ref _fragShaderHandle, combineFrag, false); - ShaderGenerator.ClearTarget(); + ShaderGenerator.ClearTarget(); - _programHandle = GL.CreateProgram(); + _programHandle = GL.CreateProgram(); - GL.AttachShader(_programHandle, _vertexShaderHandle); - GL.AttachShader(_programHandle, _fragShaderHandle); + GL.AttachShader(_programHandle, _vertexShaderHandle); + GL.AttachShader(_programHandle, _fragShaderHandle); - GL.LinkProgram(_programHandle); + GL.LinkProgram(_programHandle); #if DEBUG GL.GetProgram(_programHandle, GetProgramParameterName.LinkStatus, out int status); diff --git a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0Node.cs b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0Node.cs index 725be55a7..9493f0d18 100644 --- a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0Node.cs +++ b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0Node.cs @@ -249,7 +249,9 @@ public MDLEnvelopeMatrixMode EnvelopeMatrixMode [Browsable(false)] public List DefinitionsList => _defList; [Browsable(false)] public List BoneList => _boneList; - [Browsable(false)] public List AllBones + + [Browsable(false)] + public List AllBones { get { @@ -263,12 +265,14 @@ public MDLEnvelopeMatrixMode EnvelopeMatrixMode bones.Add(b); } } + bones = bones.OrderBy(o => o.BoneIndex).ToList(); } return bones; } } + [Browsable(false)] public List MaterialList => _matList; [Browsable(false)] public List ShaderList => _shadList; [Browsable(false)] public List VertexList => _vertList; diff --git a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0ObjectNode.cs b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0ObjectNode.cs index 166707c9c..3a75494bd 100644 --- a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0ObjectNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0ObjectNode.cs @@ -2272,6 +2272,7 @@ public override void Render(ModelPanelViewport viewport) { mat = mat.MetalMaterial; } + if (attrib._renderPolygons) { bool shaders = attrib._renderShaders && mat != null; diff --git a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0TextureNode.cs b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0TextureNode.cs index 589b77d89..c02cc5d98 100644 --- a/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0TextureNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/MDL0/MDL0TextureNode.cs @@ -219,6 +219,7 @@ public void Reload() private int _index = -1; private int _program = -1; private bool _isMetal; + private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) { _index = index; @@ -254,7 +255,8 @@ private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) } TEX0Node tNode; - if (bmp == null && (Source == null || !(Source is TEX0Node)) && TKContext.CurrentContext._states.ContainsKey("_Node_Refs")) + if (bmp == null && (Source == null || !(Source is TEX0Node)) && + TKContext.CurrentContext._states.ContainsKey("_Node_Refs")) { List nodes = RootNode.GetChildrenRecursive(); if (model?.BRESNode?.Parent != null) @@ -267,7 +269,8 @@ private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) ARCEntryNode a; BRRESNode b; bool redirect = false; - if ((a = n as ARCEntryNode) != null && bres != null && bres.GroupID == a.GroupID && (b = a.RedirectNode as BRRESNode) != null) + if ((a = n as ARCEntryNode) != null && bres != null && bres.GroupID == a.GroupID && + (b = a.RedirectNode as BRRESNode) != null) { redirect = true; } @@ -280,13 +283,16 @@ private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) { continue; } + //Search node itself first - if ((tNode = b.FindChild("Textures(NW4R)/" + Name, false, StringComparison.Ordinal) as TEX0Node) != null) + if ((tNode = b.FindChild("Textures(NW4R)/" + Name, false, StringComparison.Ordinal) as TEX0Node) != + null) { Source = tNode; Texture.Attach(tNode, _palette); return; } + //Then search the directory bmp = SearchDirectory(n._origPath); @@ -314,6 +320,7 @@ private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) Texture.Default(); return; } + using (MemoryStream ms = new MemoryStream()) { stream.CopyTo(ms); @@ -324,6 +331,7 @@ private unsafe void Load(int index, int program, MDL0Node model, bool isMetal) return; } + Texture.Default(); } diff --git a/BrawlLib/SSBB/ResourceNodes/MasqueradeNode.cs b/BrawlLib/SSBB/ResourceNodes/MasqueradeNode.cs index 1e0c5014f..3e9322e64 100644 --- a/BrawlLib/SSBB/ResourceNodes/MasqueradeNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/MasqueradeNode.cs @@ -198,8 +198,10 @@ public byte CostumeID { if (System.Windows.Forms.MessageBox.Show( "Costume slot " + value + - " is known to be bugged for WarioMan. Are you sure you'd like to proceed?", "Warning", - System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) + " is known to be bugged for WarioMan. Are you sure you'd like to proceed?", + "Warning", + System.Windows.Forms.MessageBoxButtons.YesNo) != + System.Windows.Forms.DialogResult.Yes) { return; } @@ -246,9 +248,9 @@ public override bool OnInitialize() public void regenName() { Name = "Fit" + - (((MasqueradeNode)Parent)._cosmeticSlot >= MasqueradeNode.MasqueradeInternalNames.Length ? - $"Fighter{((MasqueradeNode)Parent)._cosmeticSlot}_" - : MasqueradeNode.MasqueradeInternalNames[((MasqueradeNode)Parent)._cosmeticSlot]) + + (((MasqueradeNode) Parent)._cosmeticSlot >= MasqueradeNode.MasqueradeInternalNames.Length + ? $"Fighter{((MasqueradeNode) Parent)._cosmeticSlot}_" + : MasqueradeNode.MasqueradeInternalNames[((MasqueradeNode) Parent)._cosmeticSlot]) + _costumeID.ToString("00") + (BrawlExColorID.Colors.Length > _colorID ? " - " + BrawlExColorID.Colors[_colorID].Name : ""); @@ -264,17 +266,19 @@ public override void OnRebuild(VoidPtr address, int length, bool force) public List GetCostumeFilePath(string currentPath) { List files = new List(); - if (((MasqueradeNode)Parent)._cosmeticSlot >= MasqueradeNode.MasqueradeInternalNames.Length) + if (((MasqueradeNode) Parent)._cosmeticSlot >= MasqueradeNode.MasqueradeInternalNames.Length) { return files; } + if ((currentPath = currentPath.Substring(0, currentPath.LastIndexOf('\\'))).EndsWith( "pf\\info\\costumeslots", StringComparison.OrdinalIgnoreCase)) { currentPath = currentPath.Substring(0, currentPath.LastIndexOf("info", StringComparison.OrdinalIgnoreCase)); List internalNames = MasqueradeNode - .MasqueradeInternalNames[((MasqueradeNode) Parent)._cosmeticSlot].Split('/').ToList(); + .MasqueradeInternalNames[((MasqueradeNode) Parent)._cosmeticSlot] + .Split('/').ToList(); foreach (string s in internalNames) { if (File.Exists($"{currentPath}\\fighter\\{s}\\Fit{s}{_costumeID:00}.pac")) diff --git a/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/ActionEventNode.cs b/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/ActionEventNode.cs index 3142d1598..4a9e16888 100644 --- a/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/ActionEventNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/ActionEventNode.cs @@ -426,7 +426,7 @@ public override bool OnInitialize() Remove(); return false; } - + for (int i = 0; i < numArguments; i++) { FDefEventArgument e; diff --git a/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/MoveDefActionNode.cs b/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/MoveDefActionNode.cs index f1a12fe69..e8f0f6615 100644 --- a/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/MoveDefActionNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Moveset/Actions/MoveDefActionNode.cs @@ -283,6 +283,7 @@ public override void OnRebuild(VoidPtr address, int length, bool force) eventAddr++; //Terminate } + /* #region Scripting diff --git a/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataArticleNode.cs b/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataArticleNode.cs index 0bdf075eb..d44e5ffae 100644 --- a/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataArticleNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataArticleNode.cs @@ -209,7 +209,7 @@ public override void OnPopulate() else { actions.Children[i].Children - .Add(new MoveDefActionNode("Entry", true, actions.Children[i])); + .Add(new MoveDefActionNode("Entry", true, actions.Children[i])); } off = *((bint*) (BaseAddress + _extraOffsets[0]) + i); @@ -221,7 +221,7 @@ public override void OnPopulate() else { actions.Children[i].Children - .Add(new MoveDefActionNode("Exit", true, actions.Children[i])); + .Add(new MoveDefActionNode("Exit", true, actions.Children[i])); } } else @@ -1336,6 +1336,7 @@ public override void OnRebuild(VoidPtr address, int length, bool force) } } } + /* public int currentSubAction = 0; public MDL0Node Model = null; diff --git a/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataMiscNode.cs b/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataMiscNode.cs index b48aa7ca0..0427fc998 100644 --- a/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataMiscNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Moveset/Data Nodes/DataMiscNode.cs @@ -1342,7 +1342,9 @@ public unsafe void Render(bool selected, int type) Vector3 bonepos = BoneNode._frameMatrix.GetPoint(); Vector3 bonerot = BoneNode._frameMatrix.GetAngles(); - Vector3 bonescl = BoneNode._frameMatrix.GetScale(); // TODO: FIX (maybe), using wrong scale -> should be recursive scale + Vector3 + bonescl = BoneNode._frameMatrix + .GetScale(); // TODO: FIX (maybe), using wrong scale -> should be recursive scale bonescl *= _radius; Matrix m = Matrix.TransformMatrix(bonescl, bonerot, bonepos); diff --git a/BrawlLib/SSBB/ResourceNodes/Moveset/MoveDefNode.cs b/BrawlLib/SSBB/ResourceNodes/Moveset/MoveDefNode.cs index 2274433f1..786182dc9 100644 --- a/BrawlLib/SSBB/ResourceNodes/Moveset/MoveDefNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/Moveset/MoveDefNode.cs @@ -290,7 +290,7 @@ public unsafe class MoveDefNode : ARCEntryNode internal FDefHeader* Header => (FDefHeader*) WorkingUncompressed.Address; internal int dataSize, lookupOffset, numLookupEntries, numDataTable, numExternalSubRoutine; - internal static ResourceNode TryParse(DataSource source) + internal static ResourceNode TryParse(DataSource source) { if (MSBinNode.TryParse(source) != null) { @@ -298,13 +298,17 @@ internal static ResourceNode TryParse(DataSource source) } VoidPtr addr = source.Address; - FDefHeader* header = (FDefHeader*)addr; + FDefHeader* header = (FDefHeader*) addr; if (header->_pad1 != 0 || header->_pad2 != 0 || header->_pad3 != 0) + { return null; + } if (header->_fileSize > source.Length || header->_lookupOffset > source.Length) + { return null; + } return new MoveDefNode(); diff --git a/BrawlLib/SSBB/ResourceNodes/NodeFactory.cs b/BrawlLib/SSBB/ResourceNodes/NodeFactory.cs index 9748d9c52..594580215 100644 --- a/BrawlLib/SSBB/ResourceNodes/NodeFactory.cs +++ b/BrawlLib/SSBB/ResourceNodes/NodeFactory.cs @@ -77,8 +77,9 @@ public static ResourceNode FromFile(ResourceNode parent, string path, FileOption { string ext = path.Substring(path.LastIndexOf('.') + 1).ToUpper(CultureInfo.InvariantCulture); - if(!(t is null) && (node = Activator.CreateInstance(t) as ResourceNode) != null - || Forced.ContainsKey(ext) && (node = Activator.CreateInstance(Forced[ext]) as ResourceNode) != null) + if (!(t is null) && (node = Activator.CreateInstance(t) as ResourceNode) != null + || Forced.ContainsKey(ext) && + (node = Activator.CreateInstance(Forced[ext]) as ResourceNode) != null) { FileMap uncompressedMap = Compressor.TryExpand(ref source, false); if (uncompressedMap != null) @@ -157,7 +158,6 @@ public static ResourceNode GetRaw(DataSource source) public static ResourceNode FromFolder(ResourceNode parent, string path) { - FolderNode node = new FolderNode(); node.Path = path; node.Initialize(parent, new VoidPtr(), 0); diff --git a/BrawlLib/SSBB/ResourceNodes/RSAR/RSARExtFileNode.cs b/BrawlLib/SSBB/ResourceNodes/RSAR/RSARExtFileNode.cs index ae3d33d32..1c823639a 100644 --- a/BrawlLib/SSBB/ResourceNodes/RSAR/RSARExtFileNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/RSAR/RSARExtFileNode.cs @@ -59,8 +59,8 @@ public string FullExtPath else { _extPath = value - .Substring(RootNode._origPath.Substring(0, RootNode._origPath.LastIndexOf('\\')).Length + - 1).Replace('\\', '/'); + .Substring(RootNode._origPath.Substring(0, RootNode._origPath.LastIndexOf('\\')).Length + + 1).Replace('\\', '/'); } SignalPropertyChange(); diff --git a/BrawlLib/SSBB/ResourceNodes/ResourceNode.cs b/BrawlLib/SSBB/ResourceNodes/ResourceNode.cs index 043bddc5c..2375608f5 100644 --- a/BrawlLib/SSBB/ResourceNodes/ResourceNode.cs +++ b/BrawlLib/SSBB/ResourceNodes/ResourceNode.cs @@ -64,9 +64,9 @@ public DataSource(MemoryStream ms) : this(ms, CompressionType.None) public DataSource(MemoryStream ms, CompressionType compression) { ms.Position = 0; - Address = Marshal.AllocHGlobal((int)ms.Length); - Marshal.Copy(ms.ToArray(), 0, Address, (int)ms.Length); - Length = (int)ms.Length; + Address = Marshal.AllocHGlobal((int) ms.Length); + Marshal.Copy(ms.ToArray(), 0, Address, (int) ms.Length); + Length = (int) ms.Length; Map = null; Compression = compression; } @@ -144,7 +144,9 @@ public abstract class ResourceNode : IDisposable #if !DEBUG [Browsable(false)] #endif - public ResourceNode RootNode => _parent == null || _parent == this || _parent is FolderNode ? this : _parent.RootNode; + public ResourceNode RootNode => + _parent == null || _parent == this || _parent is FolderNode ? this : _parent.RootNode; + [Browsable(false)] public DataSource OriginalSource => _origSource; [Browsable(false)] public DataSource UncompressedSource => _uncompSource; [Browsable(false)] public DataSource WorkingSource => _replSrc != DataSource.Empty ? _replSrc : _origSource; @@ -168,7 +170,7 @@ public abstract class ResourceNode : IDisposable #else [Browsable(false)] #endif - public String NodeType => this.GetType().ToString(); + public string NodeType => GetType().ToString(); [Browsable(false)] public virtual string TreePathAbsolute => _parent == null ? Name : _parent.TreePathAbsolute + "/" + Name; @@ -258,9 +260,10 @@ public List GetChildrenRecursive() { Populate(); } + if (Children != null) { - for (int i = 0; i < Children.Count; i++)//ResourceNode r in Children) + for (int i = 0; i < Children.Count; i++) //ResourceNode r in Children) { childrenAndSubchildren.Add(Children[i]); childrenAndSubchildren.AddRange(Children[i].GetChildrenRecursive()); @@ -319,6 +322,7 @@ public virtual bool IsDirty { return false; } + if (HasChanged) { return true; @@ -593,7 +597,7 @@ public void Populate(int levels = -1) } else if (levels < 0) { - for (int i = 0; i < Children.Count; i++ ) + for (int i = 0; i < Children.Count; i++) { Children[i].Populate(); } @@ -872,11 +876,11 @@ public virtual unsafe void Export(string outPath) try { #endif - using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, - FileShare.ReadWrite, 8, FileOptions.SequentialScan)) - { - Export(stream); - } + using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, + FileShare.ReadWrite, 8, FileOptions.SequentialScan)) + { + Export(stream); + } #if !DEBUG } catch @@ -1214,7 +1218,8 @@ public static ResourceNode[] FindAllSubNodes(ResourceNode root) return resourceNodes.ToArray(); } - public static ResourceNode FindNode(ResourceNode root, string path, bool searchChildren, StringComparison compare) + public static ResourceNode FindNode(ResourceNode root, string path, bool searchChildren, + StringComparison compare) { if (string.IsNullOrEmpty(path) || root == null || root.Name.Equals(path, StringComparison.OrdinalIgnoreCase)) @@ -1223,7 +1228,7 @@ public static ResourceNode FindNode(ResourceNode root, string path, bool searchC } if (path.Contains("/") && path.Substring(0, path.IndexOf('/')) - .Equals(root.Name, compare)) + .Equals(root.Name, compare)) { return root.FindChild(path.Substring(path.IndexOf('/') + 1), searchChildren, compare); } @@ -1236,7 +1241,8 @@ public ResourceNode FindChildByType(string path, bool searchChildren, ResourceTy return FindChildByType(path, searchChildren, type, StringComparison.OrdinalIgnoreCase); } - public ResourceNode FindChildByType(string path, bool searchChildren, ResourceType type, StringComparison compare) + public ResourceNode FindChildByType(string path, bool searchChildren, ResourceType type, + StringComparison compare) { if (path == null) { @@ -1288,7 +1294,7 @@ public ResourceNode FindChildByType(string path, bool searchChildren, ResourceTy public ResourceNode FindChild(string path, bool searchChildren) { - return FindChild(path, searchChildren, StringComparison.OrdinalIgnoreCase); + return FindChild(path, searchChildren, StringComparison.OrdinalIgnoreCase); } public ResourceNode FindChild(string path, bool searchChildren, StringComparison compare) @@ -1451,7 +1457,7 @@ public ResourceNode[] FindChildrenByTypeInGroup(string path, ResourceType type, if (tempBres is BRRESNode) { foreach (MDL0Node m in ((BRRESNode) tempBres).GetFolder() - .Children) + .Children) { nodes.Add(m); } diff --git a/BrawlLib/SSBB/ResourceNodes/ResourceType.cs b/BrawlLib/SSBB/ResourceNodes/ResourceType.cs index bb48597c1..f7146ac7f 100644 --- a/BrawlLib/SSBB/ResourceNodes/ResourceType.cs +++ b/BrawlLib/SSBB/ResourceNodes/ResourceType.cs @@ -47,7 +47,7 @@ public enum ResourceType //Misc CollisionDef, - CollisionObj, + CollisionObj, MSBin, STPM, STDT, diff --git a/BrawlLib/System/ActionEventInfo.cs b/BrawlLib/System/ActionEventInfo.cs index 5cbcb8dee..e0ba13f09 100644 --- a/BrawlLib/System/ActionEventInfo.cs +++ b/BrawlLib/System/ActionEventInfo.cs @@ -92,4 +92,4 @@ public override string ToString() public Dictionary> Enums; } -} +} \ No newline at end of file diff --git a/BrawlLib/System/BrawlExDropDownLists.cs b/BrawlLib/System/BrawlExDropDownLists.cs index e967049bc..b7c345082 100644 --- a/BrawlLib/System/BrawlExDropDownLists.cs +++ b/BrawlLib/System/BrawlExDropDownLists.cs @@ -216,7 +216,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(FranchiseIcon.Icons - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -266,7 +267,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlExColorID.Colors - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -316,7 +318,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(RecordBank.Records - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -367,7 +370,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.BrawlCrate.FighterNameGenerators.slotIDList - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -395,7 +399,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (destinationType == typeof(string) && value.GetType() == typeof(byte)) { BrawlLib.SSBB.Fighter fighter = BrawlLib.BrawlCrate.FighterNameGenerators.slotIDList - .Where(s => s.ID == (byte) value).FirstOrDefault(); + .Where(s => s.ID == (byte) value).FirstOrDefault(); return "0x" + ((byte) value).ToString("X2") + (fighter == null ? "" : " - " + fighter.Name); } else if ((destinationType == typeof(int) || destinationType == typeof(byte)) && value != null && @@ -419,7 +423,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.BrawlCrate.FighterNameGenerators.fighterIDLongList - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -447,7 +452,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (destinationType == typeof(string) && value.GetType() == typeof(uint)) { BrawlLib.SSBB.Fighter fighter = BrawlLib.BrawlCrate.FighterNameGenerators.fighterIDLongList - .Where(s => s.ID == (uint) value).FirstOrDefault(); + .Where(s => s.ID == (uint) value).FirstOrDefault(); return "0x" + ((uint) value).ToString("X8") + (fighter == null ? "" : " - " + fighter.Name); } else if ((destinationType == typeof(int) || destinationType == typeof(uint)) && value != null && @@ -470,7 +475,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(AIController.aIControllers - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -520,7 +526,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.BrawlCrate.FighterNameGenerators.cssSlotIDList - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -548,7 +555,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (destinationType == typeof(string) && value.GetType() == typeof(byte)) { BrawlLib.SSBB.Fighter fighter = BrawlLib.BrawlCrate.FighterNameGenerators.cssSlotIDList - .Where(s => s.ID == (byte) value).FirstOrDefault(); + .Where(s => s.ID == (byte) value).FirstOrDefault(); return "0x" + ((byte) value).ToString("X2") + (fighter == null ? "" : " - " + fighter.Name); } else if ((destinationType == typeof(int) || destinationType == typeof(byte)) && value != null && @@ -571,7 +578,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.BrawlCrate.FighterNameGenerators.cosmeticIDList - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -599,7 +607,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (destinationType == typeof(string) && value.GetType() == typeof(byte)) { BrawlLib.SSBB.Fighter fighter = BrawlLib.BrawlCrate.FighterNameGenerators.cosmeticIDList - .Where(s => s.ID == (byte) value).FirstOrDefault(); + .Where(s => s.ID == (byte) value).FirstOrDefault(); return "0x" + ((byte) value).ToString("X2") + (fighter == null ? "" : " - " + fighter.Name); } else if ((destinationType == typeof(int) || destinationType == typeof(byte)) && value != null && diff --git a/BrawlLib/System/Drawing/Imaging/ColorPaletteExtension.cs b/BrawlLib/System/Drawing/Imaging/ColorPaletteExtension.cs index ce96a1f0c..e1e3ef2d6 100644 --- a/BrawlLib/System/Drawing/Imaging/ColorPaletteExtension.cs +++ b/BrawlLib/System/Drawing/Imaging/ColorPaletteExtension.cs @@ -27,7 +27,7 @@ public static ColorPalette CreatePalette(ColorPaletteFlags flags, int entries) public static void SetFlags(this ColorPalette pal, ColorPaletteFlags flags) { typeof(ColorPalette).GetField("flags", BindingFlags.NonPublic | BindingFlags.Instance) - .SetValue(pal, (int) flags); + .SetValue(pal, (int) flags); } public static void Clamp(this ColorPalette pal, WiiPaletteFormat format) diff --git a/BrawlLib/System/DropDownLists.cs b/BrawlLib/System/DropDownLists.cs index f27818056..2e267bd26 100644 --- a/BrawlLib/System/DropDownLists.cs +++ b/BrawlLib/System/DropDownLists.cs @@ -416,7 +416,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex { RSAREntryNode n = context.Instance as RSAREntryNode; return new StandardValuesCollection(n.RSARNode.Files.Where(x => x is RBNKNode || x is RSARExtFileNode) - .Select(r => r.ToString()).ToList()); + .Select(r => r.ToString()).ToList()); } } @@ -476,7 +476,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex { RSARFileEntryNode n = context.Instance as RSARFileEntryNode; return new StandardValuesCollection(n.Parent.Parent.Children[1].Children.Select(r => r.ToString()) - .ToList()); + .ToList()); } } @@ -496,7 +496,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex } return new StandardValuesCollection(n.SoundFileNode.Children[0].Children.Select(r => r.ToString()) - .ToList()); + .ToList()); } } @@ -877,7 +877,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlAITypes.AITypes - .Select(s => "0x" + s.AIID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.AIID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -928,7 +929,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.SSBB.Stage.RelList - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -956,7 +958,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (destinationType == typeof(string) && value != null && value.GetType() == typeof(int)) { BrawlLib.SSBB.Stage stage = BrawlLib.SSBB.Stage.RelList.Where(s => s.ID == (int) value) - .FirstOrDefault(); + .FirstOrDefault(); return "0x" + ((int) value).ToString("X2") + (stage == null ? "" : " - " + stage.Name); } else if ((destinationType == typeof(int) || destinationType == typeof(byte)) && value != null && @@ -979,8 +981,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib - .SSBB.Stage.Stages - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .SSBB.Stage.Stages + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -1025,8 +1027,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib - .SSBB.Item.Items - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .SSBB.Item.Items + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -1071,8 +1073,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib - .SSBB.Fighter.Fighters - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .SSBB.Fighter.Fighters + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) @@ -1118,7 +1120,8 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(BrawlLib.SSBB.Fighter.Fighters - .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name).ToList()); + .Select(s => "0x" + s.ID.ToString("X2") + " - " + s.Name) + .ToList()); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) diff --git a/BrawlLib/System/Event.cs b/BrawlLib/System/Event.cs index 7d732ebfc..dddda4c04 100644 --- a/BrawlLib/System/Event.cs +++ b/BrawlLib/System/Event.cs @@ -33,7 +33,7 @@ public void ResolveEventEvent() lParameters = (eventEvent & 0xFF00) / 0x100; - Array.Resize(ref parameters, (int)lParameters); + Array.Resize(ref parameters, (int) lParameters); for (int i = 0; i < lParameters; i++) { parameters[i] = new Param(); @@ -52,4 +52,4 @@ public class Param public ArgVarType _type; public long _data; } -} +} \ No newline at end of file diff --git a/BrawlLib/System/Helpers.cs b/BrawlLib/System/Helpers.cs index 585ff0057..be4ad78b7 100644 --- a/BrawlLib/System/Helpers.cs +++ b/BrawlLib/System/Helpers.cs @@ -342,12 +342,12 @@ public static string GetComparisonSign(long value) { switch (value) { - case 0: return "<"; - case 1: return "<="; - case 2: return "=="; - case 3: return "!="; - case 4: return ">="; - case 5: return ">"; + case 0: return "<"; + case 1: return "<="; + case 2: return "=="; + case 3: return "!="; + case 4: return ">="; + case 5: return ">"; default: return "(" + value + ")"; } } @@ -409,9 +409,8 @@ public static int TabDownEvents(uint eventId) public static float UnScalar(long value) { - return (float)value / 60000f; + return (float) value / 60000f; } - } public class ReferenceEqualityComparer : EqualityComparer @@ -769,5 +768,4 @@ public enum HitboxSFX SFX254, SFX255 }; - } \ No newline at end of file diff --git a/BrawlLib/System/Windows/Controls/Hex Editor/HexBox.cs b/BrawlLib/System/Windows/Controls/Hex Editor/HexBox.cs index 7befa1f4a..e4a0d63a8 100644 --- a/BrawlLib/System/Windows/Controls/Hex Editor/HexBox.cs +++ b/BrawlLib/System/Windows/Controls/Hex Editor/HexBox.cs @@ -954,7 +954,7 @@ protected bool RaiseKeyUp(Keys keyData) }, // move right with selection { Keys.Down | Keys.Shift, PreProcessWmKeyDown_ShiftDown - }, // move down with selection + }, // move down with selection {Keys.Tab, PreProcessWmKeyDown_Tab}, // switch to string view {Keys.Back, PreProcessWmKeyDown_Back}, // back {Keys.Delete, PreProcessWmKeyDown_Delete}, // delete @@ -962,7 +962,7 @@ protected bool RaiseKeyUp(Keys keyData) {Keys.End, PreProcessWmKeyDown_End}, // move to end { Keys.ShiftKey | Keys.Shift, PreProcessWmKeyDown_ShiftShiftKey - }, // begin selection process + }, // begin selection process {Keys.C | Keys.Control, PreProcessWmKeyDown_ControlC}, // copy {Keys.X | Keys.Control, PreProcessWmKeyDown_ControlX}, // cut {Keys.V | Keys.Control, PreProcessWmKeyDown_ControlV} // paste diff --git a/BrawlLib/System/Windows/Controls/InterpolationViewer.cs b/BrawlLib/System/Windows/Controls/InterpolationViewer.cs index 163206423..5a58a7749 100644 --- a/BrawlLib/System/Windows/Controls/InterpolationViewer.cs +++ b/BrawlLib/System/Windows/Controls/InterpolationViewer.cs @@ -32,7 +32,7 @@ public InterpolationViewer() private const float _lineWidth = 1.5f; //The size of lines private const float _pointWidth = 5.0f; //The size of points - private int _frame; //The current frame index + private int _frame; //The current frame index private int _frameLimit; //The overall number of frames private float _xScale; //Width/Frames ratio diff --git a/BrawlLib/System/Windows/Controls/ModelViewer/Panels/OpenedFilesPanel.cs b/BrawlLib/System/Windows/Controls/ModelViewer/Panels/OpenedFilesPanel.cs index 359e11ba0..9b2e9264a 100644 --- a/BrawlLib/System/Windows/Controls/ModelViewer/Panels/OpenedFilesPanel.cs +++ b/BrawlLib/System/Windows/Controls/ModelViewer/Panels/OpenedFilesPanel.cs @@ -252,27 +252,27 @@ public bool SaveExternal(ResourceNode current, bool As) try { #endif - if (As) + if (As) + { + using (SaveFileDialog d = new SaveFileDialog()) { - using (SaveFileDialog d = new SaveFileDialog()) + d.InitialDirectory = current._origPath.Substring(0, current._origPath.LastIndexOf('\\')); + d.Filter = string.Format("(*{0})|*{0}", Path.GetExtension(current._origPath)); + d.Title = "Please choose a location to save this file."; + if (d.ShowDialog(this) == DialogResult.OK) { - d.InitialDirectory = current._origPath.Substring(0, current._origPath.LastIndexOf('\\')); - d.Filter = string.Format("(*{0})|*{0}", Path.GetExtension(current._origPath)); - d.Title = "Please choose a location to save this file."; - if (d.ShowDialog(this) == DialogResult.OK) - { - current.Merge(); - current.Export(d.FileName); - } + current.Merge(); + current.Export(d.FileName); } } - else - { - current.Merge(); - current.Export(current._origPath); - } + } + else + { + current.Merge(); + current.Export(current._origPath); + } - return true; + return true; #if !DEBUG } catch (Exception x) diff --git a/BrawlLib/System/Windows/Forms/EditAllDialog.cs b/BrawlLib/System/Windows/Forms/EditAllDialog.cs index 02d17cd11..92976bd7f 100644 --- a/BrawlLib/System/Windows/Forms/EditAllDialog.cs +++ b/BrawlLib/System/Windows/Forms/EditAllDialog.cs @@ -109,16 +109,16 @@ public void ShowDialog(IWin32Window owner, ResourceNode resource) public void ShowDialog(IWin32Window owner, IEnumerable nodes) { _nodes = nodes - .Select(n => n as CHR0Node) - .Where(n => n != null) - .ToArray(); + .Select(n => n as CHR0Node) + .Where(n => n != null) + .ToArray(); if (!_nodes.Any()) { editAllCHR0Editor1.OnlyEntryNodesSelected(); _entries = nodes - .Select(n => n as CHR0EntryNode) - .Where(n => n != null) - .ToArray(); + .Select(n => n as CHR0EntryNode) + .Where(n => n != null) + .ToArray(); } _enabled = new bool[5]; diff --git a/BrawlLib/System/Windows/Forms/Moveset/EventModifier.cs b/BrawlLib/System/Windows/Forms/Moveset/EventModifier.cs index d17473eb6..984497087 100644 --- a/BrawlLib/System/Windows/Forms/Moveset/EventModifier.cs +++ b/BrawlLib/System/Windows/Forms/Moveset/EventModifier.cs @@ -143,7 +143,8 @@ private void InitializeComponent() | AnchorStyles.Right); lblParamDescription.BackColor = SystemColors.Control; lblParamDescription.BorderStyle = BorderStyle.Fixed3D; - lblParamDescription.Font = new Font("Microsoft Sans Serif", 9.75F, Drawing.FontStyle.Regular, GraphicsUnit.Point, + lblParamDescription.Font = new Font("Microsoft Sans Serif", 9.75F, Drawing.FontStyle.Regular, + GraphicsUnit.Point, (byte) 0); lblParamDescription.Location = new Drawing.Point(2, 140); lblParamDescription.Name = "lblParamDescription"; @@ -742,7 +743,8 @@ private void offsetOkay_Click(object sender, EventArgs e) } (param._extNode = param.Root._externalRefs[comboBox2.SelectedIndex] as MoveDefExternalNode)._refs - .Add(param); + .Add( + param); } } else diff --git a/BrawlLib/System/Windows/Forms/Moveset/OffsetEditor.cs b/BrawlLib/System/Windows/Forms/Moveset/OffsetEditor.cs index f3c8c147c..f7b501ef2 100644 --- a/BrawlLib/System/Windows/Forms/Moveset/OffsetEditor.cs +++ b/BrawlLib/System/Windows/Forms/Moveset/OffsetEditor.cs @@ -362,7 +362,8 @@ private void button1_Click(object sender, EventArgs e) (_targetNode._extNode = _targetNode.Root._externalRefs[indexBox.SelectedIndex] as MoveDefExternalNode)._refs - .Add(_targetNode); + .Add( + _targetNode); _targetNode.Name = _targetNode._extNode.Name; } } diff --git a/BrawlLib/System/Windows/Forms/Moveset/ScriptEditor.cs b/BrawlLib/System/Windows/Forms/Moveset/ScriptEditor.cs index d1c8ddd2d..261ef9688 100644 --- a/BrawlLib/System/Windows/Forms/Moveset/ScriptEditor.cs +++ b/BrawlLib/System/Windows/Forms/Moveset/ScriptEditor.cs @@ -7,7 +7,6 @@ namespace System.Windows.Forms { - public partial class ScriptEditor : UserControl { #region Designer @@ -52,7 +51,8 @@ private void InitializeComponent() description.BackColor = SystemColors.Control; description.BorderStyle = BorderStyle.Fixed3D; description.Dock = DockStyle.Fill; - description.Font = new Font("Microsoft Sans Serif", 9.75F, Drawing.FontStyle.Regular, GraphicsUnit.Point, (byte) 0); + description.Font = new Font("Microsoft Sans Serif", 9.75F, Drawing.FontStyle.Regular, GraphicsUnit.Point, + (byte) 0); description.Location = new Drawing.Point(0, 25); description.Name = "description"; description.Size = new Drawing.Size(324, 70); diff --git a/BrawlLib/System/Windows/Forms/TextureConverterDialog.cs b/BrawlLib/System/Windows/Forms/TextureConverterDialog.cs index b50d5e643..b92e55f29 100644 --- a/BrawlLib/System/Windows/Forms/TextureConverterDialog.cs +++ b/BrawlLib/System/Windows/Forms/TextureConverterDialog.cs @@ -673,21 +673,21 @@ private void UpdateSize() int palSize = PaletteSize(0x40); lblDataSize.Text = string.Format("{0:n0}B", TextureConverter.Get((WiiPixelFormat) cboFormat.SelectedItem) - .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x40 + palSize); + .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x40 + palSize); } else if (_origREFT != null || _reftParent != null) { int palSize = PaletteSize(0); lblDataSize.Text = string.Format("{0:n0}B", TextureConverter.Get((WiiPixelFormat) cboFormat.SelectedItem) - .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x20 + palSize); + .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x20 + palSize); } else if (_origTPL != null || _tplParent != null) { int palSize = PaletteSize(0xC); lblDataSize.Text = string.Format("{0:n0}B", TextureConverter.Get((WiiPixelFormat) cboFormat.SelectedItem) - .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x28 + palSize); + .GetMipOffset(ref w, ref h, (int) numLOD.Value + 1) + 0x28 + palSize); } } diff --git a/BrawlLib/Wii/Animations/AnimFormat.cs b/BrawlLib/Wii/Animations/AnimFormat.cs index 53f361040..2b9dbec6c 100644 --- a/BrawlLib/Wii/Animations/AnimFormat.cs +++ b/BrawlLib/Wii/Animations/AnimFormat.cs @@ -9,8 +9,8 @@ namespace BrawlLib.Wii.Animations { public class AnimFormat { - private static readonly string[] types = { "scale", "rotate", "translate" }; - private static readonly string[] axes = { "X", "Y", "Z" }; + private static readonly string[] types = {"scale", "rotate", "translate"}; + private static readonly string[] axes = {"X", "Y", "Z"}; public static void Serialize(CHR0Node node, string output) { @@ -23,7 +23,7 @@ public static void Serialize(CHR0Node node, string output) }; if (dlgOpen.ShowDialog() != DialogResult.OK || - (model = (MDL0Node)NodeFactory.FromFile(null, dlgOpen.FileName)) == null) + (model = (MDL0Node) NodeFactory.FromFile(null, dlgOpen.FileName)) == null) { return; } @@ -74,7 +74,7 @@ public static void Serialize(CHR0Node node, string output, MDL0Node model) file.WriteLine(" keys {"); for (KeyframeEntry entry = array._keyRoot._next; entry != array._keyRoot; entry = entry._next) { - float angle = (float)Math.Atan(entry._tangent) * Maths._rad2degf; + float angle = (float) Math.Atan(entry._tangent) * Maths._rad2degf; file.WriteLine(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10};", entry._index, entry._value.ToString(CultureInfo.InvariantCulture.NumberFormat), @@ -99,7 +99,7 @@ public static void Serialize(CHR0Node node, string output, MDL0Node model) public static CHR0Node Read(string input) { - CHR0Node node = new CHR0Node() { _name = Path.GetFileNameWithoutExtension(input) }; + CHR0Node node = new CHR0Node() {_name = Path.GetFileNameWithoutExtension(input)}; using (StreamReader file = new StreamReader(input)) { float start = 0.0f; @@ -145,7 +145,7 @@ public static CHR0Node Read(string input) } } - int frameCount = (int)(end - start + 1.5f); + int frameCount = (int) (end - start + 1.5f); node.FrameCount = frameCount; while (true) @@ -233,7 +233,7 @@ public static CHR0Node Read(string input) if ((e = node.FindChild(bone, false) as CHR0EntryNode) == null) { - e = new CHR0EntryNode() { _name = bone }; + e = new CHR0EntryNode() {_name = bone}; node.AddChild(e); } @@ -327,7 +327,7 @@ public static CHR0Node Read(string input) bool anyFixed = secondFixed || firstFixed; bool bothFixed = secondFixed && firstFixed; - KeyframeEntry x = e.SetKeyframe(mode, (int)(inVal - 0.5f), outVal, true); + KeyframeEntry x = e.SetKeyframe(mode, (int) (inVal - 0.5f), outVal, true); if (!anyFixed) { l.Add(x); @@ -336,16 +336,16 @@ public static CHR0Node Read(string input) { if (bothFixed) { - x._tangent = (float)Math.Tan((angle1 + angle2) / 2 * Maths._deg2radf) * + x._tangent = (float) Math.Tan((angle1 + angle2) / 2 * Maths._deg2radf) * ((weight1 + weight2) / 2); } else if (firstFixed) { - x._tangent = (float)Math.Tan(angle1 * Maths._deg2radf) * weight1; + x._tangent = (float) Math.Tan(angle1 * Maths._deg2radf) * weight1; } else { - x._tangent = (float)Math.Tan(angle2 * Maths._deg2radf) * weight2; + x._tangent = (float) Math.Tan(angle2 * Maths._deg2radf) * weight2; } } } diff --git a/BrawlLib/Wii/Audio/RSARConverter.cs b/BrawlLib/Wii/Audio/RSARConverter.cs index 12d5a3356..fe87e0f33 100644 --- a/BrawlLib/Wii/Audio/RSARConverter.cs +++ b/BrawlLib/Wii/Audio/RSARConverter.cs @@ -478,10 +478,10 @@ internal void SortStrings() for (int i = 0; i < 4; ++i) { _strings.AddRange(_tempStrings - .Where(x => x._type == i) - .OrderBy(x => x._index) - .Select(x => x._name - .ToString())); + .Where(x => x._type == i) + .OrderBy(x => x._index) + .Select(x => x._name + .ToString())); } foreach (string s in _strings) diff --git a/BrawlLib/Wii/Models/ModelEncoder.cs b/BrawlLib/Wii/Models/ModelEncoder.cs index a6d2afa17..4f03f0cdd 100644 --- a/BrawlLib/Wii/Models/ModelEncoder.cs +++ b/BrawlLib/Wii/Models/ModelEncoder.cs @@ -868,7 +868,7 @@ private static void WriteDefs(ModelLinker linker, ref byte* pGroup, ref byte* pD if (mdl._hasOpa && polyList != null) { DrawCall[] objects = polyList.SelectMany(x => ((MDL0ObjectNode) x)._drawCalls) - .Where(x => x.DrawPass == DrawCall.DrawPassType.Opaque).ToArray(); + .Where(x => x.DrawPass == DrawCall.DrawPassType.Opaque).ToArray(); Array.Sort(objects, DrawCall.DrawCompare); @@ -895,7 +895,7 @@ private static void WriteDefs(ModelLinker linker, ref byte* pGroup, ref byte* pD if (mdl._hasXlu && polyList != null) { DrawCall[] objects = polyList.SelectMany(x => ((MDL0ObjectNode) x)._drawCalls) - .Where(x => x.DrawPass == DrawCall.DrawPassType.Transparent).ToArray(); + .Where(x => x.DrawPass == DrawCall.DrawPassType.Transparent).ToArray(); Array.Sort(objects, DrawCall.DrawCompare); diff --git a/BrawlLib/Wii/Models/ModelLinker.cs b/BrawlLib/Wii/Models/ModelLinker.cs index 7a7cc503e..a6bc08cca 100644 --- a/BrawlLib/Wii/Models/ModelLinker.cs +++ b/BrawlLib/Wii/Models/ModelLinker.cs @@ -187,12 +187,12 @@ public void RegenerateBoneCache(bool remake = false) if (remake) { BoneCache = Model._boneGroup.FindChildrenByType(null, ResourceType.MDL0Bone) - .Select(x => x as MDL0BoneNode).ToArray(); + .Select(x => x as MDL0BoneNode).ToArray(); } else { BoneCache = Model._boneGroup.FindChildrenByType(null, ResourceType.MDL0Bone) - .Select(x => x as MDL0BoneNode).OrderBy(x => x.BoneIndex).ToArray(); + .Select(x => x as MDL0BoneNode).OrderBy(x => x.BoneIndex).ToArray(); } } else diff --git a/Updater/Program.cs b/Updater/Program.cs index c4a12627f..6f3339273 100644 --- a/Updater/Program.cs +++ b/Updater/Program.cs @@ -386,7 +386,7 @@ public static async Task CheckCanaryUpdate(string openFile, bool manual, bool fo // The browser download link to the self extracting archive, hosted on github string URL = html.Substring(html.IndexOf("browser_download_url\":\"")) - .TrimEnd('}', '"'); + .TrimEnd('}', '"'); URL = URL.Substring(URL.IndexOf("http")); // Download the update, using a download tracker @@ -479,7 +479,7 @@ public static async Task ForceDownloadDocumentation() string repoName = mainRepo.Split('/')[1]; // get Release IReadOnlyList releases = (await github.Repository.Release.GetAll(repoOwner, repoName)) - .Where(r => r.Prerelease).ToList(); + .Where(r => r.Prerelease).ToList(); Release release = null; // This track is shared by canary updates. Ensure that a documentation release is found. @@ -505,7 +505,7 @@ public static async Task ForceDownloadStable(string openFile) string repoName = mainRepo.Split('/')[1]; // get Release IReadOnlyList releases = (await github.Repository.Release.GetAll(repoOwner, repoName)) - .Where(r => !r.Prerelease).ToList(); + .Where(r => !r.Prerelease).ToList(); if (releases.Count > 0) { await DownloadRelease(releases[0], true, true, false, false, openFile);