Ejemplo n.º 1
0
        public MasterControls(DwarfGUI gui, GUIComponent parent, GameMaster master, Texture2D icons, GraphicsDevice device, SpriteFont font)
            : base(gui, parent)
        {
            Master = master;
            Icons = icons;
            IconSize = 32;
            CurrentMode = master.CurrentToolMode;
            ToolButtons = new Dictionary<GameMaster.ToolMode, Button>();

            GridLayout layout = new GridLayout(GUI, this, 1, 8)
            {
                EdgePadding = 0
            };

            CreateButton(layout, GameMaster.ToolMode.SelectUnits, "Select", "Click and drag to select dwarves.", 5, 0);
            CreateButton(layout, GameMaster.ToolMode.Dig, "Mine", "Click and drag to designate mines.\nRight click to erase.", 0, 0);
            CreateButton(layout, GameMaster.ToolMode.Build, "Build", "Click to open build menu.", 2, 0);
            CreateButton(layout, GameMaster.ToolMode.Magic, "Magic", "Click to open the magic menu.", 6, 1);
            CreateButton(layout, GameMaster.ToolMode.Gather, "Gather", "Click on resources to designate them\nfor gathering. Right click to erase.", 6, 0);
            CreateButton(layout, GameMaster.ToolMode.Chop, "Chop", "Click on trees to designate them\nfor chopping. Right click to erase.", 1, 0);
            CreateButton(layout, GameMaster.ToolMode.Guard, "Guard", "Click and drag to designate guard areas.\nRight click to erase.", 4, 0);
            CreateButton(layout, GameMaster.ToolMode.Attack, "Attack", "Click and drag to attack entities.\nRight click to cancel.", 3, 0);
            //CreateButton(layout, GameMaster.ToolMode.CreateStockpiles, "Stock", "Click and drag to designate stockpiles.\nRight click to erase.", 7, 0);

            int i = 0;
            foreach(Button b in ToolButtons.Values)
            {
                layout.SetComponentPosition(b, i, 0, 1, 1);
                i++;
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        public StockTicker(DwarfGUI gui, GUIComponent parent, Economy economy)
            : base(gui, parent)
        {
            Icons = new List<StockIcon>();
            Economy = economy;
            Window = 30;
            TickColor = Color.Brown;
            Layout = new GridLayout(gui, this, 10, 4);
            Label displayLabel = new Label(gui, Layout, "Display: ", GUI.DefaultFont);
            Layout.SetComponentPosition(displayLabel, 0, 0, 1, 1);
            IndustryBox = new ComboBox(gui, Layout);
            IndustryBox.AddValue("Our Company");
            IndustryBox.AddValue("All");
            IndustryBox.AddValue("Average");
            IndustryBox.AddValue("Exploration");
            IndustryBox.AddValue("Military");
            IndustryBox.AddValue("Manufacturing");
            IndustryBox.AddValue("Magic");
            IndustryBox.AddValue("Finance");
            IndustryBox.CurrentIndex = 0;
            IndustryBox.CurrentValue = "Our Company";

            IndustryBox.OnSelectionModified += IndustryBox_OnSelectionModified;
            Layout.SetComponentPosition(IndustryBox, 1, 0, 1, 1);

            DrawSurface = new GUIComponent(gui, Layout);

            Layout.SetComponentPosition(DrawSurface, 0, 1, 4, 9);

            IndustryBox_OnSelectionModified("Our Company");
        }
Ejemplo n.º 4
0
        public AnnouncementViewer(DwarfGUI gui, GUIComponent parent, AnnouncementManager manager)
            : base(gui, parent)
        {
            TweenTimer = new Timer(0.5f, true);
            TweenOutTimer = new Timer(0.5f, true);
            SpeechBubble = new Panel(gui, this)
            {
                Mode = Panel.PanelMode.SpeechBubble,
                DrawOrder = -2
            };
            SpeechBubble.IsVisible = false;
            Manager = manager;

            Manager.OnAdded += Manager_OnAdded;
            Manager.OnRemoved += Manager_OnRemoved;

            IsMaximized = false;

            AnnouncementViews = new List<AnnouncementView>();
            MaxViews = 4;
            WaitTimer = new Timer(5, true);
            Talker = new AnimatedImagePanel(GUI, this, animation);
            animation.Play();
            animation.Loops = true;
            animation.FrameHZ = 2.0f;
        }
Ejemplo n.º 5
0
        public ItemSelector(DwarfGUI gui, GUIComponent parent, string title)
            : base(gui, parent, title)
        {
            Columns = new List<Column>()
            {
                Column.Image,
                Column.Name,
                Column.PricePerItem
            };

            Items = new List<GItem>();
            GridLayout layout = new GridLayout(GUI, this, 1, 1);
            ScrollArea = new ScrollView(GUI, layout)
            {
                DrawBorder = false,
                WidthSizeMode = SizeMode.Fit
            };

            layout.UpdateSizes();
            layout.SetComponentPosition(ScrollArea, 0, 0, 1, 1);
            Layout = new GridLayout(gui, ScrollArea, 14, 5);
            OnItemChanged += ItemSelector_OnItemChanged;
            OnItemRemoved += ItemSelector_OnItemRemoved;
            OnItemAdded += ItemSelector_OnItemAdded;
            Behavior = ClickBehavior.RemoveItem;
            AllowShiftClick = true;
        }
Ejemplo n.º 6
0
 public ImagePanel(DwarfGUI gui, GUIComponent parent, ImageFrame image)
     : base(gui, parent)
 {
     AssetName = "";
     Lock = new Mutex();
     Image = image;
     KeepAspectRatio = true;
 }
Ejemplo n.º 7
0
 public DynamicLabel(DwarfGUI gui, GUIComponent parent, string prefixText, string postfix, SpriteFont textFont, string format, Func<float> valuefn)
     : base(gui, parent, prefixText, textFont)
 {
     ValueFn = valuefn;
     Prefix = prefixText;
     Postfix = postfix;
     Format = format;
 }
Ejemplo n.º 8
0
 public WorldGUIObject(Body parent, GUIComponent guiObject)
     : base("GUIObject", parent, Matrix.Identity, Vector3.One, Vector3.Zero)
 {
     GUIObject = guiObject;
     AddToCollisionManager = false;
     FrustrumCull = false;
     IsVisible = false;
     Enabled = false;
 }
Ejemplo n.º 9
0
 public ComboBox(DwarfGUI gui, GUIComponent parent)
     : base(gui, parent)
 {
     Values = new List<string>();
     CurrentValue = "";
     OnLeftClicked += ComboBox_OnLeftPressed;
     Selector = null;
     OnSelectionModified += ComboBox_OnSelectionModified;
 }
Ejemplo n.º 10
0
 public ResourceInfoComponent(DwarfGUI gui, GUIComponent parent, Faction faction)
     : base(gui, parent)
 {
     Faction = faction;
     UpdateTimer = new Timer(0.5f, false);
     Layout = new GridLayout(gui, this, 1, 1);
     CurrentResources = new List<ResourceAmount>();
     PanelWidth = 40;
     PanelHeight = 40;
 }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
 public FormLayout(DwarfGUI gui, GUIComponent parent)
     : base(gui, parent)
 {
     NumColumns = 1;
     MaxRows = 30;
     FitToParent = true;
     EdgePadding = 0;
     RowHeight = 32;
     ColumnWidth = 400;
     Items = new Dictionary<string, FormEntry>();
 }
Ejemplo n.º 13
0
 public LineEdit(DwarfGUI gui, GUIComponent parent, string text)
     : base(gui, parent)
 {
     HasKeyboardFocus = false;
     Text = text;
     InputManager.MouseClickedCallback += InputManager_MouseClickedCallback;
     InputManager.KeyPressedCallback += InputManager_KeyPressedCallback;
     Carat = text.Length;
     OnTextModified += LineEdit_OnTextModified;
     IsEditable = true;
 }
Ejemplo n.º 14
0
 public MiniBar(DwarfGUI gui, GUIComponent parent, float v, string label)
     : base(gui, parent)
 {
     Value = v;
     BackgroundColor = Color.Transparent;
     ForegroundColor = Color.Black;
     FillColor = new Color(10, 10, 10);
     Text = new Label(GUI, this, label, GUI.SmallFont)
     {
         LocalBounds = new Rectangle(0, 0, label.Length * 8, 32)
     };
 }
Ejemplo n.º 15
0
 public Checkbox(DwarfGUI gui, GUIComponent parent, string text, SpriteFont textFont, bool check)
     : base(gui, parent)
 {
     Text = text;
     TextColor = gui.DefaultTextColor;
     TextFont = textFont;
     OnClicked += Clicked;
     StrokeColor = new Color(0, 0, 0, 0);
     Checked = check;
     HoverTextColor = Color.DarkRed;
     OnCheckModified += CheckBox_OnCheckModified;
 }
Ejemplo n.º 16
0
 public KeyEdit(DwarfGUI gui, GUIComponent parent, Keys key)
     : base(gui, parent)
 {
     Key = key;
     HasKeyboardFocus = false;
     Text = key.ToString();
     InputManager.MouseClickedCallback += InputManager_MouseClickedCallback;
     InputManager.KeyPressedCallback += InputManager_KeyPressedCallback;
     Carat = 0;
     OnTextModified += LineEdit_OnTextModified;
     OnKeyModified += KeyEdit_OnKeyModified;
     IsEditable = true;
 }
Ejemplo n.º 17
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;
            }
        }
Ejemplo n.º 18
0
 public GridLayout(DwarfGUI gui, GUIComponent parent, int rows, int cols)
     : base(gui, parent)
 {
     ComponentPositions = new Dictionary<Rectangle, GUIComponent>();
     ComponentOffsets = new Dictionary<GUIComponent, Point>();
     Rows = rows;
     Cols = cols;
     EdgePadding = 5;
     HeightSizeMode = SizeMode.Fit;
     WidthSizeMode = SizeMode.Fit;
     RowHighlight = -1;
     ColumnHighlight = -1;
 }
Ejemplo n.º 19
0
 public ImagePanel(DwarfGUI gui, GUIComponent parent, Texture2D image)
     : base(gui, parent)
 {
     AssetName = "";
     Highlight = false;
     Lock = new Mutex();
     ConstrainSize = false;
     if(image != null)
     {
         Image = new ImageFrame(image, new Rectangle(0, 0, image.Width, image.Height));
     }
     KeepAspectRatio = true;
 }
Ejemplo n.º 20
0
 public DraggableItem(DwarfGUI gui, GUIComponent parent, GItem item)
     : base(gui, parent)
 {
     IsDragging = false;
     Item = item;
     OnHover += DraggableItem_OnHover;
     OnUnHover += DraggableItem_OnUnHover;
     OnPressed += DraggableItem_OnPressed;
     OnRelease += DraggableItem_OnRelease;
     OnDragStarted += DraggableItem_OnDragStarted;
     OnDragEnded += DraggableItem_OnDragEnded;
     IsHighlighting = false;
     KeepAspectRatio = true;
 }
