Example #1
0
        private void RebuildEmployeeList()
        {
            EmployeeList.ClearItems();

            EmployeeList.AddItem(new Widget
            {
                Text        = "+ Hire New Employee",
                MinimumSize = new Point(128, 64),
                OnClick     = (sender, args) =>
                {
                    // Show hire dialog.
                    var dialog = Root.ConstructWidget(
                        new HireEmployeeDialog(World.PlayerFaction.Economy.Information)
                    {
                        World   = World,
                        OnClose = (_s) =>
                        {
                            EmployeeList.Hidden = false;
                            RebuildEmployeeList();
                        }
                    });
                    Root.ShowModalPopup(dialog);
                    World.Tutorial("hire");
                    EmployeeList.Hidden = true;
                }
            });

            foreach (var employee in World.PlayerFaction.Minions.Where(m => PassesFilter(m)))
            {
                var bar = Root.ConstructWidget(new Widget
                {
                    Background = new TileReference("basic", 0),
                    Tag        = employee
                });

                if (employee.GetRoot().GetComponent <DwarfSprites.LayeredCharacterSprite>().HasValue(out var employeeSprite))
                {
                    bar.AddChild(new EmployeePortrait
                    {
                        AutoLayout      = AutoLayout.DockLeft,
                        MinimumSize     = new Point(48, 40),
                        MaximumSize     = new Point(48, 40),
                        Sprite          = employeeSprite.GetLayers(),
                        AnimationPlayer = employeeSprite.AnimPlayer
                    });
                }

                bar.AddChild(new Widget
                {
                    AutoLayout        = AutoLayout.DockFill,
                    TextVerticalAlign = VerticalAlign.Center,
                    MinimumSize       = new Point(128, 64),
                    Text = (employee.Stats.IsOverQualified ? employee.Stats.FullName + "*" : employee.Stats.FullName) + " (" + (employee.Stats.Title ?? employee.Stats.CurrentLevel.Name) + ")"
                });

                EmployeeList.AddItem(bar);
            }

            EmployeeList.SelectedIndex = 1;
        }
Example #2
0
        private void RebuildEmployeeList()
        {
            EmployeeList.ClearItems();

            foreach (var employee in Faction.Minions)
            {
                var bar = Root.ConstructWidget(new Widget
                {
                    Background = new TileReference("basic", 0)
                });
                var employeeSprite = employee.GetRoot().GetComponent <LayeredSprites.LayeredCharacterSprite>();


                if (employeeSprite != null)
                {
                    bar.AddChild(new EmployeePortrait
                    {
                        AutoLayout      = AutoLayout.DockLeft,
                        MinimumSize     = new Point(48, 40),
                        MaximumSize     = new Point(48, 40),
                        Sprite          = employeeSprite.GetLayers(),
                        AnimationPlayer = employeeSprite.AnimPlayer
                    });
                }

                var title = employee.Stats.Title ?? employee.Stats.CurrentLevel.Name;
                bar.AddChild(new Widget
                {
                    AutoLayout        = AutoLayout.DockFill,
                    TextVerticalAlign = VerticalAlign.Center,
                    MinimumSize       = new Point(128, 64),
                    Text = (employee.Stats.IsOverQualified ? employee.Stats.FullName + "*" : employee.Stats.FullName) + " (" + title + ")"
                });

                EmployeeList.AddItem(bar);
            }

            EmployeeList.AddItem(new Widget
            {
                Text        = "+ Hire New Employee",
                MinimumSize = new Point(128, 64),
                OnClick     = (sender, args) =>
                {
                    // Show hire dialog.
                    var dialog = Root.ConstructWidget(
                        new HireEmployeeDialog(Faction.World.PlayerCompany.Information)
                    {
                        Faction = Faction,
                        OnClose = (_s) =>
                        {
                            RebuildEmployeeList();
                        }
                    });
                    Root.ShowModalPopup(dialog);
                    Faction.World.Tutorial("hire");
                }
            });

            EmployeeList.SelectedIndex = 0;
        }
Example #3
0
        private void RebuildEmployeeList()
        {
            EmployeeList.ClearItems();

            foreach (var employee in Faction.Minions)
            {
                var bar = Root.ConstructWidget(new Widget
                {
                    Background = new TileReference("basic", 0)
                });
                var idx = GetIconIndex(employee.Stats.CurrentClass.Name);
                bar.AddChild(new Widget
                {
                    AutoLayout  = AutoLayout.DockLeft,
                    MinimumSize = new Point(32, 48),
                    Background  = idx >= 0 ? new TileReference("dwarves", idx) : null
                });

                bar.AddChild(new Widget
                {
                    AutoLayout        = AutoLayout.DockFill,
                    TextVerticalAlign = VerticalAlign.Center,
                    Text = employee.Stats.IsOverQualified ? employee.Stats.FullName + "*" : employee.Stats.FullName
                });

                EmployeeList.AddItem(bar);
            }

            EmployeeList.AddItem(new Widget
            {
                Text    = "+ Hire New Employee",
                OnClick = (sender, args) =>
                {
                    // Show hire dialog.
                    var dialog = Root.ConstructWidget(
                        new HireEmployeeDialog(Faction.World.PlayerCompany.Information)
                    {
                        Faction = Faction,
                        OnClose = (_s) =>
                        {
                            RebuildEmployeeList();
                        }
                    });
                    Root.ShowModalPopup(dialog);
                    Faction.World.Tutorial("hire");
                }
            });

            EmployeeList.SelectedIndex = 0;
        }
Example #4
0
        private void RebuildEmployeeList()
        {
            EmployeeList.ClearItems();

            for (var i = 0; i < Settings.InstanceSettings.InitalEmbarkment.Employees.Count; ++i)
            {
                EmployeeList.AddItem(CreateEmployeeListing(Settings.InstanceSettings.InitalEmbarkment.Employees[i], i));
            }
        }
        private void RebuildModListGUI()
        {
            ModListGUI.ClearItems();
            int k = 0;

            foreach (var mod in ModList)
            {
                if (mod.GUI == null)
                {
                    mod.GUI = BuildLineItemGUI(mod, k);
                }
                ModListGUI.AddItem(mod.GUI);
                k++;
            }
        }
Example #6
0
        private void UpdateColumn(Gui.Widgets.WidgetListView ListView, List <TradeableItem> selectedResources)
        {
            var lineItems = ListView.GetItems();

            ListView.ClearItems();
            for (var i = 0; i < SelectedResources.Count; ++i)
            {
                Widget lineItem = null;
                if (i >= lineItems.Count)
                {
                    lineItem = CreateLineItem(selectedResources[i]);
                }
                else
                {
                    lineItem = lineItems[i];
                }

                UpdateLineItemText(lineItem, selectedResources[i]);

                ListView.AddItem(lineItem);
            }
        }
