Esempio n. 1
0
        protected override Gui.Mesh Redraw()
        {
            if (Applicant != null)
            {
                NameLabel.Text         = Applicant.Name;
                ClassLabel.Text        = Applicant.Class.Name;
                StartingWageLabel.Text = String.Format("Starts at {0}/day", Applicant.Level.Pay);
                SigningBonusLabel.Text = String.Format("{0} signing bonus", Applicant.Level.Pay * 4);
                LastJobLabel.Text      = String.Format("Last job - {0}", Applicant.FormerProfession);
                LastJobLocation.Text   = String.Format("Home town - {0}", Applicant.HomeTown);
                Biography.Text         = Applicant.Biography;
                Resume.Text            = Applicant.CoverLetter;
                var idx = EmployeePanel.GetIconIndex(Applicant.Class.Name);
                Portrait.Background = idx >= 0 ? new TileReference("dwarves", idx) : null;
                Portrait.Invalidate();
            }

            return(base.Redraw());
        }
Esempio n. 2
0
        public override void Construct()
        {
            Border = "border-fancy";

            int w = Math.Min(Math.Max(2 * (Root.RenderData.VirtualScreen.Width / 3), 400), 600);
            int h = Math.Min(Math.Max(2 * (Root.RenderData.VirtualScreen.Height / 3), 600), 700);

            Rect = new Rectangle(Root.RenderData.VirtualScreen.Center.X - w / 2, Root.RenderData.VirtualScreen.Center.Y - h / 2, w, h);

            var left = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(5, 5, 32, 32),
                MinimumSize = new Point(32 * 2 * JobLibrary.Classes.Count, 48 * 2 + 40)
            });

            var right = AddChild(new Widget()
            {
                AutoLayout = AutoLayout.DockFill
            });


            var buttonRow = right.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 30)
            });

            var applicantInfo = right.AddChild(new ApplicantInfo
            {
                AutoLayout = AutoLayout.DockFill
            }) as ApplicantInfo;


            applicantInfo.Hidden = true;
            left.AddChild(new Widget
            {
                Text        = "Applicants",
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 20),
                Font        = "font16"
            });


            foreach (var job in JobLibrary.Classes)
            {
                var newJob = job.Key;
                var frame  = left.AddChild(new Widget()
                {
                    MinimumSize = new Point(32 * 2, 48 * 2 + 15),
                    AutoLayout  = AutoLayout.DockLeft
                });
                var idx = EmployeePanel.GetIconIndex(job.Value.Name);
                frame.AddChild(new ImageButton()
                {
                    Tooltip             = "Click to review applications for " + job.Value.Name,
                    AutoLayout          = AutoLayout.DockTop,
                    TextHorizontalAlign = HorizontalAlign.Center,
                    TextVerticalAlign   = VerticalAlign.Bottom,
                    OnClick             = (sender, args) =>
                    {
                        applicantInfo.Hidden = false;
                        HireButton.Hidden    = false;
                        HireButton.Invalidate();
                        applicantInfo.Applicant = GenerateApplicant(Company, newJob);
                    },
                    Background  = idx >= 0 ? new TileReference("dwarves", idx) : null,
                    MinimumSize = new Point(32 * 2, 48 * 2),
                    MaximumSize = new Point(32 * 2, 48 * 2)
                });
                frame.AddChild(new Widget()
                {
                    Text                = job.Value.Name,
                    MinimumSize         = new Point(0, 15),
                    TextColor           = Color.Black.ToVector4(),
                    Font                = "font8",
                    AutoLayout          = AutoLayout.DockTop,
                    TextHorizontalAlign = HorizontalAlign.Center
                });
            }

            buttonRow.AddChild(new Widget
            {
                Text       = "Back",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockLeft,
                OnClick    = (sender, args) =>
                {
                    this.Close();
                }
            });

            HireButton = buttonRow.AddChild(new Button
            {
                Text       = "Hire",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    var applicant = applicantInfo.Applicant;
                    if (applicant != null)
                    {
#if DEMO
                        if (applicant.Class.Name == "Wizard")
                        {
                            Root.ShowModalPopup(new Gui.Widgets.Confirm()
                            {
                                CancelText = "", Text = "Magic not available in demo."
                            });
                            return;
                        }
#endif
                        if (GameSettings.Default.SigningBonus > Faction.Economy.CurrentMoney)
                        {
                            Root.ShowModalPopup(Root.ConstructWidget(new Gui.Widgets.Popup
                            {
                                Text = "We can't afford the signing bonus!",
                            }));
                        }
                        else if (!Faction.GetRooms().Any(r => r.RoomData.Name == "Balloon Port"))
                        {
                            Root.ShowModalPopup(Root.ConstructWidget(new Gui.Widgets.Popup
                            {
                                Text = "We need a balloon port to hire someone.",
                            }));
                        }
                        else if (Faction.Minions.Count + Faction.World.Master.NewArrivals.Count >= GameSettings.Default.MaxDwarfs)
                        {
                            Root.ShowModalPopup(Root.ConstructWidget(new Gui.Widgets.Popup
                            {
                                Text = String.Format("Can't hire any more dwarfs. We can only have {0}.", GameSettings.Default.MaxDwarfs)
                            }));
                        }
                        else
                        {
                            var date = Faction.Hire(applicant, 1);
                            SoundManager.PlaySound(ContentPaths.Audio.cash, 0.5f);
                            applicantInfo.Hidden = true;
                            HireButton.Hidden    = true;
                            Root.ShowModalPopup(new Gui.Widgets.Popup()
                            {
                                Text = String.Format("We hired {0}, paying a signing bonus of {1}. They will arrive in about {2} hour(s).",
                                                     applicant.Name,
                                                     GameSettings.Default.SigningBonus,
                                                     (date - Faction.World.Time.CurrentDate).Hours),
                            });
                        }
                    }
                },
                Hidden = true
            }) as Button;
            this.Layout();
        }
