Esempio n. 1
0
        public SpinBox(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SpinMode mode)
            : base(gui, parent)
        {
            Increment = 1.0f;
            SpinValue = value;
            MinValue = minValue;
            MaxValue = maxValue;
            Mode = mode;
            Layout = new GridLayout(GUI, this, 1, 4);
            PlusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            MinusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            ValueBox = new LineEdit(GUI, Layout, value.ToString())
            {
                IsEditable = false
            };
            Layout.SetComponentPosition(ValueBox, 0, 0, 2, 1);
            Layout.SetComponentPosition(PlusButton, 3, 0, 1, 1);
            Layout.SetComponentPosition(MinusButton, 2, 0, 1, 1);

            PlusButton.OnClicked += PlusButton_OnClicked;
            MinusButton.OnClicked += MinusButton_OnClicked;
            OnValueChanged += SpinBox_OnValueChanged;
        }
Esempio n. 2
0
        public Window(DwarfGUI gui, GUIComponent parent, WindowButtons buttons = WindowButtons.NoButtons)
            : base(gui, parent)
        {
            IsDragging = false;
            IsResizing = false;
            Mode = buttons == WindowButtons.NoButtons ? PanelMode.Window : PanelMode.WindowEx;

            if (buttons == WindowButtons.CloseButton)
            {
                CloseButton = new Button(GUI, this, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.CloseButton));
                CloseButton.OnClicked += CloseButton_OnClicked;
            }
        }
Esempio n. 3
0
        public virtual void Initialize(ButtonType buttons, string title, string message)
        {
            IsModal = true;
            OnClicked += Dialog_OnClicked;
            OnClosed += Dialog_OnClosed;

            Layout = new GridLayout(GUI, this, 4, 4);
            Title = new Label(GUI, Layout, title, GUI.DefaultFont);
            Layout.SetComponentPosition(Title, 0, 0, 1, 1);

            Message = new Label(GUI, Layout, message, GUI.DefaultFont)
            {
                WordWrap = true
            };
            Layout.SetComponentPosition(Message, 0, 1, 4, 2);

            bool createOK = false;
            bool createCancel = false;

            switch (buttons)
            {
                case ButtonType.None:
                    break;
                case ButtonType.OkAndCancel:
                    createOK = true;
                    createCancel = true;
                    break;
                case ButtonType.OK:
                    createOK = true;
                    break;
                case ButtonType.Cancel:
                    createCancel = true;
                    break;
            }

            if (createOK)
            {
                Button okButton = new Button(GUI, Layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
                Layout.SetComponentPosition(okButton, 2, 3, 2, 1);
                okButton.OnClicked += OKButton_OnClicked;
            }

            if (createCancel)
            {
                Button cancelButton = new Button(GUI, Layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex));
                Layout.SetComponentPosition(cancelButton, 0, 3, 2, 1);
                cancelButton.OnClicked += cancelButton_OnClicked;
            }
        }
Esempio n. 4
0
        public void CreateSellTab()
        {
            TabSelector.Tab sellTab = Tabs.AddTab("Sell");

            GridLayout sellBoxLayout = new GridLayout(GUI, sellTab, 10, 4);

            SellSelector = new ItemSelector(GUI, sellBoxLayout, "Items")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice,
                    ItemSelector.Column.ArrowRight
                },
                NoItemsMessage = "No goods in our stockpiles",
                ToolTip = "Click items to put them in the sell order"
            };

            sellBoxLayout.SetComponentPosition(SellSelector, 0, 0, 2, 10);

            SellSelector.Items.AddRange(GetResources(Faction.ListResources().Values.ToList()));
            SellSelector.ReCreateItems();

            SellCart = new ItemSelector(GUI, sellBoxLayout, "Order")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.ArrowLeft,
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice
                },
                NoItemsMessage = "No items selected",
                ToolTip = "Click items to remove them from the sell order"
            };
            SellCart.ReCreateItems();
            sellBoxLayout.SetComponentPosition(SellCart, 2, 0, 2, 9);

            SellSelector.OnItemRemoved += SellCart.AddItem;
            SellCart.OnItemRemoved += SellSelector.AddItem;

            Button sellButton = new Button(GUI, sellBoxLayout, "Sell", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Click to sell items in the order"
            };

            sellBoxLayout.SetComponentPosition(sellButton, 3, 9, 1, 2);

            sellButton.OnClicked += sellButton_OnClicked;

            SellTotal = new Label(GUI, sellBoxLayout, "Order Total: $0.00", GUI.DefaultFont)
            {
                WordWrap = true,
                ToolTip = "Order total"
            };

            sellBoxLayout.SetComponentPosition(SellTotal, 2, 9, 1, 2);

            SellCart.OnItemChanged += SellCart_OnItemChanged;
        }
