Exemple #1
0
 private void SetStatusBar(Gui.Widgets.TextProgressBar Bar, Status Status)
 {
     Bar.Percentage = (float)Status.Percentage / 100.0f;
 }
Exemple #2
0
        public override void Construct()
        {
            Text = "You have no employees.";
            Font = "font16";

            InteriorPanel = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                Hidden     = true,
                Background = new TileReference("basic", 0),
                Font       = "font8",
            });

            var top = InteriorPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 96)
            });

            Icon = top.AddChild(new DwarfCorp.Gui.Widgets.EmployeePortrait
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(48, 40),
            }) as EmployeePortrait;

            NameLabel = top.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 48),
                Font        = "font16"
            });

            var levelHolder = top.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(256, 24)
            });

            TitleEditor = levelHolder.AddChild(new Gui.Widgets.EditableTextField()
            {
                AutoLayout   = AutoLayout.DockLeft,
                MinimumSize  = new Point(128, 24),
                OnTextChange = (sender) =>
                {
                    Employee.Stats.Title = sender.Text;
                },
                Tooltip = "Employee title. You can customize this."
            });

            LevelLabel = levelHolder.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(128, 24)
            });

            var columns = InteriorPanel.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 100),
                ColumnCount = 3
            });

            var left          = columns.AddChild(new Gui.Widget());
            var right         = columns.AddChild(new Gui.Widget());
            var evenMoreRight = columns.AddChild(new Gui.Widget());

            #region Stats
            var statParent = left.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 60)
            });

            var statsLeft  = statParent.AddChild(new Widget());
            var statsRight = statParent.AddChild(new Widget());

            StatDexterity = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Dexterity (affects dwarf speed)"
            });

            StatStrength = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Strength (affects dwarf attack power)"
            });

            StatWisdom = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Wisdom (affects temprement and spell resistance)"
            });

            StatCharisma = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Charisma (affects ability to make friends)"
            });

            StatConstitution = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Constitution (affects dwarf health and damage resistance)"
            });

            StatIntelligence = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Intelligence (affects crafting/farming)"
            });

            StatSize = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Size"
            });
            #endregion

            #region status bars
            Hunger    = CreateStatusBar(right, "Hunger", "Starving", "Hungry", "Peckish", "Okay");
            Energy    = CreateStatusBar(right, "Energy", "Exhausted", "Tired", "Okay", "Energetic");
            Happiness = CreateStatusBar(right, "Happiness", "Miserable", "Unhappy", "So So", "Happy", "Euphoric");
            Health    = CreateStatusBar(evenMoreRight, "Health", "Near Death", "Critical", "Hurt", "Uncomfortable", "Fine", "Perfect");
            Boredom   = CreateStatusBar(evenMoreRight, "Boredom", "Desperate", "Overworked", "Bored", "Meh", "Fine", "Excited");
            #endregion

            PayLabel = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            AgeLabel = InteriorPanel.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            Bio = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var task = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(1, 24)
            });

            var inventory = task.AddChild(new Button
            {
                AutoLayout = AutoLayout.DockRight,
                Text       = "Backpack...",
                OnClick    = (sender, args) =>
                {
                    var employeeInfo = sender.Parent.Parent.Parent as EmployeeInfo;
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("Backpack contains:\n");
                        Dictionary <string, ResourceAmount> aggregateResources = employeeInfo.Employee.Creature.Inventory.Aggregate();
                        foreach (var resource in aggregateResources)
                        {
                            stringBuilder.Append(String.Format("{0}x {1}\n", resource.Value.NumResources, resource.Key));
                        }
                        if (aggregateResources.Count == 0)
                        {
                            stringBuilder.Append("Nothing.");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };


                        sender.Root.ShowMinorPopup(popup);

                        if (aggregateResources.Count > 0)
                        {
                            popup.AddChild(new Button()
                            {
                                Text       = "Empty",
                                Tooltip    = "Click to order this dwarf to empty their backpack.",
                                AutoLayout = AutoLayout.FloatBottomLeft,
                                OnClick    = (currSender, currArgs) =>
                                {
                                    if (employeeInfo != null && employeeInfo.Employee != null &&
                                        employeeInfo.Employee.Creature != null)
                                    {
                                        employeeInfo.Employee.Creature.RestockAllImmediately(true);
                                    }
                                }
                            });
                            popup.Layout();
                        }
                    }
                }
            });

            CancelTask = task.AddChild(new Button
            {
                AutoLayout         = AutoLayout.DockRight,
                Text               = "Cancel Task",
                ChangeColorOnHover = true
            });

            TaskLabel = task.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                MinimumSize         = new Point(256, 24),
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right
            });

            Thoughts = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var bottomBar = InteriorPanel.AddChild(new Widget
            {
                Transparent = true,
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 32)
            });

            bottomBar.AddChild(new Button()
            {
                Text       = "Fire",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    Root.SafeCall(OnFireClicked, this);
                }
            });

            /*
             * if (EnablePosession)
             * {
             *  bottomBar.AddChild(new Button()
             *  {
             *      Text = "Follow",
             *      Tooltip = "Click to directly control this dwarf and have the camera follow.",
             *      AutoLayout = AutoLayout.DockRight,
             *      OnClick = (sender, args) =>
             *      {
             *          (sender.Parent.Parent.Parent as EmployeeInfo).Employee.World.Tutorial("dwarf follow");
             *          (sender.Parent.Parent.Parent as EmployeeInfo).Employee.IsPosessed = true;
             *      }
             *  });
             * }
             */

            bottomBar.AddChild(new Button()
            {
                Text       = "Tasks...",
                Tooltip    = "Open allowed tasks filter.",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    var screen = sender.Root.RenderData.VirtualScreen;
                    sender.Root.ShowModalPopup(new AllowedTaskFilter
                    {
                        Employee    = Employee,
                        Tag         = "selected-employee-allowable-tasks",
                        AutoLayout  = AutoLayout.DockFill,
                        MinimumSize = new Point(256, 256),
                        Border      = "border-fancy",
                        Rect        = new Rectangle(screen.Center.X - 128, screen.Center.Y - 128, 256, 256)
                    });
                }
            });

