Game.UI.InGame.InfoviewsUIUtils
Assembly: Assembly-CSharp
Namespace: Game.UI.InGame
Type: public class
Base: System.Object
Summary:
Utility class containing helper methods to serialize pie-chart data expected by the in-game infoviews UI. The primary helper formats five integer slice values into a JSON object of type "infoviews.ChartData" with a "values" array and a "total" property. Intended for use with Colossal.UI.Binding.IJsonWriter when updating chart data for UI components.
Fields
- This class declares no fields.
{{ This is a stateless utility class — it contains only static behavior and holds no instance data. }}
Properties
- This class declares no properties.
{{ No configurable properties; the class exposes only static helper methods. }}
Constructors
public InfoviewsUIUtils()
{{ The default parameterless constructor is implicit. This class is used as a static utility container — you typically do not need to instantiate it. }}
Methods
public static void UpdateFiveSlicePieChartData(Colossal.UI.Binding.IJsonWriter binder, int a, int b, int c, int d, int e)
{{ Serializes five integer slice values into the binder as an object of type "infoviews.ChartData". The method writes a "values" array containing the five integers (in the order a, b, c, d, e) and a "total" property containing their sum. Expected binder call sequence: TypeBegin("infoviews.ChartData") PropertyName("values") ArrayBegin(5u) Write(a), Write(b), Write(c), Write(d), Write(e) ArrayEnd() PropertyName("total") Write(sum) TypeEnd() Notes:- binder must be non-null; the method does not perform null checks.
- Input values are written as provided (no validation for negatives).
- Designed to match the infoviews chart data format used by the game's UI. }}
Usage Example
// Assume 'binder' is an IJsonWriter you obtained from the UI binding context
// Example: five slice values for a pie chart
Colossal.UI.Binding.IJsonWriter binder = /* obtain binder from UI binding context */;
InfoviewsUIUtils.UpdateFiveSlicePieChartData(binder, 10, 20, 30, 25, 15);
{{ Additional tip: If you call this from code that may run frequently, reuse or obtain the appropriate IJsonWriter instance from the UI binding system rather than creating new writer objects repeatedly. Ensure the caller handles binder lifecycle and threading rules required by the UI framework. }}