public override void Close() { try { if (SessionCore.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap); } try { SessionCore.SaveUnregister(Save); SyncBeamLength.GotValueFromServer -= Tool.UpdateVisual; SyncDistanceMode.GotValueFromServer -= Tool.UpdateVisual; SyncSpeedMultiplier.GotValueFromServer -= Tool.UpdateVisual; SyncBeamLength.Close(); SyncDistanceMode.Close(); SyncSpeedMultiplier.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap); } }
public override void Close() { try { if (SessionCore.Settings.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap); } try { HUDModule.Close(); PersistenceModule.Close(); TermModule.Close(); GridInventoryModule.RemoveWatcher(Tool); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap); } }
void SetPadStatus(string text, string font, int aliveTime = 200) { try { if (!SeeWeldPadInfo()) { return; } if (Notification == null) { Notification = MyAPIGateway.Utilities.CreateNotification(text, aliveTime, font); } else { Notification.Hide(); // required since SE v1.194 Notification.Font = font; Notification.Text = text; Notification.AliveTime = aliveTime; } Notification.Show(); } catch (Exception e) { Log.Error(e); } }
public static void Error(string msg) { Info("ERROR: " + msg); try { MyLog.Default.WriteLineAndConsole(MOD_NAME + " error: " + msg); if(MyAPIGateway.Session != null) { string text = MOD_NAME + " error - open %AppData%/SpaceEngineers/Storage/" + WORKSHOP_ID + "_" + MOD_NAME + "/" + LOG_FILE + " for details"; if(notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { notify.Text = text; notify.ResetAliveTime(); } notify.Show(); } } catch(Exception e) { Info("ERROR: Could not send notification to local client: " + e.ToString()); } }
void ComplainMissing(Dictionary <IMySlimBlock, Dictionary <string, int> > MissingPerBlock) { var Player = MyAPIGateway.Session.Player; if (Player == null) { return; } if (Player.IdentityId != Tool.OwnerId) { return; } if (Player.GetPosition().DistanceTo(Tool.GetPosition()) > 200) { return; } StringBuilder Text = new StringBuilder(); if (MissingPerBlock.Count == 1) { IMySlimBlock Block = MissingPerBlock.Keys.First(); var Missing = MissingPerBlock[Block]; bool IsProjected = Block.IsProjectable(); if (Missing != null && Missing.Count > 0) { Text.AppendLine($"{Tool.CustomName}: can't proceed to {(!IsProjected ? "build" : "place")} {Block.BlockDefinition.DisplayNameText}, missing:\n"); foreach (var ItemPair in Missing) { Text.AppendLine($"{ItemPair.Key}: {(!IsProjected ? 1 : ItemPair.Value)}"); if (IsProjected) { break; } } } } else if (UnbuiltBlocks.Count > 1 && MissingPerBlock.Values.Any(x => x.Count > 0)) { Text.AppendLine($"{Tool.CustomName}: can't proceed to build {MissingPerBlock.Count} blocks:\n"); foreach (IMySlimBlock Block in MissingPerBlock.Keys) { var Missing = MissingPerBlock[Block]; if (Missing.Count == 0) { continue; } Text.AppendLine($"{Block.BlockDefinition.DisplayNameText}: missing:"); foreach (var ItemPair in Missing) { Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}"); } Text.AppendLine(); } } Text.RemoveTrailingNewlines(); IMyHudNotification hud = MyAPIGateway.Utilities.CreateNotification(Text.ToString(), (int)Math.Ceiling(SessionCore.TickLengthMs * 101), "Red"); // Adding 1 excess tick is needed, otherwise notification can flicker hud.Show(); }
public NotifHud(NotifHudConfig cfg) { Cfg = cfg; header = MyAPIGateway.Utilities.CreateNotification(""); list = new IMyHudNotification[cfg.maxVisible]; }
public static void Error(string msg, string printText) { Info("ERROR: " + msg); try { MyLog.Default.WriteLineAndConsole(modName + " error/exception: " + msg); if(MyAPIGateway.Session != null) { if(notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(printText, 10000, MyFontEnum.Red); } else { notify.Text = printText; notify.ResetAliveTime(); } notify.Show(); } } catch(Exception e) { Info("ERROR: Could not send notification to local client: " + e); MyLog.Default.WriteLineAndConsole(modName + " error/exception: Could not send notification to local client: " + e); } }
public override void Close() { try { if (SessionCore.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap); } try { SessionCore.SaveUnregister(Save); SyncBeamLength.Close(); SyncDistanceMode.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap); } }
public static void refresh_local_player_HUD() { if (!_UI_handlers_registered) { return; } bool player_in_cockpit = local_controller is MyShipController; foreach (var message_entry in _HUD_messages) { HUD_notification cur_message = message_entry.Value; bool show_message = player_in_cockpit && _HUD_messages[message_entry.Key].toggled_on && cur_message.set_to_visible; IMyHudNotification contents = cur_message.contents; /* * if (cur_message.currently_visible != show_message) * { * if (show_message) * contents.Show(); * else * contents.Hide(); * cur_message.currently_visible = show_message; * } */ contents.Hide(); if (show_message) { contents.Show(); } } }
public Item(Func <Item, string> displayFunc = null, Action <Item> leftAction = null, Action <Item> rightAction = null, string name = "") { DisplayFunc = displayFunc; ScrollUpAction = leftAction; ScrollDownAction = rightAction; ItemText = MyAPIGateway.Utilities.CreateNotification(name); }
public void Show(int line, string text, string font = MyFontEnum.Debug, int aliveTime = DEFAULT_TIMEOUT_MS) { if (line < 0 || line >= notifications.Length) { throw new ArgumentException($"Notification line ({line.ToString()}) is either negative or above max of {(notifications.Length - 1).ToString()}."); } IMyHudNotification notify = notifications[line]; if (text == null) { if (notify != null) { notify.Hide(); } return; } if (notify == null) { notify = notifications[line] = MyAPIGateway.Utilities.CreateNotification(string.Empty); } notify.Hide(); // required since SE v1.194 notify.Font = font; notify.Text = text; notify.AliveTime = aliveTime; notify.Show(); }
private static void PrintError(string msg) { Info("ERROR: " + msg); try { MyLog.Default.WriteLineAndConsole(ModName + " error: " + msg); if (MyAPIGateway.Session != null) { var text = ModName + " error - open %AppData%/SpaceEngineers/Storage/" + WorkshopId + ".sbm_" + ModName + "/" + LogFile + " for details"; if (_notify == null) { _notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { _notify.Text = text; _notify.ResetAliveTime(); } _notify.Show(); } } catch (Exception e) { Info("ERROR: Could not send notification to local client: " + e); } }
public static void Error(string msg, string printText) { Info("ERROR: " + msg); try { MyLog.Default.WriteLineAndConsole(modName + " error/exception: " + msg); if (MyAPIGateway.Session != null) { if (notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(printText, 10000, MyFontEnum.Red); } else { notify.Text = printText; notify.ResetAliveTime(); } notify.Show(); } } catch (Exception e) { Info("ERROR: Could not send notification to local client: " + e); MyLog.Default.WriteLineAndConsole(modName + " error/exception: Could not send notification to local client: " + e); } }
public override void Close() { try { if (SessionCore.Settings.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Drill?.CustomName}.Close().DebugClose", Scrap); } try { SessionCore.SaveUnregister(Save); SyncHarvestEfficiency.GotValueFromServer -= Drill.UpdateVisual; SyncHarvestEfficiency.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Drill?.CustomName}.Close()", Scrap); } }
public override void UpdateOnceBeforeFrame() { try { if (Drill.CubeGrid.Physics?.Enabled != true || !Networker.Inited) { NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; if (!Networker.Inited) { Networker.Init(SessionCore.ModID); } return; } SyncHarvestEfficiency = new Syncer <float>(Drill, "HarvestEfficiency", 1, Checker: val => val >= 1 && val <= 4); SyncHarvestEfficiency.GotValueFromServer += Drill.UpdateVisual; Drill.PowerConsumptionMultiplier = PowerConsumptionMultiplier(); CheckInitControls(); Load(); SessionCore.SaveRegister(Save); NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; DebugNote = MyAPIGateway.Utilities.CreateNotification($"{Drill?.CustomName}", int.MaxValue, "Blue"); Owner = MyAPIGateway.Players.GetPlayer(Drill.OwnerId); if (SessionCore.Settings.Debug) { DebugNote.Show(); } } catch { } }
public override void UpdateOnceBeforeFrame() { try { if (Tool.CubeGrid.Physics == null) { NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; return; } Term = Grid.GetTerminalSystem(); ToolCargo = Tool.GetInventory(); CheckInitControls(); SyncBeamLength = new AutoSet <float>(Tool, "BeamLength", Checker: val => val >= MinBeamLengthBlocks && val <= MaxBeamLengthBlocks); SyncDistanceMode = new AutoSet <bool>(Tool, "DistanceBasedMode"); SyncBeamLength.Ask(); SyncDistanceMode.Ask(); BeamLength = 1; Tool.AppendingCustomInfo += Tool_AppendingCustomInfo; Load(); NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; DebugNote = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red")); if (SessionCore.Debug) { DebugNote.Show(); } } catch { } }
public static void Error(string msg) { Info("ERROR: " + msg); try { string text = ModName + " error - open %AppData%/SpaceEngineers/Storage/..._" + ModName + "/" + LogFile + " for details"; MyLog.Default.WriteLineAndConsole(text); if (_notify == null) { _notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { _notify.Text = text; _notify.ResetAliveTime(); } _notify.Show(); } catch (Exception e) { Info("ERROR: Could not send notification to local client: " + e.ToString()); } }
public static void Error(string msg) { Info("ERROR: " + msg); try { MyLog.Default.WriteLineAndConsole(MOD_NAME + " error: " + msg); string text = MOD_NAME + " error - open %AppData%/SpaceEngineers/Storage/" + WORKSHOP_ID + "_" + MOD_NAME + "/" + LOG_FILE + " for details"; if (notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { notify.Text = text; notify.ResetAliveTime(); } notify.Show(); } catch (Exception e) { Info("ERROR: Could not send notification to local client: " + e.ToString()); } }
public void HideNotification() { if (m_notification != null) { m_notification.Hide(); m_notification = null; } }
public override void UpdateOnceBeforeFrame() { try { if (RadarBlock.CubeGrid.Physics == null) { NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; return; } if (!Networker.Inited) { Networker.Init(907384096); } if (!Controls.InitedRadarControls) { Controls.InitRadarControls(); } NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME; GetMaxPower(); Term = RadarBlock.CubeGrid.GetTerminalSystem(); RadarPower = new AutoSet <float>(RadarBlock, "Power", 1000, x => x >= 0 && x <= MaxPower); ShowMarkers = new AutoSet <bool>(RadarBlock, "ShowMarkers", true, null); ShowRoids = new AutoSet <bool>(RadarBlock, "ShowRoids", true, null); ActiveRadar = new AutoSet <bool>(RadarBlock, "Active", false, null); ShowOnlyHostiles = new AutoSet <bool>(RadarBlock, "OnlyHostiles", true, null); ShowFloating = new AutoSet <bool>(RadarBlock, "Floating", false, null); ShowWorkingGridsOnly = new AutoSet <bool>(RadarBlock, "ShowWorkingGridsOnly", false, null); PowerModule.InitResourceSink(); PersistenceModule.Load(); RadarBlock.AppendingCustomInfo += RadarBlock_AppendingCustomInfo; RadarBlock.OnMarkForClose += OnMarkForClose; Debug.Write($"Added radar {RadarBlock.EntityId}"); if (RadarCore.Debug) { TestNote = MyAPIGateway.Utilities.CreateNotification($"{RadarBlock.CustomName}: enabled;", int.MaxValue, "Green"); } if (RadarCore.Debug) { TestNote.Show(); } RadarCore.DebugWrite("Testing", "TESTING", true); //MyRadarGrid = RadarBlock.CubeGrid.Components.Get<RadarableGrid>(); if (MyRadarGrid == null) { throw new Exception($"{RadarBlock.CustomName}.MyRadarGrid is null!"); } } catch { } }
public ReputationMessage() { ReputationChangeAmount = 0; ReputationFactionTarget = ""; CurrentValue = 0; Increase = false; Color = "Red"; Notification = MyAPIGateway.Utilities.CreateNotification("", 2000, Color); LastAliveTime = MyAPIGateway.Session.GameDateTime; }
public bool DisplayMsg() { if (Message != null && m_notification == null) { m_notification = MyAPIGateway.Utilities.CreateNotification(Message, 0, (IsMsgWinning ? MyFontEnum.Green : MyFontEnum.Red)); m_notification.Show(); return(true); } return(false); }
public bool DisplayMsg() { if (Message != null && m_notification==null) { m_notification=MyAPIGateway.Utilities.CreateNotification(Message, 0, (IsMsgWinning ? MyFontEnum.Green : MyFontEnum.Red)); m_notification.Show(); return true; } return false; }
public static void ShowDebug(this IMyHudNotification notification) { if (!Debug) #pragma warning disable 162 { return; } #pragma warning restore 162 notification.Show(); }
/// <summary> /// Prints a message to the player, repeated calls to this method will overwrite the previous message on the HUD, therefore preventing spam. /// </summary> public void NotifyHUD(string message, int time = 3000, string font = MyFontEnum.White) { if (notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(string.Empty); } notify.Text = "Air leak scan: " + message; notify.AliveTime = time; notify.Font = font; notify.Show(); }
private void ShowNotification(string text, MyFontEnum color) { if (mNotify == null) { mNotify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { mNotify.Text = text; mNotify.ResetAliveTime(); } mNotify.Show(); }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="displayms"></param> public void ShowOnHud(string text, int displayms = 10000) { if (_Notify == null) { _Notify = MyAPIGateway.Utilities.CreateNotification(text, displayms, MyFontEnum.Red); } else { _Notify.Text = text; _Notify.ResetAliveTime(); } _Notify.Show(); }
void PrintMissing(HashSet <IMySlimBlock> UnbuiltBlocks) { //if (UnbuiltBlocks == null || UnbuiltBlocks.Count == 0) return; var Player = MyAPIGateway.Session.Player; if (Player == null) { return; } if (Player.IdentityId != Tool.OwnerId) { return; } if (Player.GetPosition().DistanceTo(Tool.GetPosition()) > 1000) { return; } StringBuilder Text = new StringBuilder(); Text.AppendLine($"Performance impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 4).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 4).ToString() : "--")} ms (avg/max)"); if (UnbuiltBlocks.Count == 1) { IMySlimBlock Block = UnbuiltBlocks.First(); Text.AppendLine($"{Tool.CustomName}: can't proceed to build {Block.BlockDefinition.DisplayNameText}, missing:\n"); var Missing = Block.ReadMissingComponents(); foreach (var ItemPair in Missing) { Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}"); } } else if (UnbuiltBlocks.Count > 1) { Text.AppendLine($"{Tool.CustomName}: can't proceed to build {UnbuiltBlocks.Count} blocks:\n"); foreach (IMySlimBlock Block in UnbuiltBlocks) { var Missing = Block.ReadMissingComponents(); Text.AppendLine($"{Block.BlockDefinition.DisplayNameText}: missing:"); foreach (var ItemPair in Missing) { Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}"); } Text.AppendLine(); } } Text.RemoveTrailingNewlines(); IMyHudNotification hud = MyAPIGateway.Utilities.CreateNotification(Text.ToString(), (int)(SessionCore.TickLengthMs * (SessionCore.WorkSkipTicks + 1)), "Red"); // Adding 1 excess tick is needed, otherwise notification can flicker hud.Show(); }
public void Print(Channel channel, string text, string font = MyFontEnum.Debug, int aliveTime = 200) { IMyHudNotification notification = Channels[(int)channel]; if (notification == null) { notification = MyAPIGateway.Utilities.CreateNotification(string.Empty); Channels[(int)channel] = notification; } notification.Hide(); // required since SE v1.194 notification.Font = font; notification.Text = text; notification.AliveTime = aliveTime; notification.Show(); }
public override void Init(MyEntityComponentDefinition definition) { base.Init(definition); _definition = definition as MrzInventoryInteractionComponentDefinition; if (_definition == null) { return; } _interactionMessage = _definition.InteractionMessage; MrzUtils.ShowNotificationDebug($"InvInteraction::IsServer = {MrzUtils.IsServer}", 500); _successNotification = MrzUtils.CreateNotification(MyTexts.GetString(_definition.SuccessNotification)); _failureNotification = MrzUtils.CreateNotification(MyTexts.GetString(_definition.FailureNotification), MrzUtils.NotificationType.Error); }
private void Initialize() { if (_initialized) { return; } MyLog.Default.Info("Init #{0} \"{1}\"", Session.Player.IdentityId, Session.Player.DisplayName); Session.Player.Controller.ControlledEntityChanged += ControlledEntityChanged; ControlledEntityChanged(null, Session.Player.Controller.ControlledEntity); _notification = MyAPIGateway.Utilities.CreateNotification(""); _notification.Font = "Monospace"; _initialized = true; }
private QuickActionHudSpace() : base(HudMain.Root) { DrawBoundingBox = false; targetGrid = new TerminalGrid(); tempGrid = new TerminalGrid(); targetBuffer = new List <IMySlimBlock>(); Target = new PropertyBlock(); quickActionMenu = new QuickActionMenu(this); boundingBox = new BoundingBoard(); hudNotification = MyAPIGateway.Utilities.CreateNotification("", 1000, MyFontEnum.Red); frameTimer = new Stopwatch(); frameTimer.Start(); RichHudCore.LateMessageEntered += MessageHandler; }
private void ShowHudMessage(ref IMyHudNotification notify, string message, string printText, int printTime, string font) { try { if (!sessionReady || printText == null || MyAPIGateway.Utilities == null || MyAPIGateway.Utilities.IsDedicated) { return; } if (printText == PRINT_GENERIC_ERROR) { printText = errorPrintText; } else if (printText == PRINT_MESSAGE) { if (font == MyFontEnum.Red) { printText = $"[{modName} ERROR: {message}]"; } else { printText = $"[{modName} WARNING: {message}]"; } } if (notify == null) { notify = MyAPIGateway.Utilities.CreateNotification(printText, printTime, font); } else { notify.Hide(); // required since SE v1.194 notify.Text = printText; notify.AliveTime = printTime; notify.ResetAliveTime(); } notify.Show(); } catch (Exception e) { Info("ERROR: Could not send notification to local client: " + e); MyLog.Default.WriteLineAndConsole($"{modName} :: LOGGER error/exception: Could not send notification to local client: {e}"); } }
public static void SetLadderStatus(string text, string font, int aliveTime = 100) #endif { if(status == null) { status = MyAPIGateway.Utilities.CreateNotification(text, aliveTime, font); } else { status.Font = font; status.Text = text; status.AliveTime = aliveTime; status.Show(); } }
public void DrawTool(IMyAutomaticRifleGun gun) { holdingTool = gun; lastShotTick = gun.GunBase.LastShootTime.Ticks; if(toolStatus == null) toolStatus = Utilities.CreateNotification("", 500, MyFontEnum.White); SetToolStatus("For key combination help, type in chat: /concrete help", MyFontEnum.Blue, 1000); }
private void ShowNotification(string text, MyFontEnum color) { if(mNotify == null) { mNotify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red); } else { mNotify.Text = text; mNotify.ResetAliveTime(); } mNotify.Show(); }