Beispiel #1
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (slices > 0)
        {
            slices--;
            eatSound.Play();
            Status food = GameStateManagerScript.Instance.GetStatus(StatusType.Food);

            GameStateManagerScript.Instance.Eat(Random.Range(40, 61));
            updateTooltip();
        }
        else
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "You have no more pizza.";
            DialogOption option = new DialogOption();
            option.optionText = "Ok";
            option.optionId = "ok";
            dialog.dialogOptions.Add(option);
            if (GameStateManagerScript.Instance.GetStatus(StatusType.Money).points >= 20)
            {
                option = new DialogOption();
                option.optionText = "Order more";
                option.optionId = "order";
                option.tooltipText = "-20$";
                dialog.dialogOptions.Add(option);
            }            
            DialogManagerScript.Instance.ShowDialog(dialog, optionChosen);
        }
    }
Beispiel #2
0
 private void checkForSleep(DialogOption option)
 {
     if (option.optionText == positiveAnswerText)
     {
         sleep();
     }
 }
Beispiel #3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (workedToday)
     {
         Dialog dialog = new Dialog();
         dialog.dialogText = "You already went to work today.";
         DialogOption option = new DialogOption();
         option.optionText = "Ok";
         dialog.dialogOptions.Add(option);
         DialogManagerScript.Instance.ShowDialog(dialog, noOp);
     } 
     else if (allowWork && GameStateManagerScript.Instance.GetGameTime().hour > 14)
     {
         Dialog dialog = new Dialog();
         dialog.dialogText = "It's too late to go to work now.";
         DialogOption option = new DialogOption();
         option.optionText = "Ok";
         dialog.dialogOptions.Add(option);
         DialogManagerScript.Instance.ShowDialog(dialog, noOp);
     }
     else if (allowWork)
     {
         Dialog dialog = new Dialog();
         dialog.dialogText = "You went to work, you earned 20$.";
         DialogOption option = new DialogOption();
         option.optionText = "Ok";
         dialog.dialogOptions.Add(option);
         DialogManagerScript.Instance.ShowDialog(dialog, noOp);
         workedToday = true;
         GameStateManagerScript.Instance.AdvanceTime(8 * 60 + Random.Range(0, 30));
         GameStateManagerScript.Instance.ChangeMoney(20);
     }
 }
Beispiel #4
0
 private void optionChosen(DialogOption option)
 {
     if (option.optionId == "order")
     {
         slices = 2;
         GameStateManagerScript.Instance.ChangeMoney(-20);
         updateTooltip();
     }
 }
Beispiel #5
0
 public void removeOption(DialogOption dlo)
 {
     int k = 0;
         DialogOption[] tmp = new DialogOption [options.Length - 1];
         for (int i=0; i<options.Length-1; i++) {
             if(dlo == options[i]) k = 1;
             tmp[i] = options[i+k];
         }
         options = tmp;
 }
Beispiel #6
0
 public void OnPointerClick(PointerEventData eventData)
 {
     Dialog dialog = new Dialog();
     dialog.dialogText = confirmationDialogText;
     DialogOption yes = new DialogOption();
     yes.optionText = positiveAnswerText;
     DialogOption no = new DialogOption();
     no.optionText = negativeAnswerText;
     dialog.dialogOptions.Add(yes);
     dialog.dialogOptions.Add(no);
     DialogManagerScript.Instance.ShowDialog(dialog, checkForSleep);
 }
Beispiel #7
0
 public void addOption()
 {
     if (options != null) {
             DialogOption[] tmp = new DialogOption [options.Length + 1];
             for (int i=0; i<options.Length; i++) {
                 tmp [i] = options [i];
             }
             tmp [options.Length] = new DialogOption ();
             this.options = tmp;
         } else {
             options = new DialogOption[1];
             options[0] = new DialogOption();
         }
 }
Beispiel #8
0
    public void StartMatch()
    {
        if (GameStateManagerScript.Instance.GetGameTime().hour > 21)
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "You feel too tired for anything";
            DialogOption ok = new DialogOption();
            ok.optionText = "Ok";
            dialog.dialogOptions.Add(ok);
            DialogManagerScript.Instance.ShowDialog(dialog, noOp);
            return;
        }
		lobbyScreen.SetActive(false);
		matchScreen.SetActive(true);
		matchScript.StartMatch();
    }
Beispiel #9
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (GameStateManagerScript.Instance.GetGameTime().hour > 21)
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "You feel too tired for anything";
            DialogOption ok = new DialogOption();
            ok.optionText = "Ok";
            dialog.dialogOptions.Add(ok);
            DialogManagerScript.Instance.ShowDialog(dialog, noOp);
            return;
        }

        GameEvent watchEvent = RandomGeneratorScript.Instance.GetWatchEvent();
        GameEventManagerScript.Instance.ResolveGameEvent(watchEvent);

        GameStateManagerScript.Instance.AdvanceTime(Random.Range(30, 60));
    }
Beispiel #10
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (GameStateManagerScript.Instance.GetGameTime().hour > 21)
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "You feel too tired for anything";
            DialogOption ok = new DialogOption();
            ok.optionText = "Ok";
            dialog.dialogOptions.Add(ok);
            DialogManagerScript.Instance.ShowDialog(dialog, noOp);
            return;
        }

        GameEvent watchEvent = RandomGeneratorScript.Instance.GetWatchEvent();

        GameEventManagerScript.Instance.ResolveGameEvent(watchEvent);

        GameStateManagerScript.Instance.AdvanceTime(Random.Range(30, 60));
    }
    /// <summary>
    /// 弹出保存对话窗方法
    /// </summary>
    /// <typeparam name="TComponent"></typeparam>
    /// <param name="service">DialogService 服务实例</param>
    /// <param name="title">弹窗标题</param>
    /// <param name="saveCallback">点击保存按钮回调委托方法 返回 true 时关闭弹窗</param>
    /// <param name="parametersFactory">TComponent 组件所需参数</param>
    /// <param name="configureOption"><see cref="DialogOption"/> 实例配置回调方法</param>
    /// <param name="dialog"></param>
    /// <returns></returns>
    public static async Task ShowSaveDialog <TComponent>(this DialogService service, string title, Func <Task <bool> >?saveCallback = null, Action <Dictionary <string, object?> >?parametersFactory = null, Action <DialogOption>?configureOption = null, Dialog?dialog = null) where TComponent : ComponentBase
    {
        var option = new DialogOption()
        {
            Title          = title,
            ShowSaveButton = true,
            OnSaveAsync    = saveCallback
        };
        Dictionary <string, object?>?parameters = null;

        if (parametersFactory != null)
        {
            parameters = new Dictionary <string, object?>();
            parametersFactory.Invoke(parameters);
        }
        option.Component = BootstrapDynamicComponent.CreateComponent <TComponent>(parameters);
        configureOption?.Invoke(option);
        await service.Show(option, dialog);
    }
        public override bool CanUse(Pawn p, DialogOption option = null)
        {
            if (!string.IsNullOrEmpty(Childhood))
            {
                if (p.story.childhood.identifier != Childhood)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(Adulthood))
            {
                if (p.story.adulthood.identifier != Adulthood)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #13
0
    public void UpdateDialogOptions()
    {
        // Hide all dialog options objects
        foreach (var button in m_DialogButtons)
        {
            button.Hide();
        }

        // For the current state, set dialog options
        Debug.Assert(m_States.ContainsKey(m_CurrentState));
        DialogState state = m_States[m_CurrentState];

        for (var i = 0; i < state.options.Count; i++)
        {
            DialogOption option = state.options[i];

            DialogButton button = m_DialogButtons[i];
            button.SetOption(option.text, option);
        }
    }
Beispiel #14
0
 public void HandleDialogOption(DialogOption option)
 {
     if (option.triggerExit)
     {
         PlayerStateManager.m_Instance.SetState(PlayerState.Moving);
     }
     else
     {
         if (option.statCheck(m_PlayerStats, m_ApplianceStats))
         {
             Debug.Log("Stat check passed!");
             SetState(option.success);
         }
         else
         {
             Debug.Log("Stat check failed!");
             SetState(option.failure);
         }
     }
 }
        private Task OnClickShowDataById()
        {
            var op = new DialogOption()
            {
                Title       = "数据查询窗口",
                ShowFooter  = false,
                BodyContext = DataPrimaryId
            };

            op.BodyTemplate = DynamicComponent.CreateComponent <DataDialogComponent>(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(nameof(DataDialogComponent.OnClose), new Action(() =>
                {
                    op.Dialog?.Toggle();
                }))
            }).Render();

            DialogService?.Show(op);
            return(Task.CompletedTask);
        }
Beispiel #16
0
        private void BtnOption_Click(object sender, RoutedEventArgs e)
        {
            var target = tree.SelectedItem;
            var tmp    = new DialogOption()
            {
                Name = "<new>", Selected = true
            };

            if (target is DialogOption)
            {
                Story.FindParent(target as DialogOption).Options.Add(tmp);
            }
            else
            {
                (target as Dialog).Options.Add(tmp);
            }
            set.Default.Edited = true;
            //tree.Items.Refresh();
            tmp.Selected = true;
        }
Beispiel #17
0
        internal async Task CloseDialogAsync(DialogOption option, DialogResult result)
        {
            var messageContent = option.Element;
            var dom            = messageContent.Dom(JSRuntime);
            var top            = await dom.GetOffsetTopAsync();

            var left = await dom.GetOffsetLeftAsync();

            var style = messageContent.Dom(JSRuntime).Style;

            if (!GlobalBlazuiSettings.DisableAnimation)
            {
                await style.SetAsync("left", $"{left}px");

                await style.SetAsync("top", $"{top}px");

                await style.SetAsync("position", "absolute");

                await style.SetTransitionAsync("top 0.3s,opacity 0.3s");

                await Task.Delay(100);

                await style.SetAsync("top", $"{top - 10}px");

                await style.SetAsync("opacity", $"0");

                if (--ShadowCount <= 0)
                {
                    await option.ShadowElement.Dom(JSRuntime).Style.SetAsync("opacity", "0");
                }
                await Task.Delay(300);

                await style.ClearAsync("left");

                await style.ClearAsync("top");

                await style.ClearAsync("position");
            }
            option.TaskCompletionSource.TrySetResult(result);
            DialogService.Dialogs.Remove(option);
        }
    public override void Init()
    {
        var option1 = new DialogOption(
            "Take potion",
            () => { return(true); },
            () => { Debug.Log("Health added"); });

        var option2 = new DialogOption(
            "Take super potion (only if strenght higher than 40)",
            () => { return(PlayerStats.Strength > 40); },
            () => { Debug.Log("Health added"); });

        var option3 = new DialogOption(
            "Take super-duper potion (only if strenght higher than 70)",
            () => { return(PlayerStats.Strength > 70); },
            () => { Debug.Log("Health added"); });

        DialogOptions.Add(option1);
        DialogOptions.Add(option2);
        DialogOptions.Add(option3);
    }
    private Dialog getWardsDialog()
    {
        Dialog dialog = new Dialog();

        dialog.dialogText = "You notice your team doesn't have wards";
        DialogOption option = new DialogOption();

        option.optionId   = "team";
        option.optionText = "Tell your team to buy wards";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "self";
        option.optionText = "Buy wards yourself";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "neutral";
        option.optionText = "Do nothing";
        dialog.dialogOptions.Add(option);

        return(dialog);
    }
    private Dialog getEnemyRushanDialog()
    {
        Dialog dialog = new Dialog();

        dialog.dialogText = "You notice that the enemy team is attempting to kill Rushan";
        DialogOption option = new DialogOption();

        option.optionId   = "team";
        option.optionText = "Tell your team to buyback and try to kill them";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "self";
        option.optionText = "Try to prevent the kill yourself";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "neutral";
        option.optionText = "Do nothing";
        dialog.dialogOptions.Add(option);

        return(dialog);
    }
        public override bool CanUse(Pawn p, DialogOption option = null)
        {
            FactionInteraction interaction = QuestsManager.Communications.FactionManager.GetInteraction(p.Faction);

            if (interaction != null)
            {
                Alliance alliance = interaction.Alliance;
                if (alliance != null)
                {
                    if (alliance.FactionOwner == interaction.Faction)
                    {
                        if (alliance.Factions.Count >= MinMembers)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #22
0
        public override bool CanUse(Pawn p, DialogOption option = null)
        {
            if (ThingDef == null)
            {
                return(true);
            }

            if (Count == 0)
            {
                return(true);
            }

            int resourceCount = p.Map.resourceCounter.GetCount(ThingDef);

            if (resourceCount < Count)
            {
                return(false);
            }

            return(true);
        }
    private Dialog getOwnRushanDialog()
    {
        Dialog dialog = new Dialog();

        dialog.dialogText = "Most of the enemy team is dead, you have a chance to kill Rushan!";
        DialogOption option = new DialogOption();

        option.optionId   = "team";
        option.optionText = "Tell your team to kill Rushan";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "self";
        option.optionText = "Try to kill Rushan yourself";
        dialog.dialogOptions.Add(option);
        option            = new DialogOption();
        option.optionId   = "neutral";
        option.optionText = "Do nothing";
        dialog.dialogOptions.Add(option);

        return(dialog);
    }
Beispiel #24
0
 public void UpdateEdge(DialogOption o)
 {
     if (graph.EdgesList.Where(x => x.Key.DialogOption.ID == o.ID).Any())
     {
         graph.RemoveEdge(graph.EdgesList.First(x => x.Key.DialogOption.ID == o.ID).Key);
     }
     if (!o.TargetID.IsNullOrEmpty())
     {
         var de = new DialogEdge(graph.VertexList.First(x => x.Key.Dialog.ID == Story.FindParent(o).ID).Key, graph.VertexList.First(x => x.Key.Dialog.ID == o.TargetID).Key)
         {
             DialogOption = o
         };
         graph.AddEdge(de, new EdgeControl(graph.VertexList.First(x => x.Key.Dialog.ID == Story.FindParent(o).ID).Value, graph.VertexList.First(x => x.Key.Dialog.ID == o.TargetID).Value, de, false)
         {
             ShowArrows = true
         });
     }
     Relayout();
     //graph.GenerateAllEdges(updateLayout: false);
     //graph.UpdateParallelEdgesData();
     //graph.RelayoutGraph(true);
 }
Beispiel #25
0
        protected Task SetRole(UserDto userDto)
        {
            var option = new DialogOption()
            {
                Title       = "配置角色",
                Size        = Size.Large,
                BodyContext = userDto
            };

            option.BodyTemplate = DynamicComponent.CreateComponent <UserRole>(new KeyValuePair <string, object>[]
            {
                new KeyValuePair <string, object>(nameof(UserRole.OnClose), new Action(() => { option.Dialog?.Toggle(); })),
            }).Render();
            //option.FooterTemplate=DynamicComponent.CreateComponent<Button>(new KeyValuePair<string, object>[]
            //{
            //    new KeyValuePair<string, object>(nameof(Button.Text),"保存")
            //    //new KeyValuePair<string, object>(nameof(Button.OnClick),EventCallback.Factory.Create<MouseEventArgs>(option.Dialog,()=>{ option.Dialog. }))
            //}).Render();
            DialogService.Show(option);

            return(Task.CompletedTask);
        }
Beispiel #26
0
    private void gameStateUpdated()
    {
        if (!allowWork)
        {
            return;
        }
        int oldDay = day;
        int newDay = GameStateManagerScript.Instance.GetGameTime().day;

        day = newDay;
        if (newDay != oldDay && workedToday == false)
        {
            Debug.Log(oldDay + " " + newDay);
            for (int i = day; i <= newDay; i++)
            {
                worksMissed++;
                Debug.Log(worksMissed);
            }
        }

        if (worksMissed >= 3)
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "Your boss called and fired you. You missed work too many times this month.";
            DialogOption option = new DialogOption();
            option.optionText = "Ok";
            dialog.dialogOptions.Add(option);
            DialogManagerScript.Instance.ShowDialog(dialog, noOp);
            allowWork = false;
            gameObject.SetActive(false);
        }

        if (newDay != oldDay)
        {
            workedToday = false;
        }
    }
Beispiel #27
0
    private void gameStateUpdated()
    {
        if (!allowWork)
        {
            return;
        }
        int oldDay = day;
        int newDay = GameStateManagerScript.Instance.GetGameTime().day;
        day = newDay;
        if (newDay != oldDay && workedToday == false)
        {
            Debug.Log(oldDay + " " + newDay);
            for (int i = day; i <= newDay; i++)
            {
                worksMissed++;
                Debug.Log(worksMissed);
            }
        }

        if (worksMissed >= 3)
        {
            Dialog dialog = new Dialog();
            dialog.dialogText = "Your boss called and fired you. You missed work too many times this month.";
            DialogOption option = new DialogOption();
            option.optionText = "Ok";
            dialog.dialogOptions.Add(option);
            DialogManagerScript.Instance.ShowDialog(dialog, noOp);
            allowWork = false;
            gameObject.SetActive(false);
        }

        if (newDay != oldDay)
        {
            workedToday = false;
        }
    }
Beispiel #28
0
        private static void DrawBLPlusWindow(int windowID)
        {
            //bLPlusPosition.xMax = buildListWindowPosition.xMin;
            //bLPlusPosition.width = 100;
            bLPlusPosition.yMin = buildListWindowPosition.yMin;
            bLPlusPosition.height = 225;
            //bLPlusPosition.height = bLPlusPosition.yMax - bLPlusPosition.yMin;
            KCT_BuildListVessel b = KCT_Utilities.FindBLVesselByID(IDSelected);
            GUILayout.BeginVertical();
            if (GUILayout.Button("Scrap"))
            {
                InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "KCTPopupLock");
                DialogOption[] options = new DialogOption[2];
                options[0] = new DialogOption("Yes", ScrapVessel);
                options[1] = new DialogOption("No", DummyVoid);
                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options);
                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                showBLPlus = false;
                ResetBLWindow();
            }
            if (GUILayout.Button("Edit"))
            {
                showBLPlus = false;
                editorWindowPosition.height = 1;
                string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp.craft";
                b.shipNode.Save(tempFile);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                KCT_GameStates.editedVessel = b;
                KCT_GameStates.EditorShipEditingMode = true;
                KCT_GameStates.delayStart = true;

                InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LOAD, "KCTEditLoad");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTEditLaunch");

                KCT_GameStates.EditedVesselParts.Clear();
                foreach (ConfigNode node in b.ExtractedPartNodes)
                {
                    string name = KCT_Utilities.PartNameFromNode(node) + KCT_Utilities.GetTweakScaleSize(node);
                    if (!KCT_GameStates.EditedVesselParts.ContainsKey(name))
                        KCT_GameStates.EditedVesselParts.Add(name, 1);
                    else
                        ++KCT_GameStates.EditedVesselParts[name];
                }

                //EditorDriver.StartAndLoadVessel(tempFile);
                EditorDriver.StartAndLoadVessel(tempFile, b.type == KCT_BuildListVessel.ListType.VAB ? EditorFacility.VAB : EditorFacility.SPH);
            }
            if (GUILayout.Button("Rename"))
            {
                centralWindowPosition.width = 360;
                centralWindowPosition.x = (Screen.width - 360) / 2;
                centralWindowPosition.height = 1;
                showBuildList = false;
                showBLPlus = false;
                showRename = true;
                newName = b.shipName;
                //newDesc = b.getShip().shipDescription;
            }
            if (GUILayout.Button("Duplicate"))
            {
                KCT_Utilities.AddVesselToBuildList(b.NewCopy(true), b.InventoryParts.Count > 0);
            }
            if (KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()) != null && GUILayout.Button("Rollback"))
            {
                KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()).SwapRolloutType();
            }
            if (!b.isFinished && GUILayout.Button("Warp To"))
            {
                KCT_GameStates.targetedItem = b;
                KCT_GameStates.canWarp = true;
                KCT_Utilities.RampUpWarp(b);
                KCT_GameStates.warpInitiated = true;
                showBLPlus = false;
            }
            if (!b.isFinished && GUILayout.Button("Move to Top"))
            {
                if (b.type == KCT_BuildListVessel.ListType.VAB)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.VABList.Insert(0, b);
                }
                else if (b.type == KCT_BuildListVessel.ListType.SPH)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.SPHList.Insert(0, b);
                }
            }
            if (!b.isFinished && GUILayout.Button("Rush Build 10%\n√"+Math.Round(0.2*b.GetTotalCost())))
            {
                double cost = b.GetTotalCost();
                cost *= 0.2;
                double remainingBP = b.buildPoints - b.progress;
                if (Funding.Instance.Funds >= cost)
                {
                    b.AddProgress(remainingBP * 0.1);
                    KCT_Utilities.SpendFunds(cost, TransactionReasons.None);
                }

            }
            if (GUILayout.Button("Close"))
            {
                showBLPlus = false;
            }
            GUILayout.EndVertical();
            float width = bLPlusPosition.width;
            bLPlusPosition.x = buildListWindowPosition.x - width;
            bLPlusPosition.width = width;
        }
