aliens

Author Topic: [DONE][Suggestion] Bigger Facility Preview for Ufopaedia  (Read 2240 times)

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 56
  • Repensum Est Canicula
    • View Profile
[DONE][Suggestion] Bigger Facility Preview for Ufopaedia
« on: February 17, 2024, 06:11:41 pm »
Hello again, Meridian. I spoke with Yankes and he told me to get touch in you, since the part of the code I altered is most likely related to you (since UI coding is within your domain).

The idea for this suggestion has popped up for me after I've player XPZ and seen 3x3 facilities there, which have incomplete Ufopaedia preview. Basically, all code is already implemented in this commit: https://github.com/WarStalkeR/OpenXcomExMore/commit/7ebed321cddf51dfde67414bd52514175317fbbc

I've replaced original part of code:
Code: [Select]
if (facility->getSize()==1)
{
x_offset = y_offset = tile_size/2;
}
else
{
x_offset = y_offset = 0;
}
With universal formula that is applicable for any size:
Code: [Select]
x_offset = (tile_size * std::max(0, Options::oxcePediaFacilityMaxWidth - facility->getSize())) / 2;
y_offset = (tile_size * std::max(0, Options::oxcePediaFacilityMaxHeight - facility->getSize())) / 2;
(I even prepared it for it, when I will be doing rebase for the version with independent Width/Height parameters).

Original '_image' definition:
Code: [Select]
_image = new Surface(tile_size*2, tile_size*2, 232, 16);
Was also replaced with universal code:
Code: [Select]
_image = new Surface(
tile_size * std::max(1, Options::oxcePediaFacilityMaxWidth),
tile_size * std::max(1, Options::oxcePediaFacilityMaxHeight),
232 + Options::oxcePediaFacilityOffsetX,
16 + Options::oxcePediaFacilityOffsetY);
Default parameters are 2, 2, 0, 0 - thus all mods that don't care about that feature won't see any change, nor will need to add/remove something.

Please take a look at commit and tell me what should I improve in this code (what to rewrite, maybe use something else instead of option variables and what to use as reference), so it will be worthy of creating pull, where you won't need to spend time fixing my code like last time :D

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #1 on: February 17, 2024, 09:54:15 pm »
The only change I would do is to move the parameters from options.cfg to the ruleset.

(options.cfg is meant for user options, rulesets are meant for modder options... and I assume this is a modder feature only)

Like this:

https://github.com/MeridianOXC/OpenXcom/commit/376e136720222b5146f7ad984576ab4284bb5bca

Code: [Select]
constants:
  extendedPediaFacilityParams: [3, 3, -16, -16] # oxcePediaFacilityMaxWidth, oxcePediaFacilityMaxHeight, oxcePediaFacilityOffsetX, oxcePediaFacilityOffsetY

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 56
  • Repensum Est Canicula
    • View Profile
Re: [Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #2 on: February 18, 2024, 05:31:53 pm »
The only change I would do is to move the parameters from options.cfg to the ruleset.

(options.cfg is meant for user options, rulesets are meant for modder options... and I assume this is a modder feature only)

Like this:

https://github.com/MeridianOXC/OpenXcom/commit/376e136720222b5146f7ad984576ab4284bb5bca

Code: [Select]
constants:
  extendedPediaFacilityParams: [3, 3, -16, -16] # oxcePediaFacilityMaxWidth, oxcePediaFacilityMaxHeight, oxcePediaFacilityOffsetX, oxcePediaFacilityOffsetY
Got it! Then I will change code accordingly.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #3 on: February 18, 2024, 05:33:39 pm »
Can I push this commit already, or is there something else to wait for?

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 56
  • Repensum Est Canicula
    • View Profile
Re: [Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #4 on: February 18, 2024, 06:24:07 pm »
Sure, you can push it. I'm pretty sure I haven't missed any code.
« Last Edit: February 18, 2024, 06:26:03 pm by WarStalkeR »

Offline WarStalkeR

  • Captain
  • ***
  • Posts: 56
  • Repensum Est Canicula
    • View Profile
Re: [Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #5 on: February 18, 2024, 11:11:08 pm »
This is how it looks right now after update: https://github.com/WarStalkeR/OpenXcomExMore/commit/15e55472bf068023afa10a70ac5edf8a3e5c54de (do note that this one is in sync with code for 7.9.23).

For latest 7.11.8 I've created dedicated pull-ready branch https://github.com/WarStalkeR/OpenXcomExMore/tree/oxce-plus-pull-pedia-preview with relevant commit https://github.com/WarStalkeR/OpenXcomExMore/commit/60ef653d8a228ec149f4f4a06dc497c38d3e4561

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11728
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [DONE][Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #7 on: February 24, 2024, 12:49:58 pm »
Works well and looks nice! Thank you!

Offline 0xEBJC

  • Colonel
  • ****
  • Posts: 180
  • Y'all are awesome! Thankful for this community.
    • View Profile
    • My Projects
Re: [DONE][Suggestion] Bigger Facility Preview for Ufopaedia
« Reply #8 on: March 25, 2024, 06:57:23 pm »
Which rulset and how would I apply this to one of my base facilities that are 3x3 in size?  Thanks,  I looked at the commit, but it wasn't clear to me.

is this an individual setting for one specific ufopedia page? or a global setting for the mods ruleset?



... figured it out!

Looked at X-Com Files, which had two files constants_XCOMFILES.rul and vars_XCOMFILES.rul rule files which declare a "constants:" section
« Last Edit: March 25, 2024, 07:25:56 pm by 0xEBJC »