Font is the low-level class for loading and manipulating character fonts. This class is meant to be used by String2D
Inheritance: ObjectBase
Esempio n. 1
0
        public override void loadContent()
        {
            float logoScale;

            _logoTexture = ResourceManager.getResource<Texture>("logo_1");
            _logoShape = new RectangleShape();
            _logoShape.Texture = _logoTexture;
            _logoShape.Size = new Vector2f(_logoTexture.Size.X, _logoTexture.Size.Y);
            logoScale = Game.window.GetView().Size.X / (float)_logoTexture.Size.X;
            _logoShape.Scale = new Vector2f(logoScale, logoScale);

            _font = ResourceManager.getResource<Font>("immortal_font");
            _options = new List<Text>();
            _options.Add(new Text("New Game", _font, 48));
            _options.Add(new Text("Continue", _font, 48));
            _options.Add(new Text("Options", _font, 48));
            _options.Add(new Text("Exit", _font, 48));

            for (int i = 0; i < _options.Count; i++)
            {
                Text text = _options[i];

                text.Position = new Vector2f(128, i * 48 + _logoShape.Size.Y * _logoShape.Scale.Y + 64);
            }
        }
Esempio n. 2
0
    public static void LoadTextures()
    {
        // Conjuntos
        Tex_Character = AddTextures(Directories.Tex_Characters.FullName);
        Tex_Tile      = AddTextures(Directories.Tex_Tiles.FullName);
        Tex_Face      = AddTextures(Directories.Tex_Faces.FullName);
        Tex_Panel     = AddTextures(Directories.Tex_Painel.FullName);
        Tex_Button    = AddTextures(Directories.Tex_Buttons.FullName);
        Tex_Panorama  = AddTextures(Directories.Tex_Panoramas.FullName);
        Tex_Fog       = AddTextures(Directories.Tex_Fogs.FullName);
        Tex_Light     = AddTextures(Directories.Tex_Lights.FullName);
        Tex_Item      = AddTextures(Directories.Tex_Items.FullName);

        // Únicas
        Tex_Weather     = new Texture(Directories.Tex_Weather.FullName + Format);
        Tex_Blank       = new Texture(Directories.Tex_Blanc.FullName + Format);
        Tex_Directions  = new Texture(Directories.Tex_Directions.FullName + Format);
        Tex_Transparent = new Texture(Directories.Tex_Transparent.FullName + Format);
        Tex_Grid        = new Texture(Directories.Tex_Grid.FullName + Format);
        Tex_CheckBox    = new Texture(Directories.Tex_CheckBox.FullName + Format);
        Tex_TextBox     = new Texture(Directories.Tex_TextBox.FullName + Format);
        Tex_Lighting    = new Texture(Directories.Tex_Lighting.FullName + Format);

        // Fontes
        GameFont = new SFML.Graphics.Font(Directories.Fonts.FullName + "Georgia.ttf");
    }
Esempio n. 3
0
        public SelectLevelView(MainMenuView menu)
        {
            scene = new Scene(ScrollInputs.None);
            Font text = new Font("Content/font.ttf");
            (backButton = new FastButton(text, 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(500, 600),
                Size = new Vector2f(280, 49),
                Text = "Back to Menu",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            }).OnClick += BackToMenu;

            string[] files = Directory.GetFiles("Content/Levels/", "*.json");
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                string name = JsonConvert.DeserializeObject<GameScene>(File.ReadAllText(file)).Name;
                FastButton level = new FastButton(text, 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
                {
                    Position = new Vector2f(300, 50 + i * 50),
                    Size = new Vector2f(680, 49),
                    Text = "Play " + name,
                    Anchor = AnchorPoints.Left | AnchorPoints.Top
                };
                level.OnClick += (s, e) =>
                {
                    Next(this, new InGameView(file, this));
                };

                scene.AddComponent(level);
            }

            scene.AddComponent(backButton);
            this.menu = menu;
        }
    public static void LerTexturas()
    {
        // Conjuntos
        Tex_Personagem = AdicionarTexturas(Diretórios.Tex_Personagens.FullName);
        Tex_Azulejo    = AdicionarTexturas(Diretórios.Tex_Azulejos.FullName);
        Tex_Face       = AdicionarTexturas(Diretórios.Tex_Faces.FullName);
        Tex_Painel     = AdicionarTexturas(Diretórios.Tex_Paineis.FullName);
        Tex_Botão      = AdicionarTexturas(Diretórios.Tex_Botões.FullName);
        Tex_Panorama   = AdicionarTexturas(Diretórios.Tex_Panoramas.FullName);
        Tex_Fumaça     = AdicionarTexturas(Diretórios.Tex_Fumaças.FullName);
        Tex_Luz        = AdicionarTexturas(Diretórios.Tex_Luzes.FullName);
        Tex_Item       = AdicionarTexturas(Diretórios.Tex_Itens.FullName);

        // Únicas
        Tex_Clima         = new Texture(Diretórios.Tex_Clima.FullName + Formato);
        Tex_Preenchido    = new Texture(Diretórios.Tex_Preenchido.FullName + Formato);
        Tex_Direções      = new Texture(Diretórios.Tex_Direções.FullName + Formato);
        Tex_Transparente  = new Texture(Diretórios.Tex_Transparente.FullName + Formato);
        Tex_Grade         = new Texture(Diretórios.Tex_Grade.FullName + Formato);
        Tex_Marcador      = new Texture(Diretórios.Tex_Marcador.FullName + Formato);
        Tex_Digitalizador = new Texture(Diretórios.Tex_Digitalizador.FullName + Formato);
        Tex_Iluminação    = new Texture(Diretórios.Tex_Iluminação.FullName + Formato);

        // Fontes
        Fonte = new SFML.Graphics.Font(Diretórios.Fontes.FullName + "Georgia.ttf");
    }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyledTextsDrawer"/> class.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <exception cref="ArgumentNullException"><paramref name="font" /> is <c>null</c>.</exception>
        public StyledTextsDrawer(Font font)
        {
            if (font == null)
                throw new ArgumentNullException("font");

            _font = font;
        }