#if ENABLE_CHAT
            if (Employee != null && Employee.GetRoot().GetComponent <DwarfThoughts>() != null)
            {
                bottomBar.AddChild(new Button()
                {
                    Text       = "Chat...",
                    Tooltip    = "Have a talk with your employee.",
                    AutoLayout = AutoLayout.DockRight,
                    OnClick    = (sender, args) =>
                    {
                        Employee.Chat();
                    }
                });
            }
#endif


            LevelButton = bottomBar.AddChild(new Button()
            {
                Text       = "Promote!",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                Tooltip    = "Click to promote this dwarf.\nPromoting Dwarves raises their pay and makes them\nmore effective workers.",
                OnClick    = (sender, args) =>
                {
                    var prevLevel = Employee.Stats.CurrentLevel;
                    Employee.Stats.LevelUp();
                    if (Employee.Stats.CurrentLevel.HealingPower > prevLevel.HealingPower)
                    {
                        Employee.World.MakeAnnouncement(String.Format("{0}'s healing power increased to {1}!", Employee.Stats.FullName, Employee.Stats.CurrentLevel.HealingPower));
                    }

                    if (Employee.Stats.CurrentLevel.ExtraAttacks.Count > prevLevel.ExtraAttacks.Count)
                    {
                        Employee.World.MakeAnnouncement(String.Format("{0} learned to cast {1}!", Employee.Stats.FullName, Employee.Stats.CurrentLevel.ExtraAttacks.Last().Name));
                    }
                    SoundManager.PlaySound(ContentPaths.Audio.change, 0.5f);
                    Invalidate();
                    Employee.Creature.AddThought(Thought.ThoughtType.GotPromoted);
                }
            });


            var topbuttons = top.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.FloatTopRight,
                MinimumSize = new Point(32, 24)
            });
            topbuttons.AddChild(new Widget()
            {
                Text               = "<",
                Font               = "font10",
                Tooltip            = "Previous employee.",
                AutoLayout         = AutoLayout.DockLeft,
                ChangeColorOnHover = true,
                MinimumSize        = new Point(16, 24),
                OnClick            = (sender, args) =>
                {
                    if (Employee == null)
                    {
                        return;
                    }
                    int idx = Employee.Faction.Minions.IndexOf(Employee);
                    if (idx < 0)
                    {
                        return;
                    }
                    idx--;
                    Employee = Employee.Faction.Minions[Math.Abs(idx) % Employee.Faction.Minions.Count];
                    Employee.World.Master.SelectedMinions = new List <CreatureAI>()
                    {
                        Employee
                    };
                }
            });
            topbuttons.AddChild(new Widget()
            {
                Text               = ">",
                Font               = "font10",
                Tooltip            = "Next employee.",
                AutoLayout         = AutoLayout.DockRight,
                ChangeColorOnHover = true,
                MinimumSize        = new Point(16, 24),
                OnClick            = (sender, args) =>
                {
                    if (Employee == null)
                    {
                        return;
                    }
                    int idx = Employee.Faction.Minions.IndexOf(Employee);
                    if (idx < 0)
                    {
                        return;
                    }
                    idx++;
                    Employee = Employee.Faction.Minions[idx % Employee.Faction.Minions.Count];
                    Employee.World.Master.SelectedMinions = new List <CreatureAI>()
                    {
                        Employee
                    };
                }
            });

            base.Construct();
        }
