Fix DungeonMap tile16 copy IDs being used, update yaze version num

This commit is contained in:
scawful
2024-01-22 20:24:44 -05:00
parent a443efc8a4
commit 9f137559c3
7 changed files with 56 additions and 30 deletions

View File

@@ -136,7 +136,7 @@ namespace app {
namespace core { namespace core {
constexpr uint32_t kRedPen = 0xFF0000FF; constexpr uint32_t kRedPen = 0xFF0000FF;
constexpr float kYazeVersion = 0.05; constexpr float kYazeVersion = 0.06;
// ============================================================================ // ============================================================================
// Magic numbers // Magic numbers

View File

@@ -204,7 +204,7 @@ void MasterEditor::DrawAboutPopup() {
if (about_) ImGui::OpenPopup("About"); if (about_) ImGui::OpenPopup("About");
if (ImGui::BeginPopupModal("About", nullptr, if (ImGui::BeginPopupModal("About", nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) { ImGuiWindowFlags_AlwaysAutoResize)) {
Text("Yet Another Zelda3 Editor - v%d", core::kYazeVersion); Text("Yet Another Zelda3 Editor - v%.2f", core::kYazeVersion);
Text("Written by: scawful"); Text("Written by: scawful");
ImGui::Spacing(); ImGui::Spacing();
Text("Special Thanks: Zarby89, JaredBrian"); Text("Special Thanks: Zarby89, JaredBrian");

View File

@@ -102,9 +102,9 @@ absl::Status Tile16Editor::UpdateBlockset() {
gui::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_, 0x100, gui::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_, 0x100,
(8192 * 2), 0x20, map_blockset_loaded_, true, 55); (8192 * 2), 0x20, map_blockset_loaded_, true, 55);
if (!blockset_canvas_.Points().empty()) { if (!blockset_canvas_.points().empty()) {
uint16_t x = blockset_canvas_.Points().front().x / 32; uint16_t x = blockset_canvas_.points().front().x / 32;
uint16_t y = blockset_canvas_.Points().front().y / 32; uint16_t y = blockset_canvas_.points().front().y / 32;
notify_tile16.mutable_get() = x + (y * 8); notify_tile16.mutable_get() = x + (y * 8);
notify_tile16.apply_changes(); notify_tile16.apply_changes();

View File

@@ -681,10 +681,10 @@ void OverworldEditor::SaveOverworldChanges() {
} }
void OverworldEditor::CheckForOverworldEdits() { void OverworldEditor::CheckForOverworldEdits() {
if (!blockset_canvas_.Points().empty()) { if (!blockset_canvas_.points().empty()) {
// User has selected a tile they want to draw from the blockset. // User has selected a tile they want to draw from the blockset.
int x = blockset_canvas_.Points().front().x / 32; int x = blockset_canvas_.points().front().x / 32;
int y = blockset_canvas_.Points().front().y / 32; int y = blockset_canvas_.points().front().y / 32;
current_tile16_ = x + (y * 8); current_tile16_ = x + (y * 8);
if (ow_map_canvas_.DrawTilePainter(tile16_individual_[current_tile16_], if (ow_map_canvas_.DrawTilePainter(tile16_individual_[current_tile16_],
16)) { 16)) {
@@ -720,10 +720,14 @@ void OverworldEditor::CheckForCurrentMap() {
ow_map_canvas_.DrawOutline(parent_map_x * small_map_size, ow_map_canvas_.DrawOutline(parent_map_x * small_map_size,
parent_map_x * small_map_size, large_map_size, parent_map_x * small_map_size, large_map_size,
large_map_size); large_map_size);
// ow_map_canvas_.mutable_points()->push_back(
// ImVec2(parent_map_x * small_map_size, parent_map_y * small_map_size));
} else { } else {
ow_map_canvas_.DrawOutline(current_map_x * small_map_size, ow_map_canvas_.DrawOutline(current_map_x * small_map_size,
current_map_y * small_map_size, small_map_size, current_map_y * small_map_size,
small_map_size); small_map_size, small_map_size);
// ow_map_canvas_.mutable_points()->push_back(
// ImVec2(current_map_x * small_map_size, current_map_y * small_map_size));
} }
static int prev_map_; static int prev_map_;
@@ -763,7 +767,7 @@ void OverworldEditor::DrawOverworldCanvas() {
if (flags()->kDrawOverworldSprites) { if (flags()->kDrawOverworldSprites) {
DrawOverworldSprites(); DrawOverworldSprites();
} }
//CheckForCurrentMap(); CheckForCurrentMap();
CheckForOverworldEdits(); CheckForOverworldEdits();
} }
ow_map_canvas_.DrawGrid(64.0f); ow_map_canvas_.DrawGrid(64.0f);

View File

@@ -228,6 +228,14 @@ absl::Status ScreenEditor::LoadDungeonMapTile16() {
*rom()->mutable_dungeon_palette(3)); *rom()->mutable_dungeon_palette(3));
rom()->RenderBitmap(&*tile16_sheet_.mutable_bitmap().get()); rom()->RenderBitmap(&*tile16_sheet_.mutable_bitmap().get());
for (int i = 0; i < tile16_sheet_.num_tiles(); ++i) {
if (tile16_individual_.count(i) == 0) {
auto tile = tile16_sheet_.GetTile16(i);
tile16_individual_[i] = tile;
rom()->RenderBitmap(&tile16_individual_[i]);
}
}
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -251,29 +259,30 @@ void ScreenEditor::DrawDungeonMapsTabs() {
screen_canvas_.DrawTileSelector(64.f); screen_canvas_.DrawTileSelector(64.f);
auto boss_room = current_dungeon.boss_room; auto boss_room = current_dungeon.boss_room;
for (int i = 0; i < 25; i++) { for (int j = 0; j < 25; j++) {
if (current_dungeon.floor_rooms[floor_number][i] != 0x0F) { if (current_dungeon.floor_rooms[floor_number][j] != 0x0F) {
int tile16_id = current_dungeon.floor_gfx[floor_number][i]; int tile16_id = current_dungeon.floor_rooms[floor_number][j];
int tile_x = (tile16_id % 16) * 16; int tile_x = (tile16_id % 16) * 16;
int tile_y = (tile16_id / 16) * 16; int tile_y = (tile16_id / 16) * 16;
int posX = ((i % 5) * 32); int posX = ((j % 5) * 32);
int posY = ((i / 5) * 32); int posY = ((j / 5) * 32);
if (tile16_individual_.count(tile16_id) == 0) { if (tile16_individual_.count(tile16_id) == 0) {
auto tile = tile16_sheet_.GetTile16(tile16_id); auto tile = tile16_sheet_.GetTile16(tile16_id);
std::cout << "Tile16: " << tile16_id << std::endl;
rom()->RenderBitmap(&tile); rom()->RenderBitmap(&tile);
tile16_individual_[tile16_id] = tile; tile16_individual_[tile16_id] = tile;
} }
auto bmp = tile16_individual_[tile16_id]; screen_canvas_.DrawBitmap(tile16_individual_[tile16_id], (posX * 2),
screen_canvas_.DrawBitmap(bmp, (posX * 2), (posY * 2), 4.0f); (posY * 2), 4.0f);
if (current_dungeon.floor_rooms[floor_number][i] == boss_room) { if (current_dungeon.floor_rooms[floor_number][j] == boss_room) {
screen_canvas_.DrawOutlineWithColor((posX * 2), (posY * 2), 64, screen_canvas_.DrawOutlineWithColor((posX * 2), (posY * 2), 64,
64, core::kRedPen); 64, core::kRedPen);
} }
std::string label = std::string label =
dungeon_map_labels_[selected_dungeon][floor_number][i]; dungeon_map_labels_[selected_dungeon][floor_number][j];
screen_canvas_.DrawText(label, (posX * 2), (posY * 2)); screen_canvas_.DrawText(label, (posX * 2), (posY * 2));
// GFX.drawText( // GFX.drawText(
// e.Graphics, 16 + ((i % 5) * 32), 20 + ((i / 5) * 32), // e.Graphics, 16 + ((i % 5) * 32), 20 + ((i / 5) * 32),
@@ -287,9 +296,9 @@ void ScreenEditor::DrawDungeonMapsTabs() {
screen_canvas_.DrawGrid(64.f, 5); screen_canvas_.DrawGrid(64.f, 5);
screen_canvas_.DrawOverlay(); screen_canvas_.DrawOverlay();
if (!screen_canvas_.Points().empty()) { if (!screen_canvas_.points().empty()) {
int x = screen_canvas_.Points().front().x / 64; int x = screen_canvas_.points().front().x / 64;
int y = screen_canvas_.Points().front().y / 64; int y = screen_canvas_.points().front().y / 64;
selected_room = x + (y * 5); selected_room = x + (y * 5);
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
@@ -366,9 +375,9 @@ void ScreenEditor::DrawDungeonMapsEditor() {
tilesheet_canvas_.DrawGrid(32.f); tilesheet_canvas_.DrawGrid(32.f);
tilesheet_canvas_.DrawOverlay(); tilesheet_canvas_.DrawOverlay();
if (!tilesheet_canvas_.Points().empty()) { if (!tilesheet_canvas_.points().empty()) {
selected_tile16_ = tilesheet_canvas_.Points().front().x / 32 + selected_tile16_ = tilesheet_canvas_.points().front().x / 32 +
(tilesheet_canvas_.Points().front().y / 32) * 16; (tilesheet_canvas_.points().front().y / 32) * 16;
} }
} }
ImGui::EndChild(); ImGui::EndChild();

View File

@@ -5,6 +5,7 @@
#include <cmath> #include <cmath>
#include <string> #include <string>
#include "app/editor/graphics_editor.h"
#include "app/gfx/bitmap.h" #include "app/gfx/bitmap.h"
#include "app/rom.h" #include "app/rom.h"
@@ -143,6 +144,17 @@ void Canvas::DrawContextMenu() {
} }
ImGui::EndMenu(); ImGui::EndMenu();
} }
ImGui::Separator();
if (ImGui::BeginMenu("Palette")) {
for (const auto each : editor::kPaletteGroupAddressesKeys) {
if (ImGui::BeginMenu(each)) {
// Apply the palette to the current bitmap
}
ImGui::EndMenu();
}
ImGui::EndMenu();
}
ImGui::EndPopup(); ImGui::EndPopup();
} }
@@ -300,9 +312,9 @@ void Canvas::HandleTileEdits(Canvas &blockset_canvas,
gfx::Bitmap &destination, int &current_tile, gfx::Bitmap &destination, int &current_tile,
float scale, int tile_painter_size, float scale, int tile_painter_size,
int tiles_per_row) { int tiles_per_row) {
if (!blockset_canvas.Points().empty()) { if (!blockset_canvas.points().empty()) {
uint16_t x = blockset_canvas.Points().front().x / 32; uint16_t x = blockset_canvas.points().front().x / 32;
uint16_t y = blockset_canvas.Points().front().y / 32; uint16_t y = blockset_canvas.points().front().y / 32;
current_tile = x + (y * tiles_per_row); current_tile = x + (y * tiles_per_row);
if (DrawTilePainter(source_blockset[current_tile], tile_painter_size, if (DrawTilePainter(source_blockset[current_tile], tile_painter_size,
scale)) { scale)) {

View File

@@ -85,7 +85,8 @@ class Canvas {
void DrawOverlay(); // last void DrawOverlay(); // last
auto Points() const { return points_; } auto points() const { return points_; }
auto mutable_points() { return &points_; }
auto GetDrawList() const { return draw_list_; } auto GetDrawList() const { return draw_list_; }
auto zero_point() const { return canvas_p0_; } auto zero_point() const { return canvas_p0_; }
auto Scrolling() const { return scrolling_; } auto Scrolling() const { return scrolling_; }