Skip to content
Merged
6 changes: 2 additions & 4 deletions src/game/client/ms/clplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int playerBodyArray[16]; //MiB MAR2010_12 Armor Fix FINAL

//Master Sword player functionality
void ShowWeaponDesc(CGenericItem* pItem);
void Storage_Show(const char* DisplayName, const char* StorageName, float flFeeRatio);
void Storage_Show(const char* DisplayName);
void UpdateActiveMenus();

/*
Expand Down Expand Up @@ -877,9 +877,7 @@ int __MsgFunc_Item(const char* pszName, int iSize, void* pbuf)
case 5:
{
msstring DisplayName = READ_STRING();
msstring StorageName = READ_STRING();
float flFeeRatio = READ_FLOAT();
Storage_Show(DisplayName, StorageName, flFeeRatio);
Storage_Show(DisplayName);
bDoInvUpdate = true;
}
break;
Expand Down
5 changes: 3 additions & 2 deletions src/game/client/ui/ms/vgui_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ void VGUI_ItemInfoPanel::Update(containeritem_t &Item)
m_Name->setText(Item.getFullName());

m_Quantity->setText(Localized("#ITEMINFO_QUANTITY"), Item.Quantity);
m_Quality->setText(Localized("#ITEMINFO_QUALITY"), Item.Quality);
m_Quality->setVisible(false);
//Only items with a quality have a max quality
m_Quality->setText("Quality: %i/%i", (int)Item.Quality, (int)Item.MaxQuality);
m_Quality->setVisible(Item.MaxQuality > 0);

char weight[50];
_snprintf(weight, sizeof(weight), "Weight: %.2f", Item.Weight);
Expand Down
8 changes: 8 additions & 0 deletions src/game/client/ui/ms/vgui_mscontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ void containeritem_t::init( CGenericItem *pItem )
Properties = pItem->MSProperties( );
Quantity = FBitSet( Properties, ITEM_GROUPABLE ) ? pItem->iQuantity : 1;
Quality = pItem->Quality;
MaxQuality = pItem->MaxQuality;
if( !MaxQuality && FBitSet( Properties, ITEM_DRINKABLE ) )
{
//Drinkables don't have a max quality. A new one is full
CGenericItem *pGlobalItem = CGenericItemMgr::GetGlobalGenericItemByName( pItem->ItemName, true );
if( pGlobalItem )
MaxQuality = pGlobalItem->Quality;
}
Value = pItem->m_Value;
Desc = pItem->DisplayDesc;
bForceFull = false;
Expand Down
189 changes: 98 additions & 91 deletions src/game/client/ui/ms/vgui_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,6 @@ CStoragePanel::CStoragePanel(Panel *pParent) : CStorePanel()
//Update
void CStoragePanel::AddInventoryItems()
{
//Find the storage on the player
storage_t *pStorage = NULL;
for (int s = 0; s < player.m_Storages.size(); s++)
if (player.m_Storages[s].Name == player.m_CurrentStorage.StorageName)
{
pStorage = &player.m_Storages[s];
break;
}

if (!pStorage)
{
//If the storage doesn't exist, create it real quick. This should never happen.
storage_t Storage;
Storage.Name = player.m_CurrentStorage.StorageName;
pStorage = player.Storage_CreateAccount(Storage);
}

//Add the 'storage' container
gearitem_t GearItem;
GearItem.Name = "Storage";
Expand All @@ -99,10 +82,26 @@ void CStoragePanel::AddInventoryItems()
VGUI_Inv_GearItem *pGearItemButton = m_GearPanel->AddGearItem(GearItem);

//Add the storage items
storage_t &Storage = *pStorage;
for (int i = 0; i < Storage.Items.size(); i++)
for (int i = 0; i < player.m_Storage.size(); i++)
{
containeritem_t vNewItem = containeritem_t(Storage.Items[i]);
storageitem_t &Item = player.m_Storage[i];

//Storage only knows the item's name, so the rest comes from the global item
CGenericItem *pGlobalItem = CGenericItemMgr::GetGlobalGenericItemByName(Item.Name, true);
if (!pGlobalItem)
continue;

containeritem_t vNewItem = containeritem_t(pGlobalItem);
vNewItem.ID = Item.ID;
vNewItem.Quantity = Item.Quantity;
vNewItem.Quality = Item.Quality;
if (CBasePlayer::Storage_CombinesSwigs(Item.Name.c_str(), vNewItem.Properties))
vNewItem.MaxQuality = STORAGE_MAX_SWIGS; //Shown as how full it is, instead of against one potion
else if (Item.MaxQuality)
vNewItem.MaxQuality = Item.MaxQuality;
if (Item.Quantity > 1)
vNewItem.setFullName(msstring() + (int)Item.Quantity + " " + pGlobalItem->DisplayName() + "s"); //Named the way SPEECH::ItemName does

pGearItemButton->m_ItemContainer->AddItem(vNewItem);
}

Expand All @@ -111,6 +110,7 @@ void CStoragePanel::AddInventoryItems()

return;
}

void CStoragePanel::Update()
{
if (!player.m_CurrentStorage.Active)
Expand All @@ -122,7 +122,7 @@ void CStoragePanel::Update()

CStorePanel::Update();

m_pTitle->setText(player.m_CurrentStorage.DisplayName);
m_pTitle->setText(player.m_CurrentStorage.DisplayName + " (" + player.Storage_ItemCount() + "/" + player.Storage_MaxItems() + ")");
}

void CStoragePanel::GearItemSelected(ulong ID)
Expand Down Expand Up @@ -168,7 +168,7 @@ bool CStoragePanel::GearItemClicked(ulong ID)

for (int i = 0; i < m_SelectedItems.size(); i++)
{
if (checkValid(m_SelectedItems[i])) //Check it against the bank mask (MiB Feb2008a)
if (!AddOrRemove || checkValid(m_SelectedItems[i])) //Check it against the bank mask (MiB Feb2008a)
{
//Send the command
if (AddOrRemove)
Expand All @@ -185,55 +185,38 @@ bool CStoragePanel::GearItemClicked(ulong ID)
return true;
}

//MiB FEB2008a
bool CStoragePanel::checkValid(containeritem_t &item)
void CStoragePanel::ItemDoubleclicked(ulong ID)
{
msstring name = item.Name;
if (name.starts_with("pack_"))
return false;
if (name.starts_with("sheath_"))
return false;
if (name.starts_with("mana_"))
return false;
if (name.starts_with("health_"))
return false;
if (name.starts_with("proj_"))
return false;
//Double clicking an item in storage takes it out and puts it in my hands
if (m_LastGearItem != 1)
return;

return true;
UnSelectAllItems();
m_InfoPanel->setVisible(false);

msstring Command = msstring("storage remove ") + (int)ID + " hands\n";
gEngfuncs.pfnClientCmd(Command);
}

//Item selected
int CStoragePanel::ItemRetrievalCost(containeritem_t &Item)
bool CStoragePanel::ItemClicked(void *pData)
{
//Only so many items can be moved at once, so don't let more than that be selected
VGUI_ItemButton &ItemButton = *(VGUI_ItemButton *)pData;
return !ItemButton.m_Selected && (int)m_SelectedItems.size() >= STORAGE_MAX_TRANSFER;
}

//MiB FEB2008a
bool CStoragePanel::checkValid(containeritem_t &item)
{
return int(Item.Value * player.m_CurrentStorage.flFeeRatio);
//The server checks this too
return CBasePlayer::Storage_CanStoreItem(item.Name.c_str(), item.Properties);
}

void CStoragePanel::ItemHighlighted(void *pData)
{
CStorePanel::ItemHighlighted(pData);

if (m_LastGearItem != 1)
{
m_InfoPanel->m_SaleText->setVisible(false);
m_InfoPanel->setVisible(true);
return;
}

VGUI_ItemButton &ItemButton = *(VGUI_ItemButton *)pData;
if (ItemButton.m_Highlighted)
{
int Value = ItemRetrievalCost(ItemButton.m_Data);
if (Value)
{
char cTemp[256];
_snprintf(cTemp, sizeof(cTemp), Localized("#STORAGE_ITEM_COST"), Value );
m_InfoPanel->m_SaleText->setText(cTemp);
}
else
m_InfoPanel->m_SaleText->setText(Localized("#STORAGE_ITEM_FREE"));
m_InfoPanel->m_SaleText->setVisible(true);
}
m_InfoPanel->m_Scroll->validate();
m_InfoPanel->m_SaleText->setVisible(false);
m_InfoPanel->setVisible(true);
}

Expand All @@ -244,8 +227,6 @@ void CStoragePanel::ItemSelectChanged(ulong ID, bool fSelected)

m_SaleLabel->setVisible(true);

int Valuetotal = 0;

for (int g = 0; g < m_GearPanel->GearItemButtonTotal; g++)
{
VGUI_Inv_GearItem &GearItem = *m_GearPanel->GearItemButtons[g];
Expand All @@ -256,18 +237,21 @@ void CStoragePanel::ItemSelectChanged(ulong ID, bool fSelected)
continue;

m_SelectedItems.add(ItemButton.m_Data);

if (m_LastGearItem == 1)
Valuetotal += ItemRetrievalCost(ItemButton.m_Data);
}
}

if (m_SelectedItems.size())
{
msstring Text;
if (m_LastGearItem == 1)
m_SaleLabel->setText(msstring("Removing ") + (int)m_SelectedItems.size() + " items from storage for " + Valuetotal + " gold");
Text = msstring("Removing ") + (int)m_SelectedItems.size() + " items from storage";
else
m_SaleLabel->setText(msstring("Moving ") + (int)m_SelectedItems.size() + " items into storage");
Text = msstring("Moving ") + (int)m_SelectedItems.size() + " items into storage";

if ((int)m_SelectedItems.size() >= STORAGE_MAX_TRANSFER)
Text += " (max)";

m_SaleLabel->setText(Text);
m_SaleLabel->setVisible(true);
}
else
Expand Down Expand Up @@ -311,48 +295,71 @@ void Storage_Update()
//Item msg
void Storage_ItemReset()
{
player.m_Storages.clear();
player.m_Storage.clear();
Storage_Update();
}

void Storage_ItemMsg()
{
msstring StorageName = READ_STRING();
storage_t *pStorage = NULL;
int Count = READ_BYTE();
for (int i = 0; i < Count; i++)
{
storageitem_t Item;
Item.ID = READ_LONG();
int idx = READ_LONG();
Item.Quantity = READ_SHORT();
Item.Quality = READ_SHORT();
Item.MaxQuality = READ_SHORT();

if (idx < 0 || idx >= CGenericItemMgr::ItemCount())
continue;

Item.Name = CGenericItemMgr::Item(idx)->Name;
player.m_Storage.push_back(Item);
}

for (int s = 0; s < player.m_Storages.size(); s++)
if (player.m_Storages[s].Name == StorageName)
Storage_Update();
}

void Storage_ItemRemoveMsg()
{
ulong ID = READ_LONG();
for (int i = 0; i < player.m_Storage.size(); i++)
if (player.m_Storage[i].ID == ID)
{
pStorage = &player.m_Storages[s];
player.m_Storage.erase(player.m_Storage.begin() + i);
break;
}

if (!pStorage)
{
storage_t Storage;
Storage.Name = StorageName;
pStorage = player.Storage_CreateAccount(Storage);
}
Storage_Update();
}

bool AddItem = READ_BYTE() ? true : false;
void Storage_ItemUpdateMsg()
{
ulong ID = READ_LONG();
int Quantity = READ_SHORT();
int Quality = READ_SHORT();
for (int i = 0; i < player.m_Storage.size(); i++)
if (player.m_Storage[i].ID == ID)
{
player.m_Storage[i].Quantity = Quantity;
player.m_Storage[i].Quality = Quality;
break;
}

if (AddItem)
{
CGenericItem *pItem = ReadGenericItem(true);
if (pItem)
pStorage->Items.add(genericitem_full_t(pItem));
Storage_Update();
}

pItem->SUB_Remove();
}
void Storage_MaxMsg()
{
player.m_StorageMax = READ_SHORT();

Storage_Update();
}

void Storage_Show(const char* DisplayName, const char* StorageName, float flFeeRatio)
void Storage_Show(const char* DisplayName)
{
player.m_CurrentStorage.Active = true;
player.m_CurrentStorage.DisplayName = DisplayName;
player.m_CurrentStorage.StorageName = StorageName;
player.m_CurrentStorage.flFeeRatio = flFeeRatio;
ShowVGUIMenu(MENU_STORAGE);
}
3 changes: 2 additions & 1 deletion src/game/client/ui/ms/vgui_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ class CStoragePanel : public CStorePanel
void AddInventoryItems();
void Update();
void Close();
int ItemRetrievalCost(containeritem_t &Item);

//Item callbacks
void ItemSelectChanged(ulong ID, bool fSelected);
void ItemHighlighted(void *pData);
void GearItemSelected(ulong ID);
bool GearItemClicked(ulong ID);
void ItemDoubleclicked(ulong ID);
bool ItemClicked(void *pData);
bool checkValid(containeritem_t &Item); //MiB Feb2008a

static const char* Text_Subtitle_Storage;
Expand Down
12 changes: 12 additions & 0 deletions src/game/client/ui/ms/vgui_storemainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ void MsgFunc_Store()
void Update_StoreBuy();
void Storage_ItemReset();
void Storage_ItemMsg();
void Storage_ItemRemoveMsg();
void Storage_ItemUpdateMsg();
void Storage_MaxMsg();

int __MsgFunc_StoreItem(const char *pszName, int iSize, void *pbuf)
{
Expand Down Expand Up @@ -143,6 +146,15 @@ int __MsgFunc_StoreItem(const char *pszName, int iSize, void *pbuf)
case 2:
Storage_ItemMsg();
break;
case 3:
Storage_ItemRemoveMsg();
break;
case 4:
Storage_ItemUpdateMsg();
break;
case 5:
Storage_MaxMsg();
break;
}
return 0;
}
2 changes: 1 addition & 1 deletion src/game/client/ui/vgui_teamfortressviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ CMenuPanel *TeamFortressViewport::ShowStoreMenu(int iStoreType)
return NULL;

//Special circumstance: inventory items for packs not being held (STORE_INV)
if (CStorePanel::iStoreBuyFlags & STORE_INV)
if (iStoreType != MENU_STORAGE && (CStorePanel::iStoreBuyFlags & STORE_INV))
iStoreType = MENU_STOREBUY;

switch (iStoreType)
Expand Down
Loading
Loading