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

Make it so you can replace system textures with transparent images to preserve transparency #254

Merged
merged 4 commits into from
Jun 22, 2023
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
</p>

**Serial Loops** is a fully-fledged editor for the Nintendo DS game, _Suzumiya Haruhi no Chokuretsu_ (The Series of Haruhi Suzumiya).
**Serial Loops** is a fully-fledged editor for the Nintendo DS game _Suzumiya Haruhi no Chokuretsu_ (The Series of Haruhi Suzumiya).

## Screenshots
<p align="center">
Expand All @@ -25,6 +25,9 @@
<img width="325px" src="https://haroohie.club/images/chokuretsu/serial-loops/home-screen.png" alt="Screenshot of the Serial Loops home screen. The Serial Loops logo and title sits at the top of the menu. Below that, under 'Start' on the left hand side, options to create a project, open an existing project, and modify preferences are present. An empty list of 'Recents' is visible on the right hand side, where recent projects would appear." />
</p>

## Documentation
Documentation for how to use Serial Loops can be found on [our website](https://haroohie.club/chokuretsu/serial-loops/).

## Installation
### Prerequisites
#### Installing devKitARM
Expand All @@ -34,7 +37,8 @@
* On macOS and Linux, run `sudo dkp-pacman -S nds-dev` from the terminal after installing the devkitPro pacman distribution.

#### Installing Make or Docker
To assemble ASM hacks you want to apply, you will need to decide whether to use Make or Docker.
To assemble ASM hacks you want to apply, you will need to decide whether to use Make or Docker. Make is automatically installed when using the Debian and RPM
packages we distribute, so you don't need to worry about this step if you're using either of those.

Currently, the Docker path is **only supported on Windows** due to operating system and framework limitations. It is possible to get Docker running
just fine on Linux distros by running SerialLoops as root (e.g. `sudo SerialLoops`), but it's easier to just use Make. On macOS, there is no known
Expand Down
16 changes: 9 additions & 7 deletions src/SerialLoops.Lib/Items/SystemTextureItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ public class SystemTextureItem : Item
{
public SystemTexture SysTex { get; set; }
public GraphicsFile Grp { get; set; }
public int TransparentIndex { get; set; }
public int Width { get; set; }
public int Height { get; set; }

public SystemTextureItem(SystemTexture sysTex, Project project, string name, int transparentIndex, int width = -1, int height = -1) : base(name, ItemType.System_Texture)
public SystemTextureItem(SystemTexture sysTex, Project project, string name, int width = -1, int height = -1) : base(name, ItemType.System_Texture)
{
SysTex = sysTex;
Grp = project.Grp.Files.First(f => f.Index == sysTex.GrpIndex);
Expand All @@ -29,7 +28,6 @@ public SystemTextureItem(SystemTexture sysTex, Project project, string name, int
{
Grp.ImageForm = GraphicsFile.Form.TILE;
}
TransparentIndex = transparentIndex;
Width = width < 0 ? Grp.Width : width;
Height = height < 0 ? Grp.Height : height;
}
Expand All @@ -42,12 +40,12 @@ public SKBitmap GetTexture()
{
if (SysTex.Screen == SysTexScreen.BOTTOM_SCREEN)
{
return Grp.GetImage();
return Grp.GetImage(transparentIndex: 0);
}
else
{
SKBitmap tileBitmap = new(Width, Height);
SKBitmap tiles = Grp.GetImage(width: SysTex.TileWidth);
SKBitmap tiles = Grp.GetImage(width: SysTex.TileWidth, transparentIndex: 0);
SKCanvas tileCanvas = new(tileBitmap);
int currentTile = 0;
for (int y = 0; y < tileBitmap.Height; y += SysTex.TileHeight)
Expand All @@ -68,9 +66,13 @@ public SKBitmap GetTexture()

public void SetTexture(SKBitmap bitmap, bool replacePalette)
{
if (replacePalette == false)
{
Grp.Palette[0] = SKColors.Transparent;
}
if (SysTex.Screen == SysTexScreen.BOTTOM_SCREEN)
{
Grp.SetImage(bitmap, replacePalette, TransparentIndex);
Grp.SetImage(bitmap, replacePalette, transparentIndex: replacePalette ? 0 : -1);
}
else
{
Expand All @@ -90,7 +92,7 @@ public void SetTexture(SKBitmap bitmap, bool replacePalette)
}
tileCanvas.Flush();

Grp.SetImage(tileBitmap, replacePalette, TransparentIndex);
Grp.SetImage(tileBitmap, replacePalette, transparentIndex: replacePalette ? 0 : -1);
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/SerialLoops.Lib/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,23 +586,23 @@ public LoadProjectResult LoadArchives(ILogger log, IProgressTracker tracker)
SystemTextureFile systemTextureFile = Dat.Files.First(f => f.Name == "SYSTEXS").CastTo<SystemTextureFile>();
tracker.Focus("System Textures",
5 + systemTextureFile.SystemTextures.Count(s => Grp.Files.Where(g => g.Name.StartsWith("XTR") || g.Name.StartsWith("SYS") && !g.Name.Contains("_SPC_") && g.Name != "SYS_CMN_B12DNX" && g.Name != "SYS_PPT_001DNX").Select(g => g.Index).Distinct().Contains(s.GrpIndex)));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_CO_SEGDNX").Index), this, "SYSTEX_LOGO_SEGA", 0, height: 192));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_CO_SEGDNX").Index), this, "SYSTEX_LOGO_SEGA", height: 192));
tracker.Finished++;
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_CO_AQIDNX").Index), this, "SYSTEX_LOGO_AQI", 0, height: 192));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_CO_AQIDNX").Index), this, "SYSTEX_LOGO_AQI", height: 192));
tracker.Finished++;
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_MW_ACTDNX").Index), this, "SYSTEX_LOGO_MOBICLIP", 0, height: 192));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_MW_ACTDNX").Index), this, "SYSTEX_LOGO_MOBICLIP", height: 192));
tracker.Finished++;
string criLogoName = Grp.Files.Any(f => f.Name == "CREDITS") ? "SYSTEX_LOGO_HAROOHIE" : "SYSTEX_LOGO_CRIWARE";
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_MW_CRIDNX").Index), this, criLogoName, 0, height: 192));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "LOGO_MW_CRIDNX").Index), this, criLogoName, height: 192));
tracker.Finished++;
if (Grp.Files.Any(f => f.Name == "CREDITS"))
{
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "CREDITS").Index), this, "SYSTEX_LOGO_CREDITS", 0, height: 192));
Items.Add(new SystemTextureItem(systemTextureFile.SystemTextures.First(s => s.GrpIndex == Grp.Files.First(g => g.Name == "CREDITS").Index), this, "SYSTEX_LOGO_CREDITS", height: 192));
}
tracker.Finished++;
foreach (SystemTexture extraSysTex in systemTextureFile.SystemTextures.Where(s => Grp.Files.Where(g => g.Name.StartsWith("XTR")).Distinct().Select(g => g.Index).Contains(s.GrpIndex)))
{
Items.Add(new SystemTextureItem(extraSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == extraSysTex.GrpIndex).Name[0..^3]}", -1));
Items.Add(new SystemTextureItem(extraSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == extraSysTex.GrpIndex).Name[0..^3]}"));
tracker.Finished++;
}
// Exclude B12 as that's the nameplates we replace in the character items and PPT_001 as that's the puzzle phase singularity we'll be replacing in the puzzle items
Expand All @@ -612,11 +612,11 @@ public LoadProjectResult LoadArchives(ILogger log, IProgressTracker tracker)
if (Grp.Files.First(g => g.Index == sysSysTex.GrpIndex).Name[0..^4].EndsWith("T6"))
{
// special case the ep headers
Items.Add(new SystemTextureItem(sysSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == sysSysTex.GrpIndex).Name[0..^3]}", -1, height: 192));
Items.Add(new SystemTextureItem(sysSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == sysSysTex.GrpIndex).Name[0..^3]}", height: 192));
}
else
{
Items.Add(new SystemTextureItem(sysSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == sysSysTex.GrpIndex).Name[0..^3]}", -1));
Items.Add(new SystemTextureItem(sysSysTex, this, $"SYSTEX_{Grp.Files.First(g => g.Index == sysSysTex.GrpIndex).Name[0..^3]}"));
}
tracker.Finished++;
}
Expand Down
3 changes: 0 additions & 3 deletions src/SerialLoops/Dialogs/BackgroundCropResizeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,7 @@ private void OnMouseMove(object sender, MouseEventArgs e)
private void UpdateImage()
{
SKCanvas previewCanvas = new(_preview);

// Draw background
previewCanvas.Clear();
previewCanvas.DrawColor(SKColors.DarkGray);

// Draw image
previewCanvas.DrawBitmap(StartImage,
Expand Down