Refactor Tile16Editor for improved data handling and bitmap updates
- Changed the storage of current tile16 data from a static variable to an instance variable for better persistence. - Added a new method to update the blockset bitmap displayed in the editor, ensuring it reflects the current tile16 data. - Enhanced the DrawToCurrentTile16 method to include updates to the blockset bitmap after drawing. - Updated the CMake configuration for the tile edit table to ensure proper initialization.
This commit is contained in:
77
.github/workflows/release.yml
vendored
77
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ on:
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref_name != '' && github.ref_name || (github.event.inputs.tag != '' && github.event.inputs.tag || github.run_id) }}
|
||||
group: release-${{ github.event_name }}-${{ github.ref_name || github.event.inputs.tag || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
@@ -79,19 +79,27 @@ jobs:
|
||||
if python3 scripts/extract_changelog.py "${VERSION}" > release_notes.md; then
|
||||
echo "Changelog extracted for ${VERSION}"
|
||||
else
|
||||
printf '# yaze Release Notes\n\nSee docs/C1-changelog.md for full history.\n' > release_notes.md
|
||||
fi
|
||||
else
|
||||
printf '# yaze Release Notes\n\nSee docs/C1-changelog.md for full history.\n' > release_notes.md
|
||||
fi
|
||||
echo "---- RELEASE NOTES START ----"
|
||||
cat release_notes.md
|
||||
echo "---- RELEASE NOTES END ----"
|
||||
cat > release_notes.md <<'EOF'
|
||||
# yaze Release Notes
|
||||
|
||||
- name: Store release notes output
|
||||
id: notes
|
||||
shell: bash
|
||||
run: |
|
||||
See docs/C1-changelog.md for full history.
|
||||
EOF
|
||||
fi
|
||||
else
|
||||
cat > release_notes.md <<'EOF'
|
||||
# yaze Release Notes
|
||||
|
||||
See docs/C1-changelog.md for full history.
|
||||
EOF
|
||||
fi
|
||||
echo "---- RELEASE NOTES START ----"
|
||||
cat release_notes.md
|
||||
echo "---- RELEASE NOTES END ----"
|
||||
|
||||
- name: Store release notes output
|
||||
id: notes
|
||||
shell: bash
|
||||
run: |
|
||||
{
|
||||
echo 'content<<EOF'
|
||||
cat release_notes.md
|
||||
@@ -178,7 +186,8 @@ jobs:
|
||||
if: runner.os == 'Windows'
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgGitCommitId: '4334d8b4c8916018600212ab4dd4bbdc343065d1' # or b2cb0da531c2f1f740045bfe7c4dac59f0b2b69c
|
||||
# Registry tag 2025.09.17 full commit SHA
|
||||
vcpkgGitCommitId: '4334d8b4c8916018600212ab4dd4bbdc343065d1'
|
||||
runVcpkgInstall: true
|
||||
vcpkgJsonGlob: '**/vcpkg.json'
|
||||
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
||||
@@ -189,7 +198,7 @@ jobs:
|
||||
VCPKG_DEFAULT_TRIPLET: ${{ matrix.vcpkg_triplet }}
|
||||
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
|
||||
VCPKG_USE_SYSTEM_BINARIES: 1
|
||||
VCPKG_DOWNLOADS: ${{ github.workspace }}/vcpkg_downloads }
|
||||
VCPKG_DOWNLOADS: ${{ github.workspace }}/vcpkg_downloads
|
||||
VCPKG_DEFAULT_HOST_TRIPLET: x64-windows
|
||||
VCPKG_FEATURE_FLAGS: versions
|
||||
|
||||
@@ -250,25 +259,31 @@ jobs:
|
||||
run: |
|
||||
if (Test-Path build) { Remove-Item -Recurse -Force build }
|
||||
New-Item -ItemType Directory -Path build | Out-Null
|
||||
|
||||
$toolchain = Join-Path $env:VCPKG_ROOT 'scripts\buildsystems\vcpkg.cmake'
|
||||
$useVcpkg = (Test-Path $toolchain) -and ($env:VCPKG_AVAILABLE -ne 'false')
|
||||
|
||||
$args = @(
|
||||
"-S",".",
|
||||
"-B","build",
|
||||
"-G","${{ matrix.cmake_generator }}",
|
||||
"-A","${{ matrix.cmake_generator_platform }}",
|
||||
"-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}",
|
||||
"-DCMAKE_POLICY_VERSION_MINIMUM=3.16",
|
||||
"-DYAZE_BUILD_TESTS=OFF",
|
||||
"-DYAZE_BUILD_EMU=OFF",
|
||||
"-DYAZE_ENABLE_ROM_TESTS=OFF",
|
||||
"-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF",
|
||||
"-DYAZE_INSTALL_LIB=OFF"
|
||||
'-S','.',
|
||||
'-B','build',
|
||||
'-G','${{ matrix.cmake_generator }}',
|
||||
'-A','${{ matrix.cmake_generator_platform }}',
|
||||
'-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}',
|
||||
'-DCMAKE_POLICY_VERSION_MINIMUM=3.16',
|
||||
'-DYAZE_BUILD_TESTS=OFF',
|
||||
'-DYAZE_BUILD_EMU=OFF',
|
||||
'-DYAZE_ENABLE_ROM_TESTS=OFF',
|
||||
'-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF',
|
||||
'-DYAZE_INSTALL_LIB=OFF'
|
||||
)
|
||||
if (Test-Path "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -and $env:VCPKG_AVAILABLE -ne "false") {
|
||||
$args += "-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||
$args += "-DYAZE_MINIMAL_BUILD=OFF"
|
||||
|
||||
if ($useVcpkg) {
|
||||
$args += "-DCMAKE_TOOLCHAIN_FILE=$toolchain"
|
||||
$args += '-DYAZE_MINIMAL_BUILD=OFF'
|
||||
} else {
|
||||
$args += "-DYAZE_MINIMAL_BUILD=ON"
|
||||
$args += '-DYAZE_MINIMAL_BUILD=ON'
|
||||
}
|
||||
|
||||
cmake @args
|
||||
|
||||
# ---------- Build ----------
|
||||
@@ -319,7 +334,7 @@ jobs:
|
||||
cp "${pkg}" "${ART}.zip"
|
||||
else
|
||||
mkdir -p package
|
||||
cp -r build/bin/${{ env.BUILD_TYPE }}/* package/
|
||||
cp -r "build/bin/${{ env.BUILD_TYPE }}"/* package/
|
||||
[[ -d assets ]] && cp -r assets package/
|
||||
[[ -f LICENSE ]] && cp LICENSE package/
|
||||
[[ -f README.md ]] && cp README.md package/
|
||||
|
||||
@@ -313,10 +313,9 @@ gfx::Tile16* Tile16Editor::GetCurrentTile16Data() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Store in a static variable to return pointer (temporary solution)
|
||||
static gfx::Tile16 current_tile_data;
|
||||
current_tile_data = tile_result.value();
|
||||
return ¤t_tile_data;
|
||||
// Store in instance variable for proper persistence
|
||||
current_tile16_data_ = tile_result.value();
|
||||
return ¤t_tile16_data_;
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::UpdateROMTile16Data() {
|
||||
@@ -353,6 +352,45 @@ absl::Status Tile16Editor::RefreshTile16Blockset() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::UpdateBlocksetBitmap() {
|
||||
if (!tile16_blockset_) {
|
||||
return absl::FailedPreconditionError("Tile16 blockset not initialized");
|
||||
}
|
||||
|
||||
if (current_tile16_ < 0 || current_tile16_ >= zelda3::kNumTile16Individual) {
|
||||
return absl::OutOfRangeError("Current tile16 ID out of range");
|
||||
}
|
||||
|
||||
// Update the blockset bitmap that's displayed in the editor
|
||||
if (tile16_blockset_bmp_.is_active()) {
|
||||
// Calculate the position of this tile in the blockset bitmap
|
||||
constexpr int kTilesPerRow = 8; // Standard SNES tile16 layout is 8 tiles per row
|
||||
int tile_x = (current_tile16_ % kTilesPerRow) * kTile16Size;
|
||||
int tile_y = (current_tile16_ / kTilesPerRow) * kTile16Size;
|
||||
|
||||
// Copy pixel data from current tile to blockset bitmap
|
||||
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) {
|
||||
int src_index = tile_y_offset * kTile16Size + tile_x_offset;
|
||||
int dst_index = (tile_y + tile_y_offset) * tile16_blockset_bmp_.width() +
|
||||
(tile_x + tile_x_offset);
|
||||
|
||||
if (src_index < static_cast<int>(current_tile16_bmp_.size()) &&
|
||||
dst_index < static_cast<int>(tile16_blockset_bmp_.size())) {
|
||||
tile16_blockset_bmp_.WriteToPixel(dst_index, current_tile16_bmp_.data()[src_index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the blockset bitmap as modified and update the renderer
|
||||
tile16_blockset_bmp_.set_modified(true);
|
||||
core::Renderer::Get().UpdateBitmap(&tile16_blockset_bmp_);
|
||||
}
|
||||
|
||||
util::logf("Updated blockset bitmap for tile %d", current_tile16_);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::RegenerateTile16BitmapFromROM() {
|
||||
// Get the current tile16 data from ROM
|
||||
auto* tile_data = GetCurrentTile16Data();
|
||||
@@ -444,7 +482,7 @@ absl::Status Tile16Editor::RegenerateTile16BitmapFromROM() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 click_position,
|
||||
absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 pos,
|
||||
const gfx::Bitmap* source_tile) {
|
||||
constexpr int kTile8Size = 8;
|
||||
constexpr int kTile16Size = 16;
|
||||
@@ -477,8 +515,8 @@ absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 click_position,
|
||||
}
|
||||
|
||||
// Determine which quadrant was clicked - handle the 8x scale factor properly
|
||||
int quadrant_x = (click_position.x >= kTile8Size) ? 1 : 0;
|
||||
int quadrant_y = (click_position.y >= kTile8Size) ? 1 : 0;
|
||||
int quadrant_x = (pos.x >= kTile8Size) ? 1 : 0;
|
||||
int quadrant_y = (pos.y >= kTile8Size) ? 1 : 0;
|
||||
|
||||
int start_x = quadrant_x * kTile8Size;
|
||||
int start_y = quadrant_y * kTile8Size;
|
||||
@@ -582,6 +620,12 @@ absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 click_position,
|
||||
}
|
||||
}
|
||||
|
||||
// Write the modified tile16 data back to ROM
|
||||
RETURN_IF_ERROR(UpdateROMTile16Data());
|
||||
|
||||
// Update the blockset bitmap displayed in the editor
|
||||
RETURN_IF_ERROR(UpdateBlocksetBitmap());
|
||||
|
||||
if (live_preview_enabled_) {
|
||||
RETURN_IF_ERROR(UpdateOverworldTilemap());
|
||||
}
|
||||
@@ -948,6 +992,12 @@ absl::Status Tile16Editor::SetCurrentTile(int tile_id) {
|
||||
|
||||
current_tile16_ = tile_id;
|
||||
|
||||
// Initialize the instance variable with current ROM data
|
||||
auto tile_result = rom_->ReadTile16(current_tile16_);
|
||||
if (tile_result.ok()) {
|
||||
current_tile16_data_ = tile_result.value();
|
||||
}
|
||||
|
||||
// Extract tile data using the same method as GetTilemapData
|
||||
auto tile_data = gfx::GetTilemapData(*tile16_blockset_, tile_id);
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ class Tile16Editor : public gfx::GfxContext {
|
||||
absl::Status RefreshTile16Blockset();
|
||||
gfx::Tile16* GetCurrentTile16Data();
|
||||
absl::Status RegenerateTile16BitmapFromROM();
|
||||
absl::Status UpdateBlocksetBitmap();
|
||||
|
||||
// Manual tile8 input controls
|
||||
void DrawManualTile8Inputs();
|
||||
@@ -219,7 +220,7 @@ class Tile16Editor : public gfx::GfxContext {
|
||||
gui::CanvasGridSize::k32x32};
|
||||
gfx::Bitmap current_gfx_bmp_;
|
||||
|
||||
gui::Table tile_edit_table_{"##TileEditTable", 3, ImGuiTableFlags_Borders};
|
||||
gui::Table tile_edit_table_{"##TileEditTable", 3, ImGuiTableFlags_Borders, ImVec2(0, 0)};
|
||||
|
||||
gfx::Tilemap* tile16_blockset_ = nullptr;
|
||||
std::vector<gfx::Bitmap> current_gfx_individual_;
|
||||
@@ -231,6 +232,9 @@ class Tile16Editor : public gfx::GfxContext {
|
||||
|
||||
// Callback to notify parent editor when changes are committed
|
||||
std::function<absl::Status()> on_changes_committed_;
|
||||
|
||||
// Instance variable to store current tile16 data for proper persistence
|
||||
gfx::Tile16 current_tile16_data_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user