Пример #1
0
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, MyGuiControlPreDefinedSize predefinedSize, Vector4?backgroundColor, StringBuilder toolTip,
                         MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl) :
     this(parent, position, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, null, null /*, null, null*/)
 {
     m_predefinedSize = predefinedSize;
     m_size           = GetPredefinedControlSize();
 }
Пример #2
0
        public virtual void Draw()
        {
            if (m_backgroundColor.HasValue)
            {
                MyTexture2D controlTexture  = MyGuiManager.GetBlankTexture();
                Vector4     backgroundColor = m_backgroundColor.Value;

                if (m_controlTexture != null)
                {
                    controlTexture = m_controlTexture;

                    if (m_mouseButtonPressed && m_pressedTexture != null)
                    {
                        controlTexture = m_pressedTexture;
                    }
                    else if (IsMouseOverOrKeyboardActive())
                    {
                        if ((m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE) || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver()) || (m_hasKeyboardActiveControl && m_canHandleKeyboardActiveControl))
                        {
                            backgroundColor = m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER;
                        }
                    }
                }

                if (!Enabled)
                {
                    backgroundColor = m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR;
                }

                MyGuiManager.DrawSpriteBatch(controlTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, GetColorAfterTransitionAlpha(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }
        }
Пример #3
0
        public MyGuiScreenGameChat(bool sendToTeam)
            : base(Vector2.Zero, null, null)
        {
            m_closeOnEsc           = true;
            m_enableBackgroundFade = true;
            m_teamOnly             = sendToTeam;

            m_positionOffset = new Vector2(MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate_FULLSCREEN(new Vector2(0, 0)).X - 920 / 1920f / 2 - 0.04f, -0.2f);

            m_panelTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ChatBackground", flags: TextureFlags.IgnoreQuality);

            MyGuiControlPanel panel = new MyGuiControlPanel(this, new Vector2(0.5f, 0.85f) + m_positionOffset, new Vector2(920 / 1920f, 388 / 1200f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, m_panelTexture, null, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP);

            Controls.Add(panel);

            Vector2 menuPositionOrigin = new Vector2(0.423f, 0.939f) + m_positionOffset;
            Vector2 delta = new Vector2(0.17f, 0f);
            const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED;

            m_textbox = new MyGuiControlTextbox(this, menuPositionOrigin, MyGuiControlPreDefinedSize.MEDIUM, "", MyGuiConstants.CHAT_WINDOW_MAX_MESSAGE_LENGTH, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.75f, MyGuiControlTextboxType.NORMAL, true, false);
            Controls.Add(m_textbox);

            Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + delta,
                                                MyGuiConstants.MAIN_MENU_BUTTON_SIZE * new Vector2(0.41f, 0.78f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\ButtonChatEnter", flags: TextureFlags.IgnoreQuality), null, null,
                                                sendToTeam ? MyTextsWrapperEnum.SendToTeam : MyTextsWrapperEnum.SendToAll, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.65f,
                                                menuButtonTextAlignement, OnSendClick, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                true, true, MyGuiControlHighlightType.WHEN_ACTIVE));
        }
Пример #4
0
        public MyUseObjective(
            StringBuilder name,
            MyMissionID id,
            StringBuilder description,
            MyTexture2D icon,
            MyMission parentMission,
            MyMissionID[] requiredMissions,
            MyMissionLocation location,
            MyTextsWrapperEnum notificationText,
            MyTextsWrapperEnum useCaption,
            MyTextsWrapperEnum useText,
            int requiredTime,
            MyUseObjectiveType objectiveType = MyUseObjectiveType.Hacking,
            MyDialogueEnum?successDialogId   = null,
            MyDialogueEnum?startDialogId     = null,
            float?radiusOverride             = null,
            List <uint> fakeMissionIds       = null,
            uint?realMissionId = null)
            : base(name, id, description, icon, parentMission, requiredMissions, location, fakeMissionIds, successDialogId, startDialogId, radiusOverride: radiusOverride)
        {
            m_notificationText    = notificationText;
            m_useText             = useText;
            m_useCaption          = useCaption;
            m_requiredTime        = requiredTime;
            m_realMissionEntityId = realMissionId;
            InitSounds(objectiveType);

            if (location != null)
            {
                if (location.LocationEntityIdentifier.LocationEntityId != null)
                {
                    RequiredEntityIDs.Add(location.LocationEntityIdentifier.LocationEntityId.Value);
                }
            }
        }
 public MyGuiControlCheckbox(IMyGuiControlsParent parent, Vector2 position, Vector2 size, MyTexture2D texture, MyTexture2D checkedTexture,
                             StringBuilder toolTip, bool checkedVal, Vector4 color, bool highlightWhenChecked, MyGuiControlLabel label, Vector2?innerSize = null)
     : base(parent, position, size, color, toolTip, texture, null, null, true)
 {
     m_canHandleKeyboardActiveControl = true;
     m_checked = checkedVal;
     m_highlightWhenChecked = false; // highlightWhenChecked; this feature is depracted
     m_checkedTexture       = checkedTexture;
     m_label = label;
     if (m_label != null)
     {
         m_label.MouseEnter += delegate
         {
             m_highlight = true;
         };
         m_label.MouseLeave += delegate
         {
             m_highlight = false;
         };
         m_label.Click += delegate
         {
             UserCheck();
         };
     }
     if (innerSize == null)
     {
         m_innerSize = size;
     }
     else
     {
         m_innerSize = innerSize;
     }
 }
Пример #6
0
        public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload, MyTexture2D textureFromConstructor)
            : base(Vector2.Zero, null, null)
        {
            MyLoadingPerformance.Instance.StartTiming();

            System.Diagnostics.Debug.Assert(Static == null);
            Static = this;

            m_screenToLoad         = screenToLoad;
            m_screenToUnload       = screenToUnload;
            m_closeOnEsc           = false;
            DrawMouseCursor        = false;
            m_loadInDrawFinished   = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuoteOfTheDay = MyQuoteOfTheDay.GetRandomQuote();

            Vector2 loadingTextSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(),
                                                                     MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);

            m_rotatingWheelTexture = MyGuiManager.GetLoadingTexture();
            Controls.Add(new MyGuiControlRotatingWheel(this, MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.075f + loadingTextSize.Y),
                                                       MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture));
            m_backgroundTextureFromConstructor = textureFromConstructor;

            m_loadFinished = false;

            if (m_screenToLoad != null)
            {
                MyMinerGame.IsGameReady = false;
            }
        }
Пример #7
0
        public void DrawDraged(Vector2 position)
        {
            if ((m_icon != null && m_icon.LoadState == LoadState.Loaded) || Text != null)
            {
                if (m_icon != null)
                {
                    MyTexture2D texture = m_icon;
                    if (texture == null)
                    { // texture is still being loaded on other thread
                        DrawLoadingIcon(Vector4.One, GetIconPosition());
                    }
                    else
                    {
                        MyGUIHelper.OutsideBorder(position + GetIconPosition(), m_iconSize, 2, MyGuiConstants.TOOL_TIP_BORDER_COLOR);
                        MyGuiManager.DrawSpriteBatch(m_icon,
                                                     position + GetIconPosition(), m_iconSize,
                                                     Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    }
                }
                else if (Text != null)
                {
                    var textRect = MyGuiManager.MeasureString(MyGuiManager.GetFontMinerWarsBlue(), Text, position + GetTextPosition(), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    MyGUIHelper.OutsideBorder(textRect.LeftTop, textRect.Size, 2, MyGuiConstants.TOOL_TIP_BORDER_COLOR);
                    MyGUIHelper.FillRectangle(textRect.LeftTop, textRect.Size, TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR));

                    Color textColor = TreeView.GetColor(MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER);
                    MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text,
                                            position + GetTextPosition(),
                                            0.8f, textColor, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
            }
        }
Пример #8
0
        protected override void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType)
        {
            MyMwcLog.WriteLine("GAME AddPrefabItems - START");

            Vector2 itemSize = MyGuiConstants.CHECKBOX_SIZE * 3;

            foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues)
            {
                foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue))
                {
                    MyPrefabConfiguration config             = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId);
                    MyGuiPrefabHelper     prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper;

                    if (config == null)
                    {
                        continue;
                    }

                    if (config.FactionSpecific.HasValue && config.FactionSpecific.Value != appearanceTextureEnum)
                    {
                        continue;
                    }

                    if (config.BuildType == buildType && config.CategoryType == categoryType && config.EnabledInEditor)
                    {
                        MyMwcObjectBuilder_PrefabBase prefabObjectBuilder   = MyPrefabFactory.GetInstance().CreatePrefabObjectBuilder(enumValue, prefabId, appearanceTextureEnum);
                        MyBuildingSpecification       buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(prefabObjectBuilder);
                        MyTexture2D previewTexture = MyGuiManager.GetPrefabPreviewTexture(enumValue, prefabId, appearanceTextureEnum);
                        AddTreeViewItem(parentItem, prefabModuleHelper.Description, previewTexture, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE, prefabObjectBuilder, buildingSpecification);
                    }
                }
            }

            MyMwcLog.WriteLine("GAME AddPrefabItems - END");
        }
