This class defines a graphical 2D text, that can be drawn on screen
See also the note on coordinates and undistorted rendering in SFML.Graphics.Transformable.
Наследование: Transformable, Drawable
Пример #1
0
        public MapRenderer(IntPtr mapRenderWindowHandle, IntPtr tileSetRenderHandle, MapEditor.MapEditorProperties mapEditorProperties)
        {
            _mapRenderWindow = new RenderWindow(mapRenderWindowHandle);
            _tileSetRenderWindow = new RenderWindow(tileSetRenderHandle);
            _mapRenderWindow.MouseButtonPressed += mapRenderWindow_MouseButtonPressed;
            _mapRenderWindow.MouseMoved += mapRenderWindow_MouseMoved;
            _tileSetRenderWindow.MouseButtonPressed += tileSetRenderWindow_MouseButtonPressed;
            _tileSetRenderWindow.MouseMoved += tileSetRenderWindow_MouseMoved;
            _tileSetRenderWindow.MouseButtonReleased += tileSetRenderWindow_MouseButtonReleased;

            _mapEditorProperties = mapEditorProperties;
            _mapEditorProperties.CurrentLayer = World.Map.Layers.Ground;
            _mapEditorProperties.MapView = new View(this._mapRenderWindow.DefaultView);

            _mousePositionText = new Text("", new Font(AppDomain.CurrentDomain.BaseDirectory + "/Data/Graphics/Fonts/MainFont.ttf"), 20);

            this.LoadTileSets();

            _tileSetView = this._tileSetRenderWindow.DefaultView;

            this.Running = true;

            this._mapRenderWindow.SetActive(false);
            this._tileSetRenderWindow.SetActive(false);

            new Thread(UpdateLoop).Start();
        }
        public void Draw()
        {
            SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
            s.Position = new Vector2f(X, Y);
            _screen.Draw(s);

            Text t = new Text();
            t.Font = Program.Data.Font;
            t.CharacterSize = 14;

            CraftGUI g = (CraftGUI)Program.SM.States[1].GameGUI[10];
            Items i = Program.Data.MyItems[Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass).Count];
            {
                if (SlotID + 3 * g.CurPage < i.ItemRequired.Count)
                {
                    s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Key].Sprite]);
                    s.Position = new Vector2f(X, Y);
                    _screen.Draw(s);

                    t.DisplayedString = Program.Data.MyItems[i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Key].Name + ": " + i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Value;
                    t.Position = new Vector2f(X + 38, Y + 8);
                    _screen.Draw(t);
                }
            }
        }
Пример #3
0
 public Text(Resources.Font font, int zorder = 0)
     : base(zorder)
 {
     Font     = font;
     Txt      = new SFML.Graphics.Text();
     Txt.Font = font.Handle;
 }
        public override void Draw(RenderTarget rt)
        {
            RectangleShape bgOverlay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height)) { FillColor = Color.Black };
            rt.Draw(bgOverlay);

            Text title = new Text("Game Over", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            title.Center();
            title.Round();
            rt.Draw(title);

            Text winnerTitle = new Text(GetWinnerText(), Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            winnerTitle.Center();
            winnerTitle.Round();
            rt.Draw(winnerTitle);

            base.Draw(rt);
        }
Пример #5
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;
        }
        public override void Draw(RenderTarget rt)
        {
            RectangleShape overylay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
            {
                FillColor = new Color(0, 0, 0, 128)
            };

            rt.Draw(overylay);

            RectangleShape window = new RectangleShape(new Vector2f(GameOptions.Width * (1.0f - PaddingHorizontal * 2.0f), GameOptions.Height * (1.0f - PaddingVertical * 2.0f)))
            {
                Position = new Vector2f(GameOptions.Width * PaddingHorizontal, GameOptions.Height * PaddingVertical),
                FillColor = Color.White,
                OutlineColor = Color.Black,
                OutlineThickness = 2.0f
            };

            rt.Draw(window);

            Text labelSettings = new Text("Join by IP", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + 48.0f),
                Color = Color.Black,
                CharacterSize = 32
            };

            labelSettings.Center();
            labelSettings.Round();
            rt.Draw(labelSettings);

            base.Draw(rt);
        }
