-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed: the first the all the extra list for a form will be added to a list, if the Item is used a second time during one button press we take the next item, because at that time the extra data worn or worn left is not set yet. The list is reset before every new key input, if there is data set. * adjusted: count update when picking up item
- Loading branch information
Showing
9 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "extra_data_holder.h" | ||
#include "util/string_util.h" | ||
|
||
namespace handle { | ||
extra_data_holder* extra_data_holder::get_singleton() { | ||
static extra_data_holder singleton; | ||
return std::addressof(singleton); | ||
} | ||
|
||
void extra_data_holder::init_extra_data(const RE::TESForm* a_form, | ||
const std::vector<RE::ExtraDataList*>& a_extra_data_list) { | ||
if (!this->data_) { | ||
this->data_ = new extra_data_holder_data(); | ||
} | ||
|
||
extra_data_holder_data* data = this->data_; | ||
|
||
if (!a_form || a_extra_data_list.empty()) { | ||
return; | ||
} | ||
|
||
data->form_extra_data_map[a_form] = a_extra_data_list; | ||
logger::trace("set extra data list, form {}, count {}"sv, a_form->GetName(), data->form_extra_data_map.size()); | ||
} | ||
|
||
void extra_data_holder::overwrite_extra_data_for_form(const RE::TESForm* a_form, | ||
const std::vector<RE::ExtraDataList*>& a_extra_data_list) { | ||
if (!this->data_) { | ||
return; | ||
} | ||
extra_data_holder_data* data = this->data_; | ||
|
||
if (data->form_extra_data_map.contains(a_form)) { | ||
data->form_extra_data_map[a_form] = a_extra_data_list; | ||
} | ||
} | ||
|
||
void extra_data_holder::reset_data() { | ||
if (!this->data_) { | ||
return; | ||
} | ||
extra_data_holder_data* data = this->data_; | ||
|
||
if (data->form_extra_data_map.empty()) { | ||
return; | ||
} | ||
|
||
logger::trace("before reset, extra data list {}"sv, data->form_extra_data_map.size()); | ||
data->form_extra_data_map.clear(); | ||
logger::trace("did reset, extra data list {}"sv, data->form_extra_data_map.size()); | ||
} | ||
|
||
bool extra_data_holder::is_form_set(const RE::TESForm* a_form) { | ||
if (!this->data_) { | ||
return false; | ||
} | ||
extra_data_holder_data* data = this->data_; | ||
|
||
return data->form_extra_data_map.contains(a_form); | ||
} | ||
|
||
std::vector<RE::ExtraDataList*> extra_data_holder::get_extra_list_for_form(const RE::TESForm* a_form) { | ||
if (!this->data_) { | ||
return {}; | ||
} | ||
extra_data_holder_data* data = this->data_; | ||
|
||
if (data->form_extra_data_map.contains(a_form)) { | ||
return data->form_extra_data_map.at(a_form); | ||
} | ||
|
||
return {}; | ||
} | ||
} // handle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
namespace handle { | ||
class extra_data_holder { | ||
public: | ||
static extra_data_holder* get_singleton(); | ||
void init_extra_data(const RE::TESForm* a_form, const std::vector<RE::ExtraDataList*>& a_extra_data_list); | ||
void overwrite_extra_data_for_form(const RE::TESForm* a_form, | ||
const std::vector<RE::ExtraDataList*>& a_extra_data_list); | ||
void reset_data(); | ||
bool is_form_set(const RE::TESForm* a_form); | ||
[[nodiscard]] std::vector<RE::ExtraDataList*> get_extra_list_for_form(const RE::TESForm* a_form); | ||
|
||
extra_data_holder(const extra_data_holder&) = delete; | ||
extra_data_holder(extra_data_holder&&) = delete; | ||
|
||
extra_data_holder& operator=(const extra_data_holder&) const = delete; | ||
extra_data_holder& operator=(extra_data_holder&&) const = delete; | ||
|
||
private: | ||
extra_data_holder() : data_(nullptr) {} | ||
~extra_data_holder() = default; | ||
|
||
struct extra_data_holder_data { | ||
std::map<const RE::TESForm*, std::vector<RE::ExtraDataList*>> form_extra_data_map; | ||
}; | ||
|
||
extra_data_holder_data* data_; | ||
}; | ||
} // handle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters