Beispiel #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++;
            }
        }
Beispiel #2
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");
        }
Beispiel #3
0
 public EmployeeDisplay(DwarfGUI gui, GUIComponent parent, Faction faction, CompanyInformation company) :
     base(gui, parent)
 {
     Faction = faction;
     Company = company;
     Initialize();
 }
Beispiel #4
0
 public FarmingPanel(DwarfGUI gui, GUIComponent parent, WorldManager world, WindowButtons buttons = WindowButtons.CloseButton)
     : base(gui, parent, buttons)
 {
     MinWidth  = 512;
     MinHeight = 256;
     Setup(world);
 }
Beispiel #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;
        }
        public AnnouncementViewer(DwarfGUI gui, GUIComponent parent, AnnouncementManager manager) :
            base(gui, parent)
        {
            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)
            {
                LocalBounds = new Rectangle(-128, -64, 128, 128)
            };
            animation.Play();
            animation.Loops   = true;
            animation.FrameHZ = 2.0f;
        }
Beispiel #7
0
        public Rectangle GetImageBounds()
        {
            Rectangle toDraw = GlobalBounds;

            if (!KeepAspectRatio)
            {
                return(toDraw);
            }

            if (Image == null)
            {
                return(toDraw);
            }

            toDraw = DwarfGUI.AspectRatioFit(Image.Bounds, toDraw);

            if (ConstrainSize)
            {
                toDraw.Width  = Math.Min(Image.Bounds.Width, toDraw.Width);
                toDraw.Height = Math.Min(Image.Bounds.Height, toDraw.Height);
                toDraw.Width  = Math.Max(Image.Width, toDraw.Width);
                toDraw.Height = Math.Max(Image.Bounds.Height, toDraw.Height);
            }

            return(toDraw);
        }
Beispiel #8
0
        public TradePanel(DwarfGUI gui, GUIComponent parent, Faction faction, Faction otherFaction, List <ResourceAmount> resources)
            : base(gui, parent)
        {
            Resources     = resources;
            GoodsSent     = new List <ResourceAmount>();
            GoodsReceived = new List <ResourceAmount>();
            LocalBounds   = parent.GlobalBounds;
            Faction       = faction;
            OtherFaction  = otherFaction;
            Layout        = new GridLayout(GUI, this, 10, 4);

            SpaceLabel = new Label(GUI, Layout, "Space: " + Faction.ComputeStockpileSpace() + "/" + Faction.ComputeStockpileCapacity(), GUI.DefaultFont)
            {
                ToolTip  = "Space left in our stockpiles",
                WordWrap = true
            };

            Layout.SetComponentPosition(SpaceLabel, 1, 9, 1, 1);

            SpaceLabel.OnUpdate += SpaceLabel_OnUpdate;

            Layout.UpdateSizes();

            CreateSelector();
        }
Beispiel #9
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            string text = Text;

            if (WordWrap)
            {
                text = DwarfGUI.WrapLines(Text, LocalBounds, TextFont);
            }

            if (Truncate)
            {
                Vector2 measure  = Datastructures.SafeMeasure(TextFont, text);
                Vector2 wMeasure = Datastructures.SafeMeasure(TextFont, "W");
                if (measure.X > GlobalBounds.Width)
                {
                    int numLetters = GlobalBounds.Width / (int)wMeasure.X;
                    text = Text.Substring(0, Math.Min(numLetters, Text.Length)) + "...";
                }
            }

            if (StrokeColor.A > 0)
            {
                Drawer2D.DrawAlignedStrokedText(batch, text, TextFont, TextColor, StrokeColor, Alignment, GlobalBounds);
            }
            else
            {
                Drawer2D.DrawAlignedText(batch, text, TextFont, TextColor, Alignment, GlobalBounds);
            }
            base.Render(time, batch);
        }
Beispiel #10
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");
        }
Beispiel #11
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;
        }
Beispiel #12
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++;
            }
        }