Пример #7
0
        public PauseState(StateStack stack, Context context)
            : base(stack, context)
        {
            RenderWindow window = mContext.window;

            mBackgroundSprite = new Sprite();
            mPausedText = new Text();
            mInstructionText = new Text();

            mPausedText.Font = mContext.fonts.get(FontID.Main);
            mPausedText.DisplayedString = "Game Paused";
            mPausedText.CharacterSize = 70;
            mPausedText.centerOrigin();
            mPausedText.Position = new Vector2f(0, 0);

            mInstructionText.Font = mContext.fonts.get(FontID.Main);
            mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
            mInstructionText.centerOrigin();
            mInstructionText.Position = new Vector2f(0, 0);

            backgroundShape = new RectangleShape();
            backgroundShape.FillColor = new Color(0, 0, 0, 150);
            backgroundShape.Position = window.GetView().Center;
            backgroundShape.centerOrigin();
            backgroundShape.Size = window.GetView().Size;
        }
Пример #8
0
        public GameStateStart()
        {
            Game.Instance.AudioManager.PauseAllBackground();
            Game.Instance.AudioManager.PlaySound("game/background_music", true);

            if (Game.Instance.AllPlayers.Count != 1)
            {
                _gameMode = new MultiplayerGame(_allCells);
            }
            else
            {
                _gameMode = new SingleplayerGame(_allCells);
            }

            _gameMode.PrepareGame();

            _background = new Sprite(ResourceManager.Instance["menu/background"] as Texture);

            _playerInfoText = new Text(
                Game.Instance.Player.Name,
                ResourceManager.Instance["fonts/bebas_neue"] as Font,
                25) {
                       Position = new Vector2f(5, 5), Color = Game.Instance.Player.Color
                    };

            // register events
            Game.Instance.Window.MouseButtonPressed += MouseButtonPressed;
            Game.Instance.Window.MouseButtonReleased += MouseButtonReleased;
            Game.Instance.Window.KeyReleased += KeyReleased;
        }
Пример #9
0
 protected override float getTextWidthImpl(char[] chars)
 {
     using (Text textObj = createText(new PVector(), chars))
     {
         return(textObj.GetLocalBounds().Width);
     }
 }
Пример #10
0
 protected override void drawTextImpl(PVector position, char[] chars)
 {
     using (Text textObj = createText(position, chars))
     {
         window.Draw(textObj);
     }
 }
Пример #11
0
 public override void Init()
 {
     label = new Text(Text, Font);
     label.Scale = new SFML.Window.Vector2f(Scale, Scale);
     UpdateScale();
     base.Init();
 }
Пример #12
0
        public Hud(GameBase state)
        {
            _state = state;

            _selected = new Sprite(Assets.LoadTexture("wep_selected.png")).Center();

            _statusBack = new RectangleShape(new Vector2f(BarWidth + Padding * 2, BarHeight * 2 + Padding * 3));
            _statusBack.Position = new Vector2f(Padding, Padding);
            _statusBack.FillColor = new Color(0, 0, 0);
            _statusBack.OutlineThickness = 2;
            _statusBack.OutlineColor = new Color(38, 38, 38);

            _health = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _health.Position = _statusBack.Position + new Vector2f(Padding, Padding);
            _health.FillColor = new Color(0, 120, 0);

            _healthText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _healthText.Position = _health.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _healthText.Color = new Color(225, 225, 225);

            _energy = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _energy.Position = _health.Position + new Vector2f(0, BarHeight + Padding);
            _energy.FillColor = new Color(30, 30, 180);

            _energyText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _energyText.Position = _energy.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _energyText.Color = new Color(225, 225, 225);
        }
        public void Draw()
        {
            Text t = new Text();
            t.Font = Program.Data.Font;
            t.CharacterSize = 14;

            SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
            s.Position = new Vector2f(X, Y);
            _screen.Draw(s);

            ConstructionGUI g = (ConstructionGUI)Program.SM.States[1].GameGUI[9];
            if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX] > -1)
            {
                SpawnBuildable b = (SpawnBuildable)Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX]];
                if (SlotID + 3 * g.CurPage < b.Required.Count)//SlotID + 3 * g.CurPage < Program.Data.MySpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[g.LocY][g.LocX]].ID].)
                {
                    s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite]);
                    s.Position = new Vector2f(X, Y);
                    _screen.Draw(s);

                    t.DisplayedString = Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Name + ": " + (Program.Data.GetBuildableList()[b.ID].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Value - b.Required.ElementAt(SlotID + 3 * g.CurPage).Value.Count - b.Built.ElementAt(SlotID + 3 * g.CurPage).Value.Count) + "/" + b.Required.ElementAt(SlotID + 3 * g.CurPage).Value.Count + "/" + b.Built.ElementAt(SlotID + 3 * g.CurPage).Value.Count;
                    t.Position = new Vector2f(X + 38, Y + 8);
                    _screen.Draw(t);

                    if (State == 1)
                    {
                        b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.DrawSprite(_screen, Mouse.GetPosition(_screen).X - (int)Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite].Size.X / 2, Mouse.GetPosition(_screen).Y - (int)Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[b.Required.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Sprite].Size.Y / 2);
                    }
                }
            }
        }
Пример #14
0
 public SummaryStateView(SummaryState summaryState)
 {
     _score = new Sfg.Text($"Score: {summaryState.Score}", new Sfg.Font(FontFilePath), CharacterSize)
     {
         Position = new Vector2f(100, 100)
     };
 }
        public void Draw()
        {
            SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
            s.Position = new Vector2f(X, Y);
            _screen.Draw(s);

            Text t = new Text();
            t.Font = Program.Data.Font;
            t.CharacterSize = 11;
            t.Color = Color.Yellow;

            KnowledgeGUI g = (KnowledgeGUI)Program.SM.States[1].GameGUI[11];
            switch (g.CurView)
            {
                case 0:
                    if (g.KnowledgeDown + SlotID < Program.Data.MyKnowledge.Count)
                    {
                        s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Knowledge)[g.KnowledgeDown + SlotID]);
                        s.Position = new Vector2f(X + 1, Y + 1);
                        _screen.Draw(s);

                        t.DisplayedString = Program.Data.MyKnowledge[g.KnowledgeDown + SlotID].Name;
                        t.Position = new Vector2f(X + 30, Y + 5);
                        _screen.Draw(t);

                        if (Logic.CurrentParty.MainParty.MyParty[0].KnowledgeKnown.Contains(g.KnowledgeDown + SlotID))
                            s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[62]);
                        else
                            s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[59]);
                        s.Position = new Vector2f(X + 152, Y + 12);
                        _screen.Draw(s);
                    }
                    break;
            }
        }
Пример #16
0
        //totalbars - maxShown = max topBar
        internal BarracksScrollList(Barracks b, Vector2f start)
        {
            //int x = (overallRect.Height - 2 * 25) / champBarRect.Height;
            //scroll = overallRect.Height - (x * champBarRect.Height);
            maxShown = (int)((overallRect.Height - 2 * scroll) / champBarRect.Height - 1);
            totalBars = b.getTotalChamps();
            mBarracks = b;
            this.start = start;

            disabledButtons = new List<int>();
            champsItemIcons = new List<IconToolTip>();
            for(int i=0;i<totalBars;i++){
                ItemID item = mBarracks.getChamps()[i].item;
                Sprite itemS = new Sprite(Item.getItemTexture(item), new IntRect(0, 0, Item.ICON_WIDTH, Item.ICON_WIDTH));
                if (item == ItemID.none) {
                    IconToolTip itt = new IconToolTip(itemS, "none", "none");
                    champsItemIcons.Add(itt);
                } else {
                    Item ite = new Item(item);
                    champsItemIcons.Add(new IconToolTip(itemS, ite.name, ite.description));
                }
            }

            champBarSprite = new Sprite(champBarTexture);
            unitIconSprite = new Sprite();

            topBarDebugText = new Text(topBar + " ",GameBox.corbalFont,30U);
            topBarDebugText.Color = Color.Yellow;
            playerClassText = new Text("playerclass", GameBox.corbalFont, 15U);
            playerItemText = new Text("playeritem", GameBox.corbalFont, 15U);
        }
