This commit is contained in:
PhoenixARC
2021-06-20 10:55:29 -04:00
parent 85d7dc3d6e
commit 6b68cb9b97
65 changed files with 18039 additions and 3695 deletions

View File

@@ -0,0 +1,84 @@
using System;
using System.IO;
using System.Drawing;
using MinecraftUSkinEditor.Models;
using PckStudio.Properties;
namespace MinecraftUSkinEditor.Models
{
internal class CharacterModel : ModelBase
{
public CharacterModel()
{
}
protected override Texture[] InitializeTextures()
{
return new Texture[]
{
new Texture(PckStudio.Properties.Resources.man)
};
}
public override void AddToModelView(MinecraftModelView modelView)
{
System.Drawing.Image source = base.Textures[0].Source;
Object3D object3D = new Box(source, new System.Drawing.Rectangle(8, 0, 0x10, 8), new System.Drawing.Rectangle(0, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
Object3D object3D2 = new Box(source, new System.Drawing.Rectangle(0x28, 0, 0x10, 8), new System.Drawing.Rectangle(0x20, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
Object3D object3D3 = new Box(source, new System.Drawing.Rectangle(0x2C, 0x10, 8, 4), new System.Drawing.Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.FlipHorizontally);
Object3D object3D4 = new Box(source, new System.Drawing.Rectangle(0x2C, 0x10, 8, 4), new System.Drawing.Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.None);
Object3D object3D5 = new Box(source, new System.Drawing.Rectangle(4, 0x10, 8, 4), new System.Drawing.Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.FlipHorizontally);
Object3D object3D6 = new Box(source, new System.Drawing.Rectangle(4, 0x10, 8, 4), new System.Drawing.Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.None);
Object3D object3D7 = new Box(source, new System.Drawing.Rectangle(0x14, 0x10, 0x10, 4), new System.Drawing.Rectangle(0x10, 0x14, 0x18, 0xC), new Point3D(0f, 0f, 0f), Effects.None);
Object3DGroup object3DGroup = new Object3DGroup();
object3D2.Scale = 1.16f;
object3DGroup.RotationOrder = RotationOrders.XY;
object3DGroup.MinDegrees1 = -80f;
object3DGroup.MaxDegrees1 = 80f;
object3DGroup.MinDegrees2 = -57f;
object3DGroup.MaxDegrees2 = 57f;
object3DGroup.Add(object3D);
object3DGroup.Add(object3D2);
object3DGroup.Position = new Point3D(0f, 8f, 0f);
object3DGroup.Origin = new Point3D(0f, -4f, 0f);
object3DGroup.RotationOrder = RotationOrders.XY;
object3D7.Position = new Point3D(0f, 2f, 0f);
object3D3.Position = new Point3D(6f, 6f, 0f);
object3D3.RotationOrder = RotationOrders.ZX;
object3D3.MinDegrees1 = 0f;
object3D3.MaxDegrees1 = 160f;
object3D3.MinDegrees2 = -170f;
object3D3.MaxDegrees2 = 60f;
object3D4.Position = new Point3D(-6f, 6f, 0f);
object3D4.RotationOrder = RotationOrders.ZX;
object3D4.MinDegrees1 = -160f;
object3D4.MaxDegrees1 = 0f;
object3D4.MinDegrees2 = -170f;
object3D4.MaxDegrees2 = 60f;
object3D5.Position = new Point3D(2f, -4f, 0f);
object3D5.RotationOrder = RotationOrders.ZX;
object3D5.MinDegrees1 = 0f;
object3D5.MaxDegrees1 = 70f;
object3D5.MinDegrees2 = -110f;
object3D5.MaxDegrees2 = 60f;
object3D6.Position = new Point3D(-2f, -4f, 0f);
object3D6.RotationOrder = RotationOrders.ZX;
object3D6.MinDegrees1 = -70f;
object3D6.MaxDegrees1 = 0f;
object3D6.MinDegrees2 = -110f;
object3D6.MaxDegrees2 = 60f;
modelView.AddDynamic(object3DGroup);
modelView.AddStatic(object3D7);
modelView.AddDynamic(object3D4);
modelView.AddDynamic(object3D3);
modelView.AddDynamic(object3D6);
modelView.AddDynamic(object3D5);
}
public override string ToString()
{
return "Character";
}
}
}

View File

@@ -0,0 +1,85 @@
using System;
using MinecraftUSkinEditor.Models;
using System.Runtime.CompilerServices;
using System.Threading;
namespace MinecraftUSkinEditor.Models
{
public abstract class ModelBase
{
public ModelBase()
{
textures = InitializeTextures();
foreach (Texture texture in textures)
{
texture.Updatedx += delegate(object sender, System.EventArgs args)
{
OnUpdated();
};
}
}
public Texture[] textures;
public System.EventHandler Updated;
public Texture[] Textures
{
get
{
return textures;
}
}
public event System.EventHandler Updatedx
{
add
{
System.EventHandler eventHandler = Updated;
System.EventHandler eventHandler2;
do
{
eventHandler2 = eventHandler;
System.EventHandler value2 = (System.EventHandler)System.Delegate.Combine(eventHandler2, value);
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref Updated, value2, eventHandler2);
}
while (eventHandler != eventHandler2);
}
remove
{
System.EventHandler eventHandler = Updated;
System.EventHandler eventHandler2;
do
{
eventHandler2 = eventHandler;
System.EventHandler value2 = (System.EventHandler)System.Delegate.Remove(eventHandler2, value);
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref Updated, value2, eventHandler2);
}
while (eventHandler != eventHandler2);
}
}
protected void OnUpdated()
{
if (Updated != null)
{
Updated(this, System.EventArgs.Empty);
}
}
protected abstract Texture[] InitializeTextures();
public abstract void AddToModelView(MinecraftModelView modelView);
[System.Runtime.CompilerServices.CompilerGenerated]
private void b__0(object sender, System.EventArgs args)
{
OnUpdated();
}
}
}

View File

@@ -0,0 +1,140 @@
using System;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
namespace MinecraftUSkinEditor.Models
{
public class Texture
{
public System.Drawing.Size Size
{
get
{
return this.defaultSource.Size;
}
}
public int Width
{
get
{
return this.defaultSource.Width;
}
}
public int Height
{
get
{
return this.defaultSource.Height;
}
}
public System.Drawing.Image Source
{
get
{
if (this.customSource != null)
{
return this.customSource;
}
return this.defaultSource;
}
set
{
if (value == this.customSource)
{
return;
}
if (value == null)
{
this.customSource = null;
}
else
{
if (value.Width != this.defaultSource.Width || value.Height != this.defaultSource.Height)
{
throw new System.ArgumentException("Tekstura ma nieodpowiedni rozmiar");
}
this.customSource = value;
}
this.OnUpdated();
}
}
public string FileName
{
[System.Runtime.CompilerServices.CompilerGenerated]
get
{
return this.k__BackingField;
}
[System.Runtime.CompilerServices.CompilerGenerated]
set
{
this.k__BackingField = value;
}
}
public event System.EventHandler Updatedx
{
add
{
System.EventHandler eventHandler = this.Updated;
System.EventHandler eventHandler2;
do
{
eventHandler2 = eventHandler;
System.EventHandler value2 = (System.EventHandler)System.Delegate.Combine(eventHandler2, value);
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref this.Updated, value2, eventHandler2);
}
while (eventHandler != eventHandler2);
}
remove
{
System.EventHandler eventHandler = this.Updated;
System.EventHandler eventHandler2;
do
{
eventHandler2 = eventHandler;
System.EventHandler value2 = (System.EventHandler)System.Delegate.Remove(eventHandler2, value);
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref this.Updated, value2, eventHandler2);
}
while (eventHandler != eventHandler2);
}
}
protected void OnUpdated()
{
if (this.Updated != null)
{
this.Updated(this, System.EventArgs.Empty);
}
}
public Texture(System.Drawing.Image defaultSource)
{
this.defaultSource = defaultSource;
}
public override string ToString()
{
if (this.customSource != null)
{
return System.IO.Path.GetFileName(this.FileName);
}
return this.defaultSource.Width + " x " + this.defaultSource.Height;
}
private System.Drawing.Image defaultSource;
private System.Drawing.Image customSource;
private System.EventHandler Updated;
[System.Runtime.CompilerServices.CompilerGenerated]
private string k__BackingField;
}
}