Beispiel #13
0
        public AIDebugger(DwarfGUI gui, GameMaster master)
        {
            MainPanel = new Panel(gui, gui.RootComponent);
            Layout = new GridLayout(gui, MainPanel, 13, 1);

            DwarfSelector = new ComboBox(gui, Layout);
            DwarfSelector.OnSelectionModified += DwarfSelector_OnSelectionModified;
            GoalLabel = new Label(gui, Layout, "Script: null", gui.DefaultFont);
            PlanLabel = new Label(gui, Layout, "Plan: null", gui.DefaultFont);
            AStarPathLabel = new Label(gui, Layout, "Astar Path: null", gui.DefaultFont);
            LastMessages = new Label(gui, Layout, "Messages: ", gui.DefaultFont);
            ScrollView btDisplayHolder = new ScrollView(gui, Layout);
            BTDisplay = new ActDisplay(gui, btDisplayHolder);

            Layout.SetComponentPosition(DwarfSelector, 0, 0, 1, 1);
            Layout.SetComponentPosition(GoalLabel, 0, 1, 1, 1);
            Layout.SetComponentPosition(PlanLabel, 0, 2, 1, 1);
            Layout.SetComponentPosition(AStarPathLabel, 0, 3, 1, 1);
            Layout.SetComponentPosition(LastMessages, 0, 4, 1, 2);
            Layout.SetComponentPosition(btDisplayHolder, 0, 6, 1, 6);
            Visible = false;

            int i = 0;
            foreach(CreatureAI component in master.Faction.Minions)
            {
                DwarfSelector.AddValue("Minion " + i);
                i++;
            }

            Master = master;

            MainPanel.LocalBounds = new Rectangle(100, 120, 500, 600);
        }
Beispiel #14
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;
        }
Beispiel #15
0
        public GameSpeedControl(DwarfGUI gui, GUIComponent parent) :
            base(gui, parent)
        {
            Mode = PanelMode.Simple;
            GridLayout layout = new GridLayout(GUI, this, 1, 3);

            TimeLabel = new Label(GUI, layout, "", gui.SmallFont)
            {
                TextColor = Color.White,
                Alignment = Drawer2D.Alignment.Center
            };
            layout.SetComponentPosition(TimeLabel, 1, 0, 1, 1);

            TimeBackward = new Button(GUI, layout, "", gui.SmallFont, Button.ButtonMode.PushButton, null)
            {
                DrawFrame = false,
                TextColor = Color.White
            };
            layout.SetComponentPosition(TimeBackward, 0, 0, 1, 1);

            TimeForward = new Button(GUI, layout, "", gui.SmallFont, Button.ButtonMode.PushButton, null)
            {
                DrawFrame = false,
                TextColor = Color.White
            };
            layout.SetComponentPosition(TimeForward, 2, 0, 1, 1);

            TimeForward.OnClicked  += () => SetSpeed(_currSpeed + 1);
            TimeBackward.OnClicked += () => SetSpeed(_currSpeed - 1);
            SetSpeed(1);
            layout.UpdateSizes();
        }
Beispiel #16
0
        public MoneyEditor(DwarfGUI gui, GUIComponent parent, bool editable, float maxmoney, float currentMoney) :
            base(gui, parent)
        {
            MaxMoney = maxmoney;

            GridLayout layout = new GridLayout(GUI, this, 1, 5);

            Editor = new LineEdit(GUI, layout, "0")
            {
                TextMode   = LineEdit.Mode.Numeric,
                Prefix     = "$",
                IsEditable = editable
            };
            CurrentMoney = currentMoney;

            Editor.OnTextModified += Editor_OnTextModified;
            layout.SetComponentPosition(Editor, 2, 0, 3, 1);

            Image = new ImagePanel(GUI, layout,
                                   new NamedImageFrame(ContentPaths.Entities.DwarfObjects.coinpiles, 32, 1, 0))
            {
                KeepAspectRatio = true,
                ConstrainSize   = true
            };

            layout.SetComponentPosition(Image, 0, 0, 1, 1);

            Text = new Label(GUI, layout, "Money: ", GUI.SmallFont)
            {
                WordWrap = false,
                Truncate = false
            };

            layout.SetComponentPosition(Text, 1, 0, 1, 1);
        }
Beispiel #17
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;
        }
Beispiel #18
0
        public Rectangle GetImageBounds()
        {
            Rectangle toDraw = GlobalBounds;

            if (Image == null)
            {
                return(toDraw);
            }

            if (DontMakeBigger)
            {
                toDraw.Width  = Math.Min(toDraw.Width, Image.SourceRect.Width);
                toDraw.Height = Math.Min(toDraw.Height, Image.SourceRect.Height);
            }

            if (DontMakeSmaller)
            {
                toDraw.Width  = Math.Max(toDraw.Width, Image.SourceRect.Width);
                toDraw.Height = Math.Max(toDraw.Height, Image.SourceRect.Height);
            }

            if (!KeepAspectRatio)
            {
                return(toDraw);
            }

            toDraw = DwarfGUI.AspectRatioFit(Image.SourceRect, toDraw);

            return(toDraw);
        }
Beispiel #19
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;
        }
Beispiel #20
0
        public ComboBoxSelector(DwarfGUI gui, ComboBox parent, List<string> values, string currentValue)
            : base(gui, parent)
        {
            Columns = new List<List<string>>();
            Values = values;
            CurrentValue = currentValue;

            int height = 0;
            Columns.Add(new List<string>());
            int currentColumn = 0;
            int columnWidth = parent.GlobalBounds.Width - 37;
            ColumnWidth = columnWidth;
            int bestHeight = 0;
            foreach(string s in values)
            {
                List<string> column = Columns[currentColumn];
                Vector2 measure = Datastructures.SafeMeasure(GUI.DefaultFont, s);
                height += (int) measure.Y;
                column.Add(s);

                if(height > bestHeight)
                {
                    bestHeight = height;
                }

                if(height >= MaxHeight)
                {
                    height = 0;
                    Columns.Add(new List<string>());
                    currentColumn++;
                    columnWidth += ColumnWidth;
                }
            }

            List<List<string>> removals = new List<List<string>>();

            foreach(List<string> column in Columns)
            {
                if(column.Count == 0)
                {
                    removals.Add(column);
                }
            }

            foreach(List<string> column in removals)
            {
                Columns.Remove(column);
                columnWidth -= ColumnWidth;
            }

            bestHeight += 15;

            LocalBounds = new Rectangle(0, parent.GlobalBounds.Height / 2 + GUI.Skin.TileHeight / 2, columnWidth, bestHeight);
            Box = parent;

            ClickTimer = new Timer(0.1f, true, Timer.TimerMode.Real);
            InputManager.MouseClickedCallback += InputManager_MouseClickedCallback;
            Drawn = true;
        }
Beispiel #21
0
 public GameMaster(Faction faction, DwarfGame game, ComponentManager components, ChunkManager chunks, Camera camera, GraphicsDevice graphics, DwarfGUI gui)
 {
     Faction = faction;
     Initialize(game, components, chunks, camera, graphics, gui);
     VoxSelector.Selected += OnSelected;
     BodySelector.Selected += OnBodiesSelected;
     PlayState.Time.NewDay += Time_NewDay;
 }
Beispiel #22
0
 public ImagePanel(DwarfGUI gui, GUIComponent parent, ImageFrame image)
     : base(gui, parent)
 {
     AssetName = "";
     Lock = new Mutex();
     Image = image;
     KeepAspectRatio = true;
 }
Beispiel #23
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;
 }
Beispiel #24
0
 public ImagePanel(DwarfGUI gui, GUIComponent parent, ImageFrame image) :
     base(gui, parent)
 {
     AssetName       = "";
     Lock            = new Mutex();
     Image           = image;
     KeepAspectRatio = true;
 }
Beispiel #25
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;
 }
Beispiel #26
0
 public ToolTipManager(DwarfGUI gui)
 {
     GUI               = gui;
     HoverTimer        = new Timer(0.8f, true, Timer.TimerMode.Real);
     ToolTip           = "";
     LastMouse         = Mouse.GetState();
     MovementThreshold = 2;
     PopupTimer        = new Timer(2.5f, true, Timer.TimerMode.Real);
 }
