Exemplo n.º 1
0
        public ExperimentPopup(Vessel v, Experiment moduleOrPrefab, uint partId, string partName, ProtoPartModuleSnapshot protoModule = null)
        {
            popupId = partId + moduleOrPrefab.experiment_id.GetHashCode();

            if (activePopups.Contains(popupId))
            {
                return;
            }

            activePopups.Add(popupId);

            if (protoModule == null)
            {
                isProto = false;
            }
            else
            {
                isProto          = true;
                this.protoModule = protoModule;
            }

            this.moduleOrPrefab = moduleOrPrefab;
            this.v   = v;
            vd       = v.KerbalismData();
            expInfo  = GetExperimentInfo(moduleOrPrefab.experiment_id);
            isSample = expInfo.IsSample;

            // parse the module / protomodule data so we can use it right now
            GetData();

            // create the window
            window         = new KsmGuiWindow(KsmGuiWindow.LayoutGroupType.Vertical, true, KsmGuiStyle.defaultWindowOpacity, true, 0, TextAnchor.UpperLeft, 5f);
            window.OnClose = () => activePopups.Remove(popupId);
            window.SetLayoutElement(false, false, -1, -1, -1, 150);
            window.SetUpdateAction(GetData);

            // top header
            KsmGuiHeader topHeader = new KsmGuiHeader(window, expInfo.Title, default, 120);
Exemplo n.º 2
0
        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");
        }