diff --git a/Source/UI/Buttons/UICheckBox.cpp b/Source/UI/Buttons/UICheckBox.cpp index cd9e2267..016bc8d1 100644 --- a/Source/UI/Buttons/UICheckBox.cpp +++ b/Source/UI/Buttons/UICheckBox.cpp @@ -5,7 +5,6 @@ #include "Resource/Bitmap/BitmapResource.h" #include "Resource/ResourceMgr.h" #include "Resource/TextureNames.h" -#include "UI/Window/FrameFocus.h" #include "UI/Buttons/UICheckBox.h" // OFFSET: 0x0084F010 diff --git a/Source/UI/Edit/EditTextState.cpp b/Source/UI/Edit/EditTextState.cpp index 2fa664f3..a1a3283a 100644 --- a/Source/UI/Edit/EditTextState.cpp +++ b/Source/UI/Edit/EditTextState.cpp @@ -1,33 +1,22 @@ #include "Client/Input/InputCharset.h" #include "Client/Input/Language.h" -#include "UI/Edit/EditTextState.h" +#include "Network/TextEncoding.h" +#include "UI/Edit/UIEditCtrl.h" +#include "UI/Window/UIWindowMgr.h" #include -// INLINED -void EditTextState::SetText(const char* value) { - this->text.assign(value, std::strlen(value)); - this->Trim(); - - if (this->focused) { - g_serverLanguage->ResetInput(); - g_serverLanguage->ResetInput(); - g_serverLanguage->Insert(this->text.c_str()); - } - - this->SelectAll(); -} // OFFSET: 0x00868450 // FUNCTION: fn_10959 -void EditTextState::Trim() { +void UIEditCtrl::Trim() { const auto length = this->text.size(); if (static_cast(length) <= this->maximum) { return; } - const auto codePage = static_cast(this->codePage); + const auto codePage = static_cast(g_textCodePage); const char* start = this->text.c_str(); const char* next = CharNextExA(codePage, start, 0); @@ -45,8 +34,8 @@ void EditTextState::Trim() { // OFFSET: 0x0085A590 // FUNCTION: fn_10778 -void EditTextState::SelectAll() { - if (this->focused) { +void UIEditCtrl::SelectAll() { + if (g_windowMgr.GetHoverWindow() == this) { g_serverLanguage->Select(0, static_cast(g_serverLanguage->text.size())); } else { this->anchor = 0; @@ -54,7 +43,3 @@ void EditTextState::SelectAll() { } } -// OFFSET: 0x00858D50 -int EditTextState::Length() const { - return static_cast(this->focused ? g_serverLanguage->text.size() : this->text.size()); -} diff --git a/Source/UI/Edit/EditTextState.h b/Source/UI/Edit/EditTextState.h deleted file mode 100644 index b72d4ada..00000000 --- a/Source/UI/Edit/EditTextState.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_EDIT_EDITTEXTSTATE_H -#define RAGNAROK_SOURCE_UI_EDIT_EDITTEXTSTATE_H - -#include -#include - -struct CLanguageBase; - -struct EditTextState { - std::string& text; - int& anchor; - int& cursor; - const int& maximum; - const bool& focused; - const UINT& codePage; - - void SetText(const char* value); - void Trim(); - void SelectAll(); - int Length() const; -}; - -#endif diff --git a/Source/UI/Edit/EditViewport.cpp b/Source/UI/Edit/EditViewport.cpp index 1a374f5f..06ec310d 100644 --- a/Source/UI/Edit/EditViewport.cpp +++ b/Source/UI/Edit/EditViewport.cpp @@ -1,8 +1,7 @@ #include "Client/Input/InputCharset.h" #include "Client/Input/Language.h" -#include "Render/Text/TextContext.h" -#include "UI/Edit/EditTextState.h" -#include "UI/Edit/EditViewport.h" +#include "Network/TextEncoding.h" +#include "UI/Edit/UIEditCtrl.h" #include #include @@ -10,11 +9,11 @@ // OFFSET: 0x00862FB0 // FUNCTION: fn_10905 -void EditViewport::Synchronize() { +void UIEditCtrl::Synchronize() { const int previousCursor = this->cursor; g_serverLanguage->CopyDisplayText(this->text); g_serverLanguage->Selection(this->anchor, this->cursor); - this->state.Trim(); + this->Trim(); const auto length = static_cast(this->text.size()); bool clamped = false; @@ -37,10 +36,8 @@ void EditViewport::Synchronize() { this->firstVisible = 0; } - 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; + const auto measure = [&](const char* text, unsigned bytes) { return this->TextWidth(text, bytes, 0, 12, 0, 0); }; + const int available = this->geometry.width - 7; if (this->cursor > previousCursor || clamped) { const int before = this->firstVisible == 0 ? 0 : measure(this->text.c_str(), static_cast(this->firstVisible)); @@ -48,10 +45,10 @@ void EditViewport::Synchronize() { if (position > available) { const char* end = this->text.c_str() + this->text.size(); - const char* next = CharNextExA(static_cast(this->codePage), this->text.c_str(), 0); + const char* next = CharNextExA(static_cast(g_textCodePage), this->text.c_str(), 0); while (measure(next, 0) + 3 > available && next < end) { - next = CharNextExA(static_cast(this->codePage), next, 0); + next = CharNextExA(static_cast(g_textCodePage), next, 0); } const auto tail = static_cast(std::strlen(next)); diff --git a/Source/UI/Edit/EditViewport.h b/Source/UI/Edit/EditViewport.h deleted file mode 100644 index 95b59f47..00000000 --- a/Source/UI/Edit/EditViewport.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_EDIT_EDITVIEWPORT_H -#define RAGNAROK_SOURCE_UI_EDIT_EDITVIEWPORT_H - -#include -#include - -class CDC; -struct CLanguageBase; -struct EditTextState; - -struct EditViewport { - std::string& text; - int& anchor; - int& cursor; - int& firstVisible; - const int& width; - const UINT& codePage; - EditTextState& state; - CDC& surface; - - void Synchronize(); -}; - -#endif diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index deb70c89..54b79dca 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -18,8 +18,6 @@ #include "Contents/MessageTable.h" #include "UI/Shop/ItemDrawing.h" #include "Utility/Text/FormatString.h" -#include "UI/Edit/EditTextState.h" -#include "UI/Edit/EditViewport.h" #include "UI/Window/InputFocus.h" #include "UI/Buttons/UIButton.h" #include "UI/Edit/UIEditCtrl.h" @@ -389,12 +387,6 @@ void UIEditCtrl::SetText(const char* value) { } } -// OFFSET: 0x0085A590 -void UIEditCtrl::SelectAll() { - const bool focused = g_windowMgr.hoverWindow == this; - EditTextState state{this->text, this->anchor, this->cursor, this->maximum, focused, g_textCodePage}; - state.SelectAll(); -} // OFFSET: 0x00856980 // FUNCTION: fn_10755 @@ -404,29 +396,6 @@ void UIEditCtrl::PaintText() { -// OFFSET: 0x00862FB0 -void UIEditCtrl::Synchronize() { - const bool focused = g_windowMgr.hoverWindow == this; - EditTextState state{this->text, this->anchor, this->cursor, this->maximum, focused, g_textCodePage}; - EditViewport viewport{ - this->text, - this->anchor, - this->cursor, - this->firstVisible, - this->geometry.width, - g_textCodePage, - state, - *this->geometry.surface - }; - viewport.Synchronize(); -} - -// OFFSET: 0x00868450 -void UIEditCtrl::Trim() { - const bool focused = g_windowMgr.hoverWindow == this; - EditTextState state{this->text, this->anchor, this->cursor, this->maximum, focused, g_textCodePage}; - state.Trim(); -} // OFFSET: 0x00858D50 // FUNCTION: fn_10768 diff --git a/Source/UI/Lists/UIListBox.h b/Source/UI/Lists/UIListBox.h index 2e8b9a23..7a5c9e75 100644 --- a/Source/UI/Lists/UIListBox.h +++ b/Source/UI/Lists/UIListBox.h @@ -6,7 +6,6 @@ #include #include -struct FrameFocus; class ResourceMgr; class UIScrollBar; #include "UI/Window/WindowManagerWindows.h" diff --git a/Source/UI/UIMacroUserInfoWnd.cpp b/Source/UI/UIMacroUserInfoWnd.cpp index 37401c21..7db01214 100644 --- a/Source/UI/UIMacroUserInfoWnd.cpp +++ b/Source/UI/UIMacroUserInfoWnd.cpp @@ -25,7 +25,6 @@ #include "UI/Layout/SnapMgr.h" #include "Contents/UserData/NormalItemSlots.h" #include "UI/Lists/UIScrollBar.h" -#include "UI/Window/FrameFocus.h" #include "UI/Window/InputFocus.h" #include "UI/Window/UIWindowMgr.h" #include "UI/Window/WindowBorder.h" diff --git a/Source/UI/Window/FrameFocus.h b/Source/UI/Window/FrameFocus.h deleted file mode 100644 index cc2987b9..00000000 --- a/Source/UI/Window/FrameFocus.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_WINDOW_FRAMEFOCUS_H -#define RAGNAROK_SOURCE_UI_WINDOW_FRAMEFOCUS_H - -#include - -class UIWindow; -#include "UI/Window/WindowManagerWindows.h" - -struct FrameFocus { - std::list& order; - UIWindow*& focused; - WindowManagerWindows& windows; - - bool IsOrderFixed(int id); - void RemoveOrder(int id); - void BringToFront(int id); - void Set(UIWindow* window); - void Clear(); - UIWindow* Get() const; -}; - -extern int g_dragWindowId; - -#endif