예제 #1
0
 private GuiComponent CreateEditField(MarshalComponentParameter compPar)
 {
     if (compPar.Parameter.ParameterType == typeof(float) || compPar.Parameter.ParameterType == typeof(int) ||
         compPar.Parameter.ParameterType == typeof(String))
     {
         var editTxt = new Textbox(100, _resourceManager);
         editTxt.ClearOnSubmit = false;
         editTxt.UserData      = compPar;
         editTxt.Text          = compPar.Parameter.Parameter.ToString();
         editTxt.OnSubmit     += editTxt_OnSubmit;
         return(editTxt);
     }
     else if (compPar.Parameter.ParameterType == typeof(Boolean))
     {
         var editBool = new Checkbox(_resourceManager);
         editBool.UserData      = compPar;
         editBool.Value         = ((Boolean)compPar.Parameter.Parameter);
         editBool.ValueChanged += editBool_ValueChanged;
         return(editBool);
     }
     return(null);
 }
예제 #2
0
 private GuiComponent CreateEditField(MarshalComponentParameter compPar)
 {
     if (compPar.Parameter.ParameterType == typeof (float) || compPar.Parameter.ParameterType == typeof (int) ||
         compPar.Parameter.ParameterType == typeof (String))
     {
         var editTxt = new Textbox(100, _resourceManager);
         editTxt.ClearOnSubmit = false;
         editTxt.UserData = compPar;
         editTxt.Text = compPar.Parameter.Parameter.ToString();
         editTxt.OnSubmit += editTxt_OnSubmit;
         return editTxt;
     }
     else if (compPar.Parameter.ParameterType == typeof (Boolean))
     {
         var editBool = new Checkbox(_resourceManager);
         editBool.UserData = compPar;
         editBool.Value = ((Boolean) compPar.Parameter.Parameter);
         editBool.ValueChanged += editBool_ValueChanged;
         return editBool;
     }
     return null;
 }
예제 #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);
 }
예제 #4
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;

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

            IOrderedEnumerable<VideoMode> modes = from v in SFML.Window.VideoMode.FullscreenModes where 
                                     (v.Height > 748 && v.Width > 1024) //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);
                    _lstResolution.AddItem(GetVmString(vm));
                }
            }

            if (
                 vmList.Any(
                    x=>
                    x.Value.Width == CluwneLib.Camera.ViewSize.X && x.Value.Height == CluwneLib.Camera.ViewSize.Y ))
                    
            {
                KeyValuePair<string, VideoMode> curr =
                    vmList.FirstOrDefault(
                        x =>
                        x.Value.Width == CluwneLib.Camera.ViewSize.X &&
                        x.Value.Height == CluwneLib.Camera.ViewSize.Y );
                        
                _lstResolution.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 == CluwneLib.Camera.ViewSize.X &&
                        x.Value.Height == CluwneLib.Camera.ViewSize.Y);
                _lstResolution.SelectItem(curr.Key, false);
            }

            _ticketBg = ResourceManager.GetSprite("ticketoverlay");

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

            _btnApply = new Label("Apply", "CALIBRI", ResourceManager);
            _btnApply.DrawBorder = true;
            _btnApply.Clicked += _applybtt_Clicked;


            _lstResolution.Position = new Point(45 , (int)(CluwneLib.Camera.ViewSize.Y / 2.5f));
			_lstResolution.Update(0);
			_chkFullscreen.Position = new Point(_lstResolution.Position.X,
												_lstResolution.Position.Y + _lstResolution.ClientArea.Height + 10);
			_chkFullscreen.Update(0);
			_chkVsync.Position = new Point(_chkFullscreen.Position.X,
										   _chkFullscreen.Position.Y + _chkFullscreen.ClientArea.Height + 10);
			_chkVsync.Update(0);
			_lblFullscreen.Position = new Point(_chkFullscreen.Position.X + _chkFullscreen.ClientArea.Width + 3,
												_chkFullscreen.Position.Y + (int)(_chkFullscreen.ClientArea.Height / 2f) -
												(int)(_lblFullscreen.ClientArea.Height / 2f));
			_lblFullscreen.Update(0);
			_lblVsync.Position = new Point(_chkVsync.Position.X + _chkVsync.ClientArea.Width + 3,
										   _chkVsync.Position.Y + (int)(_chkVsync.ClientArea.Height / 2f) -
										   (int)(_chkVsync.ClientArea.Height / 2f));
			_lblVsync.Update(0);
			_btnMainMenu.Position = new Point(_lstResolution.Position.X + 650, _lstResolution.Position.Y);
			_btnMainMenu.Update(0);
			_btnApply.Position = new Point(_btnMainMenu.Position.X,
										   _btnMainMenu.Position.Y + _btnMainMenu.ClientArea.Height + 5);
			_btnApply.Update(0);
        }
예제 #5
0
 private void _chkfullscreen_ValueChanged(bool newValue, Checkbox sender)
 {
     ConfigurationManager.SetFullscreen(newValue);
 }
예제 #6
0
 private void _chkvsync_ValueChanged(bool newValue, Checkbox sender)
 {
     ConfigurationManager.SetVsync(newValue);
 }
예제 #7
0
 private void editBool_ValueChanged(bool newValue, Checkbox sender)
 {
     var assigned = (MarshalComponentParameter) sender.UserData;
     assigned.Parameter.Parameter = newValue;
     _owner.GetComponent<ISVarsComponent>(ComponentFamily.SVars).DoSetSVar(assigned);
 }
예제 #8
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;
 }
예제 #9
0
        //Setting these does not work when inside a key value pair of a list item. fix.

        private void editBool_ValueChanged(bool newValue, Checkbox sender)
        {
            var field = (FieldInfo) sender.UserData;
            if (field.IsInitOnly || field.IsLiteral) return;
            field.SetValue(assigned, newValue);
        }