Exemple #1
0
        private bool OnSubSelected(GUIComponent component, object obj)
        {
            if (subPreviewContainer == null)
            {
                return(false);
            }
            (subPreviewContainer.Parent as GUILayoutGroup)?.Recalculate();
            subPreviewContainer.ClearChildren();

            SubmarineInfo sub = obj as SubmarineInfo;

            if (sub == null)
            {
                return(true);
            }

            sub.CreatePreviewWindow(subPreviewContainer);
            return(true);
        }
        private bool OnSubSelected(GUIComponent component, object obj)
        {
            if (subPreviewContainer == null)
            {
                return(false);
            }

            subPreviewContainer.ClearChildren();

            Submarine sub = obj as Submarine;

            if (sub == null)
            {
                return(true);
            }

            sub.CreatePreviewWindow(subPreviewContainer);
            return(true);
        }
Exemple #3
0
        public void SelectLocation(Location location, LocationConnection connection)
        {
            locationInfoContainer.ClearChildren();

            if (location == null)
            {
                return;
            }

            var titleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), locationInfoContainer.RectTransform, Anchor.TopCenter), location.Name, font: GUI.LargeFont);

            Sprite portrait = location.Type.Background;

            new GUIImage(new RectTransform(
                             new Point(locationInfoContainer.Rect.Width, (int)(portrait.size.Y * (locationInfoContainer.Rect.Width / portrait.size.X))),
                             locationInfoContainer.RectTransform), portrait, scaleToFit: true);

            if (GameMain.GameSession.Map.SelectedConnection != null && GameMain.GameSession.Map.SelectedConnection.Mission != null)
            {
                var mission = GameMain.GameSession.Map.SelectedConnection.Mission;

                new GUITextBlock(
                    new RectTransform(new Vector2(1.0f, 0.05f), locationInfoContainer.RectTransform, Anchor.TopCenter),
                    TextManager.Get("Mission") + ": " + mission.Name);
                new GUITextBlock(
                    new RectTransform(new Vector2(1.0f, 0.05f), locationInfoContainer.RectTransform, Anchor.TopCenter),
                    TextManager.Get("Reward").Replace("[reward]", mission.Reward.ToString()));
                new GUITextBlock(
                    new RectTransform(new Vector2(1.0f, 0.0f), locationInfoContainer.RectTransform, Anchor.TopCenter),
                    mission.Description, wrap: true);
            }

            if (startButton != null)
            {
                startButton.Enabled = true;
            }

            selectedLevel = connection?.Level;

            OnLocationSelected?.Invoke(location, connection);
        }
        private bool OnSubSelected(GUIComponent component, object obj)
        {
            if (subPreviewContainer == null)
            {
                return(false);
            }
            (subPreviewContainer.Parent as GUILayoutGroup)?.Recalculate();
            subPreviewContainer.ClearChildren();

            if (!(obj is SubmarineInfo sub))
            {
                return(true);
            }
#if !DEBUG
            if (!isMultiplayer && sub.Price > CampaignMode.InitialMoney && !GameMain.DebugDraw)
            {
                StartButton.Enabled = false;
                return(false);
            }
#endif
            StartButton.Enabled = true;
            sub.CreatePreviewWindow(subPreviewContainer);
            return(true);
        }
Exemple #5
0
        public void RandomizeCrew()
        {
            var characterInfos = new List <(CharacterInfo Info, JobPrefab Job)>();

            foreach (JobPrefab jobPrefab in JobPrefab.Prefabs)
            {
                for (int i = 0; i < jobPrefab.InitialCount; i++)
                {
                    var variant = Rand.Range(0, jobPrefab.Variants);
                    characterInfos.Add((new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: jobPrefab, variant: variant), jobPrefab));
                }
            }

            characterInfoColumns.ClearChildren();
            CharacterMenus?.ForEach(m => m.Dispose());
            CharacterMenus = new CharacterInfo.AppearanceCustomizationMenu[characterInfos.Count];

            for (int i = 0; i < characterInfos.Count; i++)
            {
                var subLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f / characterInfos.Count, 1.0f),
                                                                     characterInfoColumns.RectTransform));

                var(characterInfo, job) = characterInfos[i];

                characterInfo.CreateIcon(new RectTransform(new Vector2(1.0f, 0.275f), subLayout.RectTransform));

                var jobTextContainer =
                    new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), subLayout.RectTransform), style: null);
                var jobText = new GUITextBlock(new RectTransform(Vector2.One, jobTextContainer.RectTransform), job.Name, job.UIColor);

                var characterName = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), subLayout.RectTransform))
                {
                    Text     = characterInfo.Name,
                    UserData = "random"
                };
                characterName.OnDeselected += (sender, key) =>
                {
                    if (string.IsNullOrWhiteSpace(sender.Text))
                    {
                        characterInfo.Name = characterInfo.GetRandomName(Rand.RandSync.Unsynced);
                        sender.Text        = characterInfo.Name;
                        sender.UserData    = "random";
                    }
                    else
                    {
                        characterInfo.Name = sender.Text;
                        sender.UserData    = "user";
                    }
                };
                characterName.OnEnterPressed += (sender, text) =>
                {
                    sender.Deselect();
                    return(false);
                };

                var customizationFrame =
                    new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f), subLayout.RectTransform), style: null);
                CharacterMenus[i] =
                    new CharacterInfo.AppearanceCustomizationMenu(characterInfo, customizationFrame, hasIcon: false)
                {
                    OnHeadSwitch = menu =>
                    {
                        if (characterName.UserData is string ud && ud == "random")
                        {
                            characterInfo.Name     = characterInfo.GetRandomName(Rand.RandSync.Unsynced);
                            characterName.Text     = characterInfo.Name;
                            characterName.UserData = "random";
                        }

                        StealRandomizeButton(menu, jobTextContainer);
                    }
                };
                StealRandomizeButton(CharacterMenus[i], jobTextContainer);
            }
        }