private static void OnToggleExperiment(ExpInfoAndSubjects expInfoAndSubjects) { currentExperiment.experimentSubjectList.Enabled = false; expInfoAndSubjects.experimentSubjectList.KnownSubjectsToggle.SetOnState(currentExperiment.experimentSubjectList.KnownSubjectsToggle.IsOn, true); currentExperiment = expInfoAndSubjects; expInfoAndSubjects.experimentSubjectList.Enabled = true; expInfoText.SetText(expInfoAndSubjects.expInfo.ModuleInfo); window.RebuildLayout(); }
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"); }