From 838c0044d2eb09b63ce95dd3aa284ec62f59715a Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 28 Oct 2026 19:35:29 +0000 Subject: [PATCH] Decompile 70 functions in Source/Client/Browser/BrowserFactory.cpp, Source/Contents/Emblems/EmblemUpload.cpp, ... Batch #1665 by ragnarok-clanker: 0 byte-identical, 70 confirmed by peer review. - fn_10904 UIEditCtrl::UpdateLinks: logic confirmed by peer review - fn_10905 EditViewport::Synchronize: logic confirmed by peer review - fn_10950 UIBalloonText::SetText: logic confirmed by peer review - fn_11216 ItemLinkDisplay::Convert: logic confirmed by peer review - fn_11326 UIListBox::Slot15: logic confirmed by peer review (already on main) - fn_11327 UIListBoxEx::Slot15: logic confirmed by peer review (already on main) - fn_11366 UIListBox::Paint: logic confirmed by peer review - fn_11367 UIListBoxEx::Paint: logic confirmed by peer review - fn_11392 UITextButton::Paint: logic confirmed by peer review - fn_11394 UITextViewer::Paint: logic confirmed by peer review - fn_11445 UITextButton::Slot31: logic confirmed by peer review (already on main) - fn_11471 UITextButton::Slot27: logic confirmed by peer review (already on main) - fn_11494 UITextButton::Slot33: logic confirmed by peer review (already on main) - fn_11562 UITextViewer::SendMsg: logic confirmed by peer review (already on main) - fn_11721 UICntWnd::DrawBorder: logic confirmed by peer review (already on main) - fn_11760 UIBank_NewWnd::Paint: logic confirmed by peer review (already on main) - fn_11761 UIChatRoomWnd::Paint: logic confirmed by peer review (already on main) - fn_11767 UIMerInfoWnd::Paint: logic confirmed by peer review (already on main) - fn_12680 ShortcutPainting::Paint: logic confirmed by peer review - fn_13829 WrapPlainText: logic confirmed by peer review - fn_13833 WrapRichText: logic confirmed by peer review - fn_16941 UIWindow::DrawAmount: logic confirmed by peer review - fn_16971 UIWindow::TextHeight: logic confirmed by peer review - fn_16972 UIWindow::VerticalTextHeight: logic confirmed by peer review - fn_16973 UIWindow::TextSize: logic confirmed by peer review - fn_16974 UIWindow::VerticalTextSize: logic confirmed by peer review - fn_16975 UIWindow::TextWidth: logic confirmed by peer review - fn_16993 WrapPixelText: logic confirmed by peer review - fn_17007 FitText: logic confirmed by peer review - fn_17009 UIWindow::DrawTextAt: logic confirmed by peer review - fn_17013 DrawOutlinedColoredText: logic confirmed by peer review - fn_17014 DrawStyledColoredText: logic confirmed by peer review - fn_17015 DrawColoredText: logic confirmed by peer review - fn_17016 DrawOutlinedText: logic confirmed by peer review - fn_17136 BrowserFactory::Create: logic confirmed by peer review - fn_18376 LookupMessage: logic confirmed by peer review - fn_01934 TextContext::TextContext: logic confirmed by peer review - fn_01957 TextContext::Marker: logic confirmed by peer review - fn_01961 TextContext::Measure: logic confirmed by peer review - fn_01966 TextContext::SetFont: logic confirmed by peer review - fn_01970 TextContext::DrawPair: logic confirmed by peer review - fn_01971 TextContext::Draw: logic confirmed by peer review - fn_01983 TextContext::MeasurePart: logic confirmed by peer review - fn_01984 TextContext::DrawPart: logic confirmed by peer review - fn_21788 ReceivePartyJoinResult: logic confirmed by peer review - fn_24191 EmotionHotkeys::LoadDefaults: logic confirmed by peer review - fn_03664 CAdventurerAgencyMgr::CompletePartyInfo: logic confirmed by peer review - fn_03666 CAdventurerAgencyMgr::CompleteRegistration: logic confirmed by peer review - fn_03668 CAdventurerAgencyMgr::CompleteStopRecruiting: logic confirmed by peer review - fn_03976 CEmblemDataMgr::CompleteUpload: logic confirmed by peer review - fn_04239 CMCStoreInfoBackup::CompleteSave: logic confirmed by peer review - fn_04262 CPlayerNameDictionary::Lookup: logic confirmed by peer review - fn_06581 ItemNaming::DisplayName: logic confirmed by peer review (already on main) - fn_06583 ItemNamingContext::Element: logic confirmed by peer review (already on main) - fn_06584 ItemNamingContext::Star: logic confirmed by peer review (already on main) - fn_06585 ItemNaming::Creator: logic confirmed by peer review (already on main) - fn_06586 ItemNamingContext::Apprentice: logic confirmed by peer review (already on main) - fn_06587 ItemNaming::Suffixes: logic confirmed by peer review (already on main) - fn_06588 ItemNaming::Prefixes: logic confirmed by peer review (already on main) - fn_09299 UIApplyForPartyWnd::Slot15: logic confirmed by peer review - fn_09300 UIRegisterPartyWnd::Slot15: logic confirmed by peer review - fn_09301 UIRequestJoinPartyWnd::Slot15: logic confirmed by peer review - fn_09303 UIApplyForPartyWnd::Paint: logic confirmed by peer review - fn_09304 UIPartyInfoWnd::Paint: logic confirmed by peer review - fn_10748 UIEditCtrl::RemoveInvalidLink: logic confirmed by peer review - fn_10758 UIEditCtrl::DrawSelectionAt: logic confirmed by peer review (already on main) - fn_10759 UIEditCtrl::DrawSelection: logic confirmed by peer review (already on main) - fn_10794 UIBasicButton::Paint: logic confirmed by peer review - fn_10799 UIBmpTextButton::Paint: logic confirmed by peer review - fn_10823 UITransBalloonText::Paint: logic confirmed by peer review Reviewed-by: ragnarok-clanker --- Source/Client/Browser/BrowserFactory.cpp | 2 +- Source/Contents/Emblems/EmblemUpload.cpp | 2 +- Source/Contents/Hotkeys/EmotionHotkeys.cpp | 2 +- Source/Contents/Items/ItemNaming.cpp | 2 +- Source/Contents/MessageTable.cpp | 13 +++--- Source/Contents/MessageTable.h | 2 +- Source/Contents/Party/PartyInfoCompletion.cpp | 2 +- Source/Contents/Party/PartyJoinResult.cpp | 2 +- .../Party/PartyRegistrationCompletion.cpp | 4 +- .../Party/StopRecruitingCompletion.cpp | 2 +- Source/Contents/PlayerNameDictionary.cpp | 2 +- Source/Contents/Store/MCStoreInfoBackup.cpp | 2 +- Source/Render/Text/TextContext.cpp | 41 ++++++++++--------- Source/Render/Text/TextContext.h | 18 ++++---- Source/UI/Buttons/UIBasicButton.cpp | 2 +- Source/UI/Buttons/UIBmpTextButton.cpp | 2 +- Source/UI/Buttons/UITextButton.cpp | 2 +- Source/UI/Chat/ChatNotifications.h | 2 +- Source/UI/Edit/EditViewport.cpp | 2 +- Source/UI/Edit/UIEditCtrl.cpp | 2 +- Source/UI/Edit/UIEditLinks.cpp | 8 ++-- Source/UI/Lists/UIListBox.cpp | 4 +- Source/UI/Lists/UIListBoxEx.cpp | 2 +- Source/UI/Party/UIApplyForPartyWnd.cpp | 4 +- Source/UI/Party/UIPartyInfoWnd.cpp | 2 +- Source/UI/Party/UIRegisterPartyWnd.cpp | 4 +- Source/UI/Party/UIRequestJoinPartyWnd.cpp | 2 +- Source/UI/Shortcuts/ShortcutPainting.cpp | 10 ++--- Source/UI/Text/ColoredText.cpp | 22 +++++----- Source/UI/Text/ColoredText.h | 8 ++-- Source/UI/Text/ItemLinkDisplay.cpp | 2 +- Source/UI/Text/PixelTextWrapping.cpp | 4 +- Source/UI/Text/PixelTextWrapping.h | 2 +- Source/UI/Text/TextFitting.cpp | 4 +- Source/UI/Text/TextFitting.h | 2 +- Source/UI/Text/TextWrapping.cpp | 13 +++--- Source/UI/Text/TextWrapping.h | 4 +- Source/UI/Text/UIBalloonText.cpp | 6 +-- Source/UI/Text/UITextViewer.cpp | 6 +-- Source/UI/Text/UITextViewerMessages.cpp | 6 +-- Source/UI/Text/UITransBalloonText.cpp | 6 +-- Source/UI/Window/UIMessageBox.cpp | 2 +- Source/UI/Window/UIWindow.cpp | 18 ++++---- 43 files changed, 125 insertions(+), 124 deletions(-) diff --git a/Source/Client/Browser/BrowserFactory.cpp b/Source/Client/Browser/BrowserFactory.cpp index db095c9..730e216 100644 --- a/Source/Client/Browser/BrowserFactory.cpp +++ b/Source/Client/Browser/BrowserFactory.cpp @@ -13,7 +13,7 @@ namespace { CWebBrowser* BrowserFactory::Create(int width, int height) { if (this->registry.browsers.size() >= maximumBrowserCount) { this->notifications.Refresh(); - const char* message = LookupMessage(MessageId::MSI_FAILED_ADD_TAB, this->languagePrefix, this->serviceType, this->language); + const char* message = LookupMessage(MessageId::MSI_FAILED_ADD_TAB); this->notifications.Text(message, RGB(255, 0, 0), nullptr, 0, false); return nullptr; diff --git a/Source/Contents/Emblems/EmblemUpload.cpp b/Source/Contents/Emblems/EmblemUpload.cpp index 81da99c..afce523 100644 --- a/Source/Contents/Emblems/EmblemUpload.cpp +++ b/Source/Contents/Emblems/EmblemUpload.cpp @@ -44,7 +44,7 @@ void CEmblemDataMgr::CompleteUpload(AsyncDiagnostic diagnostic, std::string resp case 2: case 3: case 4: { - const char* message = LookupMessage(3586, context.languagePrefix, context.serviceType, context.language); + const char* message = LookupMessage(3586); context.dialogs.Confirm(message, 0, true, false, 0, "Message", 280, 120, 0); break; } diff --git a/Source/Contents/Hotkeys/EmotionHotkeys.cpp b/Source/Contents/Hotkeys/EmotionHotkeys.cpp index 635ba38..920cd8f 100644 --- a/Source/Contents/Hotkeys/EmotionHotkeys.cpp +++ b/Source/Contents/Hotkeys/EmotionHotkeys.cpp @@ -73,7 +73,7 @@ bool EmotionHotkeys::LoadDefaults(std::uint32_t accountId, bool languagePrefix, this->current.clear(); for (int id : {544, 545, 546, 547, 549, 550, 551, 552, 553, 554}) { - this->current.emplace_back(LookupMessage(id, languagePrefix, serviceType, language)); + this->current.emplace_back(LookupMessage(id)); } CLuaInstance script; diff --git a/Source/Contents/Items/ItemNaming.cpp b/Source/Contents/Items/ItemNaming.cpp index dfb6657..26ee223 100644 --- a/Source/Contents/Items/ItemNaming.cpp +++ b/Source/Contents/Items/ItemNaming.cpp @@ -42,7 +42,7 @@ namespace { // INLINED const char* ItemNaming::Message(int id) const { - return LookupMessage(id, this->languagePrefix, this->service, this->language); + return LookupMessage(id); } // OFFSET: 0x006D77E0 diff --git a/Source/Contents/MessageTable.cpp b/Source/Contents/MessageTable.cpp index 893bb25..7d384de 100644 --- a/Source/Contents/MessageTable.cpp +++ b/Source/Contents/MessageTable.cpp @@ -1,8 +1,9 @@ +#include "Client/Input/InputCharset.h" #include "Contents/Configuration/ServiceConfiguration.h" #include "Contents/MessageTable.h" #include "Network/TextEncoding.h" #include "Utility/Text/Base64.h" -#include "Utility/Text/LanguageCharset.h" +#include "Utility/Text/TextTokens.h" #include #include @@ -104,7 +105,7 @@ void InsertMessage(int id, const char* text) { // OFFSET: 0x00B00F00 // FUNCTION: fn_18376 -const char* LookupMessage(int id, bool languagePrefix, int serviceType, WORD language) { +const char* LookupMessage(int id) { // STATIC: 0x016D57A0 static char missing[20]; if (id >= 4698) { @@ -118,7 +119,7 @@ const char* LookupMessage(int id, bool languagePrefix, int serviceType, WORD lan } const std::string& text = found->second; - if (!languagePrefix || text[0] == '/' || text == "NO MSG") { + if (!g_inlineCharset || text[0] == '/' || text == "NO MSG") { return text.c_str(); } @@ -126,13 +127,11 @@ const char* LookupMessage(int id, bool languagePrefix, int serviceType, WORD lan // GLOBAL: gl_24383 static std::vector cached(4698); std::string& result = cached[id]; - if (result.empty() || serviceType == 19) { + if (result.empty() || g_serviceType == 19) { // STATIC: 0x016D57C8 // GLOBAL: gl_24384 static char buffer[260]; - char prefix[8]; - std::sprintf(prefix, "|%02x", LanguageCharset(language)); - _snprintf_s(buffer, sizeof(buffer), _TRUNCATE, "%s%s", prefix, text.c_str()); + _snprintf_s(buffer, sizeof(buffer), _TRUNCATE, "%s%s", g_serverLanguage->Prefix(true), text.c_str()); result = buffer; } diff --git a/Source/Contents/MessageTable.h b/Source/Contents/MessageTable.h index 73a8df8..347189a 100644 --- a/Source/Contents/MessageTable.h +++ b/Source/Contents/MessageTable.h @@ -11,7 +11,7 @@ enum MessageId : int { }; extern std::unordered_map g_messageStrings; -const char* LookupMessage(int id, bool languagePrefix, int serviceType, WORD language); +const char* LookupMessage(int id); void InsertMessage(int id, const char* text); int FindMessageId(const char* name); char* DecodeMessageRot(char* str); diff --git a/Source/Contents/Party/PartyInfoCompletion.cpp b/Source/Contents/Party/PartyInfoCompletion.cpp index 3249b43..e9dac37 100644 --- a/Source/Contents/Party/PartyInfoCompletion.cpp +++ b/Source/Contents/Party/PartyInfoCompletion.cpp @@ -32,7 +32,7 @@ void CAdventurerAgencyMgr::CompletePartyInfo(AsyncDiagnostic diagnostic, std::st return; } - const auto notify = [&](int id) { context.messages.Message(LookupMessage(id, context.languagePrefix, context.service, context.language), 0xFF); }; + const auto notify = [&](int id) { context.messages.Message(LookupMessage(id), 0xFF); }; auto entry = root["data"].begin(); if (entry == root["data"].end()) { diff --git a/Source/Contents/Party/PartyJoinResult.cpp b/Source/Contents/Party/PartyJoinResult.cpp index 71a37ba..4f0a32e 100644 --- a/Source/Contents/Party/PartyJoinResult.cpp +++ b/Source/Contents/Party/PartyJoinResult.cpp @@ -15,7 +15,7 @@ void ReceivePartyJoinResult(const void* packet, PartyJoinResultContext& context) context.notifications.Notify(3, nullptr, 0); std::uint32_t status; std::memcpy(&status, bytes + 54, sizeof(status)); - const auto message = [&](int id) { return LookupMessage(id, context.stop.languagePrefix, context.stop.service, context.stop.language); }; + const auto message = [&](int id) { return LookupMessage(id); }; const auto notify = [&](int id) { context.notifications.Notify(1, message(id), 0xFF); }; const auto format = [&](int id, unsigned offset, unsigned color) { char text[500] = {}; diff --git a/Source/Contents/Party/PartyRegistrationCompletion.cpp b/Source/Contents/Party/PartyRegistrationCompletion.cpp index 0f4f6dd..bafd304 100644 --- a/Source/Contents/Party/PartyRegistrationCompletion.cpp +++ b/Source/Contents/Party/PartyRegistrationCompletion.cpp @@ -28,12 +28,12 @@ void CAdventurerAgencyMgr::CompleteRegistration(AsyncDiagnostic diagnostic, std: const int type = root["Type"].asInt(); if (type == 2 || type == 3) { - context.messages.Message(LookupMessage(3417, context.languagePrefix, context.service, context.language), 0xFF); + context.messages.Message(LookupMessage(3417), 0xFF); return; } this->registered = true; - context.messages.Message(LookupMessage(3418, context.languagePrefix, context.service, context.language), 0xFFFF64); + context.messages.Message(LookupMessage(3418), 0xFFFF64); UIWindow* board = context.windows.LookupWindow(324); if (board) { diff --git a/Source/Contents/Party/StopRecruitingCompletion.cpp b/Source/Contents/Party/StopRecruitingCompletion.cpp index 10324eb..f362eac 100644 --- a/Source/Contents/Party/StopRecruitingCompletion.cpp +++ b/Source/Contents/Party/StopRecruitingCompletion.cpp @@ -14,7 +14,7 @@ void CAdventurerAgencyMgr::CompleteStopRecruiting(AsyncDiagnostic diagnostic, std::string response, StopRecruitingContext& context) { --this->pending; const auto notify = [&](int id, unsigned color) { - context.messages.Message(LookupMessage(id, context.languagePrefix, context.service, context.language), color); + context.messages.Message(LookupMessage(id), color); }; if (!diagnostic.success) { diff --git a/Source/Contents/PlayerNameDictionary.cpp b/Source/Contents/PlayerNameDictionary.cpp index 99cdf42..ed698c1 100644 --- a/Source/Contents/PlayerNameDictionary.cpp +++ b/Source/Contents/PlayerNameDictionary.cpp @@ -33,7 +33,7 @@ std::string CPlayerNameDictionary::Lookup(std::uint32_t id) { this->m_pending.push_back(id); } - return LookupMessage(581, this->m_context->languagePrefix, this->m_context->service, this->m_context->language); + return LookupMessage(581); } // OFFSET: 0x0060ABB0 diff --git a/Source/Contents/Store/MCStoreInfoBackup.cpp b/Source/Contents/Store/MCStoreInfoBackup.cpp index 6ac400a..9b6efbf 100644 --- a/Source/Contents/Store/MCStoreInfoBackup.cpp +++ b/Source/Contents/Store/MCStoreInfoBackup.cpp @@ -168,7 +168,7 @@ void CMCStoreInfoBackup::CompleteSave(AsyncDiagnostic diagnostic, std::string re context.ui.Notify(3, nullptr, 0); if (this->type == 0 || this->type == 1) { - const char* message = LookupMessage(this->type == 0 ? 3685 : 3686, context.languagePrefix, context.serviceType, context.language); + const char* message = LookupMessage(this->type == 0 ? 3685 : 3686); context.ui.Notify(1, message, 0xFFFF); } } diff --git a/Source/Render/Text/TextContext.cpp b/Source/Render/Text/TextContext.cpp index 08622c9..5acc02e 100644 --- a/Source/Render/Text/TextContext.cpp +++ b/Source/Render/Text/TextContext.cpp @@ -1,6 +1,9 @@ #include "Render/DeviceContext/DeviceContext.h" #include "Render/Text/FontCache.h" #include "Render/Text/TextContext.h" +#include "Client/Input/InputCharset.h" +#include "Contents/Configuration/ServiceConfiguration.h" +#include "Utility/Text/TextTokens.h" #include #include @@ -40,7 +43,7 @@ namespace { // OFFSET: 0x0054D4B0 // FUNCTION: fn_01934 -TextContext::TextContext(CDC& surface, FontCache& fonts, const TextLocale& locale) : m_dc(nullptr), m_surface(&surface), m_fonts(&fonts), m_locale(&locale) { +TextContext::TextContext(CDC& surface) : m_dc(nullptr), m_surface(&surface) { if (surface.GetDC(&this->m_dc)) { this->m_previous = GetCurrentObject(this->m_dc, OBJ_FONT); SetBkMode(this->m_dc, TRANSPARENT); @@ -60,18 +63,18 @@ TextContext::~TextContext() { // FUNCTION: fn_01966 void TextContext::SetFont(int family, int height, unsigned char bold, unsigned char italic) { if (family == 0) { - switch (this->m_locale->language) { + switch (g_language) { case 1: - if (this->m_locale->service == 6) { + if (g_serviceType == 6) { family = 8; height = (height + 2); } else { height = (height + 3); - if (this->m_locale->service == 14) { + if (g_serviceType == 14) { family = 9; } else { family = 1; - if (this->m_locale->serverLanguage && *this->m_locale->serverLanguage == 31) { + if (g_serverLanguage && g_serverLanguage->alternateLanguage == 31) { family = 6; } } @@ -94,10 +97,10 @@ void TextContext::SetFont(int family, int height, unsigned char bold, unsigned c case 8: family = 7; height = (height + 3); - if (this->m_locale->service == 12) { + if (g_serviceType == 12) { height = (height - 2); - } else if (this->m_locale->service == 18) { - if (*this->m_locale->serverLanguage == 31) { + } else if (g_serviceType == 18) { + if (g_serverLanguage->alternateLanguage == 31) { family = 6; } else { height = (height - 2); @@ -117,7 +120,7 @@ void TextContext::SetFont(int family, int height, unsigned char bold, unsigned c this->m_family = family; this->m_height = height; - this->m_charset = this->m_locale->language == 0 && family >= 20 ? charsets[0] : charsets[family]; + this->m_charset = g_language == 0 && family >= 20 ? charsets[0] : charsets[family]; this->m_bold = bold; this->m_italic = italic; } @@ -182,8 +185,8 @@ unsigned TextContext::CodePage(unsigned charset) { // OFFSET: 0x0054F2E0 // FUNCTION: fn_01957 -unsigned TextContext::Marker(const char* text, unsigned bytes, bool enabled) { - if (!enabled) { +unsigned TextContext::Marker(const char* text, unsigned bytes) { + if (!g_inlineCharset) { return bytes; } @@ -238,7 +241,7 @@ SIZE TextContext::MeasurePart(const char* text, int bytes, unsigned charset) { auto* wide = reinterpret_cast(static_cast(memory) + 8); const int count = MultiByteToWideChar(CodePage(charset), 0, text, bytes, wide, static_cast(extent)); - SelectObject(this->m_dc, this->m_fonts->Get(this->m_family, this->m_height, charset, this->m_bold, this->m_italic)); + SelectObject(this->m_dc, g_fontCache.Get(this->m_family, this->m_height, charset, this->m_bold, this->m_italic)); GetTextExtentPoint32W(this->m_dc, wide, count, &size); if (this->m_italic == 1) { @@ -281,7 +284,7 @@ void TextContext::DrawPart(int x, int y, const char* text, int bytes, unsigned c auto* wide = reinterpret_cast(static_cast(memory) + 8); const int count = MultiByteToWideChar(CodePage(this->m_charset), 0, text, bytes, wide, static_cast(extent)); - SelectObject(this->m_dc, this->m_fonts->Get(this->m_family, this->m_height, charset, this->m_bold, this->m_italic)); + SelectObject(this->m_dc, g_fontCache.Get(this->m_family, this->m_height, charset, this->m_bold, this->m_italic)); TextOutW(this->m_dc, x, y, wide, count); if (allocation > 0x400) { @@ -292,7 +295,7 @@ void TextContext::DrawPart(int x, int y, const char* text, int bytes, unsigned c // OFFSET: 0x0054FD00 // FUNCTION: fn_01961 SIZE TextContext::Measure(const char* text, int bytes) { - const int first = Marker(text, bytes, this->m_locale->inlineCharset); + const int first = Marker(text, bytes); SIZE result = this->MeasurePart(text, first, this->m_charset); if (first < bytes) { SIZE second = this->MeasurePart(text + first + 3, bytes - first - 3, InlineCharset(text + first)); @@ -306,7 +309,7 @@ SIZE TextContext::Measure(const char* text, int bytes) { // OFFSET: 0x00550190 // FUNCTION: fn_01970 void TextContext::DrawPair(int x, int y, const char* text, int bytes) { - const int first = Marker(text, bytes, this->m_locale->inlineCharset); + const int first = Marker(text, bytes); this->DrawPart(x, y, text, first, this->m_charset); if (first < bytes) { const SIZE size = this->MeasurePart(text, first, this->m_charset); @@ -317,7 +320,7 @@ void TextContext::DrawPair(int x, int y, const char* text, int bytes) { // OFFSET: 0x00550220 // FUNCTION: fn_01971 void TextContext::Draw(int x, int y, const char* text, int bytes) { - if (!this->m_locale->inlineCharset) { + if (!g_inlineCharset) { this->DrawPair(x, y, text, bytes); return; } @@ -326,7 +329,7 @@ void TextContext::Draw(int x, int y, const char* text, int bytes) { int scanned = 0, remaining = bytes; while (scanned < bytes) { - scanned = (scanned + Marker(text + scanned, remaining, true)); + scanned = (scanned + Marker(text + scanned, remaining)); if (scanned >= bytes) { this->DrawPair(x, y, current, scanned); return; @@ -336,9 +339,9 @@ void TextContext::Draw(int x, int y, const char* text, int bytes) { return; } - const int segment = (Marker(text + scanned + 3, remaining - 3, true) + 3); + const int segment = (Marker(text + scanned + 3, remaining - 3) + 3); this->DrawPair(x, y, current, segment); - const int first = Marker(current, segment, true); + const int first = Marker(current, segment); int width = this->MeasurePart(current, first, this->m_charset).cx; if (first < segment) { diff --git a/Source/Render/Text/TextContext.h b/Source/Render/Text/TextContext.h index f0412ee..8785422 100644 --- a/Source/Render/Text/TextContext.h +++ b/Source/Render/Text/TextContext.h @@ -4,7 +4,6 @@ #include class CDC; -class FontCache; struct TextLocale { signed char language; @@ -15,7 +14,7 @@ struct TextLocale { class TextContext { public: - TextContext(CDC& surface, FontCache& fonts, const TextLocale& locale); + explicit TextContext(CDC& surface); ~TextContext(); void SetFont(int family, int height, unsigned char bold, unsigned char italic); void SetColor(COLORREF color); @@ -25,19 +24,18 @@ public: SIZE Measure(const char* text, int bytes); void Draw(int x, int y, const char* text, int bytes); static unsigned CodePage(unsigned charset); - static unsigned Marker(const char* text, unsigned bytes, bool enabled); + static unsigned Marker(const char* text, unsigned bytes); private: /* 0000 */ HDC m_dc; /* 0004 */ HGDIOBJ m_previous; /* 0008 */ CDC* m_surface; - FontCache* m_fonts; - const TextLocale* m_locale; - int m_family; - int m_height; - unsigned m_charset; - unsigned char m_bold; - unsigned char m_italic; + /* 000C */ int m_family; + /* 0010 */ int m_height; + /* 0014 */ unsigned m_charset; + /* 0018 */ unsigned char unknown_0018[5]; + /* 001D */ unsigned char m_bold; + /* 001E */ unsigned char m_italic; SIZE MeasurePart(const char* text, int bytes, unsigned charset); void DrawPart(int x, int y, const char* text, int bytes, unsigned charset); void DrawPair(int x, int y, const char* text, int bytes); diff --git a/Source/UI/Buttons/UIBasicButton.cpp b/Source/UI/Buttons/UIBasicButton.cpp index 9746ae4..677d75a 100644 --- a/Source/UI/Buttons/UIBasicButton.cpp +++ b/Source/UI/Buttons/UIBasicButton.cpp @@ -57,7 +57,7 @@ void UIBasicButton::Paint() { int height; { - TextContext context(*this->geometry.surface, this->m_buttonContext->fonts, this->m_buttonContext->locale); + TextContext context(*this->geometry.surface); context.SetFont(0, 12, 0, 0); height = context.Measure(this->text.c_str(), static_cast(std::strlen(this->text.c_str()))).cy; } diff --git a/Source/UI/Buttons/UIBmpTextButton.cpp b/Source/UI/Buttons/UIBmpTextButton.cpp index 34711cc..1662854 100644 --- a/Source/UI/Buttons/UIBmpTextButton.cpp +++ b/Source/UI/Buttons/UIBmpTextButton.cpp @@ -62,7 +62,7 @@ void UIBmpTextButton::Paint() { int height; { - TextContext context(*this->geometry.surface, this->m_buttonContext->fonts, this->m_buttonContext->locale); + TextContext context(*this->geometry.surface); context.SetFont(0, 12, 0, 0); height = context.Measure(this->text.c_str(), static_cast(std::strlen(this->text.c_str()))).cy; } diff --git a/Source/UI/Buttons/UITextButton.cpp b/Source/UI/Buttons/UITextButton.cpp index 28f45a9..22e2493 100644 --- a/Source/UI/Buttons/UITextButton.cpp +++ b/Source/UI/Buttons/UITextButton.cpp @@ -46,7 +46,7 @@ void UITextButton::Paint() { this->parent->Invalidate(); } - TextContext context(*this->geometry.surface, this->m_buttonContext->fonts, this->m_buttonContext->locale); + TextContext context(*this->geometry.surface); context.SetFont(this->m_family, this->m_height, this->m_outline != 0, 0); const int bytes = static_cast(std::strlen(this->m_text.c_str())); diff --git a/Source/UI/Chat/ChatNotifications.h b/Source/UI/Chat/ChatNotifications.h index bc88fe6..ddfe166 100644 --- a/Source/UI/Chat/ChatNotifications.h +++ b/Source/UI/Chat/ChatNotifications.h @@ -52,7 +52,7 @@ inline void ChatNotifications::Text(const char* text, std::uint32_t color, const } std::vector lines; - WrapPlainText(text, lines, 94, this->codePage, this->inlineCharset); + WrapPlainText(text, lines, 94, this->codePage); for (const auto& line : lines) { this->queued.push_back({line, color}); diff --git a/Source/UI/Edit/EditViewport.cpp b/Source/UI/Edit/EditViewport.cpp index ea8d231..182bfc1 100644 --- a/Source/UI/Edit/EditViewport.cpp +++ b/Source/UI/Edit/EditViewport.cpp @@ -36,7 +36,7 @@ void EditViewport::Synchronize() { this->firstVisible = 0; } - TextContext context(this->surface, this->fonts, this->locale); + TextContext context(this->surface); context.SetFont(0, 12, 0, 0); const auto measure = [&](const char* text, unsigned bytes) { return context.Measure(text, static_cast(bytes ? bytes : std::strlen(text))).cx; }; const int available = this->width - 7; diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index 618fdf4..1b9b1a4 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -89,7 +89,7 @@ struct EditPainting { }; // INLINED void EditPainting::Draw() { - TextContext context(this->surface, this->fonts, this->locale); + TextContext context(this->surface); context.SetFont(0, 12, 0, 0); const auto measure = [&](const char* text, int bytes) { return context.Measure(text, bytes ? bytes : static_cast(std::strlen(text))).cx; }; int x = 3; diff --git a/Source/UI/Edit/UIEditLinks.cpp b/Source/UI/Edit/UIEditLinks.cpp index b270a62..6762d14 100644 --- a/Source/UI/Edit/UIEditLinks.cpp +++ b/Source/UI/Edit/UIEditLinks.cpp @@ -21,7 +21,7 @@ bool UIEditCtrl::RemoveInvalidLink(std::list::iterator& entry) { return true; } - const std::string fitted = FitText(*this->geometry.surface, this->m_edit->buttons.fonts, this->m_edit->buttons.locale, name, this->geometry.width / 2); + const std::string fitted = FitText(*this->geometry.surface, name, this->geometry.width / 2); std::size_t found = remaining.find(fitted); if (found == std::string::npos) { @@ -105,7 +105,7 @@ void UIEditCtrl::UpdateLinks() { auto* button = static_cast(*entry); const std::string name = FormatNavigationLink(button->link, false); - const std::string fitted = FitText(*this->geometry.surface, this->m_edit->buttons.fonts, this->m_edit->buttons.locale, name, this->geometry.width / 2); + const std::string fitted = FitText(*this->geometry.surface, name, this->geometry.width / 2); const std::string display = "<" + fitted + ">"; const auto found = remaining.find(display); @@ -144,7 +144,7 @@ void UIEditCtrl::UpdateLinks() { void UIEditCtrl::InsertLink(const char* value) { const std::string name = FormatNavigationLink(value, false); - FitText(*this->geometry.surface, this->m_edit->buttons.fonts, this->m_edit->buttons.locale, name, this->geometry.width / 2); + FitText(*this->geometry.surface, name, this->geometry.width / 2); const std::string display = "<" + name + ">"; std::string before; bool removed = false; @@ -158,7 +158,7 @@ void UIEditCtrl::InsertLink(const char* value) { removed = true; const auto* button = static_cast(window); const std::string fitted = FitText( - *this->geometry.surface, this->m_edit->buttons.fonts, this->m_edit->buttons.locale, FormatNavigationLink(button->link, false), this->geometry.width / 2 + *this->geometry.surface, FormatNavigationLink(button->link, false), this->geometry.width / 2 ); const std::string old = "<" + fitted + ">"; diff --git a/Source/UI/Lists/UIListBox.cpp b/Source/UI/Lists/UIListBox.cpp index 378e53e..8358326 100644 --- a/Source/UI/Lists/UIListBox.cpp +++ b/Source/UI/Lists/UIListBox.cpp @@ -200,7 +200,7 @@ void UIListBox::Paint() { int height = 0; if (!line.empty()) { - TextContext context(*this->geometry.surface, owner.fonts, owner.locale); + TextContext context(*this->geometry.surface); context.SetFont(0, 12, 0, 0); height = context.Measure(line.c_str(), static_cast(std::strlen(line.c_str()))).cy; } @@ -208,7 +208,7 @@ void UIListBox::Paint() { y = static_cast(static_cast((this->lineHeight - height)) * 0.5f + static_cast(y)); } - DrawColoredText(*this, owner.fonts, owner.locale, owner.codePage, x, y, line.c_str(), static_cast(line.size()), color, 0, 12, false); + DrawColoredText(*this, owner.codePage, x, y, line.c_str(), static_cast(line.size()), color, 0, 12, false); } } diff --git a/Source/UI/Lists/UIListBoxEx.cpp b/Source/UI/Lists/UIListBoxEx.cpp index dfe4bca..afdc7b4 100644 --- a/Source/UI/Lists/UIListBoxEx.cpp +++ b/Source/UI/Lists/UIListBoxEx.cpp @@ -179,7 +179,7 @@ void UIListBoxEx::Paint() { auto& line = this->lines[index]; auto color = line.color; DrawColoredText( - *this, owner.fonts, owner.locale, owner.codePage, (3 - this->horizontalOffset), y, line.text.c_str(), static_cast(line.text.size()), color, 0, + *this, owner.codePage, (3 - this->horizontalOffset), y, line.text.c_str(), static_cast(line.text.size()), color, 0, 12, false ); } diff --git a/Source/UI/Party/UIApplyForPartyWnd.cpp b/Source/UI/Party/UIApplyForPartyWnd.cpp index 8f74d02..1ad121e 100644 --- a/Source/UI/Party/UIApplyForPartyWnd.cpp +++ b/Source/UI/Party/UIApplyForPartyWnd.cpp @@ -58,7 +58,7 @@ void UIApplyForPartyWnd::Slot15(int, int) { } std::vector lines; - WrapPlainText(controls.services.MessageText(3370), lines, 40, this->m_application->codePage, controls.locale.inlineCharset); + WrapPlainText(controls.services.MessageText(3370), lines, 40, this->m_application->codePage); int y = 136; for (const auto& line : lines) { @@ -134,7 +134,7 @@ void UIApplyForPartyWnd::Paint() { this->DrawBitmap(3, 3, base ? &base->image : nullptr, true); const auto text = [&](int x, int y, const char* value) { this->DrawTextAt(controls.fonts, controls.locale, x, y, value, 0, 0, 12, 0, 0, 0); }; text(10, 25, controls.services.MessageText(3415)); - const std::string fitted = FitText(*this->geometry.surface, controls.fonts, controls.locale, this->info.characterName, 119); + const std::string fitted = FitText(*this->geometry.surface, this->info.characterName, 119); text(60, 25, fitted.c_str()); text(10, 49, controls.services.MessageText(408)); char levels[10] = {}; diff --git a/Source/UI/Party/UIPartyInfoWnd.cpp b/Source/UI/Party/UIPartyInfoWnd.cpp index 04ef2e9..439cb18 100644 --- a/Source/UI/Party/UIPartyInfoWnd.cpp +++ b/Source/UI/Party/UIPartyInfoWnd.cpp @@ -95,7 +95,7 @@ void UIPartyInfoWnd::Paint() { this->DrawBitmap(109 + index * 18, 3, resource ? &resource->image : nullptr, false); } - const std::string fitted = FitText(*this->geometry.surface, controls.fonts, controls.locale, this->name, 119); + const std::string fitted = FitText(*this->geometry.surface, this->name, 119); text(192, fitted.c_str(), static_cast(fitted.size())); text(315, this->memo.c_str(), static_cast(this->memo.size())); diff --git a/Source/UI/Party/UIRegisterPartyWnd.cpp b/Source/UI/Party/UIRegisterPartyWnd.cpp index f39f339..2093ee1 100644 --- a/Source/UI/Party/UIRegisterPartyWnd.cpp +++ b/Source/UI/Party/UIRegisterPartyWnd.cpp @@ -85,7 +85,7 @@ void UIRegisterPartyWnd::Slot15(int, int) { }; label(controls.services.MessageText(3415), 10, 23, 40); this->character = label(owner.characterName.c_str(), 60, 23, 119); - this->character->text = FitText(*this->character->geometry.surface, controls.fonts, controls.locale, owner.characterName, 119); + this->character->text = FitText(*this->character->geometry.surface, owner.characterName, 119); this->character->tooltipEnabled = this->character->text != owner.characterName; label(controls.services.MessageText(408), 10, 49, 40); const int level = owner.playerLevel; @@ -149,7 +149,7 @@ void UIRegisterPartyWnd::Slot15(int, int) { this->m_message0 = registered ? 564 : 565; this->AddChild(submit); std::vector lines; - WrapPlainText(controls.services.MessageText(3370), lines, 40, owner.codePage, controls.locale.inlineCharset); + WrapPlainText(controls.services.MessageText(3370), lines, 40, owner.codePage); int y = 136; for (const auto& line : lines) { diff --git a/Source/UI/Party/UIRequestJoinPartyWnd.cpp b/Source/UI/Party/UIRequestJoinPartyWnd.cpp index 3a31dc8..d6ec95b 100644 --- a/Source/UI/Party/UIRequestJoinPartyWnd.cpp +++ b/Source/UI/Party/UIRequestJoinPartyWnd.cpp @@ -83,7 +83,7 @@ void UIRequestJoinPartyWnd::Slot15(int, int) { this->block->SetId(213); this->AddChild(this->block); std::vector unused; - WrapPlainText(controls.services.MessageText(3518), unused, 30, text.list.codePage, controls.locale.inlineCharset); + WrapPlainText(controls.services.MessageText(3518), unused, 30, text.list.codePage); this->blockText = new UITextViewer(*this->m_context, text); this->blockText->Configure(31, 81, 182, 47, 0); diff --git a/Source/UI/Shortcuts/ShortcutPainting.cpp b/Source/UI/Shortcuts/ShortcutPainting.cpp index 2b9c26e..cde9322 100644 --- a/Source/UI/Shortcuts/ShortcutPainting.cpp +++ b/Source/UI/Shortcuts/ShortcutPainting.cpp @@ -24,11 +24,11 @@ namespace { } // OFFSET: 0x00A86200 - void Count(UIWindow& window, FontCache& fonts, const TextLocale& locale, int right, int y, int value) { + void Count(UIWindow& window, int right, int y, int value) { char text[16]; std::sprintf(text, "%d", value); const int bytes = static_cast(std::strlen(text)); - TextContext context(*window.geometry.surface, fonts, locale); + TextContext context(*window.geometry.surface); context.SetFont(0, 11, 0, 0); const int left = (right - context.Measure(text, bytes).cx); context.SetColor(0xFFFFFF); @@ -104,7 +104,7 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N level = skill.level; } - Count(window, this->fonts, this->locale, x + 27, (y + 17), level); + Count(window, x + 27, (y + 17), level); } else { ItemInfo item = LookupClientItem(this->inventory, static_cast(slot.itemId), 1); if (item.unknown_0000[1] == 0) { @@ -113,7 +113,7 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N DrawItemIcon(window, this->resources, this->descriptions, x, y, item, static_cast(item.unknown_0060)); if (item.quantity != 0) { - Count(window, this->fonts, this->locale, x + 27, (y + 17), item.quantity); + Count(window, x + 27, (y + 17), item.quantity); } if (item.unknown_0088 > 0) { @@ -142,7 +142,7 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N const int x = 16 + 29 * column; DrawItemIcon(window, this->resources, this->descriptions, x, y, item, static_cast(item.unknown_0060)); if (item.quantity != 0) { - Count(window, this->fonts, this->locale, x + 27, (y + 17), item.quantity); + Count(window, x + 27, (y + 17), item.quantity); } } } diff --git a/Source/UI/Text/ColoredText.cpp b/Source/UI/Text/ColoredText.cpp index 95e0439..a5c6a43 100644 --- a/Source/UI/Text/ColoredText.cpp +++ b/Source/UI/Text/ColoredText.cpp @@ -61,7 +61,7 @@ namespace { // OFFSET: 0x00A84E30 // FUNCTION: fn_17015 void DrawColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, int family, int height, bool shadow ) { if (bytes == 0) { @@ -70,8 +70,8 @@ void DrawColoredText( const char* current = text; const char* end = text + bytes; - const char* marker = text + TextContext::Marker(text, bytes, locale.inlineCharset); - TextContext context(*window.geometry.surface, fonts, locale); + const char* marker = text + TextContext::Marker(text, bytes); + TextContext context(*window.geometry.surface); context.SetFont(family, height, 0, 0); if (window.HasTextBackground()) { @@ -114,7 +114,7 @@ void DrawColoredText( // OFFSET: 0x00A84B80 // FUNCTION: fn_17014 void DrawStyledColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, int family, int height, unsigned char bold, unsigned char italic, bool shadow ) { if (bytes == 0) { @@ -123,8 +123,8 @@ void DrawStyledColoredText( const char* current = text; const char* end = text + bytes; - const char* marker = text + TextContext::Marker(text, bytes, locale.inlineCharset); - TextContext context(*window.geometry.surface, fonts, locale); + const char* marker = text + TextContext::Marker(text, bytes); + TextContext context(*window.geometry.surface); context.SetFont(family, height, bold, italic); if (window.HasTextBackground()) { @@ -167,14 +167,14 @@ void DrawStyledColoredText( // OFFSET: 0x00A85720 // FUNCTION: fn_17016 void DrawOutlinedText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, int x, int y, const char* text, unsigned bytes, std::uint32_t color, std::uint32_t outline, + UIWindow& window, int x, int y, const char* text, unsigned bytes, std::uint32_t color, std::uint32_t outline, int family, int height, unsigned char bold, unsigned char italic ) { if (bytes == 0) { bytes = static_cast(std::strlen(text)); } - TextContext context(*window.geometry.surface, fonts, locale); + TextContext context(*window.geometry.surface); context.SetFont(family, height, bold, italic); if (window.HasTextBackground()) { @@ -197,7 +197,7 @@ void DrawOutlinedText( // OFFSET: 0x00A848B0 // FUNCTION: fn_17013 void DrawOutlinedColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, std::uint32_t outline, int family, int height, unsigned char bold ) { if (bytes == 0) { @@ -206,8 +206,8 @@ void DrawOutlinedColoredText( const char* current = text; const char* end = text + bytes; - const char* marker = text + TextContext::Marker(text, bytes, locale.inlineCharset); - TextContext context(*window.geometry.surface, fonts, locale); + const char* marker = text + TextContext::Marker(text, bytes); + TextContext context(*window.geometry.surface); context.SetFont(family, height, bold, 0); while (current < end) { diff --git a/Source/UI/Text/ColoredText.h b/Source/UI/Text/ColoredText.h index c7ff4f0..a133ab7 100644 --- a/Source/UI/Text/ColoredText.h +++ b/Source/UI/Text/ColoredText.h @@ -8,21 +8,21 @@ class FontCache; struct TextLocale; void DrawColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, int family, int height, bool shadow ); void DrawStyledColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, int family, int height, unsigned char bold, unsigned char italic, bool shadow ); void DrawOutlinedText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, int x, int y, const char* text, unsigned bytes, std::uint32_t color, std::uint32_t outline, + UIWindow& window, int x, int y, const char* text, unsigned bytes, std::uint32_t color, std::uint32_t outline, int family, int height, unsigned char bold, unsigned char italic ); void DrawOutlinedColoredText( - UIWindow& window, FontCache& fonts, const TextLocale& locale, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, + UIWindow& window, unsigned short codePage, int x, int y, const char* text, unsigned bytes, std::uint32_t& color, std::uint32_t outline, int family, int height, unsigned char bold ); diff --git a/Source/UI/Text/ItemLinkDisplay.cpp b/Source/UI/Text/ItemLinkDisplay.cpp index 3990fb5..3d1dedc 100644 --- a/Source/UI/Text/ItemLinkDisplay.cpp +++ b/Source/UI/Text/ItemLinkDisplay.cpp @@ -113,7 +113,7 @@ std::string ItemLinkDisplay::Convert(const std::string& text) { if (this->Name(encoded, name)) { result += '<'; - result += FitText(this->surface, this->fonts, this->locale, name, this->width / 2); + result += FitText(this->surface, name, this->width / 2); result += '>'; position += static_cast(15 + encoded.size()); } diff --git a/Source/UI/Text/PixelTextWrapping.cpp b/Source/UI/Text/PixelTextWrapping.cpp index 6b9edad..5cf1662 100644 --- a/Source/UI/Text/PixelTextWrapping.cpp +++ b/Source/UI/Text/PixelTextWrapping.cpp @@ -26,7 +26,7 @@ namespace { // OFFSET: 0x00A82310 // FUNCTION: fn_16993 void WrapPixelText( - CDC& surface, FontCache& fonts, const TextLocale& locale, unsigned short codePage, const char* text, std::vector& lines, int width + CDC& surface, unsigned short codePage, const char* text, std::vector& lines, int width ) { if (!text || *text == '\0') { return; @@ -41,7 +41,7 @@ void WrapPixelText( return 0; } - TextContext context(surface, fonts, locale); + TextContext context(surface); context.SetFont(0, 12, 0, 0); return static_cast(context.Measure(part, bytes).cx); }; diff --git a/Source/UI/Text/PixelTextWrapping.h b/Source/UI/Text/PixelTextWrapping.h index acc9406..2000f57 100644 --- a/Source/UI/Text/PixelTextWrapping.h +++ b/Source/UI/Text/PixelTextWrapping.h @@ -9,7 +9,7 @@ class FontCache; struct TextLocale; void WrapPixelText( - CDC& surface, FontCache& fonts, const TextLocale& locale, unsigned short codePage, const char* text, std::vector& lines, int width + CDC& surface, unsigned short codePage, const char* text, std::vector& lines, int width ); #endif diff --git a/Source/UI/Text/TextFitting.cpp b/Source/UI/Text/TextFitting.cpp index ad50e6f..0d3bd00 100644 --- a/Source/UI/Text/TextFitting.cpp +++ b/Source/UI/Text/TextFitting.cpp @@ -7,8 +7,8 @@ // OFFSET: 0x00A837D0 // FUNCTION: fn_17007 -std::string FitText(CDC& surface, FontCache& fonts, const TextLocale& locale, std::string text, int width) { - TextContext context(surface, fonts, locale); +std::string FitText(CDC& surface, std::string text, int width) { + TextContext context(surface); context.SetFont(0, 12, 0, 0); int extent = text.empty() ? 0 : context.Measure(text.c_str(), static_cast(text.size())).cx; context.Measure("...", 3); diff --git a/Source/UI/Text/TextFitting.h b/Source/UI/Text/TextFitting.h index efad9b0..e05cf35 100644 --- a/Source/UI/Text/TextFitting.h +++ b/Source/UI/Text/TextFitting.h @@ -7,6 +7,6 @@ class CDC; class FontCache; struct TextLocale; -std::string FitText(CDC& surface, FontCache& fonts, const TextLocale& locale, std::string text, int width); +std::string FitText(CDC& surface, std::string text, int width); #endif diff --git a/Source/UI/Text/TextWrapping.cpp b/Source/UI/Text/TextWrapping.cpp index 5bb641a..c3a4418 100644 --- a/Source/UI/Text/TextWrapping.cpp +++ b/Source/UI/Text/TextWrapping.cpp @@ -2,6 +2,7 @@ #include "Contents/Items/ItemInfo.h" #include "Render/Text/TextContext.h" #include "UI/Text/TextWrapping.h" +#include "Utility/Text/TextTokens.h" #include #include @@ -13,7 +14,7 @@ // OFFSET: 0x009B4220 // FUNCTION: fn_13829 -void WrapPlainText(const char* text, std::vector& lines, int width, unsigned short codePage, bool inlineCharset) { +void WrapPlainText(const char* text, std::vector& lines, int width, unsigned short codePage) { const char* begin = text; const char* chunk = text; const char* current = text; @@ -21,7 +22,7 @@ void WrapPlainText(const char* text, std::vector& lines, int width, const unsigned bytes = static_cast(std::strlen(text)); const char* end = text + bytes; const char* limit = text + width; - const char* marker = text + TextContext::Marker(text, bytes, inlineCharset); + const char* marker = text + TextContext::Marker(text, bytes); while (current < end) { current = CharNextExA(codePage, current, 0); @@ -47,7 +48,7 @@ void WrapPlainText(const char* text, std::vector& lines, int width, lines.emplace_back(chunk, current); } - if (inlineCharset && *marker != '\0' && marker < end) { + if (g_inlineCharset && *marker != '\0' && marker < end) { for (std::size_t index = 1; index < lines.size(); ++index) { lines[index].insert(0, marker, 3); } @@ -79,7 +80,7 @@ namespace { // OFFSET: 0x009B4730 // FUNCTION: fn_13833 void WrapRichText( - const char* text, std::vector& lines, int width, bool carriageReturns, unsigned short codePage, bool inlineCharset, ItemDescriptions& items + const char* text, std::vector& lines, int width, bool carriageReturns, unsigned short codePage, ItemDescriptions& items ) { const char* begin = text; const char* current = text; @@ -87,7 +88,7 @@ void WrapRichText( const unsigned bytes = static_cast(std::strlen(text)); const char* end = text + bytes; const char* limit = text + width; - const char* marker = text + TextContext::Marker(text, bytes, inlineCharset); + const char* marker = text + TextContext::Marker(text, bytes); while (current < end) { if (carriageReturns && *current == '\r') { @@ -194,7 +195,7 @@ void WrapRichText( lines.emplace_back(begin, current); } - if (inlineCharset && *marker != '\0' && marker < end) { + if (g_inlineCharset && *marker != '\0' && marker < end) { for (std::size_t index = 1; index < lines.size(); ++index) { const unsigned position = Color(lines[index].data(), lines[index].size()) ? 7 : 0; lines[index].insert(position, marker, 3); diff --git a/Source/UI/Text/TextWrapping.h b/Source/UI/Text/TextWrapping.h index 8394da1..9da0024 100644 --- a/Source/UI/Text/TextWrapping.h +++ b/Source/UI/Text/TextWrapping.h @@ -6,10 +6,10 @@ struct ItemDescriptions; -void WrapPlainText(const char* text, std::vector& lines, int width, unsigned short codePage, bool inlineCharset); +void WrapPlainText(const char* text, std::vector& lines, int width, unsigned short codePage); void WrapRichText( - const char* text, std::vector& lines, int width, bool carriageReturns, unsigned short codePage, bool inlineCharset, ItemDescriptions& items + const char* text, std::vector& lines, int width, bool carriageReturns, unsigned short codePage, ItemDescriptions& items ); #endif diff --git a/Source/UI/Text/UIBalloonText.cpp b/Source/UI/Text/UIBalloonText.cpp index a04234f..60fed1a 100644 --- a/Source/UI/Text/UIBalloonText.cpp +++ b/Source/UI/Text/UIBalloonText.cpp @@ -38,7 +38,7 @@ namespace { return {0, 0}; } - TextContext context(*window.geometry.surface, owner.fonts, owner.locale); + TextContext context(*window.geometry.surface); context.SetFont(family, height, 0, 0); return context.Measure(text.c_str(), static_cast(text.size())); } @@ -76,9 +76,9 @@ void UIBalloonText::SetText(const char* text, int width) { this->m_lines.clear(); if (this->m_richText != 0) { - WrapRichText(text, this->m_lines, width, false, this->m_textContext->codePage, this->m_textContext->locale.inlineCharset, this->m_textContext->items); + WrapRichText(text, this->m_lines, width, false, this->m_textContext->codePage, this->m_textContext->items); } else { - WrapPlainText(text, this->m_lines, width, this->m_textContext->codePage, this->m_textContext->locale.inlineCharset); + WrapPlainText(text, this->m_lines, width, this->m_textContext->codePage); } if (!this->m_lines.empty()) { diff --git a/Source/UI/Text/UITextViewer.cpp b/Source/UI/Text/UITextViewer.cpp index e23d36d..4036fa7 100644 --- a/Source/UI/Text/UITextViewer.cpp +++ b/Source/UI/Text/UITextViewer.cpp @@ -149,11 +149,11 @@ void UITextViewer::Paint() { const auto bytes = static_cast(line.size()); if ((this->unknown_00BC & 255) != 0) { - DrawOutlinedText(*this, owner.fonts, owner.locale, 3, y, line.c_str(), bytes, 0, 0xFFFFFF, 0, 12, 0, 0); + DrawOutlinedText(*this, 3, y, line.c_str(), bytes, 0, 0xFFFFFF, 0, 12, 0, 0); } else if (this->outline != 0) { - DrawOutlinedColoredText(*this, owner.fonts, owner.locale, owner.codePage, 3, y, line.c_str(), bytes, color, this->backgroundColor, 0, 12, this->bold); + DrawOutlinedColoredText(*this, owner.codePage, 3, y, line.c_str(), bytes, color, this->backgroundColor, 0, 12, this->bold); } else { - DrawColoredText(*this, owner.fonts, owner.locale, owner.codePage, 3, y, line.c_str(), bytes, color, 0, 12, false); + DrawColoredText(*this, owner.codePage, 3, y, line.c_str(), bytes, color, 0, 12, false); } } } diff --git a/Source/UI/Text/UITextViewerMessages.cpp b/Source/UI/Text/UITextViewerMessages.cpp index bd10a0a..6889da4 100644 --- a/Source/UI/Text/UITextViewerMessages.cpp +++ b/Source/UI/Text/UITextViewerMessages.cpp @@ -115,7 +115,7 @@ void UITextViewer::AppendText(char* text, int width, bool carriageReturns, bool std::vector wrapped; if (width == 138) { - WrapPlainText(text, wrapped, 38, owner.codePage, owner.locale.inlineCharset); + WrapPlainText(text, wrapped, 38, owner.codePage); for (const auto& line : wrapped) { this->AddLine(line.c_str()); @@ -151,10 +151,10 @@ void UITextViewer::AppendText(char* text, int width, bool carriageReturns, bool if (pixels) { const int scrollWidth = carriageReturns ? this->verticalBar->geometry.width + 2 : 0; - WrapPixelText(*this->geometry.surface, owner.fonts, owner.locale, owner.codePage, display.c_str(), wrapped, this->geometry.width - scrollWidth - 4); + WrapPixelText(*this->geometry.surface, owner.codePage, display.c_str(), wrapped, this->geometry.width - scrollWidth - 4); } else { WrapRichText( - display.c_str(), wrapped, width == 0 ? 35 : width, carriageReturns, owner.codePage, owner.locale.inlineCharset, this->m_text->items.descriptions + display.c_str(), wrapped, width == 0 ? 35 : width, carriageReturns, owner.codePage, this->m_text->items.descriptions ); } diff --git a/Source/UI/Text/UITransBalloonText.cpp b/Source/UI/Text/UITransBalloonText.cpp index f333f92..d7d8a3e 100644 --- a/Source/UI/Text/UITransBalloonText.cpp +++ b/Source/UI/Text/UITransBalloonText.cpp @@ -106,10 +106,10 @@ void UITransBalloonText::Paint() { if (this->m_richText != 0) { DrawColoredText( - *this, this->m_textContext->fonts, this->m_textContext->locale, this->m_textContext->codePage, 6, y, line.c_str(), 0, color, family, height, true + *this, this->m_textContext->codePage, 6, y, line.c_str(), 0, color, family, height, true ); } else { - TextContext context(*this->geometry.surface, this->m_textContext->fonts, this->m_textContext->locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, 0, 0); context.SetColor(this->m_outlineColor); context.Draw(7, (y + 1), line.c_str(), static_cast(line.size())); @@ -120,7 +120,7 @@ void UITransBalloonText::Paint() { int lineHeight = 0; if (!line.empty()) { - TextContext context(*this->geometry.surface, this->m_textContext->fonts, this->m_textContext->locale); + TextContext context(*this->geometry.surface); context.SetFont(0, this->m_fontHeight, 0, 0); lineHeight = context.Measure(line.c_str(), static_cast(line.size())).cy; } diff --git a/Source/UI/Window/UIMessageBox.cpp b/Source/UI/Window/UIMessageBox.cpp index 06490d4..e25d72d 100644 --- a/Source/UI/Window/UIMessageBox.cpp +++ b/Source/UI/Window/UIMessageBox.cpp @@ -48,7 +48,7 @@ namespace { if (!bytes) { bytes = static_cast(std::strlen(text)); } - TextContext context(*window.geometry.surface, fonts, locale); + TextContext context(*window.geometry.surface); context.SetFont(family, height, bold, 0); const int width = context.Measure(text, static_cast(std::strlen(text))).cx; context.SetColor(color); diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index e379e8c..a5d710d 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -705,7 +705,7 @@ int UIWindow::TextWidth( } } - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, italic); return context.Measure(text, bytes).cx; } @@ -720,7 +720,7 @@ void UIWindow::DrawTextAt( bytes = static_cast(std::strlen(text)); } - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, italic); context.SetColor(color); context.Draw(x, y, text, bytes); @@ -841,7 +841,7 @@ void UIWindow::DrawAmount(FontCache& fonts, const TextLocale& locale, int amount const char* characters = text.c_str(); const int bytes = static_cast(std::strlen(characters)); - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(0, 12, 0, 0); context.SetColor(color); if (outlined) { @@ -869,7 +869,7 @@ int UIWindow::TextHeight( } } - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, italic); return context.Measure(text, bytes).cy; } @@ -890,8 +890,8 @@ int UIWindow::VerticalTextHeight(FontCache& fonts, const TextLocale& locale, con const char* end = text + bytes; int total = 0; - const char* marker = text + TextContext::Marker(text, static_cast(end - text), locale.inlineCharset); - TextContext context(*this->geometry.surface, fonts, locale); + const char* marker = text + TextContext::Marker(text, static_cast(end - text)); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, 0); if (marker && *marker) { text = marker + 3; @@ -923,7 +923,7 @@ SIZE UIWindow::TextSize( } } - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, italic); size = context.Measure(text, bytes); return size; @@ -946,10 +946,10 @@ SIZE UIWindow::VerticalTextSize( } } - TextContext context(*this->geometry.surface, fonts, locale); + TextContext context(*this->geometry.surface); context.SetFont(family, height, bold, italic); const char* end = text + bytes; - const char* marker = text + TextContext::Marker(text, static_cast(end - text), locale.inlineCharset); + const char* marker = text + TextContext::Marker(text, static_cast(end - text)); if (marker && *marker) { text = marker + 3; }