protected override void CreateTerminalControls() { if (!MyTerminalControlFactory.AreControlsCreated <MyOreDetector>()) { base.CreateTerminalControls(); MyTerminalControlSlider <MyOreDetector> slider1 = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange); MyTerminalControlSlider <MyOreDetector> slider2 = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange); slider2.SetLimits(x => 0f, x => x.m_definition.MaximumRange); MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local3 = (MyTerminalValueControl <MyOreDetector, float> .GetterDelegate)slider2; local3.DefaultValue = new float?((float)100); local3.Getter = x => (x.Range * x.m_definition.MaximumRange) * 0.01f; MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local14 = local3; MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local15 = local3; local15.Setter = (x, v) => x.Range = (v / x.m_definition.MaximumRange) * 100f; MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local12 = local15; MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local13 = local15; local13.Writer = (x, result) => result.AppendInt32(((int)x.m_oreDetectorComponent.DetectionRadius)).Append(" m"); MyTerminalControlFactory.AddControl <MyOreDetector>((MyTerminalControl <MyOreDetector>)local13); MyStringId?on = null; on = null; MyTerminalControlCheckbox <MyOreDetector> checkbox1 = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, on, on); MyTerminalControlCheckbox <MyOreDetector> checkbox2 = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, on, on); checkbox2.Getter = x => x.m_oreDetectorComponent.BroadcastUsingAntennas; MyTerminalControlCheckbox <MyOreDetector> local10 = checkbox2; MyTerminalControlCheckbox <MyOreDetector> local11 = checkbox2; local11.Setter = (x, v) => x.m_broadcastUsingAntennas.Value = v; MyTerminalControlCheckbox <MyOreDetector> checkbox = local11; checkbox.EnableAction <MyOreDetector>(null); MyTerminalControlFactory.AddControl <MyOreDetector>(checkbox); } }
public MyGuiScreenProgressAsync(MyStringId text, MyStringId?cancelText, Func <IMyAsyncResult> beginAction, Action <IMyAsyncResult, MyGuiScreenProgressAsync> endAction) : base(text, cancelText) { FriendlyName = "MyGuiScreenProgressAsync"; m_beginAction = beginAction; m_endAction = endAction; }
protected virtual void Init(MyObjectBuilder_DefinitionBase builder) { this.Id = builder.Id; this.Public = builder.Public; this.Enabled = builder.Enabled; this.AvailableInSurvival = builder.AvailableInSurvival; this.Icon = builder.Icon; if (builder.DisplayName != null && builder.DisplayName.StartsWith("DisplayName_")) { DisplayNameEnum = MyStringId.GetOrCompute(builder.DisplayName); } else { DisplayNameString = builder.DisplayName; } if (builder.Description != null && builder.Description.StartsWith("Description_")) { DescriptionEnum = MyStringId.GetOrCompute(builder.Description); } else { DescriptionString = builder.Description; } Debug.Assert(!Context.IsBaseGame || !Public || string.IsNullOrWhiteSpace(builder.DisplayName) || (DisplayNameEnum.HasValue && builder.DisplayName.StartsWith("DisplayName_")), string.Format("Bad display name '{0}' on definition '{1}'. It should either be empty, or it must start with 'DisplayName_' and have corresponding text enum defined.", builder.DisplayName, Id)); Debug.Assert(!Context.IsBaseGame || !Public || string.IsNullOrWhiteSpace(builder.Description) || (DescriptionEnum.HasValue && builder.Description.StartsWith("Description_")), string.Format("Bad description '{0}' on definition '{1}'. It should either be empty, or it must start with 'Description_' and have corresponding text enum defined.", builder.Description, Id)); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalItemDefinition; MyDebug.AssertDebug(ob != null); this.Size = ob.Size; this.Mass = ob.Mass; this.Model = ob.Model; this.Models = ob.Models; this.Volume = ob.Volume.HasValue? ob.Volume.Value / 1000f : ob.Size.Volume; if (string.IsNullOrEmpty(ob.IconSymbol)) this.IconSymbol = null; else this.IconSymbol = MyStringId.GetOrCompute(ob.IconSymbol); PhysicalMaterial = MyStringHash.GetOrCompute(ob.PhysicalMaterial); VoxelMaterial = MyStringHash.GetOrCompute(ob.VoxelMaterial); CanSpawnFromScreen = ob.CanSpawnFromScreen; RotateOnSpawnX = ob.RotateOnSpawnX; RotateOnSpawnY = ob.RotateOnSpawnY; RotateOnSpawnZ = ob.RotateOnSpawnZ; Health = ob.Health; if (ob.DestroyedPieceId.HasValue) { DestroyedPieceId = ob.DestroyedPieceId.Value; } DestroyedPieces = ob.DestroyedPieces; if (ob.ExtraInventoryTooltipLine != null) ExtraInventoryTooltipLine = new StringBuilder().Append(Environment.NewLine).Append(ob.ExtraInventoryTooltipLine); else ExtraInventoryTooltipLine = new StringBuilder(); }
public void Draw(MyStringId?faceMaterial = null, MyStringId?lineMaterial = null, float lineThickness = -1f) { var ib = _backing._indexBuffer[_lod]; for (int i = 0, j = 0; i < ib.Length; i += 3, j++) { var i0 = ib[i]; var i1 = ib[i + 1]; var i2 = ib[i + 2]; var v0 = _vertexBuffer[i0]; var v1 = _vertexBuffer[i1]; var v2 = _vertexBuffer[i2]; var n0 = _normalBuffer[i0]; var n1 = _normalBuffer[i1]; var n2 = _normalBuffer[i2]; var color = _triColorBuffer[j]; if (faceMaterial.HasValue) { MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2, n0, n1, n2, Vector2.Zero, Vector2.Zero, Vector2.Zero, faceMaterial.Value, 0, (v0 + v1 + v2) / 3, color); } if (lineMaterial.HasValue && lineThickness > 0) { MySimpleObjectDraw.DrawLine(v0, v1, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v1, v2, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v2, v0, lineMaterial, ref color, lineThickness); } } }
public void SendPlayerData(string clientName) { uint num; uint num2; ConnectedClientDataMsg msg = new ConnectedClientDataMsg { SteamID = Sync.MyId, Name = clientName, Join = true, ExperimentalMode = this.ExperimentalMode }; byte[] buffer = new byte[0x400]; if (MyGameService.GetAuthSessionTicket(out num2, buffer, out num)) { msg.Token = new byte[num]; Array.Copy(buffer, msg.Token, (long)num); base.ReplicationLayer.SendClientConnected(ref msg); } else { MySessionLoader.UnloadAndExitToMenu(); StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); MyStringId? okButtonText = null; okButtonText = null; okButtonText = null; okButtonText = null; Vector2?size = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size)); } }
public void Draw(MatrixD matrix, float radius, int lod, Vector4 color, MyStringId?faceMaterial = null, MyStringId?lineMaterial = null, float lineThickness = -1f) { var ix = _indexBuffer[lod]; for (var i = 0; i < ix.Length - 2; i += 3) { var i0 = ix[i]; var i1 = ix[i + 1]; var i2 = ix[i + 2]; var v0 = Vector3D.Transform(radius * _vertexBuffer[i0], matrix); var v1 = Vector3D.Transform(radius * _vertexBuffer[i1], matrix); var v2 = Vector3D.Transform(radius * _vertexBuffer[i2], matrix); var n = (_vertexBuffer[i0] + _vertexBuffer[i1] + _vertexBuffer[i2]) / 3; if (faceMaterial.HasValue) { MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2, _vertexBuffer[i0], _vertexBuffer[i1], _vertexBuffer[i2], Vector2.Zero, Vector2.Zero, Vector2.Zero, faceMaterial.Value, 0, (v0 + v1 + v2) / 3, color); } if (lineMaterial.HasValue && lineThickness > 0) { MySimpleObjectDraw.DrawLine(v0, v1, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v1, v2, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v2, v0, lineMaterial, ref color, lineThickness); } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_PhysicalItemDefinition definition = builder as MyObjectBuilder_PhysicalItemDefinition; this.Size = definition.Size; this.Mass = definition.Mass; this.Model = definition.Model; this.Models = definition.Models; this.Volume = (definition.Volume != null) ? (definition.Volume.Value / 1000f) : definition.Size.Volume; this.ModelVolume = (definition.ModelVolume != null) ? (definition.ModelVolume.Value / 1000f) : this.Volume; this.IconSymbol = !string.IsNullOrEmpty(definition.IconSymbol) ? new MyStringId?(MyStringId.GetOrCompute(definition.IconSymbol)) : null; this.PhysicalMaterial = MyStringHash.GetOrCompute(definition.PhysicalMaterial); this.VoxelMaterial = MyStringHash.GetOrCompute(definition.VoxelMaterial); this.CanSpawnFromScreen = definition.CanSpawnFromScreen; this.RotateOnSpawnX = definition.RotateOnSpawnX; this.RotateOnSpawnY = definition.RotateOnSpawnY; this.RotateOnSpawnZ = definition.RotateOnSpawnZ; this.Health = definition.Health; if (definition.DestroyedPieceId != null) { this.DestroyedPieceId = new MyDefinitionId?(definition.DestroyedPieceId.Value); } this.DestroyedPieces = definition.DestroyedPieces; this.ExtraInventoryTooltipLine = (definition.ExtraInventoryTooltipLine == null) ? new StringBuilder() : new StringBuilder().Append(MyEnvironment.NewLine).Append(definition.ExtraInventoryTooltipLine); this.MaxStackAmount = definition.MaxStackAmount; }
protected override void OnClientBan(ref MyControlBanClientMsg data, ulong sender) { if ((data.BannedClient == Sync.MyId) && data.Banned) { MySessionLoader.UnloadAndExitToMenu(); StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionKicked); MyStringId? okButtonText = null; okButtonText = null; okButtonText = null; okButtonText = null; Vector2?size = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenBanned), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size)); } else { if (data.Banned) { base.AddBannedClient(data.BannedClient); } else { base.RemoveBannedClient(data.BannedClient); } if (this.m_members.Contains(data.BannedClient) && data.Banned) { base.RaiseClientLeft(data.BannedClient, MyChatMemberStateChangeEnum.Banned); } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalItemDefinition; MyDebug.AssertDebug(ob != null); this.Size = ob.Size; this.Mass = ob.Mass; this.Model = ob.Model; this.Volume = ob.Volume.HasValue? ob.Volume.Value / 1000f : ob.Size.Volume; if (string.IsNullOrEmpty(ob.IconSymbol)) { this.IconSymbol = null; } else { this.IconSymbol = MyStringId.GetOrCompute(ob.IconSymbol); } PhysicalMaterial = MyStringHash.GetOrCompute(ob.PhysicalMaterial); CanSpawnFromScreen = ob.CanSpawnFromScreen; RotateOnSpawnX = ob.RotateOnSpawnX; RotateOnSpawnY = ob.RotateOnSpawnY; RotateOnSpawnZ = ob.RotateOnSpawnZ; Health = ob.Health; }
public MyGuiScreenProgress(StringBuilder text, MyStringId?cancelText = null) : base(MySpaceTexts.Blank, cancelText) { // Copy Text = new StringBuilder(text.Length); Text.AppendStringBuilder(text); }
private void GetControlStringIDs(MyKeys[] keys, out string[] allControls, out string[] mouseControls) { var mouseButtons = Enum.GetValues(typeof(MyMouseButtonsEnum)) as MyMouseButtonsEnum[]; List <string> controlIDs = new List <string>(keys.Length), mouseControlIDs = new List <string>(mouseButtons.Length); foreach (MyKeys key in keys) { MyStringId?id = MyAPIGateway.Input.GetControl(key)?.GetGameControlEnum(); string stringID = id?.ToString(); if (stringID != null && stringID.Length > 0) { controlIDs.Add(stringID); } } foreach (MyMouseButtonsEnum key in mouseButtons) { MyStringId?id = MyAPIGateway.Input.GetControl(key)?.GetGameControlEnum(); string stringID = id?.ToString(); if (stringID != null && stringID.Length > 0 && stringID != "FORWARD") // WTH is FORWARD in there? { mouseControlIDs.Add(stringID); } } allControls = controlIDs.ToArray(); mouseControls = mouseControlIDs.ToArray(); }
public void DrawAuto(MatrixD matrix, float radius, Vector4 color, MyStringId?faceMaterial = null, MyStringId?lineMaterial = null, float lineThickness = -1f) { for (var id = 0; id < _indexBuffer[0].Length - 2; id += 3) { DrawTriangle(0, id, radius, ref matrix, ref color, faceMaterial, lineMaterial, lineThickness); } }
public void AddItem(long key, MyStringId value, int? sortOrder = null, MyStringId? toolTip = null) { AddItem( key, MyTexts.Get(value), sortOrder, (toolTip.HasValue) ? MyTexts.GetString(toolTip.Value) : null); }
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); }
private static void CreateForBase() { MyStringId?parent = null; MyControllerHelper.AddContext(CX_BASE, parent); MyControllerHelper.AddControl(CX_BASE, MyControlsSpace.CONTROL_MENU, MyJoystickButtonsEnum.J07); MyControllerHelper.AddControl(CX_BASE, MyControlsGUI.MAIN_MENU, MyJoystickButtonsEnum.J08); }
protected MyGuiScreenProgressBaseAsync(MyStringId progressText, MyStringId?cancelText = null) : base(progressText, cancelText) { if (Debugger.IsAttached) { m_constructorStackTrace = Environment.StackTrace; } }
public static MyGuiScreenMessageBox CreateMessageBox( MyMessageBoxStyleEnum styleEnum = MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType buttonType = MyMessageBoxButtonsType.OK, StringBuilder messageText = null, StringBuilder messageCaption = null, MyStringId?okButtonText = null, MyStringId?cancelButtonText = null, MyStringId?yesButtonText = null, MyStringId?noButtonText = null, Action <MyGuiScreenMessageBox.ResultEnum> callback = null, int timeoutInMiliseconds = 0, MyGuiScreenMessageBox.ResultEnum focusedResult = MyGuiScreenMessageBox.ResultEnum.YES, bool canHideOthers = true, Vector2?size = null, bool useOpacity = true, Vector2?position = null, bool focusable = true, bool canBeHidden = false, Action onClosing = null) { int num1 = (int)styleEnum; int num2 = (int)buttonType; StringBuilder messageText1 = messageText; StringBuilder messageCaption1 = messageCaption; MyStringId? nullable = okButtonText; MyStringId okButtonText1 = nullable ?? MyCommonTexts.Ok; nullable = cancelButtonText; MyStringId cancelButtonText1 = nullable ?? MyCommonTexts.Cancel; nullable = yesButtonText; MyStringId yesButtonText1 = nullable ?? MyCommonTexts.Yes; nullable = noButtonText; MyStringId noButtonText1 = nullable ?? MyCommonTexts.No; Action <MyGuiScreenMessageBox.ResultEnum> callback1 = callback; int timeoutInMiliseconds1 = timeoutInMiliseconds; int num3 = (int)focusedResult; int num4 = canHideOthers ? 1 : 0; Vector2?size1 = size; double num5 = useOpacity ? (double)MySandboxGame.Config.UIBkOpacity : 1.0; double num6 = useOpacity ? (double)MySandboxGame.Config.UIOpacity : 1.0; Vector2?position1 = position; int num7 = focusable ? 1 : 0; int num8 = canBeHidden ? 1 : 0; Action onClosing1 = onClosing; var dlg = new MyGuiScreenMessageBox((MyMessageBoxStyleEnum)num1, (MyMessageBoxButtonsType)num2, messageText1, messageCaption1, okButtonText1, cancelButtonText1, yesButtonText1, noButtonText1, callback1, timeoutInMiliseconds1, (MyGuiScreenMessageBox.ResultEnum)num3, num4 != 0, size1, (float)num5, (float)num6, position1, num7 != 0, num8 != 0, onClosing1); if (dlg.Controls.GetControlByName("MyGuiControlMultilineText") is MyGuiControlMultilineText text) { text.TextAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } return(dlg); }
private bool TrySaveAs() { MyStringId?errorType = null; if (m_nameTextbox.Text.Length < 5) { errorType = MySpaceTexts.ErrorNameTooShort; } else if (m_nameTextbox.Text.Length > 30) { errorType = MySpaceTexts.ErrorNameTooLong; } if (m_existingSessionNames != null) { foreach (var name in m_existingSessionNames) { if (name == m_nameTextbox.Text) { errorType = MySpaceTexts.ErrorNameAlreadyExists; } } } if (errorType != null) { var messageBox = MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(errorType.Value), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)); messageBox.SkipTransition = true; messageBox.InstantClose = false; MyGuiSandbox.AddScreen(messageBox); return(false); } if (m_fromMainMenu) { string name = MyUtils.StripInvalidChars(m_nameTextbox.Text); if (string.IsNullOrWhiteSpace(name)) { name = MyLocalCache.GetSessionSavesPath(name + MyUtils.GetRandomInt(int.MaxValue).ToString("########"), false, false); } MyAsyncSaving.Start(customName: name); MySession.Static.Name = m_nameTextbox.Text; this.CloseScreen(); return(true); } m_copyFrom.SessionName = m_nameTextbox.Text; MyGuiSandbox.AddScreen(new MyGuiScreenProgressAsync(MySpaceTexts.SavingPleaseWait, null, beginAction: () => new SaveResult(MyUtils.StripInvalidChars(m_nameTextbox.Text), m_sessionPath, m_copyFrom), endAction: (result, screen) => { screen.CloseScreen(); this.CloseScreen(); })); return(true); }
private MyGuiControlLabel MakeLabel(MyStringId?text = null, MyGuiDrawAlignEnum labelAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP) { float labelTextScale = 0.85f; var res = new MyGuiControlLabel( text: (text.HasValue) ? MyTexts.GetString(text.Value) : null, textScale: labelTextScale, originAlign: labelAlign); res.AutoEllipsis = true; return(res); }
public static void AddContext(MyStringId context, MyStringId?parent = null) { if (!m_bindings.ContainsKey(context)) { var contextObj = new Context(); m_bindings.Add(context, contextObj); if (parent.HasValue && m_bindings.ContainsKey(parent.Value)) { contextObj.ParentContext = m_bindings[parent.Value]; } } }
private void Matchmaking_LobbyChatUpdate(IMyLobby lobby, ulong changedUser, ulong makingChangeUser, MyChatMemberStateChangeEnum stateChange) { if (lobby.LobbyId == this.m_lobby.LobbyId) { if (stateChange == MyChatMemberStateChangeEnum.Entered) { object[] objArray1 = new object[] { "Player entered: ", MyGameService.GetPersonaName(changedUser), " (", changedUser, ")" }; MySandboxGame.Log.WriteLineAndConsole(string.Concat(objArray1)); MyGameService.Peer2Peer.AcceptSession(changedUser); if ((Sync.Clients == null) || !Sync.Clients.HasClient(changedUser)) { base.RaiseClientJoined(changedUser); if (this.Scenario && (changedUser != Sync.MyId)) { base.SendAllMembersDataToClient(changedUser); } } if (MySandboxGame.IsGameReady && (changedUser != base.ServerId)) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } else { if ((Sync.Clients == null) || Sync.Clients.HasClient(changedUser)) { base.RaiseClientLeft(changedUser, stateChange); } if (changedUser == base.ServerId) { base.RaiseHostLeft(); MySessionLoader.UnloadAndExitToMenu(); StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); MyStringId? okButtonText = null; okButtonText = null; okButtonText = null; okButtonText = null; Vector2?size = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size)); } else if (MySandboxGame.IsGameReady) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } } }
public override void DebugDraw() { if (MyDebugDrawSettings.DEBUG_DRAW_CUBE_BLOCK_AABBS) { Color red = Color.Red; Color green = Color.Green; Vector3I center = this.m_cubeBlock.BlockDefinition.Center; Vector3 max = (this.m_cubeBlock.Max * this.m_cubeBlock.CubeGrid.GridSize) + new Vector3(this.m_cubeBlock.CubeGrid.GridSize / 2f); BoundingBoxD localbox = new BoundingBoxD((Vector3D)((this.m_cubeBlock.Min * this.m_cubeBlock.CubeGrid.GridSize) - new Vector3(this.m_cubeBlock.CubeGrid.GridSize / 2f)), max); MyStringId? faceMaterial = null; faceMaterial = null; MySimpleObjectDraw.DrawTransparentBox(ref this.m_cubeBlock.CubeGrid.WorldMatrix, ref localbox, ref red, MySimpleObjectRasterizer.Wireframe, 1, 0.01f, faceMaterial, faceMaterial, false, -1, MyBillboard.BlendTypeEnum.Standard, 1f, null); } }
private void DrawTriangle(int lod, int id, float radius, ref MatrixD matrix, ref Vector4 color, MyStringId?faceMaterial, MyStringId?lineMaterial, float lineThickness) { var i0 = _indexBuffer[lod][id]; var i1 = _indexBuffer[lod][id + 1]; var i2 = _indexBuffer[lod][id + 2]; var v0 = Vector3D.Transform(radius * _vertexBuffer[i0], matrix); var v1 = Vector3D.Transform(radius * _vertexBuffer[i1], matrix); var v2 = Vector3D.Transform(radius * _vertexBuffer[i2], matrix); var n0 = Vector3D.TransformNormal(_vertexBuffer[i0], matrix); var n1 = Vector3D.TransformNormal(_vertexBuffer[i1], matrix); var n2 = Vector3D.TransformNormal(_vertexBuffer[i2], matrix); var s0 = WorldToScreen(v0); var s1 = WorldToScreen(v1); var s2 = WorldToScreen(v2); var sSize = Vector2.Max(s0, Vector2.Max(s1, s2)) - Vector2.Min(s0, Vector2.Min(s1, s2)); var size = (v0 - v1).LengthSquared() / (MyAPIGateway.Session.Camera.Position - (v0 + v1 + v2) / 3).Length(); if (size < 1 || lod == _indexBuffer.Length - 1) { // draw if (faceMaterial.HasValue) { MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2, n0, n1, n2, Vector2.Zero, Vector2.Zero, Vector2.Zero, faceMaterial.Value, 0, (v0 + v1 + v2) / 3, color); } if (lineMaterial.HasValue && lineThickness > 0) { MySimpleObjectDraw.DrawLine(v0, v1, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v1, v2, lineMaterial, ref color, lineThickness); MySimpleObjectDraw.DrawLine(v2, v0, lineMaterial, ref color, lineThickness); } } else { // subdivide var ni = id * 4; DrawTriangle(lod + 1, ni, radius, ref matrix, ref color, faceMaterial, lineMaterial, lineThickness); DrawTriangle(lod + 1, ni + 3, radius, ref matrix, ref color, faceMaterial, lineMaterial, lineThickness); DrawTriangle(lod + 1, ni + 6, radius, ref matrix, ref color, faceMaterial, lineMaterial, lineThickness); DrawTriangle(lod + 1, ni + 9, radius, ref matrix, ref color, faceMaterial, lineMaterial, lineThickness); } }
public override void Draw() { if (this.DrawSensor) { this.SetHighlight(); MatrixD worldMatrix = base.Container.Entity.PositionComp.WorldMatrix; if (ReferenceEquals(MySession.Static.ControlledEntity, this)) { Vector4 color = Color.Red.ToVector4(); MyStringId?material = null; MySimpleObjectDraw.DrawLine(worldMatrix.Translation, worldMatrix.Translation + ((worldMatrix.Forward * base.Container.Entity.PositionComp.LocalVolume.Radius) * 1.2000000476837158), material, ref color, 0.05f, MyBillboard.BlendTypeEnum.Standard); } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalItemDefinition; MyDebug.AssertDebug(ob != null); this.Size = ob.Size; this.Mass = ob.Mass; this.Model = ob.Model; this.Volume = ob.Volume.HasValue? ob.Volume.Value / 1000f : ob.Size.Volume; if (string.IsNullOrEmpty(ob.IconSymbol)) this.IconSymbol = null; else this.IconSymbol = MyStringId.GetOrCompute(ob.IconSymbol); PhysicalMaterial = MyStringId.GetOrCompute(ob.PhysicalMaterial); }
protected MyGuiControlButton MakeButton(Vector2 position, MyStringId text, Action <MyGuiControlButton> onClick, MyStringId?tooltip = null) { var button = new MyGuiControlButton( position: position, text: MyTexts.Get(text), textScale: MyGuiConstants.MAIN_MENU_BUTTON_TEXT_SCALE, onButtonClick: onClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM); if (tooltip.HasValue) { button.SetToolTip(MyTexts.GetString(tooltip.Value)); } return(button); }
public MyControl(MyStringId controlId, MyStringId name, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum?defaultControlMouse, MyKeys?defaultControlKey, MyStringId?helpText = null, MyKeys?defaultControlKey2 = null, MyStringId?description = null) { m_controlId = controlId; m_name = name; m_controlType = controlType; m_mouseButton = defaultControlMouse ?? MyMouseButtonsEnum.None; m_keyboardKey = defaultControlKey ?? MyKeys.None; m_KeyboardKey2 = defaultControlKey2 ?? MyKeys.None; m_data.Description = description; }
public static void Draw <T>(this T curve, Vector4 color, float tMin = 0f, float tMax = 1f, int segments = -1, float edgeWidth = 0.05f, Vector3?upZero = null, Vector3?upOne = null, MyStringId?material = null) where T : ICurve { var cam = MyCameraComponent.ActiveCamera; if (cam == null) { return; } if (segments < 1) { if (curve is LinearCurve) { segments = 1; } else { var camPos = cam.GetPosition(); var tNearMin = tMin; var tNearMax = tMax; NearestPoint(curve, camPos, 10, ref tNearMin, ref tNearMax); var depth = Vector3D.Distance(camPos, curve.Sample((tNearMin + tNearMax) / 2)); var lengthEst = Vector3D.Distance(curve.Sample(tMin), curve.Sample(tMax)); var screenFactor = lengthEst / (.1f + depth); segments = (int)MathHelper.Clamp(screenFactor * 5, 1, 100); } } var lastPos = default(Vector3D); for (var t = 0; t <= segments; t++) { var time = MathHelper.Lerp(tMin, tMax, (t / (float)segments)); var pos = curve.Sample(time); var pact = pos + Vector3D.Lerp(upZero ?? Vector3.Zero, upOne ?? Vector3.Zero, time); if (t > 0) { MySimpleObjectDraw.DrawLine(lastPos, pact, material ?? SquareMaterial, ref color, edgeWidth); } lastPos = pact; } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalItemDefinition; MyDebug.AssertDebug(ob != null); this.Size = ob.Size; this.Mass = ob.Mass; this.Model = ob.Model; this.Models = ob.Models; this.Volume = ob.Volume.HasValue ? ob.Volume.Value / 1000f : ob.Size.Volume; this.ModelVolume = ob.ModelVolume.HasValue ? ob.ModelVolume.Value / 1000f : this.Volume; if (string.IsNullOrEmpty(ob.IconSymbol)) { this.IconSymbol = null; } else { this.IconSymbol = MyStringId.GetOrCompute(ob.IconSymbol); } PhysicalMaterial = MyStringHash.GetOrCompute(ob.PhysicalMaterial); VoxelMaterial = MyStringHash.GetOrCompute(ob.VoxelMaterial); CanSpawnFromScreen = ob.CanSpawnFromScreen; RotateOnSpawnX = ob.RotateOnSpawnX; RotateOnSpawnY = ob.RotateOnSpawnY; RotateOnSpawnZ = ob.RotateOnSpawnZ; Health = ob.Health; if (ob.DestroyedPieceId.HasValue) { DestroyedPieceId = ob.DestroyedPieceId.Value; } DestroyedPieces = ob.DestroyedPieces; if (ob.ExtraInventoryTooltipLine != null) { ExtraInventoryTooltipLine = new StringBuilder().Append(Environment.NewLine).Append(ob.ExtraInventoryTooltipLine); } else { ExtraInventoryTooltipLine = new StringBuilder(); } this.MaxStackAmount = ob.MaxStackAmount; }
public MyGuiScreenProgressBase(MyStringId progressText, MyStringId?cancelText = null) : base(position: new Vector2(0.5f, 0.5f), backgroundColor: MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen: true) { m_progressText = progressText; m_cancelText = cancelText; EnabledBackgroundFade = true; DrawMouseCursor = m_cancelText.HasValue; m_closeOnEsc = m_cancelText.HasValue; m_drawEvenWithoutFocus = true; CanHideOthers = false; // There is no reason for hiding progress screens! CanBeHidden = false; RecreateControls(true); }
public MyGuiScreenProgressBase(MyStringId progressText, MyStringId? cancelText = null) : base(position: new Vector2(0.5f, 0.5f), backgroundColor: MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen: true) { m_progressText = progressText; m_cancelText = cancelText; EnabledBackgroundFade = true; DrawMouseCursor = m_cancelText.HasValue; m_closeOnEsc = m_cancelText.HasValue; m_drawEvenWithoutFocus = true; CanHideOthers = false; // There is no reason for hiding progress screens! CanBeHidden = false; RecreateControls(true); }
protected override void CreateTerminalControls() { if (!MyTerminalControlFactory.AreControlsCreated <MyCollector>()) { base.CreateTerminalControls(); MyStringId tooltip = new MyStringId(); MyStringId?on = null; on = null; MyTerminalControlOnOffSwitch <MyCollector> switch1 = new MyTerminalControlOnOffSwitch <MyCollector>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem, tooltip, on, on); MyTerminalControlOnOffSwitch <MyCollector> switch2 = new MyTerminalControlOnOffSwitch <MyCollector>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem, tooltip, on, on); switch2.Getter = x => x.UseConveyorSystem; MyTerminalControlOnOffSwitch <MyCollector> local4 = switch2; MyTerminalControlOnOffSwitch <MyCollector> local5 = switch2; local5.Setter = (x, v) => x.UseConveyorSystem = v; MyTerminalControlOnOffSwitch <MyCollector> onOff = local5; onOff.EnableToggleAction <MyCollector>(); MyTerminalControlFactory.AddControl <MyCollector>(onOff); } }
protected virtual void Init(MyObjectBuilder_DefinitionBase builder) { this.Id = builder.Id; this.Public = builder.Public; this.Enabled = builder.Enabled; this.AvailableInSurvival = builder.AvailableInSurvival; this.Icons = builder.Icons; if (builder.DisplayName != null && builder.DisplayName.StartsWith("DisplayName_")) { DisplayNameEnum = MyStringId.GetOrCompute(builder.DisplayName); } else { DisplayNameString = builder.DisplayName; } if (builder.Description != null && builder.Description.StartsWith("Description_")) { DescriptionEnum = MyStringId.GetOrCompute(builder.Description); } else { DescriptionString = builder.Description; } Debug.Assert(!Context.IsBaseGame || !Public || string.IsNullOrWhiteSpace(builder.DisplayName) || (DisplayNameEnum.HasValue && builder.DisplayName.StartsWith("DisplayName_")), string.Format("Bad display name '{0}' on definition '{1}'. It should either be empty, or it must start with 'DisplayName_' and have corresponding text enum defined.", builder.DisplayName, Id)); Debug.Assert(!Context.IsBaseGame || !Public || string.IsNullOrWhiteSpace(builder.Description) || (DescriptionEnum.HasValue && builder.Description.StartsWith("Description_")), string.Format("Bad description '{0}' on definition '{1}'. It should either be empty, or it must start with 'Description_' and have corresponding text enum defined.", builder.Description, Id)); }
public SoundDescription(string soundId, string soundName, MyStringId? soundNameEnum) { SoundId = soundId; SoundName = soundName; SoundNameEnum = soundNameEnum; }