Skip to content

Commit

Permalink
spritesheets to cover up to 5x zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
hunter2actual committed Apr 4, 2024
1 parent db3300f commit d681ce9
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 14 deletions.
8 changes: 4 additions & 4 deletions DalamudMinesweeper.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Author": "hunter2_",
"Name": "Minesweeper",
"InternalName": "DalamudMinesweeper",
"AssemblyVersion": "0.0.0.13",
"AssemblyVersion": "0.0.0.14",
"Description": "Logic puzzle in which you find and flag hidden mines. \nLeft click to uncover a square, right click to place a flag. \nClick a number that has the right amount of adjacent flags to reveal adjacent tiles. \nThe game ends when all mines are flagged and all safe squares have been uncovered. \nClick the smiley face to start a new game.",
"ApplicableVersion": "any",
"Tags": [
Expand All @@ -18,9 +18,9 @@
"LoadPriority": 0,
"Punchline": "Classic puzzle game.",
"AcceptsFeedback": true,
"DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/0.0.0.13/latest.zip",
"DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/0.0.0.13/latest.zip",
"DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/0.0.0.14/latest.zip",
"DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/0.0.0.14/latest.zip",
"IconUrl": "https://raw.githubusercontent.com/hunter2actual/DalamudMinesweeper/master/images/icon.png",
"Changelog": "Spritesheet rendering to prevent image bleed"
"Changelog": "Improved tile rendering"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ namespace DalamudMinesweeper;

public class ClassicSprites : IDisposable {
private DalamudPluginInterface _pluginInterface { get; set; }
private IDalamudTextureWrap Sheet { get; init; }
private IDalamudTextureWrap[] Sheets { get; init; }
private record SpriteData(Vector2 topLeftCoord, Vector2 sizePx);
private readonly Dictionary<string, SpriteData> _spriteDict;

public ClassicSprites(DalamudPluginInterface pluginInterface)
{
_pluginInterface = pluginInterface;
Sheet = LoadImage("spritesheet.png");

Sheets =
[
LoadImage("spritesheet_1x.png"),
LoadImage("spritesheet_2x.png"),
LoadImage("spritesheet_3x.png"),
LoadImage("spritesheet_4x.png"),
LoadImage("spritesheet_5x.png"),
];

_spriteDict = new Dictionary<string, SpriteData>
{
Expand Down Expand Up @@ -54,11 +62,13 @@ public void DrawSmiley(ImDrawListPtr drawList, string smileyName, Vector2 cursor

private void Draw(ImDrawListPtr drawList, SpriteData sprite, Vector2 cursorPos, int zoom)
{
var uvMin = sprite.topLeftCoord / Sheet.Size;
var uvMax = (sprite.topLeftCoord + sprite.sizePx) / Sheet.Size;
var sheet = Sheets[zoom - 1];

var uvMin = sprite.topLeftCoord * zoom / sheet.Size;
var uvMax = (sprite.topLeftCoord + sprite.sizePx) * zoom / sheet.Size;

drawList.AddImage(
Sheet.ImGuiHandle,
sheet.ImGuiHandle,
cursorPos,
cursorPos + sprite.sizePx * zoom,
uvMin,
Expand Down Expand Up @@ -90,7 +100,10 @@ private static string CellToSpriteName(Cell cell)

public void Dispose()
{
Sheet.Dispose();
foreach (var sheet in Sheets)
{
sheet.Dispose();
}
}

private IDalamudTextureWrap LoadImage(string path)
Expand Down
2 changes: 1 addition & 1 deletion DalamudMinesweeper/Components/Footer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Draw(Vector2 start)
_drawConfigAction();
}
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus) && _configuration.Zoom <= 5)
{
_configuration.Zoom++;
}
Expand Down
20 changes: 18 additions & 2 deletions DalamudMinesweeper/DalamudMinesweeper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>0.0.0.13</Version>
<Version>0.0.0.14</Version>
<Description>A logic puzzle featuring hidden mines.</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/hunter2actual/DalamudMinesweeper</PackageProjectUrl>
Expand All @@ -14,7 +14,23 @@
</PropertyGroup>

<ItemGroup>
<Content Include="..\Data\Classic\spritesheet.png">
<Content Include="..\Data\Classic\spritesheet_1x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="..\Data\Classic\spritesheet_2x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="..\Data\Classic\spritesheet_3x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="..\Data\Classic\spritesheet_4x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="..\Data\Classic\spritesheet_5x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
Expand Down
File renamed without changes
Binary file added Data/Classic/spritesheet_2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Classic/spritesheet_3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Classic/spritesheet_4x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Classic/spritesheet_5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ Dalamud plugin for FFXIV
- UI borders
- Active click logic
- High scores screen
- Spritesheet zoom levels
- [Stretch] Implement solver to reduce guessing
- [Stretch] Skins

0 comments on commit d681ce9

Please sign in to comment.