yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
graphics_sheet_labels.cc
Go to the documentation of this file.
2
3#include "absl/strings/str_format.h"
4#include "absl/strings/str_join.h"
7
8namespace yaze::core {
9
11 uint16_t sheet) {
12 const auto type = project.resource_labels.find(kGraphicsSheetLabelType);
13 if (type == project.resource_labels.end()) {
14 return "";
15 }
16 for (const std::string& key :
17 {std::to_string(sheet), absl::StrFormat("0x%02X", sheet)}) {
18 if (auto it = type->second.find(key);
19 it != type->second.end() && !it->second.empty()) {
20 return it->second;
21 }
22 }
23 return "";
24}
25
26void SetGraphicsSheetLabel(project::YazeProject& project, uint16_t sheet,
27 const std::string& label) {
28 auto& labels = project.resource_labels[kGraphicsSheetLabelType];
29 labels.erase(absl::StrFormat("0x%02X", sheet));
30 if (label.empty()) {
31 labels.erase(std::to_string(sheet));
32 } else {
33 labels[std::to_string(sheet)] = label;
34 }
35}
36
38 const std::string& csv_text, bool overwrite) {
39 int written = 0;
40 for (const auto& [value, names] : zelda3::ParseSpritesetLabelCsv(csv_text)) {
41 if (value >= zelda3::kSpriteSheetValueCount) {
42 continue;
43 }
44 const auto sheet = static_cast<uint16_t>(value + zelda3::kSpriteSheetBase);
45 if (!overwrite && !GetGraphicsSheetLabel(project, sheet).empty()) {
46 continue;
47 }
48 SetGraphicsSheetLabel(project, sheet, absl::StrJoin(names, "; "));
49 ++written;
50 }
51 return written;
52}
53
54} // namespace yaze::core
Which graphics sheets exist, which tables use them, and which 16x16 blocks are free.
Locates graphics sheets in the ROM and writes edited sheets back.
constexpr char kGraphicsSheetLabelType[]
void SetGraphicsSheetLabel(project::YazeProject &project, uint16_t sheet, const std::string &label)
int ImportSpritesetSheetLabels(project::YazeProject &project, const std::string &csv_text, bool overwrite)
std::string GetGraphicsSheetLabel(const project::YazeProject &project, uint16_t sheet)
constexpr uint16_t kSpriteSheetValueCount
constexpr uint16_t kSpriteSheetBase
std::map< uint8_t, std::set< std::string > > ParseSpritesetLabelCsv(const std::string &csv_text)
Modern project structure with comprehensive settings consolidation.
Definition project.h:287
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels
Definition project.h:353