Exemplo n.º 1
0
        private void editEnum_ItemSelected(Label item, Listbox sender)
        {
            var    field = (FieldInfo)sender.UserData;
            object state = Enum.Parse(field.FieldType, item.Text.Text, true);

            if (field.IsInitOnly || field.IsLiteral)
            {
                return;
            }
            field.SetValue(assigned, state);
        }
Exemplo n.º 2
0
        private void _lstOverride_ItemSelected(Label item, Listbox sender)
        {
            var pMan = (PlacementManager)_placementManager;

            if (pMan.CurrentMode != null)
            {
                var newObjInfo = new PlacementInformation
                {
                    PlacementOption = item.Text.Text,
                    EntityType      = pMan.CurrentPermission.EntityType,
                    Range           = -1,
                    IsTile          = pMan.CurrentPermission.IsTile
                };

                _placementManager.Clear();
                _placementManager.BeginPlacing(newObjInfo);
            }
        }
Exemplo n.º 3
0
 private GuiComponent CreateEditField(object o, FieldInfo field)
 {
     if (o is String || o is string)
     {
         var editStr = new Textbox(100, _resourceManager);
         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, _resourceManager, 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, _resourceManager);
         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(_resourceManager);
         editBool.UserData      = field;
         editBool.Value         = ((Boolean)o);
         editBool.ValueChanged += editBool_ValueChanged;
         return(editBool);
     }
     return(null);
 }
