Skip to content

Commit

Permalink
Merge pull request #15 from sinBetaKun/v1.0.3.1
Browse files Browse the repository at this point in the history
V1.0.3.1
  • Loading branch information
sinBetaKun authored Nov 9, 2024
2 parents 70247b1 + dacfdf0 commit 7689b34
Show file tree
Hide file tree
Showing 31 changed files with 1,045 additions and 785 deletions.
4 changes: 4 additions & 0 deletions SinTachiePlugin/Enums/LayerAnimationMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ public enum LayerAnimationMode
Sin,
[Display(Name = "口パク", Description = "(セラール)~(アブリール)の範囲で口パクします。\n口が閉じるときに(セラール)の値に、\n全開のときに(アブリール)の値になります。")]
VoiceVolume,
[Display(Name = "周期的往復", Description = "(セラール)~(アブリール)の範囲で「往復」と同じ動きを定期的にします。\n(セラール)の値と(アブリール)の値の間を周期的に往復します。")]
PeriodicShuttle,
[Display(Name = "周期的ループ", Description = "(セラール)~(アブリール)の範囲で「ループ」と同じ動きを定期的にします。\n(セラール)の値と(アブリール)の値の間を周期的に往復します。")]
PeriodicLoop,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal interface IIntervalParameter
{
public Animation Interval { get; }
}
}
14 changes: 14 additions & 0 deletions SinTachiePlugin/LayerValueListController/Extra/IStartParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal interface IStartParameter
{
public Animation Start { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal interface ITransitionParameter
{
public Animation Transition { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Controls;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal class IntervalSharedData
{
public Animation Interval { get; } = new Animation(0, 0, 9999);

public IntervalSharedData()
{
}

public IntervalSharedData(IIntervalParameter parameter)
{
Interval.CopyFrom(parameter.Interval);
}

public void CopyTo(IIntervalParameter parameter)
{
parameter.Interval.CopyFrom(Interval);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Project;

namespace SinTachiePlugin.LayerValueListController.Extra
{
public abstract class LayerValueExtraBase : SharedParameterBase
{
public LayerValueExtraBase()
{
}

public LayerValueExtraBase(SharedDataStore? store = null) : base(store)
{
}

public abstract double GetValue(long frame, long length, int fps);
public abstract void CopyFrom(LayerValueExtraBase? origin);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Project;

namespace SinTachiePlugin.LayerValueListController.Extra.Parameter
{
public class NoExtra : LayerValueExtraBase
{
public NoExtra()
{
}

public NoExtra(SharedDataStore? store = null) : base(store)
{
}

public override void CopyFrom(LayerValueExtraBase? origin)
{
return;
}

public override double GetValue(long frame, long length, int fps)
{
return 1.0;
}

protected override IEnumerable<IAnimatable> GetAnimatables() => [];

protected override void LoadSharedData(SharedDataStore store)
{
}

protected override void SaveSharedData(SharedDataStore store)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Controls;
using YukkuriMovieMaker.Project;

namespace SinTachiePlugin.LayerValueListController.Extra.Parameter
{
public class PeriodicParameter : LayerValueExtraBase, IStartParameter, IIntervalParameter, ITransitionParameter
{
[Display(Name = "開始", Description = "差分を動かし始めるタイミング")]
[AnimationSlider("F2", "秒", 0, 10)]
public Animation Start { get; } = new Animation(0, 0, 9999);

[Display(Name = "間隔", Description = "差分を動かす時間間隔(遷移は含まれない)")]
[AnimationSlider("F2", "秒", 0, 10)]
public Animation Interval { get; } = new Animation(0, 0, 9999);

[Display(Name = "遷移", Description = "差分を動かし始めてから終わるまでの時間")]
[AnimationSlider("F2", "秒", 0, 10)]
public Animation Transition { get; } = new Animation(0, 0, 9999);

/// <summary>
/// 制御モードが周期的往復/ループのとき、差分を指定する値を返す。
/// </summary>
/// <param name="frame"></param>
/// <param name="length"></param>
/// <param name="fps"></param>
/// <returns>0から1までのdouble</returns>
public override double GetValue(long frame, long length, int fps)
{
double start = Start.GetValue(frame, length, fps);
double time = frame / (double)fps - start;

if (time < 0)
return 1.0;

double interval = Interval.GetValue(frame, length, fps);
double transition = Transition.GetValue(frame, length, fps);

double time2 = time % (transition + interval);

if(time2 < transition)
return 1.0 - time2 / transition;

return 1.0;
}

public PeriodicParameter()
{
}

public PeriodicParameter(SharedDataStore? store) : base(store)
{
}

public override void CopyFrom(LayerValueExtraBase? origin)
{
var origin2 = origin as PeriodicParameter;
if (origin2 == null) return;
Start.CopyFrom(origin2.Start);
Interval.CopyFrom(origin2.Interval);
Transition.CopyFrom(origin2.Transition);
}

protected override IEnumerable<IAnimatable> GetAnimatables() => [Start, Interval, Transition];

protected override void SaveSharedData(SharedDataStore store)
{
store.Save(new StartSharedData(this));
store.Save(new IntervalSharedData(this));
store.Save(new TransitionSharedData(this));
}

protected override void LoadSharedData(SharedDataStore store)
{
if (store.Load<StartSharedData>() is StartSharedData startParameter)
startParameter.CopyTo(this);
if (store.Load<IntervalSharedData>() is IntervalSharedData intervalParameter)
intervalParameter.CopyTo(this);
if (store.Load<TransitionSharedData>() is TransitionSharedData transitionParameter)
transitionParameter.CopyTo(this);
}
}
}
30 changes: 30 additions & 0 deletions SinTachiePlugin/LayerValueListController/Extra/StartSharedData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Controls;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal class StartSharedData
{
public Animation Start { get; } = new Animation(0, 0, 9999);

public StartSharedData()
{
}

public StartSharedData(IStartParameter parameter)
{
Start.CopyFrom(parameter.Start);
}

public void CopyTo(IStartParameter parameter)
{
parameter.Start.CopyFrom(Start);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Commons;

namespace SinTachiePlugin.LayerValueListController.Extra
{
internal class TransitionSharedData
{
public Animation Speed { get; } = new Animation(0, 0, 9999);

public TransitionSharedData() { }

public TransitionSharedData(ITransitionParameter parameter)
{
Speed.CopyFrom(parameter.Transition);
}

public void CopyTo(ITransitionParameter parameter)
{
parameter.Transition.CopyFrom(Speed);
}
}
}
33 changes: 33 additions & 0 deletions SinTachiePlugin/LayerValueListController/LayerAnimationModeEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using SinTachiePlugin.LayerValueListController.Extra;
using SinTachiePlugin.LayerValueListController.Extra.Parameter;
using SinTachiePlugin.Parts.LayerValueListController;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YukkuriMovieMaker.Plugin.Community.Effect.Video.ZoomPixel.Size;

namespace SinTachiePlugin.LayerValueListController
{
internal static class LayerAnimationModeEx
{
public static LayerValueExtraBase Convert(this LayerAnimationMode mode, LayerValueExtraBase current)
{
var store = current.GetSharedData();
LayerValueExtraBase param = mode switch
{
LayerAnimationMode.CerrarPlusAbrir => new NoExtra(store),
LayerAnimationMode.CerrarTimesAbrir => new NoExtra(store),
LayerAnimationMode.Sin => new NoExtra(store),
LayerAnimationMode.VoiceVolume => new NoExtra(store),
LayerAnimationMode.PeriodicShuttle => new PeriodicParameter(store),
LayerAnimationMode.PeriodicLoop => new PeriodicParameter(store),
_ => throw new ArgumentOutOfRangeException(nameof(mode)),
};
if (param.GetType() != current.GetType())
return param;
return current;
}
}
}
4 changes: 2 additions & 2 deletions SinTachiePlugin/LayerValueListController/LayerNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ void AddLeaf(LayerNode node, int?[] indexs)
{
string clsName = GetType().Name;
string? mthName = MethodBase.GetCurrentMethod()?.Name;
SinTachieDialog.ShowError($"無効なレイヤー値({values[Depth]})", clsName, mthName);
throw new Exception($"無効なレイヤー値({values[Depth]})");
SinTachieDialog.ShowError($"無効な差分指定({values[Depth]})", clsName, mthName);
throw new Exception($"無効な差分指定({values[Depth]})");
}

ID2D1Image? output;
Expand Down
Loading

0 comments on commit 7689b34

Please sign in to comment.