Beispiel #29
0
        public static void DrawBuildListWindow(int windowID)
        {
            if (buildListWindowPosition.xMax > Screen.width)
                buildListWindowPosition.x = Screen.width - buildListWindowPosition.width;

            //GUI.skin = HighLogic.Skin;
            GUIStyle redText = new GUIStyle(GUI.skin.label);
            redText.normal.textColor = Color.red;
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);
            yellowText.normal.textColor = Color.yellow;
            GUIStyle greenText = new GUIStyle(GUI.skin.label);
            greenText.normal.textColor = Color.green;

            int width1 = 120;
            int width2 = 100;
            int butW = 20;
            GUILayout.BeginVertical();
            //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName);
            //List next vessel to finish
            GUILayout.BeginHorizontal();
            GUILayout.Label("Next:", windowSkin.label);
            IKCTBuildItem buildItem = KCT_Utilities.NextThingToFinish();
            if (buildItem != null)
            {
                //KCT_BuildListVessel ship = (KCT_BuildListVessel)buildItem;
                GUILayout.Label(buildItem.GetItemName());
                if (buildItem.GetListType() == KCT_BuildListVessel.ListType.VAB || buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning)
                {
                    GUILayout.Label("VAB", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.SPH)
                {
                    GUILayout.Label("SPH", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.TechNode)
                {
                    GUILayout.Label("Tech", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.KSC)
                {
                    GUILayout.Label("KSC", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }

                if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button("Warp to" + System.Environment.NewLine + "Complete"))
                {
                    KCT_GameStates.targetedItem = buildItem;
                    KCT_GameStates.canWarp = true;
                    KCT_Utilities.RampUpWarp();
                    KCT_GameStates.warpInitiated = true;
                }
                else if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex > 0 && GUILayout.Button("Stop" + System.Environment.NewLine + "Warp"))
                {
                    KCT_GameStates.canWarp = false;
                    TimeWarp.SetRate(0, true);
                    KCT_GameStates.lastWarpRate = 0;
                }

                if (KCT_GameStates.settings.AutoKACAlarams && KACWrapper.APIReady && buildItem.GetTimeLeft() > 30) //don't check if less than 30 seconds to completion. Might fix errors people are seeing
                {
                    double UT = Planetarium.GetUniversalTime();
                    if (!KCT_Utilities.ApproximatelyEqual(KCT_GameStates.KACAlarmUT - UT, buildItem.GetTimeLeft()))
                    {
                        KCTDebug.Log("KAC Alarm being created!");
                        KCT_GameStates.KACAlarmUT = (buildItem.GetTimeLeft() + UT);
                        KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KCT_GameStates.KACAlarmId);
                        if (alarm == null)
                        {
                            alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => (a.Name.StartsWith("KCT: ")));
                        }
                        if (alarm != null)
                        {
                            KCTDebug.Log("Removing existing alarm");
                            KACWrapper.KAC.DeleteAlarm(alarm.ID);
                        }
                        KCT_GameStates.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "KCT: " + buildItem.GetItemName() + " Complete", KCT_GameStates.KACAlarmUT);
                        KCTDebug.Log("Alarm created with ID: " + KCT_GameStates.KACAlarmId);
                    }
                }
            }
            else
            {
                GUILayout.Label("No Active Projects");
            }
            GUILayout.EndHorizontal();

            //Buttons for VAB/SPH lists
               // List<string> buttonList = new List<string> { "VAB", "SPH", "KSC" };
            //if (KCT_Utilities.CurrentGameHasScience() && !KCT_GameStates.settings.InstantTechUnlock) buttonList.Add("Tech");
            GUILayout.BeginHorizontal();
            //if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { buttonList.Add("Upgrades"); buttonList.Add("Settings"); }
              //  int lastSelected = listWindow;
               // listWindow = GUILayout.Toolbar(listWindow, buttonList.ToArray());

            bool VABSelectedNew = GUILayout.Toggle(VABSelected, "VAB", GUI.skin.button);
            bool SPHSelectedNew = GUILayout.Toggle(SPHSelected, "SPH", GUI.skin.button);
            bool TechSelectedNew = false;
            if (KCT_Utilities.CurrentGameHasScience())
                TechSelectedNew = GUILayout.Toggle(TechSelected, "Tech", GUI.skin.button);
            if (VABSelectedNew != VABSelected)
                SelectList("VAB");
            else if (SPHSelectedNew != SPHSelected)
                SelectList("SPH");
            else if (TechSelectedNew != TechSelected)
                SelectList("Tech");

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Upgrades"))
            {
                showUpgradeWindow = true;
                showBuildList = false;
                showBLPlus = false;
            }
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Settings"))
            {
                showBuildList = false;
                showBLPlus = false;
                ShowSettings();
            }
            GUILayout.EndHorizontal();

              /*  if (GUI.changed)
            {
                buildListWindowPosition.height = 1;
                showBLPlus = false;
                if (lastSelected == listWindow)
                {
                    listWindow = -1;
                }
            }*/
            //Content of lists
            if (listWindow == 0) //VAB Build List
            {
                List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.VABList;
                GUILayout.BeginHorizontal();
              //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                if (KCT_Utilities.ReconditioningActive(null))
                {
                    GUILayout.BeginHorizontal();
                    IKCTBuildItem item = (IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning();
                    GUILayout.Label(item.GetItemName());
                    GUILayout.Label(KCT_GameStates.ActiveKSC.GetReconditioning().ProgressPercent().ToString() + "%", GUILayout.Width(width1 / 2));
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(item.GetTimeLeft()), GUILayout.Width(width2));
                    //GUILayout.Label(Math.Round(KCT_GameStates.ActiveKSC.GetReconditioning().BP, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width((butW + 4) * 2)))
                    {
                        KCT_GameStates.targetedItem = item;
                        KCT_GameStates.canWarp = true;
                        KCT_Utilities.RampUpWarp(item);
                        KCT_GameStates.warpInitiated = true;
                    }
                    //GUILayout.Space((butW + 4) * 3);
                    GUILayout.EndHorizontal();
                }

                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the VAB to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        GUILayout.BeginHorizontal();
                        //GUILayout.Label(b.shipName, GUILayout.Width(width1));

                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                                showBLPlus = !showBLPlus;
                            else
                                showBLPlus = true;
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogOption[] options = new DialogOption[2];
                                options[0] = new DialogOption("Yes", ScrapVessel);
                                options[1] = new DialogOption("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options);
                                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                      //      GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                      //      GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        else
                            GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.VAB, null)), GUILayout.Width(width2));
                       // GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    //ADD Storage here!
                    buildList = KCT_GameStates.ActiveKSC.VABWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("VAB Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        try
                        {
                            GamePersistence.SaveGame("KCT_Backup", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                            KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(FlightGlobals.ActiveVessel);
                            KCT_GameStates.recoveredVessel.type = KCT_BuildListVessel.ListType.VAB;
                            KCT_GameStates.recoveredVessel.launchSite = "LaunchPad";
                            // HighLogic.LoadScene(GameScenes.SPACECENTER);
                            //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState);
                            GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel);
                        }
                        catch
                        {
                            Debug.LogError("[KCT] Error while recovering craft into inventory.");
                        }
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }
                    KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout);
                    //KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback);
                    bool rolloutEnabled = KCT_GameStates.settings.Reconditioning && KCT_GameStates.timeSettings.RolloutReconSplit > 0;
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback);
                        KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        GUIStyle textColor = new GUIStyle(GUI.skin.label);
                        GUIStyle buttonColor = new GUIStyle(GUI.skin.button);
                        string status = "In Storage";
                        if (rollout != null && rollout.associatedID == b.id.ToString())
                        {
                            status = "Rolling Out";
                            textColor = yellowText;
                            if (rollout.AsBuildItem().IsComplete())
                            {
                                status = "On the Pad";
                                textColor = greenText;
                            }
                        }
                        else if (rollback != null)
                        {
                            status = "Rolling Back";
                            textColor = yellowText;
                        }
                        else if (recovery != null)
                        {
                            status = "Recovering";
                            textColor = redText;
                        }

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && status == "In Storage")
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                    showBLPlus = !showBLPlus;
                                else
                                    showBLPlus = true;
                                IDSelected = b.id;
                            }
                        }
                        else
                            GUILayout.Space(butW + 4);

                        GUILayout.Label(b.shipName, textColor);
                        GUILayout.Label(status+"   ", textColor, GUILayout.ExpandWidth(false));
                        if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && (rollout == null || b.id.ToString() != rollout.associatedID) && rollback == null && GUILayout.Button("Rollout", GUILayout.ExpandWidth(false)))
                        {
                            if (rollout != null)
                            {
                                rollout.SwapRolloutType();
                            }
                            KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(b, KCT_Recon_Rollout.RolloutReconType.Rollout, b.id.ToString()));
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollout != null && b.id.ToString() == rollout.associatedID && !rollout.AsBuildItem().IsComplete() && rollback == null &&
                            GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollout.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)))
                        {
                            rollout.SwapRolloutType();
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollback != null && b.id.ToString() == rollback.associatedID && !rollback.AsBuildItem().IsComplete())
                        {
                            if (rollout == null)
                            {
                                if (GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)))
                                    rollback.SwapRolloutType();
                            }
                            else
                            {
                                GUILayout.Label(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                            }
                        }
                        else if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && (!rolloutEnabled || (rollout != null && b.id.ToString() == rollout.associatedID && rollout.AsBuildItem().IsComplete())))
                        {
                            if (rolloutEnabled && GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Roll Back", GUILayout.ExpandWidth(false)))
                            {
                                rollout.SwapRolloutType();
                            }
                            else if (!GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Launch", GUILayout.ExpandWidth(false)))
                            {
                                bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);//new PreFlightTests.FacilityOperational("LaunchPad", "building").Test();
                                if (!operational)
                                {
                                    ScreenMessages.PostScreenMessage("You must repair the launchpad prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                }
                                else if (KCT_Utilities.ReconditioningActive(null))
                                {
                                    //can't launch now
                                    ScreenMessage message = new ScreenMessage("[KCT] Cannot launch while LaunchPad is being reconditioned. It will be finished in "
                                        + KCT_Utilities.GetFormattedTime(((IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning()).GetTimeLeft()), 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                    ScreenMessages.PostScreenMessage(message, true);
                                }
                                else
                                {
                                    /*if (rollout != null)
                                        KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout);*/
                                    KCT_GameStates.launchedVessel = b;
                                    if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "LaunchPad").Count == 0)//  ShipConstruction.CheckLaunchSiteClear(HighLogic.CurrentGame.flightState, "LaunchPad", false))
                                    {
                                        showBLPlus = false;
                                        // buildList.RemoveAt(i);
                                        if (!IsCrewable(b.ExtractedParts))
                                            b.Launch();
                                        else
                                        {
                                            showBuildList = false;
                                            centralWindowPosition.height = 1;
                                            KCT_GameStates.launchedCrew.Clear();
                                            parts = KCT_GameStates.launchedVessel.ExtractedParts;
                                            pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                            KCT_GameStates.launchedCrew = new List<CrewedPart>();
                                            foreach (PseudoPart pp in pseudoParts)
                                                KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>()));
                                            CrewFirstAvailable();
                                            showShipRoster = true;
                                        }
                                    }
                                    else
                                    {
                                        showBuildList = false;
                                        showClearLaunch = true;
                                    }
                                }
                            }
                        }
                        else if (!HighLogic.LoadedSceneIsEditor && recovery != null)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 1) //SPH Build List
            {
                List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.SPHList;
                GUILayout.BeginHorizontal();
              //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the SPH to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                                showBLPlus = !showBLPlus;
                            else
                                showBLPlus = true;
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogOption[] options = new DialogOption[2];
                                options[0] = new DialogOption("Yes", ScrapVessel);
                                options[1] = new DialogOption("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap " + b.shipName + "?", windowTitle: "Scrap Vessel", options: options);
                                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                  //          GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                   //         GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        else
                            GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.SPH, null)), GUILayout.Width(width2));
                        //GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    buildList = KCT_GameStates.ActiveKSC.SPHWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("SPH Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        try
                        {
                            GamePersistence.SaveGame("KCT_Backup", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                            KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(FlightGlobals.ActiveVessel);
                            KCT_GameStates.recoveredVessel.type = KCT_BuildListVessel.ListType.SPH;
                            KCT_GameStates.recoveredVessel.launchSite = "Runway";
                            //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState);
                            GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel);
                        }
                        catch
                        {
                            Debug.LogError("[KCT] Error while recovering craft into inventory.");
                        }
                    }

                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        string status = "";
                        KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        if (recovery != null)
                            status = "Recovering";

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && status == "")
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                    showBLPlus = !showBLPlus;
                                else
                                    showBLPlus = true;
                                IDSelected = b.id;
                            }
                        }
                        else
                            GUILayout.Space(butW+4);

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(status + "   ", GUILayout.ExpandWidth(false));
                        //ScenarioDestructibles.protoDestructibles["KSCRunway"].
                        if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && GUILayout.Button("Launch", GUILayout.ExpandWidth(false)))
                        {
                            bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.SPH);//new PreFlightTests.FacilityOperational("Runway", "building").Test();
                            if (!operational)
                            {
                                ScreenMessages.PostScreenMessage("You must repair the runway prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                            }
                            else
                            {
                                showBLPlus = false;
                                KCT_GameStates.launchedVessel = b;
                                if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0)
                                {
                                    if (!IsCrewable(b.ExtractedParts))
                                        b.Launch();
                                    else
                                    {
                                        showBuildList = false;
                                        centralWindowPosition.height = 1;
                                        KCT_GameStates.launchedCrew.Clear();
                                        parts = KCT_GameStates.launchedVessel.ExtractedParts;
                                        pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                        KCT_GameStates.launchedCrew = new List<CrewedPart>();
                                        foreach (PseudoPart pp in pseudoParts)
                                            KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>()));
                                        CrewFirstAvailable();
                                        showShipRoster = true;
                                    }
                                }
                                else
                                {
                                    showBuildList = false;
                                    showClearLaunch = true;
                                }
                            }
                        }
                        else if (recovery != null)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }
                        GUILayout.EndHorizontal();
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 2) //Tech nodes
            {
                List<KCT_UpgradingBuilding> KSCList = KCT_GameStates.ActiveKSC.KSCTech;
                List<KCT_TechItem> techList = KCT_GameStates.TechList;
                //GUILayout.Label("Tech Node Research");
                GUILayout.BeginHorizontal();
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1/2));
                GUILayout.Label("Time Left:", GUILayout.Width(width1));
                GUILayout.Space(70);
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));

                if (KCT_Utilities.CurrentGameIsCareer())
                {
                    if (KSCList.Count == 0)
                        GUILayout.Label("No KSC upgrade projects are currently underway.");
                    foreach (KCT_UpgradingBuilding KCTTech in KSCList)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(KCTTech.AsIKCTBuildItem().GetItemName());
                        GUILayout.Label(Math.Round(100 * KCTTech.progress / KCTTech.BP, 2) + " %", GUILayout.Width(width1 / 2));
                        GUILayout.Label(KCT_Utilities.GetColonFormattedTime(KCTTech.AsIKCTBuildItem().GetTimeLeft()), GUILayout.Width(width1));
                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70)))
                        {
                            KCT_GameStates.targetedItem = KCTTech;
                            KCT_GameStates.canWarp = true;
                            KCT_Utilities.RampUpWarp(KCTTech);
                            KCT_GameStates.warpInitiated = true;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                            GUILayout.Space(70);
                        GUILayout.EndHorizontal();
                    }
                }

                if (techList.Count == 0)
                    GUILayout.Label("No tech nodes are being researched!\nBegin research by unlocking tech in the R&D building.");
                for (int i = 0; i < techList.Count; i++)
                {
                    KCT_TechItem t = techList[i];
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(t.techName);
                    GUILayout.Label(Math.Round(100 * t.progress / t.scienceCost, 2) + " %", GUILayout.Width(width1/2));
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(t.TimeLeft), GUILayout.Width(width1));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70)))
                    {
                        KCT_GameStates.targetedItem = t;
                        KCT_GameStates.canWarp = true;
                        KCT_Utilities.RampUpWarp(t);
                        KCT_GameStates.warpInitiated = true;
                    }
                    else if (HighLogic.LoadedSceneIsEditor)
                        GUILayout.Space(70);
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
            }

            if (KCT_UpdateChecker.UpdateFound)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Version: " + KCT_UpdateChecker.CurrentVersion);
                GUILayout.Label("Latest: " + KCT_UpdateChecker.WebVersion);
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();

            if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar)
                if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
                    GUI.DragWindow();
        }
 private void resolveOwnRushanDialog(DialogOption option)
 {
 }
