Ejemplo n.º 1
0
        void UpdateValues()
        {
            if (!m_canUpdateValues)
            {
                return;
            }

            m_canUpdateValues = false;

            m_nameTextBox.Text = DummyPoint.Name ?? String.Empty;

            if (DummyPoint.Type == MyDummyPointType.Box)
            {
                m_heightSize.Visible = true;
                m_depthSize.Visible  = true;

                m_widthSize.SetValue(DummyPoint.Size.X);
                m_heightSize.SetValue(DummyPoint.Size.Y);
                m_depthSize.SetValue(DummyPoint.Size.Z);

                m_widthSize.UpdateDescription("Width");
            }
            else
            {
                m_heightSize.Visible = false;
                m_depthSize.Visible  = false;

                m_widthSize.UpdateDescription("Diameter");

                m_widthSize.SetValue(DummyPoint.Radius * 2);
            }

            if (DummyPoint.Type == MyDummyPointType.Box)
            {
                m_typeComboBox.SelectItemByIndex(0);
            }
            else
            {
                m_typeComboBox.SelectItemByIndex(1);
            }

            m_colorArea.Checked                = (DummyPoint.DummyFlags & MyDummyPointFlags.COLOR_AREA) > 0;
            m_playerStart.Checked              = (DummyPoint.DummyFlags & MyDummyPointFlags.PLAYER_START) > 0;
            m_mothershipStart.Checked          = (DummyPoint.DummyFlags & MyDummyPointFlags.MOTHERSHIP_START) > 0;
            m_detector.Checked                 = (DummyPoint.DummyFlags & MyDummyPointFlags.DETECTOR) > 0;
            m_sideMission.Checked              = (DummyPoint.DummyFlags & MyDummyPointFlags.SIDE_MISSION) > 0;
            m_safeArea.Checked                 = (DummyPoint.DummyFlags & MyDummyPointFlags.SAFE_AREA) > 0;
            m_particleEffect.Checked           = (DummyPoint.DummyFlags & MyDummyPointFlags.PARTICLE) > 0;
            m_survivePrefabDestruction.Checked = (DummyPoint.DummyFlags & MyDummyPointFlags.SURIVE_PREFAB_DESTRUCTION) > 0;
            m_respawnPoint.Checked             = (DummyPoint.DummyFlags & MyDummyPointFlags.RESPAWN_POINT) > 0;
            m_enabled.Checked     = (DummyPoint.PersistentFlags & CommonLIB.AppCode.ObjectBuilders.MyPersistentEntityFlags.Enabled) > 0;
            m_textureQuad.Checked = (DummyPoint.DummyFlags & MyDummyPointFlags.TEXTURE_QUAD) > 0;
            m_note.Checked        = (DummyPoint.DummyFlags & MyDummyPointFlags.NOTE) > 0;

            m_redSlider.Visible             = m_colorArea.Checked || m_particleEffect.Checked;
            m_redSliderLabel.Visible        = m_colorArea.Checked || m_particleEffect.Checked;
            m_greenSlider.Visible           = m_colorArea.Checked || m_particleEffect.Checked;
            m_greenSliderLabel.Visible      = m_colorArea.Checked || m_particleEffect.Checked;
            m_blueSlider.Visible            = m_colorArea.Checked || m_particleEffect.Checked;
            m_blueSliderLabel.Visible       = m_colorArea.Checked || m_particleEffect.Checked;
            m_alphaSlider.Visible           = m_colorArea.Checked || m_particleEffect.Checked;
            m_alphaSliderLabel.Visible      = m_colorArea.Checked || m_particleEffect.Checked;
            m_alphaSliderValueLabel.Visible = m_colorArea.Checked || m_particleEffect.Checked;
            m_userScaleSliderLabel.Visible  = m_particleEffect.Checked;
            m_userScaleSlider.Visible       = m_particleEffect.Checked;
            m_userScaleLabel.Visible        = m_particleEffect.Checked;

            m_redSlider.SetValue(DummyPoint.Color.X * MyEditorConstants.COLOR_COMPONENT_MAX_VALUE);
            m_greenSlider.SetValue(DummyPoint.Color.Y * MyEditorConstants.COLOR_COMPONENT_MAX_VALUE);
            m_blueSlider.SetValue(DummyPoint.Color.Z * MyEditorConstants.COLOR_COMPONENT_MAX_VALUE);
            m_alphaSlider.SetValue(DummyPoint.Color.W * MyEditorConstants.COLOR_COMPONENT_MAX_VALUE);
            m_alphaSliderValueLabel.UpdateText(new Color(DummyPoint.Color).ToVector4().W.ToString("#,###0.000", System.Globalization.CultureInfo.InvariantCulture));
            m_userScaleSlider.SetValue(DummyPoint.UserScale);
            m_userScaleLabel.UpdateText(DummyPoint.UserScale.ToString("#,###0.000", System.Globalization.CultureInfo.InvariantCulture));

            //m_particleCombo.Visible = m_particleEffect.Checked;
            // m_particleNameLabel.Visible = m_particleEffect.Checked;
            m_particleCombo.SelectItemByKey((int)DummyPoint.ParticleID);
            m_respawnPointCombo.SelectItemByKey((int)DummyPoint.RespawnPointFaction);//hopefuly china

            if (DummyPoint.DummyFlags == MyDummyPointFlags.DETECTOR)
            {
                m_secretCombo.Visible = true;
                m_secretCombo.SelectItemByKey((int)DummyPoint.Argument);
            }
            else
            {
                m_secretCombo.Visible = false;
            }

            m_canUpdateValues = true;
        }
