Dungeon and Graphics Editor improvements
This commit is contained in:
@@ -110,47 +110,47 @@ void DungeonEditor::DrawToolset() {
|
|||||||
TableSetupColumn("#doorTool");
|
TableSetupColumn("#doorTool");
|
||||||
TableSetupColumn("#blockTool");
|
TableSetupColumn("#blockTool");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::Button(ICON_MD_UNDO)) {
|
if (ImGui::Button(ICON_MD_UNDO)) {
|
||||||
PRINT_IF_ERROR(Undo());
|
PRINT_IF_ERROR(Undo());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::Button(ICON_MD_REDO)) {
|
if (ImGui::Button(ICON_MD_REDO)) {
|
||||||
PRINT_IF_ERROR(Redo());
|
PRINT_IF_ERROR(Redo());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
ImGui::Text(ICON_MD_MORE_VERT);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_FILTER_NONE,
|
if (ImGui::RadioButton(ICON_MD_FILTER_NONE,
|
||||||
background_type_ == kBackgroundAny)) {
|
background_type_ == kBackgroundAny)) {
|
||||||
background_type_ = kBackgroundAny;
|
background_type_ = kBackgroundAny;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_FILTER_1,
|
if (ImGui::RadioButton(ICON_MD_FILTER_1,
|
||||||
background_type_ == kBackground1)) {
|
background_type_ == kBackground1)) {
|
||||||
background_type_ = kBackground1;
|
background_type_ = kBackground1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_FILTER_2,
|
if (ImGui::RadioButton(ICON_MD_FILTER_2,
|
||||||
background_type_ == kBackground2)) {
|
background_type_ == kBackground2)) {
|
||||||
background_type_ = kBackground2;
|
background_type_ = kBackground2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_FILTER_3,
|
if (ImGui::RadioButton(ICON_MD_FILTER_3,
|
||||||
background_type_ == kBackground3)) {
|
background_type_ == kBackground3)) {
|
||||||
background_type_ = kBackground3;
|
background_type_ = kBackground3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
ImGui::Text(ICON_MD_MORE_VERT);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_PEST_CONTROL, placement_type_ == kSprite)) {
|
if (ImGui::RadioButton(ICON_MD_PEST_CONTROL, placement_type_ == kSprite)) {
|
||||||
placement_type_ = kSprite;
|
placement_type_ = kSprite;
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ void DungeonEditor::DrawToolset() {
|
|||||||
ImGui::SetTooltip("Sprites");
|
ImGui::SetTooltip("Sprites");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_GRASS, placement_type_ == kItem)) {
|
if (ImGui::RadioButton(ICON_MD_GRASS, placement_type_ == kItem)) {
|
||||||
placement_type_ = kItem;
|
placement_type_ = kItem;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ void DungeonEditor::DrawToolset() {
|
|||||||
ImGui::SetTooltip("Items");
|
ImGui::SetTooltip("Items");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_SENSOR_DOOR, placement_type_ == kDoor)) {
|
if (ImGui::RadioButton(ICON_MD_SENSOR_DOOR, placement_type_ == kDoor)) {
|
||||||
placement_type_ = kDoor;
|
placement_type_ = kDoor;
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ void DungeonEditor::DrawToolset() {
|
|||||||
ImGui::SetTooltip("Doors");
|
ImGui::SetTooltip("Doors");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::RadioButton(ICON_MD_SQUARE, placement_type_ == kBlock)) {
|
if (ImGui::RadioButton(ICON_MD_SQUARE, placement_type_ == kBlock)) {
|
||||||
placement_type_ = kBlock;
|
placement_type_ = kBlock;
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ void DungeonEditor::DrawToolset() {
|
|||||||
ImGui::SetTooltip("Blocks");
|
ImGui::SetTooltip("Blocks");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (ImGui::Button(ICON_MD_PALETTE)) {
|
if (ImGui::Button(ICON_MD_PALETTE)) {
|
||||||
palette_showing_ = !palette_showing_;
|
palette_showing_ = !palette_showing_;
|
||||||
}
|
}
|
||||||
@@ -219,6 +219,12 @@ void DungeonEditor::DrawDungeonTabView() {
|
|||||||
if (ImGui::BeginTabBar("MyTabBar", kDungeonTabBarFlags)) {
|
if (ImGui::BeginTabBar("MyTabBar", kDungeonTabBarFlags)) {
|
||||||
// TODO: Manage the room that is being added to the tab bar.
|
// TODO: Manage the room that is being added to the tab bar.
|
||||||
if (ImGui::TabItemButton("+", kDungeonTabFlags)) {
|
if (ImGui::TabItemButton("+", kDungeonTabFlags)) {
|
||||||
|
if (std::find(active_rooms_.begin(), active_rooms_.end(),
|
||||||
|
current_room_id_) != active_rooms_.end()) {
|
||||||
|
// Room is already open
|
||||||
|
next_tab_id++;
|
||||||
|
}
|
||||||
|
|
||||||
active_rooms_.push_back(next_tab_id++); // Add new tab
|
active_rooms_.push_back(next_tab_id++); // Add new tab
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +275,11 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) {
|
|||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
canvas_.DrawBackground();
|
canvas_.DrawBackground(ImVec2(0x200, 0x200));
|
||||||
canvas_.DrawContextMenu();
|
canvas_.DrawContextMenu();
|
||||||
|
if (is_loaded_) {
|
||||||
|
canvas_.DrawBitmap(rooms_[room_id].layer1(), 0, 0);
|
||||||
|
}
|
||||||
canvas_.DrawGrid();
|
canvas_.DrawGrid();
|
||||||
canvas_.DrawOverlay();
|
canvas_.DrawOverlay();
|
||||||
}
|
}
|
||||||
@@ -328,7 +337,7 @@ void DungeonEditor::DrawObjectRenderer() {
|
|||||||
ImGui::GetContentRegionAvail().x);
|
ImGui::GetContentRegionAvail().x);
|
||||||
TableSetupColumn("Canvas");
|
TableSetupColumn("Canvas");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::BeginChild("DungeonObjectButtons", ImVec2(250, 0), true);
|
ImGui::BeginChild("DungeonObjectButtons", ImVec2(250, 0), true);
|
||||||
|
|
||||||
int selected_object = 0;
|
int selected_object = 0;
|
||||||
@@ -348,7 +357,7 @@ void DungeonEditor::DrawObjectRenderer() {
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
// Right side of the table - Canvas
|
// Right side of the table - Canvas
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
ImGui::BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1),
|
ImGui::BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using ImGui::Button;
|
|||||||
using ImGui::InputInt;
|
using ImGui::InputInt;
|
||||||
using ImGui::InputText;
|
using ImGui::InputText;
|
||||||
using ImGui::SameLine;
|
using ImGui::SameLine;
|
||||||
|
using ImGui::TableNextColumn;
|
||||||
|
|
||||||
constexpr ImGuiTableFlags kGfxEditTableFlags =
|
constexpr ImGuiTableFlags kGfxEditTableFlags =
|
||||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable |
|
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable |
|
||||||
@@ -87,38 +88,41 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
|||||||
"Zoom In", "Current Color", "Tile Size"})
|
"Zoom In", "Current Color", "Tile Size"})
|
||||||
ImGui::TableSetupColumn(name);
|
ImGui::TableSetupColumn(name);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_SELECT_ALL)) {
|
if (Button(ICON_MD_SELECT_ALL)) {
|
||||||
gfx_edit_mode_ = GfxEditMode::kSelect;
|
gfx_edit_mode_ = GfxEditMode::kSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_DRAW)) {
|
if (Button(ICON_MD_DRAW)) {
|
||||||
gfx_edit_mode_ = GfxEditMode::kPencil;
|
gfx_edit_mode_ = GfxEditMode::kPencil;
|
||||||
}
|
}
|
||||||
|
HOVER_HINT("Draw with current color");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_FORMAT_COLOR_FILL)) {
|
if (Button(ICON_MD_FORMAT_COLOR_FILL)) {
|
||||||
gfx_edit_mode_ = GfxEditMode::kFill;
|
gfx_edit_mode_ = GfxEditMode::kFill;
|
||||||
}
|
}
|
||||||
|
HOVER_HINT("Fill with current color");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_CONTENT_COPY)) {
|
if (Button(ICON_MD_CONTENT_COPY)) {
|
||||||
std::vector<uint8_t> png_data =
|
std::vector<uint8_t> png_data =
|
||||||
rom()->bitmap_manager().GetBitmap(current_sheet_)->GetPngData();
|
rom()->bitmap_manager().shared_bitmap(current_sheet_)->GetPngData();
|
||||||
CopyImageToClipboard(png_data);
|
CopyImageToClipboard(png_data);
|
||||||
}
|
}
|
||||||
|
HOVER_HINT("Copy to Clipboard");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_CONTENT_PASTE)) {
|
if (Button(ICON_MD_CONTENT_PASTE)) {
|
||||||
std::vector<uint8_t> png_data;
|
std::vector<uint8_t> png_data;
|
||||||
int width, height;
|
int width, height;
|
||||||
GetImageFromClipboard(png_data, width, height);
|
GetImageFromClipboard(png_data, width, height);
|
||||||
if (png_data.size() > 0) {
|
if (png_data.size() > 0) {
|
||||||
rom()
|
rom()
|
||||||
->bitmap_manager()
|
->mutable_bitmap_manager()
|
||||||
.GetBitmap(current_sheet_)
|
->mutable_bitmap(current_sheet_)
|
||||||
->LoadFromPngData(png_data, width, height);
|
->Create(width, height, 8, png_data);
|
||||||
rom()->UpdateBitmap(rom()
|
rom()->UpdateBitmap(rom()
|
||||||
->mutable_bitmap_manager()
|
->mutable_bitmap_manager()
|
||||||
->mutable_bitmap(current_sheet_)
|
->mutable_bitmap(current_sheet_)
|
||||||
@@ -127,21 +131,21 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
|||||||
}
|
}
|
||||||
HOVER_HINT("Paste from Clipboard");
|
HOVER_HINT("Paste from Clipboard");
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_ZOOM_OUT)) {
|
if (Button(ICON_MD_ZOOM_OUT)) {
|
||||||
if (current_scale_ >= 0.0f) {
|
if (current_scale_ >= 0.0f) {
|
||||||
current_scale_ -= 1.0f;
|
current_scale_ -= 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_ZOOM_IN)) {
|
if (Button(ICON_MD_ZOOM_IN)) {
|
||||||
if (current_scale_ <= 16.0f) {
|
if (current_scale_ <= 16.0f) {
|
||||||
current_scale_ += 1.0f;
|
current_scale_ += 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
auto bitmap = rom()->bitmap_manager()[current_sheet_];
|
auto bitmap = rom()->bitmap_manager()[current_sheet_];
|
||||||
auto palette = bitmap->palette();
|
auto palette = bitmap->palette();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
@@ -155,7 +159,7 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
gui::InputHexByte("Tile Size", &tile_size_, 0x01);
|
gui::InputHexByte("Tile Size", &tile_size_, 0x01);
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
@@ -174,7 +178,7 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() {
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
gui::Canvas graphics_bin_canvas_;
|
gui::Canvas graphics_bin_canvas_;
|
||||||
auto select_tile_event = [&]() {
|
auto select_tile_event = [&]() {
|
||||||
if (value.get()->IsActive()) {
|
if (value.get()->is_active()) {
|
||||||
auto texture = value.get()->texture();
|
auto texture = value.get()->texture();
|
||||||
graphics_bin_canvas_.GetDrawList()->AddImage(
|
graphics_bin_canvas_.GetDrawList()->AddImage(
|
||||||
(void*)texture,
|
(void*)texture,
|
||||||
@@ -424,7 +428,7 @@ absl::Status GraphicsEditor::DrawToolset() {
|
|||||||
for (const auto& name : kGfxToolsetColumnNames)
|
for (const auto& name : kGfxToolsetColumnNames)
|
||||||
ImGui::TableSetupColumn(name.data());
|
ImGui::TableSetupColumn(name.data());
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
TableNextColumn();
|
||||||
if (Button(ICON_MD_MEMORY)) {
|
if (Button(ICON_MD_MEMORY)) {
|
||||||
if (!open_memory_editor_) {
|
if (!open_memory_editor_) {
|
||||||
open_memory_editor_ = true;
|
open_memory_editor_ = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user