Пример #1
0
 public static void Close()
 {
     instance?.CloseMenuInternal();
     RichHudCore.LateMessageEntered -= MessageHandler;
     Target   = null;
     instance = null;
 }
Пример #2
0
        private void AddChatCommands()
        {
            CmdManager.GetOrCreateGroup("/bv2", new CmdGroupInitializer
            {
                { "help", x => RichHudTerminal.OpenToPage(helpMain) },
                { "bind", x => UpdateBind(x[0], x.GetSubarray(1)), 2 },
                { "resetBinds", x => BvBinds.Cfg = BindsConfig.Defaults },
                { "save", x => BvConfig.SaveStart() },
                { "load", x => BvConfig.LoadStart() },
                { "resetConfig", x => BvConfig.ResetConfig() },

                // Debug/Testing
                { "open", x => QuickActionHudSpace.TryOpenMenu() },
                { "close", x => QuickActionHudSpace.CloseMenu() },
                { "reload", x => ExceptionHandler.ReloadClients() },
                { "crash", x => Crash() },
                { "printControlsToLog", x => LogIO.WriteToLogStart($"Control List:\n{HelpText.controlList}") },
                { "export", x => ExportBlockData() },
                { "import", x => TryImportBlockData() },
                { "checkType", x => ExceptionHandler.SendChatMessage($"Block Type: {(QuickActionHudSpace.Target?.SubtypeId.ToString() ?? "No Target")}") },
                { "toggleDebug", x => QuickActionMenu.DrawDebug = !QuickActionMenu.DrawDebug },
                { "toggleVisDbg", x => PropertyBlock.DebugVisibility = !PropertyBlock.DebugVisibility },
                { "toggleBoundingBox", x => QuickActionHudSpace.DrawBoundingBox = !QuickActionHudSpace.DrawBoundingBox },
                { "targetBench", TargetBench, 1 },
                { "getTarget", x => GetTarget() },
            });
        }
Пример #3
0
        private void GetTarget()
        {
            IMyTerminalBlock tblock;

            if (QuickActionHudSpace.TryGetTargetedBlock(100d, out tblock))
            {
                ExceptionHandler.SendChatMessage($"Target: {tblock.GetType()}\nAccess: {tblock.GetAccessPermissions()}");
            }
            else
            {
                ExceptionHandler.SendChatMessage($"Error: No target found.");
            }
        }
Пример #4
0
        private void TargetBench(string[] args)
        {
            IMyTerminalBlock tblock;

            if (QuickActionHudSpace.TryGetTargetedBlock(100d, out tblock))
            {
                int  iterations;
                bool getProperties = false;

                int.TryParse(args[0], out iterations);

                if (args.Length > 1)
                {
                    bool.TryParse(args[1], out getProperties);
                }

                Stopwatch timer = new Stopwatch();
                timer.Start();

                var grid   = new TerminalGrid();
                var pBlock = new PropertyBlock();

                grid.SetGrid(tblock.CubeGrid);

                for (int n = 0; n < iterations; n++)
                {
                    IMyTerminalBlock temp;
                    QuickActionHudSpace.TryGetTargetedBlock(100d, out temp);
                    pBlock.SetBlock(grid, tblock);

                    if (getProperties)
                    {
                        pBlock.GetEnabledElementCount();
                    }
                }

                timer.Stop();
                ExceptionHandler.SendChatMessage
                (
                    $"Target Bench:\n" +
                    $"\tGetProperties: {getProperties}\n" +
                    $"\tTime: {(timer.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond):G6} ms\n" +
                    $"\tIsHighResolution: {Stopwatch.IsHighResolution}\n" +
                    $"\tIterations: {iterations}"
                );
            }
            else
            {
                ExceptionHandler.SendChatMessage($"Cant start target bench. No target found.");
            }
        }
Пример #5
0
        public override void BeforeClose()
        {
            if (ExceptionHandler.IsClient)
            {
                BvConfig.Save();
                QuickActionHudSpace.Close();
                BvConfig.OnConfigLoad -= UpdateBindPageVisibility;
            }

            if (ExceptionHandler.Unloading)
            {
                TerminalUtilities.Close();
                Instance = null;
            }
        }
Пример #6
0
        private void HudInit()
        {
            if (ExceptionHandler.IsClient)
            {
                CanUpdate = true;

                BvBinds.Init();
                BvConfig.Load();
                AddChatCommands();
                InitSettingsMenu();
                TerminalUtilities.Init();
                QuickActionHudSpace.Init();

                if (BvConfig.WasConfigOld)
                {
                    RichHudTerminal.OpenToPage(helpMain);
                }

                BvConfig.OnConfigLoad += UpdateBindPageVisibility;
                UpdateBindPageVisibility();
            }
        }
Пример #7
0
 protected override void Update()
 {
     QuickActionHudSpace.Update();
 }
Пример #8
0
 public static void Init()
 {
     Close();
     instance = new QuickActionHudSpace();
 }