public void Start()
        {
            Log.Warning("WernherChecker is loading..., scene: " + HighLogic.LoadedScene.ToString());
            Version = this.GetType().Assembly.GetName().Version.ToString();
            Log.Warning(string.Format("WernherChecker Version is {0}", Version));
            Instance = this;

            if (Settings.Load())
            {
                minimized    = Settings.minimized;
                mainWindow.x = Settings.windowX;
                mainWindow.y = Settings.windowY;
            }

            checklistSystem.LoadChecklists();

            //if (AssemblyLoader.loadedAssemblies.Any(a => a.dllName == "KerbalConstructionTime"))
            if (hasMod("KerbalConstructionTime"))
            {
                KCTInstalled = true;
            }
            else
            {
                KCTInstalled = false;
            }
            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                panelWidth = EditorPanels.Instance.partsEditor.panelTransform.rect.xMax;
                mainWindow = new Rect(panelWidth + 3, 120, 0, 0);
                GameEvents.onEditorScreenChange.Add(onEditorPanelChange);
                GameEvents.onEditorShipModified.Add(checklistSystem.CheckVessel);
                GameEvents.onEditorRestart.Add(checklistSystem.CheckVessel);
                GameEvents.onEditorShowPartList.Add(checklistSystem.CheckVessel);

                launchDelegate        = new UnityAction(CrewCheck.OnButtonInput);
                defaultLaunchDelegate = new UnityAction(EditorLogic.fetch.launchVessel);

                if (Settings.checkCrewAssignment && !KCTInstalled)
                {
                    EditorLogic.fetch.launchBtn.onClick.RemoveListener(defaultLaunchDelegate);
                    EditorLogic.fetch.launchBtn.onClick.AddListener(launchDelegate);
                }
            }
            else
            {
                mainWindow = new Rect(panelWidth + 3, 120, 0, 0);
            }

            if (Settings.wantedToolbar == toolbarType.BLIZZY && ToolbarManager.ToolbarAvailable)
            {
                AddToolbarButton(toolbarType.BLIZZY, true);
            }
            else
            {
                AddToolbarButton(toolbarType.STOCK, true);
            }
            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        public void Start()
        {
            Log.Warning("WernherChecker is loading..., scene: " + HighLogic.LoadedScene.ToString());
            Version = this.GetType().Assembly.GetName().Version.ToString();
            Log.Warning(string.Format("WernherChecker Version is {0}", Version));
            Instance = this;

            if (Settings.Load())
            {
                minimized = Settings.minimized;
            }

            checklistSystem.LoadChecklists();

            if (hasMod("KerbalConstructionTime"))
            {
                KCTInstalled = true;
            }
            else
            {
                KCTInstalled = false;
            }
            mainWindow = new Rect(Settings.windowX, Settings.windowY, 0, 0);

            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                panelWidth = EditorPanels.Instance.partsEditor.panelTransform.rect.xMax;
                GameEvents.onEditorScreenChange.Add(onEditorPanelChange);
                GameEvents.onEditorShipModified.Add(checklistSystem.CheckVessel);
                GameEvents.onEditorRestart.Add(checklistSystem.CheckVessel);
                GameEvents.onEditorShowPartList.Add(checklistSystem.CheckVessel);

                //launchDelegate = new UnityAction(CrewCheck.OnButtonInput);
                //defaultLaunchDelegate = new UnityAction(EditorLogic.fetch.launchVessel);

                if (Settings.checkCrewAssignment && !KCTInstalled)
                {
                    //EditorLogic.fetch.launchBtn.onClick.RemoveListener(defaultLaunchDelegate);
                    //EditorLogic.fetch.launchBtn.onClick.AddListener(launchDelegate);

                    ButtonManager.BtnManager.InitializeListener(EditorLogic.fetch.launchBtn, EditorLogic.fetch.launchVessel, "WernerChecker");
                    btnId = ButtonManager.BtnManager.AddListener(EditorLogic.fetch.launchBtn, CrewCheck.OnButtonInput, "WernerChecker", "Werner's Checker");
                }
            }



            CreateAppButton();

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Beispiel #3
0
        int CheckForParachutes(string module)
        {
            Log.Info("CheckForParachutes");
            int quantity = 0;

            if (partsToCheck.Where(p => p.Modules.Contains(module)).Count() > 0)
            {
                foreach (Part p1 in partsToCheck.Where(p => p.Modules.Contains(module)))
                {
                    Log.Info("part: " + p1.partInfo.name);
                    switch (module)
                    {
                    case "ModuleParachute":
                        foreach (ModuleParachute m in p1.Modules.GetModules <ModuleParachute>())
                        {
                            if (m.deploymentState == ModuleParachute.deploymentStates.STOWED)
                            {
                                quantity++;
                            }
                        }
                        Log.Info("ModuleParachute: " + quantity.ToString());
                        break;

                    case "RealChuteModule":
                        if (WernherChecker.hasMod("RealChute"))
                        {
                            quantity += checkForRealChutes(p1);
                        }

                        break;

                    case "RealChuteFAR":
                        break;
                    }
                }
            }
            Log.Info("CheckForParachutes, module: " + module + "   quantity: " + quantity.ToString());
            return(quantity);
        }
