forked from fengjixuchui/XHOOK-WoW-1.12.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.h
91 lines (80 loc) · 2.23 KB
/
Util.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include <Windows.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <chrono>
#include <locale>
#include <codecvt>
#include <sstream>
#include "ImGUI/imgui.h"
#include "Color.h"
#include "Vector.h"
namespace Util
{
// std::string ReplaceString(std::string subject, const std::string& search, const std::string& replace);
// void StdReplaceStr(std::string&, const std::string&, const std::string&);
// const char* PadStringRight(std::string text, size_t value);
// void ProtectAddr(void* address, int prot);
// bool Contains(const std::string &word, const std::string &sentence);
// std::string ToLower(std::string str);
//std::string ToUpper(std::string str);
//std::string WstringToString(std::wstring wstr);
//std::wstring StringToWstring(std::string str);
ImColor GetRainbowColor(float speed);
Color GetHealthColor(int hp);
// Color GetHealthColor(C_BasePlayer* player);
// const std::map<int, int> * GetModelTypeBoneMap(C_BasePlayer* player);
long GetEpochTime();
//int RandomInt(int min, int max);
//int IsDebuggerPresent();
/*static void SetConsoleState(bool);
template <typename T>
T GetValueByKey(std::vector<std::pair<int, T>> vec, int key)
{
for (auto i : vec)
if (i.first == key)
return i.second;
return "";
}*/
template <typename K, typename V>
K MapReverseSearchOrDefault(std::map<K, V> const* _map, V value, K fallback)
{
auto _pair = std::find_if(_map->begin(), _map->end(),
[value](const std::pair<K, V>& pair) {
return pair.second == value;
});
if (_pair == _map->end())
return fallback;
return _pair->first;
}
template <typename K, typename V>
V MapSearchOrDefault(std::map<K, V> const* _map, K key, V fallback)
{
auto result = _map->find(key);
if (result == _map->end())
return fallback;
return result->second;
}
template<typename T>
struct IntHash
{
size_t operator()(const T& t) const noexcept
{
return std::hash<int>()((int)t);
}
};
}
struct TeleporterInfo
{
Vector pos;
std::string name;
int currmsg;
TeleporterInfo(Vector pos, std::string name, int currmsg)
{
this->pos = pos;
this->name = name;
this->currmsg = currmsg;
}
};