cleanup dungeon room constants

This commit is contained in:
scawful
2023-11-20 06:18:28 -05:00
parent 72ef0d0536
commit 4ef2540d15
6 changed files with 147 additions and 196 deletions

View File

@@ -14,12 +14,12 @@ namespace yaze {
namespace app {
namespace editor {
void DungeonEditor::Update() {
absl::Status DungeonEditor::Update() {
if (!is_loaded_ && rom()->isLoaded()) {
for (int i = 0; i < 0x100; i++) {
rooms_.emplace_back(zelda3::dungeon::Room(i));
rooms_[i].LoadHeader();
// rooms_[i].LoadRoomGraphics(rooms_[i].blockset);
rooms_[i].LoadRoomGraphics(rooms_[i].blockset);
}
is_loaded_ = true;
}
@@ -59,6 +59,7 @@ void DungeonEditor::Update() {
DrawTileSelector();
ImGui::EndTable();
}
return absl::OkStatus();
}
// Using ImGui Custom Tabs show each individual room the user selects from the
@@ -66,13 +67,6 @@ void DungeonEditor::Update() {
void DungeonEditor::DrawDungeonTabView() {
static int next_tab_id = 0;
// TabItemButton() and Leading/Trailing flags are distinct features which we
// will demo together. (It is possible to submit regular tabs with
// Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing
// flags... but they tend to make more sense together)
static bool show_trailing_button = true;
ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
// Expose some other flags which are useful to showcase how they interact with
// Leading/Trailing tabs
static ImGuiTabBarFlags tab_bar_flags =
@@ -92,14 +86,11 @@ void DungeonEditor::DrawDungeonTabView() {
ImGuiTabBarFlags_FittingPolicyScroll);
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) {
// Demo Trailing Tabs: click the "+" button to add a new tab (in your app
// you may want to use a font icon instead of the "+") Note that we submit
// it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing
// flag it will always appear at the end.
if (show_trailing_button)
if (ImGui::TabItemButton(
"+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip))
active_rooms_.push_back(next_tab_id++); // Add new tab
// TODO: Manage the room that is being added to the tab bar.
if (ImGui::TabItemButton(
"+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip)) {
active_rooms_.push_back(next_tab_id++); // Add new tab
}
// Submit our regular tabs
for (int n = 0; n < active_rooms_.Size;) {
@@ -168,10 +159,14 @@ void DungeonEditor::DrawToolset() {
ImGui::TableSetupColumn("#spriteTool");
ImGui::TableNextColumn();
ImGui::Button(ICON_MD_UNDO);
if (ImGui::Button(ICON_MD_UNDO)) {
PRINT_IF_ERROR(Undo());
}
ImGui::TableNextColumn();
ImGui::Button(ICON_MD_REDO);
if (ImGui::Button(ICON_MD_REDO)) {
PRINT_IF_ERROR(Redo());
}
ImGui::TableNextColumn();
ImGui::Button(ICON_MD_MANAGE_HISTORY);

View File

@@ -4,6 +4,7 @@
#include <imgui/imgui.h>
#include "app/core/common.h"
#include "app/core/editor.h"
#include "app/gui/canvas.h"
#include "app/gui/icons.h"
#include "app/rom.h"
@@ -14,9 +15,14 @@ namespace yaze {
namespace app {
namespace editor {
class DungeonEditor : public SharedROM {
class DungeonEditor : public Editor, public SharedROM {
public:
void Update();
absl::Status Update() override;
absl::Status Cut() override { return absl::OkStatus(); }
absl::Status Copy() override { return absl::OkStatus(); }
absl::Status Paste() override { return absl::OkStatus(); }
absl::Status Undo() override { return absl::OkStatus(); }
absl::Status Redo() override { return absl::OkStatus(); }
private:
void DrawToolset();
@@ -26,6 +32,7 @@ class DungeonEditor : public SharedROM {
void DrawRoomGraphics();
void DrawTileSelector();
uint16_t current_room_id_ = 0;
bool is_loaded_ = false;
gfx::Bitmap room_gfx_bmp_;