Author Topic: [Suggestion] Bigger Craft Sprites (Configurable)  (Read 929 times)

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 55
  • Repensum Est Canicula
    • View Profile
[Suggestion] Bigger Craft Sprites (Configurable)
« on: March 31, 2024, 08:39:03 am »
Hello Meridian! I implemented code that allows to use different size of sprites for craft, beside default 32x40 and re-centers them accordingly.

By using option 'spriteSize: [54, 72]' in 'crafts:' rules, you can easily tell OXCE that you're using bigger (or smaller) craft sprite and that it should be re-centered accordingly by the engine.

Whole code is rather simple and can be seen in this commit: https://github.com/WarStalkeR/OpenXcomExMore/commit/0cc69e3427a25da3c48a7b08c63e066cb04196a0

My only advice is to use even sprite dimensions, since I have no idea how well it will handle odd numbers (it does int/2 division). If option isn't used, default 32x40 is used - as result code is completely backwards compatible.

If you think that anything needs to be changed, please tell me and I will implement it, before creating the pull request.
« Last Edit: May 10, 2024, 01:51:36 pm by WarStalkeR »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8888
    • View Profile
Re: [Suggestion] Bigger Craft Sprites (Configurable)
« Reply #1 on: August 11, 2024, 02:35:30 pm »
Craft sprites come from BASEBITS.PCK sprite set (internally saved as SurfaceSet).

SurfaceSets support only sprites with the same width and height for all sprites... otherwise the SurfaceSet's members _width and _height would be meaningless.

This change doesn't look correct to me.

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 55
  • Repensum Est Canicula
    • View Profile
Re: [Suggestion] Bigger Craft Sprites (Configurable)
« Reply #2 on: August 18, 2024, 09:33:20 pm »
Craft sprites come from BASEBITS.PCK sprite set (internally saved as SurfaceSet).

SurfaceSets support only sprites with the same width and height for all sprites... otherwise the SurfaceSet's members _width and _height would be meaningless.
The thing is, I've made this change because after testing this approach:
Code: [Select]
extraSprites:
  - type: BASEBITS.PCK
    files:
      ## Vanilla XPZ Craft Sprites Override
      262: Resources/Planes/Harvester_Big_Basescape.png
I found out that no part of the sprite was cut, despite it being 44x50 instead of 32x40.

And since sprite wasn't cut, but only incorrectly centered as if it is 32x40 sprite, I used easiest approach to resolve it: is to add offsets to craft that will be using bigger sprites. And to avoid bothering modders with offset calculation, modder only requires to write actual size of the sprite and offsets will be calculated automatically.

This change doesn't look correct to me.
Well, I don't really see another way how to handle it without making code changes excessively complicated.

EDIT: I also checked other BASEBITS.PCK sprites: 32x40 is only for crafts, 32x32 is for facility basescape tiles.
« Last Edit: August 19, 2024, 07:25:01 am by WarStalkeR »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8888
    • View Profile
Re: [Suggestion] Bigger Craft Sprites (Configurable)
« Reply #3 on: August 19, 2024, 08:41:23 am »
Another option is to provide override, which doesn't come from a spriteset (similar how `modSprite` in UFO ruleset was done).
Instead one could have a new attribute, for example `modSpriteBasescape: myCustomSpriteNameForBigHarvester_Base`.
And the size would come from the sprite itself, instead of having to specify it on the craft.

Btw. the craft has 3 related sprites: basescape, dogfight and minimized dogfight which currently all share the size; above commit doesn't take care of the other two yet.


The best solution (IMHO) is to not do anything.
32x40 was enough for everyone so far, even for biggest of aircraft, I haven't heard any complaints from modders yet.
And the size limitations exist too (for example in the Dogfight UI)... having different size sprites in Dogfight and in Basescape feels weird.

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 55
  • Repensum Est Canicula
    • View Profile
Re: [Suggestion] Bigger Craft Sprites (Configurable)
« Reply #4 on: August 19, 2024, 06:52:14 pm »
Another option is to provide override, which doesn't come from a spriteset (similar how `modSprite` in UFO ruleset was done).
Instead one could have a new attribute, for example `modSpriteBasescape: myCustomSpriteNameForBigHarvester_Base`.
And the size would come from the sprite itself, instead of having to specify it on the craft.
Then I will rework it accordingly. What I implemented is pretty much a crutch.

Btw. the craft has 3 related sprites: basescape, dogfight and minimized dogfight which currently all share the size; above commit doesn't take care of the other two yet.
Well, last two are tied to the interface, so unless interface is being completely reworked/replaced/moddable, 2nd and 3rd using default size will be OK. The only issue is the first one, if you want bigger (or more detailed) craft in the basescape, you're still limited to 32x40.

The best solution (IMHO) is to not do anything.
32x40 was enough for everyone so far, even for biggest of aircraft, I haven't heard any complaints from modders yet.
And the size limitations exist too (for example in the Dogfight UI)... having different size sprites in Dogfight and in Basescape feels weird.
This is only for now, until you implement custom craft types/categories (similar to custom weapon types/categories) but for hangars (or some other variant of craft slots). Once it will be possible to have dedicated hangar type for example for space battleships, I expect modders rush to add 2x3 and 3x3 hangars for them... And at this point 32x40 will be far from enough.

P.S. Conqueror from XPZ with its size pretty much begs for 3x3 (or at least 2x3) dedicated hangar (actual reason why I started multi-craft slots, craft classes and bigger basescape sprites).
« Last Edit: August 20, 2024, 07:17:14 am by WarStalkeR »