Example #7
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            if (NeedsRefresh)
            {
                NeedsRefresh = false;
                Grid.ClearItems();
                int i = 0;
                foreach (var item in Items)
                {
                    var itemWidget = new ChooserWidget
                    {
                        Item            = item,
                        Background      = new TileReference("basic", 0),
                        BackgroundColor = i % 2 == 0 ? new Vector4(0, 0, 0, 0.1f) : new Vector4(0, 0, 0, 0.2f)
                    };

                    Grid.AddItem(itemWidget);

                    itemWidget.DeleteButton.OnClick = (sender, args) =>
                    {
                        var confirm = GuiRoot.ConstructWidget(new Gui.Widgets.Confirm
                        {
                            OkayText   = "Delete",
                            CancelText = "Keep",
                            Text       = "Are you sure you want to delete this?",
                            OnClose    = (s) =>
                            {
                                if ((s as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                                {
                                    var selectedItem = itemWidget.Item;
                                    Items.Remove(selectedItem);
                                    try
                                    {
                                        global::System.IO.Directory.Delete(selectedItem.Path, true);
                                    }
                                    catch (Exception e)
                                    {
                                        GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm()
                                        {
                                            OkayText   = "Ok",
                                            CancelText = "",
                                            Text       = e.Message
                                        });
                                    }
                                    NeedsRefresh = true;
                                }
                            }
                        });
                        GuiRoot.ShowModalPopup(confirm);
                    };

                    if (itemWidget.LoadButton != null)
                    {
                        itemWidget.LoadButton.OnClick = (sender, args) =>
                        {
                            if (String.IsNullOrEmpty(itemWidget.Item.Valid) && OnProceedClicked != null)
                            {
                                OnProceedClicked(itemWidget.Item.Path);
                            }
                        }
                    }
                    ;

                    i++;
                }

                Grid.OnSelectedIndexChanged = (widget) =>
                {
                    this.ItemSelected = Grid.SelectedIndex;
                    NeedsRefresh      = true;
                };
                if (Grid.SelectedIndex > Items.Count - 1 || Grid.SelectedIndex < 0)
                {
                    Grid.SelectedIndex = 0;
                }
                ItemSelected = Grid.SelectedIndex;
                if (Items.Count > 0)
                {
                    DateTime directoryTime;
                    try
                    {
                        directoryTime = global::System.IO.File.GetLastWriteTime(Items[ItemSelected].Path + System.IO.Path.DirectorySeparatorChar + "meta.txt");
                    }
                    catch (Exception)
                    {
                        directoryTime = DateTime.MinValue;
                    }

                    BottomBar.Text = Items[ItemSelected].Path;

                    if (!String.IsNullOrEmpty(Items[ItemSelected].Valid))
                    {
                        BottomBar.Text += "\n" + Items[ItemSelected].Valid;
                    }
                    else
                    {
                        BottomBar.Text += "\n" + directoryTime.ToShortDateString() + " " + directoryTime.ToShortTimeString();
                    }
                }
                else
                {
                    BottomBar.Text = NoItemsText;
                }
            }

            GuiRoot.Update(gameTime.ToRealTime());
            base.Update(gameTime);
        }
Example #8
0
        public override void Construct()
        {
            base.Construct();

            SubscribedItems = Steam.GetSubscribedMods();

            this.Padding = new Margin(4, 4, 4, 4);
            this.Font    = "font10";

            var top = AddChild(new Widget
            {
                Transparent = true,
                MinimumSize = new Point(0, 32),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(2, 2, 2, 2)
            });

            var searchText = top.AddChild(new Gui.Widgets.EditableTextField
            {
                PromptText  = "Enter text to search for",
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(256, 0),
            }) as Gui.Widgets.EditableTextField;

            var button = top.AddChild(new Gui.Widgets.Button
            {
                Text = "Search",
                Font = "font10",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    if (!Steam.SteamAvailable)
                    {
                        List.ClearItems();
                        List.AddItem(new Widget()
                        {
                            Text       = "Error: Can't connect to steam!",
                            Background = new TileReference("basic", 0),
                            TextColor  = new Vector4(0, 0, 0, 1),
                        });
                        return;
                    }

                    if (!Steam.HasTransactionOfType <UGCQuery>())
                    {
                        Steam.AddTransaction(new UGCTransactionProcessor
                        {
                            Transaction = new UGCQuery
                            {
                                SearchString = searchText.Text
                            },
                            StatusMessageDisplay = QueryStatusMessage,
                            OnSuccess            = (query) => RefreshList((query.Transaction as UGCQuery).Results)
                        });
                    }
                },
                AutoLayout = AutoLayout.DockRight
            });

            searchText.OnEnter = (sender) =>
            {
                button.OnClick.Invoke(button, null);
            };


            QueryStatusMessage = top.AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill
            });

            List = AddChild(new WidgetListView
            {
                ItemHeight = 32,
                AutoLayout = AutoLayout.DockFill,
                Border     = null,
                SelectedItemBackgroundColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
                Padding = new Margin(2, 2, 2, 2)
            }) as WidgetListView;
        }