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); } }
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"); }
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"); }
/// <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; }
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; }
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(); } }
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; }
//////////////////////////////////////////////////////////// /// <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; }
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 OnEngineInit() { base.OnEngineInit(); this.fnt = new Font(Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + Path.DirectorySeparatorChar + "georgia.ttf"); this.txt = new Text(string.Empty, fnt, 24); }
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); } }
public UiLabel(string text, Font font) { this.font = font; foreground = new Color(255, 255, 255); backgroundColor = new Color(0, 0, 0, 80); CreateDrawables(text); }
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; }
protected static bool IsAssetValid(Font asset) { if (asset == null || asset.IsDisposed) return false; return true; }
static Debug() { drawInfos = new List<DebugDrawInfo>(); font = new Font(System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIAL.TTF")); }
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); }
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(); }
/// <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; }
public CharacterStatusComponent(Screen screen, Font font, int entityId, Vector2f offset) : base(screen) { _font = font; _entityId = entityId; _text = new Text("", font, 14); _offset = offset; }
//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; }
public Chat(Client client) { writing = false; myFont = new Font("content/arial.ttf"); toWrite = ""; msgList = new List<KeyValuePair<DateTime, string>>(); this.client = client; }
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); }
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; }
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; }
public CacheFont(Font font) { if (font != null) { _font = font; _initialized = true; } throw new ArgumentNullException("[Cache] Font provided is null."); }
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; }
/// <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 (); }
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, }; }
/// <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); }
public override void Free() { if (Handle == null) { return; } //Console.WriteLine("Freeing font: {0:x16}", Handle.CPointer.ToInt64()); Handle.Dispose(); Handle = null; }
/// <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); }
/// <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); }
/// <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); }
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; }
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; } }
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(); }
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); }
/// <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); }
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); }
public Renderer(RenderWindow _window) { _random = new Random(); window = _window; font = new Font(FileSystemHelper.PathToResources + "Fonts" + FileSystemHelper.FileSystemSeparator + "kongtext.ttf"); }
/// <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); }
/// <summary> /// Creates a font by reading from a stream. /// </summary> public Font(Stream stream) { SFMLFont = new SFont(stream); }
internal Font(SFont font) { SFMLFont = font; }
public Font(byte[] data) { SFMLFont = new SFont(data); }
/// <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(); }
public Font(string filename) : base(filename) { Handle = new SFML.Graphics.Font(filename); }
public BaseFont() { font = Fonts.DefaultFont; }