Exemplo n.º 1
0
        public Konsoul(Phont font, KonsoulSettings settings)
        {
            if (font == null)
            {
                font = PhantomAssets.Courier20Bold;
            }
            this.Visible  = false;
            this.font     = font;
            this.Settings = settings;
            this.batch    = new SpriteBatch(PhantomGame.Game.GraphicsDevice);
            this.effect   = new BasicEffect(PhantomGame.Game.GraphicsDevice);

            this.input        = "";
            this.cursor       = 0;
            this.lines        = new List <string>();
            this.promptWidth  = this.font.MeasureString(this.Settings.Prompt).X;
            this.wrapBuffer   = new List <string>();
            this.nolineBuffer = "";
            this.scrollOffset = 0;
            this.history      = new List <string>();
            this.historyIndex = 0;
            this.controlDelay = -1;

            this.keyMap = new KeyMap();
            this.previousKeyboardState = Keyboard.GetState();

            this.commands      = new Dictionary <string, ConsoleCommand>();
            this.documentation = new Dictionary <string, string>();

            this.echoQueue = new Queue <EchoLine>(this.Settings.EchoLines);

#if PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MACOS
            try
            {
                this.history = new List <string>(System.IO.File.ReadAllLines("konsoul.dat"));
                if (this.history.Count > 0)
                {
                    int.TryParse(this.history[0], out this.Settings.LineCount);
                    this.history.RemoveAt(0);
                }
            }
            catch (System.IO.FileNotFoundException)
            {
            }
            catch (System.IO.IOException e)
            {
                this.AddLines("failed to load history: " + e.Message);
            }
#endif // PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MACOS

#if PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MACOS
            Trace.Listeners.Add(this.listener = new KonsoulTraceListener(this));
#endif // !PLATFORM_XBOX
            this.SetupVertices();
            this.SetupDefaultCommands();
            this.lines.Add("] Konsoul Initialized");
        }
Exemplo n.º 2
0
 public Konsoul(KonsoulSettings settings)
     : this(null, settings)
 {
 }
Exemplo n.º 3
0
        public Konsoul(SpriteFont font, KonsoulSettings settings)
        {
            this.Visible = false;
            this.font = font;
            this.settings = settings;
            this.batch = new SpriteBatch(PhantomGame.Game.GraphicsDevice);
            this.effect = new BasicEffect(PhantomGame.Game.GraphicsDevice);

            this.input = "";
            this.cursor = 0;
            this.lines = new List<string>();
            this.promptWidth = this.font.MeasureString(this.settings.Prompt).X;
            this.wrapBuffer = new List<string>();
            this.nolineBuffer = "";
            this.scrollOffset = 0;
            this.history = new List<string>();
            this.historyIndex = 0;
            this.controlDelay = -1;

            this.keyMap = new KeyMap();
            this.previousKeyboardState = Keyboard.GetState();

            this.commands = new Dictionary<string, ConsoleCommand>();
            this.documentation = new Dictionary<string, string>();

            this.echoQueue = new Queue<EchoLine>(this.settings.EchoLines);

            #if WINDOWS || LINUX || MONOMAC
            try
            {
                this.history = new List<string>(System.IO.File.ReadAllLines("konsoul.dat"));
                if (this.history.Count > 0)
                {
                    int.TryParse(this.history[0], out this.settings.LineCount);
                    this.history.RemoveAt(0);
                }
            }
            catch (System.IO.FileNotFoundException)
            {
            }
            catch (System.IO.IOException e)
            {
                this.AddLines("failed to load history: " + e.Message);
            }
            #endif // WINDOWS || LINUX || MONOMAC

            #if !XBOX
            Trace.Listeners.Add(this.listener = new KonsoulTraceListener(this));
            #endif // !XBOX
            this.SetupVertices();
            this.SetupDefaultCommands();
            this.lines.Add("] Konsoul Initialized");
        }