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