forked from danielkrupinski/Osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeaponNames.h
45 lines (34 loc) · 1.08 KB
/
WeaponNames.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <string_view>
#include <unordered_map>
#include <utility>
#include <StringPool.h>
#include "../Memory.h"
enum class WeaponId : short;
namespace inventory_changer
{
class WeaponNames {
public:
[[nodiscard]] std::string_view getWeaponName(WeaponId weaponID) const
{
if (const auto it = names.find(weaponID); it != names.end())
return it->second.first;
return "";
}
[[nodiscard]] std::wstring_view getWeaponNameUpper(WeaponId weaponID) const
{
if (const auto it = names.find(weaponID); it != names.end())
return it->second.second;
return L"";
}
void add(WeaponId weaponID, std::string_view name, std::wstring_view nameUpperCase)
{
names.emplace(weaponID, std::make_pair(pool.add(name), poolWide.add(nameUpperCase)));
}
static const WeaponNames& instance(const OtherInterfaces& interfaces, const Memory& memory);
private:
StringPool<char> pool;
StringPool<wchar_t> poolWide;
std::unordered_map<WeaponId, std::pair<std::string_view, std::wstring_view>> names;
};
}