Esempio n. 5
0
        public void CreateBuyTab()
        {
            TabSelector.Tab buyTab = Tabs.AddTab("Buy");

            GridLayout buyBoxLayout = new GridLayout(GUI, buyTab, 10, 4);

            BuySelector = new ItemSelector(GUI, buyBoxLayout, "Items")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.PricePerItem,
                    ItemSelector.Column.ArrowRight
                },
                NoItemsMessage = "Nothing to buy",
                ToolTip = "Click items to add them to the shopping cart"
            };

            buyBoxLayout.SetComponentPosition(BuySelector, 0, 0, 2, 10);

            BuySelector.Items.AddRange(GetResources(1.0f));
            BuySelector.ReCreateItems();

            ShoppingCart = new ItemSelector(GUI, buyBoxLayout, "Order")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.ArrowLeft,
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice
                },
                NoItemsMessage = "No items selected",
                ToolTip = "Click items to remove them from the shopping cart",
                PerItemCost = 1.00f
            };
            ShoppingCart.ReCreateItems();
            buyBoxLayout.SetComponentPosition(ShoppingCart, 2, 0, 2, 9);

            BuySelector.OnItemRemoved += ShoppingCart.AddItem;
            ShoppingCart.OnItemRemoved += BuySelector.AddItem;
            ShoppingCart.OnItemChanged += shoppingCart_OnItemChanged;

            Button buyButton = new Button(GUI, buyBoxLayout, "Buy", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Click to order items in the shopping cart"
            };

            buyBoxLayout.SetComponentPosition(buyButton, 3, 9, 1, 2);

            BuyTotal = new Label(GUI, buyBoxLayout, "Order Total: $0.00", GUI.DefaultFont)
            {
                WordWrap = true,
                ToolTip = "Order total"
            };

            buyBoxLayout.SetComponentPosition(BuyTotal, 2, 9, 1, 2);

            buyButton.OnClicked += buyButton_OnClicked;
        }
Esempio n. 6
0
        public override void CreateGUIObjects()
        {
            FarmButton = new Button(PlayState.GUI, PlayState.GUI.RootComponent, "Farm", PlayState.GUI.DefaultFont,
             Button.ButtonMode.ImageButton, new NamedImageFrame(ContentPaths.GUI.icons, 32, 5, 1))
            {
                LocalBounds = new Rectangle(0, 0, 32, 32),
                DrawFrame = true,
                TextColor = Color.White,
                ToolTip = "Click to make selected employees work this " + RoomData.Name,
                DrawOrder = -100
            };
            FarmButton.OnClicked += farmButton_OnClicked;

            if (GUIObject != null)
            {
                GUIObject.Die();
            }

            GUIObject = new WorldGUIObject(PlayState.ComponentManager.RootComponent, FarmButton)
            {
                IsVisible = true,
                LocalTransform = Matrix.CreateTranslation(GetBoundingBox().Center())
            };
        }