Пример #9
0
        void LoadControls()
        {
            // Background texture unloaded in base
            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ProgressBackground", flags: TextureFlags.IgnoreQuality);
            m_wheelTexture      = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\Loading", flags: TextureFlags.IgnoreQuality);

            m_size = new Vector2(598 / 1600f, 368 / 1200f);
            Controls.Add(new MyGuiControlLabel(this, new Vector2(0.0f, -0.05f), null, m_progressText, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE * 0.86f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            float deltaX = (m_enableCancel) ? 0.08f : 0.0f;
            float deltaY = 0.035f;

            Controls.Add(new MyGuiControlRotatingWheel(this, new Vector2(-deltaX, deltaY), MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE,
                                                       MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_wheelTexture));

            //  Sometimes we don't want to allow user to cancel pending progress screen
            if (m_enableCancel)
            {
                var cancelButton = new MyGuiControlButton(this, new Vector2(deltaX, deltaY), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                                                          Vector4.One,
                                                          MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel,
                                                          MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick,
                                                          true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
                Controls.Add(cancelButton);
            }
            m_controlsCreated = true;
        }
Пример #10
0
        private MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector4?backgroundColor, StringBuilder toolTip,
                                 MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl,
                                 MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                             * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
        {
            Visible           = true;
            Enabled           = true;
            m_parent          = parent;
            m_position        = position;
            m_backgroundColor = backgroundColor;
            //m_toolTip = toolTip;
            if (toolTip != null)
            {
                m_toolTip = new MyToolTips(toolTip);
            }
            m_controlTexture            = controlTexture;
            m_hoverTexture              = hoverTexture;
            m_pressedTexture            = pressedTexture;
            m_isActiveControl           = isActiveControl;
            m_mouseCursorHoverTexture   = mouseCursorHoverTexture;
            m_mouseCursorPressedTexture = mouseCursorPressedTexture;

            /*
             * m_mouseCursorHoverBitmap = mouseCursorHoverBitmap;
             * m_mouseCursorPressedBitmap = mouseCursorPressedBitmap;
             */
        }
        public MyMultipleUseObjective(
            MyTextsWrapperEnum name,
            MyMissionID id,
            MyTextsWrapperEnum description,
            MyTexture2D icon,
            MyMission parentMission,
            MyMissionID[] requiredMissions,
            MyTextsWrapperEnum notificationText,
            MyTextsWrapperEnum useCaption,
            MyTextsWrapperEnum useText,
            int requiredTime,
            List <uint> MissionEntityIDs,
            MyUseObjectiveType objectiveType = MyUseObjectiveType.Hacking,


            MyDialogueEnum?startDialogId = null)
            : base(name, id, description, icon, parentMission, requiredMissions, null, MissionEntityIDs, startDialogId: startDialogId)
        {
            m_notificationText = notificationText;
            m_useText          = useText;
            m_useCaption       = useCaption;
            m_requiredTime     = requiredTime;

            m_objectiveType = objectiveType;
        }
Пример #12
0
 // Image without text constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                           MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
                           OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType)
     : this(parent, position,
            size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, tooltip, onButtonClick, canHandleKeyboardInput, align, implementedFeature,
            canHandleKeyboardActiveControl, highlightType, null, null /*, null, null*/)
 {
 }
Пример #13
0
 public MyGuiControlPanel(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, MyTexture2D texture,
                          MyTexture2D hoverTexture, MyTexture2D pressedTexture, int borderSize, Vector4 borderColor, StringBuilder toolTip)
     : base(parent, position, size, backgroundColor, toolTip, texture, hoverTexture, pressedTexture, false)
 {
     Visible       = true;
     m_borderSize  = borderSize;
     m_borderColor = borderColor;
 }
Пример #14
0
 public static void LoadTextures()
 {
     CircleR200   = new MyTexture2D("GameEngine\\Textures\\CircleR200");
     CircleR30    = new MyTexture2D("GameEngine\\Textures\\CircleR30");
     Box2         = new MyTexture2D("GameEngine\\Textures\\Box2");
     StripPattern = new MyTexture2D("GameEngine\\Textures\\StripePattern");
     Triangle60   = new MyTexture2D("GameEngine\\Textures\\Triangle60");
 }
Пример #15
0
 public MyGuiControlPanel(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                          MyTexture2D texture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, MyTexture2D shadowTexture,
                          MyGuiDrawAlignEnum align)
     : base(parent, position, size, backgroundColor, new StringBuilder(),
            texture, hoverTexture, pressedTexture, false)
 {
     Visible = true;
 }
Пример #16
0
 public MyActorProperties(MyTextsWrapperEnum displayName, MyTexture2D avatarImage, MyTexture2D icon, MyMwcObjectBuilder_FactionEnum faction, string name = null)
 {
     Name        = name;
     DisplayName = displayName;
     AvatarImage = avatarImage;
     Icon        = icon;
     Faction     = faction;
 }
Пример #17
0
        //  Reset the font when the device has changed
        void Reset(Device device)
        {
            foreach (KeyValuePair <int, MyBitmapInfo> kv in m_dictBitmapID2BitmapInfo)
            {
                MyTexture2D tex = MyTextureManager.GetTexture <MyTexture2D>(m_strPath + kv.Value.strFilename, null, LoadingMode.Immediate, TextureFlags.IgnoreQuality);

                m_dictBitmapID2Texture[kv.Key] = tex;
            }
        }
Пример #18
0
 public MyGuiControlListboxItem(int key, MyColoredText coloredText, MyTexture2D icon, MyToolTips toolTip)
 {
     Key             = key;
     Icon            = icon;
     ColoredText     = coloredText;
     ToolTip         = toolTip;
     BackgroundColor = Vector4.One;
     Enabled         = true;
 }
Пример #19
0
 // Image without text constructor and with custom mouse cursor textures
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                           MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
                           OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl,
                           MyGuiControlHighlightType highlightType, MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                                                                * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
     : this(parent, position, size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, onButtonClick, canHandleKeyboardInput, align, tooltip, implementedFeature,
            canHandleKeyboardActiveControl, highlightType, mouseCursorHoverTexture, mouseCursorPressedTexture /*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
 }
 protected MyGuiControlEntityUse(IMyGuiControlsParent parent, Vector2 size, MyEntity entity, MyTexture2D texture)
     : base(parent, Vector2.Zero, size, Vector4.One, new StringBuilder(entity.DisplayName), MyGuiManager.GetHubItemBackground())
 {
     m_entity          = entity;
     m_topLeftPosition = -m_size.Value / 2f + new Vector2(0.025f, 0.025f);
     Controls.Add(new MyGuiControlLabel(this, m_topLeftPosition + new Vector2(0.063f, 0.0f), null, GetEntityName(entity), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));
     LoadControls();
     m_texture = texture;
 }
Пример #21
0
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4?backgroundColor, StringBuilder toolTip,
                         MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl, MyGuiControlHighlightType highlightType,
                         MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                     * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/) :
     this(parent, position, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, mouseCursorHoverTexture, mouseCursorPressedTexture /*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
     m_size          = size;
     m_highlightType = highlightType;
 }
Пример #22
0
        private static MyTextureAtlas LoadTextureAtlas(string textureDir, string atlasFile)
        {
            var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile);

            if (!File.Exists(fsPath))
            {
                MyLog.Default.WriteLine("Warning: " + atlasFile + " not found.");
                return(null);
            }

            try
            {
                var atlas = new MyTextureAtlas(64);

                using (var file = MyFileSystem.OpenRead(fsPath))
                    using (StreamReader sr = new StreamReader(file))
                    {
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();

                            if (line.StartsWith("#"))
                            {
                                continue;
                            }
                            if (line.Trim(' ').Length == 0)
                            {
                                continue;
                            }

                            string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);

                            string name      = parts[0];
                            string atlasName = parts[1];

                            Vector4 uv = new Vector4(
                                Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture));

                            MyTexture2D        atlasTexture = MyTextureManager.GetTexture <MyTexture2D>(textureDir + atlasName);
                            MyTextureAtlasItem item         = new MyTextureAtlasItem(atlasTexture, uv);
                            atlas.Add(name, item);
                        }
                    }

                return(atlas);
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Warning: " + e.ToString());
            }

            return(null);
        }
Пример #23
0
        public void Append(MyTexture2D texture, Vector2 size, Vector4 color)
        {
            MyRichLabelImage image = new MyRichLabelImage(texture, size, color);

            if (image.GetSize().X > m_currentLineRestFreeSpace)
            {
                AppendLine();
            }
            AppendPart(new MyRichLabelImage(texture, size, color));
        }
 public MyGuiControlRotatingWheel(IMyGuiControlsParent parent, Vector2 position, Vector4 color, float scale, MyGuiDrawAlignEnum align, MyTexture2D texture)
     : base(parent, position, null, null, null, false)
 {
     m_rotatingAngle = MyMwcUtils.GetRandomRadian();
     m_color         = color;
     m_wheelScale    = scale;
     //m_scale = 4;
     m_align   = align;
     m_texture = texture;
 }
        ScreenTexture CreateTexture(MyTexture2D texture)
        {
            var screenTexture = new ScreenTexture(Camera, Vector2.Zero, BasicSize, this, texture);

            screenTexture.ReferenceVisuals(this);
            AddNestedObject(screenTexture, 3);
            OnBasicSizeChanged += newSize => screenTexture.BasicSize = newSize;
            //OnBasicPositionChanged += newPosition => screenTexture.BasicPosition = newPosition;
            return(screenTexture);
        }
Пример #26
0
 public MyMessageBoxConfiguration(MyTexture2D texture, Vector4 textColor, Vector4 backgroundColor, Vector4 buttonColor, Vector4 rotatingWheelColor, Vector4 interferenceVideoColor, MyGuiFont font, MyTexture2D buttonTexture)
 {
     Texture                = texture;
     TextColor              = textColor;
     BackgroundColor        = backgroundColor;
     ButtonColor            = buttonColor;
     RotatingWheelColor     = rotatingWheelColor;
     InterferenceVideoColor = interferenceVideoColor;
     Font          = font;
     ButtonTexture = buttonTexture;
 }
Пример #27
0
        public MyTreeViewItem AddItem(StringBuilder text, MyTexture2D icon, Vector2 iconSize, MyTexture2D expandIcon, MyTexture2D collapseIcon, Vector2 expandIconSize)
        {
            //System.Diagnostics.Trace.Assert(m_items.TrueForAll(a => a.GetIconSize() == iconSize));

            var item = new MyTreeViewItem(text, icon, iconSize, expandIcon, collapseIcon, expandIconSize);

            item.TreeView = TreeView;
            m_items.Add(item);
            item.Parent = this;
            return(item);
        }
 public MyGuiControlListboxScrollBar(IMyGuiControlsParent parent, Vector2 position, Vector2 size, Vector4?backgroundColor, Color sliderColor, MyScrollDirection scrollDirection, MyTexture2D texture)
 {
     m_parent                 = parent;
     m_position               = position;
     m_size                   = size;
     m_scrollDirection        = scrollDirection;
     m_texture                = texture;
     m_isScrollSliderDragging = false;
     InitializeScrollBar(1.0f);
     SetScrollValue(1.0f);
 }
Пример #29
0
 public MyTreeViewItem(StringBuilder text, MyTexture2D icon, Vector2 iconSize, MyTexture2D expandIcon, MyTexture2D collapseIcon, Vector2 expandIconSize)
 {
     Visible          = true;
     Enabled          = true;
     Text             = text;
     m_icon           = icon;
     m_expandIcon     = expandIcon;
     m_collapseIcon   = collapseIcon;
     m_iconSize       = iconSize;
     m_expandIconSize = expandIconSize;
 }
Пример #30
0
 public MySabotageSubmission(
     StringBuilder name,
     MyMissionID id,
     StringBuilder description,
     MyTexture2D icon,
     MyMission parentMission,
     MyMissionID[] requiredMissions,
     MyMissionLocation location)
     : this(name, id, description, icon, parentMission, requiredMissions, location, MyTextsWrapperEnum.NotificationSabotageSubmission)
 {
 }
        internal static void AddSingleSprite(MyTexture2D texture, MyVertexFormatSpritePositionTextureColor sprite)
        {
            if (m_currentInnerBatch.texture != texture.ShaderView)
            {
                if (m_currentInnerBatch.texture != null)
                    m_currentInnerBatch.Commit();

                m_currentInnerBatch = CreateSpritesBatch();
                m_currentInnerBatch.startInstance = m_spriteInstanceList.Count;
                m_currentInnerBatch.SetTexture(texture);
            }

            m_currentInnerBatch.AddSprite(sprite);
        }
 internal void SetTexture(MyTexture2D texture)
 {
     this.texture = texture.ShaderView;
 }
        internal static void AddSingleSprite(MyTexture2D texture, Vector2 position, Rectangle? sourceRectangle, float scale, Color color)
        {
            Vector2 clipOffset;
            Vector2 clipScale;

            RectangleF destination;
            if (sourceRectangle != null)
            {
                destination = new RectangleF(position.X, position.Y, scale * sourceRectangle.Value.Width,
                    scale * sourceRectangle.Value.Height);
            }
            else
            {
                destination = new RectangleF(position.X, position.Y, scale, scale);
            }

            CalculateSpriteClipspace(destination,
                MyRender.ViewportResolution,
                out clipOffset, out clipScale);

            Vector2 texOffset = Vector2.Zero;
            Vector2 texScale = Vector2.One;

            if (sourceRectangle != null)
            {
                Vector2 textureSize = texture != null ? texture.Size : Vector2.Zero;

                Vector2 leftTop = new Vector2(sourceRectangle.Value.Left, sourceRectangle.Value.Top);
                Vector2 size = new Vector2(sourceRectangle.Value.Width, sourceRectangle.Value.Height);
                texOffset = leftTop / textureSize;
                texScale = size / textureSize;
            }

            AddSingleSprite(texture, new MyVertexFormatSpritePositionTextureColor(
                new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
                new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
                new Byte4(color.R, color.G, color.B, color.A)));
        }
Пример #34
0
    void Start()
    {
        Debug.Log("START: " + footstepInterval);

        _game = GameObject.Find(" GameController").GetComponent<GameController>();
        _wave = GameObject.Find(" GameController").GetComponent<WaveController>();
        _weapon = GetComponentInChildren<WeaponController>();
        _overviewCamera = GameObject.Find("Minimap Camera").GetComponent<CameraController>();

        Screen.showCursor = true;

        Texture2D left = Resources.Load("Textures/Weapon/TakeDamage0", typeof(Texture2D)) as Texture2D;
        Texture2D right = Resources.Load("Textures/Weapon/TakeDamage1", typeof(Texture2D)) as Texture2D;
        Color c = new Color(0.8f, 0, 0, 1f);
        leftDamage = new MyTexture2D(left,
            new Rect((Screen.width / 2) - left.width, (Screen.height - left.height) / 2, left.width, left.height), c);
        rightDamage = new MyTexture2D(right,
             new Rect(Screen.width / 2, (Screen.height - right.height) / 2, right.width, right.height), c);

        // Player Variables
        _life = MAX_LIFE;

        AudioSource[] a = GetComponents<AudioSource>();
        footstepsAudio = a[0];
        footstepsAudio.volume = 0.25f;
        jumpingAudio = a[1];
        voiceAudio = a[2];

        _motor = GetComponent<CharacterMotor>();
        //		footsteps = new AudioClip[1];
        //		footsteps[0] = Resources.Load("Sound/Player/jump") as AudioClip;
        footsteps = new AudioClip[3];
        footsteps[0] = Resources.Load("Sound/Player/foot_1") as AudioClip;
        footsteps[1] = Resources.Load("Sound/Player/foot_2") as AudioClip;
        footsteps[2] = Resources.Load("Sound/Player/foot_3") as AudioClip;
        onJumpAudio = Resources.Load("Sound/Player/Lilith_jump") as AudioClip;
        onLandAudio = Resources.Load("Sound/Player/Lilith_land") as AudioClip;
        onOutOfAmmo = Resources.Load("Sound/Player/Lilith_outofammo") as AudioClip;
    }