runkissbig
01-10-12, 06:16 PM
Đầu tiên các bạn vào file WndText.cpp khai báo hàm sau vào chỗ nào cũng được. (tốt nhất là sau setinttext)
void KWndText::SetMoneyText(int nNumber, char Separator)
{
char Buff[64];
int nLen;
if (m_pText)
{
if (nNumber/10000 == 0)
nLen = sprintf(Buff, "%d l*îng",nNumber%10000);
else
{
if (nNumber%10000 == 0)
nLen = sprintf(Buff, "%d v¹n",nNumber/10000);
else
nLen = sprintf(Buff, "%d v¹n %d l*îng",nNumber/10000,nNumber%10000);
}
SetText(Buff, nLen);
}
}
vào WndText.h khai báo cho hàm vừa tạo (nên thay sau void setinttext)
void SetMoneyText(int nNumber, char Separator = 0); //Hien thi van luong
Tiếp đến là cho hiển thị vạn lượng trong rương, hành trang, giao dịch, NPC bán đồ.
các bạn sửa SetIntText thành SetMoneyText là ok. sửa ở những chỗ sau
void KUiItem::Breathe()
{
m_nMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
}
void KUiItem::UpdateData()
{
m_ItemBox.Clear();
m_nMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
void KUiStatus::UpdateRuntimeAttribute(KUiPlayerAttribu te* pInfo)
{
if (pInfo)
{
//m_Money.SetIntText(pInfo->nMoney);
m_Money.SetMoneyText(pInfo->nMoney);
void KUiStoreBox::UpdateItem(KUiObjAtRegion* pItem, int bAdd)
{
if (pItem)
{
UiSoundPlay(UI_SI_PICKPUT_ITEM);
if (pItem->Obj.uGenre != CGOG_MONEY)
{
KUiDraggedObject Obj;
Obj.uGenre = pItem->Obj.uGenre;
Obj.uId = pItem->Obj.uId;
Obj.DataX = pItem->Region.h;
Obj.DataY = pItem->Region.v;
Obj.DataW = pItem->Region.Width;
Obj.DataH = pItem->Region.Height;
if (bAdd)
m_ItemBox.AddObject(&Obj, 1);
else
m_ItemBox.RemoveObject(&Obj);
}
else
{
m_nMoney = pItem->Obj.uId;
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
}
}
else
UpdateData();
}
void KUiTrade::UpdateTakewithItems()
{
m_TakewithItemsBox.Clear();
m_nTakewithMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
void KUiTrade::OnOppositeChangedItem(KUiObjAtRegion* pObj, int bAdd)
{
_ASSERT(pObj);
if (pObj->Obj.uGenre == CGOG_MONEY)
{
m_OtherMoney.SetMoneyText(pObj->Obj.uId);
void KUiTrade::OnAdjustMoney(bool bAdd)
{
if (bAdd)
{
if (m_nTakewithMoney)
{
m_nTakewithMoney--;
m_nSelfTradeMoney++;
}
}
else if (m_nSelfTradeMoney)
{
m_nSelfTradeMoney--;
m_nTakewithMoney++;
}
m_SelfMoney.SetIntText(m_nSelfTradeMoney);
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
}
void KUiTrade::OnModififyMoney()
{
m_bAdjustingMoney = 1;
int nNewSelfTradeMoney = m_SelfMoney.GetIntNumber();
if (nNewSelfTradeMoney < 0)
nNewSelfTradeMoney = 0;
if (nNewSelfTradeMoney > m_nTakewithMoney + m_nSelfTradeMoney)
{
nNewSelfTradeMoney = m_nTakewithMoney + m_nSelfTradeMoney;
m_SelfMoney.SetIntText(nNewSelfTradeMoney);
}
m_nTakewithMoney -= nNewSelfTradeMoney - m_nSelfTradeMoney;
m_nSelfTradeMoney = nNewSelfTradeMoney;
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
}
void KUiTradeConfirm::Show()
{
m_ItemName.SetText(m_PriceInfo.szItemName);
//m_Money.SetIntText(m_PriceInfo.nPrice);
m_Money.SetMoneyText(m_PriceInfo.nPrice);
int Left, Top;
ALW_GetWndPosition(Left, Top, m_Width, m_Height);
SetPosition(Left, Top);
KWndImage::Show();
Wnd_SetExclusive((KWndWindow*)this);
}
void KUiTradeConfirm::LoadScheme(const char* pScheme)
{
char Buff[128];
KIniFile Ini;
sprintf(Buff, "%s\\%s", pScheme, SCHEME_INI);
if (Ini.Load(Buff))
{
Init(&Ini, "Main");
m_ItemName.Init(&Ini, "ItemName");
m_Money.Init(&Ini, "Price");
Ini.GetString("Price", "Color", "", Buff, sizeof(Buff));
m_uNormalPriceColor = GetColor(Buff);
Ini.GetString("Price", "CantBuyColor", "", Buff, sizeof(Buff));
m_uNotEnoughMoneyPriceColor = GetColor(Buff);
m_BuyImg.Init(&Ini, "BuyImg");
m_SaleImg.Init(&Ini, "SaleImg");
m_RepairImg.Init(&Ini, "RepairImg");
m_OkBtn.Init(&Ini, "OkBtn");
m_CancelBtn.Init(&Ini, "CancelBtn");
//m_Money.SetIntText(m_PriceInfo.nPrice);
m_Money.SetMoneyText(m_PriceInfo.nPrice);
}
}
void KWndText::SetMoneyText(int nNumber, char Separator)
{
char Buff[64];
int nLen;
if (m_pText)
{
if (nNumber/10000 == 0)
nLen = sprintf(Buff, "%d l*îng",nNumber%10000);
else
{
if (nNumber%10000 == 0)
nLen = sprintf(Buff, "%d v¹n",nNumber/10000);
else
nLen = sprintf(Buff, "%d v¹n %d l*îng",nNumber/10000,nNumber%10000);
}
SetText(Buff, nLen);
}
}
vào WndText.h khai báo cho hàm vừa tạo (nên thay sau void setinttext)
void SetMoneyText(int nNumber, char Separator = 0); //Hien thi van luong
Tiếp đến là cho hiển thị vạn lượng trong rương, hành trang, giao dịch, NPC bán đồ.
các bạn sửa SetIntText thành SetMoneyText là ok. sửa ở những chỗ sau
void KUiItem::Breathe()
{
m_nMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
}
void KUiItem::UpdateData()
{
m_ItemBox.Clear();
m_nMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
void KUiStatus::UpdateRuntimeAttribute(KUiPlayerAttribu te* pInfo)
{
if (pInfo)
{
//m_Money.SetIntText(pInfo->nMoney);
m_Money.SetMoneyText(pInfo->nMoney);
void KUiStoreBox::UpdateItem(KUiObjAtRegion* pItem, int bAdd)
{
if (pItem)
{
UiSoundPlay(UI_SI_PICKPUT_ITEM);
if (pItem->Obj.uGenre != CGOG_MONEY)
{
KUiDraggedObject Obj;
Obj.uGenre = pItem->Obj.uGenre;
Obj.uId = pItem->Obj.uId;
Obj.DataX = pItem->Region.h;
Obj.DataY = pItem->Region.v;
Obj.DataW = pItem->Region.Width;
Obj.DataH = pItem->Region.Height;
if (bAdd)
m_ItemBox.AddObject(&Obj, 1);
else
m_ItemBox.RemoveObject(&Obj);
}
else
{
m_nMoney = pItem->Obj.uId;
//m_Money.SetIntText(m_nMoney);
m_Money.SetMoneyText(m_nMoney);
}
}
else
UpdateData();
}
void KUiTrade::UpdateTakewithItems()
{
m_TakewithItemsBox.Clear();
m_nTakewithMoney = g_pCoreShell->GetGameData(GDI_PLAYER_HOLD_MONEY, 0, 0);
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
void KUiTrade::OnOppositeChangedItem(KUiObjAtRegion* pObj, int bAdd)
{
_ASSERT(pObj);
if (pObj->Obj.uGenre == CGOG_MONEY)
{
m_OtherMoney.SetMoneyText(pObj->Obj.uId);
void KUiTrade::OnAdjustMoney(bool bAdd)
{
if (bAdd)
{
if (m_nTakewithMoney)
{
m_nTakewithMoney--;
m_nSelfTradeMoney++;
}
}
else if (m_nSelfTradeMoney)
{
m_nSelfTradeMoney--;
m_nTakewithMoney++;
}
m_SelfMoney.SetIntText(m_nSelfTradeMoney);
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
}
void KUiTrade::OnModififyMoney()
{
m_bAdjustingMoney = 1;
int nNewSelfTradeMoney = m_SelfMoney.GetIntNumber();
if (nNewSelfTradeMoney < 0)
nNewSelfTradeMoney = 0;
if (nNewSelfTradeMoney > m_nTakewithMoney + m_nSelfTradeMoney)
{
nNewSelfTradeMoney = m_nTakewithMoney + m_nSelfTradeMoney;
m_SelfMoney.SetIntText(nNewSelfTradeMoney);
}
m_nTakewithMoney -= nNewSelfTradeMoney - m_nSelfTradeMoney;
m_nSelfTradeMoney = nNewSelfTradeMoney;
m_TakewithMoney.SetMoneyText(m_nTakewithMoney);
}
void KUiTradeConfirm::Show()
{
m_ItemName.SetText(m_PriceInfo.szItemName);
//m_Money.SetIntText(m_PriceInfo.nPrice);
m_Money.SetMoneyText(m_PriceInfo.nPrice);
int Left, Top;
ALW_GetWndPosition(Left, Top, m_Width, m_Height);
SetPosition(Left, Top);
KWndImage::Show();
Wnd_SetExclusive((KWndWindow*)this);
}
void KUiTradeConfirm::LoadScheme(const char* pScheme)
{
char Buff[128];
KIniFile Ini;
sprintf(Buff, "%s\\%s", pScheme, SCHEME_INI);
if (Ini.Load(Buff))
{
Init(&Ini, "Main");
m_ItemName.Init(&Ini, "ItemName");
m_Money.Init(&Ini, "Price");
Ini.GetString("Price", "Color", "", Buff, sizeof(Buff));
m_uNormalPriceColor = GetColor(Buff);
Ini.GetString("Price", "CantBuyColor", "", Buff, sizeof(Buff));
m_uNotEnoughMoneyPriceColor = GetColor(Buff);
m_BuyImg.Init(&Ini, "BuyImg");
m_SaleImg.Init(&Ini, "SaleImg");
m_RepairImg.Init(&Ini, "RepairImg");
m_OkBtn.Init(&Ini, "OkBtn");
m_CancelBtn.Init(&Ini, "CancelBtn");
//m_Money.SetIntText(m_PriceInfo.nPrice);
m_Money.SetMoneyText(m_PriceInfo.nPrice);
}
}