Пример #1
0
        private void UpdateLocationTab(Location location)
        {
            topPanel.RemoveChild(topPanel.FindChild("locationtitle"));
            topPanel.UserData = location;

            var locationTitle = new GUITextBlock(new Rectangle(0, 0, 200, 25),
                                                 "Location: " + location.Name, Color.Transparent, Color.White, Alignment.TopLeft, "", topPanel);

            locationTitle.UserData = "locationtitle";
            locationTitle.Font     = GUI.LargeFont;


            if (hireList == null)
            {
                hireList = new GUIListBox(new Rectangle(0, 40, 300, 0), "", Alignment.Right, bottomPanel[(int)PanelTab.Crew]);
                new GUITextBlock(new Rectangle(0, 0, 300, 20), "Hire:", "", Alignment.Right, Alignment.Left, bottomPanel[(int)PanelTab.Crew], false, GUI.LargeFont);

                hireList.OnSelected = SelectCharacter;
            }

            if (location.HireManager == null)
            {
                hireList.ClearChildren();
                hireList.Enabled = false;

                new GUITextBlock(new Rectangle(0, 0, 0, 0), "No-one available for hire", Color.Transparent, Color.LightGray, Alignment.Center, Alignment.Center, "", hireList);
                return;
            }

            hireList.Enabled = true;
            hireList.ClearChildren();

            foreach (CharacterInfo c in location.HireManager.availableCharacters)
            {
                var frame = c.CreateCharacterFrame(hireList, c.Name + " (" + c.Job.Name + ")", c);

                new GUITextBlock(
                    new Rectangle(0, 0, 0, 25),
                    c.Salary.ToString(),
                    null, null,
                    Alignment.TopRight, "", frame);
            }
        }
Пример #2
0
        public void UpdateCharacters()
        {
            CreateGUIFrame();

            List <GUIComponent> prevCharacterFrames = new List <GUIComponent>();

            foreach (GUIComponent child in frame.children)
            {
                if (!(child.UserData is Character))
                {
                    continue;
                }

                prevCharacterFrames.Add(child);
            }

            foreach (GUIComponent child in prevCharacterFrames)
            {
                frame.RemoveChild(child);
            }

            List <Character> aliveCharacters = crewManager.characters.FindAll(c => !c.IsDead && c.AIController is HumanAIController);

            characterFrameBottom = 0;

            int charactersPerRow = 4;

            int spacing = 5;

            int i = 0;

            foreach (Character character in aliveCharacters)
            {
                int rowCharacterCount = Math.Min(charactersPerRow, aliveCharacters.Count);
                //if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow;

                // rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i);
                int startX = -(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;


                int x = startX + (150 + spacing) * (i % Math.Min(charactersPerRow, aliveCharacters.Count));
                int y = (105 + spacing) * ((int)Math.Floor((double)i / charactersPerRow));

                GUIButton characterButton = new GUIButton(new Rectangle(x + 75, y, 150, 40), "", null, Alignment.TopCenter, "GUITextBox", frame);

                characterButton.UserData = character;
                characterButton.Padding  = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);

                characterButton.Color = Character.Controlled == character ? Color.Gold : Color.White;

                /*characterButton.HoverColor = Color.LightGray * 0.5f;
                 * characterButton.SelectedColor = Color.Gold * 0.6f;
                 * characterButton.OutlineColor = Color.LightGray * 0.8f;*/

                characterFrameBottom = Math.Max(characterFrameBottom, characterButton.Rect.Bottom);

                string name = character.Info.Name;
                if (character.Info.Job != null)
                {
                    name += '\n' + "(" + character.Info.Job.Name + ")";
                }

                GUITextBlock textBlock = new GUITextBlock(
                    new Rectangle(40, 0, 0, 25),
                    name,
                    Color.Transparent, null,
                    Alignment.Left, Alignment.Left,
                    "", characterButton, false);
                textBlock.Font    = GUI.SmallFont;
                textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);

                new GUIImage(new Rectangle(-5, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, characterButton);

                var humanAi = character.AIController as HumanAIController;
                if (humanAi != null && humanAi.CurrentOrder != null)
                {
                    CreateCharacterOrderFrame(characterButton, humanAi.CurrentOrder, humanAi.CurrentOrderOption);
                }

                i++;
            }

            foreach (GUIComponent child in frame.children)
            {
                if (!(child.UserData is Order))
                {
                    continue;
                }

                Rectangle rect = child.Rect;
                rect.Y += characterFrameBottom;

                child.Rect = rect;
            }
        }
 public void Remove(GUIFrame parent)
 {
     parent.RemoveChild(frame);
 }