Exemplo n.º 4
0
        public EntitySpawnPanel(Size size, IResourceManager resourceManager, IPlacementManager placementManager)
            : base("Entity Spawn Panel", size, resourceManager)
        {
            _resourceManager = resourceManager;
            _placementManager = placementManager;

            _entityList = new ScrollableContainer("entspawnlist", new Size(200, 400), _resourceManager)
                              {Position = new Point(5, 5)};
            components.Add(_entityList);

            var searchLabel = new Label("Entity Search:", "CALIBRI", _resourceManager) {Position = new Point(210, 0)};
            components.Add(searchLabel);

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

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

            _overLabel = new Label("Override Placement:", "CALIBRI", _resourceManager)
                             {
                                 Position = _clearLabel.Position + new Size(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, resourceManager, initOpts);
            _lstOverride.SelectItem("None");
            _lstOverride.ItemSelected += _lstOverride_ItemSelected;
            _lstOverride.Position = _overLabel.Position + new Size(0, _overLabel.ClientArea.Height);
            components.Add(_lstOverride);

            _clearLabel.Clicked += ClearLabelClicked;
            _clearLabel.BackgroundColor = Color.Gray;
            components.Add(_clearLabel);

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

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

            BuildEntityList();

            Position = new Point((int) (Gorgon.CurrentRenderTarget.Width/2f) - (int) (ClientArea.Width/2f),
                                 (int) (Gorgon.CurrentRenderTarget.Height/2f) - (int) (ClientArea.Height/2f));
            _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled;
        }
Exemplo n.º 5
0
        private void _lstOverride_ItemSelected(Label item, Listbox sender)
        {
            var pMan = (PlacementManager) _placementManager;

            if (pMan.CurrentMode != null)
            {
                var newObjInfo = new PlacementInformation
                                     {
                                         PlacementOption = item.Text.Text,
                                         EntityType = pMan.CurrentPermission.EntityType,
                                         Range = -1,
                                         IsTile = pMan.CurrentPermission.IsTile
                                     };

                _placementManager.Clear();
                _placementManager.BeginPlacing(newObjInfo);
            }
        }
Exemplo n.º 6
0
        public EntitySpawnPanel(Size size, IResourceManager resourceManager, IPlacementManager placementManager)
            : base("Entity Spawn Panel", size, resourceManager)
        {
            _resourceManager  = resourceManager;
            _placementManager = placementManager;

            _entityList = new ScrollableContainer("entspawnlist", new Size(200, 400), _resourceManager)
            {
                Position = new Point(5, 5)
            };
            components.Add(_entityList);

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

            components.Add(searchLabel);

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

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

            _overLabel = new Label("Override Placement:", "CALIBRI", _resourceManager)
            {
                Position = _clearLabel.Position + new Size(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, resourceManager, initOpts);
            _lstOverride.SelectItem("None");
            _lstOverride.ItemSelected += _lstOverride_ItemSelected;
            _lstOverride.Position      = _overLabel.Position + new Size(0, _overLabel.ClientArea.Height);
            components.Add(_lstOverride);

            _clearLabel.Clicked        += ClearLabelClicked;
            _clearLabel.BackgroundColor = Color.Gray;
            components.Add(_clearLabel);

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

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

            BuildEntityList();

            Position = new Point((int)(Gorgon.CurrentRenderTarget.Width / 2f) - (int)(ClientArea.Width / 2f),
                                 (int)(Gorgon.CurrentRenderTarget.Height / 2f) - (int)(ClientArea.Height / 2f));
            _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled;
        }
Exemplo n.º 7
0
        public OptionsMenu(IDictionary<Type, object> managers)
            : base(managers)
        {
            _background = ResourceManager.GetSprite("mainbg");
            _background.Smoothing = Smoothing.Smooth;

            _lblfullscreen = new Label("Fullscreen", "CALIBRI", ResourceManager);

            _chkfullscreen = new Checkbox(ResourceManager);
            _chkfullscreen.Value = ConfigurationManager.GetFullscreen();
            _chkfullscreen.ValueChanged += _chkfullscreen_ValueChanged;

            _lblvsync = new Label("Vsync", "CALIBRI", ResourceManager);

            _chkvsync = new Checkbox(ResourceManager);
            _chkvsync.Value = ConfigurationManager.GetVsync();
            _chkvsync.ValueChanged += _chkvsync_ValueChanged;

            _reslistbox = new Listbox(250, 150, ResourceManager);
            _reslistbox.ItemSelected += _reslistbox_ItemSelected;

            IOrderedEnumerable<VideoMode> modes = from v in Gorgon.CurrentDriver.VideoModes
                                                  where
                                                      (v.Height > 748 && v.Width > 1024) &&
                                                      v.Format == BackBufferFormats.BufferRGB888 && v.RefreshRate >= 59
                                                  //GOSH I HOPE NOONES USING 16 BIT COLORS. OR RUNNING AT LESS THAN 59 hz
                                                  orderby v.Height*v.Width ascending
                                                  select v;

            if (!modes.Any())
                //No compatible videomodes at all. It is likely the game is being run on a calculator. TODO handle this.
                Application.Exit();

            foreach (VideoMode vm in modes)
            {
                if (!vmList.ContainsKey(GetVmString(vm)))
                {
                    vmList.Add(GetVmString(vm), vm);
                    _reslistbox.AddItem(GetVmString(vm));
                }
            }

            if (
                vmList.Any(
                    x =>
                    x.Value.Width == Gorgon.CurrentVideoMode.Width && x.Value.Height == Gorgon.CurrentVideoMode.Height &&
                    x.Value.RefreshRate ==
                    (Gorgon.Screen.Windowed ? Gorgon.DesktopVideoMode.RefreshRate : Gorgon.CurrentVideoMode.RefreshRate)))
            {
                KeyValuePair<string, VideoMode> curr =
                    vmList.FirstOrDefault(
                        x =>
                        x.Value.Width == Gorgon.CurrentVideoMode.Width &&
                        x.Value.Height == Gorgon.CurrentVideoMode.Height &&
                        x.Value.RefreshRate ==
                        (Gorgon.Screen.Windowed
                             ? Gorgon.DesktopVideoMode.RefreshRate
                             : Gorgon.CurrentVideoMode.RefreshRate));
                _reslistbox.SelectItem(curr.Key, false);
            }
            else
            {
                //No match due to different refresh rate in windowed mode. Just pick first resolution based on size only.
                KeyValuePair<string, VideoMode> curr =
                    vmList.FirstOrDefault(
                        x =>
                        x.Value.Width == Gorgon.CurrentVideoMode.Width &&
                        x.Value.Height == Gorgon.CurrentVideoMode.Height);
                _reslistbox.SelectItem(curr.Key, false);
            }

            _ticketbg = ResourceManager.GetSprite("ticketoverlay");

            _mainmenubtt = new Label("Main Menu", "CALIBRI", ResourceManager);
            _mainmenubtt.DrawBorder = true;
            _mainmenubtt.Clicked += _mainmenubtt_Clicked;

            _applybtt = new Label("Apply", "CALIBRI", ResourceManager);
            _applybtt.DrawBorder = true;
            _applybtt.Clicked += _applybtt_Clicked;
        }
Exemplo n.º 8
0
 private void _reslistbox_ItemSelected(Label item, Listbox sender)
 {
     if (vmList.ContainsKey(item.Text.Text))
     {
         VideoMode sel = vmList[item.Text.Text];
         ConfigurationManager.SetResolution((uint) sel.Width, (uint) sel.Height);
         ConfigurationManager.SetDisplayRefresh((uint) sel.RefreshRate);
     }
 }
Exemplo n.º 9
0
 private GuiComponent CreateEditField(object o, FieldInfo field)
 {
     if (o is String || o is string)
     {
         var editStr = new Textbox(100, _resourceManager);
         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, _resourceManager, 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, _resourceManager);
         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(_resourceManager);
         editBool.UserData = field;
         editBool.Value = ((Boolean) o);
         editBool.ValueChanged += editBool_ValueChanged;
         return editBool;
     }
     return null;
 }
Exemplo n.º 10
0
 private void editEnum_ItemSelected(Label item, Listbox sender)
 {
     var field = (FieldInfo) sender.UserData;
     object state = Enum.Parse(field.FieldType, item.Text.Text, true);
     if (field.IsInitOnly || field.IsLiteral) return;
     field.SetValue(assigned, state);
 }