Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup loading SFX & PALEFFECT preview #359

Merged
merged 11 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SerialLoops.Lib/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using HaruhiChokuretsuLib.Archive.Graphics;
using HaruhiChokuretsuLib.Util;
using SerialLoops.Lib.Util;
using SkiaSharp;
using System;
using System.Diagnostics;
using System.Globalization;
Expand Down Expand Up @@ -214,6 +213,7 @@ private static void CopyToArchivesToIterativeOriginal(string newDataDir, string
File.Copy(Path.Combine(newDataDir, "dat.bin"), Path.Combine(iterativeOriginalDir, "dat.bin"), overwrite: true);
File.Copy(Path.Combine(newDataDir, "evt.bin"), Path.Combine(iterativeOriginalDir, "evt.bin"), overwrite: true);
File.Copy(Path.Combine(newDataDir, "grp.bin"), Path.Combine(iterativeOriginalDir, "grp.bin"), overwrite: true);
File.Copy(Path.Combine(newDataDir, "snd.bin"), Path.Combine(iterativeOriginalDir, "snd.bin"), overwrite: true);
}
catch (IOException exc)
{
Expand Down
20 changes: 2 additions & 18 deletions src/SerialLoops.Lib/Items/ScriptItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,25 +317,9 @@ public ScriptPreview GetScriptPreview(Dictionary<ScriptSection, List<ScriptItemC
SKPaint palEffectPaint = PaletteEffectScriptParameter.IdentityPaint;
if (palCommand is not null && lastBgCommand is not null && commands.IndexOf(palCommand) > commands.IndexOf(lastBgCommand))
{
switch (((PaletteEffectScriptParameter)palCommand.Parameters[0]).Effect)
{
case PaletteEffectScriptParameter.PaletteEffect.INVERTED:
palEffectPaint = PaletteEffectScriptParameter.InvertedPaint;
break;

case PaletteEffectScriptParameter.PaletteEffect.GRAYSCALE:
palEffectPaint = PaletteEffectScriptParameter.GrayscalePaint;
break;

case PaletteEffectScriptParameter.PaletteEffect.SEPIA:
palEffectPaint = PaletteEffectScriptParameter.SepiaPaint;
break;

case PaletteEffectScriptParameter.PaletteEffect.DIMMED:
palEffectPaint = PaletteEffectScriptParameter.DimmedPaint;
break;
}
preview.BgPalEffect = ((PaletteEffectScriptParameter)palCommand.Parameters[0]).Effect;
}

ScriptItemCommand bgScrollCommand = null;
for (int i = commands.Count - 1; i >= 0; i--)
{
Expand Down
6 changes: 5 additions & 1 deletion src/SerialLoops.Lib/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public class Project
[JsonIgnore]
public SKBitmap NameplateBitmap { get; set; }
[JsonIgnore]
public GraphicInfo NameplateInfo { get; set; }
[JsonIgnore]
public SKBitmap DialogueBitmap { get; set; }
[JsonIgnore]
public SKBitmap FontBitmap { get; set; }
Expand Down Expand Up @@ -329,7 +331,9 @@ public LoadProjectResult LoadArchives(ILogger log, IProgressTracker tracker)
}
try
{
NameplateBitmap = Grp.GetFileByName("SYS_CMN_B12DNX").GetImage();
GraphicsFile nameplate = Grp.GetFileByName("SYS_CMN_B12DNX");
NameplateBitmap = nameplate.GetImage();
NameplateInfo = new(nameplate);
}
catch (Exception ex)
{
Expand Down
13 changes: 5 additions & 8 deletions src/SerialLoops.Lib/Script/Parameters/BoolScriptParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace SerialLoops.Lib.Script.Parameters
{
public class BoolScriptParameter : ScriptParameter
public class BoolScriptParameter(string name, bool value, short trueValue = 1, short falseValue = 0) : ScriptParameter(name, ParameterType.BOOL)
{
public bool Value { get; set; }
public override short[] GetValues(object obj = null) => new short[] { (short)(Value ? 1 : 0) };

public BoolScriptParameter(string name, bool value) : base(name, ParameterType.BOOL)
{
Value = value;
}
public bool Value { get; set; } = value;
public short TrueValue { get; set; } = trueValue;
public short FalseValue { get; set; } = falseValue;
public override short[] GetValues(object obj = null) => [Value ? TrueValue : FalseValue];

public override BoolScriptParameter Clone(Project project, EventFile eventFile)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public static SKPaint GetPaletteEffectPaint(PaletteEffect effect)
{
ColorFilter = SKColorFilter.CreateColorMatrix(
[
0.393f, 0.769f, 0.189f, 0.00f, 0.00f,
0.349f, 0.686f, 0.168f, 0.00f, 0.00f,
0.272f, 0.534f, 0.131f, 0.00f, 0.00f,
0.296f, 0.578f, 0.143f, 0.00f, 0.00f,
0.263f, 0.515f, 0.126f, 0.00f, 0.00f,
0.204f, 0.401f, 0.099f, 0.00f, 0.00f,
0.000f, 0.000f, 0.000f, 1.00f, 0.00f,
]),
};
Expand Down
4 changes: 3 additions & 1 deletion src/SerialLoops.Lib/Script/ScriptItemCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private static List<ScriptParameter> GetScriptParameters(ScriptCommandInvocation
parameters.Add(new ShortScriptParameter(localize("Volume"), parameter));
break;
case 3:
//parameters.Add(new ShortScriptParameter(localize("crossfadeDupe"), parameter));
parameters.Add(new BoolScriptParameter(localize("Load Sound"), parameter == -1, trueValue: -1));
break;
case 4:
parameters.Add(new ShortScriptParameter(localize("Crossfade Time (Frames)"), parameter));
Expand Down Expand Up @@ -519,6 +519,8 @@ private static List<ScriptParameter> GetScriptParameters(ScriptCommandInvocation
switch (i)
{
case 0:
parameters.Add(new ShortScriptParameter(localize($"Map Character Set"), parameter));
break;
case 1:
case 2:
case 3:
Expand Down
4 changes: 2 additions & 2 deletions src/SerialLoops.Lib/SerialLoops.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageReference Include="BunLabs.NAudio.Flac" Version="2.0.1" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0.2" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.macOS" Version="7.3.0.2" />
<PackageReference Include="HaruhiChokuretsuLib" Version="0.40.5" />
<PackageReference Include="HaruhiChokuretsuLib" Version="0.40.6" />
<PackageReference Include="NAudio.Vorbis" Version="1.5.0" />
<PackageReference Include="NitroPacker.Core" Version="2.4.7" />
<PackageReference Include="NitroPacker.Core" Version="2.5.0" />
<PackageReference Include="NLayer" Version="1.15.0" />
<PackageReference Include="NLayer.NAudioSupport" Version="1.4.0" />
<PackageReference Include="QuikGraph" Version="2.5.0" />
Expand Down
1 change: 1 addition & 0 deletions src/SerialLoops/Controls/ItemEditorControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ScriptCommandCheckBox : CheckBox
{
public ScriptItemCommand Command { get; set; }
public int ParameterIndex { get; set; }
public List<ScriptCommandNumericStepper> DisableableNumericSteppers { get; set; }
}
public class ScriptCommandColorPicker : ColorPicker
{
Expand Down
Loading