Esempio n. 7
0
        public void Initialize()
        {
            ClearChildren();

            GridLayout panelLayout = new GridLayout(GUI, this, 10, 10);
            GroupBox employeeBox = new GroupBox(GUI, panelLayout, "Employees");
            GridLayout boxLayout = new GridLayout(GUI, employeeBox, 8, 4);
            ScrollView scrollView = new ScrollView(GUI, boxLayout);
            EmployeeSelector = new ListSelector(GUI, scrollView)
            {
                Label = "",
                DrawPanel = false,
                Mode = ListItem.SelectionMode.Selector,
                LocalBounds = new Rectangle(0, 0, 256, Faction.Minions.Count * 24),
                WidthSizeMode = SizeMode.Fit
            };

            boxLayout.SetComponentPosition(scrollView, 0, 1, 3, 6);
            panelLayout.SetComponentPosition(employeeBox, 0, 0, 3, 10);

            foreach (CreatureAI creature in Faction.Minions)
            {
                EmployeeSelector.AddItem(creature.Stats.FullName);
            }

            EmployeeSelector.OnItemSelected += EmployeeSelector_OnItemSelected;

            Button hireButton = new Button(GUI, boxLayout, "Hire new", GUI.DefaultFont, Button.ButtonMode.ToolButton,
                GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                ToolTip = "Hire new employees"
            };

            boxLayout.SetComponentPosition(hireButton, 0, 7, 2, 1);

            hireButton.OnClicked += hireButton_OnClicked;

            CurrentMinionBox = new GroupBox(GUI, panelLayout, "");

            GridLayout minionLayout = new GridLayout(GUI, CurrentMinionBox, 10, 10);
            CurrentMinionPanel = new MinionPanel(GUI, minionLayout, Faction.Minions.FirstOrDefault());
            CurrentMinionPanel.Fire += CurrentMinionPanel_Fire;
            minionLayout.EdgePadding = 0;
            minionLayout.SetComponentPosition(CurrentMinionPanel, 0, 1, 10, 9);

            panelLayout.SetComponentPosition(CurrentMinionBox, 3, 0, 4, 10);

            if (Faction.Minions.Count > 0)
            {
                OnMinionSelected(Faction.Minions[0]);
            }
        }
Esempio n. 8
0
        public void CreateGUI()
        {
            Settings = new WorldSettings()
            {
                Width = 512,
                Height = 512,
                Name = GetRandomWorldName(),
                NumCivilizations = 5,
                NumFaults = 3,
                NumRains = 1000,
                NumVolcanoes = 3,
                RainfallScale = 1.0f,
                SeaLevel = 0.17f,
                TemperatureScale = 1.0f
            };
            Input = new InputManager();
            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default),
                                      Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title),
                                      Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small),
                                      Input);
            MainPanel = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds =
                    new Rectangle(128, 64, Game.GraphicsDevice.Viewport.Width - 256,
                        Game.GraphicsDevice.Viewport.Height - 128)
            };

            Layout = new GridLayout(GUI, MainPanel, 8, 6)
            {
                HeightSizeMode = GUIComponent.SizeMode.Fit,
                WidthSizeMode = GUIComponent.SizeMode.Fit
            };

            NameLabel = new Label(GUI, Layout, "World Name: ", GUI.DefaultFont);
            Layout.SetComponentPosition(NameLabel, 0, 0, 1, 1);

            NameEdit = new LineEdit(GUI, Layout, Settings.Name);
            Layout.SetComponentPosition(NameEdit, 1, 0, 4, 1);
            NameEdit.OnTextModified += NameEdit_OnTextModified;

            NameRandomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            Layout.SetComponentPosition(NameRandomButton, 5, 0, 1, 1);
            NameRandomButton.OnClicked += NameRandomButton_OnClicked;

            OptionsView = new ScrollView(GUI, Layout)
            {
                DrawBorder = true
            };
            Layout.SetComponentPosition(OptionsView, 0, 1, 6, 6);

            OptionsLayout = new FormLayout(GUI, OptionsView)
            {
                WidthSizeMode = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            ComboBox sizeBox = CreateOptionsBox("World Size", "Size of the world to generate", OptionsLayout);
            sizeBox.OnSelectionModified += sizeBox_OnSelectionModified;
            sizeBox.InvokeSelectionModified();

            ComboBox nativeBox = CreateOptionsBox("Natives", "Number of native civilizations", OptionsLayout);
            nativeBox.OnSelectionModified += nativeBox_OnSelectionModified;
            nativeBox.InvokeSelectionModified();

            ComboBox faultBox = CreateOptionsBox("Faults",  "Number of straights, seas, etc.", OptionsLayout);
            faultBox.OnSelectionModified += faultBox_OnSelectionModified;
            faultBox.InvokeSelectionModified();

            ComboBox rainBox = CreateOptionsBox("Rainfall", "Amount of moisture in the world.", OptionsLayout);
            rainBox.OnSelectionModified += rainBox_OnSelectionModified;
            rainBox.InvokeSelectionModified();

            ComboBox erosionBox = CreateOptionsBox("Erosion", "More or less eroded landscape.", OptionsLayout);
            erosionBox.OnSelectionModified += erosionBox_OnSelectionModified;
            erosionBox.InvokeSelectionModified();

            ComboBox seaBox = CreateOptionsBox("Sea Level", "Height of the sea.", OptionsLayout);
            seaBox.OnSelectionModified += seaBox_OnSelectionModified;
            seaBox.InvokeSelectionModified();

            ComboBox temp = CreateOptionsBox("Temperature", "Average temperature.", OptionsLayout);
            temp.OnSelectionModified += temp_OnSelectionModified;
            temp.InvokeSelectionModified();

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };
            Layout.SetComponentPosition(BackButton, 0, 7, 1, 1);
            BackButton.OnClicked += BackButton_OnClicked;

            AcceptButton = new Button(GUI, Layout, "Next", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.RightArrow))
            {
                ToolTip = "Generate a world with these settings"
            };
            AcceptButton.OnClicked += AcceptButton_OnClicked;
            Layout.SetComponentPosition(AcceptButton, 5, 7, 1, 1);
        }