Ejemplo n.º 2
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_scale = 0.7f;

            AddCaption("Render Character", Color.Yellow.ToVector4());
            AddShareFocusHint();

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f);


            m_currentPosition.Y += 0.01f;


            if (MySession.Static.ControlledEntity == null || !(MySession.Static.ControlledEntity is MyCharacter))
            {
                AddLabel("None active character", Color.Yellow.ToVector4(), 1.2f);
                return;
            }

            MyCharacter playerCharacter = MySession.Static.LocalCharacter;

            if (!constructor)
            {
                playerCharacter.DebugMode = true;
            }

            AddSlider("Max slope", playerCharacter.Definition.MaxSlope, 0f, 89f, (slider) => { playerCharacter.Definition.MaxSlope = slider.Value; });

            AddLabel(playerCharacter.Model.AssetName, Color.Yellow.ToVector4(), 1.2f);

            AddLabel("Animation A:", Color.Yellow.ToVector4(), 1.2f);

            m_animationComboA = AddCombo();
            int i = 0;

            foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName)
            {
                m_animationComboA.AddItem(i++, new StringBuilder(animation.Key));
            }
            m_animationComboA.SelectItemByIndex(0);

            AddLabel("Animation B:", Color.Yellow.ToVector4(), 1.2f);

            m_animationComboB = AddCombo();
            i = 0;
            foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName)
            {
                m_animationComboB.AddItem(i++, new StringBuilder(animation.Key));
            }
            m_animationComboB.SelectItemByIndex(0);

            m_blendSlider = AddSlider("Blend time", 0.5f, 0, 3, null);

            AddButton(new StringBuilder("Play A->B"), OnPlayBlendButtonClick);

            m_currentPosition.Y += 0.01f;


            m_animationCombo = AddCombo();
            i = 0;
            foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName)
            {
                m_animationCombo.AddItem(i++, new StringBuilder(animation.Key));
            }
            m_animationCombo.SortItemsByValueText();
            m_animationCombo.SelectItemByIndex(0);

            m_loopCheckbox = AddCheckBox("Loop", false, null);

            m_currentPosition.Y += 0.02f;

            foreach (var name in playerCharacter.Definition.BoneSets.Keys)
            {
                var checkBox = AddCheckBox(name, false, null);
                checkBox.UserData = name;
                if (name == "Body")
                {
                    checkBox.IsChecked = true;
                }
            }

            AddButton(new StringBuilder("Play animation"), OnPlayButtonClick);

            AddCheckBox("Draw damage and hit hapsules", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_SHOW_DAMAGE));

            m_currentPosition.Y += 0.01f;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds the plugin settings controls from top to bottom.
        /// </summary>
        public void BuildControls()
        {
            Vector2 vector = new Vector2(50f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            float   x2     = 0.209375018f;
            int     mod    = m_isNewGame ? 6 : 0;

            AddCaption("SEWorldGenPlugin Settings", null, new Vector2(0f, 0.003f));

            MyGuiControlParent parent = new MyGuiControlParent(null, new Vector2(base.Size.Value.X - vector.X * 2f, 0.052f * (15 + mod)));

            parent.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            MyGuiControlSeparatorList myGuiControlSeparatorList = new MyGuiControlSeparatorList();

            myGuiControlSeparatorList.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.835f / 2f, m_size.Value.Y / 2f - 0.075f), m_size.Value.X * 0.835f);
            Controls.Add(myGuiControlSeparatorList);
            MyGuiControlSeparatorList myGuiControlSeparatorList2 = new MyGuiControlSeparatorList();

            myGuiControlSeparatorList2.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.835f / 2f, (0f - m_size.Value.Y) / 2f + 0.123f), m_size.Value.X * 0.835f);
            Controls.Add(myGuiControlSeparatorList2);

            m_useGlobalSettignsLabel       = MakeLabel("Use global Config");
            m_useSemiRandomGenerationLabel = MakeLabel("Use all planets");
            m_useVanillaPlanetsLabel       = MakeLabel("Use vanilla planets");
            m_planetsOnlyOnceLabel         = MakeLabel("Generate Planets Once");
            m_moonsOnlyOnceLabel           = MakeLabel("Generate Moons Once");
            m_planetGpsLabel         = MakeLabel("Create GPS for Planets");
            m_moonGpsLabel           = MakeLabel("Create GPS for Moons");
            m_beltGpsLabel           = MakeLabel("Create GPS for Belts");
            m_ringGpsLabel           = MakeLabel("Create GPS for Rings");
            m_asteroidGeneratorLabel = MakeLabel("Asteroid generator");
            m_asteroidDensityLabel   = MakeLabel("Asteroid density");
            m_objAmountLabel         = MakeLabel("Objects in System");
            m_orbDistanceLabel       = MakeLabel("Average Orbit distance");
            m_sizeMultiplierLabel    = MakeLabel("Planet size multiplier");
            m_sizeCapLabel           = MakeLabel("Planet size cap");
            m_moonProbLabel          = MakeLabel("Moon spawn probability");
            m_ringWidthLabel         = MakeLabel("Average ring width");
            m_ringProbLabel          = MakeLabel("Ring spawn probability");
            m_beltHeightLabel        = MakeLabel("Average belt height");
            m_beltProbLabel          = MakeLabel("Belt spawn probability");
            m_worldSizeLabel         = MakeLabel("World Size");

            m_useGlobalCheck = new MyGuiControlCheckbox();
            m_useSemiRandomGenerationCheck = new MyGuiControlCheckbox();
            m_useVanillaPlanetsCheck       = new MyGuiControlCheckbox();
            m_planetsOnlyOnceCheck         = new MyGuiControlCheckbox();
            m_moonsOnlyOnceCheck           = new MyGuiControlCheckbox();
            m_planetGpsCheck         = new MyGuiControlCheckbox();
            m_moonGpsCheck           = new MyGuiControlCheckbox();
            m_beltGpsCheck           = new MyGuiControlCheckbox();
            m_ringGpsCheck           = new MyGuiControlCheckbox();
            m_asteroidGeneratorCombo = new MyGuiControlCombobox(null, new Vector2(x2, 0.04f));
            x2 += 0.05f;
            m_asteroidDensitySlider = new MyGuiControlClickableSlider(Vector2.Zero, 0.1f, 1f, x2, 0.6f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ROID_DENS_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false);
            m_objAmountSlider       = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 100f, x2, 15f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SYS_OBJ_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_orbDistanceSlider     = new MyGuiControlClickableSlider(Vector2.Zero, 500f, 100000f, x2, 50500f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ORB_DIST_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_sizeMultiplierSlider  = new MyGuiControlClickableSlider(Vector2.Zero, 1f, 10f, x2, 2f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_MUL_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_sizeCapSlider         = new MyGuiControlClickableSlider(Vector2.Zero, 120f, 2400f, x2, 1200f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_CAP_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_moonProbSlider        = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.MOON_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false);
            m_ringWidthSlider       = new MyGuiControlClickableSlider(Vector2.Zero, 10000f, 100000f, x2, 15000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_WIDTH_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_ringProbSlider        = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false);
            m_beltHeightSlider      = new MyGuiControlClickableSlider(Vector2.Zero, 4000f, 40000f, x2, 22000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_HEIGHT_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);
            m_beltProbSlider        = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.4f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false);
            m_worldSizeSlider       = new MyGuiControlClickableSlider(Vector2.Zero, -1f, 1000000 - 1, x2, -1, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.WORLD_SIZE_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true);

            m_asteroidDensityValue             = MakeLabel(String.Format("{0:0.00}", m_asteroidDensitySlider.Value));
            m_asteroidDensityValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_objAmountValue                  = MakeLabel(m_objAmountSlider.Value.ToString());
            m_objAmountValue.OriginAlign      = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_orbDistanceValue                = MakeLabel(m_orbDistanceSlider.Value.ToString());
            m_orbDistanceValue.OriginAlign    = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_sizeMultiplierValue             = MakeLabel(m_sizeMultiplierSlider.Value.ToString());
            m_sizeMultiplierValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_sizeCapValue                = MakeLabel(m_sizeCapSlider.Value.ToString());
            m_sizeCapValue.OriginAlign    = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_moonProbValue               = MakeLabel(String.Format("{0:0.00}", m_moonProbSlider.Value));
            m_moonProbValue.OriginAlign   = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_ringWidthValue              = MakeLabel(m_ringWidthSlider.Value.ToString());
            m_ringWidthValue.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_ringProbValue               = MakeLabel(m_ringProbSlider.Value.ToString());
            m_ringProbValue.OriginAlign   = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_beltHeightValue             = MakeLabel(m_beltHeightSlider.Value.ToString());
            m_beltHeightValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_beltProbValue               = MakeLabel(String.Format("{0:0.00}", m_beltProbSlider.Value));
            m_beltProbValue.OriginAlign   = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_useGlobalCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_GLOBAL_CHECK);
            m_useGlobalCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_useSemiRandomGenerationCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_SEMI_RAND_GEN_CHECK);
            m_useSemiRandomGenerationCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_useVanillaPlanetsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_VANILLA_PLANETS);
            m_useVanillaPlanetsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_planetsOnlyOnceCheck.SetToolTip(MyPluginTexts.TOOLTIPS.PLANETS_ONLY_ONCE);
            m_planetsOnlyOnceCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_moonsOnlyOnceCheck.SetToolTip(MyPluginTexts.TOOLTIPS.MOONS_ONLY_ONCE);
            m_moonsOnlyOnceCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_planetGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_GPSL_CHECK);
            m_planetGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_moonGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.MOON_GPS_CHECK);
            m_moonGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_beltGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.BELT_GPS_CHECK);
            m_beltGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_ringGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.RING_GPS_CHECK);
            m_ringGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_asteroidGeneratorCombo.SetToolTip(MyPluginTexts.TOOLTIPS.ROID_GEN_COMBO);
            m_asteroidGeneratorCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            m_worldSizeValue             = MakeLabel(m_worldSizeSlider.Value.ToString());
            m_worldSizeValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_asteroidGeneratorCombo.AddItem(0L, "Plugin");
            m_asteroidGeneratorCombo.AddItem(1L, "Vanilla");
            m_asteroidGeneratorCombo.AddItem(2L, "Mixed");
            m_asteroidGeneratorCombo.SelectItemByIndex(0);

            m_asteroidGeneratorCombo.ItemSelected += delegate
            {
                bool val = m_asteroidGeneratorCombo.GetSelectedKey() == 01L;

                m_beltGpsCheck.Enabled          = !val;
                m_ringProbSlider.Enabled        = !val;
                m_ringWidthSlider.Enabled       = !val;
                m_beltHeightSlider.Enabled      = !val;
                m_beltProbSlider.Enabled        = !val;
                m_asteroidDensitySlider.Enabled = !val;
            };

            m_asteroidDensitySlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_asteroidDensitySlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_asteroidDensityValue.Text = String.Format("{0:0.00}", s.Value);
            });
            m_objAmountSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_objAmountSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_objAmountValue.Text = s.Value.ToString();
            });
            m_orbDistanceSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_orbDistanceSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_orbDistanceValue.Text = s.Value.ToString();
            });
            m_sizeMultiplierSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_sizeMultiplierSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_sizeMultiplierValue.Text = s.Value.ToString();
            });
            m_sizeCapSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_sizeCapSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_sizeCapValue.Text = s.Value.ToString();
            });
            m_moonProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_moonProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_moonProbValue.Text = String.Format("{0:0.00}", s.Value);
            });
            m_ringWidthSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringWidthSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_ringWidthValue.Text = s.Value.ToString();
            });
            m_ringProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_ringProbValue.Text = String.Format("{0:0.00}", s.Value);
            });
            m_beltHeightSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_beltHeightSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_beltHeightValue.Text = s.Value.ToString();
            });
            m_beltProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_beltProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                m_beltProbValue.Text = String.Format("{0:0.000}", s.Value);
            });
            m_worldSizeSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_worldSizeSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s)
            {
                if (s.Value < 0)
                {
                    m_worldSizeValue.Text = "Infinite";
                }
                else
                {
                    m_worldSizeValue.Text = s.Value.ToString();
                }
            });
            m_useGlobalCheck.IsCheckedChanged = (Action <MyGuiControlCheckbox>) Delegate.Combine(m_useGlobalCheck.IsCheckedChanged, (Action <MyGuiControlCheckbox>) delegate(MyGuiControlCheckbox s)
            {
                m_useSemiRandomGenerationCheck.Enabled = !s.IsChecked;
                m_useVanillaPlanetsCheck.Enabled       = !s.IsChecked;
                m_planetsOnlyOnceCheck.Enabled         = !s.IsChecked;
                m_moonsOnlyOnceCheck.Enabled           = !s.IsChecked;
                m_objAmountSlider.Enabled        = !s.IsChecked;
                m_asteroidDensitySlider.Enabled  = !s.IsChecked;
                m_asteroidGeneratorCombo.Enabled = !s.IsChecked;
                m_orbDistanceSlider.Enabled      = !s.IsChecked;
                m_sizeMultiplierSlider.Enabled   = !s.IsChecked;
                m_sizeCapSlider.Enabled          = !s.IsChecked;
                m_moonProbSlider.Enabled         = !s.IsChecked;
                m_ringWidthSlider.Enabled        = !s.IsChecked;
                m_ringProbSlider.Enabled         = !s.IsChecked;
                m_beltHeightSlider.Enabled       = !s.IsChecked;
                m_beltProbSlider.Enabled         = !s.IsChecked;
                m_planetGpsCheck.Enabled         = !s.IsChecked;
                m_moonGpsCheck.Enabled           = !s.IsChecked;
                m_beltGpsCheck.Enabled           = !s.IsChecked;
                m_ringGpsCheck.Enabled           = !s.IsChecked;
                m_worldSizeSlider.Enabled        = !s.IsChecked && m_isNewGame;
            });

            parent.Controls.Add(m_useGlobalSettignsLabel);
            parent.Controls.Add(m_useGlobalCheck);

            if (m_isNewGame)
            {
                parent.Controls.Add(m_useSemiRandomGenerationLabel);
                parent.Controls.Add(m_useSemiRandomGenerationCheck);

                parent.Controls.Add(m_useVanillaPlanetsLabel);
                parent.Controls.Add(m_useVanillaPlanetsCheck);

                parent.Controls.Add(m_planetsOnlyOnceLabel);
                parent.Controls.Add(m_planetsOnlyOnceCheck);

                parent.Controls.Add(m_moonsOnlyOnceLabel);
                parent.Controls.Add(m_moonsOnlyOnceCheck);

                parent.Controls.Add(m_planetGpsLabel);
                parent.Controls.Add(m_planetGpsCheck);

                parent.Controls.Add(m_moonGpsLabel);
                parent.Controls.Add(m_moonGpsCheck);
            }

            parent.Controls.Add(m_beltGpsLabel);
            parent.Controls.Add(m_beltGpsCheck);

            parent.Controls.Add(m_ringGpsLabel);
            parent.Controls.Add(m_ringGpsCheck);

            parent.Controls.Add(m_asteroidGeneratorLabel);
            parent.Controls.Add(m_asteroidGeneratorCombo);

            parent.Controls.Add(m_asteroidDensityLabel);
            parent.Controls.Add(m_asteroidDensitySlider);
            parent.Controls.Add(m_asteroidDensityValue);

            parent.Controls.Add(m_objAmountLabel);
            parent.Controls.Add(m_objAmountSlider);
            parent.Controls.Add(m_objAmountValue);

            parent.Controls.Add(m_orbDistanceLabel);
            parent.Controls.Add(m_orbDistanceSlider);
            parent.Controls.Add(m_orbDistanceValue);

            parent.Controls.Add(m_sizeMultiplierLabel);
            parent.Controls.Add(m_sizeMultiplierSlider);
            parent.Controls.Add(m_sizeMultiplierValue);

            parent.Controls.Add(m_sizeCapLabel);
            parent.Controls.Add(m_sizeCapSlider);
            parent.Controls.Add(m_sizeCapValue);

            parent.Controls.Add(m_moonProbLabel);
            parent.Controls.Add(m_moonProbSlider);
            parent.Controls.Add(m_moonProbValue);

            parent.Controls.Add(m_ringWidthLabel);
            parent.Controls.Add(m_ringWidthSlider);
            parent.Controls.Add(m_ringWidthValue);

            parent.Controls.Add(m_ringProbLabel);
            parent.Controls.Add(m_ringProbSlider);
            parent.Controls.Add(m_ringProbValue);

            parent.Controls.Add(m_beltHeightLabel);
            parent.Controls.Add(m_beltHeightSlider);
            parent.Controls.Add(m_beltHeightValue);

            parent.Controls.Add(m_beltProbLabel);
            parent.Controls.Add(m_beltProbSlider);
            parent.Controls.Add(m_beltProbValue);

            parent.Controls.Add(m_worldSizeLabel);
            parent.Controls.Add(m_worldSizeSlider);
            parent.Controls.Add(m_worldSizeValue);

            //Vector2 start = (new Vector2(0f, (!m_isNewGame) ? 0.052f : 0.026f) - new Vector2(m_size.Value.X * 0.835f / 2f, m_size.Value.Y / 2f - 0.075f)) + (new Vector2(0f, m_useGlobalSettignsLabel.Size.Y));
            Vector2 start   = Vector2.Zero - new Vector2(parent.Size.X / 2f, parent.Size.Y / 2f - 0.028f);
            Vector2 offset  = new Vector2(0f, 0.050f);//0.028f
            Vector2 offset2 = new Vector2(m_orbDistanceLabel.Size.X * 1.5f, 0f);
            Vector2 offset3 = new Vector2(0.4973214f, 0f);
            int     m       = 0;

            m_useGlobalSettignsLabel.Position = start + offset * m++;
            m_useGlobalCheck.Position         = m_useGlobalSettignsLabel.Position + offset2;

            if (m_isNewGame)
            {
                m_useSemiRandomGenerationLabel.Position = start + offset * m++;
                m_useSemiRandomGenerationCheck.Position = m_useSemiRandomGenerationLabel.Position + offset2;

                m_useVanillaPlanetsLabel.Position = start + offset * m++;
                m_useVanillaPlanetsCheck.Position = m_useVanillaPlanetsLabel.Position + offset2;

                m_planetsOnlyOnceLabel.Position = start + offset * m++;
                m_planetsOnlyOnceCheck.Position = m_planetsOnlyOnceLabel.Position + offset2;

                m_moonsOnlyOnceLabel.Position = start + offset * m++;
                m_moonsOnlyOnceCheck.Position = m_moonsOnlyOnceLabel.Position + offset2;

                m_planetGpsLabel.Position = start + offset * m++;
                m_planetGpsCheck.Position = m_planetGpsLabel.Position + offset2;

                m_moonGpsLabel.Position = start + offset * m++;
                m_moonGpsCheck.Position = m_moonGpsLabel.Position + offset2;
            }

            m_beltGpsLabel.Position = start + offset * m++;
            m_beltGpsCheck.Position = m_beltGpsLabel.Position + offset2;

            m_ringGpsLabel.Position = start + offset * m++;
            m_ringGpsCheck.Position = m_ringGpsLabel.Position + offset2;

            m_asteroidGeneratorLabel.Position = start + offset * m++;
            m_asteroidGeneratorCombo.Position = m_asteroidGeneratorLabel.Position + offset2;

            m_asteroidDensityLabel.Position  = start + offset * m++;
            m_asteroidDensitySlider.Position = m_asteroidDensityLabel.Position + offset2;
            m_asteroidDensityValue.Position  = m_asteroidDensityLabel.Position + offset3;

            m_objAmountLabel.Position  = start + offset * m++;
            m_objAmountSlider.Position = m_objAmountLabel.Position + offset2;
            m_objAmountValue.Position  = m_objAmountLabel.Position + offset3;

            m_orbDistanceLabel.Position  = start + offset * m++;
            m_orbDistanceSlider.Position = m_orbDistanceLabel.Position + offset2;
            m_orbDistanceValue.Position  = m_orbDistanceLabel.Position + offset3;

            m_sizeMultiplierLabel.Position  = start + offset * m++;
            m_sizeMultiplierSlider.Position = m_sizeMultiplierLabel.Position + offset2;
            m_sizeMultiplierValue.Position  = m_sizeMultiplierLabel.Position + offset3;

            m_sizeCapLabel.Position  = start + offset * m++;
            m_sizeCapSlider.Position = m_sizeCapLabel.Position + offset2;
            m_sizeCapValue.Position  = m_sizeCapLabel.Position + offset3;

            m_moonProbLabel.Position  = start + offset * m++;
            m_moonProbSlider.Position = m_moonProbLabel.Position + offset2;
            m_moonProbValue.Position  = m_moonProbLabel.Position + offset3;

            m_ringWidthLabel.Position  = start + offset * m++;
            m_ringWidthSlider.Position = m_ringWidthLabel.Position + offset2;
            m_ringWidthValue.Position  = m_ringWidthLabel.Position + offset3;

            m_ringProbLabel.Position  = start + offset * m++;
            m_ringProbSlider.Position = m_ringProbLabel.Position + offset2;
            m_ringProbValue.Position  = m_ringProbLabel.Position + offset3;

            m_beltHeightLabel.Position  = start + offset * m++;
            m_beltHeightSlider.Position = m_beltHeightLabel.Position + offset2;
            m_beltHeightValue.Position  = m_beltHeightLabel.Position + offset3;

            m_beltProbLabel.Position  = start + offset * m++;
            m_beltProbSlider.Position = m_beltProbLabel.Position + offset2;
            m_beltProbValue.Position  = m_beltProbLabel.Position + offset3;

            m_worldSizeLabel.Position  = start + offset * m++;
            m_worldSizeSlider.Position = m_worldSizeLabel.Position + offset2;
            m_worldSizeValue.Position  = m_worldSizeLabel.Position + offset3;

            m_okButton = new MyGuiControlButton(null, VRage.Game.MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, VRage.MyTexts.Get(MyCommonTexts.Ok), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, OkButtonClicked);
            m_okButton.SetToolTip(VRage.MyTexts.GetString(MySpaceTexts.ToolTipOptionsSpace_Ok));
            m_okButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_okButton.Position    = (m_size.Value / 2f - vector) * new Vector2(0f, 1f) + new Vector2(0f - 25f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE;

            MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(parent);

            scrollPane.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            scrollPane.ScrollbarVEnabled = true;
            scrollPane.Size     = new Vector2(base.Size.Value.X - vector.X * 2f - 0.035f, 0.74f);
            scrollPane.Position = new Vector2(-0.27f, -0.394f);

            if (!m_isNewGame)
            {
                m_worldSizeSlider.Enabled = false;
            }

            Controls.Add(m_okButton);
            Controls.Add(scrollPane);
        }
