From 7fb71b6c38efb4473cfc9e994ec8d8c4587afcad Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 5 Oct 2024 12:09:49 -0400 Subject: [PATCH] Refactor message editor tables and constants This commit refactors the message editor code by introducing separate table flags for the message table and dictionary table. The message table now uses the kMessageTableFlags, which includes the Hideable, Borders, and Resizable flags. Similarly, the dictionary table now uses the kDictTableFlags, which includes the Borders and Resizable flags. Additionally, the commit adds two new constants to the message_editor.h file: kFontGfxMessageSize with a value of 128 and kFontGfxMessageDepth with a value of 8. These constants are used in the message_editor.cc file to specify the size and depth of the font graphics data. No functional changes are made in this commit. --- src/app/editor/message/message_editor.cc | 20 ++++++++++++-------- src/app/editor/message/message_editor.h | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/editor/message/message_editor.cc b/src/app/editor/message/message_editor.cc index fa459d55..f3273e2e 100644 --- a/src/app/editor/message/message_editor.cc +++ b/src/app/editor/message/message_editor.cc @@ -37,6 +37,13 @@ using ImGui::TableSetupColumn; using ImGui::Text; using ImGui::TextWrapped; +constexpr ImGuiTableFlags kMessageTableFlags = ImGuiTableFlags_Hideable | + ImGuiTableFlags_Borders | + ImGuiTableFlags_Resizable; + +constexpr ImGuiTableFlags kDictTableFlags = + ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable; + absl::Status MessageEditor::Initialize() { for (int i = 0; i < kWidthArraySize; i++) { width_array[i] = rom()->data()[kCharactersWidth + i]; @@ -58,7 +65,8 @@ absl::Status MessageEditor::Initialize() { // 4bpp RETURN_IF_ERROR(Renderer::GetInstance().CreateAndRenderBitmap( - 128, 128, 8, font_gfx16_data_, font_gfx_bitmap_, font_preview_colors_)) + kFontGfxMessageSize, kFontGfxMessageSize, kFontGfxMessageDepth, + font_gfx16_data_, font_gfx_bitmap_, font_preview_colors_)) current_font_gfx16_data_.reserve(kCurrentMessageWidth * kCurrentMessageHeight); @@ -122,8 +130,7 @@ absl::Status MessageEditor::Update() { data_loaded_ = true; } - if (BeginTable("##MessageEditor", 4, - ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) { + if (BeginTable("##MessageEditor", 4, kDictTableFlags)) { TableSetupColumn("List"); TableSetupColumn("Contents"); TableSetupColumn("Commands"); @@ -143,8 +150,7 @@ absl::Status MessageEditor::Update() { TableNextColumn(); if (ImGui::BeginChild("##DictionaryChild", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) { - if (BeginTable("##Dictionary", 2, - ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) { + if (BeginTable("##Dictionary", 2, kDictTableFlags)) { TableSetupColumn("ID"); TableSetupColumn("Contents"); @@ -173,9 +179,7 @@ void MessageEditor::DrawMessageList() { if (BeginChild("##MessagesList", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) { - if (BeginTable("##MessagesTable", 3, - ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | - ImGuiTableFlags_Resizable)) { + if (BeginTable("##MessagesTable", 3, kMessageTableFlags)) { TableSetupColumn("ID"); TableSetupColumn("Contents"); TableSetupColumn("Data"); diff --git a/src/app/editor/message/message_editor.h b/src/app/editor/message/message_editor.h index 4dd331a0..46fdd722 100644 --- a/src/app/editor/message/message_editor.h +++ b/src/app/editor/message/message_editor.h @@ -22,6 +22,8 @@ constexpr int kCharactersWidth = 0x74ADF; constexpr int kNumMessages = 396; constexpr int kCurrentMessageWidth = 172; constexpr int kCurrentMessageHeight = 4096; +constexpr int kFontGfxMessageSize = 128; +constexpr int kFontGfxMessageDepth = 8; constexpr uint8_t kWidthArraySize = 100; constexpr uint8_t kBlockTerminator = 0x80;