Пример #17
0
 public override void Draw(RenderTarget r)
 {
     var text = ((int)(1000/EntityManager.FrameTime)).ToString () + " FPS";
     DebugText = new Text(text, DebugText.Font)
     {Position = r.GetView ().Center - r.GetView ().Size/2, Color = DebugText.Color};
     r.Draw (DebugText);
 }
Пример #18
0
        public HeadsUpDisplay(Game Game)
            : base(Game, null)
        {
            // Score
            Score = new Text("00000000", Game.TidyHand, 50);
            Score.Color = new Color(255, 255, 255, 180);
            Score.Position = new Vector2f(Game.Size.X - 270, 2);
            AddChild(Score);

            ScoreMultiplier = new Text("x001", Game.TidyHand, 35);
            ScoreMultiplier.Color = new Color(200, 200, 200, 180);
            ScoreMultiplier.Position = new Vector2f(Game.Size.X - 100, 50);
            AddChild(ScoreMultiplier);

            // Powerups
            Layer_Powerups = new Layer();
            AddChild(Layer_Powerups);

            // FPS
            if (DisplayFPS)
            {
                FPS = new Text("00.0", Game.TidyHand, 30);
                FPS.Position = new Vector2f(Game.Size.X - 70, Game.Size.Y - 40);
                AddChild(FPS);

                FPSUpdateTimer = new Timer(500); // Update every 0.5 seconds
                FPSUpdateTimer.Elapsed += FPSUpdate;
                FPSUpdateTimer.Start();
            }
        }
Пример #19
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);
        }
Пример #20
0
        static void Initialize()
        {
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Environment.CurrentDirectory + "\\libs");
            dtClock = new Stopwatch();
            textFps = new Text("0", new Font(new FileStream("assets\\fonts\\arial.ttf", FileMode.Open, FileAccess.Read)));
            window = new RenderWindow(new VideoMode(1280, 768), "Test", Styles.Default);
            window.SetFramerateLimit(60);
            window.SetTitle("NATE");
            tiles = new TileManager("assets\\tilemaps\\rpgtiles.png", 32);
            iMap = new MapInterface();
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), true); -- for random
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), false); -- blank
            map = iMap.ReadMap("map1.ntm");
            
            scaling = new Vector2f(2, 2);
            textureCollection = new Texture[(tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize)];
            camera = new Camera();
            camera.speed = 1000;

            window.Closed += (s, a) => window.Close();
            window.KeyPressed += (s, a) => { if (a.Code == Keyboard.Key.Z) { iMap.WriteMap("map0.ntm", map); } };
            window.MouseWheelMoved += (s, a) => { scaling.X += a.Delta * 0.075f; scaling.Y += a.Delta * 0.075f; };

            dtClock.Start();

            for (int i = 0; i < (tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize); i++)
            {
                textureCollection[i] = tiles.GetTile(i);
                textureCollection[i].Smooth = false;
            }
        }
Пример #21
0
        public void Draw(RenderTarget rt)
        {
            DateTime now = DateTime.Now;

            Text message = new Text("", myFont);
            message.CharacterSize = 14;

            int removeCount = 0;
            foreach(KeyValuePair<DateTime, String> pair in msgList){
             	message.DisplayedString += pair.Value + "\n";
                if((now - pair.Key).TotalSeconds > messageLifeTime)
                    removeCount++;
            }

            msgList.RemoveRange(0, removeCount);
            message.Position = new Vector2f(14, rt.Height - 54 - message.GetRect().Height);
            rt.Draw(message);

            if(writing){
                Text display = new Text("say : " + toWrite + "_", myFont);
                display.CharacterSize = 14;
                display.Position = new Vector2f(14, rt.Height - 36 - display.GetRect().Height);
                rt.Draw(display);
            }
        }
Пример #22
0
        static void Main(string[] args)
        {
            // initialize window and view
            win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!");
            view = new View();
            resetView();
            gui = new GUI(win, view);

            // exit Program, when window is being closed
            //win.Closed += new EventHandler(closeWindow);
            win.Closed += (sender, e) => { (sender as Window).Close(); };

            // initialize GameState
            handleNewGameState();

            // initialize GameTime
            GameTime gameTime = new GameTime();
            gameTime.Start();

            // debug Text
            Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf"));

            while (running && win.IsOpen())
            {
                KeyboardInputManager.update();

                currentGameState = state.update();

                // gather draw-stuff
                win.Clear(new Color(100, 149, 237));    //cornflowerblue ftw!!! 1337
                state.draw(win, view);
                state.drawGUI(gui);

                // first the state must be drawn, before I can change the currentState
                if (currentGameState != prevGameState)
                {
                    handleNewGameState();
                }

                // do the actual drawing
                win.SetView(view);
                win.Display();

                // check for window-events. e.g. window closed        
                win.DispatchEvents();

                // update GameTime
                gameTime.Update();
                float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;

                // idleLoop for fixed FrameRate
                float deltaPlusIdleTime = deltaTime;
                while (deltaPlusIdleTime < (1F / fixedFps))
                {
                    gameTime.Update();
                    deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds;
                }
                Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime));
            }
        }
        public void Draw()
        {
            Text t = new Text();
            t.Font = Program.Data.Font;
            t.CharacterSize = 14;

            SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
            s.Position = new Vector2f(X, Y);
            _screen.Draw(s);

            BuildGUI g = (BuildGUI)Program.State[1].GameGUI[8];
            if (g.CurPick + 3 * g.PickPage < Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass).Count)
            {
                if (SlotID + 3 * g.CurPage < Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.Count)
                {
                    s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Key.ID]);
                    s.Position = new Vector2f(X, Y);
                    _screen.Draw(s);

                    t.DisplayedString = Program.Data.MyItems[Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Key.ID].Name + ": " + Program.Data.GetBuildableList()[Logic.KnownBluePrintForThisCharacter(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0], g.CurClass)[g.CurPick + 3 * g.PickPage]].RequiredItems.ElementAt(SlotID + 3 * g.CurPage).Value;
                    t.Position = new Vector2f(X + 40, Y + 7);
                    _screen.Draw(t);
                }
            }
        }
Пример #24
0
        public Counter()
        {
            Text = new Text("", Game.Assets.Fonts["DejaVuSans"]);
            Text.Color = TextColor;

            Position = Game.Target.GetView().Size * 0.5f;
        }
Пример #25
0
        public Vector2f MeasureString(TextString str)
        {
            Vector2f size = new Vector2f(0f,0f);
            Vector2f curLineSize = new Vector2f(0f, 0f);

            foreach (KeyValuePair<TextStyle, string> s in str.FormatedText)
            {
                if (s.Key == TextStyle.EndLine)
                {
                    size.Y += curLineSize.Y;
                    size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
                    curLineSize = new Vector2f(0f, 0f);
                }
                else
                {
                    Text textSlope = new Text(s.Value, Font, str.CharacterSize);
                    Text.Styles textStyle = Text.Styles.Regular;
                    if ((s.Key & TextStyle.Bold) != 0)
                        textStyle |= Text.Styles.Bold;
                    if( (s.Key & TextStyle.Italic) != 0)
                        textStyle |= Text.Styles.Italic;
                    textSlope.Style = textStyle;
                    FloatRect localBounds = textSlope.GetLocalBounds();

                    Vector2f ssize = new Vector2f(localBounds.Width,localBounds.Height);
                    curLineSize.X += (int)ssize.X;
                    curLineSize.Y = (int)ssize.Y > curLineSize.Y ? (int)ssize.Y : curLineSize.Y;
                }
            }

            size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
            size.Y += curLineSize.Y;
            return size;
        }
Пример #26
0
        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;
        }
Пример #27
0
 public HighscoreList(Vector2f position)
 {
     Text = new Text();
     Text.Font = Game.Assets.Fonts["PixelPlay"];
     Text.CharacterSize = 30;
     Text.Position = position;
 }
Пример #28
0
        private void Window_TextEntered(object sender, TextEventArgs e)
        {
            if (!IsSelected)
            {
                return;
            }

            // Don't handle input if the key press event did something
            if (blockTextInput)
            {
                blockTextInput = false;
                return;
            }

            string unicode = e.Unicode;

            if (unicode == "\b")
            {
                // Backspace, delete text
                if (Text.Length > 0)
                {
                    Text = Text.Substring(0, Text.Length - 1);
                }
            }
            else
            {
                // Append text
                Text = Text.Insert(cursor++, unicode);
            }
        }
        public void Draw()
        {
            SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
            s.Position = new Vector2f(X, Y);
            _screen.Draw(s);

            PickWorldGUI g = (PickWorldGUI)Program.State[0].GameGUI[5];

            Text t = new Text();
            t.CharacterSize = 11;
            t.Color = Color.White;
            t.Font = Program.Data.Font;

            for (int i = 0; i < 11; i++)
            {
                if (i + g.SaveDown < Program.Data.MyWorldData.Count)
                {
                    t.DisplayedString = Program.Data.MyWorldData[i + g.SaveDown].Name;
                    t.Position = new Vector2f(X + 4, Y + 2 + 16 * i);
                    _screen.Draw(t);
                }
            }

            if (Program.Data.MyWorldData.Count > 0)
            {
                s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[SelectID]);
                s.Position = new Vector2f(X, Y + 16 * g.SelectedWorld);
                _screen.Draw(s);
            }
        }
Пример #30
0
 public static int MeasureText_Width(string Text)
 {
     // Data do Text
     SFML.Graphics.Text TempText = new SFML.Graphics.Text(Text, Graphics.Fonte);
     TempText.CharacterSize = 10;
     return((int)TempText.GetLocalBounds().Width);
 }
Пример #31
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;

        }
Пример #32
0
 public static short MeasureString(string Text)
 {
     // Dados do texto
     SFML.Graphics.Text TempText = new SFML.Graphics.Text(Text, Graphics.Font_Default);
     TempText.CharacterSize = 10;
     return((short)TempText.GetLocalBounds().Width);
 }
        public override void Draw(RenderTarget rt)
        {
            Text title = new Text("Oh no! Something went wrong!", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            title.Center();
            title.Round();
            rt.Draw(title);

            Text blackCardText = new Text(value, Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
                CharacterSize = 36,
                Color = Color.White
            };

            blackCardText.Center();
            blackCardText.Round();
            rt.Draw(blackCardText);

            base.Draw(rt);
        }
Пример #34
0
        internal void RenderText(Text text, SFML.Graphics.Text textSprite)
        {
            blitState.BlendMode = text.Additive ? BlendMode.Add : BlendMode.Alpha;
            blitState.Shader    = text.Effect?.Shader?.NativeShader;
            text.Effect?.Apply();

            Pipeline.RenderTarget.Draw(textSprite, blitState);
        }
Пример #35
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;
 }
Пример #36
0
 /// <summary>
 /// Настройва текста да се вписва
 /// </summary>
 /// <param name="text"></param>
 private void CreateDrawables(string text)
 {
     drawText = new Text(text, font, 12);
     drawText.Color = foreground;
     FloatRect localBounds = drawText.GetLocalBounds();
     box.Width = (int)localBounds.Width + 10;
     box.Height = (int)localBounds.Height + 6;
 }
Пример #37
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;
        }
Пример #38
0
 public TextNode(ResourceHolder<Font, FontID> fonts, string text) 
 {
     mText = new Text();
     mText.Font = fonts.get(FontID.Main);
     mText.DisplayedString = text;
     mText.CharacterSize = 20;
        
 }
Пример #39
0
        public Transformable GetShape()
        {
            SFML.Graphics.Text text = new SFML.Graphics.Text(Text, Font, (uint)FontSize)
            {
                FillColor = Color,
            };

            text.Position = CalculatePosition(text);

            return(text);
        }
Пример #40
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;
            }
