Refactor message pattern generation in TextElement for improved readability and maintainability; update table flags in MessageEditor for consistency.
This commit is contained in:
@@ -176,11 +176,15 @@ struct TextElement {
|
|||||||
}
|
}
|
||||||
HasArgument = arg;
|
HasArgument = arg;
|
||||||
Description = description;
|
Description = description;
|
||||||
Pattern =
|
if (arg) {
|
||||||
arg ? "\\[" + Token + ":?([0-9A-F]{1,2})\\]" : "\\[" + Token + "\\]";
|
Pattern = absl::StrFormat(
|
||||||
Pattern = absl::StrReplaceAll(Pattern, {{"[", "\\["}, {"]", "\\]"}});
|
"\\[%s(:[0-9A-F]{1,2})?\\]",
|
||||||
StrictPattern = absl::StrCat("^", Pattern, "$");
|
absl::StrReplaceAll(Token, {{"[", "\\["}, {"]", "\\]"}}));
|
||||||
StrictPattern = "^" + Pattern + "$";
|
} else {
|
||||||
|
Pattern = absl::StrFormat(
|
||||||
|
"\\[%s\\]", absl::StrReplaceAll(Token, {{"[", "\\["}, {"]", "\\]"}}));
|
||||||
|
}
|
||||||
|
StrictPattern = absl::StrFormat("^%s$", Pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetParamToken(uint8_t value = 0) const {
|
std::string GetParamToken(uint8_t value = 0) const {
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ constexpr ImGuiTableFlags kMessageTableFlags = ImGuiTableFlags_Hideable |
|
|||||||
ImGuiTableFlags_Borders |
|
ImGuiTableFlags_Borders |
|
||||||
ImGuiTableFlags_Resizable;
|
ImGuiTableFlags_Resizable;
|
||||||
|
|
||||||
constexpr ImGuiTableFlags kDictTableFlags =
|
|
||||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable;
|
|
||||||
|
|
||||||
void MessageEditor::Initialize() {
|
void MessageEditor::Initialize() {
|
||||||
for (int i = 0; i < kWidthArraySize; i++) {
|
for (int i = 0; i < kWidthArraySize; i++) {
|
||||||
width_array[i] = rom()->data()[kCharactersWidth + i];
|
width_array[i] = rom()->data()[kCharactersWidth + i];
|
||||||
@@ -94,7 +91,7 @@ absl::Status MessageEditor::Update() {
|
|||||||
data_loaded_ = true;
|
data_loaded_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BeginTable("##MessageEditor", 4, kDictTableFlags)) {
|
if (BeginTable("##MessageEditor", 4, kMessageTableFlags)) {
|
||||||
TableSetupColumn("List");
|
TableSetupColumn("List");
|
||||||
TableSetupColumn("Contents");
|
TableSetupColumn("Contents");
|
||||||
TableSetupColumn("Commands");
|
TableSetupColumn("Commands");
|
||||||
@@ -145,8 +142,8 @@ void MessageEditor::DrawMessageList() {
|
|||||||
|
|
||||||
EndTable();
|
EndTable();
|
||||||
}
|
}
|
||||||
EndChild();
|
|
||||||
}
|
}
|
||||||
|
EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageEditor::DrawCurrentMessage() {
|
void MessageEditor::DrawCurrentMessage() {
|
||||||
@@ -179,7 +176,7 @@ void MessageEditor::DrawCurrentMessage() {
|
|||||||
Renderer::GetInstance().UpdateBitmap(¤t_font_gfx16_bitmap_);
|
Renderer::GetInstance().UpdateBitmap(¤t_font_gfx16_bitmap_);
|
||||||
}
|
}
|
||||||
gui::BeginPadding(1);
|
gui::BeginPadding(1);
|
||||||
BeginChild("CurrentGfxFont", ImVec2(0, 0), true,
|
BeginChild("CurrentGfxFont", ImVec2(200, 0), true,
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||||
current_font_gfx16_canvas_.DrawBackground();
|
current_font_gfx16_canvas_.DrawBackground();
|
||||||
gui::EndPadding();
|
gui::EndPadding();
|
||||||
@@ -195,19 +192,22 @@ void MessageEditor::DrawTextCommands() {
|
|||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||||
for (const auto &text_element : TextCommands) {
|
for (const auto &text_element : TextCommands) {
|
||||||
if (Button(text_element.GenericToken.c_str())) {
|
if (Button(text_element.GenericToken.c_str())) {
|
||||||
|
// Insert the command into the message text box.
|
||||||
|
message_text_box_.text.append(text_element.GenericToken);
|
||||||
}
|
}
|
||||||
SameLine();
|
SameLine();
|
||||||
TextWrapped("%s", text_element.Description.c_str());
|
TextWrapped("%s", text_element.Description.c_str());
|
||||||
Separator();
|
Separator();
|
||||||
}
|
}
|
||||||
EndChild();
|
|
||||||
}
|
}
|
||||||
|
EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageEditor::DrawDictionary() {
|
void MessageEditor::DrawDictionary() {
|
||||||
if (ImGui::BeginChild("##DictionaryChild", ImVec2(0, 0), true,
|
if (ImGui::BeginChild("##DictionaryChild", ImVec2(0, 0), true,
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||||
if (BeginTable("##Dictionary", 2, kDictTableFlags)) {
|
if (BeginTable("##Dictionary", 2, kMessageTableFlags)) {
|
||||||
|
TableHeadersRow();
|
||||||
TableSetupColumn("ID");
|
TableSetupColumn("ID");
|
||||||
TableSetupColumn("Contents");
|
TableSetupColumn("Contents");
|
||||||
|
|
||||||
@@ -219,9 +219,8 @@ void MessageEditor::DrawDictionary() {
|
|||||||
}
|
}
|
||||||
EndTable();
|
EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
EndChild();
|
|
||||||
}
|
}
|
||||||
|
EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageEditor::ReadAllTextDataV2() {
|
void MessageEditor::ReadAllTextDataV2() {
|
||||||
|
|||||||
Reference in New Issue
Block a user