Esempio n. 6
0
        public ButtonControl(Font font, uint size, Texture button, Texture hover, Texture press)
        {
            left = new RectangleShape();
            middle = new RectangleShape();
            right = new RectangleShape();

            left.Texture = button;
            middle.Texture = button;
            right.Texture = button;

            left.TextureRect = new IntRect(0, 0, (int)button.Size.X / 2 - 1, (int)button.Size.Y);
            middle.TextureRect = new IntRect((int)button.Size.X / 2 - 1, 0, 2, (int)button.Size.Y);
            right.TextureRect = new IntRect((int)button.Size.X / 2 + 1, 0, (int)button.Size.X / 2, (int)button.Size.Y);

            text = new TextControl(font, size) { TextAlignment = Alignment.MiddleCenter, Bold = true };
            text.BackgroundColor = Color.Transparent;

            IsHovered = false;
            IsPressed = false;
            ClickYOffset = 4.0f;

            buttonTexture = button;
            hoverTexture = hover;
            pressedTexture = press;
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "Test01");
            window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); };

            Font font = new Font("SnowflakeLetters.ttf");
            Text text = new Text("BALD IST WEIHNACHTEN!", font);
            Color col1 = new Color(123, 12, 12);
            text.Position = new Vector2f(200, 200);
            CircleShape shape = new CircleShape(20, 8);
            shape.FillColor = Color.White;
            shape.Position = new Vector2f(50, 50);
            float a, c;
            a = c = 50f;

            while (window.IsOpen())
            {
                window.Clear(col1);
                window.Draw(text);
                if (Keyboard.IsKeyPressed(Keyboard.Key.Left) && a > 0)
                    a -= 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Right) && a < window.Size.X - shape.Radius * 2)
                    a += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Down) && c < window.Size.Y - shape.Radius * 2)
                    c += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up) && c >  0)
                    c -= 0.1f;
                window.Draw(shape);
                shape.Position = new Vector2f(a, c);

                window.Display();
                window.DispatchEvents();
            }
        }
Esempio n. 8
0
 public static void PrecacheFont(string what)
 {
     if (fonts.ContainsKey(what)) { return; }
     string thePath = Path.Combine(RootDirectory, what);
     Font theFont = new Font(thePath);
     fonts.Add(what, theFont);
 }
        public BigLabeledButtonComponent(Screen screen, Texture buttonTexture, Vector2f position, string text, Color buttonColor, Action onClick)
            : base(screen)
        {
            _buttonTexture = buttonTexture;
            _position = position;
            _buttonColor = buttonColor;
            _selectedColor = new Color(
                (byte)Math.Min(255, (int)_buttonColor.R + 50),
                (byte)Math.Min(255, (int)_buttonColor.G + 50),
                (byte)Math.Min(255, (int)_buttonColor.B + 50),
                255);
            _onClick = onClick;
            _font = ResourceManager.getResource<Font>("immortal_font");

            // Initialize button shape
            _buttonShape = new RectangleShape();
            _buttonShape.Texture = _buttonTexture;
            _buttonShape.Position = position;
            _buttonShape.Size = new Vector2f(_buttonShape.Texture.Size.X, _buttonShape.Texture.Size.Y);
            _buttonShape.FillColor = _buttonColor;

            // Initialize text
            _firstLetter = new Text(text.Substring(0, 1), _font, 72);
            _firstLetter.Position = position + new Vector2f(30, 0);
            _firstLetter.Color = Color.White;
            _firstLetterShadow = new Text(_firstLetter.DisplayedString, _font, 72);
            _firstLetterShadow.Position = _firstLetter.Position + new Vector2f(3, 3);
            _firstLetterShadow.Color = Color.Black;
            _word = new Text(text.Substring(1, text.Length - 1), _font, 48);
            _word.Position = _firstLetter.Position + new Vector2f(_firstLetter.GetLocalBounds().Width + 4, 13);
            _word.Color = Color.White;
            _wordShadow = new Text(_word.DisplayedString, _font, 48);
            _wordShadow.Position = _word.Position + new Vector2f(3, 3);
            _wordShadow.Color = Color.Black;
        }
Esempio n. 10
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct the text from a string, font and size
 /// </summary>
 /// <param name="str">String to display</param>
 /// <param name="font">Font to use</param>
 /// <param name="characterSize">Base characters size</param>
 ////////////////////////////////////////////////////////////
 public Text(string str, Font font, uint characterSize) :
     base(sfText_create())
 {
     DisplayedString = str;
     Font = font;
     CharacterSize = characterSize;
 }
Esempio n. 11
0
        private int selected;       //the menu option we have selected

        public MenuState()
        {
            //initializing the menu object we have selected
            //this is honesty unnecessary, but i like to make things explicit
            selected = 0;

            //our font object our text uses
            //(note: use a different font, this one is pulled directly from the SFML.net examples)
            font = new Font("sansation.ttf");

            //the title of our menu
            title = new Text("INVASION GRID", font);
            title.Position = new Vector2f(50.0f, 10.0f);
            title.CharacterSize = 40;

            //setup for our options text
            options = new Text[4];

            options[0] = new Text("Easy Mode", font);
            options[1] = new Text("HARDCORE MODE", font);
            options[2] = new Text("High Scores", font);
            options[3] = new Text("Quit", font);

            for (int i = 0; i < 4; i++)
            {
                options[i].Position = new Vector2f(50.0f, 100.0f * (i + 1));
                options[i].Color = Color.Red;
            }

            //setup for our pointer
            pointer = new Text(">", font);
            pointer.Position = new Vector2f(30.0f, 100.0f);
            pointer.Color = Color.White;
        }
Esempio n. 12
0
        public override void OnEngineInit()
        {
            base.OnEngineInit();

            this.fnt = new Font(Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + Path.DirectorySeparatorChar + "georgia.ttf");
            this.txt = new Text(string.Empty, fnt, 24);
        }
Esempio n. 13
0
        public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
        {
            var spawnArea = spawn.SpawnArea;

            // Only draw if it does not cover the whole map
            if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
                return;

            // Draw spawn area
            Vector2 cameraOffset = map.Camera.Min;
            Rectangle rect = spawnArea.ToRectangle(map);
            rect.X -= (int)cameraOffset.X;
            rect.Y -= (int)cameraOffset.Y;
            RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);

            // Draw name
            CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];
            if (charTemp != null)
            {
                string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);

                Vector2 textPos = new Vector2(rect.X, rect.Y);
                textPos -= new Vector2(0, font.MeasureString(text).Y);
                textPos = textPos.Round();

                spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
            }
        }
Esempio n. 14
0
 public UiLabel(string text, Font font)
 {
     this.font = font;
     foreground = new Color(255, 255, 255);
     backgroundColor = new Color(0, 0, 0, 80);
     CreateDrawables(text);
 }
Esempio n. 15
0
        public Menu()
        {

            selected = 0;

            font = new Font("sansation.ttf");

            title = new Text("INVASION GRID", font);
            title.Position = new Vector2f(50.0f, 10.0f);
            title.CharacterSize = 40;

            options = new Text[4];

            options[0] = new Text("Easy Mode", font);
            options[1] = new Text("HARDCORE MODE", font);
            options[2] = new Text("High Scores", font);
            options[3] = new Text("Quit", font);

            for(int i = 0; i < 4; i++)
            {
                options[i].Position = new Vector2f(50.0f, 100.0f * (i + 1));
                options[i].Color = Color.Red;
            }

            pointer = new Text(">", font);
            pointer.Position = new Vector2f(30.0f, 100.0f);
            pointer.Color = Color.White;

        }
Esempio n. 16
0
        protected static bool IsAssetValid(Font asset)
        {
            if (asset == null || asset.IsDisposed)
                return false;

            return true;
        }
