-
Notifications
You must be signed in to change notification settings - Fork 6
/
UIChartPanel.cs
75 lines (62 loc) · 2.52 KB
/
UIChartPanel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using ColossalFramework.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace CS_EmploymentDetailsExtender
{
class UIChartPanel : UIPanel
{
private UIRadialChart[] m_RadialChart = new UIRadialChart[4];
private static readonly Vector2 chartSize = new Vector2(112, 112);
private static readonly int chartPadding = 5;
private static readonly int chartSeparator = 10;
public static readonly Vector2 panelSize = new Vector2(chartPadding * 2 + chartSeparator + chartSize.x * 2, chartPadding * 2 + chartSeparator + chartSize.y * 2);
public override void Start()
{
base.Start();
//backgroundSprite = "InfoviewPanel"; //White Bakground
isVisible = true;
canFocus = true;
isInteractive = true;
width = panelSize.x;
height = panelSize.y;
for (int i = 0; i < m_RadialChart.Length; i++)
{
m_RadialChart[i] = CreateRadialChart(i);
}
}
private UIRadialChart CreateRadialChart(int level)
{
UIRadialChart rc = AddUIComponent<UIRadialChart>();
rc.isEnabled = true;
rc.isVisible = true;
rc.name = "EmploymentChartLevel" + level;
rc.size = chartSize;
rc.relativePosition = new Vector2(chartPadding + (level % 2 * (rc.size.x + chartSeparator)), chartPadding + (level / 2 * (rc.size.y + chartSeparator)));
rc.zOrder = 2;
rc.spriteName = "PieChartWhiteBg";
rc.AddSlice();
UIRadialChart.SliceSettings slice0 = rc.GetSlice(0);
Color32 color = JobsUtils.educationLevelColors[level];
slice0.outterColor = color;
slice0.innerColor = color;
rc.AddSlice();
UIRadialChart.SliceSettings slice1 = rc.GetSlice(1);
Color32 color2 = new Color32(132, 110, 110, 255);
slice1.outterColor = color2;
slice1.innerColor = color2;
return rc;
}
public override void Update()
{
if (isVisible && isEnabled)
{
for (int i = 0; i < m_RadialChart.Length; i++)
{
float percent = JobsUtils.GetPercentEmployedF(i);
m_RadialChart[i].SetValues(new float[] { percent, 1f - percent });
}
}
}
}
}