Exemple #3
0
        public override void Construct()
        {
            Text = "You have no employees.";
            Font = "font16";

            InteriorPanel = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                Hidden     = true,
                Background = new TileReference("basic", 0),
                Font       = "font8",
            });

            var top = InteriorPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 96)
            });

            Icon = top.AddChild(new EmployeePortrait
            {
                AutoLayout  = AutoLayout.DockLeftCentered,
                MinimumSize = new Point(48, 40),
                MaximumSize = new Point(48, 40)
            }) as EmployeePortrait;

            NameLabel = top.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 48),
                Font        = "font16"
            });

            var levelHolder = top.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(256, 24)
            });

            TitleEditor = levelHolder.AddChild(new Gui.Widgets.EditableTextField()
            {
                AutoLayout   = AutoLayout.DockLeft,
                MinimumSize  = new Point(128, 24),
                OnTextChange = (sender) =>
                {
                    Employee.Stats.Title = sender.Text;
                },
                Tooltip = "Employee title. You can customize this."
            });

            LevelLabel = levelHolder.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(128, 24)
            });

            var columns = InteriorPanel.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 100),
                ColumnCount = 3
            });

            var left          = columns.AddChild(new Gui.Widget());
            var right         = columns.AddChild(new Gui.Widget());
            var evenMoreRight = columns.AddChild(new Gui.Widget());

            #region Stats
            var statParent = left.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout          = AutoLayout.DockTop,
                MinimumSize         = new Point(0, 60),
                TriggerOnChildClick = true,
                OnClick             = (sender, args) =>
                {
                    var employeeInfo = sender.FindParentOfType <EmployeeInfo>();
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("MODIFIERS: CHA  CON  DEX  INT  SIZ  STR  WIS \n");
                        // Todo: Need to align columns. Current method only works for monospaced fonts.

                        foreach (var modifier in employeeInfo.Employee.Creature.Stats.EnumerateStatAdjustments())
                        {
                            stringBuilder.Append(SetLength(modifier.Name, 9));
                            stringBuilder.Append(": ");
                            stringBuilder.Append(FormatNumber(modifier.Charisma));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Constitution));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Dexterity));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Intelligence));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Size));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Strength));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Wisdom));
                            stringBuilder.Append("\n");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };

                        sender.Root.ShowMinorPopup(popup);
                    }
                }
            });

            var statsLeft  = statParent.AddChild(new Widget());
            var statsRight = statParent.AddChild(new Widget());

            StatDexterity = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Dexterity (affects dwarf speed)"
            });

            StatStrength = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Strength (affects dwarf attack power)"
            });

            StatWisdom = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Wisdom (affects temprement and spell resistance)"
            });

            StatCharisma = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Charisma (affects ability to make friends)"
            });

            StatConstitution = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Constitution (affects dwarf health and damage resistance)"
            });

            StatIntelligence = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Intelligence (affects crafting/farming)"
            });

            StatSize = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Size"
            });
            #endregion

            #region status bars
            Hunger    = CreateStatusBar(right, "Hunger", "Starving", "Hungry", "Peckish", "Okay");
            Energy    = CreateStatusBar(right, "Energy", "Exhausted", "Tired", "Okay", "Energetic");
            Happiness = CreateStatusBar(right, "Happiness", "Miserable", "Unhappy", "So So", "Happy", "Euphoric");
            Health    = CreateStatusBar(evenMoreRight, "Health", "Near Death", "Critical", "Hurt", "Uncomfortable", "Fine", "Perfect");
            Boredom   = CreateStatusBar(evenMoreRight, "Boredom", "Desperate", "Overworked", "Bored", "Meh", "Fine", "Excited");
            #endregion

            PayLabel = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            AgeLabel = InteriorPanel.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            Bio = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var task = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(1, 24)
            });

            var inventory = task.AddChild(new Button
            {
                AutoLayout = AutoLayout.DockRight,
                Text       = "Backpack...",
                OnClick    = (sender, args) =>
                {
                    var employeeInfo = sender.Parent.Parent.Parent as EmployeeInfo;
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("Backpack contains:\n");
                        Dictionary <string, ResourceAmount> aggregateResources = employeeInfo.Employee.Creature.Inventory.Aggregate();
                        foreach (var resource in aggregateResources)
                        {
                            stringBuilder.Append(String.Format("{0}x {1}\n", resource.Value.Count, resource.Key));
                        }
                        if (aggregateResources.Count == 0)
                        {
                            stringBuilder.Append("Nothing.");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };


                        sender.Root.ShowMinorPopup(popup);

                        if (aggregateResources.Count > 0)
                        {
                            popup.AddChild(new Button()
                            {
                                Text       = "Empty",
                                Tooltip    = "Click to order this dwarf to empty their backpack.",
                                AutoLayout = AutoLayout.FloatBottomLeft,
                                OnClick    = (currSender, currArgs) =>
                                {
                                    if (employeeInfo != null && employeeInfo.Employee != null &&
                                        employeeInfo.Employee.Creature != null)
                                    {
                                        employeeInfo.Employee.Creature.RestockAllImmediately(true);
                                    }
                                }
                            });
                            popup.Layout();
                        }
                    }
                }
            });

            CancelTask = task.AddChild(new Button
            {
                AutoLayout         = AutoLayout.DockRight,
                Text               = "Cancel Task",
                ChangeColorOnHover = true
            });

            TaskLabel = task.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                MinimumSize         = new Point(256, 24),
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right
            });

            Thoughts = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var bottomBar = InteriorPanel.AddChild(new Widget
            {
                Transparent = true,
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 32)
            });

            bottomBar.AddChild(new Button()
            {
                Text       = "Fire",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    if (Employee == null)
                    {
                        return;
                    }

                    Root.ShowModalPopup(Root.ConstructWidget(new Confirm
                    {
                        OkayText    = Library.GetString("fire-dwarf"),
                        CancelText  = Library.GetString("keep-dwarf"),
                        Text        = String.Format("Really fire {0}? They will collect {1} in severance pay.", Employee.Stats.FullName, Employee.Stats.CurrentLevel.Pay * 4),
                        Padding     = new Margin(32, 10, 10, 10),
                        MinimumSize = new Point(512, 128),
                        OnClose     = (confirm) =>
                        {
                            if ((confirm as Gui.Widgets.Confirm).DialogResult == DwarfCorp.Gui.Widgets.Confirm.Result.OKAY)
                            {
                                SoundManager.PlaySound(ContentPaths.Audio.change, 0.25f);

                                if (Employee.IsDead)
                                {
                                    return;
                                }

                                if (Employee.GetRoot().GetComponent <Inventory>().HasValue(out var inv))
                                {
                                    inv.Die();
                                }

                                Employee.World.MakeAnnouncement(Library.GetString("was-fired", Employee.Stats.FullName));
                                Employee.GetRoot().Delete();

                                Employee.World.FireEmployee(Employee);
                            }
                        }
                    }));

                    Root.SafeCall(OnFireClicked, this);
                }
            });
