private void CreateEaseToggles()
		{
			Toggle.ToggleEvent toggleEvent = new Toggle.ToggleEvent();
			toggleEvent.AddListener(new UnityEngine.Events.UnityAction<bool>(OnValueChanged));

			ToggleGroup toggleGroup = EaseTogglesRoot.GetComponent<ToggleGroup>();
			foreach(string easeName in Enum.GetNames(typeof(Ease)))
			{
				RectTransform easeToggle = Instantiate(EaseTogglePrefab);
				easeToggle.SetParent(EaseTogglesRoot);
				easeToggle.name = easeName;
				easeToggle.localScale = Vector3.one;
				easeToggle.GetComponentInChildren<Text>().text = easeName;
				Toggle toggle = easeToggle.GetComponent<Toggle>();
				toggle.group = toggleGroup;
				toggle.onValueChanged = toggleEvent;
				_easeToggles.Add(toggle);
			}
			toggleGroup.SetAllTogglesOff();
			_easeToggles[0].isOn = true;
		}
        private void Init()
        {
            Lib.Log("Science Archive init started");

            window = new KsmGuiWindow(
                KsmGuiWindow.LayoutGroupType.Vertical,
                false,
                1f,
                true,
                0,
                TextAnchor.UpperLeft,
                5f,
                TextAnchor.UpperLeft,
                TextAnchor.UpperLeft,
                280, -100);

            KsmGuiHeader mainHeader = new KsmGuiHeader(window, Local.SCIENCEARCHIVE_title);            //"SCIENCE ARCHIVE"

            new KsmGuiIconButton(mainHeader, Textures.KsmGuiTexHeaderClose, () => Close());

            KsmGuiHorizontalLayout columns = new KsmGuiHorizontalLayout(window, 5, 0, 0, 5, 0);

            KsmGuiVerticalLayout experimentColumn = new KsmGuiVerticalLayout(columns, 5);

            experimentColumn.SetLayoutElement(false, true, 160);
            new KsmGuiHeader(experimentColumn, Local.SCIENCEARCHIVE_EXPERIMENTS);                                              //"EXPERIMENTS"

            researchFilter = new KsmGuiToggle(experimentColumn, Local.SCIENCEARCHIVE_filter1, true, OnToggleResearchedFilter); //"filter by researched"
            if (Kerbalism.SerenityEnabled)
            {
                ROCFilter = new KsmGuiToggle(experimentColumn, Local.SCIENCEARCHIVE_filter2, true, OnToggleROCFilter);               //"filter ROCs"
            }
            vesselFilter = new KsmGuiToggle(experimentColumn, Local.SCIENCEARCHIVE_filter3, false, OnToggleVesselFilter);            //"filter by current vessel"

            KsmGuiVerticalScrollView experimentsScrollView = new KsmGuiVerticalScrollView(experimentColumn, 0, 0, 0, 0, 0);

            experimentsScrollView.SetLayoutElement(true, true, 160);
            experimentsToggleList = new KsmGuiToggleList <ExpInfoAndSubjects>(experimentsScrollView, OnToggleExperiment);

            foreach (ExperimentInfo expInfo in ScienceDB.ExperimentInfos.OrderBy(p => p.Title))
            {
                ExperimentSubjectList experimentSubjectList = new ExperimentSubjectList(columns, expInfo);
                experimentSubjectList.Enabled = false;
                ExpInfoAndSubjects expInfoPlus = new ExpInfoAndSubjects(expInfo, experimentSubjectList);
                new KsmGuiToggleListElement <ExpInfoAndSubjects>(experimentsToggleList, expInfoPlus, expInfo.Title);
            }

            Toggle.ToggleEvent temp = experimentsToggleList.ChildToggles[0].ToggleComponent.onValueChanged;
            experimentsToggleList.ChildToggles[0].ToggleComponent.onValueChanged = new Toggle.ToggleEvent();
            experimentsToggleList.ChildToggles[0].ToggleComponent.isOn           = true;
            experimentsToggleList.ChildToggles[0].ToggleComponent.onValueChanged = temp;

            currentExperiment = experimentsToggleList.ChildToggles[0].ToggleId;
            currentExperiment.experimentSubjectList.Enabled = true;

            KsmGuiVerticalLayout expInfoColumn = new KsmGuiVerticalLayout(columns, 5);

            new KsmGuiHeader(expInfoColumn, Local.SCIENCEARCHIVE_EXPERIMENTINFO);            //"EXPERIMENT INFO"
            KsmGuiVerticalScrollView expInfoScrollView = new KsmGuiVerticalScrollView(expInfoColumn);

            expInfoScrollView.SetLayoutElement(false, true, 200);
            expInfoText = new KsmGuiText(expInfoScrollView, currentExperiment.expInfo.ModuleInfo);
            expInfoText.SetLayoutElement(true, true);

            foreach (ExperimentInfo experimentInfo in ScienceDB.ExperimentInfos)
            {
                if (experimentInfo.IsROC)
                {
                    ROCExpInfos.Add(experimentInfo);
                }
            }

            window.SetUpdateAction(Update, 20);

            Callbacks.onConfigure.Add(OnConfigure);

            //window.RebuildLayout();
            window.Close();
            Lib.Log("Science Archive init done");
        }
 public static void AddListener(this Toggle.ToggleEvent submitEvent, Function funcToExecute)
 {
     submitEvent.AddListener(new Action <bool>((b) => { funcToExecute(b); }));
 }