Ejemplo n.º 21
0
 public ListItem(DwarfGUI gui, GUIComponent parent, string label, Texture2D tex, Rectangle texBounds)
     : base(gui, parent)
 {
     Label = label;
     Texture = tex;
     TextureBounds = texBounds;
     TextColor = gui.DefaultTextColor;
     TextStrokeColor = gui.DefaultStrokeColor;
     ToggledColor = Color.DarkRed;
     HoverColor = new Color(255, 20, 20);
     Toggleable = true;
     IsToggled = false;
     Mode = SelectionMode.Selector;
 }
Ejemplo n.º 22
0
 public Slider(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SliderMode mode)
     : base(gui, parent)
 {
     Orient = Orientation.Horizontal;
     DrawLabel = true;
     SliderValue = value;
     MinValue = minValue;
     MaxValue = maxValue;
     Mode = mode;
     Label = label;
     OnValueModified += Slider_OnValueModified;
     OnLeftPressed += Slider_OnLeftPressed;
     Focused = false;
     InvertValue = false;
 }
Ejemplo n.º 23
0
        public CapitalPanel(DwarfGUI gui, GUIComponent parent, Faction faction)
            : base(gui, parent)
        {
            Faction = faction;
            GridLayout layout = new GridLayout(gui, this, 4, 4);
            CurrentMoneyLabel = new Label(gui, layout, "Treasury: ", GUI.TitleFont);
            layout.SetComponentPosition(CurrentMoneyLabel, 0, 0, 2, 1);

            CurrentMoneyLabel.OnUpdate += CurrentMoneyLabel_OnUpdate;

            TotalPayLabel = new Label(gui, layout, "Employee pay: ", GUI.DefaultFont);
            layout.SetComponentPosition(TotalPayLabel, 2, 0, 2, 1);

            Stocks = new StockTicker(gui, layout, Faction.Economy);
            layout.SetComponentPosition(Stocks, 0, 1, 4, 3);
        }
