1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00
VVVVVV/desktop_version/src/GraphicsResources.h

54 lines
1.1 KiB
C
Raw Normal View History

2020-01-01 21:29:24 +01:00
#ifndef GRAPHICSRESOURCES_H
#define GRAPHICSRESOURCES_H
#include <SDL.h>
2020-01-01 21:29:24 +01:00
enum TextureLoadType
{
TEX_COLOR,
TEX_WHITE,
TEX_GRAYSCALE
};
2020-01-01 21:29:24 +01:00
class GraphicsResources
{
public:
Allow using help/graphics/music/game/key/map/obj everywhere This commit makes `help`, `graphics`, `music`, `game`, `key`, `map`, and `obj` essentially static global objects that can be used everywhere. This is useful in case we ever need to add a new function in the future, so we don't have to bother with passing a new argument in which means we have to pass a new argument in to the function that calls that function which means having to pass a new argument into the function that calls THAT function, etc. which is a real headache when working on fan mods of the source code. Note that this changes NONE of the existing function signatures, it merely just makes those variables accessible everywhere in the same way `script` and `ed` are. Also note that some classes had to be initialized after the filesystem was initialized, but C++ would keep initializing them before the filesystem got initialized, because I *had* to put them at the top of `main.cpp`, or else they wouldn't be global variables. The only way to work around this was to use entityclass's initialization style (which I'm pretty sure entityclass of all things doesn't need to be initialized this way), where you actually initialize the class in an `init()` function, and so then you do `graphics.init()` after the filesystem initialization, AFTER doing `Graphics graphics` up at the top. I've had to do this for `graphics` (but only because its child GraphicsResources `grphx` needs to be initialized this way), `music`, and `game`. I don't think this will affect anything. Other than that, `help`, `key`, and `map` are still using the C++-intended method of having ClassName::ClassName() functions.
2020-01-29 08:35:03 +01:00
void init(void);
2020-06-07 22:29:48 +02:00
void destroy(void);
2020-01-01 21:29:24 +01:00
Add support for translatable sprites Language folders can now have a graphics folder, with these files: - sprites.png and flipsprites.png: spritesheets which contain translated versions of the word enemies and checkpoints - spritesmask.xml: an XML file containing all the sprites that should be copied from the translated sprites and flipsprites images to the original sprites/flipsprites. This means that the translated spritesheets don't have to contain ALL sprites - they only have to contain the translated ones. When loading them, the game assembles a combined spritesheet with translated sprites replacing English ones as needed, and this sheet is used to visually substitute the normal sprites at rendering time. It's important to note that even if 32x32 enemies have pixel-perfect hitboxes, this is only a visual change. This has been discussed several times on Discord - basically we don't want to give people unfair advantages or disadvantages because of their language setting, or change existing gameplay and speedruns tactics, which may depend on the exact pixel arrangements of the enemies. Therefore, the hitboxes are still based on the English sprites. This should be basically unnoticeable for casual players, especially with some thought from translators and artists, but there will be an option in the speedrunner menu to display the original sprites all the time. I removed the `VVV_freefunc(SDL_FreeSurface, *tilesheet)` in make_array() in Graphics.cpp, which frees grphx.im_sprites_surf and grphx.im_flipsprites_surf. Since GraphicsResources::destroy() already frees these, it looks like the only purpose the one in make_array() serves is to do it earlier. But now we need them again later (when switching languages) so let's just not free them early.
2023-09-27 03:53:36 +02:00
void init_translations(void);
SDL_Surface* im_sprites_surf;
SDL_Surface* im_flipsprites_surf;
SDL_Texture* im_tiles;
SDL_Texture* im_tiles_white;
SDL_Texture* im_tiles_tint;
SDL_Texture* im_tiles2;
SDL_Texture* im_tiles2_tint;
SDL_Texture* im_tiles3;
SDL_Texture* im_entcolours;
SDL_Texture* im_entcolours_tint;
SDL_Texture* im_sprites;
SDL_Texture* im_flipsprites;
SDL_Texture* im_teleporter;
SDL_Texture* im_image0;
SDL_Texture* im_image1;
SDL_Texture* im_image2;
SDL_Texture* im_image3;
SDL_Texture* im_image4;
SDL_Texture* im_image5;
SDL_Texture* im_image6;
SDL_Texture* im_image7;
SDL_Texture* im_image8;
SDL_Texture* im_image9;
SDL_Texture* im_image10;
SDL_Texture* im_image11;
SDL_Texture* im_image12;
Add support for translatable sprites Language folders can now have a graphics folder, with these files: - sprites.png and flipsprites.png: spritesheets which contain translated versions of the word enemies and checkpoints - spritesmask.xml: an XML file containing all the sprites that should be copied from the translated sprites and flipsprites images to the original sprites/flipsprites. This means that the translated spritesheets don't have to contain ALL sprites - they only have to contain the translated ones. When loading them, the game assembles a combined spritesheet with translated sprites replacing English ones as needed, and this sheet is used to visually substitute the normal sprites at rendering time. It's important to note that even if 32x32 enemies have pixel-perfect hitboxes, this is only a visual change. This has been discussed several times on Discord - basically we don't want to give people unfair advantages or disadvantages because of their language setting, or change existing gameplay and speedruns tactics, which may depend on the exact pixel arrangements of the enemies. Therefore, the hitboxes are still based on the English sprites. This should be basically unnoticeable for casual players, especially with some thought from translators and artists, but there will be an option in the speedrunner menu to display the original sprites all the time. I removed the `VVV_freefunc(SDL_FreeSurface, *tilesheet)` in make_array() in Graphics.cpp, which frees grphx.im_sprites_surf and grphx.im_flipsprites_surf. Since GraphicsResources::destroy() already frees these, it looks like the only purpose the one in make_array() serves is to do it earlier. But now we need them again later (when switching languages) so let's just not free them early.
2023-09-27 03:53:36 +02:00
SDL_Texture* im_sprites_translated;
SDL_Texture* im_flipsprites_translated;
2020-01-01 21:29:24 +01:00
};
#endif /* GRAPHICSRESOURCES_H */