Refactor GitHub Actions workflow and Tile16Editor for improved functionality

- Updated the concurrency group in the release workflow to use a more consistent reference for tags.
- Enhanced the release notes generation logic for clarity and consistency.
- Improved logging in Tile16Editor to provide better insights during bitmap updates and error handling.
- Refactored the UpdateBlocksetBitmap method to ensure proper handling of active bitmaps and pixel copying, enhancing the editor's responsiveness.
This commit is contained in:
scawful
2025-09-28 21:21:38 -04:00
parent aeed90090d
commit b463878d6e
2 changed files with 60 additions and 46 deletions

View File

@@ -14,7 +14,7 @@ on:
type: string type: string
concurrency: concurrency:
group: release-${{ github.event_name }}-${{ github.ref_name || github.event.inputs.tag || github.run_id }} group: release-${{ github.ref || github.event.inputs.tag || github.run_id }}
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
@@ -78,24 +78,25 @@ jobs:
if [[ -f scripts/extract_changelog.py ]]; then if [[ -f scripts/extract_changelog.py ]]; then
if python3 scripts/extract_changelog.py "${VERSION}" > release_notes.md; then if python3 scripts/extract_changelog.py "${VERSION}" > release_notes.md; then
echo "Changelog extracted for ${VERSION}" echo "Changelog extracted for ${VERSION}"
else
echo "# yaze Release Notes" > release_notes.md
echo "" >> release_notes.md
echo "See docs/C1-changelog.md for full history." >> release_notes.md
fi
else else
echo "# yaze Release Notes" > release_notes.md echo "# yaze Release Notes" > release_notes.md
echo "" >> release_notes.md echo "" >> release_notes.md
echo "See docs/C1-changelog.md for full history." >> release_notes.md echo "See docs/C1-changelog.md for full history." >> release_notes.md
fi fi
echo "---- RELEASE NOTES START ----" fi
cat release_notes.md else
echo "---- RELEASE NOTES END ----" echo "# yaze Release Notes" > release_notes.md
echo "" >> release_notes.md
echo "See docs/C1-changelog.md for full history." >> release_notes.md
fi
echo "---- RELEASE NOTES START ----"
cat release_notes.md
echo "---- RELEASE NOTES END ----"
- name: Store release notes output - name: Store release notes output
id: notes id: notes
shell: bash shell: bash
run: | run: |
{ {
echo 'content<<EOF' echo 'content<<EOF'
cat release_notes.md cat release_notes.md
@@ -182,7 +183,7 @@ jobs:
if: runner.os == 'Windows' if: runner.os == 'Windows'
uses: lukka/run-vcpkg@v11 uses: lukka/run-vcpkg@v11
with: with:
# Registry tag 2025.09.17 full commit SHA # vcpkg registry baseline (full 40-char commit SHA)
vcpkgGitCommitId: '4334d8b4c8916018600212ab4dd4bbdc343065d1' vcpkgGitCommitId: '4334d8b4c8916018600212ab4dd4bbdc343065d1'
runVcpkgInstall: true runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json' vcpkgJsonGlob: '**/vcpkg.json'
@@ -338,7 +339,7 @@ jobs:
fi fi
;; ;;
macOS) macOS)
ver="${{ needs.validate-and-prepare.outputs.tag_name }}" ver="${{ needs['validate-and-prepare'].outputs.tag_name }}"
ver="${ver#v}" ver="${ver#v}"
chmod +x ./scripts/create-macos-bundle.sh chmod +x ./scripts/create-macos-bundle.sh
./scripts/create-macos-bundle.sh "${ver}" "${ART}" ./scripts/create-macos-bundle.sh "${ver}" "${ART}"
@@ -385,11 +386,11 @@ jobs:
- name: Create/Update Release - name: Create/Update Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ needs.validate-and-prepare.outputs.tag_name }} tag_name: ${{ needs['validate-and-prepare'].outputs.tag_name }}
name: yaze ${{ needs.validate-and-prepare.outputs.tag_name }} name: yaze ${{ needs['validate-and-prepare'].outputs.tag_name }}
body: ${{ needs.validate-and-prepare.outputs.release_notes }} body: ${{ needs['validate-and-prepare'].outputs.release_notes }}
draft: false draft: false
prerelease: ${{ contains(needs.validate-and-prepare.outputs.tag_name, 'beta') || contains(needs.validate-and-prepare.outputs.tag_name, 'alpha') || contains(needs.validate-and-prepare.outputs.tag_name, 'rc') }} prerelease: ${{ contains(needs['validate-and-prepare'].outputs.tag_name, 'beta') || contains(needs['validate-and-prepare'].outputs.tag_name, 'alpha') || contains(needs['validate-and-prepare'].outputs.tag_name, 'rc') }}
files: | files: |
dist/**/* dist/**/*
env: env:
@@ -402,6 +403,6 @@ jobs:
steps: steps:
- name: Announce release - name: Announce release
run: | run: |
echo "🎉 yaze ${{ needs.validate-and-prepare.outputs.tag_name }} has been released!" echo "🎉 yaze ${{ needs['validate-and-prepare'].outputs.tag_name }} has been released!"
echo "📦 Packages are now available for download" echo "📦 Packages are now available for download"
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ needs.validate-and-prepare.outputs.tag_name }}" echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ needs['validate-and-prepare'].outputs.tag_name }}"

