From 561296f2699bcfff93d22b8a67182308998cfb31 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 13 Jul 2015 18:15:37 -0600 Subject: Leather Armor can now be dyed. * Created new color class to handle dye-related coloring --- src/Item.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Item.cpp') diff --git a/src/Item.cpp b/src/Item.cpp index 36c444328..7bd344ae8 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -142,6 +142,13 @@ void cItem::GetJson(Json::Value & a_OutValue) const a_OutValue["Lore"] = m_Lore; } + if (m_ItemColor.IsValid()) + { + a_OutValue["Color_Red"] = m_ItemColor.GetRed(); + a_OutValue["Color_Green"] = m_ItemColor.GetGreen(); + a_OutValue["Color_Blue"] = m_ItemColor.GetBlue(); + } + if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR)) { a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker; @@ -172,6 +179,18 @@ void cItem::FromJson(const Json::Value & a_Value) m_CustomName = a_Value.get("Name", "").asString(); m_Lore = a_Value.get("Lore", "").asString(); + int red = a_Value.get("Color_Red", -1).asInt(); + int green = a_Value.get("Color_Green", -1).asInt(); + int blue = a_Value.get("Color_Blue", -1).asInt(); + if ((red > -1) && (red < static_cast(cColor::COLOR_LIMIT)) && (green > -1) && (green < static_cast(cColor::COLOR_LIMIT)) && (blue > -1) && (blue < static_cast(cColor::COLOR_LIMIT))) + { + m_ItemColor.SetColor(static_cast(red), static_cast(green), static_cast(blue)); + } + else if ((red != -1) || (blue != -1) || (green != -1)) + { + LOGWARNING("Item with invalid red, green, and blue values read in from json file."); + } + if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR)) { m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool(); -- cgit v1.2.3