Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New overloads for BitmapFont DrawString #253

Merged
merged 1 commit into from Sep 6, 2016
Merged

New overloads for BitmapFont DrawString #253

merged 1 commit into from Sep 6, 2016

Conversation

bsimser
Copy link

@bsimser bsimser commented Sep 5, 2016

Added additional overloads to the BitmapFont DrawString methods to support the same functions the SpriteBatch.DrawString have. BitmapFont DrawString now supports scaling, orgins, SpriteEffects. Also updated the demo to showcase all of these.

…pport the same functions the SpriteBatch.DrawString have. Also updated the demo to showcase all of these.
@craftworkgames craftworkgames merged commit 304a14d into craftworkgames:develop Sep 6, 2016
@craftworkgames
Copy link
Collaborator

Great work 😄

I'm really pleased that you updated the demo. A lot of people don't do that unfortunately.

There's still some room for improvement. I'd like to see rotation and scaling at a sentence level as we discussed before. Still, this is an excellent step in the right direction.

@bsimser
Copy link
Author

bsimser commented Sep 6, 2016

I agree the rotation and scaling should be done at both levels. That said I think the text would need to be rendered to a RenderTarget2D or something in order to do it at the sentence level which would require some work, not to mention some kind of additional parameter to the overloads to handle it (and an enum like SpriteEffects to indicate the type of rotation desired). A bunch of work but all doable. I'm a big believer of "version 1 sucks but ship it anyway" as there's always room for version 2. Thanks!

@bsimser bsimser deleted the feature/add_more_drawstring_methods_to_bitmapfont branch September 6, 2016 13:10
@craftworkgames
Copy link
Collaborator

That said I think the text would need to be rendered to a RenderTarget2D or something in order to do it at the sentence level

Yeah I was thinking about this approach too. My gut feeling says there's probably an easier way though.

I'm a big believer of "version 1 sucks but ship it anyway" as there's always room for version 2.

I couldn't agree more 👍

@bsimser
Copy link
Author

bsimser commented Sep 6, 2016

Yeah I was thinking about this approach too. My gut feeling says there's probably an easier way though.

Probably. Might be able to create a transformation matrix and apply it to the entire thing before the draw call(s) and restore it back after. Will have to poke around in the extension method and try some stuff out when I get some time.

craftworkgames pushed a commit that referenced this pull request Mar 15, 2017
* Add WorldPosition & rename ParentTransform -> Transform

* doc fix

* WorldRotation, WorldScale

* Fix scale & doc

* Update SceneNode to use Transform2D

* Update SceneGraph demo

* forgot to add drawable position, rotation, scale

* Transform2D strongly typed parent

* Revert "SceneNode & Transform2D"

* fixed a failing unit test

* Fix

* Transform updates.

* Matrix2D updates.

* negated the roation when calculating the local matrix so that it's consistent with sprite batch rotation

* updated Entity to inherit from Transform2D

* working on the ecs

* Graphics branch; sprites.

* rename to `GeometryBatch2D`

* remove SpriteOptions; use SpriteEffects even though the name is confusing

* update project

* update demo game

* doc EnqueueSprite

* doc PrimitiveTypeExtensions

* doc fix PrimitiveBatch

* remove technique name

* update Demo.Batching project name and namespaces

* doc fix

* doc fix

* doc fix

* update demo

* optimization

* change to IDrawContext api

* Bug Fixes & API Update & Documentation Fixes

* using collision rectangles created in tiled

* working on jumping

* tweaking jumping

* tightened up the controls so the feel pretty good

* Monogame.Extended.SizeF class: Added implicit operator which casts Vector2 to SizeF

* Removed unnecessary constructor from SizeF

* Added another test to RectangleF

* Added test which check if RectangleF can be constructed with Point instead of SizeF

* simplified the component system interface

* making the entity components more generic

* made the collision system more generic ready to add in more entity types

* created player death using a particle emitter component

* Objectgroups for Tiles!

Those changes make the "per tile ObjectGroups" available. They are used
by Tiled for tile collision using Objects.

* fix FramesPerSecondCounter

* remove average

* forgot to remove unused property

* use int instead of float

* fix demo

* Revert "Objectgroups for Tiles!"

* added the ability to destroy entities after a delay

* Fixing all the things!

So now I tested things and it works! Objectgroups are now available in
TileSetTiles as seen here (http://screencast.com/t/YvdCmQoUcd)

* fix to never lose time

* Fixing the Objectgroups

So this time, everything is fixed and actually tested: The tilemap demo
works just fine (apart from Game.Exit() being obsolete). Those
objectgroups are now available in their respective TileSetTiles as seen
in this screenshot: http://screencast.com/t/YvdCmQoUcd

* fixed a minor issue with the fps counter in the batching demo

* Blame me...

Seems like this got discarded while merging the remote tracking branch,
so here it is.

* Added a new constructor and documentation to TextureAtlas class (#250)

* Added a new constructor to TextureAtlas. Also documented TextureAtlas class.

* Update TextureAtlas.cs

* fixed a minor bug in the player movement system

* DynamicBatch2D - SpriteBatch API (#251)

* Matrix2D ToMatrix

* Merge draw calls when enqueueing.

* progress

* Batch2D sort modes

* SpriteBatch API for Batch2D

* doc fix

* doc fix

* DynamicBatch2D drawing API matches SpriteBatch

* Make End() protected

* Match SpriteBatch.Begin API

* DynamicBatch2D DrawSprite by destination rectangle

* GetPrimitiveCount -> GetPrimitivesCount

* doc fix

* fixed a couple of merge issues

* fixed some broken unit tests

* player sprite sheet animations are working

* tweaked player animation again

* player respawn

* Added additional overloads to the BitmapFont DrawString methods to support the same functions the SpriteBatch.DrawString have. Also updated the demo to showcase all of these. (#253)

* started working in introducing an enemy

* implemented super quick and dirty enemy ai

* enemies can kill you

* weird rules around death

* tweaking

* refactored the game code into a screen

* Fix typo (#258)

Fix a typo in the Readme.txt

* Add Nez mention (#261)

* Fixed the layers offset (#264)

* Some Basic Primitives. (#266)

* Primitives.

* Fix unit tests.

* removed the build status from the readme

* replaced GetBoundingRectangle methods with properties

* fixed a bug in rectangle GetCorners

* Fixed scale for BitmapFont draws (#269)

* Removed the X and Y properties keeping Position (#272)

I removed the X and Y properties keeping Position property to make things less redundant.
I also added another constructor that takes a Vector2 position directly.

* slight tweak on thickness parsing

* fixed the color json converter

* Add support for Multiple Tilesets per TiledTileLayer in Tiled Map Renderer. (#278)

* Tiled Map rendering now supports multiple tilesets. Previously there was a bug where tiles made with alternate tilesets would draw undefined images.

TiledTileLayer holds an array of tiles to draw. This was based on their order from left to right/top to bottom in the grid. The new ordering is based on each TiledTileset to allow tiles with the same TiledTileset to be placed next to each other in memory.

This is to support the best choice for map rendering optimization available at this time. The old code would draw the map with 1 call per TiledTileLayer. This new code has 1 draw code per Tileset, per TiledTileLayer. (The re-ordering of tiles described in the above paragraph is neccesary to prevent 1 draw call per TiledTile per TiledTileset.)

* Revert a change that I didn't mean to make; AddObjectGroup was change din between me starting the TiledTileLayer change and now.

* -Added tiny-grey-cloud.png, Updated level-1.tmx to include 2 tilesets (tiny-tiles and tiny-grey-cloud) and used both tilesets in creating the map. And of course had to update Content.mgcb which also changed Demo.Platformer.csproj.

* BoundingRectangle (#279)

* Primitives.

* Fix unit tests.

* BoundingBox2D -> BoundingRectangle

* reduced the tolerence on conversion unit tests

* BitmapFonts now returning a "rectangle" size. (#281)

* BitmapFonts correct height and width "rectangle" measuring string.

* BitmapFonts correct height and width "rectangle" measuring string.

* MeasureString now returns "rectangle" size.

BitmapFont MeasureString() now returns the proper "rectangle" size as expected.

Fixed up LetterSpacing issue if line ends with line char.

* Renamed variables and added null check.

* no idea why that test is failing

* Changed obsolete demo code (#283)

* Changed obsolete code in the demos

* Unit Test commit was a mistake

* Extra tab was added by mistake

* added a ToString to BitmapFontRegion

* Set baseVertex properly in call to DrawIndexedPrimitives when vertex buffer is larger than ushort.MaxValue (#285)

* Precalculate tilecount per tileset when TiledTileLayer is created (#287)

* Set baseVertex properly in call to DrawIndexedPrimitives when vertex buffer is larger than ushort.MaxValue

* Precalculate tilecount per tileset when TiledTileLayer is created to save time while rendering the map later.

* Update variable name to match MGE style

* BoundingRectangle Radii (#286)

* Primitives.

* Fix unit tests.

* BoundingBox2D -> BoundingRectangle

* BoundingRectangle Radii

* Changing TileSet instances to Tileset  (#289)

* Changed obsolete code in the demos

* Unit Test commit was a mistake

* Extra tab was added by mistake

* renamed TileSet to Tileset for file names and csproj

* Rename TiledTileSet to TiledTileset in github

* Rename TiledTileSet to TiledTileset in github

* Rename TiledTileSet to TiledTileset in github

* renamed variables containing tileSet to tileset

* Changed GetTileSetTileById to GetTilesetTileById

* Fix BoundingRect unit tests. (#288)

* Only draw tiles that actually exist for each tileset/layer combination (#290)

* Only draw tiles that actually exist for each tileset/layer combination

* Set baseVertex and startIndex based on the number of draw calls and tiles per call

* the delta on the angle tests was way too sensitive

* hopefully that fixes the build

* added the build status icon back into the readme

* Separate out the Tiled rendering code (#292)

* Only draw tiles that actually exist for each tileset/layer combination

* Set baseVertex and startIndex based on the number of draw calls and tiles per call

* First commit of separate map renderer code

* Only override on mono (linux)... not sure why this is needed, will look into later

* Updated test data for unittest

* Fixed layer transparency not working

* Couple of small changes

* Initial commit of separate Tiled rendering code

* Fixed bug causing last tile of each group not to draw

* Adding unit tests for FullMapRenderer and TiledTileset

* Fixed depth calculation bug when a map consists of only one layer

* Added level05.tmx to test isometric left-up rendering

* Minor bugs in TextureAtlases (#293)

* Print region name in exception

* Don't remove the path, only the extension

* Removed PathHelper

* rejiggled the tiled demo slightly

* Made BitmapFont ctr public (#300)

I'm not using the MonoGame content pipeline, so i need the contructor to be public to be able to manually load a BitmapFont from file

* Nuclex GUI (#299)

* Added a new constructor to TextureAtlas. Also documented TextureAtlas class.

* Update TextureAtlas.cs

* Adapting Nuclex GUI to MonoGame.Extended. Still incomplete.

* Ported Nuclex GUI; errors persist

* Fixed { }

* Started moving from XML skins to JSON skins

* Framework compiles

* Removed unnecessary item

* Nuclex Gui compiling completely. Demo project started. Cleaning out errors required.

* "Save" point before massive input changes

* Dealing with Input on Nuclex

* Added missing files

* Nuclex works!

* Cleanup started

* Removed plugin mechanic

* Nuclex finally finished. Mostly.

* Commented demo project

* Modified input to deal with issue #171

* Added remark to MouseListener

* Renamed skin converter to better reflect its function

* decoupled the nuclex gui code from the input listeners and other code cleanup

* moved the nuclex gui demo into the demos folder

* a couple of minor tweaks in the nuclex code

* Implemented object layer rendering and tileset transparency color (#301)

* Render tile objects in object layers and obey tileset transparency color

* Added alpha color tileset to level04.tmx

* Fixed unit test and added missing test

* Made drawing of object layers configurable

* Fixed references to missing files after merge

* Fixed another duplicate file reference

* Replacing everything with var

* fixed a minor bug in the tiled demo

* removed unused reference to PCL storage

* Implemented animated tiles (#302)

* Implemented animated tiles

* Only update animated tiles.

* massive refactor and partial implementation of animated object tiles

* Include IShapeF object as part of the TiledObject (#304)

* gui control collection

* split collisions into a separate project (#308)

* split the old gui code out into it's own project

* started refactoring the old gui code

* refactored nine patches to derive from texture reigons

* fixed some reference issues in the gui demo

* rendering nested gui controls

* using a smaller font

* started fixiing the bitmap font issues

* Fixed calculation of x and y radius for ellipse (#311)

* Fixed calculation of x and y radius for ellipse and removing TiledObject.Points in favor of using TiledObject.Shape

* Don't try to rebuild dynamic details when a map isn't loaded

* partially fixed the bitmap font issue, ignored a broken unit test to avoid confusion

* Updated the readme

* setup a bitmapfont to spritefont comparison

* basic text rendering with new lines looks identical to sprite font

* perfectly matching measure string methods

* perfect bitmap font rotation

* perfect rotation and scaling parity between bitmapfont and spritefont

* wrote a failing circle interests test

* [Shapes] CircleF.Intersects(Rectangle) fix (#315)

* Added a new constructor to TextureAtlas. Also documented TextureAtlas class.

* Update TextureAtlas.cs

* Adapting Nuclex GUI to MonoGame.Extended. Still incomplete.

* Ported Nuclex GUI; errors persist

* Fixed { }

* Started moving from XML skins to JSON skins

* Framework compiles

* Removed unnecessary item

* Nuclex Gui compiling completely. Demo project started. Cleaning out errors required.

* "Save" point before massive input changes

* Dealing with Input on Nuclex

* Added missing files

* Nuclex works!

* Cleanup started

* Removed plugin mechanic

* Nuclex finally finished. Mostly.

* Commented demo project

* Modified input to deal with issue #171

* Added remark to MouseListener

* Renamed skin converter to better reflect its function

* CircleF + some other things

* Fixed demo

* Cleanup

* cleaned up the demo and removed text wrapping

* setup a demo to show that measure string is still not quite working correctly

* perfect measure string

* added a GetStringRectangle overload for backwards compatibility and to fix a compile error on the build

* Create Graphics library. (#316)

* Fix BoundingRect unit tests.

* Create `graphics` library.

* fixed a minor project dependency issue

* first bitmap font measure string unit test

* added more bitmap font unit tests

* DynamicBatch rework (#317)

* Fix BoundingRect unit tests.

* Create `graphics` library.

* DynamicBatchRenderer2D

* remove sprite

* remove shipbuilder artifact

* Create CONTRIBUTING.md (#319)

* removed texture atlas from raw xml

* a little resharper code cleanup

* Tiled library (#322)

* Tiled library

* remove test project

* minor project reference tweak

* removed the old gui code and slowly started replacing it with the new

* removed broken tests

* tweak to gui skin

* Fix minor typo in README (#328)

* JSON.NET & .nuspecs (#330)

* JSON.NET & .nuspecs

* fix dependencies for Tiled lib

* add xml comments

* Add nuget files to solution

* fixed some project depenency issues

* finally getting back to working on the new gui system

* working gui buttons

* minor code cleanup

* labels and checkboxes

* fixed broken hint paths after upgrading to VS 2017

* gui button demo

* Tiled Rework (#331)

* Tiled Rework

* fix failing tests

* really fix failing tests

* cleaned up some project dependency issues

* minor api refactor on the tiled map renderer

* Fix Tiled Problems (#332)

* Add Tiled Content Pipeline library to NuGet

* Update Tiled NuGet package elements.

* Remove dependency on Graphics

* Update csproj for removal of Graphics dependency

* Fix build errors

* Fix problems

* creating gui skins in code

* testing inset panels

* partial gui skin serializing

* removed sprite font because it doesn't seem to work with latest monogame

* moved the demo project template to reduce confusion

* working through loading gui skins from a file

* Graphics refactor (#340)

* Graphics refactor

* fix

* working on loading gui skins from a file

* loading gui skins from a file with the exception of 9 patches

* almost there with nine patch regions in the gui skin

* rendering nine patches from the gui skin

* code cleanup mostly in the gui and serialization namespaces

* big code cleanup

* mucking around with gui control factory

* working on nested gui controls

* in the middle of loading gui screens from a file

* loading panels and buttons from skin files

* nested gui controls

* gui control visibility

* added a gui cursor and image control

* enforce c# 6.0 language version at least until VS2017 comes out of RC

* minor code cleanup

* started working on editable textbox

* renamed GuiCheckBox properly this time

* refactored the gui renderer

* working gui text box

* cleaned up and fixed some issues with keyboard focus

* basic working checkboxes

* a few tweaks to the gui skinning system

* sprite batch clipping rectangles extension method

* changed the clipping source rectangle code to account for sprite scaling

* allow clipping rectangles on nine patch regions

* extended the clipping code to cover bitmap fonts and all overloads of texture region draw methods

* added clipping rectangles to gui controls so that text is clipped inside the bounds of textbox

* clipping text inside a textbox is a little harder than I expected

* basic gui progress bars

* TiledMapRenderer allow custom effect (#345)

* renamed texture region to background region

* minor code cleanup

* hacked together a working android project from one of the monogame samples

* renamed some stuff and cleaned up namespaces

* slightly hacked gui demo rendering on android

* gui touch input mostly working

* minor tweak to gui button behaviour

* Tiled Fix (#349)

* Tiled fix.

* Remove bat file.

* upgraded the demos to match the monogame 3.6 desktop GL template

* fixed a mistake in the readme

* gah, fixed another issue in the bitmap fonts demo

* split nuclex gui out of the core library and added some new nuspec files

* fixing nuget dependency version issue hopefully

* moved the particle system and the entity component system into their own nuget packages

* fixed unsafe code flag in release mode and some minor code cleanup

* moved the scene graphs code into it's own nuget package

* reorganized the graphics project to be consistent with everything else

* changed the tools versions in the project files to be compatible with xamrain studio

* Geometric Primitives Cleanup (#346)

* CircleF and RectangleF

* Fix build errors

* Fix iteration memory leaks. (#350)

* fixed some merge conflicts

* moved the input listeners to thier own nuget package

* split the animations namespace into two nuget packages

* split the animations content pipeline code out into it's own content pipeline dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants