public void AddSection(
            SettingsButtonEntry newMenuButton,
            ISettingsSectionView newSection,
            ISettingsSectionController newSectionController,
            SettingsSectionModel sectionConfig)
        {
            newMenuButton?.Initialize(sectionConfig.icon, sectionConfig.text);

            newSection.Initialize(newSectionController, sectionConfig.widgets.ToList());
            newSection.SetActive(false);
            sections.Add(newSection);

            newMenuButton?.ConfigureAction(() =>
            {
                foreach (var button in menuButtons)
                {
                    button.MarkAsSelected(false);
                }
                newMenuButton.MarkAsSelected(true);

                OpenSection(newSection);
            });

            menuButtons.Add(newMenuButton);
        }
예제 #2
0
        public IEnumerator GenerateSectionsIntoThePanelViewCorrectly()
        {
            // Arrange
            SettingsSectionView sectionViewPrefab = ((GameObject)Resources.Load(SECTION_VIEW_PREFAB_PATH)).GetComponent <SettingsSectionView>();
            SettingsButtonEntry menuButtonPrefab  = ((GameObject)Resources.Load(MENU_BUTTON_PREFAB_PATH)).GetComponent <SettingsButtonEntry>();

            SettingsSectionModel newSectionConfig = ScriptableObject.CreateInstance <SettingsSectionModel>();

            newSectionConfig.icon              = Sprite.Create(new Texture2D(10, 10), new Rect(), new Vector2());
            newSectionConfig.text              = "TestSection";
            newSectionConfig.menuButtonPrefab  = menuButtonPrefab;
            newSectionConfig.sectionPrefab     = sectionViewPrefab;
            newSectionConfig.sectionController = ScriptableObject.CreateInstance <SettingsSectionController>();
            newSectionConfig.widgets           = new SettingsWidgetList();

            sectionsToCreate.Add(newSectionConfig);

            // Act
            panelView.Initialize(hudController, panelController, sectionsToCreate);
            yield return(null);

            // Assert
            panelController.Received(1)
            .AddSection(
                Arg.Any <SettingsButtonEntry>(),
                Arg.Any <ISettingsSectionView>(),
                Arg.Any <ISettingsSectionController>(),
                Arg.Any <SettingsSectionModel>());

            panelController.Received(1).OpenSection(0);
            panelController.Received(1).MarkMenuButtonAsSelected(0);
        }
예제 #3
0
 private static void AddSection(CreateSettingsModel bundlesModel, SettingsSectionModel section)
 {
     bundlesModel.Sections.Add(section);
     if (bundlesModel.SelectedSection.Value == null)
     {
         bundlesModel.SelectedSection.Value = section;
     }
 }
 public void SetUp()
 {
     panelController                    = new SettingsPanelHUDController();
     newSectionView                     = Substitute.For <ISettingsSectionView>();
     newSectionController               = Substitute.For <ISettingsSectionController>();
     testSprite                         = Sprite.Create(new Texture2D(10, 10), new Rect(), new Vector2());
     newSectionConfig                   = ScriptableObject.CreateInstance <SettingsSectionModel>();
     newSectionConfig.icon              = testSprite;
     newSectionConfig.text              = "TestSection";
     newSectionConfig.menuButtonPrefab  = new GameObject().AddComponent <SettingsButtonEntry>();
     newSectionConfig.sectionPrefab     = new GameObject().AddComponent <SettingsSectionView>();
     newSectionConfig.sectionController = ScriptableObject.CreateInstance <SettingsSectionController>();
     newSectionConfig.widgets           = new SettingsWidgetList();
 }
        public IDisposable BindSections()
        {
            var sections = new SettingsSectionModel[]
            {
                new LicenseSectionModel()
            };

            return(sections.ToObservable()
                   .ToList()
                   .SubscribeWithLog(list =>
            {
                _model.Sections.Clear();
                _model.Sections.AddRange(list);

                _model.SelectedSection = _model.Sections.FirstOrDefault();
            }));
        }