Beispiel #27
0
 public ComboBox(DwarfGUI gui, GUIComponent parent) :
     base(gui, parent)
 {
     Values               = new List <string>();
     CurrentValue         = "";
     OnLeftClicked       += ComboBox_OnLeftPressed;
     Selector             = null;
     OnSelectionModified += ComboBox_OnSelectionModified;
 }
 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;
 }
Beispiel #29
0
 public ProgressBar(DwarfGUI gui, GUIComponent parent, float v) :
     base(gui, parent)
 {
     Value         = v;
     Tint          = Color.Lime;
     Message       = "";
     MessageColor  = Color.White;
     MessageStroke = Color.Black;
 }
Beispiel #30
0
 public ToolTipManager(DwarfGUI gui)
 {
     GUI = gui;
     HoverTimer = new Timer(0.8f, true, Timer.TimerMode.Real);
     ToolTip = "";
     LastMouse = Mouse.GetState();
     MovementThreshold = 2;
     PopupTimer = new Timer(2.5f, true, Timer.TimerMode.Real);
 }
Beispiel #31
0
 public ColorKey(DwarfGUI gui, GUIComponent parent)
     : base(gui, parent)
 {
     Font            = gui.SmallFont;
     BackgroundColor = Color.White;
     TextColor       = Color.Black;
     BorderColor     = Color.Black;
     ColorEntries    = new Dictionary <string, Color>();
 }
Beispiel #32
0
        public static Dialog Popup(DwarfGUI gui, string title, string message, ButtonType buttons)
        {
            int w = message.Length * 8 + 150;
            int h = 150;
            int x = gui.Graphics.Viewport.Width / 2 - w / 2;
            int y = gui.Graphics.Viewport.Height / 2 - h / 2;

            return(Popup(gui, title, message, buttons, w, h, gui.RootComponent, x, y));
        }
Beispiel #33
0
 public ComboBox(DwarfGUI gui, GUIComponent parent)
     : base(gui, parent)
 {
     Values = new List<string>();
     CurrentValue = "";
     OnLeftClicked += ComboBox_OnLeftPressed;
     Selector = null;
     OnSelectionModified += ComboBox_OnSelectionModified;
 }
Beispiel #34
0
        public static TradeDialog Popup(DwarfGUI gui, GUIComponent parent, Faction faction, List <ResourceAmount> resources, WindowButtons buttons = WindowButtons.CloseButton)
        {
            int w = gui.Graphics.Viewport.Width;
            int h = gui.Graphics.Viewport.Height;
            int x = 0;
            int y = 0;

            return(Popup(gui, w, h, parent, x, y, buttons, faction, resources));
        }
Beispiel #35
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;
        }
Beispiel #36
0
        public ActDisplay(DwarfGUI gui, GUIComponent parent) :
            base(gui, parent)
        {
            DisplayColors = new Color[3];
            DisplayColors[(int)Act.Status.Running] = Color.DarkBlue;
            DisplayColors[(int)Act.Status.Success] = Color.Green;
            DisplayColors[(int)Act.Status.Fail]    = Color.Red;

            Elements = new List <ActElement>();
        }
 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;
 }
Beispiel #38
0
 public Label(DwarfGUI gui, GUIComponent parent, string text, SpriteFont textFont) :
     base(gui, parent)
 {
     Text        = text;
     TextColor   = gui.DefaultTextColor;
     StrokeColor = gui.DefaultStrokeColor;
     TextFont    = textFont;
     Alignment   = Drawer2D.Alignment.Left;
     WordWrap    = false;
 }
Beispiel #39
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;
        }