View File

@@ -353,22 +353,33 @@ absl::Status Tile16Editor::RefreshTile16Blockset() {
} }
absl::Status Tile16Editor::UpdateBlocksetBitmap() { absl::Status Tile16Editor::UpdateBlocksetBitmap() {
util::logf("UpdateBlocksetBitmap called for tile %d", current_tile16_);
if (!tile16_blockset_) { if (!tile16_blockset_) {
util::logf("ERROR: Tile16 blockset not initialized");
return absl::FailedPreconditionError("Tile16 blockset not initialized"); return absl::FailedPreconditionError("Tile16 blockset not initialized");
} }
if (current_tile16_ < 0 || current_tile16_ >= zelda3::kNumTile16Individual) { if (current_tile16_ < 0 || current_tile16_ >= zelda3::kNumTile16Individual) {
util::logf("ERROR: Current tile16 ID %d out of range", current_tile16_);
return absl::OutOfRangeError("Current tile16 ID out of range"); return absl::OutOfRangeError("Current tile16 ID out of range");
} }
// Update the blockset bitmap that's displayed in the editor // Update the blockset bitmap directly from the current tile16 bitmap
if (tile16_blockset_bmp_.is_active()) { if (tile16_blockset_bmp_.is_active() && current_tile16_bmp_.is_active()) {
util::logf("Updating blockset bitmap directly from current tile16...");
// Calculate the position of this tile in the blockset bitmap // Calculate the position of this tile in the blockset bitmap
constexpr int kTilesPerRow = 8; // Standard SNES tile16 layout is 8 tiles per row constexpr int kTilesPerRow = 8; // Standard SNES tile16 layout is 8 tiles per row
int tile_x = (current_tile16_ % kTilesPerRow) * kTile16Size; int tile_x = (current_tile16_ % kTilesPerRow) * kTile16Size;
int tile_y = (current_tile16_ / kTilesPerRow) * kTile16Size; int tile_y = (current_tile16_ / kTilesPerRow) * kTile16Size;
util::logf("Tile position: (%d, %d), blockset size: %dx%d, tile16 size: %dx%d",
tile_x, tile_y, tile16_blockset_bmp_.width(), tile16_blockset_bmp_.height(),
current_tile16_bmp_.width(), current_tile16_bmp_.height());
// Copy pixel data from current tile to blockset bitmap // Copy pixel data from current tile to blockset bitmap
int pixels_copied = 0;
for (int tile_y_offset = 0; tile_y_offset < kTile16Size; ++tile_y_offset) { for (int tile_y_offset = 0; tile_y_offset < kTile16Size; ++tile_y_offset) {
for (int tile_x_offset = 0; tile_x_offset < kTile16Size; ++tile_x_offset) { for (int tile_x_offset = 0; tile_x_offset < kTile16Size; ++tile_x_offset) {
int src_index = tile_y_offset * kTile16Size + tile_x_offset; int src_index = tile_y_offset * kTile16Size + tile_x_offset;
@@ -377,17 +388,24 @@ absl::Status Tile16Editor::UpdateBlocksetBitmap() {
if (src_index < static_cast<int>(current_tile16_bmp_.size()) && if (src_index < static_cast<int>(current_tile16_bmp_.size()) &&
dst_index < static_cast<int>(tile16_blockset_bmp_.size())) { dst_index < static_cast<int>(tile16_blockset_bmp_.size())) {
tile16_blockset_bmp_.WriteToPixel(dst_index, current_tile16_bmp_.data()[src_index]); uint8_t pixel_value = current_tile16_bmp_.data()[src_index];
tile16_blockset_bmp_.WriteToPixel(dst_index, pixel_value);
pixels_copied++;
} }
} }
} }
util::logf("Copied %d pixels to blockset bitmap", pixels_copied);
// Mark the blockset bitmap as modified and update the renderer // Mark the blockset bitmap as modified and update the renderer
tile16_blockset_bmp_.set_modified(true); tile16_blockset_bmp_.set_modified(true);
core::Renderer::Get().UpdateBitmap(&tile16_blockset_bmp_); core::Renderer::Get().UpdateBitmap(&tile16_blockset_bmp_);
util::logf("Blockset bitmap updated and renderer notified");
} else {
util::logf("ERROR: Blockset bitmap or current tile16 bitmap not active");
} }
util::logf("Updated blockset bitmap for tile %d", current_tile16_); util::logf("UpdateBlocksetBitmap completed for tile %d", current_tile16_);
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -565,17 +583,9 @@ absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 pos,
} }
} }
// Recreate the bitmap since we modified pixel data // Mark the bitmap as modified and update the renderer
auto tile16_data = current_tile16_bmp_.vector(); current_tile16_bmp_.set_modified(true);
current_tile16_bmp_.Create(kTile16Size, kTile16Size, 8, tile16_data); core::Renderer::Get().UpdateBitmap(&current_tile16_bmp_);
// Re-apply the correct palette to the tile16 bitmap after pixel updates
const auto& ow_main_pal_group = rom()->palette_group().overworld_main;
if (ow_main_pal_group.size() > 0) {
current_tile16_bmp_.SetPalette(ow_main_pal_group[0]);
}
core::Renderer::Get().RenderBitmap(&current_tile16_bmp_);
// Update ROM data when painting to tile16 // Update ROM data when painting to tile16
auto* tile_data = GetCurrentTile16Data(); auto* tile_data = GetCurrentTile16Data();
@@ -765,20 +775,23 @@ absl::Status Tile16Editor::UpdateTile16Edit() {
// Always use the flipped tile for consistency between preview and actual drawing // Always use the flipped tile for consistency between preview and actual drawing
if (tile16_edit_canvas_.DrawTilePainter(*tile_to_paint, 8, 4.0F)) { if (tile16_edit_canvas_.DrawTilePainter(*tile_to_paint, 8, 4.0F)) {
ImVec2 click_pos = tile16_edit_canvas_.drawn_tile_position(); ImVec2 click_pos = tile16_edit_canvas_.drawn_tile_position();
// Convert from display coordinates to tile16 bitmap coordinates
// The canvas shows 16x16 pixels at 4x scale (64x64 display), so divide by 4 to get actual pixel coordinates // Convert canvas coordinates to tile16 coordinates (0-15 range)
click_pos.x = // The canvas is 64x64 display pixels showing a 16x16 tile at 4x scale
(click_pos.x - 2) / 4.0F; // Account for padding and 4x scale int tile_x = static_cast<int>(click_pos.x / 4.0F);
click_pos.y = (click_pos.y - 2) / 4.0F; int tile_y = static_cast<int>(click_pos.y / 4.0F);
// Ensure coordinates are within the 16x16 tile bounds // Clamp to valid range
click_pos.x = std::max(0.0F, std::min(15.0F, click_pos.x)); tile_x = std::max(0, std::min(15, tile_x));
click_pos.y = std::max(0.0F, std::min(15.0F, click_pos.y)); tile_y = std::max(0, std::min(15, tile_y));
util::logf("Canvas click: (%.2f, %.2f) -> Tile16: (%d, %d)",
click_pos.x, click_pos.y, tile_x, tile_y);
// Pass the flipped tile if we created one, otherwise pass nullptr to use original with flips // Pass the flipped tile if we created one, otherwise pass nullptr to use original with flips
const gfx::Bitmap* tile_to_draw = const gfx::Bitmap* tile_to_draw =
(x_flip || y_flip) ? tile_to_paint : nullptr; (x_flip || y_flip) ? tile_to_paint : nullptr;
RETURN_IF_ERROR(DrawToCurrentTile16(click_pos, tile_to_draw)); RETURN_IF_ERROR(DrawToCurrentTile16(ImVec2(tile_x, tile_y), tile_to_draw));
} }
} }