| | 1 | | using DCL.SettingsPanelHUD.Controls; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL.SettingsPanelHUD.Widgets |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Interface to implement a controller for a WIDGET. |
| | 10 | | /// </summary> |
| | 11 | | public interface ISettingsWidgetController |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// List of all CONTROLS added to the WIDGET. |
| | 15 | | /// </summary> |
| | 16 | | List<ISettingsControlView> controls { get; } |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Adds a CONTROL into the WIDGET. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="newControl">New CONTROL that will be added.</param> |
| | 22 | | /// <param name="newControlController">Controller belonging to the new CONTROL.</param> |
| | 23 | | /// <param name="controlConfig">Model that will contain the configuration of the new CONTROL.</param> |
| | 24 | | void AddControl(ISettingsControlView newControl, SettingsControlController newControlController, SettingsControl |
| | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// This controller is in charge of manage all the logic related to a WIDGET. |
| | 29 | | /// </summary> |
| | 30 | | [CreateAssetMenu(menuName = "Settings/Controllers/Widget", fileName = "SettingsWidgetController")] |
| | 31 | | public class SettingsWidgetController : ScriptableObject, ISettingsWidgetController |
| | 32 | | { |
| 8 | 33 | | public List<ISettingsControlView> controls { get; } = new List<ISettingsControlView>(); |
| | 34 | |
|
| | 35 | | public void AddControl( |
| | 36 | | ISettingsControlView newControl, |
| | 37 | | SettingsControlController newControlController, |
| | 38 | | SettingsControlModel controlConfig) |
| | 39 | | { |
| 34 | 40 | | newControl.Initialize(controlConfig, newControlController); |
| 34 | 41 | | controls.Add(newControl); |
| 34 | 42 | | SettingsPanelDataStore.i.controls.controlControllers.Add(newControlController); |
| 34 | 43 | | } |
| | 44 | | } |
| | 45 | | } |