Example #1
0
        internal override void PositionUpdate(float x, float y)
        {
            if (!ScrollBox)
            {
                return;
            }

            var oldValue = Value;
            var trans    = Node.GetTransform.GlobalRect;
            var button   = ButtonSize / 2;

            if (y >= trans.Bottom - button)
            {
                Value = 1;
            }
            else if (y <= trans.Top + button)
            {
                Value = 0;
            }
            else
            {
                Value = (y - trans.Top - button) / (trans.Height - ButtonSize);
            }

            if (oldValue != Value)
            {
                OnValueChanged?.Invoke();
                ScrollBox.UpdatePositionScrollbox(new Vector2(0, 1 - Value));
            }
        }
Example #2
0
        private void ClipsFormsExample_Load(object sender, EventArgs e)
        {
            //Load_Idle();

            List <string> fact_name = new List <string>()
            {
                "Легкая крепость", "Средняя крепость", "Тяжелая крепость",
                "Очень тяжелая крепость", "Низкая стоимость", "Средняя стоимость", "Высокая стоимость",
                "Чайный лист", "Табачный лист Вирджиния", "Табачный лист Ориентал", "Табачный лист Бёрли",
                "Паста для кальяна", "Производство Россия", "Производство Америка", "Производство ОАЭ"
            };

            ScrollBox.Controls.Clear();

            //double d = 1.15;

            for (int i = 1; i <= 15; i++)
            {
                TrackBar_W fact = new TrackBar_W();

                fact.name = "f" + i.ToString();

                fact.Set_Text(fact_name[i - 1]);

                //fact.Set_Text(d.ToString().Replace(',','.'));

                facts.Add(fact);

                ScrollBox.Controls.Add(fact);
            }

            ScrollBox.Refresh();
        }
Example #3
0
        public Schnittstelle()
        {
            this.MyZustand = Schnittstelle.Zustand.KeinKampf;

            this.SuspendLayout();

            Konsole = new Konsole();
            SituationAuswahl = new SituationAuswahl(this);
            KampfBild = new KampfBild(this);
            Grafik = KampfBild.Grafik;
            SheduleText = new Label();
            SheduleText.AutoSize = true;
            ScrollSchedule = new ScrollBox(SheduleText);

            Timer = new Timer();
            Timer.Interval = 1000 / 60;
            Timer.Tick += (sender, e) => KampfBild.Mal();

            Controls.Add(ScrollSchedule);
            Controls.Add(KampfBild);
            Controls.Add(SituationAuswahl);
            Controls.Add(Konsole);

            this.ResumeLayout(false);
            this.ClientSize = new Size(1000, 1000);
            this.StartMenu = new StartMenu(this);
            this.ViewMenu = new ViewMenu(this);
            this.ZugMenu = new FigurZugMenu(this);
            this.MausZielMenu = new MausZielMenu(this);
            this.ShowMenu(StartMenu);
        }
Example #4
0
        public TileChunkArea(UIManager.UIManager uiManager)
        {
            var tileChunkArea = uiManager.UIManagerAreas.TileChunkArea = new UIArea<TileChunk>(null, 700, 500, 390, 390) {Closable = true};
            tileChunkArea.Visible = false;

            uiManager.AddArea(tileChunkArea);
            tileChunkArea.AddControl(new TextArea(30, 25, "Tile Chunks") {Color = "blue"});

            tileChunkArea.AddControl(chunkPieceList = new ScrollBox(30, 70, 96 - 16, 3, 64) {BackColor = "rgb(50,60,127)"});

            TileChunk[] tileChunks = SonicManager.Instance.SonicLevel.TileChunks.Array();
            for (int index = 0; index < tileChunks.Length; index++) {
                var tileChunk = tileChunks[index];
                ImageButton<TileChunk> chunkButton = new ImageButton<TileChunk>(tileChunk, 0, 0, 0, 0);
                chunkButton.OnDraw = (cnv, x, y) => {
//                                         chunkButton.Data.DrawUI(cnv, new Point(x, y), new DoublePoint(0.5d, 0.5d), 0);
//                                         chunkButton.Data.DrawUI(cnv, new Point(x, y), new DoublePoint(0.5d, 0.5d), 1);
                                     };
                chunkButton.Font = UIManager.UIManager.SmallTextFont;
                chunkButton.Text = "Chunk #" + index;
                chunkButton.Click = (e) => { tileChunkArea.Data = tileChunk; };
                chunkPieceList.AddControl(chunkButton);
            }

            Image image = new Image(125, 70, 256, 256);
            int areaDrawScale = 2;
            image.OnDraw += (context, x, y) => {
                                if (tileChunkArea.Data == null) return;
//                                tileChunkArea.Data.DrawUI(context, new Point(x, y), new Point(areaDrawScale, areaDrawScale), 0);
//                                tileChunkArea.Data.DrawUI(context, new Point(x, y), new Point(areaDrawScale, areaDrawScale), 1);
                            };
            image.Click += (e) => {
                               if (tileChunkArea.Data == null) return;
//                               var tilePiece = tileChunkArea.Data.GetBlockAt(e.X / areaDrawScale, e.Y / areaDrawScale);

//                               uiManager.UIManagerAreas.TilePieceArea.Visible = false;
//                               uiManager.UIManagerAreas.TilePieceArea.Data = tilePiece;
//                               tilePieceList.ScrollIndex = Math.Max(uiManager.sonicManager.SonicLevel.TilePieces.IndexOf(tilePiece) - 1, 0);
                           };
            tileChunkArea.AddControl(image);

            buildTilePiece(uiManager);

            /*
                        var table=tileChunkArea.AddControl(new Table(10, 40, 350, 280));
                        var row = table.AddRow(new TableRow(50.Percent()));
                        var cell = row.AddCell(new TableCell(50.Percent(), 50.Percent()));
                        cell.AddControl(new Button(0, 0, 0, 0, "Text"));
                        cell = row.AddCell(new TableCell(50.Percent(), 50.Percent()));
                        cell.AddControl(new Button(0, 0, 0, 0, "Text1")); 



                        row = table.AddRow(new TableRow(100));
                        cell = row.AddCell(new TableCell(100, 100));
                        cell.AddControl(new Button(0, 0, 100, 100, "Text"));
                        cell = row.AddCell(new TableCell(100, 100){FullSize=false});
                        cell.AddControl(new Button(0, 0, 100, 50, "Text1"));
                        cell.AddControl(new Button(0, 50, 100, 50, "Text2"));*/
        }
Example #5
0
    public AlertUi()
    {
        var doc = WidgetDoc.Load("ui/alert_ui.json");

        _mainWindow         = doc.GetRootContainer();
        _mainWindow.ZIndex  = 99800;
        _mainWindow.Name    = "alert_main_window";
        _mainWindow.Visible = false;

        _titleLabel = doc.GetTextContent("title");

        _okButton      = doc.GetButton("alert_ok_button");
        _okButton.Name = "alert_ok_button";
        _okButton.SetClickHandler(OkButtonClicked);
        _mainWindow.Add(_okButton);

        ScrollBoxSettings settings = new ScrollBoxSettings();

        settings.TextArea        = new Rectangle(6, 16, 287, 208);
        settings.ScrollBarPos    = new Point(297, 1);
        settings.ScrollBarHeight = 224;
        settings.Indent          = 7;
        settings.Font            = PredefinedFont.ARIAL_10;

        _scrollBox        = new ScrollBox(new Rectangle(20, 36, 310, 226), settings);
        _scrollBox.ZIndex = 99950;
        _scrollBox.Name   = "scrollbox_main_window";
        _mainWindow.Add(_scrollBox);
    }