Beispiel #31
0
 private void NoOp(DialogOption option)
 {
 }
Beispiel #32
0
 public void Choose(DialogOption dialogOption) => Choose((System.Windows.Forms.DialogResult)dialogOption);
        protected void initCollect()
        {
            cancelOtherAutoCollect();

            if(!collectNonrerunnable && vessel.FindPartModulesImplementing<IScienceDataContainer>().Any(c => !c.IsRerunnable() && c.GetData().Count() > 0)) {
                DialogOption<bool>[] dialogOptions = new DialogOption<bool>[2];
                dialogOptions[0] = new DialogOption<bool>("Transfer All Science", new Callback<bool>(collectData), true);
                dialogOptions[1] = new DialogOption<bool>("Transfer Rerunnable Science Data Only", new Callback<bool>(collectData), false);
                PopupDialog.SpawnPopupDialog(new MultiOptionDialog("Transfering science from nonrerunnable experiments will cause them to become inoperable.", "Warning", HighLogic.Skin, dialogOptions), false, HighLogic.Skin);
            }
            else {
                collectData(true);
            }
        }
    /// <summary>
    /// Methodcalled on dialogue button click. Processes all additional message events.
    /// </summary>
    /// <param name="data">Dialogue data associated with dialogue button.</param>
    public void DialogueClicked(DialogOption data)
    {
        if (data.option == "END")
        {
            ToggleDialogueWindow();
            return;
        }

        if (!MessageWindow.activeSelf)
        {
            MessageWindow.SetActive(true);
        }
        MessageWindow.transform.GetChild(0).GetComponent <Text>().text = data.response;


        //FRENIG
        if (data.option == "What is going on? I recently woke up, and met two hostile people on my way here.")
        {
            InteractiveHumanoid villageChief = worldController.banditQuestGiver.GetComponent <InteractiveHumanoid>();
            DialogOption        Dialogue     = new DialogOption()
            {
                option   = "I had spoken to Frenig, and he said you can tell me more about bandits",
                response = "Yes. It is simple, they came out of nowhere like three weeks ago from the east and started raiding our village. We managed to defend for now, but they grew stronger and also captured the forest. Nobody who went there has yet returned.", target = villageChief, isTemporary = true
            };
            villageChief.DialogOptions.Add(Dialogue);
        }

        //KUKAZU
        else if (data.option == "What are you doing here?")
        {
            InteractiveHumanoid alchemist = worldController.alchemist.GetComponent <InteractiveHumanoid>();
            DialogOption        Dialogue  = new DialogOption()
            {
                option      = "How can I help you?",
                response    = "I need red mushrooms. I will not gather them myself, as I am busy with my research, and bandits make things even harder. I will give you small healing potion for each one you bring to me.",
                target      = alchemist,
                isTemporary = true
            };
            alchemist.DialogOptions.Add(Dialogue);
            AddDialogue(Dialogue);
            RefreshEndDialogue();
        }

        else if (data.option == "How can I help you?")
        {
            InteractiveHumanoid alchemist = worldController.alchemist.GetComponent <InteractiveHumanoid>();
            DialogOption        Dialogue  = new DialogOption()
            {
                option      = "I want to trade mushrooms",
                response    = "Let's see... I will give you a healing potion for each mushroom you bring here.",
                target      = alchemist,
                isTemporary = false
            };
            alchemist.DialogOptions.Add(Dialogue);
            AddDialogue(Dialogue);
            RefreshEndDialogue();
        }

        else if (data.option == "I want to trade mushrooms")
        {
            Player player             = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
            int    firstMushroomIndex = player.Inventory.FindIndex(x => x.Name.ToLower() == "red mushroom");
            if (firstMushroomIndex != -1)
            {
                player.Inventory.RemoveAt(firstMushroomIndex);
                FoodItem potion = ScriptableObject.CreateInstance <FoodItem>();
                potion.Name        = "Small healing potion";
                potion.Owner       = player.gameObject;
                potion.HealAmount  = 2;
                potion.Description = "A healing potion I received from Kukazu";
                player.Inventory.Add(potion);
                //player.Inventory.Add(new FoodItem() { Name = "Small healing potion", Owner = player.gameObject, HealAmount = 2, Description = "A healing potion I received from Kukazu" });
            }
        }

        //VILLAGE CHIEF
        else if (data.option == "I had spoken to Frenig, and he said you can tell me more about bandits")
        {
            mainCamera.ViewPoint(GameObject.FindGameObjectWithTag("ForestCameraMarker").transform.position);
            DialogOption Dialogue = new DialogOption()
            {
                option = "I want to help. I will try to kill the bandits.", response = "WHAT? Are you serious? Currently nobody of us can help you, as direct attack would be a suicide in our opinion. Feel free to scout though, and be careful.", target = data.target, isTemporary = true
            };
            data.target.DialogOptions.Add(Dialogue);
            AddDialogue(Dialogue);
            RefreshEndDialogue();
        }

        else if (data.option == "I want to help. I will try to kill the bandits.")
        {
            worldController.StartBanditMission();
        }

        else if (data.option == "Forest bandits do not exist anymore. Does that solve bandit problem?")
        {
            worldController.StartBanditBaseMission();
        }

        else if (data.option == "I found and destroyed bandit headquarters, their commander was a knight in black armor!")
        {
            DisplayQuickMessage("You won the game! You can now continue playing and explore the world if you want.", 60);
        }

        if (data.isTemporary)
        {
            data.target.DialogOptions.Remove(data);
            DeleteDialogueButton(data.option);
        }
    }
