void catsubpanel_eventClick(UIComponent component, UIMouseEventParameter eventParam) { bool isCatActive = !CSLStatsPanelConfigSettings.isCatActive(component.name); CSLStatsPanelConfigSettings.setCatActive(component.name, isCatActive); CSLStatsPanelConfigSettings.m_ConfigChanged.value = true; UIButton b = (UIButton)component; b.textColor = (isCatActive) ? selectedcolor : deselectedcolor; b.focusedColor = (isCatActive) ? selectedcolor : deselectedcolor; b.parent.Focus(); component.color = (isCatActive) ? selectedcolor : deselectedcolor; component.parent.color = component.color; }
UIPanel drawstatsconfigpanel(StatisticsCategoryWrapper scw) { UIPanel catsubpanel = this.AddUIComponent <UIPanel>(); catpanels.Add(catsubpanel); catsubpanel.autoLayout = true; catsubpanel.wrapLayout = true; catsubpanel.autoLayoutDirection = LayoutDirection.Horizontal; catsubpanel.width = this.width - 5; catsubpanel.backgroundSprite = "GenericPanel"; //catsubpanel.height = 15; catsubpanel.autoLayoutPadding = new RectOffset(3, 3, 3, 3); bool catisChecked = CSLStatsPanelConfigSettings.isCatActive(scw.m_category); UIButton catname = catsubpanel.AddUIComponent <UIButton>(); catname.textColor = (catisChecked) ? selectedcolor : deselectedcolor; setcommonbuttonprops(catname); catname.autoSize = true; catname.text = scw.m_category; catname.name = scw.m_category; catsubpanel.color = (catisChecked) ? selectedcolor : deselectedcolor; catsubpanel.autoSize = true; catname.eventClick += new MouseEventHandler(catsubpanel_eventClick); for (int x = 0; x < scw.m_scwlist.Count(); x++) { bool isStatActive = CSLStatsPanelConfigSettings.isStatActive(scw.m_category, scw.m_scwlist[x].m_desc); UIButton statname = catsubpanel.AddUIComponent <UIButton>(); statname.name = scw.m_category + "|" + scw.m_scwlist[x].m_desc; statname.color = (isStatActive) ? selectedcolor : deselectedcolor; statname.textColor = (isStatActive) ? selectedcolor : deselectedcolor; setcommonbuttonprops(statname); statname.text = scw.m_scwlist[x].m_desc; statname.eventClick += new MouseEventHandler(statsubpanel_eventClick); } catsubpanel.FitChildrenVertically(); return(catsubpanel); }