Add menu bar to tile16 editor

This commit is contained in:
scawful
2024-04-10 09:30:02 -04:00
parent ae8ca72402
commit a6ef95c5dd
2 changed files with 52 additions and 37 deletions

View File

@@ -50,6 +50,7 @@ absl::Status Tile16Editor::Update() {
*tile8_source_canvas_.custom_labels_enabled() = true;
}
RETURN_IF_ERROR(DrawMenu());
if (BeginTabBar("Tile16 Editor Tabs")) {
RETURN_IF_ERROR(DrawTile16Editor());
RETURN_IF_ERROR(UpdateTile16Transfer());
@@ -60,10 +61,14 @@ absl::Status Tile16Editor::Update() {
}
absl::Status Tile16Editor::DrawMenu() {
if (ImGui::BeginMenu("Tile16 Editor")) {
ImGui::Checkbox("Show Collision Types",
tile8_source_canvas_.custom_labels_enabled());
ImGui::EndMenu();
if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("View")) {
ImGui::Checkbox("Show Collision Types",
tile8_source_canvas_.custom_labels_enabled());
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
return absl::OkStatus();
@@ -209,8 +214,7 @@ absl::Status Tile16Editor::UpdateTile16Edit() {
tile16_edit_canvas_.DrawOverlay();
}
ImGui::EndChild();
DrawTileEditControls();
RETURN_IF_ERROR(DrawTileEditControls());
return absl::OkStatus();
}

View File

@@ -245,7 +245,8 @@ absl::Status OverworldEditor::DrawToolset() {
if (show_tile16_editor_) {
// Create a table in ImGui for the Tile16 Editor
ImGui::Begin("Tile16 Editor", &show_tile16_editor_);
ImGui::Begin("Tile16 Editor", &show_tile16_editor_,
ImGuiWindowFlags_MenuBar);
RETURN_IF_ERROR(tile16_editor_.Update())
ImGui::End();
}
@@ -346,6 +347,9 @@ void OverworldEditor::RefreshOverworldMap() {
// TODO: Palette throws out of bounds error unexpectedly.
absl::Status OverworldEditor::RefreshMapPalette() {
const auto current_map_palette =
overworld_.overworld_map(current_map_)->current_palette();
if (overworld_.overworld_map(current_map_)->is_large_map()) {
// We need to update the map and its siblings if it's a large map
for (int i = 1; i < 4; i++) {
@@ -353,14 +357,12 @@ absl::Status OverworldEditor::RefreshMapPalette() {
if (i >= 2) sibling_index += 6;
RETURN_IF_ERROR(
overworld_.mutable_overworld_map(sibling_index)->LoadPalette());
RETURN_IF_ERROR(maps_bmp_[sibling_index].ApplyPalette(
*overworld_.mutable_overworld_map(sibling_index)
->mutable_current_palette()));
RETURN_IF_ERROR(
maps_bmp_[sibling_index].ApplyPalette(current_map_palette));
}
}
RETURN_IF_ERROR(maps_bmp_[current_map_].ApplyPalette(
*overworld_.mutable_overworld_map(current_map_)
->mutable_current_palette()));
RETURN_IF_ERROR(maps_bmp_[current_map_].ApplyPalette(current_map_palette));
return absl::OkStatus();
}
@@ -414,6 +416,7 @@ void OverworldEditor::DrawOverworldMapSettings() {
kInputFieldSize)) {
RefreshMapProperties();
status_ = RefreshMapPalette();
RefreshOverworldMap();
}
ImGui::EndGroup();
@@ -723,6 +726,7 @@ void OverworldEditor::DrawOverworldCanvas() {
CheckForOverworldEdits();
if (ImGui::IsItemHovered()) status_ = CheckForCurrentMap();
}
ow_map_canvas_.DrawGrid();
ow_map_canvas_.DrawOverlay();
ImGui::EndChild();
@@ -734,25 +738,30 @@ absl::Status OverworldEditor::DrawTile16Selector() {
gui::BeginChildWithScrollbar("##Tile16SelectorScrollRegion");
blockset_canvas_.DrawBackground();
gui::EndNoPadding();
blockset_canvas_.DrawContextMenu();
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, /*border_offset=*/2,
map_blockset_loaded_);
if (blockset_canvas_.DrawTileSelector(32.0f)) {
// Open the tile16 editor to the tile
auto tile_pos = blockset_canvas_.points().front();
int grid_x = static_cast<int>(tile_pos.x / 32);
int grid_y = static_cast<int>(tile_pos.y / 32);
int id = grid_x + grid_y * 8;
RETURN_IF_ERROR(tile16_editor_.set_tile16(id));
show_tile16_editor_ = true;
{
blockset_canvas_.DrawContextMenu();
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, /*border_offset=*/2,
map_blockset_loaded_);
if (blockset_canvas_.DrawTileSelector(32.0f)) {
// Open the tile16 editor to the tile
auto tile_pos = blockset_canvas_.points().front();
int grid_x = static_cast<int>(tile_pos.x / 32);
int grid_y = static_cast<int>(tile_pos.y / 32);
int id = grid_x + grid_y * 8;
RETURN_IF_ERROR(tile16_editor_.set_tile16(id));
show_tile16_editor_ = true;
}
if (ImGui::IsItemClicked() && !blockset_canvas_.points().empty()) {
int x = blockset_canvas_.points().front().x / 32;
int y = blockset_canvas_.points().front().y / 32;
current_tile16_ = x + (y * 8);
}
blockset_canvas_.DrawGrid();
blockset_canvas_.DrawOverlay();
}
if (ImGui::IsItemClicked() && !blockset_canvas_.points().empty()) {
int x = blockset_canvas_.points().front().x / 32;
int y = blockset_canvas_.points().front().y / 32;
current_tile16_ = x + (y * 8);
}
blockset_canvas_.DrawGrid();
blockset_canvas_.DrawOverlay();
ImGui::EndChild();
ImGui::EndGroup();
return absl::OkStatus();
@@ -798,12 +807,14 @@ void OverworldEditor::DrawAreaGraphics() {
gui::BeginChildWithScrollbar("##AreaGraphicsScrollRegion");
current_gfx_canvas_.DrawBackground();
gui::EndPadding();
current_gfx_canvas_.DrawContextMenu();
current_gfx_canvas_.DrawBitmap(current_graphics_set_[current_map_],
/*border_offset=*/2, overworld_.is_loaded());
current_gfx_canvas_.DrawTileSelector(32.0f);
current_gfx_canvas_.DrawGrid();
current_gfx_canvas_.DrawOverlay();
{
current_gfx_canvas_.DrawContextMenu();
current_gfx_canvas_.DrawBitmap(current_graphics_set_[current_map_],
/*border_offset=*/2, overworld_.is_loaded());
current_gfx_canvas_.DrawTileSelector(32.0f);
current_gfx_canvas_.DrawGrid();
current_gfx_canvas_.DrawOverlay();
}
ImGui::EndChild();
ImGui::EndGroup();
}