Maintenance: [forced, user-approved] Family G24: remove EditTextState, EditViewport (inventory rows 83, 55) and the unused FrameFocus
Batch #10246 by ragnarok-clanker: forced by an admin (0 lower score(s), 3 changed function(s)); checked with 58 compiled unit(s), including every includer of Source/UI/Lists/UIListBox.h, Source/UI/Edit/EditTextState.h, Source/UI/Edit/EditViewport.h, Source/UI/Window/FrameFocus.h. Deletes: Source/UI/Edit/EditTextState.h, Source/UI/Edit/EditViewport.h, Source/UI/Window/FrameFocus.h
This commit is contained in:
parent
a501aa68af
commit
e4b0652264
9 changed files with 15 additions and 138 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <cstring>
|
||||
|
||||
// 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<int>(length) <= this->maximum) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto codePage = static_cast<WORD>(this->codePage);
|
||||
const auto codePage = static_cast<WORD>(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<int>(g_serverLanguage->text.size()));
|
||||
} else {
|
||||
this->anchor = 0;
|
||||
|
|
@ -54,7 +43,3 @@ void EditTextState::SelectAll() {
|
|||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x00858D50
|
||||
int EditTextState::Length() const {
|
||||
return static_cast<int>(this->focused ? g_serverLanguage->text.size() : this->text.size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef RAGNAROK_SOURCE_UI_EDIT_EDITTEXTSTATE_H
|
||||
#define RAGNAROK_SOURCE_UI_EDIT_EDITTEXTSTATE_H
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
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
|
||||
|
|
@ -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 <algorithm>
|
||||
#include <cstdint>
|
||||
|
|
@ -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<std::uint32_t>(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<int>(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<unsigned>(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<WORD>(this->codePage), this->text.c_str(), 0);
|
||||
const char* next = CharNextExA(static_cast<WORD>(g_textCodePage), this->text.c_str(), 0);
|
||||
|
||||
while (measure(next, 0) + 3 > available && next < end) {
|
||||
next = CharNextExA(static_cast<WORD>(this->codePage), next, 0);
|
||||
next = CharNextExA(static_cast<WORD>(g_textCodePage), next, 0);
|
||||
}
|
||||
|
||||
const auto tail = static_cast<std::uint32_t>(std::strlen(next));
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef RAGNAROK_SOURCE_UI_EDIT_EDITVIEWPORT_H
|
||||
#define RAGNAROK_SOURCE_UI_EDIT_EDITVIEWPORT_H
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct FrameFocus;
|
||||
class ResourceMgr;
|
||||
class UIScrollBar;
|
||||
#include "UI/Window/WindowManagerWindows.h"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef RAGNAROK_SOURCE_UI_WINDOW_FRAMEFOCUS_H
|
||||
#define RAGNAROK_SOURCE_UI_WINDOW_FRAMEFOCUS_H
|
||||
|
||||
#include <list>
|
||||
|
||||
class UIWindow;
|
||||
#include "UI/Window/WindowManagerWindows.h"
|
||||
|
||||
struct FrameFocus {
|
||||
std::list<int>& 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue