Skip to content

Commit b8c4650

Browse files
committed
Add show_in_history property for hud inventory items
1 parent bdb76cd commit b8c4650

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

cl_dll/hud_inventory.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const char hudInventorySchema[] = R"(
4343
"position": {
4444
"type": "string",
4545
"pattern": "^topleft|status|bottom|topright|hide$"
46+
},
47+
"show_in_history": {
48+
"type": "boolean"
4649
}
4750
}
4851
}
@@ -51,7 +54,7 @@ const char hudInventorySchema[] = R"(
5154
}
5255
)";
5356

54-
InventoryItemHudSpec::InventoryItemHudSpec(): packedColor(0), alpha(0), position(INVENTORY_PLACE_DEFAULT), colorDefined(false)
57+
InventoryItemHudSpec::InventoryItemHudSpec(): packedColor(0), alpha(0), position(INVENTORY_PLACE_DEFAULT), colorDefined(false), showInHistory(true)
5558
{
5659
itemName[0] = '\0';
5760
spriteName[0] = '\0';
@@ -104,6 +107,7 @@ bool InventoryHudSpec::ReadFromFile(const char *fileName)
104107
item.colorDefined = ParseColor(colorIt->value.GetString(), item.packedColor);
105108
}
106109
UpdatePropertyFromJson(item.alpha, value, "alpha");
110+
UpdatePropertyFromJson(item.showInHistory, value, "show_in_history");
107111
auto positionIt = value.FindMember("position");
108112
if (positionIt != value.MemberEnd())
109113
{

cl_dll/hud_inventory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct InventoryItemHudSpec
2222
int alpha;
2323
int position;
2424
bool colorDefined;
25+
bool showInHistory;
2526
};
2627

2728
class InventoryHudSpec

cl_dll/status_icons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ int CHudStatusIcons::MsgFunc_Inventory(const char *pszName, int iSize, void *pbu
333333
item.rc = gHUD.GetSpriteRect( spr_index );
334334
m_iFlags |= HUD_ACTIVE;
335335

336-
if (countDiff >= 1)
336+
if (countDiff >= 1 && (!itemSpec || itemSpec->showInHistory))
337337
gHR.AddToHistory(HISTSLOT_ITEM, spriteName, countDiff, itemSpec ? itemSpec->packedColor : 0);
338338

339339
return 1;

game_shared/json_utils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ bool UpdatePropertyFromJson(float& f, Value& jsonValue, const char* key)
116116
return false;
117117
}
118118

119+
bool UpdatePropertyFromJson(bool& b, Value& jsonValue, const char* key)
120+
{
121+
auto it = jsonValue.FindMember(key);
122+
if (it != jsonValue.MemberEnd())
123+
{
124+
b = it->value.GetBool();
125+
return true;
126+
}
127+
return false;
128+
}
129+
119130
bool UpdatePropertyFromJson(Color& color, Value& jsonValue, const char* key)
120131
{
121132
auto it = jsonValue.FindMember(key);

game_shared/json_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bool ReadJsonDocumentWithSchema(rapidjson::Document& document, const char* pMemF
1212
bool UpdatePropertyFromJson(std::string& str, rapidjson::Value& jsonValue, const char* key);
1313
bool UpdatePropertyFromJson(int& i, rapidjson::Value& jsonValue, const char* key);
1414
bool UpdatePropertyFromJson(float& f, rapidjson::Value& jsonValue, const char* key);
15+
bool UpdatePropertyFromJson(bool& b, rapidjson::Value& jsonValue, const char* key);
1516
bool UpdatePropertyFromJson(Color& color, rapidjson::Value& jsonValue, const char* key);
1617
bool UpdatePropertyFromJson(FloatRange& floatRange, rapidjson::Value& jsonValue, const char* key);
1718
bool UpdatePropertyFromJson(IntRange& intRange, rapidjson::Value& jsonValue, const char* key);

0 commit comments

Comments
 (0)