예제 #1
0
 internal DebugCommand(Debugger.CommandFunction func, params CommandType[] types)
 {
     RegisterTypes(types);
     this.func = func;
     foreach (var t in types) {
         HelpArguments += t.ToString().ToLower() + " ";
     }
     HelpArguments = HelpArguments.TrimEnd(' ');
     ArgumentCount = types.Length;
 }
예제 #2
0
        internal void Update()
        {
            Instance = this;

            UpdatePerformance();

            if (currentState == stateNormal) {
                if (cameraTogglePressed) {
                    cameraTogglePressed = false;
                    currentState = stateCamera;
                    commandInputEnabled = false;
                    Visible = false;
                }

                if (toggleKeyPressed) {
                    toggleKeyPressed = false;
                    if (!IsOpen) {
                        Summon();
                    }
                }

                if (dismissFor > 0) {
                    int framesLeft = advanceFrames - dismissFor;
                    textFramesLeft.String = "Update " + framesLeft.ToString("000") + "/" + advanceFrames.ToString("000");
                    dismissFor--;
                    if (dismissFor == 0) {
                        Summon(true);
                    }
                }

                if (dismissPressed) {
                    Dismiss();
                }

                if (!IsOpen) {
                    return;
                }

                textCountdown.String = "";
                if (countDownTimer > 0) {
                    countDownTimer -= game.DeltaTime;
                    if (countDownTimer <= 0) {
                        dismissFor = advanceFrames;
                        locked = false;
                        Dismiss(false);
                        countDownTimer = 0;
                    }
                    if (game.MeasureTimeInFrames && game.FixedFramerate) {
                        textCountdown.String = countDownTimer.ToString("STARTING IN 00");
                    }
                    else {
                        textCountdown.String = countDownTimer.ToString("STARTING IN 00.00");
                    }
                    textCountdown.CenterOrigin();
                    return;
                }
            }
            else if (currentState == stateCamera) {
                if (cameraTogglePressed) {
                    cameraTogglePressed = false;
                    commandInputEnabled = true;
                    currentState = stateNormal;
                    Visible = true;
                }

                DebugCameraX += (debugCamX - DebugCameraX) * 0.25f;
                DebugCameraY += (debugCamY - DebugCameraY) * 0.25f;

                Scene.Instance.UpdateCamera();
            }

            imgOverlay.Alpha = Util.Approach(imgOverlay.Alpha, backgroundAlpha, 0.05f);
            imgScrollBar.Alpha = imgScrollBarBg.Alpha = imgOverlay.Alpha;
            imgOtter.Alpha = imgOverlay.Alpha * 0.25f;

            imgError.Alpha = Util.Approach(imgError.Alpha, 0, 0.02f);

            string displayString = keyString;
            if (keyString.Length > maxChars) displayString = keyString.Substring(keyString.Length - maxChars);
            textInput.String = "> " + displayString + "|";

            imgScrollBar.ScaledHeight = maxLines / Util.Max(debugLog.Count, maxLines) * textAreaHeight;

            int logMax = (int)Util.Max(debugLog.Count - maxLines, 0);
            int scrollpos = (int)Util.Floor(Util.ScaleClamp(logIndex, 0, logMax, 0, textAreaHeight - imgScrollBar.ScaledHeight));

            imgScrollBar.Y = padding + scrollpos;

            if (enterPressed) {
                SendCommand(keyString);
            }

            time += game.DeltaTime;
        }