Esempio n. 17
0
 static Debug()
 {
     drawInfos = new List<DebugDrawInfo>();
     font = new Font(System.IO.Path.Combine(
         Environment.GetFolderPath(Environment.SpecialFolder.Fonts),
         "ARIAL.TTF"));
 }
Esempio n. 18
0
    public static void LerTextures()
    {
        //Start the Devices
        Device = new RenderWindow(Window.Objects.Handle);
        Fonte  = new SFML.Graphics.Font(Directories.Fontes.FullName + "Georgia.ttf");

        // Sets
        Tex_Character = AddTextures(Directories.Tex_Characters.FullName);
        Tex_Tile      = AddTextures(Directories.Tex_Tiles.FullName);
        Tex_Face      = AddTextures(Directories.Tex_Faces.FullName);
        Tex_Panel     = AddTextures(Directories.Tex_Panels.FullName);
        Tex_Button    = AddTextures(Directories.Tex_Buttons.FullName);
        Tex_Panorama  = AddTextures(Directories.Tex_Panoramas.FullName);
        Tex_Smoke     = AddTextures(Directories.Tex_Smokes.FullName);
        Tex_Light     = AddTextures(Directories.Tex_Lightes.FullName);
        Tex_Item      = AddTextures(Directories.Tex_Items.FullName);

        //Unique
        Tex_Climate    = new Texture(Directories.Tex_Climate.FullName + Format);
        Tex_Preenchido = new Texture(Directories.Tex_Preenchido.FullName + Format);
        Tex_Location   = new Texture(Directories.Tex_Location.FullName + Format);
        Tex_Marker     = new Texture(Directories.Tex_Marker.FullName + Format);
        Tex_Scanner    = new Texture(Directories.Tex_Scanner.FullName + Format);
        Tex_Fundo      = new Texture(Directories.Tex_Fundo.FullName + Format);
        Tex_Location   = new Texture(Directories.Tex_Location.FullName + Format);
        Tex_Sombra     = new Texture(Directories.Tex_Sombra.FullName + Format);
        Tex_Bars       = new Texture(Directories.Tex_Bars.FullName + Format);
        Tex_Bars_Panel = new Texture(Directories.Tex_Bars_Panel.FullName + Format);
        Tex_Grade      = new Texture(Directories.Tex_Grade.FullName + Format);
        Tex_Equipments = new Texture(Directories.Tex_Equipments.FullName + Format);
    }
Esempio n. 19
0
        public Editor()
        {
            InitializeComponent();

            _instance = this;

            _changeMade = false;

            _curGame = new Game();

            _newGame = new NewGame();

            _IO = new IO();

            _newMap = new NewMap();

            _globalFont = new SFML.Graphics.Font("Georgia.ttf");

            _block = new Texture("block.png");

            _projectDirectory = new ProjectDirectory();

            _mapViewFormList = new List<MapViewerForm>();

            _actorManager = new ActorManagerForm();

            _gameRunner = new GameRunner(_curGame);

            _viewSwitch = new ViewSwitch();

            _viewVariable = new ViewVariable();

            DisableTool();
        }
Esempio n. 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlobalState"/> class.
        /// </summary>
        GlobalState()
        {
            ThreadAsserts.IsMainThread();

            // Load all sorts of stuff
            _contentManager = NetGore.Content.ContentManager.Create();

            var dbConnSettings = new DbConnectionSettings();
            _dbController =
                dbConnSettings.CreateDbControllerPromptEditWhenInvalid(x => new ServerDbController(x.GetMySqlConnectionString()),
                    x => dbConnSettings.PromptEditFileMessageBox(x));

            _defaultRenderFont = ContentManager.LoadFont("Font/Arial", 16, ContentLevel.Global);

            Character.NameFont = DefaultRenderFont;

            GrhInfo.Load(ContentPaths.Dev, ContentManager);
            AutomaticGrhDataSizeUpdater.Instance.UpdateSizes();

            _mapGrhWalls = new MapGrhWalls(ContentPaths.Dev, x => new WallEntity(x));

            // Load the child classes
            _mapState = new MapState(this);

            // Grab the audio manager instances, which will ensure that they are property initialized
            // before something that can't pass it an ContentManager tries to get an instance
            AudioManager.GetInstance(ContentManager);

            // Set the custom UITypeEditors
            CustomUITypeEditors.AddEditors(DbController);

            // Set up the timer
            _timer = new Timer { Interval = 1000 / 60 };
            _timer.Tick += _timer_Tick;
        }
