Refactor and add default values to various structs
- Removed `FindMatchingCharacter` declaration from `message_data.h` - Added default values to `DictionaryEntry` and `MessageData` members - Marked several methods in `DictionaryEntry`, `MessageData`, and `TextElement` as `const` - Updated `TextElement` constructor to take `const std::string&` - Added string constants for text descriptions in `TextElement` - Updated `TextCommands` vector to use new string constants - Declared new function `FindMatchingCommand` - Included `<array>` header in `message_editor.h` - Changed `width_array` in `MessageEditor` to `std::array` with default initialization - Removed `list_of_texts_` and `all_dictionaries_` vectors from `MessageEditor` - Added default values to `GameEntity` members - Initialized `sheets` array in `PseudoVram` - Initialized `map_parent_` and `all_tiles_types_` arrays in `Overworld`
This commit is contained in:
@@ -44,11 +44,11 @@ uint8_t FindDictionaryEntry(uint8_t value);
|
|||||||
std::vector<uint8_t> ParseMessageToData(std::string str);
|
std::vector<uint8_t> ParseMessageToData(std::string str);
|
||||||
|
|
||||||
struct DictionaryEntry {
|
struct DictionaryEntry {
|
||||||
uint8_t ID;
|
uint8_t ID = 0;
|
||||||
std::string Contents;
|
std::string Contents = "";
|
||||||
std::vector<uint8_t> Data;
|
std::vector<uint8_t> Data;
|
||||||
int Length;
|
int Length = 0;
|
||||||
std::string Token;
|
std::string Token = "";
|
||||||
|
|
||||||
DictionaryEntry() = default;
|
DictionaryEntry() = default;
|
||||||
DictionaryEntry(uint8_t i, std::string s)
|
DictionaryEntry(uint8_t i, std::string s)
|
||||||
@@ -57,11 +57,11 @@ struct DictionaryEntry {
|
|||||||
Data = ParseMessageToData(Contents);
|
Data = ParseMessageToData(Contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainedInString(std::string s) {
|
bool ContainedInString(std::string s) const {
|
||||||
return s.find(Contents) != std::string::npos;
|
return s.find(Contents) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ReplaceInstancesOfIn(std::string s) {
|
std::string ReplaceInstancesOfIn(std::string s) const {
|
||||||
std::string replacedString = s;
|
std::string replacedString = s;
|
||||||
size_t pos = replacedString.find(Contents);
|
size_t pos = replacedString.find(Contents);
|
||||||
while (pos != std::string::npos) {
|
while (pos != std::string::npos) {
|
||||||
@@ -86,8 +86,8 @@ std::string ReplaceAllDictionaryWords(std::string str,
|
|||||||
const std::string CHEESE = "\uBEBE";
|
const std::string CHEESE = "\uBEBE";
|
||||||
|
|
||||||
struct MessageData {
|
struct MessageData {
|
||||||
int ID;
|
int ID = 0;
|
||||||
int Address;
|
int Address = 0;
|
||||||
std::string RawString;
|
std::string RawString;
|
||||||
std::string ContentsParsed;
|
std::string ContentsParsed;
|
||||||
std::vector<uint8_t> Data;
|
std::vector<uint8_t> Data;
|
||||||
@@ -115,7 +115,7 @@ struct MessageData {
|
|||||||
ContentsParsed = other.ContentsParsed;
|
ContentsParsed = other.ContentsParsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() {
|
std::string ToString() const {
|
||||||
return absl::StrFormat("%0X - %s", ID, ContentsParsed);
|
return absl::StrFormat("%0X - %s", ID, ContentsParsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ struct TextElement {
|
|||||||
bool HasArgument;
|
bool HasArgument;
|
||||||
|
|
||||||
TextElement() = default;
|
TextElement() = default;
|
||||||
TextElement(uint8_t id, std::string token, bool arg,
|
TextElement(uint8_t id, const std::string& token, bool arg,
|
||||||
std::string description) {
|
const std::string& description) {
|
||||||
ID = id;
|
ID = id;
|
||||||
Token = token;
|
Token = token;
|
||||||
if (arg) {
|
if (arg) {
|
||||||
@@ -181,7 +181,7 @@ struct TextElement {
|
|||||||
StrictPattern = "^" + Pattern + "$";
|
StrictPattern = "^" + Pattern + "$";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetParameterizedToken(uint8_t value = 0) {
|
std::string GetParameterizedToken(uint8_t value = 0) const {
|
||||||
if (HasArgument) {
|
if (HasArgument) {
|
||||||
return absl::StrFormat("[%s:%02X]", Token, value);
|
return absl::StrFormat("[%s:%02X]", Token, value);
|
||||||
} else {
|
} else {
|
||||||
@@ -189,7 +189,7 @@ struct TextElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() {
|
std::string ToString() const {
|
||||||
return absl::StrFormat("%s %s", GenericToken, Description);
|
return absl::StrFormat("%s %s", GenericToken, Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,37 +200,61 @@ struct TextElement {
|
|||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Empty() { return ID == 0; }
|
bool Empty() const { return ID == 0; }
|
||||||
|
|
||||||
// Comparison operator
|
// Comparison operator
|
||||||
bool operator==(const TextElement& other) const { return ID == other.ID; }
|
bool operator==(const TextElement& other) const { return ID == other.ID; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const static std::string kWindowBorder = "Window border";
|
||||||
|
const static std::string kWindowPosition = "Window position";
|
||||||
|
const static std::string kScrollSpeed = "Scroll speed";
|
||||||
|
const static std::string kTextDrawSpeed = "Text draw speed";
|
||||||
|
const static std::string kTextColor = "Text color";
|
||||||
|
const static std::string kPlayerName = "Player name";
|
||||||
|
const static std::string kLine1Str = "Line 1";
|
||||||
|
const static std::string kLine2Str = "Line 2";
|
||||||
|
const static std::string kLine3Str = "Line 3";
|
||||||
|
const static std::string kWaitForKey = "Wait for key";
|
||||||
|
const static std::string kScrollText = "Scroll text";
|
||||||
|
const static std::string kDelayX = "Delay X";
|
||||||
|
const static std::string kBCDNumber = "BCD number";
|
||||||
|
const static std::string kSoundEffect = "Sound effect";
|
||||||
|
const static std::string kChoose3 = "Choose 3";
|
||||||
|
const static std::string kChoose2High = "Choose 2 high";
|
||||||
|
const static std::string kChoose2Low = "Choose 2 low";
|
||||||
|
const static std::string kChoose2Indented = "Choose 2 indented";
|
||||||
|
const static std::string kChooseItem = "Choose item";
|
||||||
|
const static std::string kNextAttractImage = "Next attract image";
|
||||||
|
const static std::string kBankMarker = "Bank marker (automatic)";
|
||||||
|
const static std::string kCrash = "Crash";
|
||||||
|
|
||||||
static const std::vector<TextElement> TextCommands = {
|
static const std::vector<TextElement> TextCommands = {
|
||||||
TextElement(0x6B, "W", true, "Window border"),
|
TextElement(0x6B, "W", true, kWindowBorder),
|
||||||
TextElement(0x6D, "P", true, "Window position"),
|
TextElement(0x6D, "P", true, kWindowPosition),
|
||||||
TextElement(0x6E, "SPD", true, "Scroll speed"),
|
TextElement(0x6E, "SPD", true, kScrollSpeed),
|
||||||
TextElement(0x7A, "S", true, "Text draw speed"),
|
TextElement(0x7A, "S", true, kTextDrawSpeed),
|
||||||
TextElement(0x77, "C", true, "Text color"),
|
TextElement(0x77, "C", true, kTextColor),
|
||||||
TextElement(0x6A, "L", false, "Player name"),
|
TextElement(0x6A, "L", false, kPlayerName),
|
||||||
TextElement(0x74, "1", false, "Line 1"),
|
TextElement(0x74, "1", false, kLine1Str),
|
||||||
TextElement(0x75, "2", false, "Line 2"),
|
TextElement(0x75, "2", false, kLine2Str),
|
||||||
TextElement(0x76, "3", false, "Line 3"),
|
TextElement(0x76, "3", false, kLine3Str),
|
||||||
TextElement(0x7E, "K", false, "Wait for key"),
|
TextElement(0x7E, "K", false, kWaitForKey),
|
||||||
TextElement(0x73, "V", false, "Scroll text"),
|
TextElement(0x73, "V", false, kScrollText),
|
||||||
TextElement(0x78, "WT", true, "Delay X"),
|
TextElement(0x78, "WT", true, kDelayX),
|
||||||
TextElement(0x6C, "N", true, "BCD number"),
|
TextElement(0x6C, "N", true, kBCDNumber),
|
||||||
TextElement(0x79, "SFX", true, "Sound effect"),
|
TextElement(0x79, "SFX", true, kSoundEffect),
|
||||||
TextElement(0x71, "CH3", false, "Choose 3"),
|
TextElement(0x71, "CH3", false, kChoose3),
|
||||||
TextElement(0x72, "CH2", false, "Choose 2 high"),
|
TextElement(0x72, "CH2", false, kChoose2High),
|
||||||
TextElement(0x6F, "CH2L", false, "Choose 2 low"),
|
TextElement(0x6F, "CH2L", false, kChoose2Low),
|
||||||
TextElement(0x68, "CH2I", false, "Choose 2 indented"),
|
TextElement(0x68, "CH2I", false, kChoose2Indented),
|
||||||
TextElement(0x69, "CHI", false, "Choose item"),
|
TextElement(0x69, "CHI", false, kChooseItem),
|
||||||
TextElement(0x67, "IMG", false, "Next attract image"),
|
TextElement(0x67, "IMG", false, kNextAttractImage),
|
||||||
TextElement(0x80, BANKToken, false, "Bank marker (automatic)"),
|
TextElement(0x80, BANKToken, false, kBankMarker),
|
||||||
TextElement(0x70, "NONO", false, "Crash"),
|
TextElement(0x70, "NONO", false, kCrash),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TextElement FindMatchingCommand(uint8_t b);
|
TextElement FindMatchingCommand(uint8_t b);
|
||||||
|
|
||||||
static const std::vector<TextElement> SpecialChars = {
|
static const std::vector<TextElement> SpecialChars = {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef YAZE_APP_EDITOR_MESSAGE_EDITOR_H
|
#ifndef YAZE_APP_EDITOR_MESSAGE_EDITOR_H
|
||||||
#define YAZE_APP_EDITOR_MESSAGE_EDITOR_H
|
#define YAZE_APP_EDITOR_MESSAGE_EDITOR_H
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -81,16 +82,13 @@ class MessageEditor : public Editor, public SharedRom {
|
|||||||
int text_position_ = 0;
|
int text_position_ = 0;
|
||||||
int shown_lines_ = 0;
|
int shown_lines_ = 0;
|
||||||
|
|
||||||
uint8_t width_array[kWidthArraySize];
|
|
||||||
|
|
||||||
std::string search_text_ = "";
|
std::string search_text_ = "";
|
||||||
|
|
||||||
|
std::array<uint8_t, kWidthArraySize> width_array = {0};
|
||||||
std::vector<uint8_t> font_gfx16_data_;
|
std::vector<uint8_t> font_gfx16_data_;
|
||||||
std::vector<uint8_t> current_font_gfx16_data_;
|
std::vector<uint8_t> current_font_gfx16_data_;
|
||||||
std::vector<std::string> parsed_messages_;
|
std::vector<std::string> parsed_messages_;
|
||||||
|
|
||||||
std::vector<MessageData> list_of_texts_;
|
std::vector<MessageData> list_of_texts_;
|
||||||
|
|
||||||
std::vector<DictionaryEntry> all_dictionaries_;
|
std::vector<DictionaryEntry> all_dictionaries_;
|
||||||
|
|
||||||
MessageData current_message_;
|
MessageData current_message_;
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ class GameEntity {
|
|||||||
kProperties = 7,
|
kProperties = 7,
|
||||||
kDungeonSprite = 8,
|
kDungeonSprite = 8,
|
||||||
} entity_type_;
|
} entity_type_;
|
||||||
int x_;
|
int x_ = 0;
|
||||||
int y_;
|
int y_ = 0;
|
||||||
int game_x_;
|
int game_x_ = 0;
|
||||||
int game_y_;
|
int game_y_ = 0;
|
||||||
int entity_id_;
|
int entity_id_ = 0;
|
||||||
uint16_t map_id_;
|
uint16_t map_id_ = 0;
|
||||||
|
|
||||||
auto set_x(int x) { x_ = x; }
|
auto set_x(int x) { x_ = x; }
|
||||||
auto set_y(int y) { y_ = y; }
|
auto set_y(int y) { y_ = y; }
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace yaze {
|
|||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
struct PseudoVram {
|
struct PseudoVram {
|
||||||
std::array<uint8_t, 16> sheets;
|
std::array<uint8_t, 16> sheets = { 0 };
|
||||||
std::vector<gfx::SnesPalette> palettes;
|
std::vector<gfx::SnesPalette> palettes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -240,8 +240,8 @@ class Overworld : public SharedRom {
|
|||||||
|
|
||||||
OverworldMapTiles map_tiles_;
|
OverworldMapTiles map_tiles_;
|
||||||
|
|
||||||
std::array<uint8_t, kNumOverworldMaps> map_parent_;
|
std::array<uint8_t, kNumOverworldMaps> map_parent_ = { 0 };
|
||||||
std::array<uint8_t, kNumTileTypes> all_tiles_types_;
|
std::array<uint8_t, kNumTileTypes> all_tiles_types_ = { 0 };
|
||||||
std::vector<gfx::Tile16> tiles16_;
|
std::vector<gfx::Tile16> tiles16_;
|
||||||
std::vector<gfx::Tile32> tiles32_;
|
std::vector<gfx::Tile32> tiles32_;
|
||||||
std::vector<uint16_t> tiles32_list_;
|
std::vector<uint16_t> tiles32_list_;
|
||||||
|
|||||||
Reference in New Issue
Block a user