Ejemplo n.º 4
0
        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.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.ControlledObject.ModelLod0;
            //m_model = res.Value.Entity.ModelLod0;

            m_modelsCombo = AddCombo();
            var modelList = 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);
        }
Ejemplo n.º 5
0
        public void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid)
        {
            if (grid == null)
            {
                ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent);
                return;
            }

            grid.RaiseGridChanged();
            m_assemblerKeyCounter = 0;
            m_assemblersByKey.Clear();
            foreach (var block in grid.GridSystems.TerminalSystem.Blocks)
            {
                var assembler = block as MyAssembler;
                if (assembler == null)
                {
                    continue;
                }
                if (!assembler.HasLocalPlayerAccess())
                {
                    continue;
                }

                m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler);
            }

            m_controlsParent = controlsParent;
            m_terminalSystem = grid.GridSystems.TerminalSystem;

            m_blueprintsArea       = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea");
            m_queueArea            = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea");
            m_inventoryArea        = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea");
            m_blueprintsBgPanel    = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel");
            m_blueprintsLabel      = controlsParent.Controls.GetControlByName("BlueprintsLabel");
            m_comboboxAssemblers   = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox");
            m_blueprintsGrid       = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl;
            m_queueGrid            = (MyGuiControlGrid)m_queueArea.ScrolledControl;
            m_inventoryGrid        = (MyGuiControlGrid)m_inventoryArea.ScrolledControl;
            m_materialsList        = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList");
            m_repeatCheckbox       = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox");
            m_slaveCheckbox        = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox");
            m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton");
            m_controlPanelButton   = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton");
            m_inventoryButton      = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton");

            {
                var assemblingButton    = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton");
                var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton");
                assemblingButton.Key    = (int)AssemblerMode.Assembling;
                disassemblingButton.Key = (int)AssemblerMode.Disassembling;
                m_modeButtonGroup.Add(assemblingButton);
                m_modeButtonGroup.Add(disassemblingButton);
            }

            foreach (var entry in m_assemblersByKey)
            {
                if (entry.Value.IsFunctional == false)
                {
                    m_incompleteAssemblerName.Clear();
                    m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName);
                    m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete));
                    m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName);
                }
                else
                {
                    m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName);
                }
            }
            m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected;

            m_comboboxAssemblers.SelectItemByIndex(0);

            m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR,
                                                            MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR,
                                                            0.7f,
                                                            MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true);
            controlsParent.Controls.Add(m_dragAndDrop);
            m_dragAndDrop.DrawBackgroundTexture = false;
            m_dragAndDrop.ItemDropped          += dragDrop_OnItemDropped;

            RefreshBlueprints();
            Assemblers_ItemSelected();

            RegisterEvents();

            if (m_assemblersByKey.Count == 0)
            {
                ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent);
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            AddCaption("Cube blocks", Color.Yellow.ToVector4());
            m_combo          = AddCombo();
            m_combo.Position = new Vector2(-0.15f, -0.35f);
            Dictionary <long, int>           dict  = new Dictionary <long, int>();
            Dictionary <long, StringBuilder> names = new Dictionary <long, StringBuilder>();

            foreach (var entity in MyEntities.GetEntities())
            {
                if (entity is MyCubeGrid)
                {
                    var grid = entity as MyCubeGrid;
                    foreach (var block in grid.GetBlocks())
                    {
                        long defId = block.BlockDefinition.Id.GetHashCode();
                        if (!dict.ContainsKey(defId))
                        {
                            dict.Add(defId, 0);
                        }

                        dict[defId]++;

                        string cubesize = "";
                        switch (block.BlockDefinition.CubeSize)
                        {
                        case MyCubeSize.Large: cubesize = "Large"; break;

                        case MyCubeSize.Small: cubesize = "Small"; break;
                        }

                        StringBuilder blockName = new StringBuilder().Append("[").Append(cubesize).Append("] ").Append(block.BlockDefinition.DisplayNameText);

                        if (!names.ContainsKey(defId))
                        {
                            names.Add(defId, blockName);
                        }
                    }
                }
            }

            int           qt;
            StringBuilder name;

            foreach (var key in names.Keys) //could be dict.Keys too
            {
                if (names.TryGetValue(key, out name) && dict.TryGetValue(key, out qt))
                {
                    m_combo.AddItem(key, name.Append(": ").Append(qt));
                }
            }

            m_combo.SortItemsByValueText();
            if (m_combo.GetItemsCount() > 0)
            {
                m_combo.SelectItemByIndex(0);
            }
            m_button             = AddButton(new StringBuilder("Remove All"), onClick_RemoveAllBlocks);
            m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default;
            m_button.Position    = new Vector2(0.0f, -0.25f);

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.35f);

            AddCheckBox("Enable use object highlight", null, MemberHelper.GetMember(() => MyFakes.ENABLE_USE_OBJECT_HIGHLIGHT));
            AddCheckBox("Show grids decay", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_GRIDS_DECAY));
            m_dummyDrawDistanceSlider = AddSlider("Dummies draw distance", MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES_DISTANCE, 0, 100, null);
            m_dummyDrawDistanceSlider.ValueChanged = DummyDrawDistanceSliderChanged;

            m_currentPosition += new Vector2(0.00f, 0.21f);

            AddCheckBox("Debug draw all mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL, onClick_DebugDrawMountPointsAll);
            AddCheckBox("Debug draw mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS, onClick_DebugDrawMountPoints);
            AddCheckBox("Forward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS0));
            AddCheckBox("Backward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS1));
            AddCheckBox("Left", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS2));
            AddCheckBox("Right", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS3));
            AddCheckBox("Up", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS4));
            AddCheckBox("Down", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS5));
            AddCheckBox("Draw autogenerated", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AUTOGENERATE));
            AddCheckBox("CubeBlock Integrity", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_BLOCK_INTEGRITY));

            m_button             = AddButton(new StringBuilder("Resave mountpoints"), onClick_Save);
            m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default;
        }
 private void SetDefaultValues()
 {
     m_difficultyCombo.SelectItemByIndex(1);
     m_onlineMode.SelectItemByIndex(0);
     FillRight();
 }
