Skip to content

Commit

Permalink
[HaRepacker] Include WzNode path as title when previewing an animatio…
Browse files Browse the repository at this point in the history
…n/spine
  • Loading branch information
lastbattle committed Feb 16, 2021
1 parent a40bad5 commit fbac03f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
4 changes: 2 additions & 2 deletions HaRepacker/GUI/Panels/ImageAnimationPreviewWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ImageAnimationPreviewWindow : Microsoft.Xna.Framework.Game
/// Constructor
/// </summary>
/// <param name="selectedAnimationNodes"></param>
public ImageAnimationPreviewWindow(List<WzNode> selectedAnimationNodes)
public ImageAnimationPreviewWindow(List<WzNode> selectedAnimationNodes, string title_path)
{
this.selectedAnimationNodes = selectedAnimationNodes;

Expand All @@ -56,7 +56,7 @@ public ImageAnimationPreviewWindow(List<WzNode> selectedAnimationNodes)
//Window.AllowUserResizing = true;
//Window.IsBorderless = true;
//Window.Position = new Point(0, 0);
Window.Title = "Animation preview";
Window.Title = title_path;
IsFixedTimeStep = false; // dont cap fps
Content.RootDirectory = "Content";

Expand Down
10 changes: 8 additions & 2 deletions HaRepacker/GUI/Panels/MainPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Xna.Framework;
using Spine;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
Expand Down Expand Up @@ -634,11 +635,13 @@ public void StartAnimateSelectedCanvas()
selectedNodes.Add(node);
}

string path_title = ((WzNode)DataTree.SelectedNodes[0]).Parent?.FullPath ?? "Animate";

Thread thread = new Thread(() =>
{
try
{
ImageAnimationPreviewWindow previewWnd = new ImageAnimationPreviewWindow(selectedNodes);
ImageAnimationPreviewWindow previewWnd = new ImageAnimationPreviewWindow(selectedNodes, path_title);
previewWnd.Run();
}
catch (Exception ex)
Expand Down Expand Up @@ -1441,14 +1444,17 @@ private void ShowObjectValue(WzObject obj)
textEditor.SetHighlightingDefinitionIndex(20); // json
textEditor.textEditor.Text = obj.ToString();


string path_title = stringObj.Parent?.FullPath ?? "Animate";

Thread thread = new Thread(() =>
{
try
{
WzSpineAnimationItem item = new WzSpineAnimationItem(stringObj);

// Create xna window
SpineAnimationWindow Window = new SpineAnimationWindow(item);
SpineAnimationWindow Window = new SpineAnimationWindow(item, path_title);
Window.Run();
}
catch (Exception e)
Expand Down
21 changes: 11 additions & 10 deletions HaSharedLibrary/GUI/SpineAnimationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using Microsoft.Xna.Framework.Input;
using Spine;
using System;
using System.Linq;

namespace HaSharedLibrary.GUI
{
Expand All @@ -47,14 +48,14 @@ public class SpineAnimationWindow : Microsoft.Xna.Framework.Game
/// Constructor
/// </summary>
/// <param name="spineAnimationItem"></param>
/// <param name="skeletonData"></param>
public SpineAnimationWindow(WzSpineAnimationItem spineAnimationItem)
/// <param name="title_path">The path of the spine animation to set as title</param>
public SpineAnimationWindow(WzSpineAnimationItem spineAnimationItem, string title_path)
{
IsMouseVisible = true;

//Window.IsBorderless = true;
//Window.Position = new Point(0, 0);
Window.Title = "Spine";
Window.Title = title_path;
IsFixedTimeStep = false; // dont cap fps
Content.RootDirectory = "Content";

Expand Down Expand Up @@ -102,15 +103,15 @@ protected override void LoadContent()
wzSpineObject.spineAnimationItem.LoadResources(graphicsDeviceMgr.GraphicsDevice); // load spine resources (this must happen after window is loaded)
wzSpineObject.skeleton = new Skeleton(wzSpineObject.spineAnimationItem.SkeletonData);

skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
skeletonRenderer.PremultipliedAlpha = wzSpineObject.spineAnimationItem.PremultipliedAlpha;
skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice)
{
PremultipliedAlpha = wzSpineObject.spineAnimationItem.PremultipliedAlpha
};

// Skin
foreach (Skin skin in wzSpineObject.spineAnimationItem.SkeletonData.Skins)
{
wzSpineObject.skeleton.SetSkin(skin.Name); // just set the first skin
break;
}
Skin skin = wzSpineObject.spineAnimationItem.SkeletonData.Skins.FirstOrDefault(); // just set the first skin
if (skin != null)
wzSpineObject.skeleton.SetSkin(skin.Name);

// Define mixing between animations.
wzSpineObject.stateData = new AnimationStateData(wzSpineObject.skeleton.Data);
Expand Down
13 changes: 11 additions & 2 deletions MapleLib/WzLib/Spine/WzSpineAnimationItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018~2020, LastBattle https://github.com/lastbattle
* Copyright (c) 2018~2021, LastBattle https://github.com/lastbattle
* Copyright (c) 2010~2013, haha01haha http://forum.ragezone.com/f701/release-universal-harepacker-version-892005/
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -38,7 +38,16 @@ namespace MapleLib.WzLib.Spine
public class WzSpineAnimationItem
{
// Spine

/// <summary>
/// Whether the renderer will assume that colors have premultiplied alpha.
///
/// A variation of a bitmap image or alpha blending calculation in which the RGB color values are assumed
/// to be already multiplied by an alpha channel, to reduce computations during Alpha blending;
/// uses the blend operation: dst *= (1 - alpha) + src; capable of mixing alpha blending with additive blending effects
/// </summary>
public bool PremultipliedAlpha { get; set; }

public SkeletonData SkeletonData { get; private set; }

// pre-loading
Expand Down Expand Up @@ -75,7 +84,7 @@ public void LoadResources(GraphicsDevice graphicsDevice)
pma = ((WzImage)wzSpineAtlasPropertyNode.parent)["PMA"].ReadValue(0) > 0;

this.SkeletonData = skeletonData;
this.PremultipliedAlpha = pma;
this.PremultipliedAlpha = pma; // whether the renderer will assume that colors have premultiplied alpha. Default is true.

}
}
Expand Down

0 comments on commit fbac03f

Please sign in to comment.