コード例 #1
0
        public void SelectTab(CampaignMode.InteractionType tab)
        {
            selectedTab = tab;
            for (int i = 0; i < tabs.Length; i++)
            {
                if (tabs[i] != null)
                {
                    tabs[i].Visible = (int)selectedTab == i;
                }
            }

            locationInfoPanel.Visible = tab == CampaignMode.InteractionType.Map && selectedLocation != null;

            switch (selectedTab)
            {
            case CampaignMode.InteractionType.Repair:
                repairHullsButton.Enabled =
                    (Campaign.PurchasedHullRepairs || Campaign.Money >= CampaignMode.HullRepairCost) &&
                    Campaign.AllowedToManageCampaign();
                repairHullsButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
                repairItemsButton.Enabled =
                    (Campaign.PurchasedItemRepairs || Campaign.Money >= CampaignMode.ItemRepairCost) &&
                    Campaign.AllowedToManageCampaign();
                repairItemsButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedItemRepairs;

                if (GameMain.GameSession?.SubmarineInfo == null || !GameMain.GameSession.SubmarineInfo.SubsLeftBehind)
                {
                    replaceShuttlesButton.Enabled = false;
                    replaceShuttlesButton.GetChild <GUITickBox>().Selected = false;
                }
                else
                {
                    replaceShuttlesButton.Enabled =
                        (Campaign.PurchasedLostShuttles || Campaign.Money >= CampaignMode.ShuttleReplaceCost) &&
                        Campaign.AllowedToManageCampaign();
                    replaceShuttlesButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
                }
                break;

            case CampaignMode.InteractionType.Store:
                Store.RefreshItemsToSell();
                Store.Refresh();
                break;

            case CampaignMode.InteractionType.Crew:
                CrewManagement.UpdateCrew();
                break;

            case CampaignMode.InteractionType.PurchaseSub:
                if (submarineSelection == null)
                {
                    submarineSelection = new SubmarineSelection(false, () => Campaign.ShowCampaignUI = false, tabs[(int)CampaignMode.InteractionType.PurchaseSub].RectTransform);
                }
                submarineSelection.RefreshSubmarineDisplay(true);
                break;
            }
        }
コード例 #2
0
ファイル: CampaignUI.cs プロジェクト: parhelia512/Barotrauma
        public void Update(float deltaTime)
        {
            switch (SelectedTab)
            {
            case CampaignMode.InteractionType.PurchaseSub:
                submarineSelection?.Update();
                break;

            case CampaignMode.InteractionType.Crew:
                CrewManagement?.Update();
                break;

            case CampaignMode.InteractionType.Store:
                Store?.Update(deltaTime);
                break;
            }
        }