Esempio n. 21
0
 public CharacterStatusComponent(Screen screen, Font font, int entityId, Vector2f offset)
     : base(screen)
 {
     _font = font;
     _entityId = entityId;
     _text = new Text("", font, 14);
     _offset = offset;
 }
Esempio n. 22
0
        //class specific vars go here
        public ScoreBoardState()
        {
            font = new Font("sansation.ttf");

            title = new Text("Scoreboard", font);
            title.Position = new Vector2f(50.0f, 10.0f);
            title.CharacterSize = 40;
        }
Esempio n. 23
0
 public Chat(Client client)
 {
     writing = false;
     myFont = new Font("content/arial.ttf");
     toWrite = "";
     msgList = new List<KeyValuePair<DateTime, string>>();
     this.client = client;
 }
Esempio n. 24
0
        public HardcoreModeState()
        {
            font = new Font("sansation.ttf");

            title = new Text("-HARDCORE MODE-", font);
            title.Position = new Vector2f(50.0f, 10.0f);
            title.CharacterSize = 40;
        }
 public TemporaryWorldTextComponent(Screen screen, Font font, string value, Vector2 position)
     : base(screen)
 {
     _font = font;
     _value = value;
     _worldPosition = position;
     _text = new Text(value, font, 18);
 }
Esempio n. 26
0
 public MenuItem(String item, Vector2f position, Func<int> action)
 {
     this.position = position;
     this.action = action;
     this.textFont = new Font("content/arial.ttf");
     this.itemText = new Text(item, textFont);
     this.itemText.Position = position;
 }
Esempio n. 27
0
        public EasyModeState()
        {
            font = new Font("sansation.ttf");

            title = new Text("Welcome to easy mode, scrub", font);
            title.Position = new Vector2f(50.0f, 10.0f);
            title.CharacterSize = 40;
        }
Esempio n. 28
0
        public CacheFont(Font font)
        {
            if (font != null) {
                _font = font;
                _initialized = true;
            }

            throw new ArgumentNullException("[Cache] Font provided is null.");
        }
Esempio n. 29
0
 public Font Font(string filename)
 {
     if (dctFonts.ContainsKey(filename)) return dctFonts[filename];
     var res = Resource(filename);
     if (res == null) return null;
     var fnt = new Font(res);
     dctFonts.Add(filename, fnt);
     return fnt;
 }
Esempio n. 30
0
 /// <summary>
 /// コンストラクター
 /// </summary>
 public FPSCounter()
 {
     this.prev = 0;
     this.count = 0;
     this.fps = 0;
     this.font = new Font (new MemoryStream (Properties.Resources.arial));
     this.watch = new Stopwatch ();
     this.watch.Start ();
 }
Esempio n. 31
0
        public Player()
        {
            Font font = new SFML.Graphics.Font("Resources/Fonts/BigBlue_TerminalPlus.ttf");

            text = new Text("Hello World", font)
            {
                FillColor     = SFML.Graphics.Color.White,
                CharacterSize = 24,
            };
        }
Esempio n. 32
0
        /// <summary>
        /// Initializes the <see cref="GameScreenHelper"/> class.
        /// </summary>
        static GameScreenHelper()
        {
            var content = ContentManager.Create();

            _defaultGameGUIFont = content.LoadFont("Font/PressStart2P", 14, ContentLevel.Global);
            _defaultChatFont = content.LoadFont("Font/PressStart2P", 14, ContentLevel.Global);
            _defaultScreenFont = content.LoadFont("Font/PressStart2P", 24, ContentLevel.Global);
            _defaultMenuButtonFont = content.LoadFont("Font/PressStart2P", 36, ContentLevel.Global);
            _defaultMenuTitleFont = content.LoadFont("Font/PressStart2P", 72, ContentLevel.Global);
        }
Esempio n. 33
0
 public override void Free()
 {
     if (Handle == null)
     {
         return;
     }
     //Console.WriteLine("Freeing font: {0:x16}", Handle.CPointer.ToInt64());
     Handle.Dispose();
     Handle = null;
 }
Esempio n. 34
0
        /// <summary>
        /// Initializes the <see cref="GameScreenHelper"/> class.
        /// </summary>
        static GameScreenHelper()
        {
            var content = ContentManager.Create();

            _defaultGameGUIFont = content.LoadFont("Font/Lavi", 14, ContentLevel.Global);
            _defaultChatFont = content.LoadFont("Font/Arial", 14, ContentLevel.Global);
            _defaultScreenFont = content.LoadFont("Font/Adler", 24, ContentLevel.Global);
            _defaultMenuButtonFont = content.LoadFont("Font/Biometric Joe", 36, ContentLevel.Global);
            _defaultMenuTitleFont = content.LoadFont("Font/If", 72, ContentLevel.Global);
        }
