2020-01-01 21:29:24 +01:00
|
|
|
#ifndef GRAPHICS_H
|
|
|
|
#define GRAPHICS_H
|
|
|
|
|
|
|
|
#include "GraphicsResources.h"
|
|
|
|
#include <vector>
|
2020-01-31 19:25:37 +01:00
|
|
|
#include <map>
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Maths.h"
|
|
|
|
#include "Textbox.h"
|
|
|
|
#include "UtilityClass.h"
|
|
|
|
#include "Game.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "GraphicsUtil.h"
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
class Graphics
|
|
|
|
{
|
|
|
|
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();
|
2020-01-01 21:29:24 +01:00
|
|
|
~Graphics();
|
|
|
|
|
|
|
|
GraphicsResources grphx;
|
|
|
|
|
2020-02-11 06:48:07 +01:00
|
|
|
int bfontlen(uint32_t ch);
|
|
|
|
int font_idx(uint32_t ch);
|
2020-01-31 19:25:37 +01:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
void Makebfont();
|
|
|
|
|
|
|
|
void drawhuetile(int x, int y, int t, int c);
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawgravityline(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void MakeTileArray();
|
|
|
|
|
|
|
|
void MakeSpriteArray();
|
|
|
|
|
|
|
|
void maketelearray();
|
|
|
|
|
|
|
|
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawmenu(int cr, int cg, int cb, int division = 30);
|
|
|
|
void drawlevelmenu(int cr, int cg, int cb, int division = 30);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void processfade();
|
|
|
|
|
|
|
|
void drawfade();
|
|
|
|
|
|
|
|
void setwarprect(int a, int b, int c, int d);
|
|
|
|
|
|
|
|
void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255);
|
|
|
|
|
|
|
|
void textboxcenter();
|
|
|
|
|
|
|
|
void textboxcenterx();
|
|
|
|
|
|
|
|
int textboxwidth();
|
|
|
|
|
|
|
|
void textboxmove(int xo, int yo);
|
|
|
|
|
|
|
|
void textboxmoveto(int xo);
|
|
|
|
|
|
|
|
void textboxcentery();
|
|
|
|
|
|
|
|
void textboxadjust();
|
|
|
|
|
|
|
|
void addline(std::string t);
|
|
|
|
|
|
|
|
void textboxtimer(int t);
|
|
|
|
|
|
|
|
void textboxremove();
|
|
|
|
|
|
|
|
void textboxremovefast();
|
|
|
|
|
|
|
|
void textboxactive();
|
|
|
|
|
|
|
|
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
|
|
|
|
|
|
|
|
void drawpixeltextbox(int x, int y, int w, int h, int w2, int h2, int r, int g, int b, int xo, int yo);
|
|
|
|
void drawcustompixeltextbox(int x, int y, int w, int h, int w2, int h2, int r, int g, int b, int xo, int yo);
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int crewcolour(const int t);
|
|
|
|
|
|
|
|
void cutscenebars();
|
2020-04-29 02:11:02 +02:00
|
|
|
void cutscenebarstimer();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void drawpartimage(int t, int xp, int yp, int wp, int hp);
|
|
|
|
|
|
|
|
void drawimage(int t, int xp, int yp, bool cent=false);
|
|
|
|
|
|
|
|
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
|
|
|
|
|
2020-04-29 03:38:43 +02:00
|
|
|
void updatetextboxes();
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawgui();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void drawsprite(int x, int y, int t, int r, int g, int b);
|
|
|
|
|
|
|
|
void printcrewname(int x, int y, int t);
|
|
|
|
|
|
|
|
void printcrewnamestatus(int x, int y, int t);
|
|
|
|
|
|
|
|
void printcrewnamedark(int x, int y, int t);
|
|
|
|
|
|
|
|
void Print(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
|
|
|
|
2020-02-10 03:23:12 +01:00
|
|
|
void PrintAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
void RPrint(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
|
|
|
|
|
|
|
void PrintOff(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
|
|
|
|
2020-02-10 03:23:12 +01:00
|
|
|
void PrintOffAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
void bprint(int x, int y, std::string t, int r, int g, int b, bool cen = false);
|
|
|
|
|
2020-02-10 03:23:12 +01:00
|
|
|
void bprintalpha(int x, int y, std::string t, int r, int g, int b, int a, bool cen = false);
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
int len(std::string t);
|
|
|
|
void bigprint( int _x, int _y, std::string _s, int r, int g, int b, bool cen = false, int sc = 2 );
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawspritesetcol(int x, int y, int t, int c);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
void flashlight();
|
|
|
|
void screenshake();
|
2020-04-29 02:29:59 +02:00
|
|
|
void updatescreenshake();
|
|
|
|
|
|
|
|
int screenshake_x;
|
|
|
|
int screenshake_y;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void render();
|
2020-04-27 04:24:50 +02:00
|
|
|
void renderwithscreeneffects();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-02 00:35:27 +02:00
|
|
|
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawentities();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtrophytext();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
|
|
|
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtele(int x, int y, int t, int c);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-02-10 03:23:12 +01:00
|
|
|
Uint32 getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
|
|
|
|
|
|
|
|
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
|
|
|
|
|
|
|
|
Uint32 getRGB(Uint32 _col);
|
|
|
|
|
|
|
|
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
|
|
|
|
|
|
|
|
|
|
|
|
Uint32 RGBf(int r, int g, int b);
|
|
|
|
|
|
|
|
void setcolreal(Uint32 t);
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawbackground(int t);
|
2020-04-29 04:28:16 +02:00
|
|
|
void updatebackground(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
void drawtile3( int x, int y, int t, int off );
|
|
|
|
void drawentcolours( int x, int y, int t);
|
2020-04-02 00:47:35 +02:00
|
|
|
void drawtile2( int x, int y, int t );
|
2020-04-02 00:42:22 +02:00
|
|
|
void drawtile( int x, int y, int t );
|
2020-01-01 21:29:24 +01:00
|
|
|
void drawtowertile( int x, int y, int t );
|
|
|
|
void drawtowertile3( int x, int y, int t, int off );
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawmap();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void drawforetile(int x, int y, int t);
|
|
|
|
|
|
|
|
void drawforetile2(int x, int y, int t);
|
|
|
|
|
|
|
|
void drawforetile3(int x, int y, int t, int off);
|
|
|
|
|
|
|
|
void drawrect(int x, int y, int w, int h, int r, int g, int b);
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtowermap();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtowermap_nobackground();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtowerspikes();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
bool onscreen(int t);
|
2020-06-12 02:56:12 +02:00
|
|
|
|
2020-06-01 01:31:02 +02:00
|
|
|
void reloadresources();
|
|
|
|
std::string assetdir;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
void menuoffrender();
|
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void drawtowerbackground();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:26:11 +02:00
|
|
|
void setcol(int t);
|
|
|
|
void drawfinalmap();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
colourTransform ct;
|
|
|
|
|
|
|
|
int bcol, bcol2, rcol;
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 20:21:32 +02:00
|
|
|
int m;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
std::vector <SDL_Surface*> backgrounds;
|
|
|
|
std::vector <SDL_Surface*> images;
|
|
|
|
|
|
|
|
std::vector <SDL_Surface*> tele;
|
|
|
|
std::vector <SDL_Surface*> tiles;
|
|
|
|
std::vector <SDL_Surface*> tiles2;
|
|
|
|
std::vector <SDL_Surface*> tiles3;
|
|
|
|
std::vector <SDL_Surface*> entcolours;
|
|
|
|
std::vector <SDL_Surface*> sprites;
|
|
|
|
std::vector <SDL_Surface*> flipsprites;
|
|
|
|
std::vector <SDL_Surface*> bfont;
|
|
|
|
std::vector <SDL_Surface*> bfontmask;
|
|
|
|
std::vector <SDL_Surface*> flipbfont;
|
|
|
|
std::vector <SDL_Surface*> flipbfontmask;
|
|
|
|
|
|
|
|
bool flipmode;
|
|
|
|
bool setflipmode;
|
2020-01-17 18:37:53 +01:00
|
|
|
bool notextoutline;
|
2020-01-01 21:29:24 +01:00
|
|
|
point tl;
|
|
|
|
//buffer objects. //TODO refactor buffer objects
|
|
|
|
SDL_Surface* backBuffer;
|
|
|
|
Screen* screenbuffer;
|
|
|
|
SDL_Surface* menubuffer;
|
|
|
|
SDL_Surface* towerbuffer;
|
2020-01-11 01:37:23 +01:00
|
|
|
SDL_Surface* foregroundBuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
SDL_Surface* tempBuffer;
|
|
|
|
|
|
|
|
SDL_Rect bfont_rect;
|
|
|
|
SDL_Rect tiles_rect;
|
|
|
|
SDL_Rect sprites_rect;
|
|
|
|
SDL_Rect bfontmask_rect;
|
|
|
|
SDL_Rect images_rect;
|
|
|
|
SDL_Rect bg_rect;
|
|
|
|
SDL_Rect line_rect;
|
|
|
|
SDL_Rect tele_rect;
|
|
|
|
|
|
|
|
SDL_Rect foot_rect;
|
|
|
|
SDL_Rect prect;
|
|
|
|
SDL_Rect footerrect;
|
2020-01-25 05:32:55 +01:00
|
|
|
SDL_Surface* footerbuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int linestate, linedelay;
|
|
|
|
int backoffset;
|
|
|
|
bool backgrounddrawn, foregrounddrawn;
|
|
|
|
|
|
|
|
int menuoffset;
|
2020-04-29 05:46:33 +02:00
|
|
|
int oldmenuoffset;
|
2020-01-01 21:29:24 +01:00
|
|
|
bool resumegamemode;
|
|
|
|
|
|
|
|
SDL_Rect warprect;
|
|
|
|
|
|
|
|
int crewframe;
|
|
|
|
int crewframedelay;
|
|
|
|
|
|
|
|
int fademode;
|
|
|
|
int fadeamount;
|
2020-04-29 03:10:40 +02:00
|
|
|
int oldfadeamount;
|
2020-01-01 21:29:24 +01:00
|
|
|
std::vector <int> fadebars;
|
|
|
|
|
|
|
|
bool trinketcolset;
|
|
|
|
int trinketr, trinketg, trinketb;
|
|
|
|
|
|
|
|
std::vector <textboxclass> textbox;
|
|
|
|
|
|
|
|
bool showcutscenebars;
|
|
|
|
int cutscenebarspos;
|
2020-04-29 02:16:24 +02:00
|
|
|
int oldcutscenebarspos;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
std::vector<SDL_Rect> stars;
|
|
|
|
std::vector<int> starsspeed;
|
|
|
|
|
|
|
|
int spcol, spcoldel;
|
|
|
|
std::vector<SDL_Rect> backboxes;
|
|
|
|
std::vector<int> backboxvx;
|
|
|
|
std::vector<int> backboxvy;
|
|
|
|
std::vector<float> backboxint;
|
|
|
|
|
|
|
|
int warpskip, warpfcol, warpbcol;
|
|
|
|
|
2020-01-25 05:43:04 +01:00
|
|
|
bool translucentroomname;
|
2020-01-29 08:17:13 +01:00
|
|
|
|
|
|
|
bool showmousecursor;
|
2020-01-31 19:25:37 +01:00
|
|
|
|
|
|
|
std::map<int, int> font_positions;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
|
2020-06-13 00:20:39 +02:00
|
|
|
SDL_Surface* ghostbuffer;
|
2020-04-29 01:02:55 +02:00
|
|
|
|
|
|
|
float inline lerp(const float v0, const float v1)
|
|
|
|
{
|
|
|
|
return v0 + alpha * (v1 - v0);
|
|
|
|
}
|
|
|
|
float alpha;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
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
|
|
|
extern Graphics graphics;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* GRAPHICS_H */
|