Add message preview functionality and refactor MessageEditor
- Introduced MessagePreview class to handle message rendering and preview logic. - Updated MessageEditor to utilize MessagePreview for drawing messages and managing font graphics. - Refactored drawing methods to improve organization and clarity, including the addition of DrawFontAtlas and DrawExpandedMessageSettings. - Enhanced message handling by integrating new dictionary entry lookup and improved bitmap updates for message previews. - Cleaned up unused functions and variables to streamline the codebase.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/message/message_data.h"
|
||||
#include "app/editor/message/message_preview.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/style.h"
|
||||
@@ -19,13 +20,10 @@ namespace editor {
|
||||
constexpr int kGfxFont = 0x70000; // 2bpp format
|
||||
constexpr int kCharactersWidth = 0x74ADF;
|
||||
constexpr int kNumMessages = 396;
|
||||
constexpr int kCurrentMessageWidth = 172;
|
||||
constexpr int kCurrentMessageHeight = 4096;
|
||||
constexpr int kFontGfxMessageSize = 128;
|
||||
constexpr int kFontGfxMessageDepth = 64;
|
||||
constexpr int kFontGfx16Size = 172 * 4096;
|
||||
|
||||
constexpr uint8_t kWidthArraySize = 100;
|
||||
constexpr uint8_t kBlockTerminator = 0x80;
|
||||
constexpr uint8_t kMessageBankChangeId = 0x80;
|
||||
|
||||
@@ -51,17 +49,11 @@ class MessageEditor : public Editor {
|
||||
|
||||
void DrawMessageList();
|
||||
void DrawCurrentMessage();
|
||||
void DrawFontAtlas();
|
||||
void DrawTextCommands();
|
||||
void DrawSpecialCharacters();
|
||||
void DrawExpandedMessageSettings();
|
||||
void DrawDictionary();
|
||||
|
||||
void DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
|
||||
int sizex = 1, int sizey = 1);
|
||||
void DrawCharacterToPreview(char c);
|
||||
void DrawCharacterToPreview(const std::vector<uint8_t>& text);
|
||||
|
||||
void DrawStringToPreview(std::string str);
|
||||
void DrawMessagePreview();
|
||||
std::string DisplayTextOverflowError(int pos, bool bank);
|
||||
|
||||
@@ -70,34 +62,25 @@ class MessageEditor : public Editor {
|
||||
|
||||
private:
|
||||
Rom* rom_;
|
||||
bool skip_next = false;
|
||||
bool data_loaded_ = false;
|
||||
bool case_sensitive_ = false;
|
||||
bool match_whole_word_ = false;
|
||||
bool export_expanded_messages_ = false;
|
||||
|
||||
int text_line_ = 0;
|
||||
int text_position_ = 0;
|
||||
int shown_lines_ = 0;
|
||||
|
||||
std::string expanded_message_address_ = "";
|
||||
std::string search_text_ = "";
|
||||
|
||||
std::array<uint8_t, kWidthArraySize> width_array = {0};
|
||||
std::vector<uint8_t> font_gfx16_data_;
|
||||
std::array<uint8_t, 0x4000> raw_font_gfx_data_;
|
||||
std::vector<uint8_t> current_font_gfx16_data_;
|
||||
std::vector<std::string> parsed_messages_;
|
||||
std::vector<MessageData> list_of_texts_;
|
||||
std::vector<DictionaryEntry> all_dictionaries_;
|
||||
|
||||
MessageData current_message_;
|
||||
MessagePreview message_preview_;
|
||||
|
||||
gfx::Bitmap font_gfx_bitmap_;
|
||||
gfx::Bitmap current_font_gfx16_bitmap_;
|
||||
gfx::SnesPalette font_preview_colors_;
|
||||
|
||||
gui::Canvas font_gfx_canvas_{"##FontGfxCanvas", ImVec2(128, 128)};
|
||||
gui::Canvas font_gfx_canvas_{"##FontGfxCanvas", ImVec2(256, 256)};
|
||||
gui::Canvas current_font_gfx16_canvas_{"##CurrentMessageGfx",
|
||||
ImVec2(172 * 2, 4096)};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user