Esempio n. 35
0
        /// <summary>
        /// Initializes the <see cref="GameScreenHelper"/> class.
        /// </summary>
        static GameScreenHelper()
        {
            var content = ContentManager.Create();

            _defaultGameGUIFont = content.LoadFont("Font/varelaroundregular", 12, ContentLevel.Global);
            _defaultChatFont = content.LoadFont("Font/varelaroundregular", 12, ContentLevel.Global);
            _defaultScreenFont = content.LoadFont("Font/varelaroundregular", 24, ContentLevel.Global);
            _defaultMenuButtonFont = content.LoadFont("Font/journal", 42, ContentLevel.Global);
            _defaultMenuTitleFont = content.LoadFont("Font/journal", 72, ContentLevel.Global);
        }
Esempio n. 36
0
        /// <summary>
        /// Loads the specified font.
        /// </summary>
        /// <param name="font">Font to load.</param>
        /// <returns>True if succeeded.</returns>
        public override bool LoadFont(Font font)
        {
            font.RealSize = font.Size * Scale;

            var sfFont = new SFMLFont(font.FaceName);

            font.RendererData = sfFont;

            return(true);
        }
Esempio n. 37
0
            private void initializeRankAndFileDebugTextGraphics()
            {
                var textColor           = new SFML.Graphics.Color(red: 0x00, green: 0xD2, blue: 0xED);
                var textBackgroundColor = new SFML.Graphics.Color(red: 0x56, green: 0x56, blue: 0x56);
                var textFont            = new SFML.Graphics.Font("Assets/Fonts/RobotoMono-Regular.ttf");

                rankAndFileText = new Text(this.RankAndFile.ToString(), textFont)
                {
                    FillColor = textColor, OutlineColor = textBackgroundColor, OutlineThickness = 4
                };
                rankAndFileText.Style = SFML.Graphics.Text.Styles.Bold;
            }
Esempio n. 38
0
 private static void LoadSystemResources( )
 {
     try
     {
         systemFont = new Font("Resources/pixelmix.ttf");
     }
     catch (SFML.LoadingFailedException fileException)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(fileException.Message);
         Console.ForegroundColor = ConsoleColor.White;
     }
 }
Esempio n. 39
0
        public EditorDebug(SFML.Graphics.Font SystemFont)
        {
            //Init debug info
            DEBUG_INFO = new Text[5] {
                new Text("", SystemFont),
                new Text("", SystemFont),
                new Text("", SystemFont),
                new Text("", SystemFont),
                new Text("", SystemFont)
            };
            EditorFont = SystemFont;

            TextPropertiesCallback();
        }
Esempio n. 40
0
    public static void Init()
    {
        // Carrega a fonte
        Font_Default = new SFML.Graphics.Font(Directories.Fonts.FullName + "Georgia.ttf");

        // Carrega as texturas
        LoadTextures();

        // Inicia a janela
        RenderWindow                      = new RenderWindow(new VideoMode(800, 608), Lists.Options.Game_Name, Styles.Close);
        RenderWindow.Closed              += new EventHandler(Window.OnClosed);
        RenderWindow.MouseButtonPressed  += new EventHandler <MouseButtonEventArgs>(Window.OnMouseButtonPressed);
        RenderWindow.MouseMoved          += new EventHandler <MouseMoveEventArgs>(Window.OnMouseMoved);
        RenderWindow.MouseButtonReleased += new EventHandler <MouseButtonEventArgs>(Window.OnMouseButtonReleased);
        RenderWindow.KeyPressed          += new EventHandler <KeyEventArgs>(Window.OnKeyPressed);
        RenderWindow.KeyReleased         += new EventHandler <KeyEventArgs>(Window.OnKeyReleased);
        RenderWindow.TextEntered         += new EventHandler <TextEventArgs>(Window.OnTextEntered);
    }
Esempio n. 41
0
        /// <summary>
        ///  <para>Loads Font from given Zip-File and Entry.</para>
        /// </summary>
        private Font LoadFontFrom(ZipFile zipFile, ZipEntry fontEntry)
        {
            var byteBuffer = new byte[zipBufferSize];

            Stream zipStream = zipFile.GetInputStream(fontEntry);
            //Will throw exception is missing or wrong password. Handle this.

            var memStream = new MemoryStream();

            StreamUtils.Copy(zipStream, memStream, byteBuffer);
            memStream.Position = 0;

            Font loadedFont = new Font(memStream);


            // memStream.Close();
            zipStream.Close();
            // memStream.Dispose();
            zipStream.Dispose();

            return(loadedFont);
        }