Esempio n. 9
0
 public override void OnBuilt()
 {
     Button farmButton = new Button(PlayState.GUI, PlayState.GUI.RootComponent, "Farm", PlayState.GUI.DefaultFont,
         Button.ButtonMode.ImageButton, new NamedImageFrame(ContentPaths.GUI.icons, 32, 5, 1))
     {
         LocalBounds = new Rectangle(0, 0, 32, 32),
         DrawFrame = true,
         TextColor = Color.White,
         DrawOrder = -100
     };
     farmButton.OnClicked += farmButton_OnClicked;
     GUIObject = new WorldGUIObject(PlayState.ComponentManager.RootComponent, farmButton)
     {
         IsVisible = true,
         LocalTransform = Matrix.CreateTranslation(GetBoundingBox().Center())
     };
     base.OnBuilt();
 }
Esempio n. 10
0
        public override void Initialize(Dialog.ButtonType buttons, string title, string message)
        {
            WasSomeoneHired = false;
            GenerateApplicants();
            IsModal = true;
            OnClicked += HireDialog_OnClicked;
            OnClosed += HireDialog_OnClosed;

            int w = LocalBounds.Width;
            int h = LocalBounds.Height;
            int rows = h / 64;
            int cols = 8;

            GridLayout layout = new GridLayout(GUI, this, rows, cols);
            Title = new Label(GUI, layout, title, GUI.TitleFont);
            layout.SetComponentPosition(Title, 0, 0, 2, 1);

            GroupBox applicantSelectorBox = new GroupBox(GUI, layout, "");
            layout.SetComponentPosition(applicantSelectorBox, 0, 1, rows / 2 - 1, cols - 1);

            GridLayout selectorLayout = new GridLayout(GUI, applicantSelectorBox, 1, 1);
            ScrollView view = new ScrollView(GUI, selectorLayout);
            ApplicantSelector = new ListSelector(GUI, view)
            {
                Label = "-Applicants-"
            };

            selectorLayout.SetComponentPosition(view, 0, 0, 1, 1);

            foreach (Applicant applicant in Applicants)
            {
                ApplicantSelector.AddItem(applicant.Level.Name + " - " + applicant.Name);
            }

            ApplicantSelector.DrawPanel = false;
            ApplicantSelector.LocalBounds = new Rectangle(0, 0, 128, Applicants.Count * 24);

            ApplicantSelector.OnItemSelected += ApplicantSelector_OnItemSelected;

            CurrentApplicant = Applicants[0];

            GroupBox applicantPanel = new GroupBox(GUI, layout, "");
            layout.SetComponentPosition(applicantPanel, rows / 2 - 1, 1, rows / 2 - 1, cols - 1);

            GridLayout applicantLayout = new GridLayout(GUI, applicantPanel, 1, 1);

            ApplicantPanel = new ApplicationPanel(applicantLayout);
            applicantLayout.SetComponentPosition(ApplicantPanel, 0, 0, 1, 1);
            ApplicantPanel.SetApplicant(CurrentApplicant);

            bool createOK = false;
            bool createCancel = false;

            switch (buttons)
            {
                case ButtonType.None:
                    break;
                case ButtonType.OkAndCancel:
                    createOK = true;
                    createCancel = true;
                    break;
                case ButtonType.OK:
                    createOK = true;
                    break;
                case ButtonType.Cancel:
                    createCancel = true;
                    break;
            }

            if (createOK)
            {
                Button okButton = new Button(GUI, layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
                layout.SetComponentPosition(okButton, cols - 2, rows - 1 , 2, 1);
                okButton.OnClicked += okButton_OnClicked;
            }

            if (createCancel)
            {
                Button cancelButton = new Button(GUI, layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex));
                layout.SetComponentPosition(cancelButton, cols - 4, rows - 1, 2, 1);
                cancelButton.OnClicked += cancelButton_OnClicked;
            }

            HireButton = new Button(GUI, layout, "Hire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn));
            layout.SetComponentPosition(HireButton, cols - 1, rows - 2, 1, 1);

            HireButton.OnClicked += HireButton_OnClicked;
        }
Esempio n. 11
0
        public void InitializePanel()
        {
            StatLabels = new Dictionary<string, Label>();
            StatusBars = new Dictionary<string, MiniBar>();
            GridLayout layout = new GridLayout(GUI, this, 10, 8);

            CreateStatsLabel("Dexterity", "DEX:", layout);
            CreateStatsLabel("Strength", "STR:", layout);
            CreateStatsLabel("Wisdom", "WIS:", layout);
            CreateStatsLabel("Constitution", "CON:", layout);
            CreateStatsLabel("Intelligence", "INT:", layout);
            CreateStatsLabel("Size", "SIZ:", layout);

            int i = 0;
            int nx = 3;
            int ny = 2;
            foreach(KeyValuePair<string, Label> label in StatLabels)
            {
                layout.SetComponentPosition(label.Value, (i % nx), (((i - i % nx) / nx) % ny), 1, 1);
                i++;
            }

            CreateStatusBar("Hunger", layout);
            CreateStatusBar("Energy", layout);
            CreateStatusBar("Happiness", layout);
            CreateStatusBar("Health", layout);

            i = 0;
            nx = 2;
            ny = 3;
            foreach (KeyValuePair<string, MiniBar> label in StatusBars)
            {
                layout.SetComponentPosition(label.Value, (i % nx) * 2, (((i - i % nx) / nx) % ny) * 2 + 2, 2, 2);
                i++;
            }

            Portrait = new AnimatedImagePanel(GUI, layout, new ImageFrame())
            {
                KeepAspectRatio = true
            };

            layout.SetComponentPosition(Portrait, 5, 0, 4, 4);

            ClassLabel = new Label(GUI, layout, "Level", GUI.DefaultFont)
            {
                WordWrap = true
            };

            layout.SetComponentPosition(ClassLabel, 5, 4, 4, 2);

            XpLabel = new Label(GUI, layout, "XP", GUI.SmallFont)
            {
                WordWrap = true
            };

            layout.SetComponentPosition(XpLabel, 5, 7, 2, 1);

            PayLabel = new Label(GUI, layout, "Pay", GUI.SmallFont);
            layout.SetComponentPosition(PayLabel, 5, 8, 2, 1);

            LevelUpButton = new Button(GUI, layout, "Promote", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowUp));
            layout.SetComponentPosition(LevelUpButton, 5, 9, 2, 1);
            LevelUpButton.OnClicked += LevelUpButton_OnClicked;

            FireButton = new Button(GUI, layout, "Fire", GUI.DefaultFont, Button.ButtonMode.ToolButton,
                GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                ToolTip = "Let this employee go."
            };

            layout.SetComponentPosition(FireButton, 0, 9, 2, 1);

            FireButton.OnClicked +=FireButton_OnClicked;
        }