Ejemplo n.º 8
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_usableWidth = Size.Value.X * 0.75f;

            if (!m_pluginInstalled)
            {
                CheckPluginInstalledOnServer();
                return;
            }

            if (m_isRecreating)
            {
                return;
            }
            m_isRecreating = true;

            var comboBoxTop = GetCombo();
            int oldCount    = comboBoxTop.GetItemsCount();

            if (MySession.Static.IsUserSpaceMaster(Sync.MyId) && MySession.Static.IsUserAdmin(Sync.MyId))
            {
                comboBoxTop.AddItem(oldCount, "SEWorldGenPlugin - Spawning");
                comboBoxTop.AddItem(oldCount + 1, "SEWorldGenPlugin - Editing");
            }

            MyGuiControlCombobox newCombo = AddCombo();

            for (int i = 0; i < comboBoxTop.GetItemsCount(); i++)
            {
                newCombo.AddItem(comboBoxTop.GetItemByIndex(i).Key, comboBoxTop.GetItemByIndex(i).Value);
            }

            newCombo.Position    = comboBoxTop.Position;
            newCombo.Size        = comboBoxTop.Size;
            newCombo.OriginAlign = comboBoxTop.OriginAlign;
            newCombo.SelectItemByIndex(m_selectedMenuIndex);

            Controls[Controls.IndexOf(comboBoxTop)] = newCombo;
            Controls.Remove(comboBoxTop);

            newCombo.ItemSelected += delegate
            {
                if (newCombo.GetSelectedIndex() != m_selectedMenuIndex)
                {
                    ForceFetchStarSystem = true;
                }

                m_selectedMenuIndex = newCombo.GetSelectedIndex();

                foreach (var provider in m_asteroidProviders)
                {
                    provider.GetAdminMenuCreator().Close();
                }

                if (newCombo.GetSelectedIndex() >= oldCount)
                {
                    RecreateControls(false);
                }
                else
                {
                    comboBoxTop.SelectItemByIndex(m_selectedMenuIndex);
                    RecreateControls(false);
                }
            };

            if (m_selectedMenuIndex == oldCount)
            {
                ClearControls();
                BuildSpawnMenu();
            }
            if (m_selectedMenuIndex == oldCount + 1)
            {
                ClearControls();
                BuildEditMenu();
            }
            m_isRecreating = false;
        }