Esempio n. 42
0
        public MainGame(Tiler.GSM.GameStateStack gameStateStack) : base(gameStateStack)
        {
            GameView = new View(GameStateContext.Window.RenderWindow.GetView());

            var font = new SFML.Graphics.Font("data/saxmono.ttf");

            var window = new Tiler.GUI.Controls.Window()
            {
                Font     = font,
                Position = new Vector2i(100, 100),
                Size     = new Vector2i(300, 300)
            };

            window.InvalidateLayout(true);

            var button = new Tiler.GUI.Controls.Button()
            {
                Parent        = window,
                Font          = font,
                CharacterSize = 14,
                Text          = "Animate",
                FillColor     = new SFML.Graphics.Color(100, 100, 100),
                TextColor     = SFML.Graphics.Color.Black
            };

            button.SizeToParent();
            button.Click += (s, e) =>
            {
                if (window.Animating)
                {
                    return;
                }

                var anim = window.NewAnimation <Tiler.GUI.Animations.Move>();
                anim.Duration = 1;
                anim.Finish  += (s2, e2) => Console.WriteLine("Finished animating");

                if (window.Position == new Vector2i(200, 200))
                {
                    anim.EndPosition = new Vector2i(100, 100);
                }
                else
                {
                    anim.EndPosition = new Vector2i(200, 200);
                }

                anim.Animate();
            };

            Gamemode = new TestGamemode();
            Gamemode.RegisterTileTypes();

            using (var MapBmp = new Bitmap("data/map.png"))
            {
                World.Map = new Map(MapBmp.Width, MapBmp.Height);

                for (int Y = 0; Y < MapBmp.Height; Y++)
                {
                    for (int X = 0; X < MapBmp.Width; X++)
                    {
                        var MapPx = MapBmp.GetPixel(X, Y);
                        var Tile  = 0;

                        if (MapPx.R == 255 && MapPx.G == 255 && MapPx.B == 255 && MapPx.A == 255)
                        {
                            Tile = 1;
                        }
                        else if (MapPx.R == 0 && MapPx.G == 0 && MapPx.B == 0 && MapPx.A == 255)
                        {
                            Tile = 2;
                        }
                        else if (MapPx.R == 0 && MapPx.G == 255 && MapPx.B == 0 && MapPx.A == 255)
                        {
                            Tile = 3;
                        }

                        World.Map.SetTile(X, Y, Tile);
                    }
                }
            }

            World.Entities.Add(new PlayerSpawn(192, 192));

            Player = new Player();

            Gamemode.CreateTeams();
            Gamemode.PlayerInitialSpawn(Player);
            PlayerSpawn spawnPoint = Gamemode.PlayerSelectSpawn(Player);

            if (spawnPoint is null)
            {
                throw new Exception("No spawnpoint");
            }

            // Original
            //Player.Position = spawnPoint.Position;

            var Body = Player.GetComponent <Tiler.ECS.Components.PhysicsBody>().Value;

            Body.Position = spawnPoint.SpawnPosition;
            Player.GetComponent <Tiler.ECS.Components.PhysicsBody>().Value = Body;

            Gamemode.PlayerSpawn(Player);
        }
Esempio n. 43
0
 public Renderer(RenderWindow _window)
 {
     _random = new Random();
     window  = _window;
     font    = new Font(FileSystemHelper.PathToResources + "Fonts" + FileSystemHelper.FileSystemSeparator + "kongtext.ttf");
 }
Esempio n. 44
0
 /// <summary>
 ///     Creates a new font by copying from another font.
 /// </summary>
 /// <param name="font">The font to copy.</param>
 public Font(Font font)
 {
     SFMLFont = new SFont(font.SFMLFont);
 }
Esempio n. 45
0
 /// <summary>
 ///     Creates a font by reading from a stream.
 /// </summary>
 public Font(Stream stream)
 {
     SFMLFont = new SFont(stream);
 }
Esempio n. 46
0
 internal Font(SFont font)
 {
     SFMLFont = font;
 }
Esempio n. 47
0
 public Font(byte[] data)
 {
     SFMLFont = new SFont(data);
 }