Beispiel #35
0
    private void displayNodeEditor()
    {
        if (tree.treeNodes.Count > 0)
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Edit Node Information", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Node Name", GUILayout.MaxWidth(100));
            tree.treeNodes [editingIndex].name = EditorGUILayout.TextField(tree.treeNodes [editingIndex].name);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("String Key", GUILayout.MaxWidth(100));
            tree.treeNodes [editingIndex].textKey = EditorGUILayout.TextField(tree.treeNodes [editingIndex].textKey);
            EditorGUILayout.EndHorizontal();

            if (languageAsset != null)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Text Preview", GUILayout.MaxWidth(110));
                string preview = languageAsset.Get(tree.treeNodes [editingIndex].textKey);

                if (preview != null)
                {
                    EditorGUILayout.BeginVertical();
                    GUIStyle wrap = new GUIStyle();
                    wrap.wordWrap = true;
                    EditorGUILayout.LabelField(preview, wrap);
                    EditorGUILayout.EndVertical();
                }
                else
                {
                    EditorGUILayout.LabelField("Invalid Key");
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Dialog Options", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            // Collapse values for foldouts
            while (optionCollapse.Count < tree.treeNodes[editingIndex].dialogOptions.Count)
            {
                optionCollapse.Add(true);
            }

            while (optionIndices.Count < tree.treeNodes [editingIndex].dialogOptions.Count)
            {
                optionIndices.Add(0);
            }

            int optionToDelete = -1;

            for (int i = 0; i < tree.treeNodes [editingIndex].dialogOptions.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                optionCollapse[i] = EditorGUILayout.Foldout(optionCollapse [i], "Option " + (i + 1));
                EditorGUILayout.EndHorizontal();

                if (optionCollapse [i])
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("String Key", GUILayout.MaxWidth(100));
                    tree.treeNodes [editingIndex].dialogOptions[i].textKey = EditorGUILayout.TextField(tree.treeNodes [editingIndex].dialogOptions[i].textKey);
                    EditorGUILayout.EndHorizontal();

                    if (languageAsset != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Text Preview", GUILayout.MaxWidth(110));
                        string option_preview = languageAsset.Get(tree.treeNodes [editingIndex].dialogOptions [i].textKey);

                        if (option_preview != null)
                        {
                            EditorGUILayout.BeginVertical();
                            GUIStyle wrap = new GUIStyle();
                            wrap.wordWrap = true;
                            EditorGUILayout.LabelField(option_preview, wrap);
                            EditorGUILayout.EndVertical();
                        }
                        else
                        {
                            EditorGUILayout.LabelField("Invalid Key");
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    // Popup menu  for selecting the next node
                    EditorGUILayout.BeginHorizontal();

                    if (tree.treeNodes[editingIndex].dialogOptions[i].nextNode != null)
                    {
                        if (tree.treeNodes [editingIndex].dialogOptions [i].isEnd)
                        {
                            optionIndices [i] = tree.treeNodes.Count;
                        }
                        else
                        {
                            optionIndices [i] = tree.treeNodes.FindIndex(
                                delegate(DialogNode obj) {
                                return(obj.GID == tree.treeNodes[editingIndex].dialogOptions[i].nextNode);
                            });
                            if (optionIndices [i] == -1)
                            {
                                optionIndices [i] = 0;
                            }
                        }
                    }
                    else
                    {
                        optionIndices[i] = 0;
                    }

                    string[] options = getPopupOptions(true);
                    optionIndices[i] = EditorGUILayout.Popup("Next Node", optionIndices[i], options);

                    // Special case for END node
                    if (optionIndices [i] == tree.treeNodes.Count)
                    {
                        tree.treeNodes [editingIndex].dialogOptions [i].isEnd = true;
                    }
                    else
                    {
                        tree.treeNodes [editingIndex].dialogOptions [i].isEnd    = false;
                        tree.treeNodes [editingIndex].dialogOptions [i].nextNode = tree.treeNodes [optionIndices [i]].GID;
                    }

                    EditorGUILayout.EndHorizontal();

                    if (languageAsset != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Next Node Text Preview", GUILayout.MaxWidth(150));
                        if (!tree.treeNodes [editingIndex].dialogOptions [i].isEnd)
                        {
                            string next_preview = languageAsset.Get(tree.treeNodes [optionIndices [i]].textKey);

                            if (next_preview != null)
                            {
                                EditorGUILayout.BeginVertical();
                                GUIStyle wrap = new GUIStyle();
                                wrap.wordWrap = true;
                                EditorGUILayout.LabelField(next_preview, wrap);
                                EditorGUILayout.EndVertical();
                            }
                            else
                            {
                                EditorGUILayout.LabelField("Invalid Key");
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }


                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Delete Dialog Option", EditorStyles.miniButtonRight, GUILayout.MaxWidth(120)))
                    {
                        optionToDelete = i;
                    }

                    EditorGUILayout.EndHorizontal();

                    if (optionToDelete != -1)
                    {
                        tree.treeNodes [editingIndex].dialogOptions.RemoveAt(optionToDelete);
                        optionCollapse.RemoveAt(optionToDelete);
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add New Dialog Option"))
            {
                DialogOption newOption = new DialogOption();
                tree.treeNodes [editingIndex].dialogOptions.Add(newOption);
                optionCollapse.Add(true);
            }
            EditorGUILayout.EndHorizontal();
        }
    }
Beispiel #36
0
        public static void DrawPresetWindow(int windowID)
        {
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);

            yellowText.normal.textColor = Color.yellow;

            if (WorkingPreset == null)
            {
                SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.ActivePreset), false); //might need to copy instead of assign here
                presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset);
            }

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            //preset selector
            GUILayout.BeginVertical();
            GUILayout.Label("Presets", yellowText, GUILayout.ExpandHeight(false));
            //preset toolbar in a scrollview
            presetScrollView = GUILayout.BeginScrollView(presetScrollView, HighLogic.Skin.textArea, GUILayout.Width(presetPosition.width / 6.0f));
            string[] presetShortNames = KCT_PresetManager.Instance.PresetShortNames(true);
            if (presetIndex == -1)
            {
                SetNewWorkingPreset(null, true);

                /*presetIndex = presetShortNames.Length - 1;
                 * WorkingPreset.name = "Custom";
                 * WorkingPreset.shortName = "Custom";
                 * WorkingPreset.description = "A custom set of configs.";
                 * WorkingPreset.author = HighLogic.SaveFolder;*/
            }
            if (changed && presetIndex < presetShortNames.Length - 1 && !KCT_Utilities.ConfigNodesAreEquivalent(WorkingPreset.AsConfigNode(), KCT_PresetManager.Instance.Presets[presetIndex].AsConfigNode())) //!KCT_PresetManager.Instance.PresetsEqual(WorkingPreset, KCT_PresetManager.Instance.Presets[presetIndex], true)
            {
                SetNewWorkingPreset(null, true);

                /*presetIndex = presetShortNames.Length - 1; //Custom preset
                 * WorkingPreset.name = "Custom";
                 * WorkingPreset.shortName = "Custom";
                 * WorkingPreset.description = "A custom set of configs.";
                 * WorkingPreset.author = HighLogic.SaveFolder;*/
            }

            /* presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset); //Check that the current preset is equal to the expected one
             * if (presetIndex == -1)
             *   presetIndex = presetNames.Length - 1;*/
            int prev = presetIndex;

            presetIndex = GUILayout.SelectionGrid(presetIndex, presetShortNames, 1);
            if (prev != presetIndex) //If a new preset was selected
            {
                if (presetIndex != presetShortNames.Length - 1)
                {
                    SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.Presets[presetIndex]), false);
                }
                else
                {
                    SetNewWorkingPreset(null, true);

                    /*WorkingPreset.name = "Custom";
                     * WorkingPreset.shortName = "Custom";
                     * WorkingPreset.description = "A custom set of configs.";
                     * WorkingPreset.author = HighLogic.SaveFolder;*/
                }
            }

            //presetIndex = GUILayout.Toolbar(presetIndex, presetNames);

            GUILayout.EndScrollView();
            if (GUILayout.Button("Save as\nNew Preset", GUILayout.ExpandHeight(false)))
            {
                //create new preset
                SaveAsNewPreset(WorkingPreset);
            }
            if (WorkingPreset.AllowDeletion && presetIndex != presetShortNames.Length - 1 && GUILayout.Button("Delete Preset")) //allowed to be deleted and isn't Custom
            {
                DialogOption[] options = new DialogOption[2];
                options[0] = new DialogOption("Delete File", DeleteActivePreset);
                options[1] = new DialogOption("Cancel", DummyVoid);
                MultiOptionDialog dialog = new MultiOptionDialog("Are you sure you want to delete the selected Preset, file and all? This cannot be undone!", windowTitle: "Confirm Deletion", options: options);
                PopupDialog.SpawnPopupDialog(dialog, false, HighLogic.Skin);
            }
            GUILayout.EndVertical();

            //Main sections
            GUILayout.BeginVertical();
            presetMainScroll = GUILayout.BeginScrollView(presetMainScroll);
            //Preset info section
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.Label("Preset Name: " + WorkingPreset.name);
            GUILayout.Label("Description: " + WorkingPreset.description);
            GUILayout.Label("Author(s): " + WorkingPreset.author);
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();
            //Features section
            GUILayout.BeginVertical();
            GUILayout.Label("Features", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            WorkingPreset.generalSettings.Enabled                     = GUILayout.Toggle(WorkingPreset.generalSettings.Enabled, "Mod Enabled", HighLogic.Skin.button);
            WorkingPreset.generalSettings.BuildTimes                  = GUILayout.Toggle(WorkingPreset.generalSettings.BuildTimes, "Build Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.ReconditioningTimes         = GUILayout.Toggle(WorkingPreset.generalSettings.ReconditioningTimes, "Launchpad Reconditioning", HighLogic.Skin.button);
            WorkingPreset.generalSettings.TechUnlockTimes             = GUILayout.Toggle(WorkingPreset.generalSettings.TechUnlockTimes, "Tech Unlock Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.KSCUpgradeTimes             = GUILayout.Toggle(WorkingPreset.generalSettings.KSCUpgradeTimes, "KSC Upgrade Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.Simulations                 = GUILayout.Toggle(WorkingPreset.generalSettings.Simulations, "Allow Simulations", HighLogic.Skin.button);
            WorkingPreset.generalSettings.SimulationCosts             = GUILayout.Toggle(WorkingPreset.generalSettings.SimulationCosts, "Simulation Costs", HighLogic.Skin.button);
            WorkingPreset.generalSettings.RequireVisitsForSimulations = GUILayout.Toggle(WorkingPreset.generalSettings.RequireVisitsForSimulations, "Must Visit Planets", HighLogic.Skin.button);
            WorkingPreset.generalSettings.TechUpgrades                = GUILayout.Toggle(WorkingPreset.generalSettings.TechUpgrades, "Upgrades From Tech Tree", HighLogic.Skin.button);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Starting Upgrades:");
            WorkingPreset.generalSettings.StartingPoints = GUILayout.TextField(WorkingPreset.generalSettings.StartingPoints, GUILayout.Width(100));
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndVertical(); //end Features


            GUILayout.BeginVertical(); //Begin time settings
            GUILayout.Label("Time Settings", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Overall Multiplier: ");
            double.TryParse(OMultTmp = GUILayout.TextField(OMultTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.OverallMultiplier);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Build Effect: ");
            double.TryParse(BEffTmp = GUILayout.TextField(BEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.BuildEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Inventory Effect: ");
            double.TryParse(IEffTmp = GUILayout.TextField(IEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.InventoryEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Reconditioning Effect: ");
            double.TryParse(ReEffTmp = GUILayout.TextField(ReEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.ReconditioningEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Max Reocnditioning: ");
            double.TryParse(MaxReTmp = GUILayout.TextField(MaxReTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.MaxReconditioning);
            GUILayout.EndHorizontal();
            GUILayout.Label("Rollout-Reconditioning Split:");
            GUILayout.BeginHorizontal();
            //GUILayout.Label("Rollout", GUILayout.ExpandWidth(false));
            WorkingPreset.timeSettings.RolloutReconSplit = GUILayout.HorizontalSlider((float)Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100f), 0, 100) / 100.0;
            //GUILayout.Label("Recon.", GUILayout.ExpandWidth(false));
            GUILayout.EndHorizontal();
            GUILayout.Label((Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100)) + "% Rollout, " + (100 - Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100)) + "% Reconditioning");
            GUILayout.EndVertical();   //end time settings
            GUILayout.EndVertical();
            GUILayout.EndHorizontal(); //end feature/time setting split

            //begin formula settings
            GUILayout.BeginVertical();
            GUILayout.Label("Formula Settings (Advanced)", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Show/Hide Formulas"))
            {
                showFormula = !showFormula;
            }
            if (GUILayout.Button("View Wiki in Browser"))
            {
                Application.OpenURL("https://github.com/magico13/KCT/wiki");
            }
            GUILayout.EndHorizontal();

            if (showFormula)
            {
                //show half here, half on other side? Or all in one big list
                int textWidth = 350;
                GUILayout.BeginHorizontal();
                GUILayout.Label("NodeFormula: ");
                WorkingPreset.formulaSettings.NodeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.NodeFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeFunds: ");
                WorkingPreset.formulaSettings.UpgradeFundsFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeFundsFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeScience: ");
                WorkingPreset.formulaSettings.UpgradeScienceFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeScienceFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("ResearchFormula: ");
                WorkingPreset.formulaSettings.ResearchFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ResearchFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("EffectivePart: ");
                WorkingPreset.formulaSettings.EffectivePartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.EffectivePartFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("ProceduralPart: ");
                WorkingPreset.formulaSettings.ProceduralPartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ProceduralPartFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("BPFormula: ");
                WorkingPreset.formulaSettings.BPFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BPFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("KSCUpgrade: ");
                WorkingPreset.formulaSettings.KSCUpgradeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.KSCUpgradeFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Reconditioning: ");
                WorkingPreset.formulaSettings.ReconditioningFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ReconditioningFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("BuildRate: ");
                WorkingPreset.formulaSettings.BuildRateFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BuildRateFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("SimCost: ");
                WorkingPreset.formulaSettings.SimCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.SimCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("KerbinSimCost: ");
                WorkingPreset.formulaSettings.KerbinSimCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.KerbinSimCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeReset: ");
                WorkingPreset.formulaSettings.UpgradeResetFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeResetFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("InventorySale: ");
                WorkingPreset.formulaSettings.InventorySaleFormula = GUILayout.TextField(WorkingPreset.formulaSettings.InventorySaleFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("RolloutCosts: ");
                WorkingPreset.formulaSettings.RolloutCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.RolloutCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUILayout.EndVertical(); //end formula settings

            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Save", GUILayout.ExpandWidth(false)))
            {
                KCT_PresetManager.Instance.ActivePreset = WorkingPreset;
                KCT_PresetManager.Instance.SaveActiveToSaveData();
                WorkingPreset = null;
                showSettings  = false;


                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                {
                    KCT_Utilities.DisableModFunctionality();
                }
                //KCT_GameStates.settings.enabledForSave = KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled;
                KCT_GameStates.settings.MaxTimeWarp          = newTimewarp;
                KCT_GameStates.settings.ForceStopWarp        = forceStopWarp;
                KCT_GameStates.settings.DisableAllMessages   = disableAllMsgs;
                KCT_GameStates.settings.OverrideLaunchButton = overrideLaunchBtn;
                KCT_GameStates.settings.Debug                = debug;
                KCT_GameStates.settings.AutoKACAlarms        = autoAlarms;
                KCT_GameStates.settings.PreferBlizzyToolbar  = useBlizzyToolbar;
                KCT_GameStates.settings.CheckForDebugUpdates = debugUpdateChecking;

                KCT_GameStates.settings.Save();
                showSettings = false;
                if (!PrimarilyDisabled && !showFirstRun)
                {
                    ResetBLWindow();
                    if (KCT_Events.instance.KCTButtonStock != null)
                    {
                        KCT_Events.instance.KCTButtonStock.SetTrue();
                    }
                    else
                    {
                        showBuildList = true;
                    }
                }
                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                {
                    InputLockManager.RemoveControlLock("KCTKSCLock");
                }

                for (int j = 0; j < KCT_GameStates.TechList.Count; j++)
                {
                    KCT_GameStates.TechList[j].UpdateBuildRate(j);
                }

                KCT_GUI.ResetFormulaRateHolders();
            }
            if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
            {
                WorkingPreset = null;
                showSettings  = false;
                if (!PrimarilyDisabled && !showFirstRun)
                {
                    ResetBLWindow();
                    if (KCT_Events.instance.KCTButtonStock != null)
                    {
                        KCT_Events.instance.KCTButtonStock.SetTrue();
                    }
                    else
                    {
                        showBuildList = true;
                    }
                }

                for (int j = 0; j < KCT_GameStates.TechList.Count; j++)
                {
                    KCT_GameStates.TechList[j].UpdateBuildRate(j);
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();                       //end column 2

            GUILayout.BeginVertical(GUILayout.Width(100)); //Start general settings
            GUILayout.Label("General Settings", yellowText);
            GUILayout.Label("NOTE: Affects all saves!", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.Label("Max Timewarp");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.ExpandWidth(false)))
            {
                newTimewarp = Math.Max(newTimewarp - 1, 0);
            }
            //current warp setting
            GUILayout.Label(TimeWarp.fetch.warpRates[newTimewarp] + "x");
            if (GUILayout.Button("+", GUILayout.ExpandWidth(false)))
            {
                newTimewarp = Math.Min(newTimewarp + 1, TimeWarp.fetch.warpRates.Length - 1);
            }
            GUILayout.EndHorizontal();

            forceStopWarp     = GUILayout.Toggle(forceStopWarp, "Auto Stop TimeWarp", HighLogic.Skin.button);
            autoAlarms        = GUILayout.Toggle(autoAlarms, "Auto KAC Alarms", HighLogic.Skin.button);
            overrideLaunchBtn = GUILayout.Toggle(overrideLaunchBtn, "Override Launch Button", HighLogic.Skin.button);
            useBlizzyToolbar  = GUILayout.Toggle(useBlizzyToolbar, "Use Toolbar Mod", HighLogic.Skin.button);
            disableAllMsgs    = !GUILayout.Toggle(!disableAllMsgs, "Use Message System", HighLogic.Skin.button);
            debug             = GUILayout.Toggle(debug, "Debug Logging", HighLogic.Skin.button);
#if DEBUG
            debugUpdateChecking = GUILayout.Toggle(debugUpdateChecking, "Check for Dev Updates", HighLogic.Skin.button);
#endif
            GUILayout.EndVertical();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal(); //end main split
            GUILayout.EndVertical();   //end window

            changed = GUI.changed;

            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
            {
                GUI.DragWindow();
            }
        }
 public override void ExplicitVisit(DialogOption fragment)
 {
     _fragments.Add(fragment);
 }
		public static void OnWindow(int WindowID) {
			string title;

			if(GUI.Button(new Rect(windowPos.width - 21, 1, 20, 18), "_", skin.FindStyle("expandButton"))) {
				isVisable = false;
			}

			GUILayout.BeginVertical();

			#region Container Selection
			scrollPos = GUILayout.BeginScrollView(scrollPos, skin.FindStyle("selectBox"), GUILayout.Height(188f), GUILayout.Width(382f));

			foreach(IScienceDataContainer container in vesselSettings.containers) {
				GUILayout.BeginHorizontal();

				if(container.GetScienceCount() > 0) {
					if(GUILayout.Button(vesselSettings.expanded.Contains(container) ? "-" : "+", skin.FindStyle("expandbutton"))) {
						vesselSettings.ExpandOrCollapseContainer(container);

						if(vesselSettings.selectedData != null && container.GetData().Contains(vesselSettings.selectedData)) {
							vesselSettings.selectedData = null;
						}
					}
				}
				else {
					GUILayout.Label("-", skin.FindStyle("expandLabel"));
				}

				if(GUILayout.Button((title = ((PartModule)container).part.partInfo.title).Length > 40 ? (title.Substring(0, 40) + "...") : title, skin.FindStyle(container == vesselSettings.selectedContainer ? "selectButtonDown" : "selectButtonUp"))) {
					if(container == vesselSettings.selectedContainer) {
						vesselSettings.SelectContainer(null);
					}
					else {
						vesselSettings.SelectContainer(container);
					}
				}

				GUILayout.EndHorizontal();

				#region Data Selection

				if(vesselSettings.expanded.Contains(container)) {
					foreach(ScienceData data in container.GetData().OrderBy(d => d.title)) {
						GUILayout.BeginHorizontal();

						GUILayout.Label("\u2514", skin.FindStyle("expandLabel"));
						if(GUILayout.Button((title = data.title).Count() > 40 ? (title.Substring(0, 40) + "...") : title, skin.FindStyle(data == vesselSettings.selectedData ? "selectButtonDown" : "selectButtonUp"))) {

							if(data == vesselSettings.selectedData) {
								vesselSettings.SelectData(null);
							}
							else {
								vesselSettings.SelectData(data);
								UpdateScienceInfo(data);
							}
						}
						GUILayout.EndHorizontal();
					}
				}
				#endregion
			}

			GUILayout.EndScrollView();
			#endregion

			Rect temp = GUILayoutUtility.GetLastRect();

			#region Info

			if(vesselSettings.selectedContainer != null) {
			}
			else if(vesselSettings.selectedData != null) {
				GUILayout.BeginHorizontal();

				#region Data Info
				GUILayout.BeginVertical();

				GUIStyle resultField = skin.FindStyle("resultfield");
				GUIStyle icons = skin.FindStyle("icons");
				GUIStyle iconstext = skin.FindStyle("iconstext");

				GUILayout.BeginHorizontal();
				GUILayout.Label(vesselSettings.selectedData.title);
				if(GUILayout.Button("X", skin.GetStyle("deselectButton"))) {
					vesselSettings.selectedContainer = null;
					vesselSettings.selectedData = null;
				}
				GUILayout.EndHorizontal();

				GUILayout.Box(dataResultText);

				GUILayout.BeginHorizontal(resultField);
				GUILayout.Box(DargonUtils.dataIcon, icons);
				GUILayout.Label(dataSizeText, iconstext);
				GUILayout.EndHorizontal();

				GUILayout.BeginHorizontal(resultField);
				GUILayout.Box(DargonUtils.scienceIcon, icons);
				GUILayout.Label(dataRecoverText, iconstext);
				GUILayout.FlexibleSpace();
				GUIUtil.Layout.ProgressBar(0f, dataValue / dataRefValue, skin.FindStyle("progressBarBG"), skin.FindStyle("progressBarFill"), GUILayout.Width(100f));
				GUIUtil.ProgressBar(GUILayoutUtility.GetLastRect(), 0f, dataValue / dataRefValue - dataValueAfterRec / dataRefValue, skin.FindStyle("progressBarFill2"));
				GUILayout.EndHorizontal();

				GUILayout.BeginHorizontal(resultField);
				GUILayout.Box(DargonUtils.scienceIcon, icons);
				GUILayout.Label(dataXmitText, iconstext);
				GUILayout.FlexibleSpace();
				GUIUtil.Layout.ProgressBar(0f, dataXmitValue / dataRefValue, skin.FindStyle("progressBarBG"), skin.FindStyle("progressBarFill3"), GUILayout.Width(100f));
				GUIUtil.ProgressBar(GUILayoutUtility.GetLastRect(), 0f, dataXmitValue / dataRefValue - dataValueAfterXmit / dataRefValue, skin.FindStyle("progressBarFill4"));
				GUILayout.EndHorizontal();
				GUILayout.EndVertical();
				#endregion

				#region Buttons
				GUILayout.BeginVertical();
				GUILayout.FlexibleSpace();
				GUILayout.Space(5);
				if(GUILayout.Button("", skin.FindStyle(dataContainer.IsRerunnable() ? "discard button" : "reset button"))) {
					Print(vesselSettings.selectedData.title + " dumped.");

					dataContainer.ReviewDataItem(vesselSettings.selectedData);
					ExperimentsResultDialog.Instance.currentPage.OnDiscardData(vesselSettings.selectedData);
					vesselSettings.selectedData = null;
					if(dataContainer.GetData().Length == 0) {
						vesselSettings.CollapseContainer(dataContainer);
					}
				}
				if(GUILayout.Button("", skin.FindStyle("lab button"))) {
					if(ModuleScienceLab.IsLabData(FlightGlobals.ActiveVessel, vesselSettings.selectedData)) {
						Print(vesselSettings.selectedData.title + " is set to be sent to the lab.");

						dataContainer.ReviewDataItem(vesselSettings.selectedData);
						ExperimentsResultDialog.Instance.currentPage.OnSendToLab(vesselSettings.selectedData);
						vesselSettings.selectedData = null;
						if(dataContainer.GetData().Length == 0) {
							vesselSettings.CollapseContainer(dataContainer);
						}
					}
					else {
						Print(vesselSettings.selectedData.title + " is not lab data.");
					}
				}
				GUILayout.Space(5);
				if(GUILayout.Button((dataXmitValue / dataRefValue * 100f) + "%", skin.FindStyle("transmit button"))) {
					Print(vesselSettings.selectedData.title + " is set to be transmitted.");

					dataContainer.ReviewDataItem(vesselSettings.selectedData);
					ExperimentsResultDialog.Instance.currentPage.OnTransmitData(vesselSettings.selectedData);
					vesselSettings.selectedData = null;
					if(dataContainer.GetData().Length == 0) {
						vesselSettings.CollapseContainer(dataContainer);
					}
				}
				GUILayout.Space(5);
				if(GUILayout.Button("", skin.FindStyle("transferButton"))) {
					Print(vesselSettings.selectedData.title + " is set to be transfered.");

					int i = 0;
					Callback<ScienceHardDrive> driveSelectCallback = new Callback<ScienceHardDrive>(DriveSelectCallback);
					DialogOption<ScienceHardDrive>[] dialogOptions = new DialogOption<ScienceHardDrive>[vesselSettings.containers.Where(c => c is ScienceHardDrive).Count() + 1];

					foreach(ScienceHardDrive d in vesselSettings.containers.Where(c => c is ScienceHardDrive).ToArray()) {
						dialogOptions[i++] = new DialogOption<ScienceHardDrive>(d.part.partInfo.title, driveSelectCallback, d);
					}
					dialogOptions[i] = new DialogOption<ScienceHardDrive>("Cancel", driveSelectCallback, null);

					PopupDialog.SpawnPopupDialog(new MultiOptionDialog("Select which drive to transfer ScienceData to.", "", HighLogic.Skin, dialogOptions), false, HighLogic.Skin);
				}
				GUILayout.FlexibleSpace();
				GUILayout.EndVertical();
				#endregion

				GUILayout.EndHorizontal();
			}
			else {
			}

			#endregion

			GUILayout.EndVertical();

			GUI.DragWindow();

		}
		protected static void DriveSelectCallback(ScienceHardDrive drive) {
			if(drive != null) {
				IScienceDataContainer container = vesselSettings.containers.First(c => ((PartModule)c).part.flightID == vesselSettings.selectedData.container);

				if(container.IsRerunnable()) {
					QueueManager.instance.QueueDataForXfer(drive, container, vesselSettings.selectedData);
					vesselSettings.selectedData = null;
				}
				else {
					Callback<ScienceHardDrive> xferAnywaysCallback = new Callback<ScienceHardDrive>(XferAnywaysCallback);

					DialogOption<ScienceHardDrive>[] dialogOptions = new DialogOption<ScienceHardDrive>[2];
					dialogOptions[0] = new DialogOption<ScienceHardDrive>("Transfer Anyways", xferAnywaysCallback, drive);
					dialogOptions[1] = new DialogOption<ScienceHardDrive>("Abort Transfer", xferAnywaysCallback, null);
					PopupDialog.SpawnPopupDialog(new MultiOptionDialog("Transfering science from a nonrerunnable experiment will cause it to become inoperable.", "Warning", HighLogic.Skin, dialogOptions), false, HighLogic.Skin);
				}
			}
			else {
				Print("Transfer canceled.");
			}
		}
Beispiel #40
0
 private void noOp(DialogOption obj)
 {
 }
Beispiel #41
0
        public static void DrawBuildListWindow(int windowID)
        {
            if (buildListWindowPosition.xMax > Screen.width)
            {
                buildListWindowPosition.x = Screen.width - buildListWindowPosition.width;
            }

            //GUI.skin = HighLogic.Skin;
            GUIStyle redText = new GUIStyle(GUI.skin.label);

            redText.normal.textColor = Color.red;
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);

            yellowText.normal.textColor = Color.yellow;
            GUIStyle greenText = new GUIStyle(GUI.skin.label);

            greenText.normal.textColor = Color.green;

            int width1 = 120;
            int width2 = 100;
            int butW   = 20;

            GUILayout.BeginVertical();
            //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName);
            //List next vessel to finish
            GUILayout.BeginHorizontal();
            GUILayout.Label("Next:", windowSkin.label);
            IKCTBuildItem buildItem = KCT_Utilities.NextThingToFinish();

            if (buildItem != null)
            {
                //KCT_BuildListVessel ship = (KCT_BuildListVessel)buildItem;
                GUILayout.Label(buildItem.GetItemName());
                if (buildItem.GetListType() == KCT_BuildListVessel.ListType.VAB || buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning)
                {
                    GUILayout.Label("VAB", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.SPH)
                {
                    GUILayout.Label("SPH", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.TechNode)
                {
                    GUILayout.Label("Tech", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.KSC)
                {
                    GUILayout.Label("KSC", windowSkin.label);
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));
                }

                if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button("Warp to" + System.Environment.NewLine + "Complete"))
                {
                    KCT_GameStates.targetedItem = buildItem;
                    KCT_GameStates.canWarp      = true;
                    KCT_Utilities.RampUpWarp();
                    KCT_GameStates.warpInitiated = true;
                }
                else if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex > 0 && GUILayout.Button("Stop" + System.Environment.NewLine + "Warp"))
                {
                    KCT_GameStates.canWarp = false;
                    TimeWarp.SetRate(0, true);
                    KCT_GameStates.lastWarpRate = 0;
                }

                if (KCT_GameStates.settings.AutoKACAlarams && KACWrapper.APIReady)
                {
                    double UT = Planetarium.GetUniversalTime();
                    if (!KCT_Utilities.ApproximatelyEqual(KCT_GameStates.KACAlarmUT - UT, buildItem.GetTimeLeft()))
                    {
                        KCTDebug.Log("KAC Alarm being created!");
                        KCT_GameStates.KACAlarmUT = (buildItem.GetTimeLeft() + UT);
                        KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KCT_GameStates.KACAlarmId);
                        if (alarm == null)
                        {
                            alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => (a.Name.StartsWith("KCT: ")));
                        }
                        if (alarm != null)
                        {
                            KCTDebug.Log("Removing existing alarm");
                            KACWrapper.KAC.DeleteAlarm(alarm.ID);
                        }
                        KCT_GameStates.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "KCT: " + buildItem.GetItemName() + " Complete", KCT_GameStates.KACAlarmUT);
                        KCTDebug.Log("Alarm created with ID: " + KCT_GameStates.KACAlarmId);
                    }
                }
            }
            else
            {
                GUILayout.Label("No Active Projects");
            }
            GUILayout.EndHorizontal();

            //Buttons for VAB/SPH lists
            List <string> buttonList = new List <string> {
                "VAB", "SPH", "KSC"
            };

            if (KCT_Utilities.CurrentGameHasScience() && !KCT_GameStates.settings.InstantTechUnlock)
            {
                buttonList.Add("Tech");
            }
            GUILayout.BeginHorizontal();
            //if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { buttonList.Add("Upgrades"); buttonList.Add("Settings"); }
            int lastSelected = listWindow;

            listWindow = GUILayout.Toolbar(listWindow, buttonList.ToArray());

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Upgrades"))
            {
                showUpgradeWindow = true;
                showBuildList     = false;
                showBLPlus        = false;
            }
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Settings"))
            {
                showBuildList = false;
                showBLPlus    = false;
                ShowSettings();
            }
            GUILayout.EndHorizontal();

            if (GUI.changed)
            {
                buildListWindowPosition.height = 1;
                showBLPlus = false;
                if (lastSelected == listWindow)
                {
                    listWindow = -1;
                }
            }
            //Content of lists
            if (listWindow == 0) //VAB Build List
            {
                List <KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.VABList;
                GUILayout.BeginHorizontal();
                //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                if (KCT_Utilities.ReconditioningActive(null))
                {
                    GUILayout.BeginHorizontal();
                    IKCTBuildItem item = (IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning();
                    GUILayout.Label(item.GetItemName());
                    GUILayout.Label(KCT_GameStates.ActiveKSC.GetReconditioning().ProgressPercent().ToString() + "%", GUILayout.Width(width1 / 2));
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(item.GetTimeLeft()), GUILayout.Width(width2));
                    //GUILayout.Label(Math.Round(KCT_GameStates.ActiveKSC.GetReconditioning().BP, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width((butW + 4) * 2)))
                    {
                        KCT_GameStates.targetedItem = item;
                        KCT_GameStates.canWarp      = true;
                        KCT_Utilities.RampUpWarp(item);
                        KCT_GameStates.warpInitiated = true;
                    }
                    //GUILayout.Space((butW + 4) * 3);
                    GUILayout.EndHorizontal();
                }

                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the VAB to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        GUILayout.BeginHorizontal();
                        //GUILayout.Label(b.shipName, GUILayout.Width(width1));

                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                            {
                                showBLPlus = !showBLPlus;
                            }
                            else
                            {
                                showBLPlus = true;
                            }
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogOption[] options = new DialogOption[2];
                                options[0] = new DialogOption("Yes", ScrapVessel);
                                options[1] = new DialogOption("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options);
                                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                            //      GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                            //      GUILayout.Space(butW + 4);
                        }


                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        }
                        else
                        {
                            GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.VAB, null)), GUILayout.Width(width2));
                        }
                        // GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    //ADD Storage here!
                    buildList = KCT_GameStates.ActiveKSC.VABWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("VAB Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        KCT_GameStates.recoveredVessel            = new KCT_BuildListVessel(FlightGlobals.ActiveVessel);
                        KCT_GameStates.recoveredVessel.type       = KCT_BuildListVessel.ListType.VAB;
                        KCT_GameStates.recoveredVessel.launchSite = "LaunchPad";
                        // HighLogic.LoadScene(GameScenes.SPACECENTER);
                        //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState);
                        GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel);
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }
                    KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout);
                    //KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback);
                    bool rolloutEnabled = KCT_GameStates.settings.Reconditioning && KCT_GameStates.timeSettings.RolloutReconSplit > 0;
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b           = buildList[i];
                        KCT_Recon_Rollout   rollback    = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback);
                        KCT_Recon_Rollout   recovery    = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        GUIStyle            textColor   = new GUIStyle(GUI.skin.label);
                        GUIStyle            buttonColor = new GUIStyle(GUI.skin.button);
                        string status = "In Storage";
                        if (rollout != null && rollout.associatedID == b.id.ToString())
                        {
                            status    = "Rolling Out";
                            textColor = yellowText;
                            if (rollout.AsBuildItem().IsComplete())
                            {
                                status    = "On the Pad";
                                textColor = greenText;
                            }
                        }
                        else if (rollback != null)
                        {
                            status    = "Rolling Back";
                            textColor = yellowText;
                        }
                        else if (recovery != null)
                        {
                            status    = "Recovering";
                            textColor = redText;
                        }

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && status == "In Storage")
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                {
                                    showBLPlus = !showBLPlus;
                                }
                                else
                                {
                                    showBLPlus = true;
                                }
                                IDSelected = b.id;
                            }
                        }
                        else
                        {
                            GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName, textColor);
                        GUILayout.Label(status + "   ", textColor, GUILayout.ExpandWidth(false));
                        if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && (rollout == null || b.id.ToString() != rollout.associatedID) && rollback == null && GUILayout.Button("Rollout", GUILayout.ExpandWidth(false)))
                        {
                            if (rollout != null)
                            {
                                rollout.SwapRolloutType();
                            }
                            KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(b, KCT_Recon_Rollout.RolloutReconType.Rollout, b.id.ToString()));
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollout != null && b.id.ToString() == rollout.associatedID && !rollout.AsBuildItem().IsComplete() && rollback == null &&
                                 GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollout.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)))
                        {
                            rollout.SwapRolloutType();
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollback != null && b.id.ToString() == rollback.associatedID && !rollback.AsBuildItem().IsComplete())
                        {
                            if (rollout == null)
                            {
                                if (GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)))
                                {
                                    rollback.SwapRolloutType();
                                }
                            }
                            else
                            {
                                GUILayout.Label(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                            }
                        }
                        else if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && (!rolloutEnabled || (rollout != null && b.id.ToString() == rollout.associatedID && rollout.AsBuildItem().IsComplete())))
                        {
                            if (rolloutEnabled && GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Roll Back", GUILayout.ExpandWidth(false)))
                            {
                                rollout.SwapRolloutType();
                            }
                            else if (!GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Launch", GUILayout.ExpandWidth(false)))
                            {
                                bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);//new PreFlightTests.FacilityOperational("LaunchPad", "building").Test();
                                if (!operational)
                                {
                                    ScreenMessages.PostScreenMessage("You must repair the launchpad prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                }
                                else if (KCT_Utilities.ReconditioningActive(null))
                                {
                                    //can't launch now
                                    ScreenMessage message = new ScreenMessage("[KCT] Cannot launch while LaunchPad is being reconditioned. It will be finished in "
                                                                              + KCT_Utilities.GetFormattedTime(((IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning()).GetTimeLeft()), 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                    ScreenMessages.PostScreenMessage(message, true);
                                }
                                else
                                {
                                    /*if (rollout != null)
                                     *  KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout);*/
                                    KCT_GameStates.launchedVessel = b;
                                    if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "LaunchPad").Count == 0)//  ShipConstruction.CheckLaunchSiteClear(HighLogic.CurrentGame.flightState, "LaunchPad", false))
                                    {
                                        showBLPlus = false;
                                        // buildList.RemoveAt(i);
                                        if (!IsCrewable(b.ExtractedParts))
                                        {
                                            b.Launch();
                                        }
                                        else
                                        {
                                            showBuildList = false;
                                            centralWindowPosition.height = 1;
                                            KCT_GameStates.launchedCrew.Clear();
                                            parts       = KCT_GameStates.launchedVessel.ExtractedParts;
                                            pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                            KCT_GameStates.launchedCrew = new List <CrewedPart>();
                                            foreach (PseudoPart pp in pseudoParts)
                                            {
                                                KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List <ProtoCrewMember>()));
                                            }
                                            CrewFirstAvailable();
                                            showShipRoster = true;
                                        }
                                    }
                                    else
                                    {
                                        showBuildList   = false;
                                        showClearLaunch = true;
                                    }
                                }
                            }
                        }
                        else if (!HighLogic.LoadedSceneIsEditor && recovery != null)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 1) //SPH Build List
            {
                List <KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.SPHList;
                GUILayout.BeginHorizontal();
                //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the SPH to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                            {
                                showBLPlus = !showBLPlus;
                            }
                            else
                            {
                                showBLPlus = true;
                            }
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogOption[] options = new DialogOption[2];
                                options[0] = new DialogOption("Yes", ScrapVessel);
                                options[1] = new DialogOption("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap " + b.shipName + "?", windowTitle: "Scrap Vessel", options: options);
                                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                            //          GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                            //         GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        }
                        else
                        {
                            GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.SPH, null)), GUILayout.Width(width2));
                        }
                        //GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    buildList = KCT_GameStates.ActiveKSC.SPHWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("SPH Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        KCT_GameStates.recoveredVessel            = new KCT_BuildListVessel(FlightGlobals.ActiveVessel);
                        KCT_GameStates.recoveredVessel.type       = KCT_BuildListVessel.ListType.SPH;
                        KCT_GameStates.recoveredVessel.launchSite = "Runway";
                        //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState);
                        GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel);
                    }

                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b      = buildList[i];
                        string            status   = "";
                        KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        if (recovery != null)
                        {
                            status = "Recovering";
                        }

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && status == "")
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                {
                                    showBLPlus = !showBLPlus;
                                }
                                else
                                {
                                    showBLPlus = true;
                                }
                                IDSelected = b.id;
                            }
                        }
                        else
                        {
                            GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(status + "   ", GUILayout.ExpandWidth(false));
                        //ScenarioDestructibles.protoDestructibles["KSCRunway"].
                        if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && GUILayout.Button("Launch", GUILayout.ExpandWidth(false)))
                        {
                            bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.SPH);//new PreFlightTests.FacilityOperational("Runway", "building").Test();
                            if (!operational)
                            {
                                ScreenMessages.PostScreenMessage("You must repair the runway prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                            }
                            else
                            {
                                showBLPlus = false;
                                KCT_GameStates.launchedVessel = b;
                                if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0)
                                {
                                    if (!IsCrewable(b.ExtractedParts))
                                    {
                                        b.Launch();
                                    }
                                    else
                                    {
                                        showBuildList = false;
                                        centralWindowPosition.height = 1;
                                        KCT_GameStates.launchedCrew.Clear();
                                        parts       = KCT_GameStates.launchedVessel.ExtractedParts;
                                        pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                        KCT_GameStates.launchedCrew = new List <CrewedPart>();
                                        foreach (PseudoPart pp in pseudoParts)
                                        {
                                            KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List <ProtoCrewMember>()));
                                        }
                                        CrewFirstAvailable();
                                        showShipRoster = true;
                                    }
                                }
                                else
                                {
                                    showBuildList   = false;
                                    showClearLaunch = true;
                                }
                            }
                        }
                        else if (recovery != null)
                        {
                            GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }
                        GUILayout.EndHorizontal();
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 2) //KSC things
            {
                List <KCT_UpgradingBuilding> KSCList = KCT_GameStates.ActiveKSC.KSCTech;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width1));
                GUILayout.Space(70);
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                if (KSCList.Count == 0)
                {
                    GUILayout.Label("No upgrade projects are currently underway.");
                }
                foreach (KCT_UpgradingBuilding KCTTech in KSCList)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(KCTTech.AsIKCTBuildItem().GetItemName());
                    GUILayout.Label(Math.Round(100 * KCTTech.progress / KCTTech.BP, 2) + " %", GUILayout.Width(width1 / 2));
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(KCTTech.AsIKCTBuildItem().GetTimeLeft()), GUILayout.Width(width1));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70)))
                    {
                        KCT_GameStates.targetedItem = KCTTech;
                        KCT_GameStates.canWarp      = true;
                        KCT_Utilities.RampUpWarp(KCTTech);
                        KCT_GameStates.warpInitiated = true;
                    }
                    else if (HighLogic.LoadedSceneIsEditor)
                    {
                        GUILayout.Space(70);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 3) //Tech nodes
            {
                List <KCT_TechItem> techList = KCT_GameStates.TechList;
                //GUILayout.Label("Tech Node Research");
                GUILayout.BeginHorizontal();
                GUILayout.Label("Node Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width1));
                GUILayout.Space(70);
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                if (techList.Count == 0)
                {
                    GUILayout.Label("No tech nodes are being researched!\nBegin research by unlocking tech in the R&D building.");
                }
                for (int i = 0; i < techList.Count; i++)
                {
                    KCT_TechItem t = techList[i];
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(t.techName);
                    GUILayout.Label(Math.Round(100 * t.progress / t.scienceCost, 2) + " %", GUILayout.Width(width1 / 2));
                    GUILayout.Label(KCT_Utilities.GetColonFormattedTime(t.TimeLeft), GUILayout.Width(width1));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70)))
                    {
                        KCT_GameStates.targetedItem = t;
                        KCT_GameStates.canWarp      = true;
                        KCT_Utilities.RampUpWarp(t);
                        KCT_GameStates.warpInitiated = true;
                    }
                    else if (HighLogic.LoadedSceneIsEditor)
                    {
                        GUILayout.Space(70);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
            }

            if (KCT_UpdateChecker.UpdateFound)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Version: " + KCT_UpdateChecker.CurrentVersion);
                GUILayout.Label("Latest: " + KCT_UpdateChecker.WebVersion);
                GUILayout.EndHorizontal();
            }

            if (KCT_SpecialSurpriseInside.instance.activated)
            {
                GUILayout.BeginHorizontal();
                //jeb coin img, jeb coin amt, store button, daily challenge, SRB races
                GUILayout.Label(KCT_SpecialSurpriseInside.instance.jebCoinTex, GUILayout.ExpandWidth(false));
                if (GUILayout.Button(" Jeb Coins: " + KCT_SpecialSurpriseInside.instance.TotalJebCoins, GUILayout.ExpandWidth(false)))
                {
                    KCT_SpecialSurpriseInside.instance.JebCoinStore();
                }
                GUILayout.Label("");
                if (GUILayout.Button("Daily Challenge", GUILayout.ExpandWidth(false)))
                {
                    KCT_SpecialSurpriseInside.instance.DailyChallengePopup();
                }
                GUILayout.Label("");
                if (GUILayout.Button("Race SRBs", GUILayout.ExpandWidth(false)))
                {
                    KCT_SpecialSurpriseInside.instance.showRace = true;
                    showBuildList = false;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }
Beispiel #42
0
        //Maak een eigen DateTimeDialog
        private void ShowDateTimeDialog(string title, DialogOption timeOption)
        {
            //Initialisatie en design voor de dialog
            Form prompt = new Form();
            prompt.Width = 250;
            prompt.Height = 200;
            prompt.Text = title;
            Label textLabel = new Label() { Left = 10, Top = 20, Text = title };
            DateTimePicker datePicker = new DateTimePicker() { Left = 10, Top = 50 };
            DateTimePicker timePicker = new DateTimePicker() { Left = 10, Top = 80 };
            timePicker.Format = DateTimePickerFormat.Time;
            timePicker.ShowUpDown = true;

            //Wanneer starttime is geselecteerd, verander de schermgegevens naar de modelgegevens
            if (timeOption == DialogOption.START_TIME) {
                datePicker.MinDate = DateTime.Now;
                datePicker.Value = Model.LocallyEditedExam.Starttime;
                timePicker.Value = Model.LocallyEditedExam.Starttime;
            }
            //Wanneer endtime is geselecteerd, verander de schermgegevens naar de modelgegevens
            else if (timeOption == DialogOption.END_TIME) {
                datePicker.MinDate = Model.LocallyEditedExam.Starttime;
                datePicker.Value = Model.LocallyEditedExam.Endtime;
                timePicker.Value = Model.LocallyEditedExam.Endtime;
            }

            //Wanneer er op OK is geklikt
            Button confirmation = new Button() { Text = "OK", Left = 10, Width = 100, Top = 110 };
            confirmation.Click += (sender, e) => {
                DateTime newDate = datePicker.Value.Date + timePicker.Value.TimeOfDay;
                //Check of de einddatum klopt
                if (timeOption == DialogOption.START_TIME) {
                    if (newDate > Model.LocallyEditedExam.Endtime || newDate < DateTime.Now) {
                        MessageBox.Show("Ongeldige datum");
                    }
                    else {
                        Model.LocallyEditedExam.Starttime = newDate;
                        prompt.Close();
                    }
                }
                //Check of de startdatum klopt
                else if (timeOption == DialogOption.END_TIME) {
                    if (newDate < Model.LocallyEditedExam.Starttime) {
                        MessageBox.Show("Ongeldige datum");
                    }
                    else {
                        Model.LocallyEditedExam.Endtime = newDate;
                        prompt.Close();
                    }
                }
                //Werk de gegevens bij
                UpdateView();
            };

            //Voeg de controls toe aan de prompt en laat hierna de dialog zien.
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(datePicker);
            prompt.Controls.Add(timePicker);
            prompt.ShowDialog();
        }
Beispiel #43
0
        private static void DrawBLPlusWindow(int windowID)
        {
            //bLPlusPosition.xMax = buildListWindowPosition.xMin;
            //bLPlusPosition.width = 100;
            bLPlusPosition.yMin   = buildListWindowPosition.yMin;
            bLPlusPosition.height = 225;
            //bLPlusPosition.height = bLPlusPosition.yMax - bLPlusPosition.yMin;
            KCT_BuildListVessel b = KCT_Utilities.FindBLVesselByID(IDSelected);

            GUILayout.BeginVertical();
            if (GUILayout.Button("Scrap"))
            {
                InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "KCTPopupLock");
                DialogOption[] options = new DialogOption[2];
                options[0] = new DialogOption("Yes", ScrapVessel);
                options[1] = new DialogOption("No", DummyVoid);
                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options);
                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                showBLPlus = false;
                ResetBLWindow();
            }
            if (GUILayout.Button("Edit"))
            {
                showBLPlus = false;
                editorWindowPosition.height = 1;
                string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp.craft";
                b.shipNode.Save(tempFile);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                KCT_GameStates.editedVessel          = b;
                KCT_GameStates.EditorShipEditingMode = true;
                KCT_GameStates.delayStart            = true;

                InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LOAD, "KCTEditLoad");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTEditLaunch");

                KCT_GameStates.EditedVesselParts.Clear();
                foreach (ConfigNode node in b.ExtractedPartNodes)
                {
                    string name = KCT_Utilities.PartNameFromNode(node) + KCT_Utilities.GetTweakScaleSize(node);
                    if (!KCT_GameStates.EditedVesselParts.ContainsKey(name))
                    {
                        KCT_GameStates.EditedVesselParts.Add(name, 1);
                    }
                    else
                    {
                        ++KCT_GameStates.EditedVesselParts[name];
                    }
                }

                //EditorDriver.StartAndLoadVessel(tempFile);
                EditorDriver.StartAndLoadVessel(tempFile, b.type == KCT_BuildListVessel.ListType.VAB ? EditorFacility.VAB : EditorFacility.SPH);
            }
            if (GUILayout.Button("Rename"))
            {
                centralWindowPosition.width  = 360;
                centralWindowPosition.x      = (Screen.width - 360) / 2;
                centralWindowPosition.height = 1;
                showBuildList = false;
                showBLPlus    = false;
                showRename    = true;
                newName       = b.shipName;
                //newDesc = b.getShip().shipDescription;
            }
            if (GUILayout.Button("Duplicate"))
            {
                KCT_Utilities.AddVesselToBuildList(b.NewCopy(true), b.InventoryParts.Count > 0);
            }
            if (KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()) != null && GUILayout.Button("Rollback"))
            {
                KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()).SwapRolloutType();
            }
            if (!b.isFinished && GUILayout.Button("Warp To"))
            {
                KCT_GameStates.targetedItem = b;
                KCT_GameStates.canWarp      = true;
                KCT_Utilities.RampUpWarp(b);
                KCT_GameStates.warpInitiated = true;
                showBLPlus = false;
            }
            if (!b.isFinished && GUILayout.Button("Move to Top"))
            {
                if (b.type == KCT_BuildListVessel.ListType.VAB)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.VABList.Insert(0, b);
                }
                else if (b.type == KCT_BuildListVessel.ListType.SPH)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.SPHList.Insert(0, b);
                }
            }
            if (!b.isFinished && GUILayout.Button("Rush Build 10%\n√" + Math.Round(0.2 * b.GetTotalCost())))
            {
                double cost = b.GetTotalCost();
                cost *= 0.2;
                double remainingBP = b.buildPoints - b.progress;
                if (Funding.Instance.Funds >= cost)
                {
                    b.AddProgress(remainingBP * 0.1);
                    KCT_Utilities.SpendFunds(cost, TransactionReasons.None);
                }
            }
            if (GUILayout.Button("Close"))
            {
                showBLPlus = false;
            }
            GUILayout.EndVertical();
            float width = bLPlusPosition.width;

            bLPlusPosition.x     = buildListWindowPosition.x - width;
            bLPlusPosition.width = width;
        }
        private void ApplyDefaults(DialogOption[] options)
        {
            this.OkButtonDefault     = false;
            this.CloseButtonDefault  = false;
            this.CancelButtonDefault = false;
            this.YesButtonDefault    = false;
            this.NoButtonDefault     = false;

            if (options is null || options.Length < 1)
            {
                switch (this.Buttons)
                {
                case DialogButton.OkCancel:
                case DialogButton.YesNoCancel:
                    this.CancelButtonDefault = true;
                    return;

                case DialogButton.OkClose:
                    this.CloseButtonDefault = true;
                    return;

                case DialogButton.YesNo:
                    this.NoButtonDefault = true;
                    return;
                }

                if (this.Buttons.HasFlag(DialogButton.Cancel))
                {
                    this.CancelButtonDefault = true;
                    return;
                }

                if (this.Buttons.HasFlag(DialogButton.Close))
                {
                    this.CloseButtonDefault = true;
                    return;
                }

                if (this.Buttons.HasFlag(DialogButton.No))
                {
                    this.NoButtonDefault = true;
                    return;
                }

                return;
            }

            DialogOption option = options.Where(x => x.IsDefault).FirstOrDefault();

            if (option is null)
            {
                return;
            }

            switch (option.Button)
            {
            case DialogButton.Ok:
                this.OkButtonDefault = true;
                return;

            case DialogButton.Yes:
                this.YesButtonDefault = true;
                return;

            case DialogButton.No:
                this.NoButtonDefault = true;
                return;

            case DialogButton.Close:
                this.CloseButtonDefault = true;
                return;

            case DialogButton.Cancel:
                this.CancelButtonDefault = true;
                return;
            }
        }
