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

enhancement: configurable map items size #1788

Conversation

Arufonsu
Copy link
Contributor

@Arufonsu Arufonsu commented Apr 16, 2023

enhances spawned/dropped items in maps by:

  • Adding configurable size for their sprites.
  • Centering their sprites in relation to the tiles they occupy.

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:

imagen

imagen

@Arufonsu Arufonsu added the enhancement Minor feature addition or quality of life change label Apr 16, 2023
@Arufonsu Arufonsu requested review from jcsnider and a team April 16, 2023 22:17
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from 396cd0d to a339243 Compare April 16, 2023 22:19
Intersect (Core)/Config/Options.cs Outdated Show resolved Hide resolved
Comment on lines 41 to 50
/// <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;

Copy link
Member

@lodicolo lodicolo Apr 21, 2023

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 uints.

If the value is default, you can skip the computation for that dimension and just use the Tile<Dimension>.

Comment on lines 736 to 745
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);
Copy link
Member

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.

@Arufonsu Arufonsu marked this pull request as draft April 23, 2023 04:47
@Arufonsu Arufonsu requested a review from lodicolo April 29, 2023 23:15
@Arufonsu Arufonsu marked this pull request as ready for review April 29, 2023 23:17
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from d3828d0 to a5e003a Compare May 6, 2023 20:30
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from a5e003a to 764662b Compare July 6, 2023 17:35
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from 764662b to cd8831a Compare August 22, 2023 02:51
@Arufonsu Arufonsu requested review from AlexVild, WeylonSantana and a team August 22, 2023 02:51
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch 2 times, most recently from f894fb3 to ebf6bf8 Compare August 27, 2023 04:22
Comment on lines 726 to 727
var mapItemWidth = preferredMapItemWidth <= 0 ? tileWidth : preferredMapItemWidth;
var mapItemHeight = preferredMapItemHeight <= 0 ? tileHeight : preferredMapItemHeight;
Copy link
Member

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

@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch 2 times, most recently from 11faa44 to 6edc76b Compare August 28, 2023 02:47
@Arufonsu Arufonsu requested a review from lodicolo August 28, 2023 02:47
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch 2 times, most recently from 6edc76b to 2808ece Compare September 1, 2023 01:13
@AscensionGameDev AscensionGameDev deleted a comment from intersectbot Sep 1, 2023
@TimtyG
Copy link
Contributor

TimtyG commented Sep 25, 2023

/helptest

@intersectbot
Copy link
Member

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!

@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from 2808ece to 9a13c2b Compare October 2, 2023 23:40
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from 9a13c2b to b6f7f34 Compare October 13, 2023 03:50
@Arufonsu Arufonsu self-assigned this Oct 13, 2023
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.
@Arufonsu Arufonsu force-pushed the dev/enhancement-configurable-mapitemsize branch from b6f7f34 to e2fd072 Compare October 21, 2023 18:28
@Arufonsu
Copy link
Contributor Author

Updated PR for B8

@lodicolo lodicolo merged commit 31a00d2 into AscensionGameDev:main Oct 31, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Minor feature addition or quality of life change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants