Пример #1
0
        private void OnGenerateListOfAssets(MyGuiControlButton sender)
        {
            string trimPath = @"Models2\";
            foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues)
            {
                foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue))
                {
                    MyGuiPrefabHelper prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper;
                    MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId);
                    string assetName = MyModels.GetModelAssetName(config.ModelLod0Enum);
                    int trimIndex = assetName.IndexOf(trimPath);
                    if (trimIndex >= 0)
                    {
                        assetName = assetName.Substring(trimIndex + trimPath.Length);
                    }

                    MyMwcLog.WriteLine(string.Format("{0};{1}", prefabModuleHelper.Description, assetName));
                }
            }

            foreach (MyMwcObjectBuilder_SmallShip_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues)
            {
                MyGuiSmallShipHelperSmallShip smallShipHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)enumValue) as MyGuiSmallShipHelperSmallShip;
                var properties = MyShipTypeConstants.GetShipTypeProperties(enumValue);
                string assetName = MyModels.GetModelAssetName(properties.Visual.ModelLod0Enum);
                int trimIndex = assetName.IndexOf(trimPath);
                if (trimIndex >= 0)
                {
                    assetName = assetName.Substring(trimIndex + trimPath.Length);
                }

                MyMwcLog.WriteLine(string.Format("{0};{1}", smallShipHelper.Description, assetName));
            }
        }
        void Init()
        {
            m_enableBackgroundFade = true;
            m_size = new Vector2(0.73f, 0.93f);
            Vector2 controlsOriginLeft  = GetControlsOriginLeftFromScreenSize() + new Vector2(0.02f, 0.01f);
            Vector2 controlsOriginRight = GetControlsOriginRightFromScreenSize();

            // Add screen title
            AddCaption();

            #region Faction nationality

            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * CONTROLS_DELTA, null, MyTextsWrapperEnum.SetShipFaction, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            m_selectShipFactionCombobox = new MyGuiControlCombobox(this, controlsOriginRight + 1 * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                                                                   MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 5);

            foreach (MyMwcObjectBuilder_FactionEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_ShipFactionNationalityEnumValues)
            {
                MyGuiHelperBase factionNationalityHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipFactionNationality(enumValue);
                m_selectShipFactionCombobox.AddItem((int)enumValue, null, factionNationalityHelper.Description);
            }

            m_selectShipFactionCombobox.SelectItemByKey(1);
            Controls.Add(m_selectShipFactionCombobox);

            #endregion

            // AI Template
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 2 * CONTROLS_DELTA, null, MyTextsWrapperEnum.AITemplate, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            m_selectAITemplateCombobox = new MyGuiControlCombobox(this, controlsOriginRight + 2 * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                                                                  MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 5);

            foreach (MyAITemplateEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_BotAITemplateValues)
            {
                MyGuiHelperBase aiTemplateHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipBotAITemplate(enumValue);
                if (aiTemplateHelper != null)
                {
                    m_selectAITemplateCombobox.AddItem((int)enumValue, null, aiTemplateHelper.Description);
                }
            }

            m_selectAITemplateCombobox.SelectItemByKey(0);
            Controls.Add(m_selectAITemplateCombobox);

            // Aggresivity
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Aggressivity, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            m_aggresivitySlider = new MyGuiControlSlider(this, controlsOriginRight + 3 * CONTROLS_DELTA + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2, 0), MyGuiConstants.SLIDER_WIDTH,
                                                         0, 1, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                         new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);

            m_aggresivityLabel = new MyGuiControlLabel(this, controlsOriginRight + 3 * CONTROLS_DELTA + new Vector2(MyGuiConstants.SLIDER_WIDTH, 0), null, MyTextsWrapperEnum.SetShipFaction, MyGuiConstants.LABEL_TEXT_COLOR,
                                                       MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            Controls.Add(m_aggresivitySlider);
            Controls.Add(m_aggresivityLabel);

            m_aggresivitySlider.OnChange += OnAggresivityChanged;
            OnAggresivityChanged(m_aggresivitySlider);

            // See distance
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.SeeDistance, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            m_seeDistanceSlider = new MyGuiControlSlider(this, controlsOriginRight + 4 * CONTROLS_DELTA + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2, 0), MyGuiConstants.SLIDER_WIDTH,
                                                         0, 1000, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                         new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);

            m_seeDistanceLabel = new MyGuiControlLabel(this, controlsOriginRight + 4 * CONTROLS_DELTA + new Vector2(MyGuiConstants.SLIDER_WIDTH, 0), null, MyTextsWrapperEnum.SetShipFaction, MyGuiConstants.LABEL_TEXT_COLOR,
                                                       MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            Controls.Add(m_seeDistanceSlider);
            Controls.Add(m_seeDistanceLabel);

            m_seeDistanceSlider.OnChange += OnSeeDistanceChanged;
            OnSeeDistanceChanged(m_seeDistanceSlider);

            #region Smallship Model

            MyGuiControlLabel smallShipLabel = new MyGuiControlLabel(this, controlsOriginLeft + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ChooseModel, MyGuiConstants.LABEL_TEXT_COLOR,
                                                                     MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(smallShipLabel);

            //COMBOBOX - small ship
            var comboboxPredefinedSize = MyGuiControlPreDefinedSize.LONGMEDIUM;
            var comboboxSize           = MyGuiControlCombobox.GetPredefinedControlSize(comboboxPredefinedSize);
            m_selectSmallShipCombobox = new MyGuiControlCombobox(
                this,
                controlsOriginLeft + 5 * CONTROLS_DELTA + 0.5f * new Vector2(comboboxSize.X, 0) + new Vector2(0.19f, 0.01f),
                comboboxPredefinedSize,
                MyGuiConstants.COMBOBOX_BACKGROUND_COLOR,
                MyGuiConstants.COMBOBOX_TEXT_SCALE,
                6,
                true,
                false,
                true);

            if (m_templatesBuilders == null)
            {
                foreach (MyMwcObjectBuilder_SmallShip_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues)
                {
                    //MyGuiSmallShipHelperSmallShip smallShipHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperSmallShip(enumValue);
                    MyGuiSmallShipHelperSmallShip smallShipHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)enumValue) as MyGuiSmallShipHelperSmallShip;
                    m_selectSmallShipCombobox.AddItem((int)enumValue, smallShipHelper.Icon, smallShipHelper.Name);
                }
                m_selectSmallShipCombobox.SelectItemByKey(1);
            }
            else
            {
                for (int i = 0; i < m_templatesBuilders.Count; i++)
                {
                    var templateBuilder = m_templatesBuilders[i];
                    m_selectSmallShipCombobox.AddItem(i, templateBuilder.Name);
                }
            }

            m_selectSmallShipCombobox.OnSelectItemDoubleClick += OnOkClick;
            Controls.Add(m_selectSmallShipCombobox);
            #endregion

            if (m_bot != null)
            {
                Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 10 * CONTROLS_DELTA + new Vector2(0.07f, 0.02f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyTextsWrapperEnum.Inventory, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnInventoryClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));

                AddActivatedCheckbox(controlsOriginLeft, m_bot.Activated);
            }

            AddOkAndCancelButtonControls(new Vector2(0, -0.02f));
        }