コード例 #1
0
        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();
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
ファイル: LaserDrill.cs プロジェクト: Cheetah97/LaserWelders
 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);
     }
 }
コード例 #5
0
        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();
                }
            }
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 public void HideNotification()
 {
     if (m_notification != null)
     {
         m_notification.Hide();
         m_notification = null;
     }
 }
コード例 #9
0
ファイル: ThrustBoost.cs プロジェクト: kapitanov/SE_Booster
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();
            Initialize();

            if (_grid == null || _thrusters.Count == 0)
            {
                return;
            }

            var hasOverheat = false;

            foreach (var t in _thrusters)
            {
                ThrusterMode thrusterMode;
                ReadThrusterState(t, out thrusterMode);
                hasOverheat = hasOverheat || thrusterMode == ThrusterMode.Overheat;
            }

            var enableBoost = MyAPIGateway.Input.IsAnyShiftKeyPressed() && !hasOverheat;

            var heatLevel = 0f;

            hasOverheat = false;
            foreach (var t in _thrusters)
            {
                float        thrusterHeat;
                ThrusterMode thrusterMode;
                UpdateThruster(t, enableBoost, out thrusterHeat, out thrusterMode);
                if (heatLevel < thrusterHeat)
                {
                    heatLevel = thrusterHeat;
                }

                hasOverheat = hasOverheat || thrusterMode == ThrusterMode.Overheat;
            }

            if (enableBoost || heatLevel > 0f)
            {
                var progress = 100f * heatLevel / MAX_HEAT;
                _notification.Text = RenderMessage(progress, hasOverheat, enableBoost);

                _notification.ResetAliveTime();
                _notification.Show();
            }
            else
            {
                _notification.Hide();
            }
        }
コード例 #10
0
            /// <summary>
            /// Hides notificatins
            /// </summary>
            public override void Hide()
            {
                header.Hide();

                foreach (IMyHudNotification prop in list)
                {
                    if (prop != null)
                    {
                        prop.Hide();
                    }
                }

                base.Hide();
            }
コード例 #11
0
        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();
        }
コード例 #12
0
            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}");
                }
            }
コード例 #13
0
ファイル: ReputationMessage.cs プロジェクト: jturp/RivalAI
        public void DisplayMessage(int amount)
        {
            var time = MyAPIGateway.Session.GameDateTime - LastAliveTime;

            if (time.TotalSeconds > Notification.AliveTime)
            {
                CurrentValue = 0;
            }

            CurrentValue += amount;
            Notification.Hide();
            Notification.Font = CurrentValue < 0 ? "Red" : "Green";
            Notification.Text = string.Format("Reputation With {0} Changed By: {1}", ReputationFactionTarget, CurrentValue);
            Notification.ResetAliveTime();
            Notification.Show();
            LastAliveTime = MyAPIGateway.Session.GameDateTime;
            //Logger.MsgDebug(string.Format("Rep Message Displayed. Current Value {0} - ReceivedAmount: {1}", CurrentValue, amount), DebugTypeEnum.Owner);
        }