public MyGuiControlColor AddColorSlider(string name, Vector2 position, Color startColor) { var sldr = new MyGuiControlColor(name, .8f, position, startColor, startColor, MyStringId.GetOrCompute("AAA")); Controls.Add(sldr); return(sldr); }
void OnChangeColor(MyGuiControlColor obj) { foreach (var item in TargetBlocks) { Setter(item, obj.GetColor()); } }
protected MyGuiControlColor addColor(StringBuilder text) { MyGuiControlColor colorControl = new MyGuiControlColor(this, text, m_currentPosition, new Vector2(0.3f, 0.1f), 1.0f, Color.White); Controls.Add(colorControl); return(colorControl); }
protected override MyGuiControlBase CreateGui() { m_color = new MyGuiControlColor(MyTexts.Get(Title), 0.95f, Vector2.Zero, Color.White, Color.White, placeSlidersVertically: true); m_changeColor = OnChangeColor; m_color.OnChange += m_changeColor; m_color.Size = new Vector2(PREFERRED_CONTROL_WIDTH, m_color.Size.Y); return(new MyGuiControlBlockProperty(String.Empty, String.Empty, m_color)); }
protected MyGuiControlColor AddColor(String text, Color value, Action <MyGuiControlColor> setter) { MyGuiControlColor colorControl = AddColor(text); colorControl.SetColor(value); colorControl.OnChange += delegate(MyGuiControlColor sender) { setter(colorControl); }; return(colorControl); }
private MyGuiControlColor AddColor(StringBuilder text) { MyGuiControlColor colorControl = new MyGuiControlColor( text: text, textScale: m_scale, position: m_currentPosition, color: Color.White, defaultColor: Color.White, font: MyFontEnum.Debug); colorControl.ColorMask = Color.Yellow.ToVector4(); colorControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(colorControl); m_currentPosition.Y += colorControl.Size.Y; return(colorControl); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); BackgroundColor = new Vector4(1f, 1f, 1f, 0.5f); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.13f); AddCaption("Voxel materials", Color.Yellow.ToVector4()); AddShareFocusHint(); m_materialsCombo = AddCombo(); var defList = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().OrderBy(x => x.Id.SubtypeName).ToList(); foreach (var material in defList) { m_materialsCombo.AddItem(material.Index, new StringBuilder(material.Id.SubtypeName)); } m_materialsCombo.ItemSelected += materialsCombo_OnSelect; m_currentPosition.Y += 0.01f; m_sliderInitialScale = AddSlider("Initial scale", 0, 1f, 100f, null); m_sliderScaleMultiplier = AddSlider("Scale multiplier", 0, 1f, 100f, null); m_sliderInitialDistance = AddSlider("Initial distance", 0, 1f, 100f, null); m_sliderDistanceMultiplier = AddSlider("Distance multiplier", 0, 1f, 100f, null); m_sliderFar1Distance = AddSlider("Far1 distance", 0, 0f, 20000f, null); m_sliderFar1Scale = AddSlider("Far1 scale", 0, 1f, 50000f, null); m_sliderFar2Distance = AddSlider("Far2 distance", 0, 0f, 20000f, null); m_sliderFar2Scale = AddSlider("Far2 scale", 0, 1f, 50000f, null); m_sliderFar3Distance = AddSlider("Far3 distance", 0, 0f, 40000f, null); m_sliderFar3Scale = AddSlider("Far3 scale", 0, 1f, 50000f, null); m_sliderExtScale = AddSlider("Detail scale (/1000)", 0, 0.01f, 1f, null); m_materialsCombo.SelectItemByIndex(0); m_colorFar3 = AddColor(new StringBuilder("Far3 color"), m_selectedVoxelMaterial, MemberHelper.GetMember(() => m_selectedVoxelMaterial.Far3Color)); m_colorFar3.SetColor(m_selectedVoxelMaterial.Far3Color); m_currentPosition.Y += 0.01f; AddButton(new StringBuilder("Reload definition"), OnReloadDefinition); }
protected MyGuiControlColor AddColor(StringBuilder text, object instance, MemberInfo memberInfo) { MyGuiControlColor colorControl = AddColor(text); if (memberInfo is PropertyInfo) { PropertyInfo property = (PropertyInfo)memberInfo; var val = property.GetValue(instance, new object[0]); if (val is Color) { colorControl.SetColor((Color)val); } else if (val is Vector3) { colorControl.SetColor((Vector3)val); } else if (val is Vector4) { colorControl.SetColor((Vector4)val); } colorControl.UserData = new Tuple <object, PropertyInfo>(instance, property); colorControl.OnChange += delegate(MyGuiControlColor sender) { Tuple <object, PropertyInfo> tuple = sender.UserData as Tuple <object, PropertyInfo>; if (tuple.Item2.MemberType.GetType() == typeof(Color)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor(), new object[0]); ValueChanged(sender); } else if (tuple.Item2.MemberType.GetType() == typeof(Vector3)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor().ToVector3(), new object[0]); ValueChanged(sender); } else if (tuple.Item2.MemberType.GetType() == typeof(Vector4)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor().ToVector4(), new object[0]); ValueChanged(sender); } }; } else if (memberInfo is FieldInfo) { FieldInfo field = (FieldInfo)memberInfo; var val = field.GetValue(instance); if (val is Color) { colorControl.SetColor((Color)val); } else if (val is Vector3) { colorControl.SetColor((Vector3)val); } else if (val is Vector4) { colorControl.SetColor((Vector4)val); } colorControl.UserData = new Tuple <object, FieldInfo>(instance, field); colorControl.OnChange += delegate(MyGuiControlColor sender) { Tuple <object, FieldInfo> tuple = sender.UserData as Tuple <object, FieldInfo>; if (tuple.Item2.FieldType == typeof(Color)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor()); ValueChanged(sender); } else if (tuple.Item2.FieldType == typeof(Vector3)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor().ToVector3()); ValueChanged(sender); } else if (tuple.Item2.FieldType == typeof(Vector4)) { tuple.Item2.SetValue(tuple.Item1, sender.GetColor().ToVector4()); ValueChanged(sender); } }; } else { System.Diagnostics.Debug.Assert(false, "Unknown type of memberInfo"); } return(colorControl); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; m_scale = 0.7f; AddCaption("Render Model FX", Color.Yellow.ToVector4()); AddShareFocusHint(); //if (MySession.Static.ControlledObject == null) //return; AddButton(new StringBuilder("Reload textures"), delegate { VRageRender.MyRenderProxy.ReloadTextures(); }); //Line line = new Line(MySector.MainCamera.Position, MySector.MainCamera.Position + MySector.MainCamera.ForwardVector * 10); //var res = MyEntities.GetIntersectionWithLine(ref line, null, null); //if (!res.HasValue) // return; ////MyModel model = MySession.Static.ControlledObject.ModelLod0; //m_model = res.Value.Entity.ModelLod0; m_modelsCombo = AddCombo(); var modelList = VRage.Game.Models.MyModels.GetLoadedModels(); if (modelList.Count == 0) { return; } for (int i = 0; i < modelList.Count; i++) { var model = modelList[i]; m_modelsCombo.AddItem((int)i, new StringBuilder(System.IO.Path.GetFileNameWithoutExtension(model.AssetName))); } m_modelsCombo.SelectItemByIndex(m_currentModelSelectedItem); m_modelsCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(modelsCombo_OnSelect); m_model = modelList[m_currentModelSelectedItem]; if (m_model == null) { return; } m_meshesCombo = AddCombo(); for (int i = 0; i < m_model.GetMeshList().Count; i++) { var mesh = m_model.GetMeshList()[i]; m_meshesCombo.AddItem((int)i, new StringBuilder(mesh.Material.Name)); } m_meshesCombo.SelectItemByIndex(m_currentSelectedMeshItem); m_meshesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(meshesCombo_OnSelect); if (MySector.MainCamera != null) { m_voxelsCombo = AddCombo(); m_voxelsCombo.AddItem(-1, new StringBuilder("None")); int i = 0; foreach (var voxelMaterial in MyDefinitionManager.Static.GetVoxelMaterialDefinitions()) { m_voxelsCombo.AddItem(i++, new StringBuilder(voxelMaterial.Id.SubtypeName)); } m_voxelsCombo.SelectItemByIndex(m_currentSelectedVoxelItem + 1); m_voxelsCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(voxelsCombo_OnSelect); } if (m_model.GetMeshList().Count <= m_currentSelectedMeshItem) { return; } var selectedMesh = m_model.GetMeshList()[m_currentSelectedMeshItem]; var selectedMaterial = selectedMesh.Material; m_diffuseColor = AddColor(new StringBuilder("Diffuse"), selectedMaterial, MemberHelper.GetMember(() => selectedMaterial.DiffuseColor)); m_specularIntensity = AddSlider("Specular intensity", selectedMaterial.SpecularIntensity, 0, 32, null); m_specularPower = AddSlider("Specular power", selectedMaterial.SpecularPower, 0, 128, null); }
protected MyGuiControlColor addColor(StringBuilder text) { MyGuiControlColor colorControl = new MyGuiControlColor(this, text, m_currentPosition, new Vector2(0.3f, 0.1f), 1.0f, Color.White); Controls.Add(colorControl); return colorControl; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var lbl = new MyGuiControlLabel(new Vector2(-.13f, -.32f), null, "More PP Settings - By: Math0424"); Controls.Add(lbl); MyGuiControlSeparatorList seperator = new MyGuiControlSeparatorList(); seperator.Position = new Vector2(0, 0); seperator.AddHorizontal(new Vector2(-.3f, -.14f), .6f, .002f); Elements.Add(seperator); //bloom bloomSlidr = AddSliderLabel("Bloom Scale", new Vector2(.08f, -.25f), 0, 400, PPSettings.Static.BloomScale); bloomDirt = AddSliderLabel("Bloom Dirt", new Vector2(.08f, -.18f), 0, 1, PPSettings.Static.BloomDirtRatio); bloomMulti = AddSliderLabel("Bloom Mult", new Vector2(-.17f, -.25f), 0, 1, PPSettings.Static.BloomMult); bloomSize = AddSliderLabel("Bloom Size", new Vector2(-.17f, -.18f), 0, 10, PPSettings.Static.BloomSize, true); bloom = AddCheckbox("Bloom", new Vector2(.22f, -.215f), PPSettings.Static.EnableBloom); //misc slider brightness = AddSliderLabel("Brightness", new Vector2(-.23f, .04f), 0, 10, PPSettings.Static.Brightness); saturation = AddSliderLabel("Saturation", new Vector2(-.23f, .11f), 0, 10, PPSettings.Static.Saturation); //chromatic chromatic = AddCheckbox("Chromatic Ab.", new Vector2(.24f, .09f), PPSettings.Static.EnableChromaticAberration); chromaticFactor = AddSlider(new Vector2(.1f, .09f), -1.5f, 1.5f, PPSettings.Static.ChromaticFactor); //vignette vignette = AddCheckbox("Vignette", new Vector2(.24f, -.025f), PPSettings.Static.EnableVignette); vignetteLength = AddSliderLabel("Length", new Vector2(.1f, .01f), 0, 10, PPSettings.Static.VignetteLength); vignetteStart = AddSliderLabel("Start", new Vector2(.1f, -.07f), 0, 10, PPSettings.Static.VignetteStart); //Coloring headlamp = AddColorSlider("Headlamp Color", new Vector2(-.2f, -.08f), PPSettings.Static.HeadlampColor); headlamp.Color.Alpha(255); //ambient ambient = AddCheckbox("Ambient Occlusion", new Vector2(-.31f, .17f), PPSettings.Static.EnableAmbientOcclusion); eyeadaption = AddCheckbox("Eye Adaptation", new Vector2(-.31f, .22f), PPSettings.Static.EnableEyeAdaption); //misc playerShake = AddCheckbox("Player shake", new Vector2(-.1f, .17f), PPSettings.Static.EnablePlayerShake); fullbright = AddCheckbox("Fullbright", new Vector2(-.1f, .22f), PPSettings.Static.EnableFullbright); glare = AddCheckbox("Sun glare", new Vector2(.05f, .17f), PPSettings.Static.EnableSunGlare); var button = new MyGuiControlButton() { Position = new Vector2(-0.23f, .3f), Text = "Save & Exit", }; Controls.Add(button); button.ButtonClicked += (e) => { ApplySettings(); PPSettings.Save(); CloseScreen(); }; var button3 = new MyGuiControlButton() { Position = new Vector2(0f, .3f), Text = "Save", }; Controls.Add(button3); button3.ButtonClicked += (e) => { ApplySettings(); PPSettings.Save(); }; var button2 = new MyGuiControlButton() { Position = new Vector2(0.23f, .3f), Text = "Exit", }; Controls.Add(button2); button2.ButtonClicked += (e) => { CloseScreen(); }; }