Beispiel #4
0
        public Criterion(ConfigNode node)
        {
            this.type = (CriterionType)Enum.Parse(typeof(CriterionType), node.GetValue("type"));
            if (type == CriterionType.Part || type == CriterionType.Module || type == CriterionType.MinResourceLevel || type == CriterionType.MinResourceCapacity || type == CriterionType.CrewMember)
            {
                paramsGUIFunction = ChecklistSystem.ParamsTextField;
                parameter         = 1;
                tempParam         = 1;
                parameterType     = typeof(int);
                hasParameter      = true;
            }

            if (node.HasValue("defaultParameter"))
            {
                int i;
                if (int.TryParse(node.GetValue("defaultParameter"), out i))
                {
                    this.parameter = i;
                    this.tempParam = this.parameter;
                }
            }
            if (node.HasValue("requiredMod"))
            {
                Log.Info("requiredMod found");
                reqModName = node.GetValue("requiredMod");
                Log.Info("reqModName: " + reqModName);
                if (!WernherChecker.hasMod(reqModName))
                {
                    Log.Info("required mod not found");
                    valid = false;
                    return;
                }
            }
            else
            {
                reqModName = null;
            }
            valid = true;

            switch (this.type)
            {
            case CriterionType.Module:
                this.modules         = node.GetValue("modules").Trim().Split(',').ToList <string>();
                this.measure         = "QTY";
                this.valuesFull      = string.Join(", ", this.modules.ToArray());
                this.valuesShortened = this.modules.First() + (this.modules.Count == 1 ? string.Empty : ",...");
                this.tooltip         = "How many of <b><color=#90FF3E>" + this.valuesFull + "</color></b> should your vessel contain";
                break;

            case CriterionType.Part:
                this.parts           = node.GetValue("parts").Trim().Split(',').ToList <string>();
                this.measure         = "QTY";
                this.valuesFull      = string.Join(", ", this.parts.ToArray());
                this.valuesShortened = this.parts.First() + (this.parts.Count == 1 ? string.Empty : ",...");
                this.tooltip         = "How many of <b><color=#90FF3E>" + this.valuesFull + "</color></b> should your vessel contain";
                break;

            case CriterionType.MinResourceLevel:
                this.resourceName    = node.GetValue("resourceName");
                this.measure         = "AMT";
                this.valuesFull      = this.resourceName;
                this.valuesShortened = this.resourceName;
                this.tooltip         = "How much of <b><color=#90FF3E>" + this.valuesFull + "</color></b> should your vessel contain";
                break;

            case CriterionType.MinResourceCapacity:
                this.resourceName    = node.GetValue("resourceName");
                this.measure         = "CAPY";
                this.valuesFull      = this.resourceName;
                this.valuesShortened = this.resourceName;
                this.tooltip         = "How much of <b><color=#90FF3E>" + this.valuesFull + "</color></b> should your vessel has capacity for";
                break;

            case CriterionType.CrewMember:
                this.experienceTrait = node.GetValue("experienceTrait");
                this.measure         = "LVL";
                this.valuesFull      = this.experienceTrait;
                this.valuesShortened = this.experienceTrait;
                this.tooltip         = "Minimum experience level of your <b><color=#90FF3E>" + this.valuesFull + "</color></b>";
                break;

            case CriterionType.ContractRequirements:
                break;
            }
        }
        public void Start()
        {
            Debug.LogWarning("WernherChecker v0.4.1 is loading...");
            Instance = this;
            if (Settings.Load())
            {
                minimized = Settings.minimized;
                mainWindow.x = Settings.windowX;
                mainWindow.y = Settings.windowY;
            }
            checklistSystem.LoadChecklists();
            GameEvents.onEditorScreenChange.Add(onEditorPanelChange);
            GameEvents.onEditorShipModified.Add(checklistSystem.CheckVessel);
            GameEvents.onEditorRestart.Add(checklistSystem.CheckVessel);
            GameEvents.onEditorShowPartList.Add(checklistSystem.CheckVessel);

            if (AssemblyLoader.loadedAssemblies.Any(a => a.dllName == "KerbalConstructionTime"))
                KCTInstalled = true;
            else
                KCTInstalled = false;

            if (Settings.checkCrewAssignment && !KCTInstalled)
            {
                EditorLogic.fetch.launchBtn.onClick.RemoveListener(defaultLaunchDelegate);
                EditorLogic.fetch.launchBtn.onClick.AddListener(launchDelegate);
            }

            if (Settings.wantedToolbar == toolbarType.BLIZZY && ToolbarManager.ToolbarAvailable)
            {
                AddToolbarButton(toolbarType.BLIZZY, true);
            }
            else
            {
                AddToolbarButton(toolbarType.STOCK, true);
            }
        }