Skip to content

Commit

Permalink
Merge main into '3dSkinRenderer'
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Jul 18, 2024
2 parents b512895 + 4c2d68e commit ab03831
Show file tree
Hide file tree
Showing 66 changed files with 761 additions and 636 deletions.
6 changes: 3 additions & 3 deletions PCK-Studio/Extensions/AnimationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static Image CreateAnimationImage(this Animation animation)
}
var ms = new System.IO.MemoryStream();
var generateor = new AnimatedGifCreator(ms, GameConstants.GameTickInMilliseconds, 0);
foreach (var frame in animation.GetInterpolatedFrames())
foreach (Animation.Frame frame in animation.GetInterpolatedFrames())
{
generateor.AddFrame(frame.Texture, frame.Ticks * GameConstants.GameTickInMilliseconds, GifQuality.Bit8);
}
Expand All @@ -36,13 +36,13 @@ internal static JObject ConvertToJavaAnimation(this Animation animation)
mcmeta["comment"] = $"Animation converted with {Application.ProductName}";
mcmeta["animation"] = janimation;
JArray jframes = new JArray();
foreach (var frame in animation.GetFrames())
foreach (Animation.Frame frame in animation.GetFrames())
{
JObject jframe = new JObject();
jframe["index"] = animation.GetTextureIndex(frame.Texture);
jframe["time"] = frame.Ticks;
jframes.Add(jframe);
};
}
janimation["interpolation"] = animation.Interpolate;
janimation["frames"] = jframes;
return mcmeta;
Expand Down
6 changes: 3 additions & 3 deletions PCK-Studio/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class EnumerableExtensions
public static IEnumerable<(int index, T value)>enumerate<T>(this IEnumerable<T> array)
{
int i = 0;
foreach (var item in array)
foreach (T item in array)
{
yield return (i++, item);
}
Expand All @@ -17,7 +17,7 @@ internal static class EnumerableExtensions

public static bool EqualsAny<T>(this T type, params T[] items)
{
foreach (var item in items)
foreach (T item in items)
{
if (item.Equals(type))
return true;
Expand All @@ -27,7 +27,7 @@ public static bool EqualsAny<T>(this T type, params T[] items)

public static bool ContainsAny<T>(this IEnumerable<T> array, params T[] items)
{
foreach (var item in array)
foreach (T item in array)
{
if (items.Contains(item))
return true;
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Extensions/GraphicsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void ApplyConfig(this Graphics graphics, GraphicsConfig config)

internal static Graphics Fill(this Graphics graphics, Rectangle area, Color color)
{
var clip = graphics.Clip;
Region clip = graphics.Clip;
graphics.SetClip(area, CombineMode.Replace);
graphics.Clear(color);
graphics.SetClip(clip, CombineMode.Replace);
Expand Down
4 changes: 2 additions & 2 deletions PCK-Studio/Extensions/ImageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ internal static Image Combine(this IList<Image> sources, ImageLayoutDirection la

using (var graphic = Graphics.FromImage(image))
{
foreach (var (i, texture) in sources.enumerate())
foreach ((int i, Image texture) in sources.enumerate())
{
var info = new ImageSection(texture.Size, i, layoutDirection);
graphic.DrawImage(texture, info.Point);
};
}
}
return image;
}
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Extensions/LocFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class LocFileExtensions
public static void Initialize(this LOCFile locFile, string language, params (string, string)[] locKeyValuePairs)
{
locFile.AddLanguage(language);
foreach (var locKeyValue in locKeyValuePairs)
foreach ((string, string) locKeyValue in locKeyValuePairs)
locFile.AddLocKey(locKeyValue.Item1, locKeyValue.Item2);
}
}
Expand Down
6 changes: 4 additions & 2 deletions PCK-Studio/Extensions/MathExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ internal class MathExtensions
{
internal static T Clamp<T>(T value, T min, T max) where T : IComparable<T>
{
if (value.CompareTo(min) < 0) return min;
if (value.CompareTo(max) > 0) return max;
if (value.CompareTo(min) < 0)
return min;
if (value.CompareTo(max) > 0)
return max;
return value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Extensions/PckAssetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ internal static void DeserializePropertiesFromString(this PckAsset asset, string
internal static string SerializePropertiesToString(this PckAsset asset)
{
StringBuilder builder = new StringBuilder(asset.PropertyCount * 20);
foreach (var property in asset.GetProperties())
foreach (KeyValuePair<string, string> property in asset.GetProperties())
{
builder.AppendLine(property.Key + ": " + property.Value);
}
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Extensions/PckFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static PckAsset CreateNewAssetIf(this PckFile pck, bool condition, stri

internal static PckAsset CreateNewAsset(this PckFile pck, string filename, PckAssetType filetype, IDataFormatWriter writer)
{
var asset = pck.CreateNewAsset(filename, filetype);
PckAsset asset = pck.CreateNewAsset(filename, filetype);
asset.SetData(writer);
return asset;
}
Expand Down
4 changes: 2 additions & 2 deletions PCK-Studio/Extensions/PictureBoxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ internal static class PictureBoxExtensions
{
public static bool IsAnimating(this PictureBox pictureBox)
{
var fi = typeof(PictureBox).GetField("currentlyAnimating", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo fi = typeof(PictureBox).GetField("currentlyAnimating", BindingFlags.NonPublic | BindingFlags.Instance);
return (bool)fi.GetValue(pictureBox);
}

public static void Animate(this PictureBox pictureBox, bool animate)
{
var animateMethod = typeof(PictureBox).GetMethod("Animate", BindingFlags.NonPublic | BindingFlags.Instance,
MethodInfo animateMethod = typeof(PictureBox).GetMethod("Animate", BindingFlags.NonPublic | BindingFlags.Instance,
null, new Type[] { typeof(bool) }, null);
animateMethod.Invoke(pictureBox, new object[] { animate });
}
Expand Down
4 changes: 2 additions & 2 deletions PCK-Studio/Extensions/TreeNodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal static bool IsTagOfType<T>(this TreeNode node) where T : class

internal static bool TryGetTagData<TOut>(this TreeNode node, out TOut tagData) where TOut : class
{
if (node?.Tag is TOut _data)
if (node?.Tag is TOut data)
{
tagData = _data;
tagData = data;
return true;
}
tagData = default;
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/Extensions/TreeViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static TreeNode[] FindPath(this TreeView treeView, string path)
string segment = path.Substring(0, path.IndexOf(treeView.PathSeparator));
if (treeView.Nodes.ContainsKey(segment))
{
var res = treeView.Nodes[segment].GetChildNodes().Where(node => node.FullPath == path).ToArray();
TreeNode[] res = treeView.Nodes[segment].GetChildNodes().Where(node => node.FullPath == path).ToArray();
return res;
}
return Array.Empty<TreeNode>();
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 @@ -148,7 +148,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();
SetNewTexture(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
13 changes: 7 additions & 6 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 @@ -29,8 +28,10 @@ internal partial class FilterPrompt : MetroForm
public string AcceptButtonText { get => acceptButton.Text; set => acceptButton.Text = value; }
public string CancelButtonText { get => cancelButton.Text; set => cancelButton.Text = value; }

private object selectedItem;
public object SelectedItem => selectedItem;
public Color PageBackColor { get; set; } = Color.FromArgb(64, 64, 64);

private object _selectedItem;
public object SelectedItem => _selectedItem;

public int SelectedTabIndex => tabController.SelectedIndex;

Expand All @@ -56,11 +57,11 @@ public TreeView AddFilterPage(string categoryName, string key, FilterPredicate f
var pageView = new TreeView()
{
Dock = DockStyle.Fill,
BackColor = Color.FromArgb(64, 64, 64),
BackColor = PageBackColor,
};
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 @@ -112,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;
}
}
}
1 change: 1 addition & 0 deletions PCK-Studio/Forms/Additional-Popups/Loc/AddLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public AddLanguage(string[] avalibleLanguages)
{
InitializeComponent();
LanguageComboBox.Items.AddRange(avalibleLanguages);
LanguageComboBox.SelectedIndex = 0;
}

private void AddBtn_Click(object sender, EventArgs e)
Expand Down
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
2 changes: 1 addition & 1 deletion PCK-Studio/Forms/Additional-Popups/TextPrompt.resx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<value>165, 23</value>
</data>
<data name="InputTextBox.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
<value>1</value>
</data>
<data name="&gt;&gt;InputTextBox.Name" xml:space="preserve">
<value>InputTextBox</value>
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
Loading

0 comments on commit ab03831

Please sign in to comment.