Exemple #4
0
        public override void Construct()
        {
            Font = "font8";

            PayLabel = AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            AgeLabel = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var columns = AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 100),
                ColumnCount = 3
            });

            var left          = columns.AddChild(new Gui.Widget());
            var right         = columns.AddChild(new Gui.Widget());
            var evenMoreRight = columns.AddChild(new Gui.Widget());

            #region Stats
            var statParent = left.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout          = AutoLayout.DockTop,
                MinimumSize         = new Point(0, 60),
                TriggerOnChildClick = true,
                OnClick             = (sender, args) =>
                {
                    var employeeInfo = sender.FindParentOfType <OverviewPanel>();
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("MODIFIERS: CHA  CON  DEX  INT  SIZ  STR  WIS \n");
                        // Todo: Need to align columns. Current method only works for monospaced fonts.

                        foreach (var modifier in employeeInfo.Employee.Creature.Stats.EnumerateStatAdjustments())
                        {
                            stringBuilder.Append(SetLength(modifier.Name, 9));
                            stringBuilder.Append(": ");
                            stringBuilder.Append(FormatNumber(modifier.Charisma));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Constitution));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Dexterity));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Intelligence));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Size));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Strength));
                            stringBuilder.Append(" ");
                            stringBuilder.Append(FormatNumber(modifier.Wisdom));
                            stringBuilder.Append("\n");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };

                        sender.Root.ShowMinorPopup(popup);
                    }
                }
            });

            var statsLeft  = statParent.AddChild(new Widget());
            var statsRight = statParent.AddChild(new Widget());

            StatDexterity = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Dexterity (affects dwarf speed)"
            });

            StatStrength = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Strength (affects dwarf attack power)"
            });

            StatWisdom = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Wisdom (affects temprement and spell resistance)"
            });

            StatCharisma = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Charisma (affects ability to make friends)"
            });

            StatConstitution = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Constitution (affects dwarf health and damage resistance)"
            });

            StatIntelligence = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Intelligence (affects crafting/farming)"
            });

            StatSize = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Size"
            });
            #endregion

            #region status bars
            Hunger    = CreateStatusBar(right, "Hunger", "Starving", "Hungry", "Peckish", "Okay");
            Energy    = CreateStatusBar(right, "Energy", "Exhausted", "Tired", "Okay", "Energetic");
            Happiness = CreateStatusBar(right, "Happiness", "Miserable", "Unhappy", "So So", "Happy", "Euphoric");
            Health    = CreateStatusBar(evenMoreRight, "Health", "Near Death", "Critical", "Hurt", "Uncomfortable", "Fine", "Perfect");
            Boredom   = CreateStatusBar(evenMoreRight, "Boredom", "Desperate", "Overworked", "Bored", "Meh", "Fine", "Excited");
            #endregion

            Thoughts = AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var bottomBar = AddChild(new Widget
            {
                Transparent = true,
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 32)
            });


            base.Construct();
        }