コード例 #3
0
ファイル: CampaignUI.cs プロジェクト: parhelia512/Barotrauma
        private void CreateUI(GUIComponent container)
        {
            container.ClearChildren();

            tabs = new GUIFrame[Enum.GetValues(typeof(CampaignMode.InteractionType)).Length];

            // map tab -------------------------------------------------------------------------

            tabs[(int)CampaignMode.InteractionType.Map] = CreateDefaultTabContainer(container, new Vector2(0.9f));
            var mapFrame = new GUIFrame(new RectTransform(Vector2.One, GetTabContainer(CampaignMode.InteractionType.Map).RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);

            new GUICustomComponent(new RectTransform(Vector2.One, mapFrame.RectTransform), DrawMap, UpdateMap);
            new GUIFrame(new RectTransform(Vector2.One, mapFrame.RectTransform), style: "InnerGlow", color: Color.Black * 0.9f)
            {
                CanBeFocused = false
            };

            // crew tab -------------------------------------------------------------------------

            var crewTab = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);

            tabs[(int)CampaignMode.InteractionType.Crew] = crewTab;
            CrewManagement = new CrewManagement(this, crewTab);

            // store tab -------------------------------------------------------------------------

            var storeTab = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);

            tabs[(int)CampaignMode.InteractionType.Store] = storeTab;
            Store = new Store(this, storeTab);

            // repair tab -------------------------------------------------------------------------

            tabs[(int)CampaignMode.InteractionType.Repair] = CreateDefaultTabContainer(container, new Vector2(0.7f));
            var repairFrame = new GUIFrame(new RectTransform(Vector2.One, GetTabContainer(CampaignMode.InteractionType.Repair).RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);

            new GUIFrame(new RectTransform(new Vector2(1.25f, 1.25f), repairFrame.RectTransform, Anchor.Center), style: "OuterGlow", color: Color.Black * 0.7f)
            {
                UserData     = "outerglow",
                CanBeFocused = false
            };

            var repairContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), repairFrame.RectTransform, Anchor.Center))
            {
                RelativeSpacing = 0.05f,
                Stretch         = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), repairContent.RectTransform), "", font: GUI.LargeFont)
            {
                TextGetter = GetMoney
            };

            // repair hulls -----------------------------------------------

            var repairHullsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
            {
                RelativeSpacing = 0.05f,
                Stretch         = true
            };

            new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairHullsHolder.RectTransform, Anchor.CenterLeft), "RepairHullButton")
            {
                IgnoreLayoutGroups = true,
                CanBeFocused       = false
            };
            var repairHullsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairHullsHolder.RectTransform), TextManager.Get("RepairAllWalls"), textAlignment: Alignment.Right, font: GUI.SubHeadingFont)
            {
                ForceUpperCase = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairHullsHolder.RectTransform), CampaignMode.HullRepairCost.ToString(), textAlignment: Alignment.Right, font: GUI.SubHeadingFont);
            repairHullsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairHullsHolder.RectTransform)
            {
                MinSize = new Point(140, 0)
            }, TextManager.Get("Repair"))
            {
                OnClicked = (btn, userdata) =>
                {
                    if (Campaign.PurchasedHullRepairs)
                    {
                        Campaign.Money += CampaignMode.HullRepairCost;
                        Campaign.PurchasedHullRepairs = false;
                    }
                    else
                    {
                        if (Campaign.Money >= CampaignMode.HullRepairCost)
                        {
                            Campaign.Money -= CampaignMode.HullRepairCost;
                            Campaign.PurchasedHullRepairs = true;
                        }
                    }
                    GameMain.Client?.SendCampaignState();
                    btn.GetChild <GUITickBox>().Selected = Campaign.PurchasedHullRepairs;

                    return(true);
                }
            };
            new GUITickBox(new RectTransform(new Vector2(0.65f), repairHullsButton.RectTransform, Anchor.CenterLeft)
            {
                AbsoluteOffset = new Point(10, 0)
            }, "")
            {
                CanBeFocused = false
            };

            // repair items -------------------------------------------

            var repairItemsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
            {
                RelativeSpacing = 0.05f,
                Stretch         = true
            };

            new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), repairItemsHolder.RectTransform, Anchor.CenterLeft), "RepairItemsButton")
            {
                IgnoreLayoutGroups = true,
                CanBeFocused       = false
            };
            var repairItemsLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), repairItemsHolder.RectTransform), TextManager.Get("RepairAllItems"), textAlignment: Alignment.Right, font: GUI.SubHeadingFont)
            {
                ForceUpperCase = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), repairItemsHolder.RectTransform), CampaignMode.ItemRepairCost.ToString(), textAlignment: Alignment.Right, font: GUI.SubHeadingFont);
            repairItemsButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), repairItemsHolder.RectTransform)
            {
                MinSize = new Point(140, 0)
            }, TextManager.Get("Repair"))
            {
                OnClicked = (btn, userdata) =>
                {
                    if (Campaign.PurchasedItemRepairs)
                    {
                        Campaign.Money += CampaignMode.ItemRepairCost;
                        Campaign.PurchasedItemRepairs = false;
                    }
                    else
                    {
                        if (Campaign.Money >= CampaignMode.ItemRepairCost)
                        {
                            Campaign.Money -= CampaignMode.ItemRepairCost;
                            Campaign.PurchasedItemRepairs = true;
                        }
                    }
                    GameMain.Client?.SendCampaignState();
                    btn.GetChild <GUITickBox>().Selected = Campaign.PurchasedItemRepairs;

                    return(true);
                }
            };
            new GUITickBox(new RectTransform(new Vector2(0.65f), repairItemsButton.RectTransform, Anchor.CenterLeft)
            {
                AbsoluteOffset = new Point(10, 0)
            }, "")
            {
                CanBeFocused = false
            };

            // replace lost shuttles -------------------------------------------

            var replaceShuttlesHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), repairContent.RectTransform), childAnchor: Anchor.TopRight)
            {
                RelativeSpacing = 0.05f,
                Stretch         = true
            };

            new GUIImage(new RectTransform(new Vector2(0.3f, 1.0f), replaceShuttlesHolder.RectTransform, Anchor.CenterLeft), "ReplaceShuttlesButton")
            {
                IgnoreLayoutGroups = true,
                CanBeFocused       = false
            };
            var replaceShuttlesLabel = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.3f), replaceShuttlesHolder.RectTransform), TextManager.Get("ReplaceLostShuttles"), textAlignment: Alignment.Right, font: GUI.SubHeadingFont)
            {
                ForceUpperCase = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), replaceShuttlesHolder.RectTransform), CampaignMode.ShuttleReplaceCost.ToString(), textAlignment: Alignment.Right, font: GUI.SubHeadingFont);
            replaceShuttlesButton = new GUIButton(new RectTransform(new Vector2(0.4f, 0.3f), replaceShuttlesHolder.RectTransform)
            {
                MinSize = new Point(140, 0)
            }, TextManager.Get("ReplaceShuttles"))
            {
                OnClicked = (btn, userdata) =>
                {
                    if (GameMain.GameSession?.SubmarineInfo != null &&
                        GameMain.GameSession.SubmarineInfo.LeftBehindSubDockingPortOccupied)
                    {
                        new GUIMessageBox("", TextManager.Get("ReplaceShuttleDockingPortOccupied"));
                        return(true);
                    }

                    if (Campaign.PurchasedLostShuttles)
                    {
                        Campaign.Money += CampaignMode.ShuttleReplaceCost;
                        Campaign.PurchasedLostShuttles = false;
                    }
                    else
                    {
                        if (Campaign.Money >= CampaignMode.ShuttleReplaceCost)
                        {
                            Campaign.Money -= CampaignMode.ShuttleReplaceCost;
                            Campaign.PurchasedLostShuttles = true;
                        }
                    }
                    GameMain.Client?.SendCampaignState();
                    btn.GetChild <GUITickBox>().Selected = Campaign.PurchasedLostShuttles;

                    return(true);
                }
            };
            new GUITickBox(new RectTransform(new Vector2(0.65f), replaceShuttlesButton.RectTransform, Anchor.CenterLeft)
            {
                AbsoluteOffset = new Point(10, 0)
            }, "")
            {
                CanBeFocused = false
            };
            GUITextBlock.AutoScaleAndNormalize(repairHullsLabel, repairItemsLabel, replaceShuttlesLabel);
            GUITextBlock.AutoScaleAndNormalize(repairHullsButton.GetChild <GUITickBox>().TextBlock, repairItemsButton.GetChild <GUITickBox>().TextBlock, replaceShuttlesButton.GetChild <GUITickBox>().TextBlock);

            // upgrade tab -------------------------------------------------------------------------

            tabs[(int)CampaignMode.InteractionType.Upgrade] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
            UpgradeStore = new UpgradeStore(this, GetTabContainer(CampaignMode.InteractionType.Upgrade));

            // Submarine buying tab
            tabs[(int)CampaignMode.InteractionType.PurchaseSub] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);

            // mission info -------------------------------------------------------------------------

            locationInfoPanel = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.75f), GetTabContainer(CampaignMode.InteractionType.Map).RectTransform, Anchor.CenterRight)
            {
                RelativeOffset = new Vector2(0.02f, 0.0f)
            },
                                             color: Color.Black)
            {
                Visible = false
            };

            // -------------------------------------------------------------------------

            SelectTab(CampaignMode.InteractionType.Map);

            prevResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
        }