View File

@@ -0,0 +1,195 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using MinecraftUSkinEditor.Models;
using PckStudio.Properties;
namespace MinecraftUSkinEditor.Models
{
public class TextureSelector : global::System.Windows.Forms.UserControl
{
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.textureNameBox = new global::System.Windows.Forms.TextBox();
this.browseButton = new global::System.Windows.Forms.Button();
this.openFileDialog = new global::System.Windows.Forms.OpenFileDialog();
this.reloadButton = new global::System.Windows.Forms.Button();
base.SuspendLayout();
this.textureNameBox.Anchor = (global::System.Windows.Forms.AnchorStyles.Top | global::System.Windows.Forms.AnchorStyles.Left | global::System.Windows.Forms.AnchorStyles.Right);
this.textureNameBox.Enabled = false;
this.textureNameBox.Location = new global::System.Drawing.Point(3, 5);
this.textureNameBox.Name = "textureNameBox";
this.textureNameBox.Size = new global::System.Drawing.Size(0x86, 0x14);
this.textureNameBox.TabIndex = 0;
this.browseButton.Anchor = (global::System.Windows.Forms.AnchorStyles.Top | global::System.Windows.Forms.AnchorStyles.Right);
this.browseButton.Location = new global::System.Drawing.Point(0x8F, 3);
this.browseButton.Name = "browseButton";
this.browseButton.Size = new global::System.Drawing.Size(0x20, 0x17);
this.browseButton.TabIndex = 1;
this.browseButton.Text = "...";
this.browseButton.UseVisualStyleBackColor = true;
this.browseButton.Click += this.OnBrowseButtonClick;
this.openFileDialog.DefaultExt = "png";
this.openFileDialog.Filter = "PNG (*.png)|*.png";
this.reloadButton.Anchor = (global::System.Windows.Forms.AnchorStyles.Top | global::System.Windows.Forms.AnchorStyles.Right);
this.reloadButton.Enabled = false;
this.reloadButton.Image = global::PckStudio.Properties.Resources.BINKA_ICON;
this.reloadButton.Location = new global::System.Drawing.Point(0xB5, 3);
this.reloadButton.Name = "reloadButton";
this.reloadButton.Size = new global::System.Drawing.Size(0x20, 0x17);
this.reloadButton.TabIndex = 1;
this.reloadButton.UseVisualStyleBackColor = true;
this.reloadButton.Click += this.OnReloadButtonClick;
this.AllowDrop = true;
base.AutoScaleDimensions = new global::System.Drawing.SizeF(6f, 13f);
base.AutoScaleMode = global::System.Windows.Forms.AutoScaleMode.Font;
base.Controls.Add(this.reloadButton);
base.Controls.Add(this.browseButton);
base.Controls.Add(this.textureNameBox);
base.Margin = new global::System.Windows.Forms.Padding(0);
base.Name = "TextureSelector";
base.Size = new global::System.Drawing.Size(0xD8, 0x20);
base.ResumeLayout(false);
base.PerformLayout();
}
public global::MinecraftUSkinEditor.Models.Texture Texture
{
get
{
return this.texture;
}
set
{
this.texture = value;
this.UpdateTextureName();
this.UpdateReloadButton();
}
}
private void UpdateTextureName()
{
this.textureNameBox.Text = this.texture.ToString();
}
private void UpdateReloadButton()
{
this.reloadButton.Enabled = (this.texture != null && !string.IsNullOrEmpty(this.texture.FileName));
}
public TextureSelector()
{
this.InitializeComponent();
global::System.Windows.Forms.ToolTip toolTip = new global::System.Windows.Forms.ToolTip();
toolTip.SetToolTip(this.browseButton, "Browse...");
toolTip.SetToolTip(this.reloadButton, "Reload texture");
}
private void OnBrowseButtonClick(object sender, global::System.EventArgs e)
{
if (this.openFileDialog.ShowDialog() == global::System.Windows.Forms.DialogResult.OK)
{
string fileName = this.openFileDialog.FileName;
using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(fileName))
{
global::System.Drawing.Image image = global::System.Drawing.Image.FromStream(fileStream);
if (image.Width != this.texture.Width || image.Height != this.texture.Height)
{
global::System.Windows.Forms.MessageBox.Show("Image '" + global::System.IO.Path.GetFileName(fileName) + "' has wrong size.", "Minecraft Skin Viewer Extended", global::System.Windows.Forms.MessageBoxButtons.OK, global::System.Windows.Forms.MessageBoxIcon.Hand);
}
else
{
this.texture.Source = image;
this.texture.FileName = fileName;
this.UpdateTextureName();
this.reloadButton.Enabled = true;
}
}
}
}
private void OnReloadButtonClick(object sender, global::System.EventArgs e)
{
if (this.texture == null || this.texture.Source == null)
{
this.reloadButton.Enabled = false;
return;
}
string fileName = this.texture.FileName;
if (!global::System.IO.File.Exists(fileName))
{
global::System.Windows.Forms.MessageBox.Show("Image '" + global::System.IO.Path.GetFileName(fileName) + "' not found.", "Minecraft Skin Viewer Extended", global::System.Windows.Forms.MessageBoxButtons.OK, global::System.Windows.Forms.MessageBoxIcon.Hand);
return;
}
using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(fileName))
{
global::System.Drawing.Image image = global::System.Drawing.Image.FromStream(fileStream);
if (image.Width != this.texture.Width || image.Height != this.texture.Height)
{
global::System.Windows.Forms.MessageBox.Show("Image '" + global::System.IO.Path.GetFileName(fileName) + "' has wrong size.", "Minecraft Skin Viewer Extended", global::System.Windows.Forms.MessageBoxButtons.OK, global::System.Windows.Forms.MessageBoxIcon.Hand);
}
else
{
this.texture.Source = image;
this.UpdateTextureName();
}
}
}
protected override void OnDragEnter(global::System.Windows.Forms.DragEventArgs drgevent)
{
if (drgevent.Data.GetDataPresent(global::System.Windows.Forms.DataFormats.FileDrop))
{
string[] array = (string[])drgevent.Data.GetData(global::System.Windows.Forms.DataFormats.FileDrop, false);
if (array.Length == 1 && array[0].EndsWith(".PNG", true, global::System.Globalization.CultureInfo.CurrentCulture))
{
drgevent.Effect = global::System.Windows.Forms.DragDropEffects.Copy;
}
}
}
protected override void OnDragDrop(global::System.Windows.Forms.DragEventArgs drgevent)
{
string text = ((string[])drgevent.Data.GetData(global::System.Windows.Forms.DataFormats.FileDrop, false))[0];
using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(text))
{
global::System.Drawing.Image image = global::System.Drawing.Image.FromStream(fileStream);
if (image.Width != this.texture.Width || image.Height != this.texture.Height)
{
global::System.Windows.Forms.MessageBox.Show("Image '" + global::System.IO.Path.GetFileName(text) + "' has wrong size.", "Minecraft Skin Viewer Extended", global::System.Windows.Forms.MessageBoxButtons.OK, global::System.Windows.Forms.MessageBoxIcon.Hand);
}
else
{
this.texture.Source = image;
this.texture.FileName = text;
this.UpdateTextureName();
this.reloadButton.Enabled = true;
}
}
}
private global::System.ComponentModel.IContainer components;
private global::System.Windows.Forms.TextBox textureNameBox;
private global::System.Windows.Forms.Button browseButton;
private global::System.Windows.Forms.OpenFileDialog openFileDialog;
private global::System.Windows.Forms.Button reloadButton;
private global::MinecraftUSkinEditor.Models.Texture texture;
}
}