コード例 #1
0
        public void ReloadControls()
        {
            Vector2 originDelta        = new Vector2(0.02f, 0);
            Vector2 controlsOriginLeft = GetControlsOriginLeftFromScreenSize() + originDelta;

            if (GetAsteroidType() == MyGuiAsteroidTypesEnum.VOXEL)
            {
                #region Voxel File
                //choose asteroid label
                m_selectAsteroidLabel = new MyGuiControlLabel(this, controlsOriginLeft + 2.5f * CONTROLS_DELTA + new Vector2(0.02f, -0.02f), null, MyTextsWrapperEnum.AsteroidName, MyGuiConstants.LABEL_TEXT_COLOR,
                                                              MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                Controls.Add(m_selectAsteroidLabel);

                //COMBOBOX - voxel files
                m_selectVoxelMapCombobox = new MyGuiControlCombobox(this, controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f + 0.02f, -0.065f), MyGuiControlPreDefinedSize.LONGMEDIUM,
                                                                    MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 11, true, false, true);

                foreach (MyMwcVoxelFilesEnum enumValue in MyGuiAsteroidHelpers.MyMwcVoxelFilesEnumValues)
                {
                    MyGuiAsteroidHelper voxelFileHelper = MyGuiAsteroidHelpers.GetMyGuiVoxelFileHelper(enumValue);
                    Debug.Assert(voxelFileHelper.Description != null);
                    m_selectVoxelMapCombobox.AddItem((int)enumValue, voxelFileHelper.Icon, voxelFileHelper.Description);
                }

                m_selectVoxelMapCombobox.SortItemsByValueText();
                m_selectVoxelMapCombobox.SelectItemByKey(1);
                m_selectVoxelMapCombobox.OnSelectItemDoubleClick += OnDoubleClick;
                Controls.Add(m_selectVoxelMapCombobox);
                #endregion

                #region Voxel Material
                Vector2 delta = new Vector2(m_selectVoxelMapCombobox.GetSize().Value.X + 0.02f, 0);
                AddVoxelMaterialCombobox(
                    controlsOriginLeft + 2.5f * CONTROLS_DELTA + delta + new Vector2(0.14f, -0.02f),
                    controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0) + delta + new Vector2(0.14f, -0.065f),
                    null);
                #endregion
            }
            else if (GetAsteroidType() == MyGuiAsteroidTypesEnum.STATIC)
            {
                #region Static Asteroid
                m_selectAsteroidLabel = new MyGuiControlLabel(this, controlsOriginLeft + 2.5f * CONTROLS_DELTA + new Vector2(0.02f, -0.02f), null, MyTextsWrapperEnum.AsteroidName, MyGuiConstants.LABEL_TEXT_COLOR,
                                                              MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                Controls.Add(m_selectAsteroidLabel);

                //COMBOBOX - static asteroids
                m_selectVoxelMapCombobox = new MyGuiControlCombobox(this, controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f + 0.02f, -0.065f), MyGuiControlPreDefinedSize.LONGMEDIUM,
                                                                    MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 11, true, false, true);

                m_selectVoxelMapCombobox.OnSelectItemDoubleClick += OnDoubleClick;

                foreach (MyMwcObjectBuilder_StaticAsteroid_TypesEnum enumValue in MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues)
                {
                    MyGuiAsteroidHelper staticAsteroidHelper = MyGuiAsteroidHelpers.GetStaticAsteroidTypeHelper(enumValue);

                    if (staticAsteroidHelper != null)
                    {
                        m_selectVoxelMapCombobox.AddItem((int)enumValue, staticAsteroidHelper.Icon, staticAsteroidHelper.Description);
                    }
                }

                m_selectVoxelMapCombobox.SelectItemByIndex(0);
                Controls.Add(m_selectVoxelMapCombobox);

                Vector2 delta = new Vector2(m_selectVoxelMapCombobox.GetSize().Value.X + 0.02f, 0);
                AddVoxelMaterialCombobox(
                    controlsOriginLeft + 2.5f * CONTROLS_DELTA + delta + new Vector2(0.14f, -0.02f),
                    controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0) + delta + new Vector2(0.14f, -0.065f),
                    null);

                m_selectVoxelMapMaterialCombobox.SelectItemByKey(0); // Select default material

                #endregion
            }
        }