Skip to content

Commit

Permalink
Format code to conform with code style guide lines
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Jul 16, 2024
1 parent 2dcc2c8 commit c41fecd
Show file tree
Hide file tree
Showing 51 changed files with 535 additions and 445 deletions.
2 changes: 1 addition & 1 deletion PCK-Studio/FileFormats/CSMBFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CSMBPart
public CSMBParentPart Parent = 0;
public float posX, posY, posZ = 0.0f;
public float sizeX, sizeY, sizeZ = 0.0f;
public int uvX, uvY = 0;
public int uvX, uvY = 0;
public bool HideWArmour, MirrorTexture = false;
public float Inflation = 0.0f;
}
Expand Down
8 changes: 5 additions & 3 deletions PCK-Studio/FileFormats/PckAudioFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void AddCredits(params string[] credits)
/// </summary>
public void ApplyCredits(LOCFile locFile)
{
foreach (var credit in Credits)
foreach (KeyValuePair<string, string> credit in Credits)
{
locFile.SetLocEntry(credit.Key, credit.Value);
}
Expand Down Expand Up @@ -135,7 +135,8 @@ public bool AddCategory(AudioCategory.EAudioParameterType parameterType, AudioCa
category > AudioCategory.EAudioType.Unused)
throw new InvalidCategoryException(nameof(category));
bool exists = HasCategory(category);
if (!exists) _categories[(int)category] = new AudioCategory(name, parameterType, category);
if (!exists)
_categories[(int)category] = new AudioCategory(name, parameterType, category);
return !exists;
}

