Skip to content

Commit

Permalink
Add save clearing (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonko0493 authored Jan 30, 2024
1 parent f4af006 commit c3a27ca
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 305 deletions.
381 changes: 189 additions & 192 deletions src/SerialLoops.Lib/Items/ScriptItem.cs

Large diffs are not rendered by default.

31 changes: 22 additions & 9 deletions src/SerialLoops.Lib/SaveFile/SaveFilePreview.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using System;
using HaruhiChokuretsuLib.Save;
using SerialLoops.Lib.Items;
using SerialLoops.Lib.Script.Parameters;
using SerialLoops.Lib.Util;
using SkiaSharp;
using System;

namespace SerialLoops.Lib.SaveFile {
public class SaveFilePreview {

namespace SerialLoops.Lib.SaveFile
{
public class SaveFilePreview
{
private const int WIDTH = 250;
private const int HEIGHT = 42;
private const float SCALE = 2f;

private SaveSlotData _slotData;
private Project _project;

public SaveFilePreview(SaveSlotData slotData, Project project)
{
_slotData = slotData;
Expand All @@ -41,8 +42,8 @@ public SKBitmap DrawPreview()
canvas.Flush();
return bitmap.Resize(
new SKImageInfo(
(int) (WIDTH * SCALE),
(int) (HEIGHT * SCALE)
(int)(WIDTH * SCALE),
(int)(HEIGHT * SCALE)
),
SKFilterQuality.None
);
Expand Down Expand Up @@ -136,8 +137,20 @@ private void DrawLargeGlyph(char glyph, SKCanvas canvas, SKBitmap bitmap, int x,
{
int offset = glyph switch
{
'0' => 0, '1' => 8, '2' => 16, '3' => 24, '4' => 32, '5' => 40, '6' => 48,
'7' => 56, '8' => 64, '9' => 72, ':' => 80, '/' => 88, '%' => 96, _ => 104
'0' => 0,
'1' => 8,
'2' => 16,
'3' => 24,
'4' => 32,
'5' => 40,
'6' => 48,
'7' => 56,
'8' => 64,
'9' => 72,
':' => 80,
'/' => 88,
'%' => 96,
_ => 104
};
canvas.DrawBitmap(
bitmap,
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.1" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.macOS" Version="7.3.0.1" />
<PackageReference Include="HaruhiChokuretsuLib" Version="0.36.6" />
<PackageReference Include="HaruhiChokuretsuLib" Version="0.36.7" />
<PackageReference Include="NAudio.Vorbis" Version="1.5.0" />
<PackageReference Include="NitroPacker.Core" Version="2.4.4" />
<PackageReference Include="NitroPacker.Core" Version="2.4.6" />
<PackageReference Include="NLayer" Version="1.15.0" />
<PackageReference Include="NLayer.NAudioSupport" Version="1.4.0" />
<PackageReference Include="QuikGraph" Version="2.5.0" />
Expand Down
25 changes: 13 additions & 12 deletions src/SerialLoops/Dialogs/SaveEditorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void InitializeComponent()
Height = 390;
Resizable = false;
Padding = 10;

UpdateContent();
}

Expand Down Expand Up @@ -95,19 +95,19 @@ private void UpdateContent()
};
}

private Control GetSaveFiles()
private TableLayout GetSaveFiles()
{
Button saveCommonButton = new()
{
Text = "Common Save Data...",
Text = "Common Save Data...",
Image = ControlGenerator.GetIcon("Edit_Save", _log)
};
saveCommonButton.Click += (sender, args) =>
{
SaveSlotEditorDialog saveSlotEditorDialog = new(
_log,
_save.CommonData,
Path.GetFileName(_saveLoc),
Path.GetFileName(_saveLoc),
"Common Save Data",
_project,
_tabs,
Expand Down Expand Up @@ -163,11 +163,11 @@ private TableRow GetSaveSlotPreview(SaveSlotData data, int slotNum)
Items =
{
GetSlotEditButton(data, Path.GetFileName(_saveLoc), slotNum),
// GetSlotClearButton(data, Path.GetFileName(_saveLoc), slotNum) TODO
GetSlotClearButton(data, Path.GetFileName(_saveLoc), slotNum),
},
}
)
{
{
Orientation = Orientation.Vertical,
HorizontalContentAlignment = HorizontalAlignment.Center,
VerticalContentAlignment = VerticalAlignment.Center,
Expand Down Expand Up @@ -196,19 +196,20 @@ private Button GetSlotEditButton(SaveSlotData slot, string fileName, int slotNum
};
return slotButton;
}

private Button GetSlotClearButton(SaveSlotData slot, string fileName, int slotNumber)
{
Button slotButton = new()
{
Width = 22,
Button slotButton = new()
{
Width = 22,
Image = ControlGenerator.GetIcon("Clear", _log),
Enabled = slot.EpisodeNumber > 0
Enabled = slot.EpisodeNumber > 0
};
slotButton.Click += (sender, args) =>
{
slot.EpisodeNumber = 0;
slot.Clear();
_log.Log($"Cleared Save File {slotNumber}.");
UpdateContent();
};
return slotButton;
}
Expand Down
Loading

0 comments on commit c3a27ca

Please sign in to comment.