rodecomp/Source/UI/Chat/ChatNotifications.h
ragnarok-clanker 309774e67b Maintenance: [forced, user-approved] CLanguage steps 2-4 (resubmit of #10182, which was returned only for the global rule). Fix: the
Batch #10183 by ragnarok-clanker: forced by an admin (6 lower score(s), 50 changed function(s)); checked with 115 compiled unit(s), including every includer of Source/Client/Input/InputCharset.h, Source/Client/Input/Language.h, Source/Client/Input/LanguageTC.h, Source/UI/Chat/ChatNotifications.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Text/TextWrapping.h, Source/Client/Input/ImeInput.h.
Deletes: Source/Client/Input/ImeInput.h
2026-11-02 19:33:35 +00:00

75 lines
1.8 KiB
C++

#ifndef RAGNAROK_SOURCE_UI_CHAT_CHATNOTIFICATIONS_H
#define RAGNAROK_SOURCE_UI_CHAT_CHATNOTIFICATIONS_H
#include "UI/Shortcuts/ShortcutVisibility.h"
#include "UI/Text/TextWrapping.h"
#include "UI/Window/UIWindow.h"
#include <cstddef>
#include <cstring>
#include <vector>
#include <cstdint>
#include <list>
#include <string>
class UIWindow;
struct ShortcutVisibility;
struct QueuedChatNotification {
/* 0000 */ std::string text;
/* 0018 */ std::uint32_t color;
};
struct ChatNotifications {
UIWindow* const& chat;
std::list<QueuedChatNotification>& queued;
const int& restricted;
const bool& allowsRestricted;
const unsigned short& codePage;
const bool& inlineCharset;
ShortcutVisibility& shortcuts;
void Text(const char* text, std::uint32_t color, const char* extra, int value, bool alternate);
void Refresh();
};
// INLINED
inline void ChatNotifications::Text(const char* text, std::uint32_t color, const char* extra, int value, bool alternate) {
if (this->restricted != 0 && !this->allowsRestricted) {
return;
}
if (color == 0) {
color = 0xFFFFFF;
}
if (this->chat) {
if (std::strcmp(text, "No Msg") != 0 && std::strcmp(text, "NO MSG") != 0) {
this->chat->SendMsg(nullptr, alternate ? 115 : 37, reinterpret_cast<std::intptr_t>(text), color, reinterpret_cast<std::intptr_t>(extra), value);
}
return;
}
std::vector<std::string> lines;
WrapPlainText(text, lines, 94);
for (const auto& line : lines) {
this->queued.push_back({line, color});
}
}
// INLINED
inline void ChatNotifications::Refresh() {
this->shortcuts.Show(1);
if (this->chat) {
this->chat->SendMsg(nullptr, 16, 0, 0, 0, 0);
}
}
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(QueuedChatNotification) == 0x1C);
static_assert(offsetof(QueuedChatNotification, color) == 0x0018);
#endif
#endif