Fix Overworld sprite drawing system
- Updated the MapPropertiesSystem to improve the layout of the simplified map settings table, increasing column widths for better visibility and usability. - Adjusted button sizes in the OverworldEditor for Graphics, Palettes, Overlays, and Properties to enhance user interaction. - Implemented filtering of sprites in the OverworldEditor based on the current world, ensuring only relevant sprites are displayed. - Refactored sprite drawing logic to utilize global coordinates directly, improving accuracy in sprite rendering.
This commit is contained in:
@@ -29,17 +29,17 @@ void MapPropertiesSystem::DrawSimplifiedMapSettings(int& current_world, int& cur
|
||||
bool& show_custom_bg_color_editor, bool& show_overlay_editor) {
|
||||
// Enhanced settings table with popup buttons for quick access
|
||||
if (BeginTable("SimplifiedMapSettings", 8, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit, ImVec2(0, 0), -1)) {
|
||||
ImGui::TableSetupColumn("World", ImGuiTableColumnFlags_WidthFixed, 80);
|
||||
ImGui::TableSetupColumn("World", ImGuiTableColumnFlags_WidthFixed, 100);
|
||||
ImGui::TableSetupColumn("Map", ImGuiTableColumnFlags_WidthFixed, 60);
|
||||
ImGui::TableSetupColumn("Area Size", ImGuiTableColumnFlags_WidthFixed, 100);
|
||||
ImGui::TableSetupColumn("Lock", ImGuiTableColumnFlags_WidthFixed, 60);
|
||||
ImGui::TableSetupColumn("Graphics", ImGuiTableColumnFlags_WidthFixed, 70);
|
||||
ImGui::TableSetupColumn("Palettes", ImGuiTableColumnFlags_WidthFixed, 70);
|
||||
ImGui::TableSetupColumn("Overlays", ImGuiTableColumnFlags_WidthFixed, 70);
|
||||
ImGui::TableSetupColumn("Properties", ImGuiTableColumnFlags_WidthFixed, 80);
|
||||
ImGui::TableSetupColumn("Graphics", ImGuiTableColumnFlags_WidthFixed, 90);
|
||||
ImGui::TableSetupColumn("Palettes", ImGuiTableColumnFlags_WidthFixed, 90);
|
||||
ImGui::TableSetupColumn("Overlays", ImGuiTableColumnFlags_WidthFixed, 90);
|
||||
ImGui::TableSetupColumn("Properties", ImGuiTableColumnFlags_WidthFixed, 100);
|
||||
|
||||
TableNextColumn();
|
||||
ImGui::SetNextItemWidth(70.f);
|
||||
ImGui::SetNextItemWidth(90.f);
|
||||
if (ImGui::Combo("##world", ¤t_world, kWorldList, 3)) {
|
||||
// World changed, update current map if needed
|
||||
if (current_map >= 0x40 && current_world == 0) {
|
||||
@@ -77,28 +77,28 @@ void MapPropertiesSystem::DrawSimplifiedMapSettings(int& current_world, int& cur
|
||||
HOVER_HINT(current_map_lock ? "Unlock Map" : "Lock Map");
|
||||
|
||||
TableNextColumn();
|
||||
if (ImGui::Button("Graphics", ImVec2(60, 0))) {
|
||||
if (ImGui::Button("Graphics", ImVec2(80, 0))) {
|
||||
ImGui::OpenPopup("GraphicsPopup");
|
||||
}
|
||||
HOVER_HINT("Graphics Settings");
|
||||
DrawGraphicsPopup(current_map);
|
||||
|
||||
TableNextColumn();
|
||||
if (ImGui::Button("Palettes", ImVec2(60, 0))) {
|
||||
if (ImGui::Button("Palettes", ImVec2(80, 0))) {
|
||||
ImGui::OpenPopup("PalettesPopup");
|
||||
}
|
||||
HOVER_HINT("Palette Settings");
|
||||
DrawPalettesPopup(current_map, show_custom_bg_color_editor);
|
||||
|
||||
TableNextColumn();
|
||||
if (ImGui::Button("Overlays", ImVec2(60, 0))) {
|
||||
if (ImGui::Button("Overlays", ImVec2(80, 0))) {
|
||||
ImGui::OpenPopup("OverlaysPopup");
|
||||
}
|
||||
HOVER_HINT("Overlay Settings");
|
||||
DrawOverlaysPopup(current_map, show_overlay_editor);
|
||||
|
||||
TableNextColumn();
|
||||
if (ImGui::Button("Properties", ImVec2(70, 0))) {
|
||||
if (ImGui::Button("Properties", ImVec2(90, 0))) {
|
||||
ImGui::OpenPopup("PropertiesPopup");
|
||||
}
|
||||
HOVER_HINT("Map Properties");
|
||||
|
||||
@@ -1400,10 +1400,21 @@ void OverworldEditor::DrawOverworldItems() {
|
||||
void OverworldEditor::DrawOverworldSprites() {
|
||||
int i = 0;
|
||||
for (auto &sprite : *overworld_.mutable_sprites(game_state_)) {
|
||||
if (!sprite.deleted()) {
|
||||
int map_x = sprite.map_x();
|
||||
int map_y = sprite.map_y();
|
||||
ow_map_canvas_.DrawRect(map_x, map_y, kTile16Size, kTile16Size,
|
||||
// Filter sprites by current world - only show sprites for the current world
|
||||
if (!sprite.deleted() &&
|
||||
sprite.map_id() < 0x40 + (current_world_ * 0x40) &&
|
||||
sprite.map_id() >= (current_world_ * 0x40)) {
|
||||
|
||||
// Sprites are already stored with global coordinates (realX, realY from ROM loading)
|
||||
// So we can use sprite.x_ and sprite.y_ directly
|
||||
int sprite_x = sprite.x_;
|
||||
int sprite_y = sprite.y_;
|
||||
|
||||
// Temporarily update sprite coordinates for entity interaction
|
||||
int original_x = sprite.x_;
|
||||
int original_y = sprite.y_;
|
||||
|
||||
ow_map_canvas_.DrawRect(sprite_x, sprite_y, kTile16Size, kTile16Size,
|
||||
/*magenta=*/ImVec4(255, 0, 255, 150));
|
||||
if (current_mode == EditingMode::SPRITES) {
|
||||
HandleEntityDragging(&sprite, ow_map_canvas_.zero_point(),
|
||||
@@ -1418,13 +1429,17 @@ void OverworldEditor::DrawOverworldSprites() {
|
||||
}
|
||||
if (core::FeatureFlags::get().overworld.kDrawOverworldSprites) {
|
||||
if (sprite_previews_[sprite.id()].is_active()) {
|
||||
ow_map_canvas_.DrawBitmap(sprite_previews_[sprite.id()], map_x, map_y,
|
||||
ow_map_canvas_.DrawBitmap(sprite_previews_[sprite.id()], sprite_x, sprite_y,
|
||||
2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ow_map_canvas_.DrawText(absl::StrFormat("%s", sprite.name()), map_x,
|
||||
map_y);
|
||||
ow_map_canvas_.DrawText(absl::StrFormat("%s", sprite.name()), sprite_x,
|
||||
sprite_y);
|
||||
|
||||
// Restore original coordinates
|
||||
sprite.x_ = original_x;
|
||||
sprite.y_ = original_y;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user