Esempio n. 12
0
        public Button CreateButton(GUIComponent parent, GameMaster.ToolMode mode, string name, string tooltip, int x, int y)
        {
            Button button = new Button(GUI, parent, name, GUI.SmallFont, Button.ButtonMode.ImageButton, new ImageFrame(Icons, IconSize, x, y))
            {
                CanToggle = true,
                IsToggled = false,
                KeepAspectRatio = true,
                DontMakeBigger = true,
                ToolTip = tooltip,
                TextColor = Color.White,
                HoverTextColor = Color.Yellow,
                DrawFrame = true
            };
            button.OnClicked += () => ButtonClicked(button);
            ToolButtons[mode] = button;

            return button;
        }
Esempio n. 13
0
        /*
        private void buildBox_OnSelectionModified(string arg)
        {
            if(arg.Contains("Wall"))
            {
                string voxType = BuildPanel.CurrentWallType;
                if (string.IsNullOrEmpty(voxType)) return;

                Master.Faction.WallBuilder.CurrentVoxelType = VoxelLibrary.GetVoxelType(voxType);
                Master.VoxSelector.SelectionType = VoxelSelectionType.SelectEmpty;
                Master.Faction.RoomBuilder.CurrentRoomData = null;
                Master.Faction.CraftBuilder.IsEnabled = false;
            }
            else if (arg.Contains("Craft"))
            {
                CraftLibrary.CraftItemType itemType = BuildPanel.CurrentCraftType;
                Master.VoxSelector.SelectionType = VoxelSelectionType.SelectEmpty;
                Master.Faction.RoomBuilder.CurrentRoomData = null;
                Master.Faction.WallBuilder.CurrentVoxelType = null;
                Master.Faction.CraftBuilder.CurrentCraftType = itemType;
                Master.Faction.CraftBuilder.IsEnabled = true;
            }
            else
            {
                if (string.IsNullOrEmpty(arg)) return;

                Master.Faction.RoomBuilder.CurrentRoomData = RoomLibrary.GetData(arg);
                Master.VoxSelector.SelectionType = VoxelSelectionType.SelectFilled;
                Master.Faction.WallBuilder.CurrentVoxelType = null;
                Master.Faction.CraftBuilder.IsEnabled = false;
            }
        }
         */
        public void ButtonClicked(Button sender)
        {
            sender.IsToggled = true;

            foreach(KeyValuePair<GameMaster.ToolMode, Button> pair in ToolButtons)
            {
                if(pair.Value == sender)
                {
                    CurrentMode = pair.Key;
                   Master.Tools[pair.Key].OnBegin();

                    if (Master.CurrentTool != Master.Tools[pair.Key])
                    {
                        Master.CurrentTool.OnEnd();
                    }

                }
                else
                {
                    pair.Value.IsToggled = false;
                }
            }
        }
