diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index 1bfce5e2..3dd38dc4 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -3652,3 +3652,57 @@ bool IsInputSuggestionAllowed() { return true; } + +// OFFSET: 0x00860080 +// FUNCTION: fn_10898 +bool UIEditCtrl::DecodeItemLink(const std::vector& values, ITEM_INFO& item) { + if (values.empty()) { + return false; + } + + ITEM_DESC description = FindItemDescription(values[2]); + item.SetName(description.identifiedName); + std::string name(description.identifiedName); + LowercaseText(name); + if (name.find("unknown item") != std::string::npos) { + return false; + } + + item.unknown_0000[2] = values[0]; + item.SetItemId(values[2]); + if (values[1] != 0) { + item.unknown_0000[0] = 4; + } + + if (values.size() > 3) { + item.unknown_0060 = values[3]; + } + + item.unknown_0070 = values[4]; + int cardCount = 0; + item.unknown_0088 = static_cast(values[5]); + if (values.size() > 6) { + cardCount = values[6]; + for (int i = 1; i < cardCount + 1; ++i) { + int index = i - 1; + item.SetCard(values[6 + i], index); + } + } + + if (static_cast(cardCount + 8) < values.size()) { + item.unknown_0098 = values[cardCount + 8]; + int optionCount = item.unknown_0098 + 1; + for (int i = 1; i < optionCount; ++i) { + const int base = cardCount + 9 + (i - 1) * 3; + ItemOption option; + option.id = static_cast(values[base]); + option.value = static_cast(values[base + 2]); + option.parameter = static_cast(values[base + 1]); + int index = i - 1; + item.SetOption(option, index); + } + } + + item.identified = 1; + return true; +} diff --git a/Source/UI/Edit/UIEditCtrl.h b/Source/UI/Edit/UIEditCtrl.h index 3961d811..c267529b 100644 --- a/Source/UI/Edit/UIEditCtrl.h +++ b/Source/UI/Edit/UIEditCtrl.h @@ -16,6 +16,7 @@ class WindowManagerWindows; class NavigationDestination; class UINaviLinkButton; class UIItemTagButton; +struct ITEM_INFO; struct UIEditContext { InputFocus& focus; @@ -70,6 +71,7 @@ public: void DrawSelection(int x, int width); void MoveCandidateWindow(int x); void MoveReadingWindow(int x); + bool DecodeItemLink(const std::vector& values, ITEM_INFO& item); /* 007C */ int anchor; /* 0080 */ int cursor; diff --git a/Source/UI/UIGradeEnchantWnd.cpp b/Source/UI/UIGradeEnchantWnd.cpp index b4897b04..1b103786 100644 --- a/Source/UI/UIGradeEnchantWnd.cpp +++ b/Source/UI/UIGradeEnchantWnd.cpp @@ -549,3 +549,56 @@ void UIGradeEnchantWnd::SetResult(int state, int result) { this->Invalidate(); } + +struct SessionMessengerContext { + int GetList0Size() const; +}; + +// OFFSET: 0x007E7050 +// FUNCTION: fn_09748 +void UIGradeEnchantWnd::sub_7E7050() { + this->unknown_011C.clear(); + if (this->state != 1) { + return; + } + + std::string message; + if (this->unknown_0118 == 0) { + this->unknown_011C.push_back(3821); + return; + } + + if (this->selectedMaterial != -1 && this->materials[this->selectedMaterial].unknown_0010 == 0) { + this->unknown_011C.push_back(3822); + } + + if (this->selectedMaterial == -1) { + this->unknown_011C.push_back(3707); + } + + if (this->selectedMaterial != -1 && + LookupClientItem(g_session.m_inventoryItems, this->materials[this->selectedMaterial].itemId, 0).quantity < + this->materials[this->selectedMaterial].amount) { + this->unknown_011C.push_back(3708); + } + + if (g_session.m_zeny < this->SelectedMaterialZeny()) { + this->unknown_011C.push_back(3709); + } + + if (static_cast(g_session.m_weight) > static_cast(g_session.m_maxWeight) * 0.7f || + reinterpret_cast(&g_session)->GetList0Size() + g_session.CountItems17F0() + + g_session.CountItems2B50() >= + g_session.unknown_7FBC + 100) { + this->unknown_011C.push_back(3710); + } + + if (this->selectedMaterial != -1 && this->materials[this->selectedMaterial].unknown_0010 == 1) { + int warning = this->SuccessRate() < 100 ? 3712 : 3822; + this->unknown_011C.push_back(warning); + } + + if (this->selectedMaterial != -1 && this->materials[this->selectedMaterial].unknown_000C > 0) { + this->unknown_011C.push_back(3713); + } +} diff --git a/Source/UI/UIGradeEnchantWnd.h b/Source/UI/UIGradeEnchantWnd.h index bc75ecea..a075e527 100644 --- a/Source/UI/UIGradeEnchantWnd.h +++ b/Source/UI/UIGradeEnchantWnd.h @@ -13,7 +13,8 @@ struct GradeEnchantMaterial { /* 0000 */ std::uint32_t itemId; /* 0004 */ std::int32_t amount; /* 0008 */ std::int32_t zeny; - /* 000C */ unsigned char unknown_000C[5]; + /* 000C */ std::int32_t unknown_000C; + /* 0010 */ unsigned char unknown_0010; }; #pragma pack(pop)