-
Notifications
You must be signed in to change notification settings - Fork 363
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
enhancement: configurable map items size #1788
enhancement: configurable map items size #1788
Conversation
396cd0d
to
a339243
Compare
/// <summary> | ||
/// The width of map items. | ||
/// </summary> | ||
public int MapItemHeight { get; set; } = 32; | ||
|
||
/// <summary> | ||
/// The height of map items. | ||
/// </summary> | ||
public int MapItemWidth { get; set; } = 32; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The of the map items in pixels.
Also, remove the = 32;
, and change these to uint
s.
If the value is default
, you can skip the computation for that dimension and just use the Tile<Dimension>
.
Intersect.Client/Maps/MapInstance.cs
Outdated
var tileX = key % Options.MapWidth; | ||
var tileY = (int)Math.Floor(key / (float)Options.MapWidth); | ||
var x = X + tileX * Options.TileWidth; | ||
var y = Y + tileY * Options.TileHeight; | ||
var centerX = x + (Options.TileWidth / 2); | ||
var centerY = y + (Options.TileHeight / 2); | ||
var textureWidth = Options.MapItemWidth; | ||
var textureHeight = Options.MapItemHeight; | ||
var textureXPosition = centerX - (textureWidth / 2); | ||
var textureYPosition = centerY - (textureHeight / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this computation should only ever happen once: when the configuration is loaded.
d3828d0
to
a5e003a
Compare
a5e003a
to
764662b
Compare
764662b
to
cd8831a
Compare
f894fb3
to
ebf6bf8
Compare
Intersect.Client/Maps/MapInstance.cs
Outdated
var mapItemWidth = preferredMapItemWidth <= 0 ? tileWidth : preferredMapItemWidth; | ||
var mapItemHeight = preferredMapItemHeight <= 0 ? tileHeight : preferredMapItemHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be getting done in MapOptions.Validate()
in the other file, like I said this gets done when it is loaded.
Also switch to < 1
11faa44
to
6edc76b
Compare
6edc76b
to
2808ece
Compare
/helptest |
Developers have requested community assistance to test the code changes in this pull request. If you'd like to help you can download binaries for this PR here. These builds are only meant for testing to validate bug fixes and could cause significant damage to your game data. In other words, make a backup of your game data before proceeding. Please comment below to provide testing feedback. Thanks! |
2808ece
to
9a13c2b
Compare
9a13c2b
to
b6f7f34
Compare
enhances spawned/dropped items in maps by: - Adding configurable size for their sprites. - Centering their sprites in relation to the tiles they occupy.
- removes previously added config/options.cs statics - turns MapItemHeight and MapItemWidth into uints - if configured value is not set or equals <= 0 (default value when uint is not set: 0), the draw method skips the computation and uses the tiles dimensions. - moved out of the loop computation variables that should only happen once at the beginning of the method.
b6f7f34
to
e2fd072
Compare
Updated PR for B8 |
enhances spawned/dropped items in maps by:
This doesn't requires additional texture loading, this simply allows the users to configure the size the icon textures.
The implementation also makes sure to always center the item's texture in relation with the tile they occupy while considering the configured item render size, this way we are not limited by the boundaries of the tile size of the grid anymore.
Preview: