OpenXcom Forum

Modding => Help => Topic started by: Reuged on February 09, 2022, 05:28:36 pm

Title: Weapons Frames pallete swap [SOLVED (for good)]
Post by: Reuged on February 09, 2022, 05:28:36 pm
someone could help?, i'm struggling to implement new frames on my custom weaponry, the game loads the weapons fine butt the weapon pallet always swap to its negative and they are offen appears cut off and off center, what i'm doing wrong?, the frames always it has to be 32x48?

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

so sorry for re-onpening the case butt i found stuck yet again in the same subject, i make it work propelly using Paint.net (yeah the bad drawing program but it was'nt easy task make it work, but i did 8)) butt now i have to stick with pink background instead of transparent background like others mods what searched for reference what i have to do to have trasparent background??? plz help :(
Title: Re: Weapons Frames pallete swap
Post by: The Martian on February 09, 2022, 08:38:52 pm
Be aware that many graphics editors do not play well with OpenXcom, here is a list of ones that do and don't 'image editors / graphics programs (https://openxcom.org/forum/index.php/topic,2676.0.html)'

Even though GIMP is listed as a program that will give you trouble, if you are using it here is a method I posted in a different thread (https://openxcom.org/forum/index.php/topic,9722.msg139294.html#msg139294) that may make the palette display correctly.

The part about the transparent background  may not apply to your current situation, but the rest of it about setting the image's palette may fix the strange colours you are experiencing.

I'm also using GIMP, and when making X-Com sprites it does fight you.

If you are not already using it you should look at Falko's Modding Tool's Palette converter (https://falkooxc2.pythonanywhere.com/spritepalette), if you run an image through that and the background becomes green you are usually fine.

Falko's Modding Tool's OpenXcom forum thread: https://openxcom.org/forum/index.php/topic,2980.0.html (https://openxcom.org/forum/index.php/topic,2980.0.html)

Falko's Modding Tool: Palette converter: https://falkooxc2.pythonanywhere.com/spritepalette (https://falkooxc2.pythonanywhere.com/spritepalette)

The modding tool works directly off a website so no need to install or download anything.


If your image's background is Black, Yellow or White unexpectedly I've found this works to fix it:

[1] Open the image in GIMP.
[2] Create a new layer (Do not duplicate the layer of the image with the incorrect background)
[3] Copy your image to the new layer.
[4] Selected the "Select by Colour Tool"
[5] Change "Threshold" to 0.0
[6] Select the rogue background colour by clicking on it in the image.
[7] Press the Delete key.
[8] If this works you should have an empty transparency area where the colour was, but we're not done yet.
[9] In the menu's drop down selection of "Image -> Mode" select RGB.

Now you will need the GIMP palette files for UFO: Enemy Unknown/X-COM: UFO Defense (Or X-Com: Terror From The Deep which uses a different palette)

I've attached both the UFO & TFTD GIMP Palette files I use to this post.

[10] Download and install into GIMP the Enemy Unknown/X-COM: UFO Defense palette (https://openxcom.org/forum/index.php?action=dlattach;topic=9722.0;attach=54144).
[11]<Optional> Download and install into GIMP the X-Com: Terror From The Deep palette (https://openxcom.org/forum/index.php?action=dlattach;topic=9722.0;attach=54145).

[12] Now in GIMP's menu's drop down selection of "Image -> Mode" select "Indexed..."
[13] Select XCOM-BattleScape.gpl  palette file.
[14] Make sure "Remove unusued colours from colourmap" is left unchecked!
(https://openxcom.org/forum/index.php?action=dlattach;topic=9722.0;attach=54148)

[15] Press "Convert"

Final steps, you should now have an image with the correct colour palette and a background that is a transparency area, however to make 100% it works every time now do the following:

[16] Open Falko's Modding Tool: Palette converter (https://falkooxc2.pythonanywhere.com/spritepalette).
[17] Click the red box marked "Drop files here or Click to upload multiple images."
[18] Select the files you want to convert.
[19] Since you are using the UFO palette the default settings are fine (Note: If using TFTD then click "fix-palette(ufo-battlescape)" and change it to a TFTD setting.)
[20] Press "Convert" and wait. (Large sprite sheets take a second, BigObs, FloorObs & HandObs are almost instantly done.)
[21] After you've pressed the "Convert" button it will gray out, when it returns to normal press "Download" and obtain your converted images.

[22]<Optional> If you want to see the images before downloading click "Show Images" in the upper right or the "Show" button beside the file entry you are converting, then select "images" from the "Show" button's menu


If Falko's Tool (https://falkooxc2.pythonanywhere.com/spritepalette) has converted the image to having a green background then it usually is going to work in OpenXcom without a problem.
(Note: If the background has simply changed colour and is now White, Black or Yellow. Repeat the above steps and it usually becomes the expected bright green.)


Hope that helps. (It sounds like a lot of steps, but it is actually really fast once you get used to doing it.)


Here is an example of what you should see if you use Falko's Modding Tool: Palette converter (https://falkooxc2.pythonanywhere.com/spritepalette):
(https://openxcom.org/forum/index.php?action=dlattach;topic=9722.0;attach=54146)
Title: Re: Weapons Frames pallete swap
Post by: The Martian on February 09, 2022, 09:26:18 pm
... the frames it has to always 32x48?

The size needs to be the following for an item's images:
BigOb   =  32 x 48
FloorOb =  32 x 40
HandOb  = 256 x 40

Also when you are using the UFO palette be aware that for the images used during the Battlescape you should avoid using the final bottom row of dark gray colours in the palette.
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56015)
That row is reserved for something else and has a tendency to be automatically swapped with the first row of light gray when you are converting the images for use and will not always display correctly when viewed in the UFOpaedia pages.
Title: Re: Weapons Frames pallete swap
Post by: The Martian on February 09, 2022, 09:37:31 pm
... they are offen appears cut off and off center, what i'm doing wrong?

If the image is not aligned correctly when displayed, make sure that the item the image is being used for in the items: section has the correct value for the invWidth: and invHeight: variables.

Are these the unaligned weapons?
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56014;image)

It may help located the problem if you attached the image files directly to your post, I understand completely if you'd prefer not to upload your work-in-progress though.


Just from what I can see, make sure that the item is aligned in the image towards the upper left corner, like this:
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56037)

Not like this:
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56038)

And check that the BigOb's image file size is 32 x 48. (Even if the equipment is only 1 x 2 inventory slots in size)
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56039)
Title: Re: Weapons Frames pallete swap
Post by: Reuged on February 10, 2022, 12:26:53 am
@The Martian oh boy look at me   ;D  trying to give a nice look to my wepons and this detail sliped way off my head xD and about the image yeah this https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56014;image this was supose to be the gas cannon like this attachment, anyway, i'll study better the material you bring for me thanks for the help
Title: Re: Weapons Frames pallete swap [Re-open]
Post by: The Martian on February 13, 2022, 04:38:04 pm
so sorry for re-onpening the case butt i found stuck yet again in the same subject, i make it work propelly using Paint.net (yeah the bad drawing program but it was'nt easy task make it work, but i did 8)) butt now i have to stick with pink background instead of transparent background like others mods what searched for reference what i have to do to have trasparent background??? plz help :(

Are you making your mod for X-COM: UFO Defense or X-COM: Terror From The Deep?
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56104) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56105)

Green transparent background = X-COM: UFO Defense
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56106) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56108) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56110)

Clear transparent background = X-COM: UFO Defense
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56114) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56116) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56118)


Pink transparent background = X-COM: Terror From The Deep
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56107) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56109) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56111)

Clear transparent background = X-COM: Terror From The Deep
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56115) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56117) (https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56119)


I haven't used Paint.net before so I'm unsure of how to achieve the clear (No green / pink) background as you would in GIMP.

Perhaps the operation in both programs is similar? I'll list the method I use with GIMP and perhaps you can replicate it in Paint.net.

With GIMP you can get a clear transparency layer that 'usually' works in OpenXcom by following these steps:

[1] Open the image in GIMP.
[2] Create a new layer
[3] Copy your image to the new layer.
[4] Selected the "Select by Colour Tool"
[5] Change "Threshold" to 0.0
[6] Select the Green or Pink background colour by clicking on it in the image.
[7] Press the Delete key.
[8] If this works you should have an empty transparency area where the colour was.
[9] In the menu's drop down selection of "Image -> Mode" select 'RGB'
[10] In the menu's drop down selection of "Image -> Mode" select 'Indexed...'
[11] Select either your TFTD or UFO battlescape palette.
[12] In the menu's drop down selection of "File" select "Export As..."
[13] Give your file a name and make sure that the file name ends in ".png"
[14] This menu will appear, make sure the 'Save background colour' is checked:
(https://openxcom.org/forum/index.php?action=dlattach;topic=10367.0;attach=56112)

In 'theory' the file should have the correct TFTD or UFO palette now and no pink or green transparency layer.

However if you are using Paint.NET or GIMP they have a tendency to corrupt the indexed palette so I still recommend running it through Falko's Modding Tool: Palette converter (https://falkooxc2.pythonanywhere.com/spritepalette) and using the presence of the green or pink background as a sign the palette is still intact and ready to use with OpenXcom.

If the background is any other colour after using Falk's Tool (https://falkooxc2.pythonanywhere.com/spritepalette) the indexed palette is likely corrupted. A Black or Yellow background after using Falk's Tool (https://falkooxc2.pythonanywhere.com/spritepalette) is a common sign that GIMP has altered the image's palette unexpectedly and it will need to be fixed to restore it's transparency.



On a side note, avoid using .gif image files. the Mac version of OpenXcom has a problem with them so you are better of with .png images for higher compatibility.
A quick question about Mods: are "gif" files allowed with the latest OXCE version?

Short answer: yes

Long answer: The GIF file loading is not done directly by OpenXcom, it is done by SDL (a 3rd party library we are using), and even SDL is outsourcing some work to the operating system. On most platforms (e.g. Windows, Linux, Android), it works fine. On some platforms (e.g. MacOS) it doesn't. So, unless you're using Mac, you can use GIFs. If you are on Mac, the only safe bet is png.
Title: Re: Weapons Frames pallete swap [Re-open]
Post by: The Martian on February 13, 2022, 04:52:46 pm
For convenience here are the files with clear transparent backgrounds. (Had to add them to a 2nd post as there was a limit of 10 attachments)

I tested the BigOb_Gas_Cannon_TFTD.png in OpenXcom and it seems to be loading correctly without corruption so I'm assuming the entire batch is fine, although that may not be the case.
Title: Re: Weapons Frames pallete swap [Re-open]
Post by: Reuged on February 14, 2022, 12:08:47 am
Are you making your mod for X-COM: UFO Defense or X-COM: Terror From The Deep?

i'm doing my as first mod just a wepons reskin and some minor QoL improvements for TFTD something simple just to get used with these shinanigans first

Quote from: The Martian link=topic=10367.msg144098#msg144098 date=1644763084
I haven't used Paint.net before so I'm unsure of how to achieve the clear (No green / pink) background as you would in GIMP.

Perhaps the operation in both programs is similar?

no gimp is far superior than Paint.net in that case i just give a try on the save settings, i just set to save as 8-bit png, with octree saving algorithm but one of many stingy things on Paint.net is, it don't ignore the tranparency and it counts the transparency channel as a active channel (that's why Paint.net mess with the pallets so much and its a Pain to use but its usable in many cases), i use falkoo tools to fix the issue butt when it done the falkoo saves with a black backgroung instead keeping the transparecy so that's why whole pinky situation i don't like use gimp as a pixel editor i ca'nt even do a simpe square figure without making a whole set of thingmagick but i'll study waht you teach me and give a try thanks again for the help