GraphicsEditor, OverworldEditor housekeeping
This commit is contained in:
@@ -219,93 +219,60 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
|||||||
open_sheets_.insert(next_tab_id++);
|
open_sheets_.insert(next_tab_id++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit our regular tabs
|
for (auto& sheet_id : open_sheets_) {
|
||||||
for (auto& each : open_sheets_) {
|
current_sheet_ = sheet_id;
|
||||||
current_sheet_ = each;
|
|
||||||
|
|
||||||
bool open = true;
|
bool open = true;
|
||||||
if (ImGui::BeginTabItem(absl::StrFormat("%d", each).c_str(), &open,
|
if (ImGui::BeginTabItem(absl::StrFormat("%d", sheet_id).c_str(), &open,
|
||||||
ImGuiTabItemFlags_None)) {
|
ImGuiTabItemFlags_None)) {
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||||
release_queue_.push(each);
|
release_queue_.push(sheet_id);
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
|
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
|
||||||
release_queue_.push(each);
|
release_queue_.push(sheet_id);
|
||||||
child_window_sheets_.insert(each);
|
child_window_sheets_.insert(sheet_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto child_id =
|
const auto child_id =
|
||||||
absl::StrFormat("##GfxEditPaletteChildWindow%d", each);
|
absl::StrFormat("##GfxEditPaletteChildWindow%d", sheet_id);
|
||||||
ImGui::BeginChild(child_id.c_str(), ImVec2(0, 0), true,
|
ImGui::BeginChild(child_id.c_str(), ImVec2(0, 0), true,
|
||||||
ImGuiWindowFlags_NoDecoration |
|
ImGuiWindowFlags_NoDecoration |
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
||||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
||||||
|
|
||||||
auto draw_tile_event = [&]() {
|
auto draw_tile_event = [&]() {
|
||||||
// Convert the ImVec4 into a 16-bit value
|
uint16_t snes_color = gfx::ConvertRGBtoSNES(current_color_);
|
||||||
Uint8 r = static_cast<Uint8>(current_color_.x * 31);
|
auto click_position = current_sheet_canvas_.drawn_tile_position();
|
||||||
Uint8 g = static_cast<Uint8>(current_color_.y * 31);
|
gfx::Bitmap& current_bitmap = *rom()->bitmap_manager()[sheet_id];
|
||||||
Uint8 b = static_cast<Uint8>(current_color_.z * 31);
|
current_sheet_canvas_.DrawTileOnBitmap(click_position, tile_size_,
|
||||||
Uint16 snes_color =
|
current_bitmap, snes_color);
|
||||||
((r & 0x1F) << 10) | ((g & 0x1F) << 5) | (b & 0x1F);
|
auto& bitmap = *rom()->bitmap_manager().mutable_bitmap(sheet_id);
|
||||||
|
rom()->UpdateBitmap(&bitmap);
|
||||||
auto click_position =
|
|
||||||
current_sheet_canvas_.GetCurrentDrawnTilePosition();
|
|
||||||
|
|
||||||
// Calculate the tile index for x and y based on the
|
|
||||||
// click_position
|
|
||||||
int tile_index_x =
|
|
||||||
(static_cast<int>(click_position.x) % 8) / tile_size_;
|
|
||||||
int tile_index_y =
|
|
||||||
(static_cast<int>(click_position.y) % 8) / tile_size_;
|
|
||||||
|
|
||||||
// Calculate the pixel start position based on tile index and tile
|
|
||||||
// size
|
|
||||||
ImVec2 start_position;
|
|
||||||
start_position.x = tile_index_x * tile_size_;
|
|
||||||
start_position.y = tile_index_y * tile_size_;
|
|
||||||
|
|
||||||
// Get the current map's bitmap from the BitmapTable
|
|
||||||
gfx::Bitmap& current_bitmap = *rom()->bitmap_manager()[each];
|
|
||||||
|
|
||||||
// Update the bitmap's pixel data based on the start_position and
|
|
||||||
// tile_data
|
|
||||||
for (int y = 0; y < tile_size_; ++y) {
|
|
||||||
for (int x = 0; x < tile_size_; ++x) {
|
|
||||||
int pixel_index =
|
|
||||||
(start_position.y + y) * current_bitmap.width() +
|
|
||||||
(start_position.x + x);
|
|
||||||
current_bitmap.WriteToPixel(pixel_index, snes_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rom()->bitmap_manager()[each]->WriteToPixel(position,
|
|
||||||
// snesColor);
|
|
||||||
|
|
||||||
rom()->UpdateBitmap(
|
|
||||||
rom()->mutable_bitmap_manager()->mutable_bitmap(each).get());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
current_sheet_canvas_.UpdateColorPainter(
|
current_sheet_canvas_.UpdateColorPainter(
|
||||||
*rom()->bitmap_manager()[each], current_color_, draw_tile_event,
|
*rom()->bitmap_manager()[sheet_id], current_color_, draw_tile_event,
|
||||||
ImVec2(0x100, 0x40), tile_size_, current_scale_, 8.0f);
|
ImVec2(0x100, 0x40), tile_size_, current_scale_, 8.0f);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!open) release_queue_.push(each);
|
if (!open) release_queue_.push(sheet_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release any tabs that were closed
|
||||||
while (!release_queue_.empty()) {
|
while (!release_queue_.empty()) {
|
||||||
auto each = release_queue_.top();
|
auto sheet_id = release_queue_.top();
|
||||||
open_sheets_.erase(each);
|
open_sheets_.erase(sheet_id);
|
||||||
release_queue_.pop();
|
release_queue_.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw any child windows that were created
|
||||||
if (!child_window_sheets_.empty()) {
|
if (!child_window_sheets_.empty()) {
|
||||||
int id_to_release = -1;
|
int id_to_release = -1;
|
||||||
for (const auto& id : child_window_sheets_) {
|
for (const auto& id : child_window_sheets_) {
|
||||||
|
|||||||
@@ -185,9 +185,10 @@ absl::Status OverworldEditor::DrawToolset() {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OverworldEditor::DrawOverworldMapSettings() {
|
void OverworldEditor::DrawOverworldMapSettings() {
|
||||||
if (ImGui::BeginTable(kOWMapTable.data(), 8, kOWMapFlags, ImVec2(0, 0), -1)) {
|
if (ImGui::BeginTable(kOWMapTable.data(), 7, kOWMapFlags, ImVec2(0, 0), -1)) {
|
||||||
for (const auto &name : kOverworldSettingsColumnNames)
|
for (const auto &name : {"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
||||||
ImGui::TableSetupColumn(name.data());
|
"##sprpalCol", "##msgidCol", "##2ndCol"})
|
||||||
|
ImGui::TableSetupColumn(name);
|
||||||
|
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(120.f);
|
ImGui::SetNextItemWidth(120.f);
|
||||||
@@ -225,11 +226,8 @@ void OverworldEditor::DrawOverworldMapSettings() {
|
|||||||
|
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(100.f);
|
ImGui::SetNextItemWidth(100.f);
|
||||||
ImGui::Combo("##World", &game_state_, kGamePartComboString, 3);
|
ImGui::Combo("##World", &game_state_, kGamePartComboString.data(), 3);
|
||||||
|
|
||||||
// TODO: Make enable grid bool change the current canvas.
|
|
||||||
TableNextColumn();
|
|
||||||
ImGui::Checkbox("Show grid", &opt_enable_grid);
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,7 +326,7 @@ void OverworldEditor::DrawOverworldSprites() {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OverworldEditor::DrawOverworldEdits() {
|
void OverworldEditor::DrawOverworldEdits() {
|
||||||
auto mouse_position = ow_map_canvas_.GetCurrentDrawnTilePosition();
|
auto mouse_position = ow_map_canvas_.drawn_tile_position();
|
||||||
auto canvas_size = ow_map_canvas_.GetCanvasSize();
|
auto canvas_size = ow_map_canvas_.GetCanvasSize();
|
||||||
int x = mouse_position.x / canvas_size.x;
|
int x = mouse_position.x / canvas_size.x;
|
||||||
int y = mouse_position.y / canvas_size.y;
|
int y = mouse_position.y / canvas_size.y;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/editor.h"
|
#include "app/core/editor.h"
|
||||||
#include "app/gui/pipeline.h"
|
|
||||||
#include "app/editor/modules/gfx_group_editor.h"
|
#include "app/editor/modules/gfx_group_editor.h"
|
||||||
#include "app/editor/modules/palette_editor.h"
|
#include "app/editor/modules/palette_editor.h"
|
||||||
#include "app/editor/modules/tile16_editor.h"
|
#include "app/editor/modules/tile16_editor.h"
|
||||||
@@ -21,6 +20,7 @@
|
|||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
|
#include "app/gui/pipeline.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld.h"
|
#include "app/zelda3/overworld.h"
|
||||||
|
|
||||||
@@ -41,10 +41,6 @@ static constexpr absl::string_view kToolsetColumnNames[] = {
|
|||||||
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
||||||
"#transportTool", "#musicTool", "#separator3", "#tilemapTool"};
|
"#transportTool", "#musicTool", "#separator3", "#tilemapTool"};
|
||||||
|
|
||||||
static constexpr absl::string_view kOverworldSettingsColumnNames[] = {
|
|
||||||
"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
|
||||||
"##sprpalCol", "##msgidCol", "##2ndCol"};
|
|
||||||
|
|
||||||
constexpr ImGuiTableFlags kOWMapFlags = ImGuiTableFlags_Borders;
|
constexpr ImGuiTableFlags kOWMapFlags = ImGuiTableFlags_Borders;
|
||||||
constexpr ImGuiTableFlags kToolsetTableFlags = ImGuiTableFlags_SizingFixedFit;
|
constexpr ImGuiTableFlags kToolsetTableFlags = ImGuiTableFlags_SizingFixedFit;
|
||||||
constexpr ImGuiTableFlags kOWEditFlags =
|
constexpr ImGuiTableFlags kOWEditFlags =
|
||||||
@@ -55,7 +51,7 @@ constexpr ImGuiTableFlags kOWEditFlags =
|
|||||||
constexpr absl::string_view kWorldList =
|
constexpr absl::string_view kWorldList =
|
||||||
"Light World\0Dark World\0Extra World\0";
|
"Light World\0Dark World\0Extra World\0";
|
||||||
|
|
||||||
constexpr char *const kGamePartComboString[] = {"Part 0", "Part 1", "Part 2"};
|
constexpr absl::string_view kGamePartComboString = "Part 0\0Part 1\0Part 2\0";
|
||||||
|
|
||||||
constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
|
constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
|
||||||
constexpr absl::string_view kOWEditTable = "##OWEditTable";
|
constexpr absl::string_view kOWEditTable = "##OWEditTable";
|
||||||
|
|||||||
Reference in New Issue
Block a user