Ejemplo n.º 24
0
        public ScrollView(DwarfGUI gui, GUIComponent parent)
            : base(gui, parent)
        {
            ScrollX = 0;
            ScrollY = 0;
            HorizontalSlider = new Slider(gui, parent, "", 0.0f, 0.0f, 1.0f, Slider.SliderMode.Float)
            {
                DrawLabel = false
            };
            HorizontalSlider.OnValueModified += HorizontalSlider_OnValueModified;

            VerticalSlider = new Slider(gui, parent, "", 0.0f, 0.0f, 1.0f, Slider.SliderMode.Float) {DrawLabel = false};
            VerticalSlider.OnValueModified += VerticalSlider_OnValueModified;
            VerticalSlider.Orient = Slider.Orientation.Vertical;
            OnScrolled += ScrollView_OnScrolled;
        }
Ejemplo n.º 25
0
        public BuildMenu(DwarfGUI gui, GUIComponent parent, GameMaster faction)
            : base(gui, parent, WindowButtons.CloseButton)
        {
            GridLayout layout = new GridLayout(GUI, this, 1, 1);
            Master = faction;
            Selector = new TabSelector(GUI, layout, 3);
            layout.SetComponentPosition(Selector, 0, 0, 1, 1);

            SetupBuildRoomTab();
            SetupBuildItemTab();
            SetupBuildWallTab();

            Selector.SetTab("Rooms");
            MinWidth = 512;
            MinHeight = 256;
        }
Ejemplo n.º 26
0
        public KeyEditor(DwarfGUI gui, GUIComponent parent, KeyManager keyManager, int numRows, int numColumns)
            : base(gui, parent)
        {
            Keys[] reserved =
            {
                Keys.Up,
                Keys.Left,
                Keys.Right,
                Keys.Down,
                Keys.LeftControl,
                Keys.LeftShift,
                Keys.RightShift,
                Keys.LeftAlt,
                Keys.RightAlt,
                Keys.RightControl,
                Keys.Escape
            };
            ReservedKeys = new List<Keys>();
            ReservedKeys.AddRange(reserved);

            KeyManager = keyManager;

            Layout = new GridLayout(gui, this, numRows, numColumns * 2);

            int r = 0;
            int c = 0;

            foreach(KeyValuePair<string, Keys> button in KeyManager.Buttons)
            {
                if(r == numRows)
                {
                    r = 0;
                    c++;
                }

                Label keyLabel = new Label(gui, Layout, button.Key, gui.DefaultFont);
                KeyEdit editor = new KeyEdit(gui, Layout, button.Value);
                Layout.SetComponentPosition(keyLabel, c * 2, r, 1, 1);
                Layout.SetComponentPosition(editor, c * 2 + 1, r, 1, 1);

                string name = button.Key;

                editor.OnKeyModified += (prevKey, arg, keyedit) => editor_OnKeyModified(name, prevKey, arg, keyedit);

                r++;
            }
        }
Ejemplo n.º 27
0
 public MagicMenu(DwarfGUI gui, GUIComponent parent, GameMaster master, WindowButtons buttons = WindowButtons.CloseButton)
     : base(gui, parent, buttons)
 {
     Master = master;
     MinWidth = 512;
     MinHeight = 256;
     Selector = new TabSelector(GUI, this, 2)
     {
         WidthSizeMode = SizeMode.Fit,
         HeightSizeMode = SizeMode.Fit,
         LocalBounds = new Rectangle(0, 0, MinWidth, MinHeight)
     };
     SpellTriggered = spell => { };
     CreateSpellsTab();
     CreateResearchTab();
     Selector.SetTab("Known Spells");
 }
