public MyGuiScreenProgress(StringBuilder text, MyStringId? cancelText = null)
     : base(MySpaceTexts.Blank, cancelText)
 {
     // Copy
     Text = new StringBuilder(text.Length);
     Text.AppendStringBuilder(text);
 }
Ejemplo n.º 2
0
        public void AddAction(MyStringId actionId, MethodInfo methodInfo, bool returnsRunning, Func<IMyBot, object[], MyBehaviorTreeState> action)
        {
            if (!m_actions.ContainsKey(actionId))
                AddBotActionDesc(actionId);

            Debug.Assert(m_actions[actionId].Action == null, "Adding a bot action under the same name!");

            var actionDesc = m_actions[actionId];
            var parameters = methodInfo.GetParameters();
            actionDesc.Action = action;
            actionDesc.ActionParams = new object[parameters.Length];
            actionDesc.ParametersDesc = new Dictionary<int, MyTuple<Type, MyMemoryParameterType>>();
            actionDesc.ReturnsRunning = returnsRunning;
            for (int i = 0; i < parameters.Length; i++)
            {
                var paramAttrs = Attribute.GetCustomAttributes(parameters[i], true);
                foreach (var paramAttr in paramAttrs)
                {
                    if (paramAttr is BTMemParamAttribute)
                    {
                        var memParam = paramAttr as BTMemParamAttribute;
                        actionDesc.ParametersDesc.Add(i, new MyTuple<Type, MyMemoryParameterType>(parameters[i].ParameterType.GetElementType(), memParam.MemoryType));
                    }
                }
            }
        }
 private static void AddId(Type type, MyStringId id)
 {
     Debug.Assert(!m_idToType.ContainsKey(id));
     Debug.Assert(!m_typeToId.ContainsKey(type));
     m_idToType[id] = type;
     m_typeToId[type] = id;
 }
 public MyGuiScreenProgressAsync(MyStringId text, MyStringId? cancelText, Func<IMyAsyncResult> beginAction, Action<IMyAsyncResult, MyGuiScreenProgressAsync> endAction)
     : base(text, cancelText)
 {
     FriendlyName = "MyGuiScreenProgressAsync";
     m_beginAction = beginAction;
     m_endAction = endAction;
 }
        public override void Construct(MyObjectBuilder_BehaviorTreeNode nodeDefinition, MyBehaviorTree.MyBehaviorTreeDesc treeDesc)
        {
            base.Construct(nodeDefinition, treeDesc);

            var ob = (MyObjectBuilder_BehaviorTreeActionNode)nodeDefinition;
            Debug.Assert(!string.IsNullOrEmpty(ob.ActionName), "Action name was not provided");
            if (!string.IsNullOrEmpty(ob.ActionName))
            {
                m_actionName = MyStringId.GetOrCompute(ob.ActionName);
                treeDesc.ActionIds.Add(m_actionName);
            }

            if (ob.Parameters != null)
            {
                var obParameters = ob.Parameters;
                m_parameters = new object[obParameters.Length];
                for (int i = 0; i < m_parameters.Length; i++)
                {
                    var obParam = obParameters[i];
                    if (obParam is MyObjectBuilder_BehaviorTreeActionNode.MemType)
                    {
                        string value = (string)obParam.GetValue();
                        m_parameters[i] = (Boxed<MyStringId>)MyStringId.GetOrCompute(value);
                    }
                    else
                    {
                        m_parameters[i] = obParam.GetValue();
                    }
                }
            }
        }
        public MyGuiScreenTriggerTime(MyTrigger trg, MyStringId labelText)
            : base(trg, new Vector2(WINSIZEX + 0.1f, WINSIZEY))
        {
            float left = m_textboxMessage.Position.X-m_textboxMessage.Size.X/2;
            float top = -WINSIZEY / 2f + MIDDLE_PART_ORIGIN.Y;
            m_labelTime = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: new Vector2(0.013f, 0.035f),
                text: MyTexts.Get(labelText).ToString()//text: MyTexts.Get(MySpaceTexts.GuiTriggerTimeLimit).ToString()
            );
            left += m_labelTime.Size.X + spacingH;
            m_textboxTime = new MyGuiControlTextbox()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(0.05f, 0.035f),
                Type = MyGuiControlTextboxType.DigitsOnly,
                Name = "time"
            };
            m_textboxTime.TextChanged += OnTimeChanged;

            Controls.Add(m_labelTime);
            Controls.Add(m_textboxTime);

        }
 public static MyGuiDescriptor GetGameControlHelper(MyStringId controlHelper)
 {
     MyGuiDescriptor ret;
     if (m_gameControlHelpers.TryGetValue(controlHelper, out ret))
         return ret;
     else
         return null;
 }
        public void AddItemDefinition(MyStringId definition)
        {
            System.Diagnostics.Debug.Assert(!m_itemDefinitions.Contains(definition));
            if (m_itemDefinitions.Contains(definition)) return;

            m_itemDefinitions.Add(definition);
            m_definitionList.Add(definition);
        }
Ejemplo n.º 9
0
 public MyGuiScreenDialogText(string initialValue = null, MyStringId? caption = null)
 {
     m_value = initialValue ?? string.Empty;
     CanHideOthers = false;
     EnabledBackgroundFade = true;
     m_caption = caption ?? MySpaceTexts.DialogAmount_SetValueCaption;
     RecreateControls(true);
 }
Ejemplo n.º 10
0
 public LocalizationFileInfo(string language, string path, ulong id, bool isDefault, MyStringId bundle)
 {
     Language = language;
     Path = path;
     Bundle = bundle;
     Id = id;
     IsDefault = isDefault;
 }
Ejemplo n.º 11
0
        public void AddPostAction(MyStringId actionId, Action<IMyBot> action)
        {
            if (!m_actions.ContainsKey(actionId))
                AddBotActionDesc(actionId);

            Debug.Assert(m_actions[actionId].PostAction == null, "Adding a bot post action under the same name!");

            m_actions[actionId].PostAction = action;
        }
Ejemplo n.º 12
0
        public void AddInitAction(MyStringId actionName, Action<IMyBot> action)
        {
            if (!m_actions.ContainsKey(actionName))
                AddBotActionDesc(actionName);

            Debug.Assert(m_actions[actionName].InitAction == null, "Adding a bot init action under the same name!");

            m_actions[actionName].InitAction = action;
        }
 public ControlWithDescription(MyStringId control)
 {
     MyControl c = MyInput.Static.GetGameControl(control);
     BoundButtons = null;
     c.AppendBoundButtonNames(ref BoundButtons, unassignedText: MyInput.Static.GetUnassignedName());
     Description = MyTexts.Get(c.GetControlDescription() ?? c.GetControlName());
     LeftFont = MyFontEnum.Red;
     RightFont = MyFontEnum.White;
 }
Ejemplo n.º 14
0
        public void PlayMusic(MyStringId transition,MyStringId category, bool loop)
        {
            var msg = new PlayMusicMsg();
            msg.Transition = transition;
            msg.Category = category;
            msg.Loop = loop;

            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }
 public MyControllableEntityControlHelper(
     MyStringId controlId,
     Action<IMyControllableEntity> action,
     Func<IMyControllableEntity, bool> valueGetter,
     MyStringId label,
     MySupportKeysEnum supportKeys = MySupportKeysEnum.NONE)
     : this(controlId, action, valueGetter, label, MySpaceTexts.ControlMenuItemValue_On, MySpaceTexts.ControlMenuItemValue_Off, supportKeys)
 {
 }
 public MyHudMissingComponentNotification(MyStringId text,
     int disapearTimeMs           = 2500,
     MyFontEnum font              = MyFontEnum.White,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
     int priority                 = 0,
     MyNotificationLevel level    = MyNotificationLevel.Normal)
     : base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
 public virtual bool CanStack(MyObjectBuilderType typeId, MyStringId subtypeId, MyItemFlags flags)
 {
     if (flags == Flags &&
         typeId == TypeId &&
         subtypeId == SubtypeId)
     {
         return true;
     }
     return false;
 }
Ejemplo n.º 18
0
        public MyInventoryConstraint(MyStringId description, string icon = null, bool whitelist = true)
        {
            Icon = icon;
            m_useDefaultIcon = icon == null;

            Description = MyTexts.GetString(description);
            m_constrainedIds = new HashSet<MyDefinitionId>();
            m_constrainedTypes = new HashSet<MyObjectBuilderType>();
            IsWhitelist = whitelist;
        }
 public MyGeneratedBlockLocation(MySlimBlock refBlock, MyCubeBlockDefinition blockDefinition, Vector3I position, MyBlockOrientation orientation, ushort? blockIdInCompound = null, MyGridInfo gridInfo = null)
 {
     RefBlock = refBlock;
     BlockDefinition = blockDefinition;
     Position = position;
     Orientation = orientation;
     BlockIdInCompound = blockIdInCompound;
     GridInfo = gridInfo;
     GeneratedBlockType = MyStringId.NullOrEmpty;
 }
        public MyEnvironmentItemDefinition GetItemDefinition(MyStringId subtypeId)
        {
            MyEnvironmentItemDefinition retval = null;

            MyDefinitionId defId = new MyDefinitionId(m_itemDefinitionType, subtypeId);
            MyDefinitionManager.Static.TryGetDefinition(defId, out retval);
            Debug.Assert(retval != null, "Could not find environment item with definition id " + defId);

            return retval;
        }
Ejemplo n.º 21
0
 private void PlaySound(MyStringId soundId)
 {
     if (m_sound != null && m_sound.IsPlaying)
     {
         var effect = MyAudio.Static.ApplyEffect(m_sound, MyStringId.GetOrCompute("CrossFade"), new MyStringId[] { soundId }, 2000);
         m_sound = effect.OutputSound;
     }
     else
         m_sound = MyAudio.Static.PlaySound(soundId, null, MySoundDimensions.D2);
 }
 public MyGeneratedBlockLocation(MySlimBlock refBlock, MyCubeBlockDefinition blockDefinition, Vector3I position, Vector3I forward, Vector3I up, ushort? blockIdInCompound = null, MyGridInfo gridInfo = null)
 {
     RefBlock = refBlock;
     BlockDefinition = blockDefinition;
     Position = position;
     Orientation = new MyBlockOrientation(Base6Directions.GetDirection(ref forward), Base6Directions.GetDirection(ref up));
     BlockIdInCompound = blockIdInCompound;
     GridInfo = gridInfo;
     GeneratedBlockType = MyStringId.NullOrEmpty;
 }
Ejemplo n.º 23
0
 public static void RequestThrow(MyObjectBuilder_CubeGrid grid, Vector3D position, Vector3D linearVelocity, float mass, MyStringId throwSound)
 {
     ThrowMsg msg = new ThrowMsg();
     msg.Grid = grid;
     msg.Position = position;
     msg.LinearVelocity = linearVelocity;
     msg.Mass = mass;
     msg.ThrowSound = throwSound;
     MySession.Static.SyncLayer.SendMessageToServer(ref msg);
 }
Ejemplo n.º 24
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            var ob = builder as MyObjectBuilder_ScenarioDefinition;

            AsteroidClustersEnabled = ob.AsteroidClusters.Enabled;
            AsteroidClustersOffset  = ob.AsteroidClusters.Offset;
            CentralClusterEnabled   = ob.AsteroidClusters.CentralCluster;
            CreativeDefaultToolbar  = ob.CreativeDefaultToolbar;
            SurvivalDefaultToolbar  = ob.SurvivalDefaultToolbar;
            MainCharacterModel = MyStringId.GetOrCompute(ob.MainCharacterModel);

            GameDate = new DateTime(ob.GameDate);

            SunDirection = ob.SunDirection;
            
            if (ob.PossibleStartingStates != null && ob.PossibleStartingStates.Length > 0)
            {
                PossiblePlayerStarts = new MyWorldGeneratorStartingStateBase[ob.PossibleStartingStates.Length];
                for (int i = 0; i < ob.PossibleStartingStates.Length; ++i)
                {
                    PossiblePlayerStarts[i] = MyWorldGenerator.StartingStateFactory.CreateInstance(ob.PossibleStartingStates[i]);
                }
            }

            if (ob.WorldGeneratorOperations != null && ob.WorldGeneratorOperations.Length > 0)
            {
                WorldGeneratorOperations = new MyWorldGeneratorOperationBase[ob.WorldGeneratorOperations.Length];
                for (int i = 0; i < ob.WorldGeneratorOperations.Length; ++i)
                {
                    WorldGeneratorOperations[i] = MyWorldGenerator.OperationFactory.CreateInstance(ob.WorldGeneratorOperations[i]);
                }
            }

            if (ob.CreativeModeWeapons != null && ob.CreativeModeWeapons.Length > 0)
            {
                CreativeModeWeapons = new MyStringId[ob.CreativeModeWeapons.Length];
                for (int i = 0; i < ob.CreativeModeWeapons.Length; ++i)
                {
                    CreativeModeWeapons[i] = MyStringId.GetOrCompute(ob.CreativeModeWeapons[i]);
                }
            }

            if (ob.SurvivalModeWeapons != null && ob.SurvivalModeWeapons.Length > 0)
            {
                SurvivalModeWeapons = new MyStringId[ob.SurvivalModeWeapons.Length];
                for (int i = 0; i < ob.SurvivalModeWeapons.Length; ++i)
                {
                    SurvivalModeWeapons[i] = MyStringId.GetOrCompute(ob.SurvivalModeWeapons[i]);
                }
            }

            WorldBoundaries.Min = ob.WorldBoundaries.Min;
            WorldBoundaries.Max = ob.WorldBoundaries.Max;
        }
Ejemplo n.º 25
0
 public MyEffectInstance CreateEffect(IMySourceVoice input, MyStringId effect, MySourceVoice[] cues = null, float? duration = null)
 {
     if(!m_effects.ContainsKey(effect))
     {
         Debug.Fail(string.Format("Effect not found: {0}", effect.ToString()));
         return null;
     }
     var instance = new MyEffectInstance(m_effects[effect], input, cues, duration, m_engine);
     m_activeEffects.Add(instance);
     return instance;
 }
Ejemplo n.º 26
0
 public void Flush()
 {
     m_cue = MyStringId.NullOrEmpty;
     m_voice.Stop();
     m_voice.FlushSourceBuffers();
     for (int i = 0; i < m_loopBuffers.Length; i++ )
         m_loopBuffers[i] = null;
     m_isPlaying = false;
     m_isPaused = false;
     m_isLoopable = false;
     m_currentDescriptor = null;
 }
        void StateChanged(IMyLandingGear gear, LandingGearMode oldMode)
        {
            if (oldMode == LandingGearMode.ReadyToLock && gear.LockMode == LandingGearMode.Locked)
                HudMessage = MySpaceTexts.NotificationLandingGearSwitchLocked;
            else if (oldMode == LandingGearMode.Locked && gear.LockMode == LandingGearMode.Unlocked)
                HudMessage = MySpaceTexts.NotificationLandingGearSwitchUnlocked;
            else //if (oldMode == LandingGearMode.ReadyToLock && gear.LockMode == LandingGearMode.Unlocked)
                HudMessage = MyStringId.NullOrEmpty;

            m_gearStates[(int)oldMode].Remove(gear);
            m_gearStates[(int)gear.LockMode].Add(gear);
        }
 /// <param name="min">Minimum allowed amount.</param>
 /// <param name="max">Maximum allowed amount.</param>
 /// <param name="minMaxDecimalDigits">Number of digits used from min and max value. Decimal places beyond this value are cut off (no rounding occurs).</param>
 /// <param name="parseAsInteger">True will ensure parsing as integer number (you cannot input decimal values). False will parse as decimal number.</param>
 public MyGuiScreenDialogAmount(float min, float max, int minMaxDecimalDigits = 3, bool parseAsInteger = false, float? defaultAmount = null, MyStringId? caption = null) :
     base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
 {
     CanHideOthers = false;
     EnabledBackgroundFade = true;
     m_textBuffer = new StringBuilder();
     m_amountMin = min;
     m_amountMax = max;
     m_amount = defaultAmount.HasValue? defaultAmount.Value : max;
     m_parseAsInteger = parseAsInteger;
     m_caption = caption ?? MySpaceTexts.DialogAmount_AddAmountCaption;
     RecreateControls(true);
 }
Ejemplo n.º 29
0
        // Removes a delegate from an EventKey (if it exists) and 
        // removes the EventKey -> Delegate mapping the last delegate is removed
        public void Remove(MyStringId eventKey, Delegate handler)
        {
            // Call TryGetValue to ensure that an exception is not thrown if
            // attempting to remove a delegate from an EventKey not in the set
            Delegate d;
            if (m_events.TryGetValue(eventKey, out d))
            {
                d = Delegate.Remove(d, handler);

                // If a delegate remains, set the new head else remove the EventKey
                if (d != null) m_events[eventKey] = d;
                else m_events.Remove(eventKey);
            }
        }
Ejemplo n.º 30
0
 protected MyGuiControlButton CreateButton(float usableWidth, StringBuilder text, Action<MyGuiControlButton> onClick, bool enabled = true, MyStringId? tooltip = null, float textScale = 1f)
 {
     var button = AddButton(text, onClick);
     button.VisualStyle = MyGuiControlButtonStyleEnum.Rectangular;
     button.TextScale = textScale;
     button.Size = new Vector2(usableWidth, button.Size.Y);
     button.Position = button.Position + new Vector2(-0.04f / 2.0f, 0.0f);
     button.Enabled = enabled;
     if (tooltip != null)
     {
         button.SetToolTip(tooltip.Value);
     }
     return button;
 }
Ejemplo n.º 31
0
 public bool ContainsAction(MyStringId actionId)
 {
     return(m_actions[actionId].Action != null);
 }
Ejemplo n.º 32
0
 public bool ContainsActionDesc(MyStringId actionId)
 {
     return(m_actions.ContainsKey(actionId));
 }
Ejemplo n.º 33
0
 public bool ReturnsRunning(MyStringId actionId)
 {
     return(m_actions[actionId].ReturnsRunning);
 }
Ejemplo n.º 34
0
 internal static MyMeshMaterialId GetMaterialId(string name)
 {
     return(MaterialNameIndex.Get(MyStringId.GetOrCompute(name)));
 }
 public MyTerminalControlLabel(MyStringId label)
     : base("Label")
 {
     Label = label;
 }
Ejemplo n.º 36
0
        private void Refresh()
        {
            var time = (Stopwatch.GetTimestamp() - startTimestamp) / (double)Stopwatch.Frequency;

            Stats.Timing.Write("IntegrityRunTime: {0}s", (float)time, VRage.Stats.MyStatTypeEnum.CurrentValue | VRage.Stats.MyStatTypeEnum.FormatFlag, 100, 1);

            var grids = MyEntities.GetEntities().OfType <MyCubeGrid>();

            if (m_grids.Count == 0)
            {
                startTimestamp = Stopwatch.GetTimestamp();
            }

            foreach (var gr in m_grids.ToArray())
            {
                if (gr.Value.m_grid.Closed)
                {
                    m_grids.Remove(gr.Value.m_grid);
                }
            }

            foreach (var g in grids)
            {
                StructureData structure;
                if (!m_grids.TryGetValue(g, out structure))
                {
                    structure        = new StructureData();
                    structure.m_grid = g;
                    m_grids[g]       = structure;
                }

                bool cubeChanged = false;

                foreach (var c in structure.Lookup)
                {
                    if (g.GetCubeBlock(c.Key) == null)
                    {
                        cubeChanged = true;
                        m_removeList.Add(c.Key);
                    }
                }

                foreach (var x in m_removeList)
                {
                    structure.Lookup.Remove(x);
                }
                m_removeList.Clear();

                foreach (var b in g.GetBlocks())
                {
                    bool isStatic;

                    if (b.BlockDefinition.DisplayNameEnum == MyStringId.GetOrCompute("DisplayName_Block_HeavyArmorBlock"))
                    {
                        isStatic = true;
                    }
                    else if (b.BlockDefinition.DisplayNameEnum == MyStringId.GetOrCompute("DisplayName_Block_LightArmorBlock"))
                    {
                        isStatic = false;
                    }
                    else
                    {
                        continue;
                    }

                    Element cube;
                    if (!structure.Lookup.TryGetValue(b.Position, out cube))
                    {
                        cubeChanged = true;
                        cube        = new Element(isStatic);
                        if (!isStatic)
                        {
                            cube.CurrentOffset = 0.05f;
                        }
                        structure.Lookup[b.Position] = cube;
                    }
                }

                if (cubeChanged)
                {
                    var copy = structure.Lookup.ToDictionary(s => s.Key, v => v.Value);
                    structure.Lookup.Clear();

                    Stack <KeyValuePair <Vector3I, Element> > tmp = new Stack <KeyValuePair <Vector3I, Element> >();

                    // Merge everything possible
                    while (copy.Count > 0)
                    {
                        var first = copy.First();
                        copy.Remove(first.Key);

                        if (!first.Value.IsStatic)
                        {
                            structure.Elements.Add(first.Value);
                        }

                        tmp.Push(first);
                        while (tmp.Count > 0)
                        {
                            var item = tmp.Pop();
                            first.Value.Cubes.Add(item.Key);
                            structure.Lookup.Add(item.Key, first.Value);

                            if (first.Value.IsStatic)
                            {
                                continue;
                            }

                            AddNeighbor(tmp, copy, item.Key + Vector3I.UnitX);
                            AddNeighbor(tmp, copy, item.Key + Vector3I.UnitY);
                            AddNeighbor(tmp, copy, item.Key + Vector3I.UnitZ);
                            AddNeighbor(tmp, copy, item.Key - Vector3I.UnitX);
                            AddNeighbor(tmp, copy, item.Key - Vector3I.UnitY);
                            AddNeighbor(tmp, copy, item.Key - Vector3I.UnitZ);
                        }
                    }
                }
            }
        }
Ejemplo n.º 37
0
        void OnUserJoined(ref JoinResultMsg msg, ulong sender)
        {
            if (msg.JoinResult == JoinResult.OK)
            {
                if (OnJoin != null)
                {
                    OnJoin();
                    OnJoin         = null;
                    m_clientJoined = true;
                }
            }
            else if (msg.JoinResult == JoinResult.NotInGroup)
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                Dispose();

                ulong  groupId   = Server.GetGameTagByPrefixUlong("groupId");
                string groupName = MySteam.API.Friends.GetClanName(groupId);

                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                    messageText: new StringBuilder(string.Format(
                                                       MyTexts.GetString(MySpaceTexts.MultiplayerErrorNotInGroup), groupName)),
                    buttonType: MyMessageBoxButtonsType.YES_NO);
                messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result)
                {
                    if (result == MyGuiScreenMessageBox.ResultEnum.YES)
                    {
                        MySteam.API.OpenOverlayUser(groupId);
                    }
                    ;
                };
                MyGuiSandbox.AddScreen(messageBox);
            }
            else if (msg.JoinResult == JoinResult.BannedByAdmins)
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                Dispose();

                ulong admin = msg.Admin;

                if (admin != 0)
                {
                    var messageBox = MyGuiSandbox.CreateMessageBox(
                        messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                        messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorBannedByAdminsWithDialog),
                        buttonType: MyMessageBoxButtonsType.YES_NO);
                    messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result)
                    {
                        if (result == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            MySteam.API.OpenOverlayUser(admin);
                        }
                        ;
                    };
                    MyGuiSandbox.AddScreen(messageBox);
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorBannedByAdmins)));
                }
            }
            else
            {
                MyStringId resultText = MySpaceTexts.MultiplayerErrorConnectionFailed;

                switch (msg.JoinResult)
                {
                case JoinResult.AlreadyJoined:
                    resultText = MySpaceTexts.MultiplayerErrorAlreadyJoined;
                    break;

                case JoinResult.ServerFull:
                    resultText = MySpaceTexts.MultiplayerErrorServerFull;
                    break;

                case JoinResult.SteamServersOffline:
                    resultText = MySpaceTexts.MultiplayerErrorSteamServersOffline;
                    break;

                case JoinResult.TicketInvalid:
                    resultText = MySpaceTexts.MultiplayerErrorTicketInvalid;
                    break;

                case JoinResult.GroupIdInvalid:
                    resultText = MySpaceTexts.MultiplayerErrorGroupIdInvalid;
                    break;

                case JoinResult.TicketCanceled:
                    resultText = MySpaceTexts.MultiplayerErrorTicketCanceled;
                    break;

                case JoinResult.TicketAlreadyUsed:
                    resultText = MySpaceTexts.MultiplayerErrorTicketAlreadyUsed;
                    break;

                case JoinResult.LoggedInElseWhere:
                    resultText = MySpaceTexts.MultiplayerErrorLoggedInElseWhere;
                    break;

                case JoinResult.NoLicenseOrExpired:
                    resultText = MySpaceTexts.MultiplayerErrorNoLicenseOrExpired;
                    break;

                case JoinResult.UserNotConnected:
                    resultText = MySpaceTexts.MultiplayerErrorUserNotConnected;
                    break;

                case JoinResult.VACBanned:
                    resultText = MySpaceTexts.MultiplayerErrorVACBanned;
                    break;

                case JoinResult.VACCheckTimedOut:
                    resultText = MySpaceTexts.MultiplayerErrorVACCheckTimedOut;
                    break;

                default:
                    System.Diagnostics.Debug.Fail("Unknown JoinResult");
                    break;
                }

                Dispose();
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(resultText)));
                return;
            }
        }
