Skip to content
Merged
6 changes: 4 additions & 2 deletions include/RE/B/BGSKeywordForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ namespace RE
void InitializeDataComponent() override; // 02 - { return; }

// add
virtual BGSKeyword* GetDefaultKeyword() const; // 0B

virtual BGSKeyword* GetDefaultKeyword() const; // 0B
bool AddKeyword(BGSKeyword* keyword);
[[nodiscard]] bool ContainsKeywordString(std::string_view a_editorID);
void ForEachKeyword(std::function<BSContainer::ForEachResult(BGSKeyword*)> a_callback);
[[nodiscard]] std::uint32_t GetNumKeywords() const;
[[nodiscard]] bool HasKeyword(BGSKeyword* keyword) const;
[[nodiscard]] bool HasKeywordString(std::string_view a_editorID);
bool RemoveKeyword(BGSKeyword* keyword);

// members
BSTArray<BGSFormFolderKeywordList*> formFolderKeywordLists; // 10
Expand Down
1 change: 1 addition & 0 deletions include/RE/B/BSTArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace RE
for (const auto& i : a_rhs) {
emplace_back(i);
}
return *this;
}

BSTArray& operator=(BSTArray&& a_rhs)
Expand Down
59 changes: 59 additions & 0 deletions src/RE/B/BGSKeywordForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

namespace RE
{
bool BGSKeywordForm::AddKeyword(BGSKeyword* keyword)
{
if (!keyword) {
return false;
}

for (const auto& existing : keywords) {
if (existing == keyword) {
return false;
}
}

keywords.push_back(keyword);
return true;
}

bool BGSKeywordForm::ContainsKeywordString(std::string_view a_editorID)
{
bool result{};
Expand Down Expand Up @@ -39,6 +55,33 @@ namespace RE
return keywords.size();
}

bool BGSKeywordForm::HasKeyword(BGSKeyword* keyword) const
{
if (!keyword) {
return false;
}

for (const auto& existing : keywords) {
if (existing == keyword) {
return true;
}
}

for (const auto& formFolderKeywordList : formFolderKeywordLists) {
if (!formFolderKeywordList) {
continue;
}

for (const auto& existing : formFolderKeywordList->keywords) {
if (existing == keyword) {
return true;
}
}
}

return false;
}

bool BGSKeywordForm::HasKeywordString(std::string_view a_editorID)
{
bool result{};
Expand All @@ -50,4 +93,20 @@ namespace RE
});
return result;
}

bool BGSKeywordForm::RemoveKeyword(BGSKeyword* keyword)
{
if (!keyword) {
return false;
}

for (auto it = keywords.begin(); it != keywords.end(); ++it) {
if (*it == keyword) {
keywords.erase(it);
return true;
}
}

return false;
}
}
Loading