Beispiel #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");
        }
Beispiel #2
0
 public TextArea(string name, Vector2 position, Vector2 size, Phont font, string text, float relativeSize, float relativeLineSpacing, Color[] colors)
     : base(name, position + size * 0.5f, new OABB(size * 0.5f))
 {
     this.HalfSize    = size * 0.5f;
     this.font        = font;
     this.colors      = colors;
     this.text        = new List <TextSegment>();
     Height           = SetText(text, relativeSize, relativeLineSpacing);
     this.OnMouseMove = DoMouseMove;
     this.OnMouseOut  = DoMouseOut;
 }
Beispiel #3
0
        public static void Initialize(Phont font)
        {
            MapLoader.Initialize();
            PhantomGame.Game.Console.Register("editor", "Opens editor window.", delegate(string[] argv)
            {
                if (!(PhantomGame.Game.CurrentState is EditorState))
                {
                    PhantomGame.Game.PushState(new EditorState(PhantomGame.Game.CurrentState));
                }
                else
                {
                    PhantomGame.Game.PopState();
                    PhantomGame.Game.CurrentState.HandleMessage(Messages.MapLoaded, null);
                }
            });

            Editor.font = font;
        }
Beispiel #4
0
        static PhantomAssets()
        {
            Stream   stream;
            Assembly assembly = Assembly.GetAssembly(typeof(PhantomAssets));

            stream = assembly.GetManifestResourceStream("Phantom.Assets.white.png");
            White  = Texture2D.FromStream(PhantomGame.Game.GraphicsDevice, stream);

            stream = assembly.GetManifestResourceStream("Phantom.Assets.courier20bold.png");
            Texture2D courier20tex = Texture2D.FromStream(PhantomGame.Game.GraphicsDevice, stream);

            Courier20Bold = new PhontMono(courier20tex, 0.8f);

            stream = assembly.GetManifestResourceStream("Phantom.Assets.sans16.png");
            Texture2D sans16tex = Texture2D.FromStream(PhantomGame.Game.GraphicsDevice, stream);

            Sans16 = new Phont(sans16tex, 0.45f, 0.6f, 0.1f, 0.0f, 0.10f, 0.9f);
        }
Beispiel #5
0
 public Konsoul(Phont font = null)
     : this(font, new KonsoulSettings())
 {
 }