Beispiel #40
0
        public GodModeTool(DwarfGUI gui, GameMaster master)
        {
            GUI    = gui;
            Player = master;

            SelectorPanel = new Window(GUI, gui.RootComponent)
            {
                LocalBounds = new Rectangle(200, 100, 300, 100)
            };

            Label label = new Label(GUI, SelectorPanel, "Cheat Mode!", GUI.DefaultFont)
            {
                LocalBounds = new Rectangle(10, 10, 250, 32)
            };

            SelectorBox = new ComboBox(GUI, SelectorPanel)
            {
                LocalBounds   = new Rectangle(10, 64, 250, 32),
                WidthSizeMode = GUIComponent.SizeMode.Fit
            };

            IsActive = false;
            Chunks   = PlayState.ChunkManager;


            foreach (string s in RoomLibrary.GetRoomTypes())
            {
                SelectorBox.AddValue("Build " + s);
            }

            List <string> strings = EntityFactory.EntityFuncs.Keys.ToList();

            strings.Sort();
            foreach (string s in strings)
            {
                SelectorBox.AddValue(s);
            }

            foreach (VoxelType type in VoxelLibrary.PrimitiveMap.Keys.Where(type => type.Name != "empty" && type.Name != "water"))
            {
                SelectorBox.AddValue("Place " + type.Name);
            }


            SelectorBox.AddValue("Delete Block");
            SelectorBox.AddValue("Kill Block");
            SelectorBox.AddValue("Kill Things");
            SelectorBox.AddValue("Fill Water");
            SelectorBox.AddValue("Fill Lava");
            SelectorBox.AddValue("Fire");
            SelectorBox.OnSelectionModified += SelectorBox_OnSelectionModified;


            SelectorPanel.IsVisible = false;
        }
Beispiel #41
0
 public RenderPanel(DwarfGUI gui, GUIComponent parent, RenderTarget2D image) :
     base(gui, parent)
 {
     Tint            = Color.White;
     AssetName       = "";
     Highlight       = false;
     Lock            = new Mutex();
     ConstrainSize   = false;
     Image           = image;
     KeepAspectRatio = true;
 }
Beispiel #42
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>();
 }
Beispiel #43
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>();
 }
Beispiel #44
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;
 }
Beispiel #45
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;
 }
Beispiel #46
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)
     };
 }
Beispiel #47
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;
 }
Beispiel #48
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)
     };
 }
Beispiel #49
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;
            }
        }
Beispiel #50
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;
 }
Beispiel #51
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;
 }
Beispiel #52
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;
 }
Beispiel #53
0
        public GodModeTool(DwarfGUI gui, GameMaster master)
        {
            GUI = gui;
            Player = master;

            SelectorPanel = new Window(GUI, gui.RootComponent)
            {
                LocalBounds = new Rectangle(200, 100, 300, 100)
            };

            Label label = new Label(GUI, SelectorPanel, "Cheat Mode!", GUI.DefaultFont)
            {
                LocalBounds = new Rectangle(10, 10, 250, 32)
            };

            SelectorBox = new ComboBox(GUI, SelectorPanel)
            {
                LocalBounds = new Rectangle(10, 64, 250, 32),
                WidthSizeMode = GUIComponent.SizeMode.Fit
            };

            IsActive = false;
            Chunks = PlayState.ChunkManager;

            foreach(string s in RoomLibrary.GetRoomTypes())
            {
                SelectorBox.AddValue("Build " + s);
            }

            List<string> strings = EntityFactory.EntityFuncs.Keys.ToList();
            strings.Sort();
            foreach (string s in strings)
            {
                SelectorBox.AddValue(s);
            }

            foreach(VoxelType type in VoxelLibrary.PrimitiveMap.Keys.Where(type => type.Name != "empty" && type.Name != "water"))
            {
                SelectorBox.AddValue("Place " + type.Name);
            }

            SelectorBox.AddValue("Delete Block");
            SelectorBox.AddValue("Kill Block");
            SelectorBox.AddValue("Kill Things");
            SelectorBox.AddValue("Fill Water");
            SelectorBox.AddValue("Fill Lava");
            SelectorBox.AddValue("Fire");
            SelectorBox.OnSelectionModified += SelectorBox_OnSelectionModified;

            SelectorPanel.IsVisible = false;
        }
Beispiel #54
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;
 }
Beispiel #55
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;
 }
Beispiel #56
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;
 }
Beispiel #57
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);
        }
Beispiel #58
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;
        }
Beispiel #59
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;
        }
Beispiel #60
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++;
            }
        }