Пример #41
0
 public GameplayStateView(GameplayState gameplayState)
 {
     _gameplayState = gameplayState;
     _background    = new Sfg.RectangleShape(new Sfs.Vector2f(Game.Resolution.X, Game.Resolution.Y))
     {
         FillColor = new Sfg.Color(25, 25, 112),
         Position  = new Sfs.Vector2f(-680 / 2f, -320 / 2f)
     };
     _score = new Sfg.Text(0.ToString(), new Sfg.Font(FontFilePath), CharacterSize)
     {
         Position = new Sfs.Vector2f(400, 0)
     };
 }
Пример #42
0
        public void WriteDebug(string content, Vector2f position, RenderTarget target)
        {
            var text = new SFML.Graphics.Text(content, _debugFont)
            {
                Position         = position,
                FillColor        = Color.Green,
                CharacterSize    = 8,
                Scale            = Scale,
                OutlineColor     = Color.Black,
                OutlineThickness = 1.0f
            };

            text.Draw(target, RenderStates.Default);
        }
Пример #43
0
        private Text createText(PVector position, char[] chars)
        {
            string text = new string(chars);

            Text textObj = new Text(text, defaultFont);

            textObj.Position         = toVector2f(position);
            textObj.OutlineColor     = toColor(strokeColor);
            textObj.OutlineThickness = strokeWeight;
            textObj.FillColor        = toColor(fillColor);
            textObj.CharacterSize    = (uint)textSize;
            textObj.LineSpacing      = textLeading / textSize;
            textObj.Rotation         = Helpers.ConvertionHelper.RadiansToDegrees(transformation.Angle);

            FloatRect textBox = textObj.GetLocalBounds();

            textObj.Origin = getTextOrigin(textBox);

            return(textObj);
        }
Пример #44
0
        private void Window_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
        {
            if (!IsSelected)
            {
                return;
            }

            if (e.Control)
            {
                if (e.Code == Keyboard.Key.C)
                {
                    Clipboard.SetText(Text);
                    blockTextInput = true;
                }
                else if (e.Code == Keyboard.Key.V)
                {
                    Text           = Text.Insert(cursor, Clipboard.GetText());
                    blockTextInput = true;
                }
            }
            else
            {
                if (e.Code == Keyboard.Key.Left)
                {
                    CursorPosition--;
                }
                else if (e.Code == Keyboard.Key.Right)
                {
                    CursorPosition++;
                }
                else if (e.Code == Keyboard.Key.Return)
                {
                    if (OnTextConfirmedHandler != null)
                    {
                        OnTextConfirmedHandler(this);
                    }
                    blockTextInput = true;
                }
            }
        }
Пример #45
0
        private Vector2f CalculatePosition(SFML.Graphics.Text textElement)
        {
            float x = 0;
            float y = 0;

            switch (HorizontalPosition)
            {
            case TextPosition.Start:
                x = ContainerPosition.X + Margins.X;
                break;

            case TextPosition.Middle:
                x = ContainerPosition.X + ContainerPosition.Width / 2 - textElement.GetGlobalBounds().Width / 2;
                break;

            case TextPosition.End:
                x = ContainerPosition.X + ContainerPosition.Width - textElement.GetGlobalBounds().Width - Margins.X;
                break;
            }

            switch (VerticalPosition)
            {
            case TextPosition.Start:
                y = ContainerPosition.Y + Margins.Y;
                break;

            case TextPosition.Middle:
                y = ContainerPosition.Y + ContainerPosition.Height / 2 - textElement.CharacterSize / 1.5F;
                break;

            case TextPosition.End:
                y = ContainerPosition.Y + ContainerPosition.Height - textElement.GetGlobalBounds().Height - Margins.Y;
                break;
            }

            return(new Vector2f((float)Math.Ceiling(x), (float)Math.Floor(y)));
        }
Пример #46
0
 public Text(Vector2f position, Font font, string text, uint size)
 {
     this.text = new SFML.Graphics.Text(text, font, size);
 }
Пример #47
0
 public ScreenText(Vector2f pos, string initString, int size)
 {
     text          = new SFML.Graphics.Text(initString, font, (uint)size);
     text.Position = pos;
     this.pos      = pos;
 }
Пример #48
0
 public void Draw(SFML.Graphics.Text text, RenderTarget target)
 {
     text.Draw(target, RenderStates.Default);
 }