rodecomp/Source/UI/Shop/MerchantShopRefresh.cpp
ragnarok-clanker c932ad6499 Maintenance: Resubmission of 15134 without the 12 struct/type renames (their new names changed mangled symbols in 17 functions). Rena
Batch #15141 by ragnarok-clanker: no function's compiled code changes; checked with 537 compiled unit(s), including every includer of Source/Client/Input/LanguageTC.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Contents/AchievementMgr.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/Pc.h, Source/Contents/EnchantMgr.h, Source/Contents/GuildInfo.h, Source/Contents/Messenger/MessengerWindows.h, Source/Contents/Schedule/TimeScheduler.h, Source/Contents/Sound/SoundMgr.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/TableMng.h, Source/Contents/World/SkyBox.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/UI/Window/UINewSkillListWnd.h, Source/UI/Window/UIPetInfoWnd.h, Source/UI/Window/UIReplayRECControlWnd.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl.
2026-11-09 12:21:09 +00:00

96 lines
2.6 KiB
C++

#include "Client/Session.h"
#include "Contents/Store/MCStoreInfoBackup.h"
#include "UI/Shop/PriceColor.h"
#include "UI/Shop/UIMerchantShopMakeWnd.h"
#include "UI/Buttons/UIBasicButton.h"
#include "UI/Edit/UIEditCtrl.h"
#include "UI/Window/UIWindowMgr.h"
#include "Utility/Text/GroupedInteger.h"
#include <cstdlib>
#include <cstring>
// OFFSET: 0x00970E60
// FUNCTION: fn_13262
void UIMerchantShopMakeWnd::Refresh() {
CMCStoreInfoBackup& backup = g_session.m_storeInfoBackup;
if (std::string(backup.title).empty()) {
this->actionButton->SetDisabled(0);
this->actionButton->Invalidate();
return;
}
this->titleEdit->SetText(std::string(backup.title).c_str());
this->titleEdit->Invalidate();
for (int index = 0; index < this->slotCount; ++index) {
UIEditCtrl* edit = this->priceEdits[index];
edit->SetText("");
int background;
if (this->mode != 0) {
background = 232;
} else {
edit->disabled = 1;
edit->Invalidate();
background = 182;
}
edit->Background(background, background, background);
}
const int count = g_session.GetList11Size();
for (int index = 0; index < count; ++index) {
const ITEM_INFO item = g_session.GetItem1768At(index);
g_session.AddMerchantMyShopItem(item, this->mode, 0);
}
g_session.ClearMerchantPurchaseSavedItems();
backup.Restore(this->mode != 0, this->slotCount);
const std::vector<ITEM_INFO> displayed(backup.items);
int index = 0;
UIEditCtrl** edit = this->priceEdits;
for (const ITEM_INFO& item : displayed) {
if (index >= this->slotCount) {
break;
}
const int price = static_cast<int>(item.prices[0]);
char value[24] = {};
_itoa(price, value, 10);
(*edit)->disabled = 0;
(*edit)->Invalidate();
(*edit)->Background(232, 232, 232);
(*edit)->SelectAll();
(*edit)->SetText(value);
if (this->mode != 0 && index < 5) {
char quantity[24] = {};
_itoa(item.quantity, quantity, 10);
this->quantityEdits[index]->SetText(quantity);
this->quantityEdits[index]->Invalidate();
} else {
const PriceColors colors = PriceColor(price);
(*edit)->TextColor(colors.primary, colors.secondary);
char grouped[24] = {};
FormatGroupedInteger(price, grouped, sizeof(grouped));
(*edit)->SetText(grouped);
this->previousPriceLength = (*edit)->Length();
}
++edit;
++index;
}
g_session.RefreshItem1768Window(this->mode != 0, 0);
g_session.RefreshItem1750Window(this->mode);
this->actionButton->SetDisabled(0);
this->actionButton->Invalidate();
backup.Clear();
}