예제 #3
0
        internal Debugger(Game game)
        {
            Instance = this;
            this.game = game;

            imgOtter = new Image(new Texture(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Otter.otterlogo.png")));

            imgOtter.Batchable = false;

            imgOtter.CenterOrigin();
            imgOtter.Scroll = 0;

            UpdateSurface();

            textInput.Scroll = 0;
            textInput.OutlineThickness = 2;
            textInput.OutlineColor = Color.Black;

            textPastCommands.Scroll = 0;
            textPastCommands.OutlineColor = Color.Black;
            textPastCommands.OutlineThickness = 1;

            textCommandsBuffered.Scroll = 0;
            textCommandsBuffered.OutlineThickness = 2;
            textCommandsBuffered.OutlineColor = Color.Black;
            textCommandsBuffered.Color = Color.Gold;

            textCountdown.Scroll = 0;

            textCountdown.OutlineThickness = 3;
            textCountdown.OutlineColor = Color.Black;

            textFramesLeft.Scroll = 0;
            textFramesLeft.OutlineThickness = 2;
            textFramesLeft.OutlineColor = Color.Black;

            textPerformance.Scroll = 0;
            textPerformance.OutlineColor = Color.Black;
            textPerformance.OutlineThickness = 2;

            textCamera.OutlineThickness = 3;
            textCamera.OutlineColor = Color.Black;

            RegisterInstantCommand("help", "Shows help.", CmdHelp);
            RegisterInstantCommand("overlay", "Set the opacity of the console background to X.", CmdOverlay, CommandType.Float);
            RegisterInstantCommand("music", "Change the music volume. 0 - 1.", CmdMusic, CommandType.Float);
            RegisterInstantCommand("sound", "Change the sound volume. 0 - 1.", CmdSound, CommandType.Float);
            RegisterInstantCommand("clear", "Clears the console.", CmdClear);
            RegisterInstantCommand("showfps", "Shows performance information. Use 0 - 5.", CmdFps, CommandType.Int);
            RegisterInstantCommand("next", "Advances the game by X updates.", CmdNext, CommandType.Int);
            RegisterInstantCommand("watch", "Display watched values.", CmdWatch);
            RegisterInstantCommand("quit", "Exits the game.", CmdExit);

            RegisterCommand("spawn", "Add a new entity at X, Y.", CmdSpawn, CommandType.String, CommandType.Int, CommandType.Int);

            Log("== Otter Console Initialized!");
            Log("Use 'help' to see available commands.");
            Log("", false);

            IsOpen = false;
            dismissFor = 0;
        }
예제 #4
0
파일: Debugger.cs 프로젝트: voiddaek/STD
        internal Debugger(Game game) {
            Instance = this;
            this.game = game;

            imgOtter = new Image(new Texture(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Otter.otterlogo.png")));

            imgOtter.Batchable = false;

            imgOtter.CenterOrigin();
            imgOtter.Scroll = 0;

            UpdateSurface();

            textInput.Scroll = 0;
            textInput.OutlineThickness = 2;
            textInput.OutlineColor = Color.Black;

            textPastCommands.Scroll = 0;
            textPastCommands.OutlineColor = Color.Black;
            textPastCommands.OutlineThickness = 1;

            textPastCommandsLive.Scroll = 0;
            textPastCommandsLive.OutlineColor = Color.Black;
            textPastCommandsLive.OutlineThickness = 2;

            textCommandsBuffered.Scroll = 0;
            textCommandsBuffered.OutlineThickness = 2;
            textCommandsBuffered.OutlineColor = Color.Black;
            textCommandsBuffered.Color = Color.Gold;

            textCountdown.Scroll = 0;

            textCountdown.OutlineThickness = 3;
            textCountdown.OutlineColor = Color.Black;

            textFramesLeft.Scroll = 0;
            textFramesLeft.OutlineThickness = 2;
            textFramesLeft.OutlineColor = Color.Black;

            textPerformance.Scroll = 0;
            textPerformance.OutlineColor = Color.Black;
            textPerformance.OutlineThickness = 2;

            textCamera.OutlineThickness = 3;
            textCamera.OutlineColor = Color.Black;

            RegisterCommands();

            Log("== Otter Console Initialized!");
            Log("Use 'help' to see available commands.");
            Log("", false);

            IsOpen = false;
            dismissFor = 0;
        }