Ejemplo n.º 28
0
 public DragGrid(DwarfGUI gui, GUIComponent parent, DragManager dragManager, int gridWidth, int gridHeight)
     : base(gui, parent)
 {
     Items = new List<DraggableItem>();
     DragManager = dragManager;
     GridWidth = gridWidth;
     GridHeight = gridHeight;
     SetupLayout();
     DrawGrid = false;
     DragManager.OnDragEnded += DragManager_OnDragEnded;
     DragManager.OnDragStarted += DragManager_OnDragStarted;
     OnItemCreated += DragGrid_OnItemCreated;
     OnItemDestroyed += DragGrid_OnItemDestroyed;
     OnChanged += DragGrid_OnChanged;
     DrawBackground = true;
     BackColor = new Color(255, 255, 255, 100);
     BorderColor = new Color(0, 0, 0, 100);
 }
Ejemplo n.º 29
0
        public SpellTreeDisplay(DwarfGUI gui, GUIComponent parent, SpellTree tree)
            : base(gui, parent)
        {
            Tree = tree;

            Scroller = new ScrollView(gui, this)
            {
                HeightSizeMode = SizeMode.Fit,
                WidthSizeMode = SizeMode.Fit
            };

            MainPanel = new GUIComponent(gui, Scroller)
            {
                HeightSizeMode = SizeMode.Fixed,
                WidthSizeMode = SizeMode.Fixed
            };

            InitializeSpellButtons();
        }
Ejemplo n.º 30
0
        public GUIComponent(DwarfGUI gui, GUIComponent parent)
        {
            DrawOrder = -1;
            WidthSizeMode = SizeMode.Fixed;
            HeightSizeMode = SizeMode.Fixed;
            MinWidth = -1;
            MinHeight = -1;
            MaxWidth = -1;
            MaxHeight = -1;
            Children = new List<GUIComponent>();
            LocalBounds = new Rectangle();
            GlobalBounds = new Rectangle();
            GUI = gui;
            IsMouseOver = false;
            IsLeftPressed = false;
            IsRightPressed = false;
            Parent = parent;
            IsVisible = true;
            OverrideClickBehavior = false;
            if(parent != null)
            {
                Parent.AddChild(this);
            }
            OnClicked += dummy;
            OnLeftClicked += dummy;
            OnRightClicked += dummy;
            OnPressed += dummy;
            OnLeftPressed += dummy;
            OnRightPressed += dummy;
            OnHover += dummy;
            OnRelease += dummy;
            OnUnHover += dummy;
            OnUpdate += dummy;
            OnRender += dummy;
            OnScrolled += SillyGUIComponent_OnScrolled;

            ChildrenToRemove = new List<GUIComponent>();
            ChildrenToAdd = new List<GUIComponent>();
            Tweens = new List<GUITween>();
        }
Ejemplo n.º 31
0
 public GroupBox(DwarfGUI gui, GUIComponent parent, string title) :
     base(gui, parent)
 {
     Title      = title;
     DrawBounds = true;
 }