Ejemplo n.º 38
0
        private bool HandleRotationInput(MyStringId context)
        {
            int frameDt = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastInputHandleTime;

            m_lastInputHandleTime += frameDt;

            if (m_activated)
            {
                for (int i = 0; i < 6; ++i)
                {
                    bool standardRotation = MyControllerHelper.IsControl(context, m_rotationControls[i], MyControlStateType.PRESSED);
                    if (standardRotation)
                    {
                        bool newStandardPress = MyControllerHelper.IsControl(context, m_rotationControls[i], MyControlStateType.NEW_PRESSED);
                        bool newPress         = newStandardPress;

                        int axis      = -1;
                        int direction = m_rotationDirections[i];

                        //if (MyFakes.ENABLE_STANDARD_AXES_ROTATION)
                        //{
                        //    axis = GetStandardRotationAxisAndDirection(i, ref direction);
                        //}

                        if (MyFakes.ENABLE_STANDARD_AXES_ROTATION)
                        {
                            int[] axes = new int[] { 1, 1, 0, 0, 2, 2 };
                            if (m_rotationHints.RotationUpAxis != axes[i])
                            {
                                return(true);
                                //axis = m_rotationHints.RotationUpAxis;
                                //direction *= m_rotationHints.RotationUpDirection;
                            }
                        }
                        //else
                        //{
                        if (i < 2)
                        {
                            axis       = m_rotationHints.RotationUpAxis;
                            direction *= m_rotationHints.RotationUpDirection;
                        }
                        if (i >= 2 && i < 4)
                        {
                            axis       = m_rotationHints.RotationRightAxis;
                            direction *= m_rotationHints.RotationRightDirection;
                        }
                        if (i >= 4)
                        {
                            axis       = m_rotationHints.RotationForwardAxis;
                            direction *= m_rotationHints.RotationForwardDirection;
                        }
                        // }

                        if (axis != -1)
                        {
                            m_rotationHintRotating |= !newPress;
                            RotateAxis(axis, direction, newPress, frameDt);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 39
0
        private static void AddCheckbox(string id, string title, string toolTip, Option opt)
        {
            MyTerminalControlCheckbox <MyTextPanel> control = new MyTerminalControlCheckbox <MyTextPanel>(id, MyStringId.GetOrCompute(title), MyStringId.GetOrCompute(toolTip));

            new ValueSync <bool, TextPanel>(control, (panel) => (panel.m_optionsTerminal & opt) == opt,
                                            (panel, value) => {
                if (value)
                {
                    panel.m_optionsTerminal |= opt;
                }
                else
                {
                    panel.m_optionsTerminal &= ~opt;
                }
            });
            MyTerminalControlFactory.AddControl(control);
        }
Ejemplo n.º 40
0
 public static string GetKeyName(MyStringId control)
 {
     return(MyInput.Static.GetGameControl(control).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard));
 }
Ejemplo n.º 41
0
 public bool AddInstance(Vector3 blockPos, Color color, MyStringId edgeModel, Base27Directions.Direction normal0, Base27Directions.Direction normal1)
 {
     return(m_data.Set(GetIndex(ref blockPos), color, edgeModel, normal0, normal1));
 }
Ejemplo n.º 42
0
        public override void AddControls(List <IMyTerminalControl> controls)
        {
            MyTerminalControlSlider <MyShipController> distance = new MyTerminalControlSlider <MyShipController>("Distance", MyStringId.GetOrCompute("Distance"), MyStringId.GetOrCompute(AddDescription));

            distance.DefaultValue = 0;
            distance.Normalizer   = Normalizer;
            distance.Denormalizer = Denormalizer;
            distance.Writer       = (block, sb) => {
                if (m_distSetting >= minJumpDistance)
                {
                    sb.Append(PrettySI.makePretty(m_distSetting));
                    sb.Append("m");
                }
                else
                {
                    sb.AppendLine("Disable");
                }
            };
            IMyTerminalValueControl <float> valueControler = distance;

            valueControler.Getter = block => m_distSetting;
            valueControler.Setter = (block, value) => m_distSetting = value;
            controls.Add(distance);
        }
Ejemplo n.º 43
0
        public static void DrawBB(MatrixD wm, BoundingBoxD bb, Color color, MySimpleObjectRasterizer raster = MySimpleObjectRasterizer.Wireframe, float thickness = 0.01f)
        {
            var material = MyStringId.GetOrCompute("Square");

            MySimpleObjectDraw.DrawTransparentBox(ref wm, ref bb, ref color, raster, 1, thickness, material, material);
        }
        public static MyGuiScreenStartQuickLaunch CurrentScreen = null;    //  This is always filled with reference to actual instance of this scree. If there isn't, it's null.


        public MyGuiScreenStartQuickLaunch(MyQuickLaunchType quickLaunchType, MyStringId progressText) :
            base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
        {
            m_quickLaunchType = quickLaunchType;
            CurrentScreen     = this;
        }
Ejemplo n.º 45
0
        public static bool PlayContactSound(long entityId, MyStringId strID, Vector3D position, MyStringHash materialA, MyStringHash materialB, float volume = 1, Func <bool> canHear = null, Func <bool> shouldPlay2D = null, MyEntity surfaceEntity = null, float separatingVelocity = 0f)
        {
            ProfilerShort.Begin("GetCue");

            MyEntity firstEntity = null;

            if (!MyEntities.TryGetEntityById(entityId, out firstEntity) || MyMaterialPropertiesHelper.Static == null || MySession.Static == null)
            {
                ProfilerShort.End();
                return(false);
            }

            MySoundPair cue = (firstEntity.Physics != null && firstEntity.Physics.IsStatic == false) ?
                              MyMaterialPropertiesHelper.Static.GetCollisionCueWithMass(strID, materialA, materialB, ref volume, firstEntity.Physics.Mass, separatingVelocity) :
                              MyMaterialPropertiesHelper.Static.GetCollisionCue(strID, materialA, materialB);

            if (cue == null || cue.SoundId == null || MyAudio.Static == null)
            {
                return(false);
            }

            if (separatingVelocity > 0f && separatingVelocity < 0.5f)
            {
                return(false);
            }

            if (!cue.SoundId.IsNull && MyAudio.Static.SourceIsCloseEnoughToPlaySound(position, cue.SoundId))
            {
                MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter();
                if (emitter == null)
                {
                    ProfilerShort.End();
                    return(false);
                }
                ProfilerShort.BeginNextBlock("Emitter lambdas");
                MyAudioComponent.ContactSoundsPool.TryAdd(entityId, 0);
                emitter.StoppedPlaying += (e) =>
                {
                    byte val;
                    MyAudioComponent.ContactSoundsPool.TryRemove(entityId, out val);
                };
                if (MySession.Static.Settings.RealisticSound && MyFakes.ENABLE_NEW_SOUNDS)
                {
                    Action <MyEntity3DSoundEmitter> remove = null;
                    remove = (e) =>
                    {
                        emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Remove(canHear);
                        emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Remove(shouldPlay2D);
                        emitter.StoppedPlaying -= remove;
                    };
                    emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(canHear);
                    emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add(shouldPlay2D);
                    emitter.StoppedPlaying += remove;
                }
                ProfilerShort.BeginNextBlock("PlaySound");
                bool inSpace = MySession.Static.Settings.RealisticSound && MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.LocalCharacter != null && MySession.Static.LocalCharacter.AtmosphereDetectorComp != null && MySession.Static.LocalCharacter.AtmosphereDetectorComp.InVoid;
                if (surfaceEntity != null && !inSpace)
                {
                    emitter.Entity = surfaceEntity;
                }
                else
                {
                    emitter.Entity = firstEntity;
                }
                emitter.SetPosition(position);

                //GR: Changed stopPrevious argument to false due to bugs with explosion sound. May revision to the future
                emitter.PlaySound(cue, false);

                if (emitter.Sound != null)
                {
                    emitter.Sound.SetVolume(emitter.Sound.Volume * volume);
                }

                if (inSpace && surfaceEntity != null)
                {
                    MyEntity3DSoundEmitter emitter2 = MyAudioComponent.TryGetSoundEmitter();
                    if (emitter2 == null)
                    {
                        ProfilerShort.End();
                        return(false);
                    }
                    ProfilerShort.BeginNextBlock("Emitter 2 lambdas");
                    Action <MyEntity3DSoundEmitter> remove = null;
                    remove = (e) =>
                    {
                        emitter2.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Remove(canHear);
                        emitter2.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Remove(shouldPlay2D);
                        emitter2.StoppedPlaying -= remove;
                    };
                    emitter2.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(canHear);
                    emitter2.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add(shouldPlay2D);
                    emitter2.StoppedPlaying += remove;

                    ProfilerShort.BeginNextBlock("PlaySound");
                    emitter2.Entity = surfaceEntity;
                    emitter2.SetPosition(position);

                    emitter2.PlaySound(cue, false);

                    if (emitter2.Sound != null)
                    {
                        emitter2.Sound.SetVolume(emitter2.Sound.Volume * volume);
                    }
                }

                ProfilerShort.End();
                return(true);
            }

            ProfilerShort.End();
            return(false);
        }
 public static MyGuiControlButton ButtonByText(this MyGuiControlElementGroup group, MyStringId stringId)
 {
     return(group.GetInstanceFieldOrThrow <List <MyGuiControlBase> >("m_controlElements").OfType <MyGuiControlButton>()
            .First(x => x.Text == MyTexts.Get(stringId).ToString()));
 }
Ejemplo n.º 47
0
 private void AddBotActionDesc(MyStringId actionId)
 {
     m_actions.Add(actionId, new BotActionDesc());
 }
Ejemplo n.º 48
0
 public void AddPostAction(string actionName, Action <IMyBot> action)
 {
     AddPostAction(MyStringId.GetOrCompute(actionName), action);
 }
Ejemplo n.º 49
0
        public override void UpdateAfterSimulation10()
        {
            try
            {
                if (BuildInfo.instance == null || BuildInfo.instance.isThisDS)
                {
                    return;
                }

                var leakInfo = BuildInfo.instance.leakInfo;

                if (leakInfo == null)
                {
                    return;
                }

                var block = (IMyAirVent)Entity;

                if (init == 0)
                {
                    if (block.CubeGrid.Physics == null || leakInfo == null)
                    {
                        return;
                    }

                    init = 1;
                    block.AppendingCustomInfo += CustomInfo;

                    if (leakInfo.terminalControl == null)
                    {
                        // separator
                        MyAPIGateway.TerminalControls.AddControl <IMyAirVent>(MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyAirVent>(string.Empty));

                        // on/off switch
                        var c = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, IMyAirVent>("FindAirLeak");
                        c.Title = MyStringId.GetOrCompute("Air leak scan");
                        //c.Tooltip = MyStringId.GetOrCompute("Finds the path towards an air leak and displays it as blue lines, for a maximum of " + LeakInfoComponent.MAX_DRAW_SECONDS + " seconds.\nTo find the leak it first requires the air vent to be powered, functional, enabled and the room not sealed.\nIt only searches once and doesn't update in realtime. If you alter the ship or open/close doors you need to start it again.\nThe lines are only shown to the player that requests the air leak scan.\nDepending on ship size the computation might take a while, you can cancel at any time however.\nAll air vents control the same system, therefore you can start it from one and stop it from another.\n\nAdded by the Build Info mod.");
                        c.Tooltip = MyStringId.GetOrCompute("A client-side pathfinding towards an air leak.\nAdded by Build Info mod.");
                        c.OnText  = MyStringId.GetOrCompute("Find");
                        c.OffText = MyStringId.GetOrCompute("Stop");
                        //c.Enabled = Terminal_Enabled;
                        c.SupportsMultipleBlocks = false;
                        c.Setter = Terminal_Setter;
                        c.Getter = Terminal_Getter;
                        MyAPIGateway.TerminalControls.AddControl <IMyAirVent>(c);
                        leakInfo.terminalControl = c;
                    }
                }

                if (init < 2 && block.IsFunctional) // needs to be functional to get the dummy from the main model
                {
                    init = 2;
                    const string DUMMY_NAME = "vent_001"; // HACK hardcoded from MyAirVent.VentDummy property

                    var dummies = leakInfo.dummies;
                    dummies.Clear();

                    IMyModelDummy dummy;
                    if (block.Model.GetDummies(dummies) > 0 && dummies.TryGetValue(DUMMY_NAME, out dummy))
                    {
                        dummyLocation = dummy.Matrix.Translation;
                    }

                    dummies.Clear();
                }

                if (++skip > 6) // every second
                {
                    skip = 0;

                    // clear the air leak visual display or stop the running thread if the air vent's room is sealed.
                    if (leakInfo.usedFromVent == block && leakInfo.status != LeakInfo.Status.IDLE && block.CanPressurize)
                    {
                        leakInfo.ClearStatus();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 50
0
 public void AddAction(string actionName, MethodInfo methodInfo, bool returnsRunning, Func <IMyBot, object[], MyBehaviorTreeState> action)
 {
     AddAction(MyStringId.GetOrCompute(actionName), methodInfo, returnsRunning, action);
 }
Ejemplo n.º 51
0
 public static StringBuilder AppendFormat(this StringBuilder stringBuilder, MyStringId textEnum, object arg0)
 {
     return(stringBuilder.AppendFormat(GetString(textEnum), arg0));
 }
Ejemplo n.º 52
0
 private MyGuiControlLabel MakeLabel(MyStringId textEnum)
 {
     return(new MyGuiControlLabel(text: MyTexts.GetString(textEnum), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
 }
Ejemplo n.º 53
0
        public override void ActiveUpdate()
        {
            if (MyAPIGateway.Session.Player == null)
            {
                return;
            }

            //if (Vector3D.Distance(MyAPIGateway.Session.Camera.Position, m_source.PositionComp.GetPosition()) > 50f)
            if (Vector3D.Distance(MyAPIGateway.Session.Player.GetPosition(), m_source.PositionComp.GetPosition()) > 50f)
            {
                return;
            }

            for (int s = m_activeBolts.Count - 1; s >= 0; s--)
            {
                var activeItem = m_activeBolts[s];

                activeItem.Position++;
                if (activeItem.Position >= activeItem.MaxPosition)
                {
                    m_activeBolts.Remove(activeItem);
                    m_globalBolts--;
                    continue;
                }
            }

            if (m_activeBolts.Count < m_maxBolts && m_globalBolts < m_globalMaxBolts)
            {
                int numAdd = Math.Min(2, m_maxBolts - m_activeBolts.Count);
                for (int r = 0; r < numAdd; r++)
                {
                    var bolt     = m_boltPool[MyUtils.GetRandomInt(0, m_boltPool.Count)];
                    var boltPath = m_boltPathPool[MyUtils.GetRandomInt(0, m_boltPathPool.Count)];
                    var boltItem = new LightningBoltInstance(bolt, boltPath, 60 + MyUtils.GetRandomInt(-10, 15));
                    m_activeBolts.Add(boltItem);
                    m_globalBolts++;
                }
            }

            for (int s = 0; s < m_activeBolts.Count; s++)
            {
                var activeItem = m_activeBolts[s];

                Vector3D sourceBolt      = new Vector3D(0f, 4f, 0f);
                Vector3D startBoltPoint  = activeItem.Path.Start - new Vector3D(0f, 1.5f, 0f);
                Vector3D endBoltPoint    = activeItem.Path.End - new Vector3D(0f, 1.5f, 0f);
                Vector3D endDiff         = endBoltPoint - startBoltPoint;
                Vector3D endBoltPosition = startBoltPoint + Vector3D.Normalize(endDiff) * (endDiff.Length() * ((float)activeItem.Position / (float)activeItem.MaxPosition));

                Quaternion rot = sourceBolt.CreateQuaternionFromVector(endBoltPosition);

                int startPos      = 0;
                int maxPos        = activeItem.Bolt.Points.Count;
                var previousPoint = activeItem.Bolt.Points[startPos];
                var color         = activeItem.Path.Color;
                for (int r = startPos + 1; r < maxPos; r++)
                {
                    var currentPoint = activeItem.Bolt.Points[startPos + r];

                    if (previousPoint.Length() > endBoltPosition.Length())
                    {
                        break;
                    }

                    // Spin the bolt on the Y axis
                    var startPoint = Vector3D.Transform(currentPoint, MatrixD.CreateRotationY(MathHelper.ToRadians((float)activeItem.Position * 5)));
                    // Rotate the bolt towards the endpoint
                    startPoint = Vector3D.Transform(startPoint, rot);
                    // Move the bolt up to the center of the sphere
                    startPoint += new Vector3D(0f, 1.5f, 0f);
                    // Place it in the world properly
                    startPoint = Vector3D.Transform(startPoint, m_source.WorldMatrix);

                    var endPoint = Vector3D.Transform(previousPoint, MatrixD.CreateRotationY(MathHelper.ToRadians((float)activeItem.Position * 5)));
                    endPoint  = Vector3D.Transform(endPoint, rot);
                    endPoint += new Vector3(0f, 1.5f, 0f);
                    endPoint  = Vector3D.Transform(endPoint, m_source.WorldMatrix);

                    var dir    = Vector3D.Normalize(endPoint - startPoint);
                    var length = (endPoint - startPoint).Length() * 2f;

                    float pulse = MathExtensions.TrianglePulse((float)activeItem.Position, 1f, activeItem.MaxPosition / 2f) + 0.2f;
                    if (activeItem.Position < 10)
                    {
                        pulse = MathExtensions.TrianglePulse((float)activeItem.Position, 1f, 2.5f);
                    }

                    Vector4 diff      = color * pulse;
                    float   thickness = (0.0125f);

                    MyTransparentGeometry.AddLineBillboard(MyStringId.GetOrCompute("Testfly"), diff, startPoint, dir, (float)length, (float)thickness);
                    previousPoint = currentPoint;
                }
            }
        }
Ejemplo n.º 54
0
 public static bool Exists(MyStringId id)
 {
     return(m_strings.ContainsKey(id));
 }
Ejemplo n.º 55
0
        public static void CreateControls(IMyTerminalBlock block, List <IMyTerminalControl> controls)
        {
            if (block as IMyCargoContainer == null || controlsCreated == true)
            {
                return;
            }

            controlsCreated = true;

            //seperator and label
            var separatorA = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyCargoContainer>("FilterSectionSeparator");

            separatorA.Enabled = Block => true;
            separatorA.SupportsMultipleBlocks = false;
            separatorA.Visible = Block => ContainerControls.ControlVisibility(Block);
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(separatorA);
            controls.Add(separatorA);

            var labelA = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlLabel, IMyCargoContainer>("FilterSectionLabel");

            labelA.Enabled = Block => true;
            labelA.SupportsMultipleBlocks = false;
            labelA.Visible = Block => ContainerControls.ControlVisibility(Block);
            labelA.Label   = MyStringId.GetOrCompute("Container Filter Controls");
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(labelA);
            controls.Add(labelA);

            IMyTerminalControlSeparator separatorb = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyCargoContainer>("FilterSectionSeparatorlower");

            separatorb.Enabled = Block => true;
            separatorb.SupportsMultipleBlocks = false;
            separatorb.Visible = Block => ContainerControls.ControlVisibility(Block);
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(separatorb);
            controls.Add(separatorb);

            // BlackList/WhiteList comboBox

            var filterMode = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCombobox, IMyCargoContainer>("filterMode");

            filterMode.Enabled = Block => true;
            filterMode.Visible = Block => ContainerControls.ControlVisibility(Block);
            filterMode.Title   = MyStringId.GetOrCompute("Filter Mode:");
            filterMode.Tooltip = MyStringId.GetOrCompute("");
            filterMode.SupportsMultipleBlocks = false;
            filterMode.ComboBoxContent        = ContainerControls.CreateFilterMode;
            filterMode.Setter = ContainerControls.SetFilterMode;
            filterMode.Getter = ContainerControls.GetFilterMode;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(filterMode);
            controls.Add(filterMode);

            // "Clear Filter" Button

            var clearFilter = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyCargoContainer>("ClearFilterButton");

            clearFilter.Enabled = Block => true;
            clearFilter.Visible = Block => ContainerControls.ControlVisibility(block);
            clearFilter.Title   = MyStringId.GetOrCompute("Clear Filter");
            clearFilter.Tooltip = MyStringId.GetOrCompute("Removes all items and types from Filter");
            clearFilter.SupportsMultipleBlocks = false;
            clearFilter.Action = ContainerControls.ClearFilter;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(clearFilter);
            controls.Add(clearFilter);

            // Current filter list

            var Currentlist = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyCargoContainer>("CurrentList");

            Currentlist.Enabled = Block => true;
            Currentlist.SupportsMultipleBlocks = false;
            Currentlist.Visible          = Block => ContainerControls.ControlVisibility(Block);
            Currentlist.Title            = MyStringId.GetOrCompute("Current Filter:");
            Currentlist.VisibleRowsCount = 6;
            Currentlist.Multiselect      = true;
            Currentlist.ListContent      = ContainerControls.CreateCurrentList;
            Currentlist.ItemSelected     = ContainerControls.SetSelectedcurrentItem;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(Currentlist);
            controls.Add(Currentlist);

            // "Remove" button

            var removeButton = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyCargoContainer>("RemoveButton");

            removeButton.Enabled = Block => true;
            removeButton.SupportsMultipleBlocks = false;
            removeButton.Visible = Block => ContainerControls.ControlVisibility(block);
            removeButton.Title   = MyStringId.GetOrCompute("Remove");
            removeButton.Tooltip = MyStringId.GetOrCompute("Removes the item selected in Current list from filter");
            removeButton.Action  = ContainerControls.RemoveFromFilter;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(removeButton);
            controls.Add(removeButton);

            // Filter Candidates list

            var CandidatesList = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyCargoContainer>("CandidatesList");

            CandidatesList.Enabled = Block => true;
            CandidatesList.SupportsMultipleBlocks = false;
            CandidatesList.Visible          = Block => ContainerControls.ControlVisibility(Block);
            CandidatesList.ListContent      = ContainerControls.CreateCandidateList;
            CandidatesList.Title            = MyStringId.GetOrCompute("Filter Candidates:");
            CandidatesList.VisibleRowsCount = 8;
            CandidatesList.Multiselect      = true;
            CandidatesList.ItemSelected     = ContainerControls.SetSelectedCandidate;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(CandidatesList);
            controls.Add(CandidatesList);

            // "Add" button

            var addButton = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyCargoContainer>("AddButton");

            addButton.Enabled = Block => true;
            addButton.SupportsMultipleBlocks = false;
            addButton.Visible = Block => ContainerControls.ControlVisibility(Block);
            addButton.Title   = MyStringId.GetOrCompute("Add");
            addButton.Tooltip = MyStringId.GetOrCompute("Adds the selected candidate to filter");
            addButton.Action  = ContainerControls.AddToFilter;
            MyAPIGateway.TerminalControls.AddControl <IMyCargoContainer>(addButton);
            controls.Add(addButton);
        }
Ejemplo n.º 56
0
        public static string GetString(string keyString)
        {
            MyStringId stringId = MyStringId.GetOrCompute(keyString);

            return(GetString(stringId));
        }
Ejemplo n.º 57
0
 bool IMyAudio.IsValidTransitionCategory(MyStringId transitionCategory, MyStringId musicCategory)
 {
     return(false);
 }
Ejemplo n.º 58
0
 bool IMyAudio.ApplyTransition(MyStringId transitionEnum, int priority, MyStringId?category, bool loop)
 {
     return(false);
 }
Ejemplo n.º 59
0
        private void AddMember(long playerId, string playerName, bool isLeader, MyMemberComparerEnum status, MyStringId textEnum, Color?color = null)
        {
            var row = new MyGuiControlTable.Row(new MyFactionMember(playerId, isLeader));

            row.AddCell(new MyGuiControlTable.Cell(text:    new StringBuilder(playerName),
                                                   toolTip: playerName,
                                                   userData: playerId, textColor: color));
            row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.Get(textEnum), userData: status, textColor: color));
            m_tableMembers.Add(row);
        }
Ejemplo n.º 60
0
 public bool GetNormalInfo(int index, out Color color, out MyStringId edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     m_data.Get(index, out color, out edgeModel, out normal0, out normal1);
     color.A = 0;
     return(normal0 != 0);
 }