Exemple #4
0
 public static void Add(this Toggle.ToggleEvent buttonClickedEvent, Action <bool> action)
 {
     buttonClickedEvent.AddListener((b) => { action(b); });
 }
Exemple #5
0
        public void Refresh(UnitData unit)
        {
            if (unit == null)
            {
                return;
            }
            DataSource.Bind <UnitData>(((Component)this).get_gameObject(), unit);
            int index1 = 0;
            int index2 = 0;

            this.mJobSlots.Clear();
            Toggle.ToggleEvent toggleEvent = new Toggle.ToggleEvent();
            for (int jobNo = 0; jobNo < unit.Jobs.Length; ++jobNo)
            {
                JobData job = unit.Jobs[jobNo];
                if (job != null && job.Param != null)
                {
                    if (unit.IsJobAvailable(jobNo))
                    {
                        this.mJobSlots.Add(this.mJobIcons[index1]);
                        ++index1;
                    }
                    else
                    {
                        this.mJobSlots.Add(this.mCCIcons[index2]);
                        ++index2;
                    }
                    AnimatedToggle mJobIcon = this.mJobIcons[this.mJobSlots.Count - 1];
                    DataSource.Bind <JobData>(((Component)mJobIcon).get_gameObject(), unit.Jobs[jobNo]);
                    ((Component)mJobIcon).get_gameObject().SetActive(true);
                    ((Selectable)mJobIcon).set_interactable(unit.CheckJobUnlockable(jobNo));
                    Toggle.ToggleEvent onValueChanged = (Toggle.ToggleEvent)mJobIcon.onValueChanged;
                    mJobIcon.onValueChanged = (__Null)toggleEvent;
                    mJobIcon.set_isOn(jobNo == unit.JobIndex);
                    mJobIcon.onValueChanged = (__Null)onValueChanged;
                    ((Animator)((Component)mJobIcon).GetComponent <Animator>()).SetBool(this.JobIconUnlockBool, job.IsActivated);
                }
            }
            for (int index3 = index2; index3 < this.mCCIcons.Count; ++index3)
            {
                ((Component)this.mCCIcons[index3]).get_gameObject().SetActive(false);
            }
            for (int index3 = index1; index3 < this.mJobIcons.Count; ++index3)
            {
                ((Component)this.mJobIcons[index3]).get_gameObject().SetActive(false);
            }
            if (Object.op_Inequality((Object)this.SkinButton, (Object)null))
            {
                ((Selectable)this.SkinButton).set_interactable(unit.IsSkinUnlocked());
            }
            DataSource.Bind <UnitData>(this.JobNameObject, unit);
            bool flag = true;

            for (int index3 = 0; index3 < this.mJobSlots.Count; ++index3)
            {
                this.mJobSlots[index3].set_isOn(unit.JobIndex == index3);
                Animator component = (Animator)((Component)this.mJobSlots[index3]).GetComponent <Animator>();
                int      num       = 0;
                do
                {
                    component.Update(!flag ? 0.0f : 1f);
                    ++num;
                }while (component.IsInTransition(0) && num < 10);
            }
            if (Object.op_Inequality((Object)this.VoiceButton, (Object)null) && Object.op_Inequality((Object)this.VoiceUnlock, (Object)null))
            {
                this.VoiceUnlock.SetActive(!unit.CheckUnlockPlaybackVoice());
            }
            GameParameter.UpdateAll(((Component)this).get_gameObject());
        }
 void Update()
 {
     if (Liste_de_couleurs_listeners_set == false) {
         //Ajout des listener à chaque toggle pour la couleur de la cible
         Toggle[] Toggles_couleurs = Liste_de_couleurs.GetComponentsInChildren<Toggle> ();
         for (int i=0; i<Toggles_couleurs.Length; i++) {
             string couleur = Toggles_couleurs [i].GetComponentInChildren<Text> ().text;
             Toggle currentToggle = Toggles_couleurs [i];
             Toggle.ToggleEvent onToggleChangeEvent = new Toggle.ToggleEvent ();
             onToggleChangeEvent.AddListener (delegate {
                 onValueChangeCouleurCible (couleur, currentToggle);
             });
             Toggles_couleurs [i].onValueChanged = onToggleChangeEvent;
             Liste_de_couleurs_listeners_set = true;
         }
     }
 }