fixed event handling and a lot of ID stuff OOPS

This commit is contained in:
2026-01-13 03:16:38 -05:00
parent f9087b8ed3
commit 7f4e05a927
13 changed files with 78 additions and 17 deletions
+3
View File
@@ -40,6 +40,7 @@ namespace anm2ed::anm2
Spritesheet* spritesheet_get(int);
bool spritesheet_add(const std::filesystem::path&, const std::filesystem::path&, int&);
std::vector<std::string> spritesheet_labels_get();
std::vector<int> spritesheet_ids_get();
std::set<int> spritesheets_unused();
bool spritesheets_deserialize(const std::string&, const std::filesystem::path&, types::merge::Type type,
std::string*);
@@ -56,11 +57,13 @@ namespace anm2ed::anm2
void event_add(int&);
std::vector<std::string> event_labels_get();
std::vector<int> event_ids_get();
std::set<int> events_unused();
bool events_deserialize(const std::string&, types::merge::Type, std::string*);
bool sound_add(const std::filesystem::path& directory, const std::filesystem::path& path, int& id);
std::vector<std::string> sound_labels_get();
std::vector<int> sound_ids_get();
std::set<int> sounds_unused();
bool sounds_deserialize(const std::string&, const std::filesystem::path&, types::merge::Type, std::string*);
+9
View File
@@ -25,6 +25,15 @@ namespace anm2ed::anm2
return labels;
}
std::vector<int> Anm2::event_ids_get()
{
std::vector<int> ids{};
ids.emplace_back(-1);
for (auto& id : content.events | std::views::keys)
ids.emplace_back(id);
return ids;
}
std::set<int> Anm2::events_unused()
{
std::set<int> used{};
+9
View File
@@ -29,6 +29,15 @@ namespace anm2ed::anm2
return labels;
}
std::vector<int> Anm2::sound_ids_get()
{
std::vector<int> ids{};
ids.emplace_back(-1);
for (auto& [id, sound] : content.sounds)
ids.emplace_back(id);
return ids;
}
std::set<int> Anm2::sounds_unused()
{
std::set<int> used;
+8
View File
@@ -47,6 +47,14 @@ namespace anm2ed::anm2
return labels;
}
std::vector<int> Anm2::spritesheet_ids_get()
{
std::vector<int> ids{};
for (auto& [id, spritesheet] : content.spritesheets)
ids.emplace_back(id);
return ids;
}
bool Anm2::spritesheets_deserialize(const std::string& string, const std::filesystem::path& directory,
merge::Type type, std::string* errorString)
{
+2 -1
View File
@@ -103,10 +103,11 @@ namespace anm2ed::anm2
element->SetAttribute("Interpolated", isInterpolated);
break;
case TRIGGER:
element->SetAttribute("EventId", eventID);
if (eventID != -1) element->SetAttribute("EventId", eventID);
for (auto& id : soundIDs)
{
if (id == -1) continue;
auto soundChild = element->InsertNewChildElement("Sound");
soundChild->SetAttribute("Id", id);
}