From 6ac9a6b3e3e5fe8958646a18c6e81a25aa5bb326 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 8 Mar 2011 22:19:17 +0200 Subject: Show item colors in buy dialog. --- src/shopitem.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'src/shopitem.cpp') diff --git a/src/shopitem.cpp b/src/shopitem.cpp index 861d03bdc..a87c1f3f9 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -22,6 +22,7 @@ #include "shopitem.h" +#include "client.h" #include "units.h" #include "utils/stringutils.h" @@ -34,8 +35,16 @@ ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color, mPrice(price), mShowQuantity(true) { - mDisplayName = getInfo().getName() + " (" - + Units::formatCurrency(mPrice).c_str() + ") "; + if (serverVersion > 0) + { + mDisplayName = getInfo().getName(color) + " (" + + Units::formatCurrency(mPrice).c_str() + ") "; + } + else + { + mDisplayName = getInfo().getName() + " (" + + Units::formatCurrency(mPrice).c_str() + ") "; + } if (quantity > 0) mDisplayName += "[" + toString(quantity) + "]"; @@ -48,8 +57,16 @@ ShopItem::ShopItem (int id, unsigned char color, int price) : mPrice(price), mShowQuantity(false) { - mDisplayName = getInfo().getName() + - " (" + Units::formatCurrency(mPrice).c_str() + ")"; + if (serverVersion > 0) + { + mDisplayName = getInfo().getName(color) + + " (" + Units::formatCurrency(mPrice).c_str() + ")"; + } + else + { + mDisplayName = getInfo().getName() + + " (" + Units::formatCurrency(mPrice).c_str() + ")"; + } setInvIndex(-1); addDuplicate(-1, 0); } @@ -68,8 +85,16 @@ void ShopItem::update() { if (mShowQuantity) { - mDisplayName = getInfo().getName() + " (" - + Units::formatCurrency(mPrice).c_str() + ") "; + if (serverVersion > 0) + { + mDisplayName = getInfo().getName(mColor) + " (" + + Units::formatCurrency(mPrice).c_str() + ") "; + } + else + { + mDisplayName = getInfo().getName() + " (" + + Units::formatCurrency(mPrice).c_str() + ") "; + } if (mQuantity > 0) mDisplayName += "[" + toString(mQuantity) + "]"; } -- cgit v1.2.3-60-g2f50