Esempio n. 3
0
        protected override Gui.Mesh Redraw()
        {
            // Set values from CreatureAI
            if (Employee != null)
            {
                InteriorPanel.Hidden = false;

                var idx = EmployeePanel.GetIconIndex(Employee.Stats.CurrentClass.Name);
                Icon.Background = idx >= 0 ? new TileReference("dwarves", idx) : null;
                Icon.Invalidate();

                NameLabel.Text        = "\n" + Employee.Stats.FullName;
                StatDexterity.Text    = String.Format("Dex: {0}", Employee.Stats.BuffedDex);
                StatStrength.Text     = String.Format("Str: {0}", Employee.Stats.BuffedStr);
                StatWisdom.Text       = String.Format("Wis: {0}", Employee.Stats.BuffedWis);
                StatConstitution.Text = String.Format("Con: {0}", Employee.Stats.BuffedCon);
                StatIntelligence.Text = String.Format("Int: {0}", Employee.Stats.BuffedInt);
                StatSize.Text         = String.Format("Size: {0}", Employee.Stats.BuffedSiz);
                StatCharisma.Text     = String.Format("Cha: {0}", Employee.Stats.BuffedChar);
                SetStatusBar(Hunger, Employee.Status.Hunger);
                SetStatusBar(Energy, Employee.Status.Energy);
                SetStatusBar(Happiness, Employee.Status.Happiness);
                SetStatusBar(Health, Employee.Status.Health);

                LevelLabel.Text = String.Format("\n{0}: Level {1} {2} ({3} xp). {4}", Employee.Stats.CurrentLevel.Name,
                                                Employee.Stats.LevelIndex,
                                                Employee.Stats.CurrentClass.Name,
                                                Employee.Stats.XP,
                                                Employee.Creature.Gender);

                Bio.Text = Employee.Biography;

                StringBuilder thoughtsBuilder = new StringBuilder();
                thoughtsBuilder.Append("Thoughts:\n");
                foreach (var thought in Employee.Thoughts)
                {
                    thoughtsBuilder.Append(String.Format("{0} ({1})\n", thought.Description, thought.HappinessModifier));
                }
                var diseases = Employee.Creature.Buffs.OfType <Disease>();
                if (diseases.Any())
                {
                    thoughtsBuilder.Append("Conditions: ");
                }

                if (Employee.Status.IsAsleep)
                {
                    thoughtsBuilder.AppendLine("Unconscious");
                }

                foreach (var disease in diseases)
                {
                    thoughtsBuilder.AppendLine(disease.Name);
                }
                Thoughts.Text = thoughtsBuilder.ToString();

                if (Employee.Stats.CurrentClass.Levels.Count > Employee.Stats.LevelIndex + 1)
                {
                    var nextLevel = Employee.Stats.CurrentClass.Levels[Employee.Stats.LevelIndex + 1];
                    var diff      = nextLevel.XP - Employee.Stats.XP;

                    if (diff > 0)
                    {
                        //ExperienceLabel.Text = String.Format("XP: {0}\n({1} to next level)",
                        //    Employee.Stats.XP, diff);
                        LevelButton.Hidden = true;
                        LevelButton.Invalidate();
                    }
                    else
                    {
                        //ExperienceLabel.Text = String.Format("XP: {0}\n({1} to next level)",
                        //    Employee.Stats.XP, "(Overqualified)");
                        LevelButton.Hidden  = false;
                        LevelButton.Tooltip = "Promote to " + nextLevel.Name;
                        LevelButton.Invalidate();
                    }
                }
                else
                {
                    //ExperienceLabel.Text = String.Format("XP: {0}", Employee.Stats.XP);
                }

                PayLabel.Text = String.Format("Pay: {0}/day\nWealth: {1}", Employee.Stats.CurrentLevel.Pay,
                                              Employee.Status.Money);

                if (Employee.CurrentTask != null)
                {
                    TaskLabel.Text       = "Current Task: " + Employee.CurrentTask.Name;
                    CancelTask.TextColor = new Vector4(0, 0, 0, 1);
                    CancelTask.Invalidate();
                    CancelTask.OnClick = (sender, args) =>
                    {
                        if (Employee.CurrentTask != null)
                        {
                            Employee.CurrentTask.Cancel();
                            Employee.CurrentTask = null;
                            TaskLabel.Text       = "No tasks";
                            TaskLabel.Invalidate();
                            CancelTask.OnClick   = null;
                            CancelTask.TextColor = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
                            CancelTask.Invalidate();
                        }
                    };
                }
                else
                {
                    TaskLabel.Text       = "No tasks";
                    CancelTask.OnClick   = null;
                    CancelTask.TextColor = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
                    CancelTask.Invalidate();
                }

                AgeLabel.Text = String.Format("Age: {0}", Employee.Stats.Age);
            }
            else
            {
                InteriorPanel.Hidden = true;
            }

            foreach (var child in Children)
            {
                child.Invalidate();
            }

            return(base.Redraw());
        }