Beispiel #1
0
        protected void SelectFirstHandItem()
        {
            MyCharacter playerCharacter = MySession.Static.LocalCharacter;
            var         weapon          = playerCharacter.CurrentWeapon;

            if (weapon == null)
            {
                if (m_handItemsCombo.GetItemsCount() > 0)
                {
                    m_handItemsCombo.SelectItemByIndex(0);
                }
            }
            else
            {
                if (m_handItemsCombo.GetItemsCount() > 0)
                {
                    try
                    {
                        if (weapon.DefinitionId.TypeId != typeof(MyObjectBuilder_PhysicalGunObject))
                        {
                            var physicalItemId = MyDefinitionManager.Static.GetPhysicalItemForHandItem(weapon.DefinitionId).Id;
                            //def = MyDefinitionManager.Static.GetDefinition(physicalItemId);
                            int index = m_handItemDefinitions.FindIndex(x => x.PhysicalItemId == physicalItemId);
                            m_handItemsCombo.SelectItemByKey(index);
                        }
                        else
                        {
                            MyDefinitionBase def;
                            def = MyDefinitionManager.Static.GetDefinition(weapon.DefinitionId);
                            int index = m_handItemDefinitions.FindIndex(x => x.DisplayNameText == def.DisplayNameText);
                            m_handItemsCombo.SelectItemByKey(index);
                        }
                    }
                    catch (Exception e)
                    {
                        m_handItemsCombo.SelectItemByIndex(0);
                    }
                }
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            MyGuiControlCombobox modeCombo = GetCombo();

            if (MySession.Static.IsUserSpaceMaster(Sync.MyId) && MySession.Static.IsUserAdmin(Sync.MyId))
            {
                modeCombo.AddItem(8L, "SEWorldGenPlugin - Rings");
                modeCombo.AddItem(9L, "SEWorldGenPlugin - Planets");
            }

            MyGuiControlCombobox newCombo = AddCombo();

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

            newCombo.Position = modeCombo.Position;
            newCombo.SelectItemByKey(m_currentKey);
            Controls[Controls.IndexOf(modeCombo)] = newCombo;
            Controls.Remove(modeCombo);

            newCombo.ItemSelected += delegate
            {
                m_currentKey = newCombo.GetSelectedKey();
                if (newCombo.GetSelectedKey() > 7)
                {
                    RecreateControls(false);
                }
                else
                {
                    m_attachedEntity = 0L;
                    m_selectedPlanet = null;
                    modeCombo.SelectItemByKey(newCombo.GetSelectedKey());
                    RecreateControls(false);
                }
            };
            if (newCombo.GetSelectedKey() == 8)
            {
                ClearControls();
                CheckBuildPluginControls(BuildRingMenu);
            }
            else if (newCombo.GetSelectedKey() == 9)
            {
                ClearControls();
                CheckBuildPluginControls(BuildPlanetMenu);
            }
        }
Beispiel #3
0
 void OnItemSelected()
 {
     if (m_comboBox.GetItemsCount() > 0)
     {
         var selected = m_comboBox.GetSelectedKey();
         if (Setter != null)
         {
             foreach (var block in TargetBlocks)
             {
                 Setter(block, selected);
             }
         }
     }
 }
Beispiel #4
0
        void m_comboNodes_ItemSelected()
        {
            m_selectedCutsceneNode = m_selectedCutscene.SequenceNodes[m_comboNodes.GetSelectedKey()];
            m_nodeTimeSlider.Value = m_selectedCutsceneNode.Time;

            m_comboWaypoints.ClearItems();

            if (m_selectedCutsceneNode.Waypoints != null)
            {
                foreach (var waypoint in m_selectedCutsceneNode.Waypoints)
                {
                    m_comboWaypoints.AddItem(waypoint.Name.GetHashCode(), waypoint.Name);
                }

                if (m_comboWaypoints.GetItemsCount() > 0)
                {
                    m_comboWaypoints.SelectItemByIndex(0);
                }
            }
        }
Beispiel #5
0
        void UdpateCuesCombo(MyGuiControlCombobox box)
        {
            box.ClearItems();
            long key = 0;

            foreach (var cue in MyAudio.Static.CueDefinitions)
            {
                if ((m_currentCategorySelectedItem == ALL_CATEGORIES) || (m_currentCategorySelectedItem == cue.Category.ToString()))
                {
                    box.AddItem(key, new StringBuilder(cue.SubtypeId.ToString()));
                    key++;
                }
            }

            box.SortItemsByValueText();
            if (box.GetItemsCount() > 0)
            {
                box.SelectItemByIndex(0);
            }
        }
Beispiel #6
0
        void m_comboCutscenes_ItemSelected()
        {
            m_selectedCutscene = MySession.Static.GetComponent <MySessionComponentCutscenes>().GetCutscene(m_comboCutscenes.GetSelectedValue().ToString());

            m_comboNodes.ClearItems();

            if (m_selectedCutscene.SequenceNodes != null)
            {
                int i = 0;
                foreach (var node in m_selectedCutscene.SequenceNodes)
                {
                    m_comboNodes.AddItem(i, node.Time.ToString());
                    i++;
                }
            }


            if (m_comboNodes.GetItemsCount() > 0)
            {
                m_comboNodes.SelectItemByIndex(0);
            }
        }
        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;
        }
Beispiel #8
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);
            }
        }