Esempio n. 14
0
        void Initialize()
        {
            TalkerName = TextGenerator.GenerateRandom(Datastructures.SelectRandom(Faction.Race.NameTemplates).ToArray());
            Tabs = new Dictionary<string, GUIComponent>();
            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default),
                Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title),
                Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Layout.UpdateSizes();

            Talker = new SpeakerComponent(GUI, Layout, new Animation(Faction.Race.TalkAnimation));
            Layout.SetComponentPosition(Talker, 0, 0, 4, 4);

            DialougeSelector = new ListSelector(GUI, Layout)
            {
                Mode = ListItem.SelectionMode.ButtonList,
                DrawPanel = false,
                Label = ""
            };
            DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected;
            Layout.SetComponentPosition(DialougeSelector, 2, 2, 2, 10);

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(back, 0, 10, 1, 1);
            back.OnClicked += back_OnClicked;

            DialougeTree = new SpeechNode()
            {
                Text = GetGreeting(),
                Actions = new List<SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Let's trade.",
                        Action = WaitForTrade
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Goodbye.",
                        Action = () => SpeechNode.Echo(new SpeechNode()
                        {
                            Text = GetFarewell(),
                            Actions = new List<SpeechNode.SpeechAction>()
                        })
                    }
                }
            };

            Transition(DialougeTree);
            Politics.HasMet = true;

            PlayerFation.AddResources(new ResourceAmount(ResourceLibrary.ResourceType.Mana, 64));
        }