Expand All @@ -149,7 +150,8 @@ public bool AddCategory(AudioCategory.EAudioType category)
public bool RemoveCategory(AudioCategory.EAudioType category)
{
bool exists = HasCategory(category);
if (exists) _categories[(int)category] = null;
if (exists)
_categories[(int)category] = null;
return exists;
}

Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Forms/Additional-Popups/AddSkinPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void skinPictureBox_MouseClick(object sender, MouseEventArgs e)
{
if (ofd.FileName.EndsWith(".3dst"))
{
using (var fs = File.OpenRead(ofd.FileName))
using (FileStream fs = File.OpenRead(ofd.FileName))
{
var reader = new _3DSTextureReader();
CheckImage(reader.FromStream(fs));
Expand Down
4 changes: 2 additions & 2 deletions PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ private void GetTileDataToView(ResourceCategory key)
ResourceCategory.ItemAnimation => (Tiles.ItemTileInfos, Tiles.ItemImageList, "Items"),
_ => throw new InvalidOperationException(nameof(key))
};
var view = filterPrompt.AddFilterPage(name, null, filterPredicate);
TreeView view = filterPrompt.AddFilterPage(name, null, filterPredicate);
view.ImageList = imgList;
foreach ((int i, var tileData) in textureInfos?.enumerate())
foreach ((int i, JsonTileInfo tileData) in textureInfos?.enumerate())
{
if (string.IsNullOrEmpty(tileData.InternalName) || view.Nodes.ContainsKey(tileData.InternalName))
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using MetroFramework.Forms;
using System.Windows.Forms;
using System.Diagnostics;

namespace PckStudio.Forms.Additional_Popups.Animation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using MetroFramework.Forms;
using System.Windows.Forms;
using MetroFramework.Forms;

namespace PckStudio.Forms.Additional_Popups.Animation
{
Expand Down
6 changes: 3 additions & 3 deletions PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public AddEntry(string dataType, System.Drawing.Image[] entityImages)
{
filterPrompt = new FilterPrompt();
filterPrompt.OnSelectedItemChanged += FilterPrompt_OnSelectedItemChanged;
var treeViewEntity = filterPrompt.AddFilterPage("Entities", null, filterPredicate);
TreeView treeViewEntity = filterPrompt.AddFilterPage("Entities", null, filterPredicate);
ImageList entities = new ImageList();
entities.ColorDepth = ColorDepth.Depth32Bit;
entities.ImageSize = new System.Drawing.Size(32, 32);
entities.Images.AddRange(entityImages);
treeViewEntity.ImageList = entities;

var entityInfos = dataType switch
List<EntityInfo> entityInfos = dataType switch
{
"models" => Entities.ModelInfos,
"materials" => Entities.MaterialInfos,
Expand All @@ -36,7 +36,7 @@ public AddEntry(string dataType, System.Drawing.Image[] entityImages)

int i = 0;

foreach(var entity in entityInfos)
foreach(EntityInfo entity in entityInfos)
{
TreeNode entityNode = new TreeNode(entity.DisplayName)
{
Expand Down
9 changes: 4 additions & 5 deletions PCK-Studio/Forms/Additional-Popups/FilterPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
**/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using MetroFramework.Forms;
Expand All @@ -31,8 +30,8 @@ internal partial class FilterPrompt : MetroForm

public Color PageBackColor { get; set; } = Color.FromArgb(64, 64, 64);

private object selectedItem;
public object SelectedItem => selectedItem;
private object _selectedItem;
public object SelectedItem => _selectedItem;

public int SelectedTabIndex => tabController.SelectedIndex;

Expand Down Expand Up @@ -62,7 +61,7 @@ public TreeView AddFilterPage(string categoryName, string key, FilterPredicate f
};
pageView.AfterSelect += (sender, e) =>
{
selectedItem = e.Node.Tag;
_selectedItem = e.Node.Tag;
Events[nameof(OnSelectedItemChanged)]?.DynamicInvoke(this, EventArgs.Empty);
};
pageView.Tag = new List<TreeNode>(4);
Expand Down Expand Up @@ -114,7 +113,7 @@ private void CancelBtn_Click(object sender, EventArgs e)

private void AcceptBtn_Click(object sender, EventArgs e)
{
DialogResult = selectedItem is null ? DialogResult.Cancel : DialogResult.OK;
DialogResult = _selectedItem is null ? DialogResult.Cancel : DialogResult.OK;
}
}
}
3 changes: 2 additions & 1 deletion PCK-Studio/Forms/Additional-Popups/TextPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private void OKBtn_Click(object sender, EventArgs e)
{
MessageBox.Show(this, "Please insert a value in the text box.", "Empty string");
}
else DialogResult = DialogResult.OK;
else
DialogResult = DialogResult.OK;
}

private void RenamePrompt_Load(object sender, EventArgs e)
Expand Down
5 changes: 1 addition & 4 deletions PCK-Studio/Forms/ContributorsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public partial class ContributorsForm : MetroForm
public ContributorsForm()
{
InitializeComponent();
#if false
Task.Run(GetContributors);
#endif
string buildConfig = "";
#if BETA
buildConfig = "Beta";
Expand All @@ -33,7 +30,7 @@ public ContributorsForm()
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
foreach (var contributorsName in ApplicationScope.Contributors)
foreach (Octokit.RepositoryContributor contributorsName in ApplicationScope.Contributors)
{
if (InvokeRequired)
Invoke(() => contributorsLayoutPanel.Controls.Add(new GithubUserPanel(contributorsName)));
Expand Down
76 changes: 45 additions & 31 deletions PCK-Studio/Forms/Editor/ANIMEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class ANIMEditor : MetroFramework.Forms.MetroForm

sealed class ANIMRuleSet
{
public SkinANIM Value => anim;
public SkinANIM Value => _anim;
public Action<SkinANIM> OnCheckboxChanged;

private class Bictionary<T1, T2> : Dictionary<T1, T2>
Expand All @@ -41,15 +41,15 @@ public T1 this[T2 index]

internal void AddRange(IEnumerable<(T1, T2)> range)
{
foreach (var (key, value) in range)
foreach ((T1 key, T2 value) in range)
{
Add(key, value);
}
}
}
private Bictionary<CheckBox, SkinAnimFlag> checkBoxLinkage;
private SkinANIM anim;
private bool ignoreCheckChanged = false;
private SkinANIM _anim;
private bool _ignoreCheckChanged = false;

public ANIMRuleSet(params (CheckBox, SkinAnimFlag)[] linkage)
{
Expand All @@ -58,15 +58,15 @@ public ANIMRuleSet(params (CheckBox, SkinAnimFlag)[] linkage)
Debug.WriteLine($"Not all {nameof(SkinAnimFlag)} are mapped to a given checkbox.");

checkBoxLinkage.AddRange(linkage);
foreach (var (checkbox, _) in linkage)
foreach ((CheckBox checkbox, SkinAnimFlag _) in linkage)
{
checkbox.CheckedChanged += checkedChanged;
}
}

internal void SetAll(bool state)
{
foreach (var item in checkBoxLinkage)
foreach (KeyValuePair<CheckBox, SkinAnimFlag> item in checkBoxLinkage)
{
IgnoreAndDo(item.Key, checkbox =>
{
Expand All @@ -84,33 +84,36 @@ internal void SetAll(bool state)
break;
case SkinAnimFlag.RESOLUTION_64x64:
checkbox.Enabled = !state;
if(state) checkbox.Checked = false; // Prioritize slim model > classic model, LCE would
// Prioritize slim model > classic model, LCE would
if(state)
checkbox.Checked = false;
break;
}
anim.SetFlag(item.Value, checkbox.Checked);
_anim.SetFlag(item.Value, checkbox.Checked);
});
}
OnCheckboxChanged?.Invoke(anim);
OnCheckboxChanged?.Invoke(_anim);
}

internal void ApplyAnim(SkinANIM anim)
{
this.anim = anim;
foreach (var item in checkBoxLinkage)
this._anim = anim;
foreach (KeyValuePair<CheckBox, SkinAnimFlag> item in checkBoxLinkage)
{
/*
* not the best way to do this but whatever lol
* fix for both model flags being unset when both are set to true, with slim model prioritized of course
*/
if (item.Value == SkinAnimFlag.RESOLUTION_64x64 && anim.GetFlag(SkinAnimFlag.SLIM_MODEL)) continue;
if (item.Value == SkinAnimFlag.RESOLUTION_64x64 && anim.GetFlag(SkinAnimFlag.SLIM_MODEL))
continue;

item.Key.Checked = anim.GetFlag(item.Value);
}
}

private void checkedChanged(object sender, EventArgs e)
{
if (!ignoreCheckChanged && sender is CheckBox checkBox && checkBoxLinkage.ContainsKey(checkBox))
if (!_ignoreCheckChanged && sender is CheckBox checkBox && checkBoxLinkage.ContainsKey(checkBox))
{
switch (checkBoxLinkage[checkBox])
{
Expand Down Expand Up @@ -151,8 +154,8 @@ private void checkedChanged(object sender, EventArgs e)
default:
break;
}
anim.SetFlag(checkBoxLinkage[checkBox], checkBox.Checked && checkBox.Enabled);
OnCheckboxChanged?.Invoke(anim);
_anim.SetFlag(checkBoxLinkage[checkBox], checkBox.Checked && checkBox.Enabled);
OnCheckboxChanged?.Invoke(_anim);
}
}

Expand All @@ -163,9 +166,9 @@ private void Uncheck(CheckBox checkBox)

private void IgnoreAndDo(CheckBox checkBox, Action<CheckBox> action)
{
ignoreCheckChanged = true;
_ignoreCheckChanged = true;
action.Invoke(checkBox);
ignoreCheckChanged = false;
_ignoreCheckChanged = false;
}
}

Expand All @@ -176,14 +179,14 @@ private ANIMEditor()
saveButton.Visible = !Settings.Default.AutoSaveChanges;
}

public ANIMEditor(string ANIM) : this()
public ANIMEditor(string animString) : this()
{
if (!SkinANIM.IsValidANIM(ANIM))
if (!SkinANIM.IsValidANIM(animString))
{
DialogResult = DialogResult.Abort;
Close();
}
var anim = initialANIM = SkinANIM.FromString(ANIM);
SkinANIM anim = initialANIM = SkinANIM.FromString(animString);
setDisplayAnim(anim);
ruleset.ApplyAnim(anim);
}
Expand Down Expand Up @@ -254,15 +257,17 @@ private void importButton_Click(object sender, EventArgs e)
string value = string.Empty;
while (!SkinANIM.IsValidANIM(value))
{
if (!string.IsNullOrWhiteSpace(value)) MessageBox.Show(this, $"The following value \"{value}\" is not valid. Please try again.");
if (!string.IsNullOrWhiteSpace(value))
MessageBox.Show(this, $"The following value \"{value}\" is not valid. Please try again.");
TextPrompt diag = new TextPrompt(value);
diag.LabelText = "ANIM";
diag.OKButtonText = "Ok";
if (diag.ShowDialog(this) == DialogResult.OK)
{
value = diag.NewText;
}
else return;
else
return;
}
ruleset.ApplyAnim(SkinANIM.FromString(value));
}
Expand Down Expand Up @@ -306,15 +311,24 @@ private void exportButton_Click(object sender, EventArgs e)
graphic.FillRectangle(Brushes.Magenta, new Rectangle(16, 16, 24, 16));
if (img.Height == 64)
{
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(40, 16, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 16, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.BODY_OVERLAY_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(16, 32, 24, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_ARM_OVERLAY_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(40, 32, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_LEG_OVERLAY_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 32, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_LEG_OVERLAY_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(16, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(32, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_ARM_OVERLAY_DISABLED)) graphic.FillRectangle(Brushes.Magenta, new Rectangle(48, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(40, 16, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 16, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.BODY_OVERLAY_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(16, 32, 24, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_ARM_OVERLAY_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(40, 32, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.RIGHT_LEG_OVERLAY_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 32, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_LEG_OVERLAY_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(0, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(16, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(32, 48, 16, 16));
if (ruleset.Value.GetFlag(SkinAnimFlag.LEFT_ARM_OVERLAY_DISABLED))
graphic.FillRectangle(Brushes.Magenta, new Rectangle(48, 48, 16, 16));
}
else
{
Expand Down
Loading

0 comments on commit c41fecd

Please sign in to comment.