Ejemplo n.º 9
0
        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("Audio FX", Color.Yellow.ToVector4());
            AddShareFocusHint();

            if (MyAudio.Static is MyNullAudio)
            {
                return;
            }

            m_categoriesCombo = AddCombo();
            List <MyStringId> categories = MyAudio.Static.GetCategories();

            m_categoriesCombo.AddItem(0, new StringBuilder(ALL_CATEGORIES));
            int catCount = 1;

            foreach (var category in categories)
            {
                m_categoriesCombo.AddItem(catCount++, new StringBuilder(category.ToString()));//jn:TODO get rid of ToString
            }

            m_categoriesCombo.SortItemsByValueText();
            m_categoriesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(categoriesCombo_OnSelect);

            m_cuesCombo = AddCombo();

            m_cuesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(cuesCombo_OnSelect);

            m_cueVolumeSlider = AddSlider("Volume", 1f, 0f, 1f, null);
            m_cueVolumeSlider.ValueChanged = CueVolumeChanged;

            m_applyVolumeToCategory         = AddButton(new StringBuilder("Apply to category"), OnApplyVolumeToCategorySelected);
            m_applyVolumeToCategory.Enabled = false;

            m_cueVolumeCurveCombo = AddCombo();
            foreach (var curveType in Enum.GetValues(typeof(MyCurveType)))
            {
                m_cueVolumeCurveCombo.AddItem((int)curveType, new StringBuilder(curveType.ToString()));
            }

            m_effects = AddCombo();
            m_effects.AddItem(0, new StringBuilder(""));
            catCount = 1;
            foreach (var effect in MyDefinitionManager.Static.GetAudioEffectDefinitions())
            {
                m_effects.AddItem(catCount++, new StringBuilder(effect.Id.SubtypeName));
            }
            m_effects.SelectItemByIndex(0);
            m_effects.ItemSelected += effects_ItemSelected;

            m_cueMaxDistanceSlider = AddSlider("Max distance", 0, 0, 2000, null);
            m_cueMaxDistanceSlider.ValueChanged = MaxDistanceChanged;

            m_applyMaxDistanceToCategory         = AddButton(new StringBuilder("Apply to category"), OnApplyMaxDistanceToCategorySelected);
            m_applyMaxDistanceToCategory.Enabled = false;

            m_cueVolumeVariationSlider = AddSlider("Volume variation", 0, 0, 10, null);
            m_cueVolumeVariationSlider.ValueChanged = VolumeVariationChanged;
            m_cuePitchVariationSlider = AddSlider("Pitch variation", 0, 0, 500, null);
            m_cuePitchVariationSlider.ValueChanged = PitchVariationChanged;

            m_soloCheckbox = AddCheckBox("Solo", false, null);
            m_soloCheckbox.IsCheckedChanged = SoloChanged;

            MyGuiControlButton btn = AddButton(new StringBuilder("Play selected"), OnPlaySelected);

            btn.CueEnum = GuiSounds.None;

            AddButton(new StringBuilder("Stop selected"), OnStopSelected);
            AddButton(new StringBuilder("Save"), OnSave);
            AddButton(new StringBuilder("Reload"), OnReload);

            if (m_categoriesCombo.GetItemsCount() > 0)
            {
                m_categoriesCombo.SelectItemByIndex(0);
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            var layout = new MyLayoutTable(this);

            layout.SetColumnWidthsNormalized(50, 300, 300, 300, 300, 300, 50);
            layout.SetRowHeightsNormalized(50, 450, 70, 70, 70, 400, 70, 70, 50);

            //BRIEFING:
            MyGuiControlParent briefing = new MyGuiControlParent();
            var briefingScrollableArea  = new MyGuiControlScrollablePanel(
                scrolledControl: briefing)
            {
                Name = "BriefingScrollableArea",
                ScrollbarVEnabled   = true,
                OriginAlign         = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture   = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
            };

            layout.AddWithSize(briefingScrollableArea, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 4, colSpan: 3);
            //inside scrollable area:
            m_descriptionBox = new MyGuiControlMultilineText(
                position: new Vector2(-0.227f, 5f),
                size: new Vector2(briefingScrollableArea.Size.X - 0.02f, 11f),
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: false);
            briefing.Controls.Add(m_descriptionBox);

            m_connectedPlayers                  = new MyGuiControlTable();
            m_connectedPlayers.Size             = new Vector2(490f, 150f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_connectedPlayers.VisibleRowsCount = 8;
            m_connectedPlayers.ColumnsCount     = 2;
            m_connectedPlayers.SetCustomColumnWidths(new float[] { 0.7f, 0.3f });
            m_connectedPlayers.SetColumnName(0, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerName));
            m_connectedPlayers.SetColumnName(1, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerStatus));

            m_kickPlayerButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Kick), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                        size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnKick2Clicked);
            m_kickPlayerButton.Enabled = CanKick();

            m_timeoutLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.GuiScenarioTimeout), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            TimeoutCombo = new MyGuiControlCombobox();
            TimeoutCombo.ItemSelected += OnTimeoutSelected;
            TimeoutCombo.AddItem(3, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout3min));
            TimeoutCombo.AddItem(5, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout5min));
            TimeoutCombo.AddItem(10, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout10min));
            TimeoutCombo.AddItem(-1, MyTexts.Get(MySpaceTexts.GuiScenarioTimeoutUnlimited));
            TimeoutCombo.SelectItemByIndex(0);
            TimeoutCombo.Enabled = Sync.IsServer;

            m_canJoinRunningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScenarioSettings_CanJoinRunningShort), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_canJoinRunning      = new MyGuiControlCheckbox();

            m_canJoinRunningLabel.Enabled = false;
            m_canJoinRunning.Enabled      = false;

            m_startButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioStart), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                   size: new Vector2(200, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnStartClicked);
            m_startButton.Enabled = Sync.IsServer;

            m_chatControl = new MyHudControlChat(
                MyHud.Chat,
                size: new Vector2(1400f, 300f) / MyGuiConstants.GUI_OPTIMAL_SIZE,
                font: MyFontEnum.DarkBlue,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                backgroundColor: MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR,
                contents: null,
                drawScrollbar: true,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_chatControl.BorderEnabled = true;
            m_chatControl.BorderColor   = Color.CornflowerBlue;

            m_chatTextbox               = new MyGuiControlTextbox(maxLength: ChatMessageBuffer.MAX_MESSAGE_SIZE);
            m_chatTextbox.Size          = new Vector2(1400f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_chatTextbox.TextScale     = 0.8f;
            m_chatTextbox.VisualStyle   = MyGuiControlTextboxStyleEnum.Default;
            m_chatTextbox.EnterPressed += ChatTextbox_EnterPressed;

            m_sendChatButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioSend), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                                                      size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnSendChatClicked);


            layout.AddWithSize(m_connectedPlayers, MyAlignH.Left, MyAlignV.Top, 1, 4, rowSpan: 2, colSpan: 2);

            layout.AddWithSize(m_kickPlayerButton, MyAlignH.Left, MyAlignV.Center, 2, 5);
            layout.AddWithSize(m_timeoutLabel, MyAlignH.Left, MyAlignV.Center, 3, 4);
            layout.AddWithSize(TimeoutCombo, MyAlignH.Left, MyAlignV.Center, 3, 5);

            layout.AddWithSize(m_canJoinRunningLabel, MyAlignH.Left, MyAlignV.Center, 4, 4);
            layout.AddWithSize(m_canJoinRunning, MyAlignH.Right, MyAlignV.Center, 4, 5);

            layout.AddWithSize(m_chatControl, MyAlignH.Left, MyAlignV.Top, 5, 1, rowSpan: 1, colSpan: 5);

            layout.AddWithSize(m_chatTextbox, MyAlignH.Left, MyAlignV.Top, 6, 1, rowSpan: 1, colSpan: 4);
            layout.AddWithSize(m_sendChatButton, MyAlignH.Right, MyAlignV.Top, 6, 5);

            layout.AddWithSize(m_startButton, MyAlignH.Left, MyAlignV.Top, 7, 2);
        }
