MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / UpdateWeight

Method UpdateWeight

ogsr_engine/xrGame/ui/UIInventoryUtilities.cpp:293–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291//////////////////////////////////////////////////////////////////////////
292
293void InventoryUtilities::UpdateWeight(CUIStatic& wnd, bool withPrefix)
294{
295 CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(Level().CurrentEntity());
296 R_ASSERT(pInvOwner);
297 string128 buf{};
298
299 float total = pInvOwner->inventory().CalcTotalWeight();
300 float max = pInvOwner->MaxCarryWeight();
301
302 string16 cl{};
303
304 if (total > max)
305 {
306 strcpy_s(cl, "%c[red]");
307 }
308 else
309 {
310 strcpy_s(cl, "%c[UI_orange]");
311 }
312
313 string32 prefix{};
314
315 if (withPrefix)
316 {
317 sprintf_s(prefix, "%%c[default]%s ", *CStringTable().translate("ui_inv_weight"));
318 }
319 else
320 {
321 strcpy_s(prefix, "");
322 }
323
324 sprintf_s(buf, "%s%s%3.1f %s/%5.1f", prefix, cl, total, "%c[UI_orange]", max);
325 wnd.SetText(buf);
326 // UIStaticWeight.ClipperOff();
327}
328
329//////////////////////////////////////////////////////////////////////////
330

Callers

nothing calls this directly

Calls 5

CStringTableClass · 0.85
CalcTotalWeightMethod · 0.80
MaxCarryWeightMethod · 0.80
translateMethod · 0.45
SetTextMethod · 0.45

Tested by

no test coverage detected