Beispiel #45
0
        protected void DrawMainGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(250)); //offered/active list
            int oldStatus = offeredActiveToolbar;
            offeredActiveToolbar = GUILayout.Toolbar(offeredActiveToolbar, new string[] { "Offered", "Active" });
            if (offeredActiveToolbar != oldStatus)
            {
                selectedCourse = null;
            }
            offeredActiveScroll = GUILayout.BeginScrollView(offeredActiveScroll);
            if (offeredActiveToolbar == 0) //offered list
            {
                foreach (CourseTemplate template in FlightSchool.Instance.OfferedCourses)
                {
                    if (GUILayout.Button(template.id + " - " + template.name))
                    {
                        selectedCourse = new ActiveCourse(template);
                        totalCost = selectedCourse.CalculateCost();
                    }
                }
            }
            else //active list
            {
                foreach (ActiveCourse course in FlightSchool.Instance.ActiveCourses)
                {
                    if (GUILayout.Button(course.id + " - " + course.name)) //show percent complete?
                    {
                        selectedCourse = course;
                    }
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUILayout.BeginVertical(); //Selected info
            if (offeredActiveToolbar == 0)
            {
                if (selectedCourse != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(selectedCourse.id + " - " + selectedCourse.name);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.Label(selectedCourse.description);

					GUILayout.Label("Course length: " /*+ MagiCore.Utilities.GetFormattedTime(selectedCourse.time, true)*/);  //Likely from an older version of MagiCore.  It may have been merge in recently.

                    //select the teacher
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Teacher: " + (selectedCourse.Teacher != null ? (selectedCourse.Teacher.name+" ("+selectedCourse.Teacher.trait+" "+selectedCourse.Teacher.experienceLevel+")" ) : "Guest Lecturer"), GUILayout.ExpandWidth(false)))
                    {
                        //select a teacher
                        List<ProtoCrewMember> validTeachers = new List<ProtoCrewMember>();
                        foreach (ProtoCrewMember pcm in HighLogic.CurrentGame.CrewRoster.Crew)
                        {
                            if (selectedCourse.MeetsTeacherReqs(pcm))
                                validTeachers.Add(pcm);
                        }

                        DialogOption[] options = new DialogOption[validTeachers.Count+1];
                        for (int i=0; i< validTeachers.Count; i++)
                        {
                            ProtoCrewMember pcm = validTeachers[i];
                            options[i] = new DialogOption(pcm.name + ": " + pcm.trait + " " + pcm.experienceLevel, () => { selectedCourse.SetTeacher(pcm); totalCost = selectedCourse.CalculateCost(); });
                        }
                        options[validTeachers.Count] = new DialogOption("Guest Lecturer", () => { selectedCourse.Teacher = null; totalCost = selectedCourse.CalculateCost(); });
                        MultiOptionDialog diag = new MultiOptionDialog("Select a kerbal to lead this course:", "Select Teacher", null, options);
                        PopupDialog.SpawnPopupDialog(diag, false, GUI.skin);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    //select the kerbals. Two lists, the current Students and the available ones
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(250));
                    GUILayout.Label("Enrolled:");
                    currentStudentList = GUILayout.BeginScrollView(currentStudentList);
                    for (int i = 0; i < selectedCourse.Students.Count; i++ )
                    {
                        ProtoCrewMember student = selectedCourse.Students[i];
                        if (GUILayout.Button(student.name+": "+student.trait+" "+student.experienceLevel))
                        {
                            selectedCourse.Students.RemoveAt(i);
                            i--;
                            totalCost = selectedCourse.CalculateCost();
                        }

                    }
                    GUILayout.EndScrollView();
                    if (selectedCourse.seatMax > 0)
                    {
                        GUILayout.Label(selectedCourse.seatMax - selectedCourse.Students.Count + " remaining seat(s).");
                    }
                    if (selectedCourse.seatMin > 0)
                    {
                        GUILayout.Label(Math.Max(0, selectedCourse.seatMin - selectedCourse.Students.Count) + " student(s) required.");
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(250));
                    GUILayout.Label("Available:");
                    availableKerbalList = GUILayout.BeginScrollView(availableKerbalList);
                    for (int i = 0; i < HighLogic.CurrentGame.CrewRoster.Count; i++)
                    {
                        ProtoCrewMember student = HighLogic.CurrentGame.CrewRoster[i];
                        if (selectedCourse.MeetsStudentReqs(student))
                        {
                            if (GUILayout.Button(student.name + ": " + student.trait + " " + student.experienceLevel))
                            {
                                selectedCourse.AddStudent(student);
                                totalCost = selectedCourse.CalculateCost();
                            }
                        }

                    }
                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();

                    //double totalCost = selectedCourse.costBase + (selectedCourse.costTeacher * (selectedCourse.Teacher != null ? 0 : 1)) + (selectedCourse.Students.Count * selectedCourse.costSeat);


                    
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Start Course: √"+Math.Ceiling(totalCost), GUILayout.ExpandWidth(false)))
                    {
                        selectedCourse.StartCourse();
                        FlightSchool.Instance.ActiveCourses.Add(selectedCourse);
                        selectedCourse = null;
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                }
            }
            else
            {
                //An active course has been selected
                if (selectedCourse != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(selectedCourse.id + " - " + selectedCourse.name);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.Label(selectedCourse.description);

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("Teacher: " + (selectedCourse.Teacher != null ? (selectedCourse.Teacher.name + " (" + selectedCourse.Teacher.trait + " " + selectedCourse.Teacher.experienceLevel + ")") : "Guest Lecturer"), GUILayout.ExpandWidth(false));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.Label("Time remaining: "/*+MagiCore.Utilities.GetFormattedTime(selectedCourse.time-selectedCourse.elapsedTime, true)*/);  //Read what was ststed above
                    GUILayout.Label(Math.Round(100*selectedCourse.elapsedTime/selectedCourse.time, 1) + "% complete");

                    //scroll list of all students
                    GUILayout.Label("Students:");
                    currentStudentList = GUILayout.BeginScrollView(currentStudentList);
                    for (int i = 0; i < selectedCourse.Students.Count; i++ )
                    {
                        ProtoCrewMember student = selectedCourse.Students[i];
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(student.name+": "+student.trait+" "+student.experienceLevel);
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            DialogOption[] options = new DialogOption[2];
                            options[0] = new DialogOption("Yes", () => {selectedCourse.Students.Remove(student); student.rosterStatus = ProtoCrewMember.RosterStatus.Available;});
                            options[1] = new DialogOption("No", ()=>{});

                            MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want "+student.name+ " to drop this course?", "Drop Course?", null, options);
                            PopupDialog.SpawnPopupDialog(diag, false, GUI.skin);

                            i--;
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndScrollView();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Cancel Course", GUILayout.ExpandWidth(false)))
                    {
                        DialogOption[] options = new DialogOption[2];
                        options[0] = new DialogOption("Yes", () => { selectedCourse.CompleteCourse(); FlightSchool.Instance.ActiveCourses.Remove(selectedCourse); selectedCourse = null; });
                        options[1] = new DialogOption("No", ()=>{});

                        MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to cancel this course?", "Cancel Course?", null, options);
                        PopupDialog.SpawnPopupDialog(diag, false, GUI.skin);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
                GUI.DragWindow();
        }
        /// <summary>
        /// Loads the contract group details from the given config node.
        /// </summary>
        /// <param name="configNode">The config node to load from</param>
        /// <returns>Whether we were successful.</returns>
        public bool Load(ConfigNode configNode)
        {
            try
            {
                dataNode = new DataNode(configNode.GetValue("name"), this);

                LoggingUtil.CaptureLog = true;
                ConfigNodeUtil.SetCurrentDataNode(dataNode);
                bool valid = true;

                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "name", x => name = x, this);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "displayName", x => displayName = x, this, name);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "minVersion", x => minVersion = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxCompletions", x => maxCompletions = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxSimultaneous", x => maxSimultaneous = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "disabledContractType", x => disabledContractType = x, this, new List<string>());

                if (!string.IsNullOrEmpty(minVersion))
                {
                    if (Util.Version.VerifyAssemblyVersion("ContractConfigurator", minVersion) == null)
                    {
                        valid = false;

                        var ainfoV = Attribute.GetCustomAttribute(typeof(ExceptionLogWindow).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
                        string title = "Contract Configurator " + ainfoV.InformationalVersion + " Message";
                        string message = "The contract group '" + name + "' requires at least Contract Configurator " + minVersion +
                            " to work, and you are running version " + ainfoV.InformationalVersion +
                            ".  Please upgrade Contract Configurator to use the contracts in this group.";
                        DialogOption dialogOption = new DialogOption("Okay", new Callback(DoNothing), true);
                        PopupDialog.SpawnPopupDialog(new MultiOptionDialog(message, title, HighLogic.Skin, dialogOption), false, HighLogic.Skin);
                    }
                }

                // Load DATA nodes
                valid &= dataNode.ParseDataNodes(configNode, this, dataValues, uniquenessChecks);

                // Do the deferred loads
                valid &= ConfigNodeUtil.ExecuteDeferredLoads();

                config = configNode.ToString();
                log += LoggingUtil.capturedLog;
                LoggingUtil.CaptureLog = false;

                // Load child groups
                foreach (ConfigNode childNode in ConfigNodeUtil.GetChildNodes(configNode, "CONTRACT_GROUP"))
                {
                    ContractGroup child = null;
                    string childName = childNode.GetValue("name");
                    try
                    {
                        child = new ContractGroup(childName);
                    }
                    catch (ArgumentException)
                    {
                        LoggingUtil.LogError(this, "Couldn't load CONTRACT_GROUP '" + childName + "' due to a duplicate name.");
                        valid = false;
                        continue;
                    }

                    valid &= child.Load(childNode);
                    child.parent = this;
                    child.dataNode.Parent = dataNode;
                    if (child.hasWarnings)
                    {
                        hasWarnings = true;
                    }
                }

                // Check for unexpected values - always do this last
                valid &= ConfigNodeUtil.ValidateUnexpectedValues(configNode, this);

                // Invalidate children
                if (!valid)
                {
                    Invalidate();
                }

                enabled = valid;
                return valid;
            }
            catch
            {
                enabled = false;
                throw;
            }
        }
Beispiel #47
0
 public abstract bool CanUse(Pawn p, DialogOption option = null);
Beispiel #48
0
 private void NoOp(DialogOption option)
 {
 }
Beispiel #49
0
    [SerializeField] Transform buttonZone    = null;//放置按鍵位置

    /// <summary>
    /// 彈跳視窗初始化,使用進階設定。
    /// </summary>
    public override void Init(DialogOption option)
    {
        this.option = option;
        SpecificInit();
    }
Beispiel #50
0
 public override void ExplicitVisit(DialogOption node) { this.action(node); }
Beispiel #51
0
    public void AddMessageBehind()
    {
        GameObject emptyObject       = new GameObject();
        GameObject nextMessageObject = Instantiate(emptyObject, transform.parent);

        DestroyImmediate(emptyObject);

        Undo.RecordObject(nextMessageObject, "Change Message Name");
        nextMessageObject.name = "NewNextMessage";
        Undo.RecordObject(nextMessageObject, "Add Options");
        DialogMessage nextMessage = nextMessageObject.AddComponent <DialogMessage>();

        if (nextMessage.options.IsNullOrEmpty())
        {
            nextMessage.options = new List <DialogOption>();
        }

        if (autoAddNextOnNext)
        {
            // Add Close, Previous and Next to new Messag
            DialogOption nextOption = nextMessageObject.AddComponent <DialogOption>();
            nextOption.optionName = nextOptionText;
            nextOption.eventType  = DialogOption.EventType.DialogMessage;
            nextMessage.options.Add(nextOption);
        }

        if (autoAddPreviousOnNext)
        {
            DialogOption backOption = nextMessageObject.AddComponent <DialogOption>();
            backOption.optionName    = backOptionText;
            backOption.eventType     = DialogOption.EventType.DialogMessage;
            backOption.dialogMessage = this;
            nextMessage.options.Add(backOption);
        }

        if (autoAddCloseOnNext)
        {
            DialogOption closeOption = nextMessageObject.AddComponent <DialogOption>();
            closeOption.optionName = closeOptionText;
            closeOption.eventType  = DialogOption.EventType.Close;
            nextMessage.options.Add(closeOption);
        }

        Undo.RecordObject(nextMessage, "Autoassing Values");
        nextMessage.autoAssignNext        = autoAssignNext;
        nextMessage.autoAddNext           = autoAddNext;
        nextMessage.autoAddNextOnNext     = autoAddNextOnNext;
        nextMessage.autoAddPreviousOnNext = autoAddPreviousOnNext;
        nextMessage.autoAddCloseOnNext    = autoAddCloseOnNext;


        // Add message to this next option
        DialogOption[] possiblyNext = gameObject.GetComponents <DialogOption>();

        if (autoAssignNext)
        {
            Undo.RecordObject(this, "Add Next reference");

            bool nextOptionFound = false;
            if (!possiblyNext.IsNullOrEmpty())
            {
                for (int i = 0; i < possiblyNext.Length; i++)
                {
                    if (possiblyNext[i].optionName == nextOptionText)
                    {
                        possiblyNext[i].eventType     = DialogOption.EventType.DialogMessage;
                        possiblyNext[i].dialogMessage = nextMessage;
                        nextOptionFound = true;
                    }
                }
            }

            if (autoAddNext)
            {
                if (!nextOptionFound)
                {
                    DialogOption thisNextOption = gameObject.AddComponent <DialogOption>();
                    thisNextOption.optionName    = nextOptionText;
                    thisNextOption.eventType     = DialogOption.EventType.DialogMessage;
                    thisNextOption.dialogMessage = nextMessage;

                    if (options.IsNullOrEmpty())
                    {
                        options = new List <DialogOption>();
                    }

                    options.Insert(0, thisNextOption);
                }
            }
        }
    }
Beispiel #52
0
    void OnClick(GameObject sender)
    {
        Tools.PlayAudio(Constants.Audio.Audio_LobbyClickButton);

        int btnIndex = GetBtnIndexFromName(sender.name);

        if (btnIndex < 0)
        {
            DebugConsole.Log("Cant find button:" + sender.name);
            return;
        }

        switch ((Constants.LobbyBtn)btnIndex)
        {
        case Constants.LobbyBtn.Btn_Slot:
        {
            // 检查是否登录
            if (m_login)
            {
                Redirect();
            }
            else
            {
                WorkDone callBack = new WorkDone(Redirect);
                QuickLogin(callBack);
            }
        }
        break;

        case Constants.LobbyBtn.Btn_Poker:
        {
            //DialogBase.Show("POKER", "Exit game?", QuitGame);
        }
        break;

        case Constants.LobbyBtn.Btn_Option:
        {
            DialogOption.Show();
        }
        break;

        case Constants.LobbyBtn.Btn_Avatar:
        case Constants.LobbyBtn.Btn_Head:
        {
            GetProfile(Lobby.getInstance().UId, ShowPersonalInfoDlg);
        }
        break;

        case Constants.LobbyBtn.Btn_Message:
        {
            DialogMessage.Show();
        }
        break;

        case Constants.LobbyBtn.Btn_Credits:
        {
            DialogStore.Show(0);
        }
        break;

        case Constants.LobbyBtn.Btn_Gems:
        {
            DialogStore.Show(1);
        }
        break;

        case Constants.LobbyBtn.Btn_Friends:
        {
            // 根据ActivePage获取数据
            GetFriends();
        }
        break;

        case Constants.LobbyBtn.Btn_FreeBonus:
        {
            TakeFreeBonus();
        }
        break;

        case Constants.LobbyBtn.Btn_Bag:     // Bag
        {
            GetItems();
        }
        break;

        case Constants.LobbyBtn.Btn_Bingo:
        {
            //DoBuy("jb_1");
        }
        break;

        case Constants.LobbyBtn.Btn_Sj:
        {
            //string uuid = GetUUID();
            //DialogBase.Show("UUID", uuid);
        }
        break;

        default:
            DialogBase.Show("Button clicked", sender.name);
            break;
        }
    }
Beispiel #53
0
        //Maak een eigen ShowListBoxDialog
        private void ShowListBoxDialog(string title, DialogOption option)
        {
            //Initialisatie & design voor de dialog.
            Form prompt = new Form();
            prompt.Width = 400;
            prompt.Height = 540;
            prompt.Text = title;
            Label textLabel = new Label() { Left = 10, Top = 20, Text = title };
            ListBox listBox = new ListBox() { Left = 10, Top = 50, Width = 360, Height = 400 };
            Button confirmation = new Button() { Text = "OK", Left = 10, Width = 100, Top = 470 };

            if (option == DialogOption.LECTURE)
            {
                //Haal de lectures uit de database en voeg ze toe aan de listbox wanneer er lecture geselecteerd is.
                foreach (Lecture lecture in MasterController.DB.GetAllLectures()) {
                    listBox.Items.Add(lecture);
                }
            }
            else if (option == DialogOption.QUESTIONNAIRE)
            {
                //Haal de questionnaires uit de database en voeg ze toe aan de listbox wanneer er questionnaire geselecteerd is.
                foreach (Questionnaire questionnaire in MasterController.DB.GetAllQuestionnaires()) {
                    listBox.Items.Add(questionnaire);
                }
            }

            //Buttonclick event.
            confirmation.Click += (sender, e) => {
                if (option == DialogOption.LECTURE) {
                    //Wanneer lecture is geselecteerd, zet de model lecture naar de geselecteerde lecture.
                    Lecture selectedLecture = (Lecture)listBox.SelectedItem;
                    Model.LocallyEditedExam.Lecture = selectedLecture;
                }
                else if (option == DialogOption.QUESTIONNAIRE)
                {
                    //Wanneer questionnaire is geselecteerd, zet de model questionnaire naar de geselecteerde questionnaire.
                    Questionnaire selectedQuestionnaire = (Questionnaire)listBox.SelectedItem;
                    Model.LocallyEditedExam.Questionnaire = selectedQuestionnaire;
                }

                prompt.Close();
                UpdateView();
            };

            //Voeg de controls toe aan de prompt en laat de dialog zien.
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(listBox);
            prompt.ShowDialog();
        }
    /// <summary>
    /// Generate button based on the dialog option
    /// </summary>
    /// <param name="rect"></param>
    /// <param name="opt"></param>
    /// <returns></returns>
    private bool MakeButton(Rect rect, DialogOption opt)
    {
        bool result = false;

        List<string> urls = new List<string>();

        switch (opt.Tipe)
        {
        case DialogEngine.DIALOG_OPTION_CHOICE:	// Plain Choice
            {
                string content;
                urls = DecodeEmbeddedUrl(opt.Content, out content);

                float hintWidth = rect.height;

                result = GUI.Button(new Rect(rect.x + hintWidth, rect.y, rect.width - hintWidth * 2, rect.height), content);

                if (result)
                {
                    foreach (string url in urls)
                    {
                        if (Application.isWebPlayer)
                        {
                            Application.ExternalEval("window.open('" + url + "', '_blank')");
                        }
                        else
                        {
                            Application.OpenURL(url);
                        }
                    }
                }
            }
            break;

        case DialogEngine.DIALOG_OPTION_QUEST: // Quest button
            {
                // Get the quest
                Quest quest = QuestEngine.Instance.GetQuest(opt.Next);

                // Check if Quest required for this quest is valid
                bool isQuestValid = QuestEngine.Instance.IsQuestRequirementValid(opt.Next);

                // Check for date range
                bool isQuestDateTimeRangeValid = QuestEngine.Instance.IsQuestDateTimeRangeValid(opt.Next, PBGameMaster.GameTime);

                // Proceed only when requirements and date range valid
                if (quest != null && isQuestValid && isQuestDateTimeRangeValid)
                {
                    float hintWidth = rect.height;

                    GUI.Box(new Rect(rect.x, rect.y, hintWidth-2, rect.height), "", _questHintStyle);

                    string desc;
                    urls = DecodeEmbeddedUrl(quest.Description, out desc);

                    // Render the button
                    result = GUI.Button(new Rect(rect.x + hintWidth, rect.y, rect.width - hintWidth * 2, rect.height), desc, _questButtonStyle);

                    if (result)
                    {
                        dlgIsQuest = true;
                        _activeQuestID = quest.ID;
                        QuestState = GetState(_activeQuestID);

                        // Open the URLs
                        if (result)
                        {
                            foreach (string url in urls)
                            {
                                Application.OpenURL(url);
                            }
                        }
                    }

                }
            }
            break;
        }

        return result;
    }