예제 #1
0
 private GuiComponent CreateEditField(object o, FieldInfo field)
 {
     if (o is String || o is string)
     {
         var editStr = new Textbox(100, _resourceCache);
         editStr.ClearOnSubmit = false;
         editStr.UserData      = field;
         editStr.Text          = ((string)o);
         editStr.OnSubmit     += editStr_OnSubmit;
         return(editStr);
     }
     else if (o is Enum)
     {
         var editEnum = new Listbox(100, 100, _resourceCache, Enum.GetNames(o.GetType()).ToList());
         editEnum.UserData = field;
         editEnum.SelectItem(o.ToString());
         editEnum.ItemSelected += editEnum_ItemSelected;
         return(editEnum);
     }
     else if (o is float || o is int || o is Int16 || o is Int32 || o is Int64 || o is double || o is Double ||
              o is decimal || o is Decimal || o is Single)
     {
         var editNum = new Textbox(100, _resourceCache);
         editNum.ClearOnSubmit = false;
         editNum.UserData      = field;
         editNum.Text          = o.ToString();
         editNum.OnSubmit     += editNum_OnSubmit;
         return(editNum);
     }
     else if (o is bool || o is Boolean)
     {
         var editBool = new Checkbox(_resourceCache);
         editBool.UserData      = field;
         editBool.Value         = ((Boolean)o);
         editBool.ValueChanged += editBool_ValueChanged;
         return(editBool);
     }
     return(null);
 }
예제 #2
0
        public EntitySpawnPanel(Vector2i size, IResourceCache resourceCache, IPlacementManager placementManager)
            : base("Entity Spawn Panel", size, resourceCache)
        {
            _placementManager = placementManager;

            _entityList = new ScrollableContainer("entspawnlist", new Vector2i(200, 400), _resourceCache)
            {
                Position = new Vector2i(5, 5)
            };
            components.Add(_entityList);

            var searchLabel = new Label("Entity Search:", "CALIBRI", _resourceCache)
            {
                Position = new Vector2i(210, 0)
            };

            components.Add(searchLabel);

            _entSearchTextbox = new Textbox(125, _resourceCache)
            {
                Position = new Vector2i(210, 20)
            };
            _entSearchTextbox.OnSubmit += entSearchTextbox_OnSubmit;
            components.Add(_entSearchTextbox);

            _clearLabel = new Label("[Clear Filter]", "CALIBRI", _resourceCache)
            {
                DrawBackground = true,
                DrawBorder     = true,
                Position       = new Vector2i(210, 55)
            };

            _overLabel = new Label("Override Placement:", "CALIBRI", _resourceCache)
            {
                Position = _clearLabel.Position + new Vector2i(0, _clearLabel.ClientArea.Height + 15)
            };

            components.Add(_overLabel);

            var initOpts = new List <string>();

            initOpts.AddRange(new[]
            {
                "None",
                "AlignNone",
                "AlignFree",
                "AlignSimilar",
                "AlignTileAny",
                "AlignTileEmpty",
                "AlignTileNonSolid",
                "AlignTileSolid",
                "AlignWall",
                "AlignWallTops"
            });

            _lstOverride = new Listbox(150, 125, resourceCache, initOpts);
            _lstOverride.SelectItem("AlignFree");
            _lstOverride.ItemSelected += _lstOverride_ItemSelected;
            _lstOverride.Position      = _overLabel.Position + new Vector2i(0, _overLabel.ClientArea.Height);
            components.Add(_lstOverride);

            _clearLabel.Clicked        += ClearLabelClicked;
            _clearLabel.BackgroundColor = new SFML.Graphics.Color(128, 128, 128);
            components.Add(_clearLabel);

            _eraserButton = new ImageButton
            {
                ImageNormal = "erasericon",
                Position    =
                    new Vector2i(_clearLabel.Position.X + _clearLabel.ClientArea.Width + 5,
                                 _clearLabel.Position.Y)
            };

            //eraserButton.Position = new Vector2i(clearLabel.ClientArea.Right + 5, clearLabel.ClientArea.Top); Clientarea not updating properly. FIX THIS
            _eraserButton.Clicked += EraserButtonClicked;
            components.Add(_eraserButton);

            BuildEntityList();

            Position = new Vector2i((int)(CluwneLib.CurrentRenderTarget.Size.X / 2f) - (int)(ClientArea.Width / 2f),
                                    (int)(CluwneLib.CurrentRenderTarget.Size.Y / 2f) - (int)(ClientArea.Height / 2f));
            _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled;
        }