Ejemplo n.º 11
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            if (m_asteroid_showPlanet)
            {
                CreatePlanetMenu();
                return;
            }

            Vector2 cbOffset       = new Vector2(-0.05f, 0.0f);
            Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top

            float textScale     = 0.8f;
            float separatorSize = 0.01f;
            float usableWidth   = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2;
            float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f;

            m_currentPosition    = -m_size.Value / 2.0f;
            m_currentPosition   += controlPadding;
            m_currentPosition.Y += hiddenPartTop;
            m_scale              = textScale;

            var caption = AddCaption(MySpaceTexts.ScreenDebugSpawnMenu_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop));

            m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize;

            if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS || MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS)
            {
                AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f));
            }

            if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS)
            {
                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale);
                var combo = AddCombo();
                combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids);
                combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids);
                // DA: Remove from MySpaceTexts and just hardcode until release. Leave a todo so you don't forget about it before release of planets.
                combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets);

                combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2);
                combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); };
            }

            if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && m_asteroid_showPredefinedOrProcedural)
            {
                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale);
                m_asteroidCombobox = AddCombo();
                {
                    foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions())
                    {
                        m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString());
                    }
                    m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected;
                    m_asteroidCombobox.SortItemsByValueText();
                    m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex);
                }

                m_currentPosition.Y += separatorSize;

                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale);
                CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid);

                m_currentPosition.Y += separatorSize;
            }

            if (MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS && !m_asteroid_showPredefinedOrProcedural)
            {
                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale);


                m_procAsteroidSize = new MyGuiControlSlider(
                    position: m_currentPosition,
                    width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                    minValue: 5.0f,
                    maxValue: 500f,
                    labelText: String.Empty,
                    labelDecimalPlaces: 2,
                    labelScale: 0.75f * m_scale,
                    originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    labelFont: MyFontEnum.Debug);
                m_procAsteroidSize.DebugScale = m_sliderDebugScale;
                m_procAsteroidSize.ColorMask  = Color.White.ToVector4();
                Controls.Add(m_procAsteroidSize);

                MyGuiControlLabel label = new MyGuiControlLabel(
                    position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2),
                    text: String.Empty,
                    colorMask: Color.White.ToVector4(),
                    textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale,
                    font: MyFontEnum.Debug);
                label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                Controls.Add(label);
                m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; };

                m_procAsteroidSize.Value = m_procAsteroidSizeValue;

                m_currentPosition.Y += m_procAsteroidSize.Size.Y;
                m_currentPosition.Y += separatorSize;

                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale);

                m_procAsteroidSeed              = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal);
                m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; };
                m_procAsteroidSeed.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                Controls.Add(m_procAsteroidSeed);
                m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize;

                CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick);
                AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale);
                CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid);

                m_currentPosition.Y += separatorSize;
            }

            CreateObjectsSpawnMenu(separatorSize, usableWidth);
        }
        private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth)
        {
            AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f));

            AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale);
            m_physicalObjectCombobox = AddCombo();
            {
                foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions())
                {
                    if (!definition.Public)
                    {
                        continue;
                    }
                    var physicalItemDef = definition as MyPhysicalItemDefinition;
                    if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false)
                    {
                        continue;
                    }

                    int key = m_physicalItemDefinitions.Count;
                    m_physicalItemDefinitions.Add(physicalItemDef);
                    m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText);
                }
                m_physicalObjectCombobox.SortItemsByValueText();
                m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex);
                m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected;
            }

            m_currentPosition.Y += separatorSize;

            AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale);
            m_amountTextbox              = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly);
            m_amountTextbox.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_amountTextbox.TextChanged += OnAmountTextChanged;
            Controls.Add(m_amountTextbox);

            m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y;
            m_errorLabel         = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale);
            m_errorLabel.Visible = false;
            CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject);

            MyCharacterDetectorComponent comp;
            MyTerminalBlock detected     = null;
            bool            enableButton = false;

            if (MySession.Static.LocalCharacter != null && MySession.Static.LocalCharacter.Components.TryGet(out comp) && comp.UseObject != null)
            {
                detected = comp.DetectedEntity as MyTerminalBlock;
            }

            string name = "-";

            if (detected != null && detected.HasInventory && detected.HasLocalPlayerAccess())
            {
                name         = detected.CustomName.ToString();
                enableButton = true;
            }

            AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_CurrentTarget) + name, Color.White.ToVector4(), m_scale);
            CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnTargeted, OnSpawnIntoContainer, enableButton);

            m_currentPosition.Y += separatorSize;
        }