Ejemplo n.º 32
0
        void Initialize()
        {
            Faction.TradeMoney += MathFunctions.Rand(-100.0f, 100.0f);
            Faction.TradeMoney  = Math.Max(Faction.TradeMoney, 0.0f);
            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 GUIComponent(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,
                DrawButtons = true,
                DrawPanel   = false,
                Label       = "",
                ItemHeight  = 35,
                Padding     = 5
            };
            DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected;
            Layout.SetComponentPosition(DialougeSelector, 2, 3, 1, 8);

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(BackButton, 2, 10, 1, 1);
            BackButton.OnClicked += back_OnClicked;
            BackButton.IsVisible  = false;
            DialougeTree          = new SpeechNode()
            {
                Text    = GetGreeting(),
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Trade...",
                        Action = WaitForTrade
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Ask a question...",
                        Action = AskAQuestion
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Declare war!",
                        Action = DeclareWar
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Leave",
                        Action = () =>
                        {
                            BackButton.IsVisible = true;
                            if (Envoy != null)
                            {
                                Faction.RecallEnvoy(Envoy);
                            }
                            return(SpeechNode.Echo(new SpeechNode()
                            {
                                Text = GetFarewell(),
                                Actions = new List <SpeechNode.SpeechAction>()
                            }));
                        }
                    }
                }
            };


            if (Politics.WasAtWar)
            {
                PreeTree = new SpeechNode()
                {
                    Text    = Datastructures.SelectRandom(Faction.Race.Speech.PeaceDeclarations),
                    Actions = new List <SpeechNode.SpeechAction>()
                    {
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Make peace with " + Faction.Name,
                            Action = () =>
                            {
                                if (!Politics.HasEvent("you made peace with us"))
                                {
                                    Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                                    {
                                        Change      = 0.4f,
                                        Description = "you made peace with us",
                                        Duration    = new TimeSpan(4, 0, 0, 0),
                                        Time        = PlayState.Time.CurrentDate
                                    });
                                }
                                return(SpeechNode.Echo(DialougeTree));
                            }
                        },
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Continue the war with " + Faction.Name,
                            Action = DeclareWar
                        }
                    }
                };
                Transition(PreeTree);
                Politics.WasAtWar = false;
            }
            else
            {
                Transition(DialougeTree);
            }


            if (!Politics.HasMet)
            {
                Politics.HasMet = true;

                Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                {
                    Change      = 0.0f,
                    Description = "we just met",
                    Duration    = new TimeSpan(1, 0, 0, 0),
                    Time        = PlayState.Time.CurrentDate
                });
            }

            Layout.UpdateSizes();
            Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f);
            DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f);
        }
Ejemplo n.º 33
0
        public DraggableItem Drop()
        {
            MouseState mouseState = Mouse.GetState();

            if (CurrentItem != null)
            {
                Rectangle rect = CurrentItem.GlobalBounds;
                rect.X = mouseState.X - rect.Width / 2;
                rect.Y = mouseState.Y - rect.Height / 2;

                GUIComponent drop = GetIntersectingSlot(rect);


                if (drop != null)
                {
                    foreach (GUIComponent slotDropper in IllegalDrags.Keys)
                    {
                        if (CurrentItem.HasAnscestor(slotDropper))
                        {
                            foreach (GUIComponent illegals in IllegalDrags[slotDropper].Keys)
                            {
                                if (drop.HasAnscestor(illegals))
                                {
                                    CurrentItem.Item.CurrentAmount += CurrentDragAmount;
                                    OnDragEnded.Invoke(CurrentItem, null, 0);
                                    return(null);
                                }
                            }
                        }
                    }

                    DraggableItem toReturn = null;
                    bool          wasNew   = false;
                    bool          success  = Drag(CurrentItem, CurrentDragAmount, drop, out toReturn, out wasNew);

                    if (!success)
                    {
                        CurrentItem.Item.CurrentAmount += CurrentDragAmount;
                        OnDragEnded.Invoke(CurrentItem, null, 0);
                        return(null);
                    }
                    else if (wasNew)
                    {
                        OnDragEnded.Invoke(CurrentItem, toReturn, CurrentDragAmount);
                        return(toReturn);
                    }
                    else
                    {
                        OnDragEnded.Invoke(CurrentItem, null, CurrentDragAmount);
                        return(null);
                    }
                }
                else
                {
                    CurrentItem.Item.CurrentAmount += CurrentDragAmount;
                    OnDragEnded.Invoke(CurrentItem, null, 0);
                    return(null);
                }
            }


            CurrentItem       = null;
            CurrentDragAmount = 0;
            OnDragEnded.Invoke(CurrentItem, null, 0);
            return(null);
        }
Ejemplo n.º 34
0
 public ColorPanel(DwarfGUI gui, GUIComponent parent) :
     base(gui, parent)
 {
 }
Ejemplo n.º 35
0
 public Panel(DwarfGUI gui, GUIComponent parent) :
     base(gui, parent)
 {
     Mode = PanelMode.Fancy;
 }
Ejemplo n.º 36
0
 public ScrollingAnimation(DwarfGUI gui, GUIComponent parent) :
     base(gui, parent)
 {
     Tint = Color.White;
 }
Ejemplo n.º 37
0
 public Tray(DwarfGUI gui, GUIComponent parent) :
     base(gui, parent)
 {
     TrayPosition = Position.BottomRight;
 }