Example #6
0
 public static void SetHelpContent(this ScrollBox scrollBox, string topicId, bool includeTitle = false)
 {
     if (GameSystems.Help.TryGetTopic(topicId, out var topic))
     {
         scrollBox.SetHelpContent(topic, includeTitle);
     }
     else
     {
         scrollBox.ClearLines();
     }
 }
Example #7
0
                public BindGroupBox(HudParentBase parent = null) : base(parent)
                {
                    name = new Label()
                    {
                        Format     = GlyphFormat.White,
                        AutoResize = false,
                        Height     = 24f,
                        Padding    = new Vector2(0f, 24f),
                    };

                    resetButton = new BorderedButton(this)
                    {
                        Text            = "Defaults",
                        Size            = new Vector2(234f, 44f),
                        ParentAlignment = ParentAlignments.Top | ParentAlignments.Right | ParentAlignments.Inner,
                        Visible         = false,
                        BorderThickness = 1f,
                    };

                    resetButton.MouseInput.LeftClicked += ResetBinds;

                    scrollBox = new ScrollBox <ScrollBoxEntry <BindBox>, BindBox>(true)
                    {
                        SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainOffAxis | HudChainSizingModes.ClampChainAlignAxis,
                        Spacing    = 8f,
                    };

                    scrollBox.Background.Visible = false;

                    var divider1 = new TexturedBox()
                    {
                        Color   = new Color(53, 66, 75),
                        Padding = new Vector2(0f, 16f),
                        Height  = 2f,
                    };

                    var divider2 = new TexturedBox()
                    {
                        Color   = new Color(53, 66, 75),
                        Padding = new Vector2(0f, 16f),
                        Height  = 2f,
                    };

                    layout = new HudChain(true, this)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        DimAlignment        = DimAlignments.Width | DimAlignments.IgnorePadding,
                        Padding             = new Vector2(20f, 0f),
                        Offset              = new Vector2(-10f, 0f),
                        CollectionContainer = { name, divider1, scrollBox, divider2 },
                    };

                    Height = 338f;
                }
