-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChatEntryManager.cpp
More file actions
65 lines (54 loc) · 1.11 KB
/
Copy pathChatEntryManager.cpp
File metadata and controls
65 lines (54 loc) · 1.11 KB
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
#pragma once
#include "ChatEntryManager.h"
#include "imgui.h"
ChatEntryManager::ChatEntryManager()
{
entries.reserve(MAX_PAGESIZE);
}
void ChatEntryManager::push(int entryId, int screenIndex, const CRect& rect)
{
if (screenIndex < 0)
return;
if (entries.size() <= static_cast<size_t>(screenIndex))
entries.resize(screenIndex + 1);
entries[screenIndex] = { rect, entryId, screenIndex };
}
int ChatEntryManager::getEntryIdByScreenCoords(
int xPos,
int yPos
) const
{
for (const auto& entry : entries)
{
if (xPos >= static_cast<int>(entry.rect.x1) &&
xPos < static_cast<int>(entry.rect.x2) &&
yPos >= static_cast<int>(entry.rect.y1) &&
yPos < static_cast<int>(entry.rect.y2))
{
return entry.entryId;
}
}
return -1;
}
ChatEntryPosition* ChatEntryManager::getByEntryId(int entryId)
{
for (auto& entry : entries)
{
if (entry.entryId == entryId)
return &entry;
}
return nullptr;
}
void ChatEntryManager::clear()
{
entries.clear();
}
void ChatEntryManager::setChatPointer(CChat* ptr)
{
if (pChat != nullptr) return;
pChat = ptr;
}
CChat* ChatEntryManager::getChatPointer()
{
return pChat;
}