Esempio n. 48
0
        /// <summary>
        ///  <para>Loads all Resources from given Zip into the respective Resource Lists and Caches</para>
        /// </summary>
        public void LoadResourceZip(string path = null, string pw = null)
        {
            string zipPath  = path ?? _configurationManager.GetResourcePath();
            string password = pw ?? _configurationManager.GetResourcePassword();


            if (!File.Exists(zipPath))
            {
                throw new FileNotFoundException("Specified Zip does not exist: " + zipPath);
            }

            FileStream zipFileStream = File.OpenRead(zipPath);
            var        zipFile       = new ZipFile(zipFileStream);

            if (!string.IsNullOrWhiteSpace(password))
            {
                zipFile.Password = password;
            }

            var directories = from ZipEntry a in zipFile
                              where a.IsDirectory
                              orderby a.Name.ToLowerInvariant() == "textures" descending
                              select a;

            Dictionary <string, List <ZipEntry> > sorted = new Dictionary <string, List <ZipEntry> >();

            foreach (ZipEntry dir in directories)
            {
                if (sorted.ContainsKey(dir.Name.ToLowerInvariant()))
                {
                    continue;                                                  //Duplicate folder? shouldnt happen.
                }
                List <ZipEntry> folderContents = (from ZipEntry entry in zipFile
                                                  where entry.Name.ToLowerInvariant().Contains(dir.Name.ToLowerInvariant())
                                                  where entry.IsFile
                                                  select entry).ToList();

                sorted.Add(dir.Name.ToLowerInvariant(), folderContents);
            }

            sorted = sorted.OrderByDescending(x => x.Key == "textures/").ToDictionary(x => x.Key, x => x.Value); //Textures first.

            foreach (KeyValuePair <string, List <ZipEntry> > current in sorted)
            {
                switch (current.Key)
                {
                case ("textures/"):
                    foreach (ZipEntry texture in current.Value)
                    {
                        if (supportedImageExtensions.Contains(Path.GetExtension(texture.Name).ToLowerInvariant()))
                        {
                            Image loadedImg = LoadImageFrom(zipFile, texture);
                            if (loadedImg == null)
                            {
                                continue;
                            }
                            else
                            {
                                _images.Add(texture.Name, loadedImg);
                            }
                        }
                    }
                    break;

                case ("tai/"):    // Tai?
                    foreach (ZipEntry tai in current.Value)
                    {
                        if (Path.GetExtension(tai.Name).ToLowerInvariant() == ".tai")
                        {
                            IEnumerable <CluwneSprite> loadedSprites = LoadSpritesFrom(zipFile, tai);
                            foreach (CluwneSprite currentSprite in loadedSprites.Where(currentSprite => !_sprites.ContainsKey(currentSprite.Name)))
                            {
                                _sprites.Add(currentSprite.Name, currentSprite);
                            }
                        }
                    }
                    break;

                case ("fonts/"):
                    foreach (ZipEntry font in current.Value)
                    {
                        if (Path.GetExtension(font.Name).ToLowerInvariant() == ".ttf")
                        {
                            Font loadedFont = LoadFontFrom(zipFile, font);
                            if (loadedFont == null)
                            {
                                continue;
                            }
                            string ResourceName = Path.GetFileNameWithoutExtension(font.Name).ToLowerInvariant();
                            _fonts.Add(ResourceName, loadedFont);
                        }
                    }
                    break;

                case ("particlesystems/"):
                    foreach (ZipEntry particles in current.Value)
                    {
                        if (Path.GetExtension(particles.Name).ToLowerInvariant() == ".xml")
                        {
                            ParticleSettings particleSettings = LoadParticlesFrom(zipFile, particles);
                            if (particleSettings == null)
                            {
                                continue;
                            }
                            else
                            {
                                _particles.Add(Path.GetFileNameWithoutExtension(particles.Name), particleSettings);
                            }
                        }
                    }
                    break;

                case ("shaders/"):
                    foreach (ZipEntry shader in current.Value)
                    {
                        //FIXME Throws Exception
                        //if (Path.GetExtension(shader.Name).ToLowerInvariant() == ".fx")
                        //{
                        //    FXShader loadedShader = LoadShaderFrom(zipFile, shader);
                        //    if (loadedShader == null) continue;
                        //    else _shaders.Add(shader.Name, loadedShader);
                        //}
                    }
                    break;

                case ("animations/"):
                    foreach (ZipEntry animation in current.Value)
                    {
                        if (Path.GetExtension(animation.Name).ToLowerInvariant() == ".xml")
                        {
                            AnimationCollection animationCollection = LoadAnimationCollectionFrom(zipFile, animation);
                            if (animationCollection == null)
                            {
                                continue;
                            }
                            else
                            {
                                _animationCollections.Add(animationCollection.Name, animationCollection);
                            }
                        }
                    }
                    break;
                }
            }

            sorted = null;

            zipFile.Close();
            zipFileStream.Close();
            zipFileStream.Dispose();

            GC.Collect();
        }
Esempio n. 49
0
 public Font(string filename)
     : base(filename)
 {
     Handle = new SFML.Graphics.Font(filename);
 }
Esempio n. 50
0
 public BaseFont()
 {
     font = Fonts.DefaultFont;
 }