Exemple #5
0
        public override void Construct()
        {
            Text = "Select a single employee to view stats.";
            Font = "font16";

            InteriorPanel = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                Hidden     = true,
                Background = new TileReference("basic", 0),
                Font       = "font8",
            });

            var top = InteriorPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 96)
            });

            Icon = top.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(64, 96),
            });

            NameLabel = top.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 32),
                Font        = "font16"
            });

            LevelLabel = top.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var columns = InteriorPanel.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 120)
            });

            var left  = columns.AddChild(new Gui.Widget());
            var right = columns.AddChild(new Gui.Widget());

            #region Stats
            var statParent = left.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 60)
            });

            var statsLeft  = statParent.AddChild(new Widget());
            var statsRight = statParent.AddChild(new Widget());

            StatDexterity = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Dexterity (affects dwarf speed)"
            });

            StatStrength = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Strength (affects dwarf attack power)"
            });

            StatWisdom = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Wisdom (affects temprement and spell resistance)"
            });

            StatCharisma = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Charisma (affects ability to make friends)"
            });

            StatConstitution = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Constitution (affects dwarf health and damage resistance)"
            });

            StatIntelligence = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Intelligence (affects crafting/farming)"
            });

            StatSize = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Size"
            });
            #endregion

            #region status bars
            Hunger    = CreateStatusBar(right, "Hunger", "Starving", "Hungry", "Peckish", "Okay");
            Energy    = CreateStatusBar(right, "Energy", "Exhausted", "Tired", "Okay", "Energetic");
            Happiness = CreateStatusBar(right, "Happiness", "Miserable", "Unhappy", "So So", "Happy", "Euphoric");
            Health    = CreateStatusBar(right, "Health", "Near Death", "Critical", "Hurt", "Uncomfortable", "Fine", "Perfect");
            #endregion

            PayLabel = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            AgeLabel = InteriorPanel.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            Bio = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var task = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(1, 24)
            });

            var inventory = task.AddChild(new Button
            {
                AutoLayout = AutoLayout.DockRight,
                Text       = "Backpack...",
                OnClick    = (sender, args) =>
                {
                    var employeeInfo = sender.Parent.Parent.Parent as EmployeeInfo;
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("Backpack contains:\n");
                        Dictionary <string, ResourceAmount> aggregateResources = employeeInfo.Employee.Creature.Inventory.Aggregate();
                        foreach (var resource in aggregateResources)
                        {
                            stringBuilder.Append(String.Format("{0}x {1}\n", resource.Value.NumResources, resource.Key));
                        }
                        if (aggregateResources.Count == 0)
                        {
                            stringBuilder.Append("Nothing.");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };


                        sender.Root.ShowMinorPopup(popup);

                        if (aggregateResources.Count > 0)
                        {
                            popup.AddChild(new Button()
                            {
                                Text       = "Empty",
                                Tooltip    = "Click to order this dwarf to empty their backpack.",
                                AutoLayout = AutoLayout.FloatBottomLeft,
                                OnClick    = (currSender, currArgs) =>
                                {
                                    if (employeeInfo != null && employeeInfo.Employee != null &&
                                        employeeInfo.Employee.Creature != null)
                                    {
                                        employeeInfo.Employee.Creature.RestockAllImmediately();
                                    }
                                }
                            });
                            popup.Layout();
                        }
                    }
                }
            });

            CancelTask = task.AddChild(new Button
            {
                AutoLayout = AutoLayout.DockRight,
                Text       = "Cancel Task"
            });

            TaskLabel = task.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                MinimumSize         = new Point(128, 24),
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right
            });

            Thoughts = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var bottomBar = InteriorPanel.AddChild(new Widget
            {
                Transparent = true,
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 32)
            });

            bottomBar.AddChild(new Button()
            {
                Text       = "Fire",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    Root.SafeCall(OnFireClicked, this);
                }
            });

            if (EnablePosession)
            {
                bottomBar.AddChild(new Button()
                {
                    Text       = "Follow",
                    Tooltip    = "Click to directly control this dwarf and have the camera follow.",
                    AutoLayout = AutoLayout.DockRight,
                    OnClick    = (sender, args) =>
                    {
                        (sender.Parent.Parent.Parent as EmployeeInfo).Employee.World.Tutorial("dwarf follow");
                        (sender.Parent.Parent.Parent as EmployeeInfo).Employee.IsPosessed = true;
                    }
                });
            }

            LevelButton = bottomBar.AddChild(new Button()
            {
                Text       = "Promote!",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                Tooltip    = "Click to promote this dwarf.\nPromoting Dwarves raises their pay and makes them\nmore effective workers.",
                OnClick    = (sender, args) =>
                {
                    Employee.Stats.LevelUp();
                    SoundManager.PlaySound(ContentPaths.Audio.change, 0.5f);
                    Invalidate();
                    Employee.AddThought(Thought.ThoughtType.GotPromoted);
                }
            });

            base.Construct();
        }