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); }
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); }
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; }
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; }
private void _chkfullscreen_ValueChanged(bool newValue, Checkbox sender) { ConfigurationManager.SetFullscreen(newValue); }
private void _chkvsync_ValueChanged(bool newValue, Checkbox sender) { ConfigurationManager.SetVsync(newValue); }
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; }
//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); }
private void editBool_ValueChanged(bool newValue, Checkbox sender) { var assigned = (MarshalComponentParameter) sender.UserData; assigned.Parameter.Parameter = newValue; _owner.GetComponent<ISVarsComponent>(ComponentFamily.SVars).DoSetSVar(assigned); }