diff --git a/WzComparerR2.Common/Animation/SpineAnimationData.cs b/WzComparerR2.Common/Animation/SpineAnimationData.cs index bca1900d..f04ed4c0 100644 --- a/WzComparerR2.Common/Animation/SpineAnimationData.cs +++ b/WzComparerR2.Common/Animation/SpineAnimationData.cs @@ -19,6 +19,7 @@ private SpineAnimationData() public bool PremultipliedAlpha { get; set; } public SkeletonData SkeletonData { get; private set; } + public string DefaultSkin { get; set; } public static SpineAnimationData CreateFromNode(Wz_Node atlasNode, bool? useJson, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode) { diff --git a/WzComparerR2.Common/Animation/SpineAnimator.cs b/WzComparerR2.Common/Animation/SpineAnimator.cs index 64ed363f..79f1771c 100644 --- a/WzComparerR2.Common/Animation/SpineAnimator.cs +++ b/WzComparerR2.Common/Animation/SpineAnimator.cs @@ -25,6 +25,8 @@ public SpineAnimator(SpineAnimationData data) public ReadOnlyCollection Animations { get; private set; } + public ReadOnlyCollection Skins { get; private set; } + public int SelectedAnimationIndex { get @@ -75,6 +77,12 @@ public string SelectedAnimationName } } + public string SelectedSkin + { + get { return this.Skeleton.Skin?.Name; } + set { this.Skeleton.SetSkin(value); } + } + public int CurrentTime { get { return (int)((this._animationState?.GetCurrent(0)?.Time ?? 0) * 1000); } @@ -269,10 +277,20 @@ private LinkedList GetTimeLineKeyFrames(Timeline timeLine) private void Load() { this.Skeleton = new Skeleton(this.Data.SkeletonData); - IList aniNames = this.Data.SkeletonData.Animations.Select(ani => ani.Name).ToArray(); + IList aniNames = this.Data.SkeletonData.Animations.Select(ani => ani.Name).ToList(); this.Animations = new ReadOnlyCollection(aniNames); this._animationState = new AnimationState(new AnimationStateData(this.Data.SkeletonData)); - + this.Skins = new ReadOnlyCollection(this.Data.SkeletonData.Skins.Select(skin => skin.Name).ToList()); + + if (!string.IsNullOrEmpty(this.Data.DefaultSkin)) + { + var skin = this.Skeleton.Data.FindSkin(this.Data.DefaultSkin); + if (skin != null) + { + this.Skeleton.SetSkin(skin); + } + } + if (this.Animations.Count > 0) { this.SelectedAnimationIndex = 0; diff --git a/WzComparerR2/MainForm.Designer.cs b/WzComparerR2/MainForm.Designer.cs index 4d232070..7ca14dd1 100644 --- a/WzComparerR2/MainForm.Designer.cs +++ b/WzComparerR2/MainForm.Designer.cs @@ -159,6 +159,7 @@ private void InitializeComponent() this.pictureBoxEx1 = new WzComparerR2.PictureBoxEx(); this.ribbonBar5 = new DevComponents.DotNetBar.RibbonBar(); this.cmbItemAniNames = new DevComponents.DotNetBar.ComboBoxItem(); + this.cmbItemSkins = new DevComponents.DotNetBar.ComboBoxItem(); this.buttonItemSaveImage = new DevComponents.DotNetBar.ButtonItem(); this.itemContainer27 = new DevComponents.DotNetBar.ItemContainer(); this.buttonItemAutoSave = new DevComponents.DotNetBar.ButtonItem(); @@ -194,6 +195,7 @@ private void InitializeComponent() this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.superTabItem1 = new DevComponents.DotNetBar.SuperTabItem(); this.superTabControlPanel2 = new DevComponents.DotNetBar.SuperTabControlPanel(); + this.chkResolvePngLink = new DevComponents.DotNetBar.Controls.CheckBoxX(); this.chkOutputRemovedImg = new DevComponents.DotNetBar.Controls.CheckBoxX(); this.chkOutputAddedImg = new DevComponents.DotNetBar.Controls.CheckBoxX(); this.labelX1 = new DevComponents.DotNetBar.LabelX(); @@ -243,7 +245,6 @@ private void InitializeComponent() this.dockSite3 = new DevComponents.DotNetBar.DockSite(); this.dockContainerItem2 = new DevComponents.DotNetBar.DockContainerItem(); this.panelDockContainer2 = new DevComponents.DotNetBar.PanelDockContainer(); - this.chkResolvePngLink = new DevComponents.DotNetBar.Controls.CheckBoxX(); this.ribbonControl1.SuspendLayout(); this.ribbonPanel2.SuspendLayout(); this.ribbonPanel1.SuspendLayout(); @@ -1655,10 +1656,10 @@ private void InitializeComponent() // this.btnItemOptions.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText; this.btnItemOptions.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnItemOptions.Name = "buttonItem12"; + this.btnItemOptions.Name = "btnItemOptions"; this.btnItemOptions.SubItemsExpandWidth = 24; this.btnItemOptions.Text = "Opt&ions"; - this.btnItemOptions.Click += new System.EventHandler(btnItemOptions_Click); + this.btnItemOptions.Click += new System.EventHandler(this.btnItemOptions_Click); // // buttonItem13 // @@ -1794,8 +1795,8 @@ private void InitializeComponent() this.superTabControl1.ControlBox.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] { this.superTabControl1.ControlBox.MenuBox, this.superTabControl1.ControlBox.CloseBox}); - this.superTabControl1.Controls.Add(this.superTabControlPanel2); this.superTabControl1.Controls.Add(this.superTabControlPanel1); + this.superTabControl1.Controls.Add(this.superTabControlPanel2); this.superTabControl1.Controls.Add(this.superTabControlPanel3); this.superTabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.superTabControl1.Location = new System.Drawing.Point(0, 0); @@ -1880,6 +1881,7 @@ private void InitializeComponent() this.ribbonBar5.DragDropSupport = true; this.ribbonBar5.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { this.cmbItemAniNames, + this.cmbItemSkins, this.buttonItemSaveImage, this.buttonItemGif}); this.ribbonBar5.Location = new System.Drawing.Point(0, 202); @@ -1907,6 +1909,16 @@ private void InitializeComponent() this.cmbItemAniNames.Name = "cmbItemAniNames"; this.cmbItemAniNames.SelectedIndexChanged += new System.EventHandler(this.cmbItemAniNames_SelectedIndexChanged); // + // cmbItemSkins + // + this.cmbItemSkins.ComboWidth = 80; + this.cmbItemSkins.DropDownHeight = 106; + this.cmbItemSkins.DropDownWidth = 180; + this.cmbItemSkins.ItemHeight = 14; + this.cmbItemSkins.Name = "cmbItemSkins"; + this.cmbItemSkins.Visible = false; + this.cmbItemSkins.SelectedIndexChanged += new System.EventHandler(this.cmbItemSkins_SelectedIndexChanged); + // // buttonItemSaveImage // this.buttonItemSaveImage.Name = "buttonItemSaveImage"; @@ -2270,12 +2282,25 @@ private void InitializeComponent() this.superTabControlPanel2.Controls.Add(this.labelXComp1); this.superTabControlPanel2.Controls.Add(this.btnEasyCompare); this.superTabControlPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.superTabControlPanel2.Location = new System.Drawing.Point(0, 26); + this.superTabControlPanel2.Location = new System.Drawing.Point(0, 0); this.superTabControlPanel2.Name = "superTabControlPanel2"; - this.superTabControlPanel2.Size = new System.Drawing.Size(530, 202); + this.superTabControlPanel2.Size = new System.Drawing.Size(530, 228); this.superTabControlPanel2.TabIndex = 0; this.superTabControlPanel2.TabItem = this.superTabItem2; // + // chkResolvePngLink + // + // + // + // + this.chkResolvePngLink.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this.chkResolvePngLink.Location = new System.Drawing.Point(318, 34); + this.chkResolvePngLink.Name = "chkResolvePngLink"; + this.chkResolvePngLink.Size = new System.Drawing.Size(107, 23); + this.chkResolvePngLink.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.chkResolvePngLink.TabIndex = 9; + this.chkResolvePngLink.Text = "ResolvePngLink"; + // // chkOutputRemovedImg // // @@ -2850,19 +2875,6 @@ private void InitializeComponent() this.panelDockContainer2.Style.GradientAngle = 90; this.panelDockContainer2.TabIndex = 2; // - // chkResolvePngLink - // - // - // - // - this.chkResolvePngLink.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.chkResolvePngLink.Location = new System.Drawing.Point(318, 34); - this.chkResolvePngLink.Name = "chkResolvePngLink"; - this.chkResolvePngLink.Size = new System.Drawing.Size(107, 23); - this.chkResolvePngLink.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; - this.chkResolvePngLink.TabIndex = 9; - this.chkResolvePngLink.Text = "ResolvePngLink"; - // // MainForm // this.ClientSize = new System.Drawing.Size(750, 512); @@ -3126,5 +3138,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tsmi1DumpAsXml; private DevComponents.Editors.ComboItem comboItem18; private DevComponents.DotNetBar.Controls.CheckBoxX chkResolvePngLink; + private DevComponents.DotNetBar.ComboBoxItem cmbItemSkins; } } diff --git a/WzComparerR2/MainForm.cs b/WzComparerR2/MainForm.cs index 36cde3b9..e8d049a1 100644 --- a/WzComparerR2/MainForm.cs +++ b/WzComparerR2/MainForm.cs @@ -354,6 +354,20 @@ private void cmbItemAniNames_SelectedIndexChanged(object sender, EventArgs e) } } + private void cmbItemSkins_SelectedIndexChanged(object sender, EventArgs e) + { + if (this.cmbItemSkins.SelectedIndex > -1 && this.pictureBoxEx1.Items.Count > 0) + { + var aniItem = this.pictureBoxEx1.Items[0] as Animation.SpineAnimator; + if (aniItem != null) + { + string skinName = this.cmbItemSkins.SelectedItem as string; + aniItem.SelectedSkin = skinName; + this.cmbItemSkins.Tooltip = skinName; + } + } + } + private void buttonItemSaveImage_Click(object sender, EventArgs e) { if (this.pictureBoxEx1.Items.Count <= 0) @@ -474,10 +488,16 @@ private void buttonItemGif_Click(object sender, EventArgs e) { this.pictureBoxEx1.ShowAnimation(spineData); var aniItem = this.pictureBoxEx1.Items[0] as Animation.SpineAnimator; + this.cmbItemAniNames.Items.Clear(); this.cmbItemAniNames.Items.Add(""); this.cmbItemAniNames.Items.AddRange(aniItem.Animations.ToArray()); this.cmbItemAniNames.SelectedIndex = 0; + + this.cmbItemSkins.Visible = true; + this.cmbItemSkins.Items.Clear(); + this.cmbItemSkins.Items.AddRange(aniItem.Skins.ToArray()); + this.cmbItemSkins.SelectedIndex = aniItem.Skins.IndexOf(aniItem.SelectedSkin); } } else @@ -488,6 +508,7 @@ private void buttonItemGif_Click(object sender, EventArgs e) { this.pictureBoxEx1.ShowAnimation(frameData); this.cmbItemAniNames.Items.Clear(); + this.cmbItemSkins.Visible = false; } } this.pictureBoxEx1.PictureName = aniName; @@ -2942,6 +2963,8 @@ private void btnItemOptions_Click(object sender, System.EventArgs e) UpdateWzLoadingSettings(); } } + + } #region 内部用扩展方法