Example #8
0
    public static void SetHelpContent(this ScrollBox scrollBox, D20HelpTopic topic, bool includeTitle = false)
    {
        scrollBox.ClearLines();
        scrollBox.DontAutoScroll = true;
        scrollBox.Indent         = 15;
        var firstLine = includeTitle ? topic.Title + "\n\n" : "\n\n";

        scrollBox.SetEntries(new List <D20RollHistoryLine>
        {
            new(firstLine, new List <D20HelpLink>()),
            new(topic.Text, topic.Links)
        });
Example #9
0
        public void AddControl(string control)
        {
            switch (control)
            {
            case "button":
                Button button = new Button(new Rectangle(START_POS_X, START_POS_Y, PROP_BUTTON_WIDTH, PROP_BUTTON_HEIGHT), Form);
                button.Text = "New Button".ToRichText();
                break;

            case "checkBox":
                CheckBox checkBox = new CheckBox(new Rectangle(START_POS_X, START_POS_Y, PROP_CHECKBOX_DIM, PROP_CHECKBOX_DIM), Form);
                checkBox.Text  = "New CheckBox".ToRichText();
                checkBox.Value = true;
                break;

            case "comboBox":
                ComboBox comboBox = new ComboBox(new Rectangle(START_POS_X, START_POS_Y, PROP_BUTTON_WIDTH, PROP_BUTTON_HEIGHT), null, Form);
                comboBox.Text = "New ComboBox".ToRichText();
                break;

            case "image":
                Image image = new Image(new Rectangle(START_POS_X, START_POS_Y, 200, 200), new Sprite(GraphicsHelper.PixelTexture), null, Form);
                break;

            case "label":
                Label label = new Label(new Rectangle(START_POS_X, START_POS_Y, 0, 0), "New Label".ToRichText(), Form);
                break;

            case "progressBar":
                ProgressBar progressBar = new ProgressBar(new Rectangle(START_POS_X, START_POS_Y, PROP_BUTTON_WIDTH, PROP_BUTTON_HEIGHT), 1f, 0.25f, Form);
                break;

            case "scrollBox":
                ScrollBox scrollBox = new ScrollBox(new Rectangle(START_POS_X, START_POS_Y, PROP_BUTTON_WIDTH, 500), null, Form);
                break;

            case "spinButton":
                SpinButton spinButton = new SpinButton(new Rectangle(START_POS_X, START_POS_Y, 100, 100), null, Form);
                break;

            case "textBox":
                TextBox textBox = new TextBox(new Rectangle(START_POS_X, START_POS_Y, PROP_BUTTON_WIDTH, PROP_BUTTON_HEIGHT), Form);
                break;

            case "textLog":
                TextLog textLog = new TextLog(new Rectangle(START_POS_X, START_POS_Y, 500, 300), Form);
                break;

            case "toolTip":
                break;
            }
        }
Example #10
0
 private static void InitGUIDefaults()
 {
     // initialise defaults for the gui system
     Control.InitDefaults();
     Button.InitDefaults();
     CheckBox.InitDefaults();
     ComboBox.InitDefaults();
     Form.InitDefaults();
     ProgressBar.InitDefaults();
     ScrollBox.InitDefaults();
     TextBox.InitDefaults();
     ToolTip.InitDefaults();
 }
Example #11
0
        private void SbCities_SelectedChanged(object sender, ListItemEventArgs e)
        {
            // when a list item is clicked in the scroll tell the client to select that city
            ScrollBox sb = (ScrollBox)sender;

            if (sb.SelectedIndex == -1)
            {
                return;
            }
            CityListitem item = (CityListitem)e.ListItem;

            client.SelectedCity = item.City;
            sb.SelectedIndex    = -1; // remove the selection from the scroll box to create desired behaivour
        }
                public CategoryElement(bool alignVertical, HudParentBase parent = null) : base(parent)
                {
                    header = new Label()
                    {
                        AutoResize = false,
                        Height     = 24f,
                        Format     = GlyphFormat.White,
                    };

                    subheader = new Label()
                    {
                        AutoResize     = false,
                        VertCenterText = false,
                        Height         = 20f,
                        Padding        = new Vector2(0f, 10f),
                        Format         = GlyphFormat.White.WithSize(.8f),
                        BuilderMode    = TextBuilderModes.Wrapped,
                    };

                    scrollBox = new ScrollBox <TMember>(alignVertical)
                    {
                        SizingMode      = HudChainSizingModes.FitChainOffAxis | HudChainSizingModes.ClampChainAlignAxis,
                        MinVisibleCount = 1,
                        Spacing         = 12f,
                        Height          = 280f,
                        Color           = Color.Red,
                    };

                    scrollBox.Background.Visible = false;

                    layout = new HudChain(true, this)
                    {
                        DimAlignment        = DimAlignments.Width | DimAlignments.IgnorePadding,
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { header, subheader, scrollBox }
                    };

                    HeaderText    = "NewSettingsCategory";
                    SubheaderText = "Subheading\nLine 1\nLine 2\nLine 3\nLine 4";

                    if (alignVertical)
                    {
                        Width = 334f;
                    }
                    else
                    {
                        Height = 334f;
                    }
                }
Example #13
0
        /// <summary>
        /// Opens the gui element
        /// </summary>
        public void Show()
        {
            lock (SceneGame._lock_guiDrawCall)
            {
                sceneGame.HideForms();               // hide other forms
                canvas.RemoveChild(form);            // remove this form from the canvas
                form = new Form(formConfig, canvas); // re build the form from the config
                string gfx_res = ConfigManager.Instance.GetVar(Constants.CONFIG_GFX_RESOLUTION);
                int    res_w   = int.Parse(gfx_res.Split('x')[0]);
                form.Location = new Point(res_w - form.Size.Width, 100); // position the form

                // retrieve form components and set them up
                ScrollBox sbCities = (ScrollBox)form.GetChildByName("sbCityList");
                sbCities.Items            = cityListItems;
                sbCities.SelectedIndex    = -1;
                sbCities.SelectedChanged += SbCities_SelectedChanged;
            }
        }
Example #14
0
        /// <summary>
        /// Opens the gui elements
        /// </summary>
        public void Show()
        {
            lock (SceneGame._lock_guiDrawCall)
            {
                // setup the form
                sceneGame.HideForms();
                canvas.RemoveChild(form);
                form = new Form(formConfig, canvas);
                string gfx_res = ConfigManager.Instance.GetVar(Constants.CONFIG_GFX_RESOLUTION);
                int    res_w   = int.Parse(gfx_res.Split('x')[0]);
                form.Location = new Point(res_w - form.Size.Width, 100); // position the form

                // get and setup the form elements
                ScrollBox sbUnitList = (ScrollBox)form.GetChildByName("sbUnitList");
                sbUnitList.SelectedIndex    = -1;
                sbUnitList.Items            = unitListItems;
                sbUnitList.SelectedChanged += SbUnitList_SelectedChanged;
            }
        }
Example #15
0
        private void Lobby_BtnEmpireSelect_MouseClick(object sender, MouseEventArgs e)
        {
            // setup the empire selection pane in the lobby form
            frm_lobby.RemoveChild(frm_lobby_configWindow);
            frm_lobby_configWindow = new Form(new Rectangle(frm_lobby.Bounds.Width - 235, 40, 230, 390), frm_lobby);
            frm_lobby_configWindow.CloseButtonEnabled = false;
            frm_lobby_configWindow.Draggable          = false;
            frm_lobby_configWindow.DrawTitlebar       = false;
            frm_lobby_configWindow.Text = "Select an empire".ToRichText();
            int       yOffset = 35;
            ScrollBox sb      = new ScrollBox(new Rectangle(5, yOffset + 5, frm_lobby_configWindow.Bounds.Width - 10, frm_lobby_configWindow.Bounds.Height - yOffset - 10), GetEmpires(), frm_lobby_configWindow);

            sb.SelectedIndex    = manager.Client.DataManager.Empire.IndexOf(manager.Client.LobbyState.Players.Find(p => p.InstanceID == manager.Client.Player.InstanceID).EmpireID);
            sb.SelectedChanged += (s, a) =>
            {
                EmpireListItem eli = (EmpireListItem)sb.Selected;
                manager.Client.Lobby_SelectNewEmpire(eli.Empire.ID);
            };
        }
Example #16
0
        private void Lobby_BtnWorldSize_MouseClick(object sender, MouseEventArgs e)
        {
            // setup the world size options pane in the lobby form
            frm_lobby.RemoveChild(frm_lobby_configWindow);
            frm_lobby_configWindow = new Form(new Rectangle(frm_lobby.Bounds.Width - 235, 40, 230, 390), frm_lobby);
            frm_lobby_configWindow.CloseButtonEnabled = false;
            frm_lobby_configWindow.Draggable          = false;
            frm_lobby_configWindow.DrawTitlebar       = false;
            frm_lobby_configWindow.Text = "Select world size".ToRichText();
            int       yOffset = 35;
            ScrollBox sb      = new ScrollBox(new Rectangle(5, yOffset + 5, frm_lobby_configWindow.Bounds.Width - 10, frm_lobby_configWindow.Bounds.Height - yOffset - 10), GetEnumStringListItems(typeof(WorldSize)), frm_lobby_configWindow);

            sb.SelectedIndex    = (int)manager.Server.LobbyState.WorldSize;
            sb.SelectedChanged += (s, a) =>
            {
                manager.Server.LobbyState.WorldSize = (WorldSize)sb.SelectedIndex;
                manager.Server.SendLobbyStateToAll();
            };
        }
Example #17
0
                public void Load(XmlReader xmlReader)
                {
                    for (int i = 0; i < xmlReader.AttributeCount; i++)
                    {
                        xmlReader.MoveToAttribute(i);
                        if (xmlReader.Name == "ID")
                        {
                            this.id = int.Parse(xmlReader.GetAttribute(i));
                        }
                        if (xmlReader.Name == "X")
                        {
                            this.x = int.Parse(xmlReader.GetAttribute(i));
                        }
                        if (xmlReader.Name == "Y")
                        {
                            this.y = int.Parse(xmlReader.GetAttribute(i));
                        }

                        if (xmlReader.Name == "WIDTH")
                        {
                            this.width = int.Parse(xmlReader.GetAttribute(i));
                        }
                        if (xmlReader.Name == "HEIGHT")
                        {
                            this.height = int.Parse(xmlReader.GetAttribute(i));
                        }
                        if (xmlReader.Name == "LISTBOXID")
                        {
                            this.listboxid = short.Parse(xmlReader.GetAttribute(i));
                        }
                    }
                    do
                    {
                        xmlReader.Read();
                        if (xmlReader.Name == "SCROLLBOX" && xmlReader.HasAttributes)
                        {
                            ScrollBox scrollBox = new ScrollBox();
                            scrollBox.Load(xmlReader);
                            this.scrollbox = scrollBox;
                        }
                    } while (xmlReader.Name != "SCROLLBAR" && !xmlReader.HasAttributes);
                }
Example #18
0
        public About() : base("About " + Info.Name)
        {
            // Initialize Dialog Window Options
            this.SetDefaultSize(320, 223);

            // Initialize VBox
            this.vbox = new Gtk.VBox(false, 0);
            this.Add(this.vbox);

            // Initialize Image Logo
            this.imageLogo = StockIcons.GetImage("NyIVLogo");
            this.vbox.PackStart(this.imageLogo, false, false, 0);

            // Initialize Credit ScollBox
            this.scrollBox = new ScrollBox(CreditText);
            this.scrollBox.SetSizeRequest(320, 95);
            this.vbox.PackStart(this.scrollBox, false, false, 0);

            this.ShowAll();
        }
Example #19
0
        public About()
            : base("About " + Info.Name)
        {
            // Initialize Dialog Window Options
            this.SetDefaultSize(320, 223);

            // Initialize VBox
            this.vbox = new Gtk.VBox(false, 0);
            this.Add(this.vbox);

            // Initialize Image Logo
            this.imageLogo = StockIcons.GetImage("NyIVLogo");
            this.vbox.PackStart(this.imageLogo, false, false, 0);

            // Initialize Credit ScollBox
            this.scrollBox = new ScrollBox(CreditText);
            this.scrollBox.SetSizeRequest(320, 95);
            this.vbox.PackStart(this.scrollBox, false, false, 0);

            this.ShowAll();
        }
Example #20
0
                    public ModList(HudParentBase parent = null) : base(parent)
                    {
                        scrollBox = new ScrollBox <ModControlRoot, LabelElementBase>(true, this)
                        {
                            SizingMode      = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.ClampChainBoth,
                            ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV,
                            Color           = TerminalFormatting.DarkSlateGrey,
                            Padding         = new Vector2(6f)
                        };

                        listInput = new ListInputElement <ModControlRoot, LabelElementBase>(scrollBox);

                        header = new LabelBox(scrollBox)
                        {
                            AutoResize      = false,
                            ParentAlignment = ParentAlignments.Top,
                            DimAlignment    = DimAlignments.Width,
                            Size            = new Vector2(200f, 36f),
                            Color           = new Color(32, 39, 45),
                            Format          = TerminalFormatting.ControlFormat,
                            Text            = "Mod List:",
                            TextPadding     = new Vector2(30f, 0f),
                        };

                        var listDivider = new TexturedBox(header)
                        {
                            ParentAlignment = ParentAlignments.Bottom,
                            DimAlignment    = DimAlignments.Width,
                            Height          = 1f,
                            Color           = new Color(53, 66, 75),
                        };

                        var listBorder = new BorderBox(this)
                        {
                            DimAlignment = DimAlignments.Both,
                            Thickness    = 1f,
                            Color        = new Color(53, 66, 75),
                        };
                    }
Example #21
0
        public CharacterCreator(ControlForm Form, CharakterErstellungsDaten Daten)
        {
            this.Universe = Daten.Universe;
            this.Form = Form;
            this.Data = new ManifestData(Universe);

            Desc = CreateLabel("");
            ScrollDesc = new ScrollBox(Desc);
            ScrollDesc.Top = 20;
            ScrollDesc.Left = 20;
            Controls.Add(ScrollDesc);

            Liste = new ControlList();
            Liste.Align = 1f;
            Liste.Location = new Point(50, 10);
            ScrollBox = new ScrollBox(Liste);
            ScrollBox.Top = 20;
            Controls.Add(ScrollBox);

            Werte = new List<CharakterWertControl>();
            NeedSpeicherort = new List<Control>();

            MakeSaveOpenDialogs();
        }
Example #22
0
        private BuildStateUI InitializeUI()
        {
            SpriteFont   buttonFont      = Content.Load <SpriteFont>("DebugFont");
            BuildStateUI newBuildStateUI = new BuildStateUI();

            #region Resource Labels
            TextBox woodLabel = new TextBox(buttonFont);
            TextBox woodCount = new TextBox(buttonFont);
            woodLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_WOOD;
            woodCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_WOOD;
            woodLabel.TextAlignment = TextBox.TextAlign.Left;
            woodCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(woodLabel);
            newBuildStateUI.RegisterResourceLabel(woodCount, GameCode.Resource.ResourceType.Wood);

            TextBox stoneLabel = new TextBox(buttonFont);
            TextBox stoneCount = new TextBox(buttonFont);
            stoneLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_STONE;
            stoneCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_STONE;
            stoneLabel.TextAlignment = TextBox.TextAlign.Left;
            stoneCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(stoneLabel);
            newBuildStateUI.RegisterResourceLabel(stoneCount, GameCode.Resource.ResourceType.Stone);

            TextBox oreLabel = new TextBox(buttonFont);
            TextBox oreCount = new TextBox(buttonFont);
            oreLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_ORE;
            oreCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_ORE;
            oreLabel.TextAlignment = TextBox.TextAlign.Left;
            oreCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(oreLabel);
            newBuildStateUI.RegisterResourceLabel(oreCount, GameCode.Resource.ResourceType.Ore);

            TextBox metalLabel = new TextBox(buttonFont);
            TextBox metalCount = new TextBox(buttonFont);
            metalLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_METAL;
            metalCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_METAL;
            metalLabel.TextAlignment = TextBox.TextAlign.Left;
            metalCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(metalLabel);
            newBuildStateUI.RegisterResourceLabel(metalCount, GameCode.Resource.ResourceType.Metal);
            #endregion

            #region ScrollBox

            ScrollBox scrollBox = new ScrollBox(Content, ControlConstants.BUILD_SCROLLBOX);
            newBuildStateUI.Add(scrollBox);
            newBuildStateUI.RegisterScrollBox(scrollBox);


            #endregion

            #region Cancel Button

            Button cancelButton = new Button(Content, ControlConstants.CANCEL_BUTTON_INFO);
            cancelButton.BackColour  = ControlConstants.CANCEL_BUTTON_COLOR;
            cancelButton.HoverColour = ControlConstants.CANCEL_BUTTON_HOVER_COLOR;
            cancelButton.Click      += Data.Town.CancelPlacementButton_Click;
            newBuildStateUI.Add(cancelButton);

            Button removeStructure = new Button(Content, ControlConstants.REMOVE_STRUCTURE_BUTTON_INFO);
            removeStructure.BackColour  = ControlConstants.REMOVE_STRUCTURE_BUTTON_COLOR;
            removeStructure.HoverColour = ControlConstants.REMOVE_STRUCTURE_BUTTON_HOVER_COLOR;
            removeStructure.Click      += Data.Town.RemoveStructureButton_Click;
            newBuildStateUI.Add(removeStructure);


            #endregion

            return(newBuildStateUI);
        }
        public ObjectFrameworkListArea(UIManager.UIManager uiManager)
        {
            Action<string> loadObject = null;

            var objectFrameworkListArea = uiManager.UIManagerAreas.ObjectFrameworkListArea = new UIArea(90, 500, 390, 300) {Closable = true};
            objectFrameworkListArea.Visible = true;

            uiManager.AddArea(objectFrameworkListArea);
            objectFrameworkListArea.AddControl(new TextArea(30, 25, "Object Frameworks") {Color = "blue"});
            ScrollBox fList;
            objectFrameworkListArea.AddControl(fList = new ScrollBox(30, 90, 25, 6, 315) {BackColor = "rgb(50,60,127)"});
            objectFrameworkListArea.AddControl(new Button(35, 50, 160, 25, "Create Framework") {
                                                                                                       Color = "rgb(50,150,50)",
                                                                                                       Click = (p) => {
                                                                                                                   uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(new LevelObject("SomeKey"));
                                                                                                                   uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                                                                                               }
                                                                                               });
            Action getObjects = () => {
                                    SonicEngine.Instance.client.Emit("GetAllObjects", "");
                                    SonicEngine.Instance.client.On<DataObject<string[]>>("GetAllObjects.Response",
                                                                                         (data) => {
                                                                                             var obj = data.Data;

                                                                                             fList.Controls = new List<Element>();
                                                                                             foreach (var itm in obj.OrderBy(a => a)) {
                                                                                                 Button d;
                                                                                                 string name = itm;
                                                                                                 fList.AddControl(d = new Button(0, 0, 0, 0, itm) {
                                                                                                                                                          Color = "rgb(50,190,90)",
                                                                                                                                                          Click = (p) => { loadObject(name); }
                                                                                                                                                  });
                                                                                             }
                                                                                         });
                                };

            objectFrameworkListArea.AddControl(new Button(200, 50, 160, 25, "Save Framework") {
                                                                                                      Color = "rgb(50,150,50)",
                                                                                                      Click = (p) => {
                                                                                                                  var oldTitle = UIManager.UIManager.CurLevelName;
                                                                                                                  UIManager.UIManager.UpdateTitle("Saving Object");

                                                                                                                  var k = uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.Key;
                                                                                                                  var o = uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.oldKey ??
                                                                                                                          uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework.Key;
                                                                                                                  var v = Help.Stringify(uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Data.ObjectFramework);

                                                                                                                  SonicEngine.Instance.client.Emit("SaveObject", new SaveObjectModel {Key = k, OldKey = o, Data = v});
                                                                                                                  SonicEngine.Instance.client.On<bool>("SaveObject.Response", (data) => { UIManager.UIManager.UpdateTitle(oldTitle); });

                                                                                                                  getObjects();
                                                                                                              }
                                                                                              });

            getObjects();
            loadObject = (name) => {
                             var objects = SonicManager.Instance.cachedObjects;
                             if (objects != null) {
                                 if (objects[name] != null) {
                                     uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(objects[name]);
                                     uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                     return;
                                 }
                             }

                             var oldTitle = UIManager.UIManager.CurLevelName;

                             UIManager.UIManager.UpdateTitle("Downloading Object:" + name);

                             SonicEngine.Instance.client.Emit("GetObject", new DataObject<string>(name));
                             SonicEngine.Instance.client.On<DataObject<string>>("GetObject.Response",
                                                                                (lvl) => {
                                                                                    UIManager.UIManager.UpdateTitle(oldTitle);
                                                                                    var d = ObjectManager.ExtendObject(jQuery.ParseJsonData<LevelObjectData>(lvl.Data));
                                                                                    uiManager.UIManagerAreas.ObjectFrameworkArea.Populate(d);
                                                                                    uiManager.UIManagerAreas.ObjectFrameworkArea.objectFrameworkArea.Visible = true;
                                                                                });
                         };
        }
            public PropertyListMenu(QuickActionMenu parent) : base(parent)
            {
                quickActionMenu = parent;

                header = new LabelBox()
                {
                    Format     = listHeaderFormat,
                    Text       = "Build Vision",
                    AutoResize = false,
                    Size       = new Vector2(300f, 34f),
                    Color      = headerColor,
                };

                listBody = new ScrollBox <PropertyListEntry, PropertyListEntryElement>(true)
                {
                    MemberMinSize      = new Vector2(300f, 0f),
                    SizingMode         = HudChainSizingModes.ClampChainOffAxis | HudChainSizingModes.FitChainAlignAxis,
                    Padding            = new Vector2(30f, 16f),
                    Color              = bodyColor,
                    EnableScrolling    = false,
                    UseSmoothScrolling = false,
                    MinVisibleCount    = 10,
                    Visible            = false,
                };

                listBody.ScrollBar.Padding = new Vector2(12f, 16f);
                listBody.ScrollBar.Width   = 4f;

                peekBody = new LabelBox()
                {
                    AutoResize     = false,
                    VertCenterText = false,
                    Color          = bodyColor,
                    TextPadding    = new Vector2(48f, 16f),
                    BuilderMode    = TextBuilderModes.Lined,
                };

                var border = new BorderBox(listBody)
                {
                    DimAlignment = DimAlignments.Both,
                    Color        = new Color(58, 68, 77),
                    Thickness    = 1f,
                };

                highlightBox = new HighlightBox(listBody.Background)
                {
                    Padding = new Vector2(16f, 0f)
                };

                footer = new DoubleLabelBox()
                {
                    AutoResize  = false,
                    TextPadding = new Vector2(48f, 0f),
                    Size        = new Vector2(300f, 24f),
                    Color       = headerColor,
                };

                layout = new HudChain(true, this)
                {
                    MemberMinSize       = new Vector2(300f, 0f),
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    CollectionContainer =
                    {
                        header,
                        { listBody,true      },
                        { peekBody,true      },
                        footer
                    }
                };

                debugText = new Label(layout)
                {
                    ParentAlignment = ParentAlignments.Right,
                    BuilderMode     = TextBuilderModes.Lined
                };

                peekBuilder       = new RichText();
                entryPool         = new ObjectPool <PropertyListEntry>(() => new PropertyListEntry(), x => x.Reset());
                notificationTimer = new Stopwatch();
                listWrapTimer     = new Stopwatch();
            }
Example #25
0
        private void SetupUserInterface()
        {
            var mainMenuSpriteMap = _spriteMapLoader.GetContent("assets/UI/title_menu_buttons.json");

            _buttonScale = 3f;
            var font = _contentChest.Get <SpriteFont>("Fonts/TitleFont");

            // Main Menu Heading
            var signTopSprite = mainMenuSpriteMap.CreateSpriteFromRegion("Title_Button_Heading");

            SignTopImage = _userInterface.AddWidget(new Image(signTopSprite,
                                                              new Vector2(_viewPortManager.ViewPort.Center().X - signTopSprite.Source.Width * _buttonScale / 2f,
                                                                          _viewPortManager.ViewPort.Center().Y - _viewPortManager.ViewPort.Height / 6f), _buttonScale));

            // Title Text
            TitleTextBlock = new TextBlock(Title,
                                           new Vector2(_viewPortManager.ViewPort.Center().X - font.MeasureString(Title).X / 2,
                                                       SignTopImage.Bounds.Top -
                                                       font.MeasureString(Title).Y), font, Color.Black, null);

            // News Section
            var newsPanelSprite   = mainMenuSpriteMap.CreateSpriteFromRegion("Main_Menu_Empty");
            var newsPanelPosition = new Vector2(SignTopImage.Bounds.Right - newsPanelSprite.Source.Width * _buttonScale,
                                                SignTopImage.Bounds.Bottom);

            NewsPanelImage = SignTopImage.AddChild(new Image(newsPanelSprite,
                                                             newsPanelPosition, _buttonScale));
            ScrollBox = new ScrollBox(_contentChest,
                                      "{line} Welcome to Project Sanctuary! {line} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi congue finibus maximus. Maecenas rhoncus malesuada eros vitae tincidunt. Nam suscipit, justo ac gravida rhoncus, ante neque auctor urna, a egestas dui odio eget ante. Aenean nec eros nisi. Nam bibendum viverra tincidunt. Phasellus elementum urna nibh, ac egestas nibh pellentesque vitae. Nulla in mollis nisl. Vivamus nec mauris rutrum magna sollicitudin venenatis et a enim. Phasellus quis mi ex. {line} ",
                                      NewsPanelImage.Bounds.Add(5 * _buttonScale, 14 * _buttonScale, -11 * _buttonScale, -20 * _buttonScale));

            // New Game Button
            var newButtonPosition = new Vector2(SignTopImage.Bounds.Left,
                                                SignTopImage.Bounds.Bottom);

            NewGameButton = new TexturedButton(
                mainMenuSpriteMap.CreateSpriteFromRegion("New_Off"),
                mainMenuSpriteMap.CreateSpriteFromRegion("New_On"),
                newButtonPosition, _buttonScale);
            NewGameButton.OnClick += () => { };

            // Load Game Button
            LoadGameButton = new TexturedButton(
                mainMenuSpriteMap.CreateSpriteFromRegion("Load_Off"),
                mainMenuSpriteMap.CreateSpriteFromRegion("Load_On"),
                newButtonPosition + new Vector2(0, NewGameButton.Height * _buttonScale), _buttonScale);
            LoadGameButton.OnClick += () => { };

            // Exit Game Button
            ExitGameButton = new TexturedButton(
                mainMenuSpriteMap.CreateSpriteFromRegion("Exit_Off"),
                mainMenuSpriteMap.CreateSpriteFromRegion("Exit_On"),
                newButtonPosition + new Vector2(0,
                                                NewGameButton.Height * _buttonScale + LoadGameButton.Height * _buttonScale),
                _buttonScale);
            ExitGameButton.OnClick += () => Console.WriteLine("Closing Game...");

            var settingsSprite = mainMenuSpriteMap.CreateSpriteFromRegion("Settings_On");
            var settingsButton = new TexturedButton(
                mainMenuSpriteMap.CreateSpriteFromRegion("Settings_Off"), settingsSprite,
                new Vector2(_viewPortManager.ViewPort.Width - settingsSprite.Source.Width * _buttonScale - 10,
                            _viewPortManager.ViewPort.Height - settingsSprite.Source.Height * _buttonScale - 10), _buttonScale);

            // Add all elements to the parent.
            SignTopImage.AddChild(TitleTextBlock);
            SignTopImage.AddChild(ScrollBox);
            SignTopImage.AddChild(NewGameButton as IWidget);
            SignTopImage.AddChild(LoadGameButton as IWidget);
            SignTopImage.AddChild(ExitGameButton as IWidget);
            SignTopImage.AddChild(settingsButton);

            _userInterface.AddWidget(SignTopImage);
        }
Example #26
0
        /// <summary>
        /// opens the gui element
        /// </summary>
        public void Show()
        {
            lock (SceneGame._lock_guiDrawCall)
            {
                sceneGame.HideForms(false);      // hide other forms

                if (client.SelectedCity == null) // dont't continue if there is no selected city
                {
                    return;
                }

                int yOffset    = 40;
                int itemHeight = 50;

                // setup the production list/selection form
                canvas.RemoveChild(frmProduction);
                frmProduction          = new Form(frmProductionConfig, canvas);
                frmProduction.Location = new Point(0, 1080 - frmProduction.Size.Height);

                // setup the stats form
                canvas.RemoveChild(frmStats);
                frmStats          = new Form(frmStatsConfig, canvas);
                frmStats.Location = new Point(frmProduction.Size.Width, yOffset);

                // setup the citizen focus form
                canvas.RemoveChild(frmFocus);
                frmFocus          = new Form(frmFocusConfig, canvas);
                frmFocus.Location = new Point(1920 - frmFocus.Size.Width, yOffset);

                // setup the form in the bottom middle of the screen that allows the user to leave the city screen
                canvas.RemoveChild(frmReturnBuy);
                frmReturnBuy = new Form(frmReturnBuyConfig, canvas);
                frmReturnBuy.CentreControl();
                frmReturnBuy.Location = new Point(frmReturnBuy.Location.X, 1080 - 100 - frmReturnBuy.Size.Height);

                // get and format the stats form elements
                Label lblPopulationValue = (Label)frmStats.GetChildByName("lblPopulationValue");
                lblPopulationValue.Text = $"{client.SelectedCity.Population}".ToRichText();
                Label lblPopGrowthValue = (Label)frmStats.GetChildByName("lblPopGrowthValue");
                int   turnsUntilGrowth  = client.SelectedCity.TurnsUntilPopulationGrowth;
                if (turnsUntilGrowth == -1)
                {
                    lblPopGrowthValue.Text = $"Inf".ToRichText();
                }
                else if (turnsUntilGrowth == -2)
                {
                    lblPopGrowthValue.Text = $"~".ToRichText();
                }
                else
                {
                    lblPopGrowthValue.Text = $"{turnsUntilGrowth}".ToRichText();
                }
                Label lblFoodValue = (Label)frmStats.GetChildByName("lblFoodValue");
                lblFoodValue.Text = $"+{client.SelectedCity.IncomeFood}".ToRichText();
                Label lblProductionValue = (Label)frmStats.GetChildByName("lblProductionValue");
                lblProductionValue.Text = $"+{client.SelectedCity.IncomeProduction}".ToRichText();
                Label lblGoldValue = (Label)frmStats.GetChildByName("lblGoldValue");
                lblGoldValue.Text = $"+{client.SelectedCity.IncomeGold}".ToRichText();
                Label lblScienceValue = (Label)frmStats.GetChildByName("lblScienceValue");
                lblScienceValue.Text = $"+{client.SelectedCity.IncomeScience}".ToRichText();
                Label lblFaithValue = (Label)frmStats.GetChildByName("lblFaithValue");
                lblFaithValue.Text = $"+{client.SelectedCity.IncomeFaith}".ToRichText();
                Label lblTourismValue = (Label)frmStats.GetChildByName("lblTourismValue");
                lblTourismValue.Text = $"+{client.SelectedCity.IncomeTourism}".ToRichText();
                Label lblCultureValue = (Label)frmStats.GetChildByName("lblCultureValue");
                lblCultureValue.Text = $"+{client.SelectedCity.IncomeCulture}".ToRichText();
                Label lblBorderGrowthValue = (Label)frmStats.GetChildByName("lblBorderGrowthValue");
                lblBorderGrowthValue.Text = $"+{client.SelectedCity.IncomeCulture}".ToRichText();
                int turnsUntilBorderGrowth = client.SelectedCity.TurnsUntilBorderGrowth;
                if (turnsUntilBorderGrowth == -1)
                {
                    lblBorderGrowthValue.Text = $"Inf".ToRichText();
                }
                else if (turnsUntilBorderGrowth == -2)
                {
                    lblBorderGrowthValue.Text = $"~".ToRichText();
                }
                else
                {
                    lblBorderGrowthValue.Text = $"{turnsUntilBorderGrowth}".ToRichText();
                }
                TextBox tbName = (TextBox)frmStats.GetChildByName("tbName");
                tbName.Text          = client.SelectedCity.Name;
                tbName.EnterPressed += TbName_EnterPressed;

                // get and setup the production form elements
                sbProductionQueue                  = (ScrollBox)frmProduction.GetChildByName("sbProductionQueue");
                sbProductionQueue.ItemHeight       = itemHeight;
                sbProductionQueue.Items            = GetProductionQueueListItems();
                sbProductionQueue.SelectedIndex    = sbProductionQueueSelected;
                sbProductionQueue.SelectedChanged += (s, a) => sbProductionQueueSelected = sbProductionQueue.SelectedIndex;
                sbProductionList                  = (ScrollBox)frmProduction.GetChildByName("sbProductionList");
                sbProductionList.ItemHeight       = itemHeight;
                sbProductionList.Items            = GetProductionListListItems();
                sbProductionList.SelectedIndex    = sbProductionListSelected;
                sbProductionList.SelectedChanged += (s, a) => sbProductionListSelected = sbProductionList.SelectedIndex;
                Button btnCancelProduction = (Button)frmProduction.GetChildByName("btnCancelProduction");
                btnCancelProduction.MouseClick += BtnCancelProduction_MouseClick;
                Button btnMoveUp = (Button)frmProduction.GetChildByName("btnMoveUp");
                btnMoveUp.MouseClick += BtnMoveUp_MouseClick;
                Button btnMoveDown = (Button)frmProduction.GetChildByName("btnMoveDown");
                btnMoveDown.MouseClick += BtnMoveDown_MouseClick;
                Button btnChangeProduction = (Button)frmProduction.GetChildByName("btnChangeProduction");
                btnChangeProduction.MouseClick += BtnChangeProduction_MouseClick;
                Button btnQueueProduction = (Button)frmProduction.GetChildByName("btnQueueProduction");
                btnQueueProduction.MouseClick += BtnQueueProduction_MouseClick;
                Button btnPurchase = (Button)frmProduction.GetChildByName("btnPurchase");
                btnPurchase.MouseClick += BtnPurchase_MouseClick;

                // get and setup the citizen focus form elements
                sbCitizenFocus                  = (ScrollBox)frmFocus.GetChildByName("sbCitizenFocus");
                sbCitizenFocus.Items            = GetCitizenFocusListItems();
                sbCitizenFocus.SelectedIndex    = (int)client.SelectedCity.CitizenFocus;
                sbCitizenFocus.SelectedChanged += SbCitizenFocus_SelectedChanged;
                sbBuildingList                  = (ScrollBox)frmFocus.GetChildByName("sbBuildingList");
                sbBuildingList.ItemHeight       = itemHeight;
                sbBuildingList.Items            = GetBuildingList();
                sbBuildingList.SelectedIndex    = 0;
                Button btnDemolish = (Button)frmFocus.GetChildByName("btnDemolish");
                btnDemolish.MouseClick += BtnDemolish_MouseClick;

                // get and setup the return/buy tiles form elements
                Button btnBuyTile = (Button)frmReturnBuy.GetChildByName("btnBuyTile");
                btnBuyTile.MouseClick += (s, a) => buyingTiles = true;
                Button btnReturnToMap = (Button)frmReturnBuy.GetChildByName("btnReturnToMap");
                btnReturnToMap.MouseClick += (s, a) => Hide();
            }
        }
Example #27
0
        public MainWindow()
        {
            InitializeComponent();

            Widget.Style       = MooTUI.Drawing.Style.Light.Value;
            BoxDrawing.Default = BoxDrawing.Square;

            TabBox tabs = new TabBox(
                new LayoutRect(
                    new FlexSize(80),
                    new FlexSize(40)));

            WPFMooViewer viewer = new WPFFormattedTextViewer(tabs.Width, tabs.Height, 8, 17, 14.725,
                                                             Theme.Basic.Value);

            Content    = viewer;
            Background = new SolidColorBrush(Theme.Basic.Value.Palette[MooTUI.Drawing.Color.Base03]);

            new MooInterface(viewer, tabs);

            Container = new LayoutContainer(
                new LayoutRect(
                    new FlexSize(70),
                    new FlexSize(35)),
                Orientation.Vertical,
                crossJustification: LayoutContainer.CrossAxisJustification.STRETCH);

            ScrollBox scroll = new ScrollBox(
                new LayoutRect(75, 30),
                Container);

            tabs.AddTab(scroll, TextSpan.Parse("{base03/altyellow}Tab 01"));

            Button bigboi = new Button(new LayoutRect(new FlexSize(30), new FlexSize(10)),
                                       new TextSpan("This is a beeg boi"));

            tabs.AddTab(bigboi, TextSpan.Parse("This tab has a button"));

            ListBox list = new ListBox(
                new LayoutRect(
                    new FlexSize(20),
                    new Size(10)),
                new TextSpan("List!"),
                true);

            Container.AddChild(list);

            Button addToList = new Button(
                new LayoutRect(
                    new FlexSize(35),
                    new Size(1)),
                TextSpan.Parse("{green/}add an item to the list!"));

            addToList.Click += (s, e) =>
            {
                list.Add("This is a {yellow/}listitem!");
            };
            Button removeList = new Button(
                new LayoutRect(
                    new FlexSize(35),
                    new Size(1)),
                TextSpan.Parse("{red/}remove selected listitem!"));

            removeList.Click += (s, e) =>
            {
                list.RemoveElementUnderCursor();
            };

            Container.AddChild(addToList);
            Container.AddChild(removeList);

            SimpleTextInput t = new SimpleTextInput(
                new FlexSize(10),
                10,
                false,
                "Prompt!!!");

            ScrollBox b = new ScrollBox(
                new LayoutRect(
                    new FlexSize(35),
                    new Size(3)),
                t,
                vScrollbarVisibility: ScrollBox.ScrollBarVisibility.DISABLED);

            Button setText = new Button(
                new LayoutRect(
                    new FlexSize(35),
                    new Size(1)),
                new TextSpan("set the text of the textInput"));

            setText.Click += (s, e) => t.SetText("TEXT :)");

            Container.AddChild(b);
            Container.AddChild(setText);

            Container.AddChild(new Toggle(TextSpan.Parse("Check?")));
        }
Example #28
0
        private void buildTilePiece(UIManager.UIManager uiManager)
        {
            var tilePieceArea = uiManager.UIManagerAreas.TilePieceArea = new UIArea<TilePiece>(null, 1100, 400, 390, 390) {Closable = true};
            tilePieceArea.Visible = false;

            uiManager.AddArea(tilePieceArea);
            tilePieceArea.AddControl(new TextArea(30, 25, "Tile Pieces") {Color = "blue"});

            bool showHeightMap = false;
            tilePieceArea.AddControl(new Button(100, 50, 125, 25, (Func<string>) ( () => showHeightMap ? "Hide Height Map" : "Show Height Map" )) {
                                                                                                                                                          Click = (e) => {
                                                                                                                                                                      if (tilePieceArea.Data == null) return;
                                                                                                                                                                      showHeightMap = !showHeightMap;
                                                                                                                                                                  }
                                                                                                                                                  });

            tilePieceList = new ScrollBox(10, 35, 96 - 16, 4, 64) {BackColor = "rgb(50,60,127)"};
            tilePieceArea.AddControl(tilePieceList);

            var tilePieces = SonicManager.Instance.SonicLevel.TilePieces.Array();
            for (int index = 0; index < tilePieces.Length; index++) {
                var tilePiece = tilePieces[index];
                ImageButton<TilePiece> tilePieceButton = new ImageButton<TilePiece>(tilePiece, 0, 0, 0, 0);
                tilePieceButton.OnDraw = (cnv, x, y) => {
                                             cnv.Save();
                                             cnv.Translate(x, y);
                                             cnv.Scale(4, 4);
//                                             tilePieceButton.Data.Draw(cnv, new Point(0, 0), ChunkLayer.Low, false, false, 0);
//                                             tilePieceButton.Data.Draw(cnv, new Point(0, 0), ChunkLayer.High, false, false, 0);

                                             if (showHeightMap) {
                                                 HeightMap hmap;
                                                 if (SonicManager.Instance.SonicLevel.CurHeightMap)
                                                     hmap = tilePiece.GetLayer1HeightMaps();
                                                 else
                                                     hmap = tilePiece.GetLayer2HeightMaps();

                                                 hmap.Draw(cnv, new Point(0, 0), false, false, 1, 0);
                                             }

                                             cnv.Restore();
                                         };
                tilePieceButton.Font = UIManager.UIManager.SmallTextFont;
                tilePieceButton.Text = "Tile Piece #" + index;
                tilePieceButton.Click = (e) => { tilePieceArea.Data = tilePiece; };
                tilePieceList.AddControl(tilePieceButton);
            }

            Image image = new Image(105, 120, 256, 256);
            image.OnDraw += (context, x, y) => {
                                if (tilePieceArea.Data == null) return;
                                context.Save();
                                context.Translate(x, y);
                                context.Scale(16, 16);
//                                tilePieceArea.Data.Draw(context, new Point(0, 0), ChunkLayer.Low, false, false, 0);
//                                tilePieceArea.Data.Draw(context, new Point(0, 0), ChunkLayer.High, false, false, 0);
                                context.Restore();
                            };

            tilePieceArea.AddControl(image);
        }
            public ItemListe(string NeuText, Gegenstand.Kategorie Kategorie, CharakterErstellungsDaten Daten, int Maximum)
            {
                this.Kategorie = Kategorie;
                this.Daten = Daten;
                this.Gegenstande = new List<Gegenstand>();
                this.Form = new ElementAuswahlForm<Gegenstand>(Daten.Universe.Gegenstande);
                this.Maximum = Maximum;

                Liste = new ControlList();
                ScrollBox = new ScrollBox(Liste);
                Neu = new Button();
                Neu.Text = NeuText;
                Neu.AutoSize = true;
                Neu.Click += NeuKlick;
                Neu.Enabled = false;
                this.Controls.Add(ScrollBox);

                this.Size = ScrollBox.Size = new Size(300, 300);

                FillListe(Gegenstande);
                UpdateInfo();
            }
Example #30
0
        /// <summary>
        /// Opens the gui element
        /// </summary>
        public void Show()
        {
            lock (SceneGame._lock_guiDrawCall)
            {
                // setup the form
                sceneGame.HideForms();
                canvas.RemoveChild(form);
                form           = new Form(formConfig, canvas);
                form.Draggable = false;
                form.Drawn    += Form_Drawn;
                form.CentreControl();
                form.Location = new Point(form.Location.X, 35);

                // get and setup the form elements
                ScrollBox sbSocialPolicyTrees = (ScrollBox)form.GetChildByName("sbSocialPolicyTrees");
                sbSocialPolicyTrees.SelectedIndex    = selectedIndex;
                sbSocialPolicyTrees.Items            = GetPolicyTreeListItems();
                sbSocialPolicyTrees.SelectedChanged += SbPolicyTrees_SelectedChanged;
                PolicyTreeListItem selectedItem = (PolicyTreeListItem)sbSocialPolicyTrees.Selected;

                lines = new List <Line>();

                int offsetX    = sbSocialPolicyTrees.AbsoluteBounds.Width + 10;
                int offsetY    = 50;
                int itemWidth  = 200;
                int itemHeight = 70;
                int sepX       = 70;
                int sepY       = 50;

                // build a button for every node in the social policy tree
                foreach (SocialPolicy policy in client.Player.SocialPolicyInstance.GetAllSocialPoliciesInTree(selectedItem.SocialPolicyTree.ID))
                {
                    Rectangle dest = new Rectangle(offsetX + policy.GridX * (itemWidth + sepX), offsetY + policy.GridY * (itemHeight + sepY), itemWidth, itemHeight);
                    Button    b    = new Button(dest, form);
                    string    text = policy.Name;
                    // format the button text
                    b.Text = text.ToRichText();
                    // pick an appropriate sprite
                    bool unlockable = true;
                    foreach (string prereqID in policy.Prerequisites)
                    {
                        SocialPolicy prereq = client.Player.SocialPolicyInstance.GetSocialPolicy(prereqID);
                        if (prereq != null && !prereq.Unlocked)
                        {
                            unlockable = false;
                        }
                    }
                    if (policy.Unlocked)
                    {
                        b.Sprite = policyUnlockedSprite;
                    }
                    else if (unlockable)
                    {
                        b.Sprite = policyAdoptable;
                    }
                    else
                    {
                        b.Sprite = policyLockedSprite;
                    }

                    string policyID = policy.ID; // cache id because of closure
                    b.MouseClick += (s, a) =>
                    {
                        // only tell the server to select a new tech if all the prereqs are unlocked
                        SocialPolicy clicked = client.DataManager.SocialPolicy.GetSocialPolicy(policyID);
                        foreach (string prereqID in clicked.Prerequisites)
                        {
                            SocialPolicy prereq = client.Player.SocialPolicyInstance.GetSocialPolicy(prereqID);
                            if (prereq != null && !prereq.Unlocked)
                            {
                                return;
                            }
                        }

                        client.CommandPlayer(new PlayerCommand(PlayerCommandID.UnlockPolicy, policyID));
                    };
                    // add a tool tip with more info about the policy
                    b.ToolTip = new ToolTip(policy.Description.ToRichText(), 500);
                    b.ToolTip.FollowCurosr = true;

                    // add a line from the current policy to all its prereqs
                    foreach (string prereqID in policy.Prerequisites)
                    {
                        SocialPolicy prereq = client.DataManager.SocialPolicy.GetSocialPolicy(prereqID);
                        if (prereq == null)
                        {
                            continue;
                        }
                        Rectangle prereqRect = new Rectangle(offsetX + prereq.GridX * (itemWidth + sepX), offsetY + prereq.GridY * (itemHeight + sepY), itemWidth, itemHeight);
                        lines.Add(new Line(new Vector2(form.AbsoluteLocation.X + dest.X, dest.Y + itemHeight / 2 + offsetY), new Vector2(form.AbsoluteLocation.X + prereqRect.X + itemWidth, prereqRect.Y + itemHeight / 2 + offsetY)));
                    }
                }
            }
        }
Example #31
0
        // sets up the lobby form
        private void SetUpLobbyForm()
        {
            lock (_lock_guiSetUp)
            {
                // set the audio manager to play the selected empire's anthem over and over
                AudioManager.Instance.PlayerState = MusicPlayerState.RepeatOne;

                // register events
                manager.Client.LostConnection += Client_LostConnection;

                // load the form config
                FormConfig formConfig = FormConfig.FromStream(Engine.Instance.Content.GetAsset <Stream>("Core:XML/Interface/Menu/Lobby"));

                // setup the form
                canvas.RemoveChild(frm_lobby);
                frm_lobby = new Form(formConfig, canvas);
                frm_lobby.CentreControl();

                // get and setup the for elements
                Button btnStart = (Button)frm_lobby.GetChildByName("btnStart");
                if (host)
                {
                    btnStart.MouseClick += Lobby_BtnStart_MouseClick;
                }
                else
                {
                    btnStart.Enabled = false;
                }

                Button btnBack = (Button)frm_lobby.GetChildByName("btnBack");
                btnBack.MouseClick += Lobby_BtnBack_MouseClick;

                Button btnKick = (Button)frm_lobby.GetChildByName("btnKick");
                if (host)
                {
                    btnKick.MouseClick += Lobby_BtnKick_MouseClick;
                }
                else
                {
                    btnKick.Enabled = false;
                }

                Button btnBan = (Button)frm_lobby.GetChildByName("btnBan");
                if (host)
                {
                    btnBan.MouseClick += Lobby_BtnBan_MouseClick;
                }
                else
                {
                    btnBan.Enabled = false;
                }

                lobby_btnEmpireSelect             = (Button)frm_lobby.GetChildByName("btnEmpire");
                lobby_btnEmpireSelect.MouseClick += Lobby_BtnEmpireSelect_MouseClick;

                lobby_btnWorldSize = (Button)frm_lobby.GetChildByName("btnWorldSize");
                if (host)
                {
                    lobby_btnWorldSize.MouseClick += Lobby_BtnWorldSize_MouseClick;
                }
                else
                {
                    lobby_btnWorldSize.Enabled = false;
                }

                lobby_btnWorldType = (Button)frm_lobby.GetChildByName("btnWorldType");
                if (host)
                {
                    lobby_btnWorldType.MouseClick += Lobby_BtnWorldType_MouseClick;
                }
                else
                {
                    lobby_btnWorldType.Enabled = false;
                }

                lobby_btnGameSpeed = (Button)frm_lobby.GetChildByName("btnGameSpeed");
                if (host)
                {
                    lobby_btnGameSpeed.MouseClick += Lobby_BtnGameSpeed_MouseClick;
                }
                else
                {
                    lobby_btnGameSpeed.Enabled = false;
                }

                lobby_btnVictoryTypes             = (Button)frm_lobby.GetChildByName("btnVictoryTypes");
                lobby_btnVictoryTypes.MouseClick += Lobby_BtnVictoryTypes_MouseClick;

                lobby_btnOtherOptions             = (Button)frm_lobby.GetChildByName("btnOtherOptions");
                lobby_btnOtherOptions.MouseClick += Lobby_BtnOtherOptions_MouseClick;

                lobby_sbPlayers       = (ScrollBox)frm_lobby.GetChildByName("sbPlayers");
                lobby_sbPlayers.Items = GetPlayers();

                // fake an event to open the empire select menu
                Lobby_BtnEmpireSelect_MouseClick(lobby_btnEmpireSelect, new MouseEventArgs(true, false, false, lobby_btnEmpireSelect.AbsoluteLocation, 0));
            }
        }