Ejemplo n.º 13
0
        private void RecreateControls()
        {
            Controls.Clear();

            AddCaption(new StringBuilder("Select Sector"), MyGuiConstants.SCREEN_CAPTION_TEXT_COLOR);

            Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.04f, -m_size.Value.Y / 2.0f + 0.08f);
            Vector2 controlsDelta      = new Vector2(0, 0.0525f);

            // controls for typing friend name to search
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * controlsDelta, null, MyTextsWrapperEnum.FriendName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_findPlayerName = new MyGuiControlTextbox(this, controlsOriginLeft + 2 * controlsDelta + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, "", 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL);
            Controls.Add(m_findPlayerName);

            // search button
            Controls.Add(new MyGuiControlButton(this, m_findPlayerName.GetPosition() + new Vector2(0.2f, 0), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                MyTextsWrapperEnum.Search, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnSearchClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));

            // friend maps available for selection
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 4 * controlsDelta, null, MyTextsWrapperEnum.Map, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            if (m_sectorIdentifiers != null && m_userDetails != null)
            {
                m_mapsCombobox = new MyGuiControlCombobox(this, controlsOriginLeft + 5 * controlsDelta + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
                for (int i = 0; i < m_sectorIdentifiers.Count; i++)
                {
                    MyMwcSectorIdentifier sectorIdentifier = m_sectorIdentifiers[i];
                    if (!sectorIdentifier.UserId.HasValue)
                    {
                        AddSectorToCombo(sectorIdentifier, i, "STORY");
                    }
                    else
                    {
                        foreach (MyMwcUserDetail userDetail in m_userDetails)
                        {
                            if (sectorIdentifier.UserId.HasValue && sectorIdentifier.UserId.Value == userDetail.UserId)
                            {
                                AddSectorToCombo(sectorIdentifier, i, userDetail.DisplayName);
                            }
                        }
                    }
                }

                SortSectors();

                m_mapsCombobox.SelectItemByIndex(0);
                Controls.Add(m_mapsCombobox);
            }
            else
            {
                Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 5 * controlsDelta, null, MyTextsWrapperEnum.NoSectorsAvailable, MyGuiConstants.LABEL_TEXT_COLOR,
                                                   MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            }

            //  Buttons OK and CANCEL
            Vector2 buttonDelta = new Vector2(0.1f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f);

            if (m_mapsCombobox != null)
            {
                Controls.Add(new MyGuiControlButton(this, new Vector2(-buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
                Controls.Add(new MyGuiControlButton(this, new Vector2(+buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            }
            else
            {
                Controls.Add(new MyGuiControlButton(this, new Vector2(0, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            }
        }