Esempio n. 15
0
        public void CreateSelector()
        {
            TheirGoods = new ItemSelector(GUI, Layout, "Their Items")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.PricePerItem,
                    ItemSelector.Column.ArrowRight
                },
                NoItemsMessage = "Nothing to buy",
                ToolTip = "Click items to trade for them."
            };

            Layout.SetComponentPosition(TheirGoods, 0, 0, 2, 9);

            TheirGoods.Items.AddRange(GetResources(1.0f));
            TheirGoods.ReCreateItems();

            MyGoods = new ItemSelector(GUI, Layout, "Our Items")
            {
                Columns = new List<ItemSelector.Column>()
                {
                    ItemSelector.Column.ArrowLeft,
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice
                },
                NoItemsMessage = "No items selected",
                ToolTip = "Click items to offer them for trade.",
                PerItemCost = 1.00f
            };
            MyGoods.Items.AddRange(GetResources(PlayState.PlayerFaction.ListResources().Values.ToList()));
            MyGoods.ReCreateItems();
            Layout.SetComponentPosition(MyGoods, 2, 0, 2, 9);

            TheirGoods.OnItemRemoved += MyGoods.AddItem;
            MyGoods.OnItemRemoved += TheirGoods.AddItem;
            MyGoods.OnItemChanged += shoppingCart_OnItemChanged;
            MyGoods.OnItemRemoved += TheirGoods_OnItemAdded;
            TheirGoods.OnItemRemoved += MyGoods_OnItemAdded;
            Button buyButton = new Button(GUI, Layout, "Offer Trade", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Click to offer up a trade."
            };

            Layout.SetComponentPosition(buyButton, 3, 9, 1, 2);

            BuyTotal = new Label(GUI, Layout, "Profit: $0.00", GUI.DefaultFont)
            {
                WordWrap = true,
                ToolTip = "Their profit from the trade."
            };

            Layout.SetComponentPosition(BuyTotal, 0, 9, 1, 2);

            buyButton.OnClicked += buyButton_OnClicked;
        }
Esempio n. 16
0
        public Minimap(DwarfGUI gui, GUIComponent parent, int width, int height, PlayState playState, Texture2D colormap, Texture2D frame)
            : base(gui, parent, new ImageFrame())
        {
            Frame = frame;
            SuppressClick = false;
            ColorMap = colormap;

            RenderWidth = width;
            RenderHeight = height;
            RenderTarget = new RenderTarget2D(GameState.Game.GraphicsDevice, RenderWidth, RenderHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            Image.Image = RenderTarget;
            Image.SourceRect = new Rectangle(0, 0, RenderWidth, RenderHeight);
            PlayState = playState;

            ConstrainSize = true;

            Camera = new OrbitCamera(0, 0, 0.01f, new Vector3(0, 0, 0), new Vector3(0, 0, 0),  2.5f, 1.0f, 0.1f, 1000.0f)
            {
                Projection = global::DwarfCorp.Camera.ProjectionMode.Orthographic
            };

            ZoomInButton = new Button(GUI, this, "", GUI.SmallFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                LocalBounds = new Rectangle(1, 1, 32, 32),
                ToolTip =  "Zoom in"
            };

            ZoomInButton.OnClicked += zoomInButton_OnClicked;

            ZoomOutButton = new Button(GUI, this, "", GUI.SmallFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                LocalBounds = new Rectangle(33, 1, 32, 32),
                ToolTip =  "Zoom out"
            };

            ZoomOutButton.OnClicked += zoomOutButton_OnClicked;

            ZoomHomeButton = new Button(GUI, this, "", GUI.SmallFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomHome))
            {
                LocalBounds = new Rectangle(65, 1, 32, 32),
                ToolTip =  "Home camera"
            };

            ZoomHomeButton.OnClicked +=ZoomHomeButton_OnClicked;

            MinimizeButton = new Button(GUI, this, "", GUI.SmallFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowDown))
            {
                LocalBounds = new Rectangle(width - 32, 0, 32, 32),
                ToolTip = "Show/Hide Map"
            };

            MinimizeButton.OnClicked += MinimizeButton_OnClicked;

            OnClicked += Minimap_OnClicked;
        }