// Recalculate buttons. void ServiceAddedOrRemoved(HEROsModService modifiedService) { // Clear existing icons in the Hotbar _iconView.RemoveAllChildren(); // For each service, add its icon to the hotbar float xPos = Spacing; for (int i = 0; i < HEROsMod.ServiceController.Services.Count; i++) { HEROsModService service = HEROsMod.ServiceController.Services[i]; if (service.HotbarIcon == null || !service.HasPermissionToUse) { continue; } if (service.IsHotbar) { service.Hotbar.buttonView.RemoveAllChildren(); service.Hotbar.test(); } if (service.IsInHotbar /* && service.HotbarParent.buttonView != null*/) { //ErrorLogger.Log("adding " + service.Name); //ErrorLogger.Log("adding 1" + service.HotbarParent.ChildCount); //ErrorLogger.Log("adding 3" + service.HotbarParent.buttonView.ChildCount); UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon; //icon.Anchor = AnchorPosition.Left; //icon.X = xPos; //icon.Y = 0; //xPos += icon.Width + Spacing; service.HotbarParent.buttonView.AddChild(icon); //_iconView.AddChild(icon); //icon.CenterYAxisToParentCenter(); service.HotbarParent.test(); //ModUtils.DebugText("added " + service.Name); } else { UIImage icon = HEROsMod.ServiceController.Services[i].HotbarIcon; icon.Anchor = AnchorPosition.Left; icon.X = xPos; icon.Y = 0; xPos += icon.Width + Spacing; _iconView.AddChild(icon); icon.CenterYAxisToParentCenter(); } } if (_iconView.ChildCount > 0) { this.Width = _iconView.GetLastChild().X + _iconView.GetLastChild().Width + Spacing; _iconView.Width = this.Width; } collapseButton.CenterXAxisToParentCenter(); collapseArrow.Position = collapseButton.Position; }
/// <summary> /// Remove a HEROsModService from the ServiceController /// </summary> /// <param name="service">Service to Remove</param> public void RemoveService(HEROsModService service) { service.Destroy(); _services.Remove(service); ServiceRemoved?.Invoke(service); }
/// <summary> /// Add a HEROsModService to the ServiceController /// </summary> /// <param name="service">Service to add</param> public void AddService(HEROsModService service) { _services.Add(service); ServiceAdded?.Invoke(service); }