Canvas Gui and styling improvements, helper fns
This commit is contained in:
@@ -375,7 +375,7 @@ void DungeonEditor::DrawRoomGraphics() {
|
|||||||
if (current_block >= 1) {
|
if (current_block >= 1) {
|
||||||
top_left_y = room_gfx_canvas_.zero_point().y + height * current_block;
|
top_left_y = room_gfx_canvas_.zero_point().y + height * current_block;
|
||||||
}
|
}
|
||||||
room_gfx_canvas_.GetDrawList()->AddImage(
|
room_gfx_canvas_.draw_list()->AddImage(
|
||||||
(void*)graphics_bin_[block].texture(),
|
(void*)graphics_bin_[block].texture(),
|
||||||
ImVec2(room_gfx_canvas_.zero_point().x + 2, top_left_y),
|
ImVec2(room_gfx_canvas_.zero_point().x + 2, top_left_y),
|
||||||
ImVec2(room_gfx_canvas_.zero_point().x + 0x100,
|
ImVec2(room_gfx_canvas_.zero_point().x + 0x100,
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() {
|
|||||||
auto select_tile_event = [&]() {
|
auto select_tile_event = [&]() {
|
||||||
if (value.get()->is_active()) {
|
if (value.get()->is_active()) {
|
||||||
auto texture = value.get()->texture();
|
auto texture = value.get()->texture();
|
||||||
graphics_bin_canvas_.GetDrawList()->AddImage(
|
graphics_bin_canvas_.draw_list()->AddImage(
|
||||||
(void*)texture,
|
(void*)texture,
|
||||||
ImVec2(graphics_bin_canvas_.zero_point().x + 2,
|
ImVec2(graphics_bin_canvas_.zero_point().x + 2,
|
||||||
graphics_bin_canvas_.zero_point().y + 2),
|
graphics_bin_canvas_.zero_point().y + 2),
|
||||||
@@ -202,10 +202,10 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() {
|
|||||||
ImVec2 rent_min(text_pos.x, text_pos.y);
|
ImVec2 rent_min(text_pos.x, text_pos.y);
|
||||||
ImVec2 rent_max(text_pos.x + text_size.x, text_pos.y + text_size.y);
|
ImVec2 rent_max(text_pos.x + text_size.x, text_pos.y + text_size.y);
|
||||||
|
|
||||||
graphics_bin_canvas_.GetDrawList()->AddRectFilled(
|
graphics_bin_canvas_.draw_list()->AddRectFilled(
|
||||||
rent_min, rent_max, IM_COL32(0, 125, 0, 128));
|
rent_min, rent_max, IM_COL32(0, 125, 0, 128));
|
||||||
|
|
||||||
graphics_bin_canvas_.GetDrawList()->AddText(
|
graphics_bin_canvas_.draw_list()->AddText(
|
||||||
text_pos, IM_COL32(125, 255, 125, 255),
|
text_pos, IM_COL32(125, 255, 125, 255),
|
||||||
absl::StrFormat("%02X", key).c_str());
|
absl::StrFormat("%02X", key).c_str());
|
||||||
}
|
}
|
||||||
@@ -261,10 +261,9 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
|||||||
rom()->UpdateBitmap(¤t_bitmap);
|
rom()->UpdateBitmap(¤t_bitmap);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto size = ImVec2(0x80, 0x20);
|
|
||||||
current_sheet_canvas_.UpdateColorPainter(
|
current_sheet_canvas_.UpdateColorPainter(
|
||||||
*rom()->bitmap_manager()[sheet_id], current_color_, draw_tile_event,
|
*rom()->bitmap_manager()[sheet_id], current_color_, draw_tile_event,
|
||||||
size, tile_size_, current_scale_, 8.0f);
|
tile_size_, current_scale_);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
@@ -293,12 +292,13 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
|||||||
ImGui::Begin(absl::StrFormat("##GfxEditPaletteChildWindow%d", id).c_str(),
|
ImGui::Begin(absl::StrFormat("##GfxEditPaletteChildWindow%d", id).c_str(),
|
||||||
&active, ImGuiWindowFlags_AlwaysUseWindowPadding);
|
&active, ImGuiWindowFlags_AlwaysUseWindowPadding);
|
||||||
current_sheet_ = id;
|
current_sheet_ = id;
|
||||||
|
// ImVec2(0x100, 0x40),
|
||||||
current_sheet_canvas_.UpdateColorPainter(
|
current_sheet_canvas_.UpdateColorPainter(
|
||||||
*rom()->bitmap_manager()[id], current_color_,
|
*rom()->bitmap_manager()[id], current_color_,
|
||||||
[&]() {
|
[&]() {
|
||||||
|
|
||||||
},
|
},
|
||||||
ImVec2(0x100, 0x40), tile_size_, current_scale_, 8.0f);
|
tile_size_, current_scale_);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
if (active == false) {
|
if (active == false) {
|
||||||
|
|||||||
@@ -182,7 +182,8 @@ class GraphicsEditor : public SharedROM {
|
|||||||
gui::Canvas import_canvas_;
|
gui::Canvas import_canvas_;
|
||||||
gui::Canvas scr_canvas_;
|
gui::Canvas scr_canvas_;
|
||||||
gui::Canvas super_donkey_canvas_;
|
gui::Canvas super_donkey_canvas_;
|
||||||
gui::Canvas current_sheet_canvas_;
|
gui::Canvas current_sheet_canvas_{ImVec2(0x80, 0x20),
|
||||||
|
gui::CanvasGridSize::k8x8};
|
||||||
absl::Status status_;
|
absl::Status status_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -751,41 +751,47 @@ void OverworldEditor::DrawOverworldCanvas() {
|
|||||||
DrawOverworldMapSettings();
|
DrawOverworldMapSettings();
|
||||||
Separator();
|
Separator();
|
||||||
}
|
}
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
gui::BeginNoPadding();
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
gui::BeginChildBothScrollbars(7);
|
||||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)7);
|
ow_map_canvas_.DrawBackground();
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
gui::EndNoPadding();
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
ow_map_canvas_.DrawContextMenu();
|
||||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar)) {
|
if (overworld_.is_loaded()) {
|
||||||
ow_map_canvas_.DrawBackground(ImVec2(0x200 * 8, 0x200 * 8));
|
DrawOverworldMaps();
|
||||||
ImGui::PopStyleVar(2);
|
DrawOverworldEntrances(ow_map_canvas_.zero_point(),
|
||||||
ow_map_canvas_.DrawContextMenu();
|
ow_map_canvas_.scrolling());
|
||||||
if (overworld_.is_loaded()) {
|
DrawOverworldExits(ow_map_canvas_.zero_point(), ow_map_canvas_.scrolling());
|
||||||
DrawOverworldMaps();
|
if (flags()->kDrawOverworldSprites) {
|
||||||
DrawOverworldEntrances(ow_map_canvas_.zero_point(),
|
DrawOverworldSprites();
|
||||||
ow_map_canvas_.Scrolling());
|
|
||||||
DrawOverworldExits(ow_map_canvas_.zero_point(),
|
|
||||||
ow_map_canvas_.Scrolling());
|
|
||||||
if (flags()->kDrawOverworldSprites) {
|
|
||||||
DrawOverworldSprites();
|
|
||||||
}
|
|
||||||
CheckForCurrentMap();
|
|
||||||
CheckForOverworldEdits();
|
|
||||||
}
|
}
|
||||||
ow_map_canvas_.DrawGrid(64.0f);
|
// CheckForCurrentMap(); Performance Bottleneck
|
||||||
ow_map_canvas_.DrawOverlay();
|
CheckForOverworldEdits();
|
||||||
}
|
}
|
||||||
|
ow_map_canvas_.DrawGrid();
|
||||||
|
ow_map_canvas_.DrawOverlay();
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OverworldEditor::DrawTile16Selector() {
|
||||||
|
gui::BeginPadding(3);
|
||||||
|
gui::BeginChildWithScrollbar(/*id=*/1);
|
||||||
|
blockset_canvas_.DrawBackground();
|
||||||
|
gui::EndNoPadding();
|
||||||
|
blockset_canvas_.DrawContextMenu();
|
||||||
|
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, /*border_offset=*/2,
|
||||||
|
map_blockset_loaded_);
|
||||||
|
blockset_canvas_.DrawTileSelector(32.0f);
|
||||||
|
blockset_canvas_.DrawGrid();
|
||||||
|
blockset_canvas_.DrawOverlay();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tile 8 Selector
|
// Tile 8 Selector
|
||||||
// Displays all the individual tiles that make up a tile16.
|
// Displays all the individual tiles that make up a tile16.
|
||||||
void OverworldEditor::DrawTile8Selector() {
|
void OverworldEditor::DrawTile8Selector() {
|
||||||
graphics_bin_canvas_.DrawBackground(
|
graphics_bin_canvas_.DrawBackground();
|
||||||
ImVec2(0x100 + 1, kNumSheetsToLoad * 0x40 + 1));
|
|
||||||
graphics_bin_canvas_.DrawContextMenu();
|
graphics_bin_canvas_.DrawContextMenu();
|
||||||
if (all_gfx_loaded_) {
|
if (all_gfx_loaded_) {
|
||||||
// for (const auto &[key, value] : graphics_bin_) {
|
|
||||||
for (auto &[key, value] : rom()->bitmap_manager()) {
|
for (auto &[key, value] : rom()->bitmap_manager()) {
|
||||||
int offset = 0x40 * (key + 1);
|
int offset = 0x40 * (key + 1);
|
||||||
int top_left_y = graphics_bin_canvas_.zero_point().y + 2;
|
int top_left_y = graphics_bin_canvas_.zero_point().y + 2;
|
||||||
@@ -793,38 +799,48 @@ void OverworldEditor::DrawTile8Selector() {
|
|||||||
top_left_y = graphics_bin_canvas_.zero_point().y + 0x40 * key;
|
top_left_y = graphics_bin_canvas_.zero_point().y + 0x40 * key;
|
||||||
}
|
}
|
||||||
auto texture = value.get()->texture();
|
auto texture = value.get()->texture();
|
||||||
graphics_bin_canvas_.GetDrawList()->AddImage(
|
graphics_bin_canvas_.draw_list()->AddImage(
|
||||||
(void *)texture,
|
(void *)texture,
|
||||||
ImVec2(graphics_bin_canvas_.zero_point().x + 2, top_left_y),
|
ImVec2(graphics_bin_canvas_.zero_point().x + 2, top_left_y),
|
||||||
ImVec2(graphics_bin_canvas_.zero_point().x + 0x100,
|
ImVec2(graphics_bin_canvas_.zero_point().x + 0x100,
|
||||||
graphics_bin_canvas_.zero_point().y + offset));
|
graphics_bin_canvas_.zero_point().y + offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphics_bin_canvas_.DrawGrid(16.0f);
|
graphics_bin_canvas_.DrawGrid();
|
||||||
graphics_bin_canvas_.DrawOverlay();
|
graphics_bin_canvas_.DrawOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverworldEditor::DrawAreaGraphics() {
|
||||||
|
gui::BeginPadding(3);
|
||||||
|
gui::BeginChildWithScrollbar(/*id=*/2);
|
||||||
|
current_gfx_canvas_.DrawBackground();
|
||||||
|
gui::EndPadding();
|
||||||
|
current_gfx_canvas_.DrawContextMenu();
|
||||||
|
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_, /*border_offset=*/2,
|
||||||
|
overworld_.is_loaded());
|
||||||
|
current_gfx_canvas_.DrawTileSelector(32.0f);
|
||||||
|
current_gfx_canvas_.DrawGrid();
|
||||||
|
current_gfx_canvas_.DrawOverlay();
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
void OverworldEditor::DrawTileSelector() {
|
void OverworldEditor::DrawTileSelector() {
|
||||||
if (BeginTabBar(kTileSelectorTab.data(),
|
if (BeginTabBar(kTileSelectorTab.data(),
|
||||||
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
||||||
if (BeginTabItem("Tile16")) {
|
if (BeginTabItem("Tile16")) {
|
||||||
gui::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_, 0x100,
|
DrawTile16Selector();
|
||||||
(8192 * 2), 0x20, map_blockset_loaded_, true,
|
|
||||||
1);
|
|
||||||
EndTabItem();
|
EndTabItem();
|
||||||
}
|
}
|
||||||
if (BeginTabItem("Tile8")) {
|
if (BeginTabItem("Tile8")) {
|
||||||
if (ImGui::BeginChild("##tile8viewer", ImGui::GetContentRegionAvail(),
|
gui::BeginPadding(3);
|
||||||
true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
gui::BeginChildWithScrollbar(/*id=*/2);
|
||||||
DrawTile8Selector();
|
DrawTile8Selector();
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
gui::EndNoPadding();
|
||||||
EndTabItem();
|
EndTabItem();
|
||||||
}
|
}
|
||||||
if (BeginTabItem("Area Graphics")) {
|
if (BeginTabItem("Area Graphics")) {
|
||||||
gui::BitmapCanvasPipeline(current_gfx_canvas_, current_gfx_bmp_, 256,
|
DrawAreaGraphics();
|
||||||
0x10 * 0x40, 0x20, overworld_.is_loaded(), true,
|
|
||||||
3);
|
|
||||||
EndTabItem();
|
EndTabItem();
|
||||||
}
|
}
|
||||||
EndTabBar();
|
EndTabBar();
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ class OverworldEditor : public Editor,
|
|||||||
void CheckForCurrentMap();
|
void CheckForCurrentMap();
|
||||||
void DrawOverworldCanvas();
|
void DrawOverworldCanvas();
|
||||||
|
|
||||||
|
void DrawTile16Selector();
|
||||||
void DrawTile8Selector();
|
void DrawTile8Selector();
|
||||||
|
void DrawAreaGraphics();
|
||||||
void DrawTileSelector();
|
void DrawTileSelector();
|
||||||
|
|
||||||
absl::Status LoadSpriteGraphics();
|
absl::Status LoadSpriteGraphics();
|
||||||
@@ -187,10 +189,15 @@ class OverworldEditor : public Editor,
|
|||||||
PaletteEditor palette_editor_;
|
PaletteEditor palette_editor_;
|
||||||
zelda3::Overworld overworld_;
|
zelda3::Overworld overworld_;
|
||||||
|
|
||||||
gui::Canvas ow_map_canvas_;
|
gui::Canvas ow_map_canvas_{ImVec2(0x200 * 8, 0x200 * 8),
|
||||||
gui::Canvas current_gfx_canvas_;
|
gui::CanvasGridSize::k64x64};
|
||||||
gui::Canvas blockset_canvas_;
|
gui::Canvas current_gfx_canvas_{ImVec2(0x100 + 1, 0x10 * 0x40 + 1),
|
||||||
gui::Canvas graphics_bin_canvas_;
|
gui::CanvasGridSize::k32x32};
|
||||||
|
gui::Canvas blockset_canvas_{ImVec2(0x100 + 1, 0x2000 + 1),
|
||||||
|
gui::CanvasGridSize::k32x32};
|
||||||
|
gui::Canvas graphics_bin_canvas_{
|
||||||
|
ImVec2(0x100 + 1, kNumSheetsToLoad * 0x40 + 1),
|
||||||
|
gui::CanvasGridSize::k16x16};
|
||||||
gui::Canvas properties_canvas_;
|
gui::Canvas properties_canvas_;
|
||||||
|
|
||||||
gfx::SNESPalette palette_;
|
gfx::SNESPalette palette_;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void GraphicsBinCanvasPipeline(int width, int height, int tile_size,
|
|||||||
if (key >= 1) {
|
if (key >= 1) {
|
||||||
top_left_y = canvas.zero_point().y + height * key;
|
top_left_y = canvas.zero_point().y + height * key;
|
||||||
}
|
}
|
||||||
canvas.GetDrawList()->AddImage(
|
canvas.draw_list()->AddImage(
|
||||||
(void*)value.texture(),
|
(void*)value.texture(),
|
||||||
ImVec2(canvas.zero_point().x + 2, top_left_y),
|
ImVec2(canvas.zero_point().x + 2, top_left_y),
|
||||||
ImVec2(canvas.zero_point().x + 0x100,
|
ImVec2(canvas.zero_point().x + 0x100,
|
||||||
@@ -113,7 +113,7 @@ void GraphicsManagerCanvasPipeline(int width, int height, int tile_size,
|
|||||||
if (key >= 1) {
|
if (key >= 1) {
|
||||||
top_left_y = canvas.zero_point().y + height * key;
|
top_left_y = canvas.zero_point().y + height * key;
|
||||||
}
|
}
|
||||||
canvas.GetDrawList()->AddImage(
|
canvas.draw_list()->AddImage(
|
||||||
(void*)value->texture(),
|
(void*)value->texture(),
|
||||||
ImVec2(canvas.zero_point().x + 2, top_left_y),
|
ImVec2(canvas.zero_point().x + 2, top_left_y),
|
||||||
ImVec2(canvas.zero_point().x + 0x100,
|
ImVec2(canvas.zero_point().x + 0x100,
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
void BeginWindowWithDisplaySettings(const char* id, bool* active, const ImVec2& size,
|
void BeginWindowWithDisplaySettings(const char* id, bool* active,
|
||||||
ImGuiWindowFlags flags) {
|
const ImVec2& size,
|
||||||
|
ImGuiWindowFlags flags) {
|
||||||
ImGuiStyle* ref = &ImGui::GetStyle();
|
ImGuiStyle* ref = &ImGui::GetStyle();
|
||||||
static float childBgOpacity = 0.75f;
|
static float childBgOpacity = 0.75f;
|
||||||
auto color = ImVec4(0.f, 0.f, 0.f, childBgOpacity);
|
auto color = ImVec4(0.f, 0.f, 0.f, childBgOpacity);
|
||||||
@@ -31,6 +32,31 @@ void EndWindowWithDisplaySettings() {
|
|||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BeginPadding(int i) {
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(i, i));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(i, i));
|
||||||
|
}
|
||||||
|
void EndPadding() { EndNoPadding(); }
|
||||||
|
|
||||||
|
void BeginNoPadding() {
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||||
|
}
|
||||||
|
void EndNoPadding() { ImGui::PopStyleVar(2); }
|
||||||
|
|
||||||
|
void BeginChildWithScrollbar(int id) {
|
||||||
|
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)id);
|
||||||
|
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||||
|
ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeginChildBothScrollbars(int id) {
|
||||||
|
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)id);
|
||||||
|
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||||
|
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
||||||
|
ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawDisplaySettings(ImGuiStyle* ref) {
|
void DrawDisplaySettings(ImGuiStyle* ref) {
|
||||||
// You can pass in a reference ImGuiStyle structure to compare to, revert to
|
// You can pass in a reference ImGuiStyle structure to compare to, revert to
|
||||||
// and save to (without a reference style pointer, we will use one compared
|
// and save to (without a reference style pointer, we will use one compared
|
||||||
|
|||||||
@@ -15,6 +15,16 @@ void BeginWindowWithDisplaySettings(const char* id, bool* active,
|
|||||||
|
|
||||||
void EndWindowWithDisplaySettings();
|
void EndWindowWithDisplaySettings();
|
||||||
|
|
||||||
|
void BeginPadding(int i);
|
||||||
|
void EndPadding();
|
||||||
|
|
||||||
|
void BeginNoPadding();
|
||||||
|
void EndNoPadding();
|
||||||
|
|
||||||
|
void BeginChildWithScrollbar(int id);
|
||||||
|
|
||||||
|
void BeginChildBothScrollbars(int id);
|
||||||
|
|
||||||
void DrawDisplaySettings(ImGuiStyle* ref = nullptr);
|
void DrawDisplaySettings(ImGuiStyle* ref = nullptr);
|
||||||
|
|
||||||
void TextWithSeparators(const absl::string_view& text);
|
void TextWithSeparators(const absl::string_view& text);
|
||||||
|
|||||||
Reference in New Issue
Block a user