Move from surfaces to the SDL render system

Ever since VVVVVV was initially ported to C++ in 2.0, it has used surfaces from SDL. The downside is, that's all software rendering. This commit moves most things off of surfaces, and all into GPU, by using textures and SDL_Renderer.

Pixel-perfect collision has been kept by keeping a copy of sprites as surfaces. There's plans for pixel-perfect collision to use masks instead of reading pixel data directly, but that's out of scope for this commit.

- `graphics.reloadresources()` is now called later in `main`, because textures cannot be created without a renderer.

- This commit also removes a bunch of surface functions which are no longer needed.

- This also recaches target textures in certain places for d3d9.

- graphics.images was converted to a fixed-size array.

- fillbox and fillboxabs use SDL_RenderDrawRect instead of drawing an outline using four filled rectangles

- Update my name in the credits
This commit is contained in:
AllyTally
2023-01-07 14:28:07 -04:00
committed by Misa Elizabeth Kai
parent 556e3a110a
commit 19b2a317f1
24 changed files with 1446 additions and 1387 deletions

View File

@@ -22,6 +22,7 @@
#include "Script.h"
#include "UtilityClass.h"
#include "VFormat.h"
#include "Vlogging.h"
editorclass::editorclass(void)
{
@@ -281,18 +282,28 @@ static int edentat( int xp, int yp )
static void fillbox(const int x, const int y, const int x2, const int y2, const SDL_Color color)
{
FillRect(graphics.backBuffer, x, y, x2-x, 1, color);
FillRect(graphics.backBuffer, x, y2-1, x2-x, 1, color);
FillRect(graphics.backBuffer, x, y, 1, y2-y, color);
FillRect(graphics.backBuffer, x2-1, y, 1, y2-y, color);
graphics.set_color(color);
const SDL_Rect rect = {x, y, x2 - x, y2 - y};
const int result = SDL_RenderDrawRect(gameScreen.m_renderer, &rect);
if (result != 0)
{
WHINE_ONCE_ARGS(("Could not render rectangle outline: %s", SDL_GetError()));
}
}
static void fillboxabs(const int x, const int y, const int x2, const int y2, const SDL_Color color)
{
FillRect(graphics.backBuffer, x, y, x2, 1, color);
FillRect(graphics.backBuffer, x, y+y2-1, x2, 1, color);
FillRect(graphics.backBuffer, x, y, 1, y2, color);
FillRect(graphics.backBuffer, x+x2-1, y, 1, y2, color);
graphics.set_color(color);
const SDL_Rect rect = {x, y, x2, y2};
const int result = SDL_RenderDrawRect(gameScreen.m_renderer, &rect);
if (result != 0)
{
WHINE_ONCE_ARGS(("Could not render rectangle outline: %s", SDL_GetError()));
}
}
@@ -492,8 +503,8 @@ void editorrender(void)
const RoomProperty* const room = cl.getroomprop(ed.levx, ed.levy);
//Draw grid
graphics.clear();
ClearSurface(graphics.backBuffer);
for(int j=0; j<30; j++)
{
for(int i=0; i<40; i++)
@@ -566,12 +577,12 @@ void editorrender(void)
//left edge
if(ed.freewrap((ed.levx*40)-1,j+(ed.levy*30))==1)
{
FillRect(graphics.backBuffer, 0,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
graphics.fill_rect(0,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
}
//right edge
if(ed.freewrap((ed.levx*40)+40,j+(ed.levy*30))==1)
{
FillRect(graphics.backBuffer, 318,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
graphics.fill_rect(318,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
}
}
@@ -579,12 +590,12 @@ void editorrender(void)
{
if(ed.freewrap((ed.levx*40)+i,(ed.levy*30)-1)==1)
{
FillRect(graphics.backBuffer, i*8,0, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
graphics.fill_rect(i*8,0, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
}
if(ed.freewrap((ed.levx*40)+i,30+(ed.levy*30))==1)
{
FillRect(graphics.backBuffer, i*8,238, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
graphics.fill_rect(i*8,238, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
}
}
@@ -595,7 +606,6 @@ void editorrender(void)
// Special case for drawing gray entities
bool custom_gray = room->tileset == 3 && room->tilecol == 6;
const SDL_Color gray_ct = {255, 255, 255, 255};
// Draw entities backward to remain accurate with ingame
for (int i = customentities.size() - 1; i >= 0; i--)
@@ -613,7 +623,7 @@ void editorrender(void)
{
ed.entcolreal = graphics.getcol(18);
}
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal);
if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "V", 255, 255, 255 - help.glow, false);
if(customentities[i].p1==1) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "^", 255, 255, 255 - help.glow, false);
if(customentities[i].p1==2) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "<", 255, 255, 255 - help.glow, false);
@@ -621,18 +631,13 @@ void editorrender(void)
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255,164,255));
break;
case 2: //Threadmills & platforms
if (!INBOUNDS_VEC(obj.customplatformtile, graphics.entcolours))
{
continue;
}
tpoint.x = (customentities[i].x*8)- (ed.levx*40*8);
tpoint.y = (customentities[i].y*8)- (ed.levy*30*8);
drawRect = graphics.tiles_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
for (int j = 0; j < 4; j++) {
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
graphics.draw_grid_tile(custom_gray ? graphics.grphx.im_entcolours_tint : graphics.grphx.im_entcolours, obj.customplatformtile, drawRect.x, drawRect.y, 8, 8);
drawRect.x += 8;
}
@@ -664,8 +669,7 @@ void editorrender(void)
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
for (int j = 0; j < 4; j++) {
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
graphics.draw_grid_tile(custom_gray ? graphics.grphx.im_entcolours_tint : graphics.grphx.im_entcolours, obj.customplatformtile, drawRect.x, drawRect.y, 8, 8);
drawRect.x += 8;
}
}
@@ -682,18 +686,13 @@ void editorrender(void)
}
break;
case 3: //Disappearing Platform
if (!INBOUNDS_VEC(obj.customplatformtile, graphics.entcolours))
{
continue;
}
tpoint.x = (customentities[i].x*8)- (ed.levx*40*8);
tpoint.y = (customentities[i].y*8)- (ed.levy*30*8);
drawRect = graphics.tiles_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
for (int j = 0; j < 4; j++) {
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
graphics.draw_grid_tile(custom_gray ? graphics.grphx.im_entcolours_tint : graphics.grphx.im_entcolours, obj.customplatformtile, drawRect.x, drawRect.y, 8, 8);
drawRect.x += 8;
}
@@ -701,11 +700,11 @@ void editorrender(void)
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getRGB(255,255,255));
break;
case 9: //Shiny Trinket
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),22,196,196,196);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),22,196,196,196);
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
break;
case 10: //Checkpoints
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),20 + customentities[i].p1,196,196,196);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),20 + customentities[i].p1,196,196,196);
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
break;
case 11: //Gravity lines
@@ -714,7 +713,7 @@ void editorrender(void)
int tx = customentities[i].p2;
int tx2 = tx + customentities[i].p3/8;
int ty = customentities[i].y % 30;
FillRect(graphics.backBuffer, (tx*8),(ty*8)+4, (tx2-tx)*8,1, graphics.getRGB(194,194,194));
graphics.fill_rect((tx*8),(ty*8)+4, (tx2-tx)*8,1, graphics.getRGB(194,194,194));
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164));
}
else //Vertical
@@ -722,12 +721,12 @@ void editorrender(void)
int tx = customentities[i].x % 40;
int ty = customentities[i].p2;
int ty2 = ty + customentities[i].p3/8;
FillRect(graphics.backBuffer, (tx*8)+3,(ty*8), 1,(ty2-ty)*8, graphics.getRGB(194,194,194));
graphics.fill_rect((tx*8)+3,(ty*8), 1,(ty2-ty)*8, graphics.getRGB(194,194,194));
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164));
}
break;
case 13://Warp tokens
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),18+(ed.entframe%2),196,196,196);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),18+(ed.entframe%2),196,196,196);
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
if (i == edent_under_cursor)
{
@@ -740,18 +739,18 @@ void editorrender(void)
}
break;
case 15: //Crewmates
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),144,graphics.crewcolourreal(customentities[i].p1));
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),144,graphics.crewcolourreal(customentities[i].p1));
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164));
break;
case 16: //Start
{
if(customentities[i].p1==0) //Left
{
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),0,graphics.col_crewcyan);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),0,graphics.col_crewcyan);
}
else if(customentities[i].p1==1)
{
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),3,graphics.col_crewcyan);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),3,graphics.col_crewcyan);
}
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(255, 255, 164));
short labelcol = ed.entframe<2 ? 255 : 196;
@@ -790,7 +789,7 @@ void editorrender(void)
usethistile = 0; // Flipped;
usethisy -= 8;
}
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8), usethisy + 8, usethistile + 16, 96,96,96);
graphics.draw_sprite((customentities[i].x*8)- (ed.levx*40*8), usethisy + 8, usethistile + 16, 96,96,96);
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164));
if (i == edent_under_cursor)
{
@@ -862,7 +861,7 @@ void editorrender(void)
{
if (customentities[i].p1 / 40 == ed.levx && customentities[i].p2 / 30 == ed.levy)
{
graphics.drawsprite((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),18+(ed.entframe%2),64,64,64);
graphics.draw_sprite((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),18+(ed.entframe%2),64,64,64);
fillboxabs((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),16,16,graphics.getRGB(96, 64, 64));
if(ed.tilex+(ed.levx*40)==customentities[i].p1 && ed.tiley+(ed.levy*30)==customentities[i].p2)
{
@@ -922,11 +921,12 @@ void editorrender(void)
//Draw ghosts (spooky!)
if (game.ghostsenabled) {
ClearSurface(graphics.ghostbuffer);
graphics.set_render_target(graphics.ghostTexture);
graphics.set_blendmode(graphics.ghostTexture, SDL_BLENDMODE_BLEND);
graphics.clear(0, 0, 0, 0);
for (int i = 0; i < (int)ed.ghosts.size(); i++) {
if (i <= ed.currentghosts) { // We don't want all of them to show up at once :)
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy
|| !INBOUNDS_VEC(ed.ghosts[i].frame, graphics.sprites))
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy)
continue;
point tpoint;
tpoint.x = ed.ghosts[i].x;
@@ -937,10 +937,12 @@ void editorrender(void)
SDL_Rect drawRect = graphics.sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured(graphics.sprites[ed.ghosts[i].frame],NULL, graphics.ghostbuffer, &drawRect, ct);
graphics.draw_sprite(drawRect.x, drawRect.y, ed.ghosts[i].frame, ct);
}
}
SDL_BlitSurface(graphics.ghostbuffer, NULL, graphics.backBuffer, NULL);
graphics.set_render_target(graphics.gameTexture);
graphics.set_texture_alpha_mod(graphics.ghostTexture, 128);
graphics.copy_texture(graphics.ghostTexture, NULL, NULL);
}
//Draw Cursor
@@ -1026,11 +1028,19 @@ void editorrender(void)
//Draw five lines of the editor
const int temp = ed.dmtile - (ed.dmtile % 40) - 80;
FillRect(graphics.backBuffer, 0,-t2,320,40, graphics.getRGB(0,0,0));
FillRect(graphics.backBuffer, 0,-t2+40,320,2, graphics.getRGB(255,255,255));
if(room->tileset==0)
graphics.fill_rect(0,-t2,320,40, graphics.getRGB(0,0,0));
graphics.fill_rect(0,-t2+40,320,2, graphics.getRGB(255,255,255));
int texturewidth;
int textureheight;
if (room->tileset == 0)
{
const int numtiles = (((int) graphics.tiles.size()) / 40) * 40;
if (graphics.query_texture(graphics.grphx.im_tiles, NULL, NULL, &texturewidth, &textureheight) != 0)
{
return;
}
const int numtiles = (int) (texturewidth / 8) * (textureheight / 8);
for(int i=0; i<40; i++)
{
@@ -1043,7 +1053,11 @@ void editorrender(void)
}
else
{
const int numtiles = (((int) graphics.tiles2.size()) / 40) * 40;
if (graphics.query_texture(graphics.grphx.im_tiles2, NULL, NULL, &texturewidth, &textureheight) != 0)
{
return;
}
const int numtiles = (int) (texturewidth / 8) * (textureheight / 8);
for(int i=0; i<40; i++)
{
@@ -1064,8 +1078,8 @@ void editorrender(void)
short labellen = 2 + graphics.len(loc::gettext("Tile:"));
graphics.bprint(2, 45-t2, loc::gettext("Tile:"), 196, 196, 255 - help.glow, false);
graphics.bprint(labellen+16, 45-t2, help.String(ed.dmtile), 196, 196, 255 - help.glow, false);
FillRect(graphics.backBuffer, labellen+2,44-t2,10,10, graphics.getRGB(255 - help.glow, 196, 196));
FillRect(graphics.backBuffer, labellen+3,45-t2,8,8, graphics.getRGB(0,0,0));
graphics.fill_rect(labellen+2,44-t2,10,10, graphics.getRGB(255 - help.glow, 196, 196));
graphics.fill_rect(labellen+3,45-t2,8,8, graphics.getRGB(0,0,0));
if(room->tileset==0)
{
@@ -1081,8 +1095,8 @@ void editorrender(void)
short labellen = 2 + graphics.len(loc::gettext("Tile:"));
graphics.bprint(2, 12, loc::gettext("Tile:"), 196, 196, 255 - help.glow, false);
graphics.bprint(labellen+16, 12, help.String(ed.dmtile), 196, 196, 255 - help.glow, false);
FillRect(graphics.backBuffer, labellen+2,11,10,10, graphics.getRGB(255 - help.glow, 196, 196));
FillRect(graphics.backBuffer, labellen+3,12,8,8, graphics.getRGB(0,0,0));
graphics.fill_rect(labellen+2,11,10,10, graphics.getRGB(255 - help.glow, 196, 196));
graphics.fill_rect(labellen+3,12,8,8, graphics.getRGB(0,0,0));
if(room->tileset==0)
{
@@ -1143,16 +1157,16 @@ void editorrender(void)
message = graphics.string_wordwrap(message, 312, &lines);
short textheight = 8*lines;
FillRect(graphics.backBuffer, 0,238-textheight,320,240, graphics.getRGB(32,32,32));
FillRect(graphics.backBuffer, 0,239-textheight,320,240, graphics.getRGB(0,0,0));
graphics.fill_rect(0,238-textheight,320,240, graphics.getRGB(32,32,32));
graphics.fill_rect(0,239-textheight,320,240, graphics.getRGB(0,0,0));
graphics.PrintWrap(4, 240-textheight, message, 255,255,255, false, 8, 312);
}
else if(ed.scripteditmod)
{
//Elaborate C64 BASIC menu goes here!
FillRect(graphics.backBuffer, 0,0,320,240, graphics.getRGB(123, 111, 218));
FillRect(graphics.backBuffer, 14,16,292,208, graphics.getRGB(61, 48, 162));
graphics.fill_rect(0,0,320,240, graphics.getRGB(123, 111, 218));
graphics.fill_rect(14,16,292,208, graphics.getRGB(61, 48, 162));
switch(ed.scripthelppage)
{
case 0:
@@ -1189,7 +1203,7 @@ void editorrender(void)
case 1:
{
//Current scriptname
FillRect(graphics.backBuffer, 14,226,292,12, graphics.getRGB(61, 48, 162));
graphics.fill_rect(14,226,292,12, graphics.getRGB(61, 48, 162));
char namebuffer[SCREEN_WIDTH_CHARS + 1];
vformat_buf(
namebuffer, sizeof(namebuffer),
@@ -1223,7 +1237,7 @@ void editorrender(void)
}
else
{
ClearSurface(graphics.backBuffer);
graphics.clear();
}
int tr = graphics.titlebg.r - (help.glow / 4) - int(fRandom() * 4);
@@ -1245,8 +1259,8 @@ void editorrender(void)
std::string wrapped = graphics.string_wordwrap(ed.textdesc, 312, &lines);
short textheight = 8*lines+8;
FillRect(graphics.backBuffer, 0, 238-textheight, 320, 240, graphics.getRGB(32, 32, 32));
FillRect(graphics.backBuffer, 0, 239-textheight, 320, 240, graphics.getRGB(0, 0, 0));
graphics.fill_rect(0, 238-textheight, 320, 240, graphics.getRGB(32, 32, 32));
graphics.fill_rect(0, 239-textheight, 320, 240, graphics.getRGB(0, 0, 0));
graphics.PrintWrap(4, 240-textheight, wrapped, 255, 255, 255, false, 8, 312);
std::string input = key.keybuffer;
if (ed.entframe < 2)
@@ -1262,8 +1276,8 @@ void editorrender(void)
else if(ed.warpmod)
{
//placing warp token
FillRect(graphics.backBuffer, 0,221,320,240, graphics.getRGB(32,32,32));
FillRect(graphics.backBuffer, 0,222,320,240, graphics.getRGB(0,0,0));
graphics.fill_rect(0,221,320,240, graphics.getRGB(32,32,32));
graphics.fill_rect(0,222,320,240, graphics.getRGB(0,0,0));
graphics.Print(4, 224, loc::gettext("Left click to place warp destination"), 196, 196, 255 - help.glow, false);
graphics.Print(4, 232, loc::gettext("Right click to cancel"), 196, 196, 255 - help.glow, false);
}
@@ -1271,8 +1285,8 @@ void editorrender(void)
{
if(ed.spacemod)
{
FillRect(graphics.backBuffer, 0,208,320,240, graphics.getRGB(32,32,32));
FillRect(graphics.backBuffer, 0,209,320,240, graphics.getRGB(0,0,0));
graphics.fill_rect(0,208,320,240, graphics.getRGB(32,32,32));
graphics.fill_rect(0,209,320,240, graphics.getRGB(0,0,0));
//Draw little icons for each thingy
int tx=6, ty=211, tg=32;
@@ -1281,9 +1295,9 @@ void editorrender(void)
{
for(int i=0; i<10; i++)
{
FillRect(graphics.backBuffer, 4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
graphics.fill_rect(4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
}
FillRect(graphics.backBuffer, 4+(ed.drawmode*tg), 209,20,20,graphics.getRGB(64,64,64));
graphics.fill_rect(4+(ed.drawmode*tg), 209,20,20,graphics.getRGB(64,64,64));
//0:
graphics.drawtile(tx,ty,83);
graphics.drawtile(tx+8,ty,83);
@@ -1300,10 +1314,10 @@ void editorrender(void)
graphics.drawtile(tx+4,ty+4,8);
//3:
tx+=tg;
graphics.drawsprite(tx,ty,22,196,196,196);
graphics.draw_sprite(tx,ty,22,196,196,196);
//4:
tx+=tg;
graphics.drawsprite(tx,ty,21,196,196,196);
graphics.draw_sprite(tx,ty,21,196,196,196);
//5:
tx+=tg;
graphics.drawtile(tx,ty+4,3);
@@ -1318,10 +1332,10 @@ void editorrender(void)
graphics.drawtile(tx+8,ty+4,1);
//8:
tx+=tg;
graphics.drawsprite(tx,ty,78+ed.entframe,196,196,196);
graphics.draw_sprite(tx,ty,78+ed.entframe,196,196,196);
//9:
tx+=tg;
FillRect(graphics.backBuffer, tx+2,ty+8,12,1,graphics.getRGB(255,255,255));
graphics.fill_rect(tx+2,ty+8,12,1,graphics.getRGB(255,255,255));
for (int i = 0; i < 10; i++)
{
@@ -1339,9 +1353,9 @@ void editorrender(void)
{
for(int i=0; i<7; i++)
{
FillRect(graphics.backBuffer, 4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
graphics.fill_rect(4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
}
FillRect(graphics.backBuffer, 4+((ed.drawmode-10)*tg), 209,20,20,graphics.getRGB(64,64,64));
graphics.fill_rect(4+((ed.drawmode-10)*tg), 209,20,20,graphics.getRGB(64,64,64));
//10:
graphics.Print(tx,ty,"A",196, 196, 255 - help.glow, false);
graphics.Print(tx+8,ty,"B",196, 196, 255 - help.glow, false);
@@ -1349,22 +1363,22 @@ void editorrender(void)
graphics.Print(tx+8,ty+8,"D",196, 196, 255 - help.glow, false);
//11:
tx+=tg;
graphics.drawsprite(tx,ty,17,196,196,196);
graphics.draw_sprite(tx,ty,17,196,196,196);
//12:
tx+=tg;
fillboxabs(tx+4,ty+4,8,8,graphics.getRGB(96,96,96));
//13:
tx+=tg;
graphics.drawsprite(tx,ty,18+(ed.entframe%2),196,196,196);
graphics.draw_sprite(tx,ty,18+(ed.entframe%2),196,196,196);
//14:
tx+=tg;
FillRect(graphics.backBuffer, tx+6,ty+2,4,12,graphics.getRGB(255,255,255));
graphics.fill_rect(tx+6,ty+2,4,12,graphics.getRGB(255,255,255));
//15:
tx+=tg;
graphics.drawsprite(tx,ty,186,graphics.col_crewblue);
graphics.draw_sprite(tx,ty,186,graphics.col_crewblue);
//16:
tx+=tg;
graphics.drawsprite(tx,ty,184,graphics.col_crewcyan);
graphics.draw_sprite(tx,ty,184,graphics.col_crewcyan);
for (int i = 0; i < 7; i++)
{
@@ -1446,30 +1460,27 @@ void editorrender(void)
break;
}
int toolnamelen = graphics.len(toolname);
FillRect(graphics.backBuffer, 0,197,toolnamelen+8,11, graphics.getRGB(32,32,32));
FillRect(graphics.backBuffer, 0,198,toolnamelen+7,10, graphics.getRGB(0,0,0));
graphics.fill_rect(0,197,toolnamelen+8,11, graphics.getRGB(32,32,32));
graphics.fill_rect(0,198,toolnamelen+7,10, graphics.getRGB(0,0,0));
graphics.bprint(2,199, toolname, 196, 196, 255 - help.glow);
FillRect(graphics.backBuffer, 260,197,80,11, graphics.getRGB(32,32,32));
FillRect(graphics.backBuffer, 261,198,80,10, graphics.getRGB(0,0,0));
graphics.fill_rect(260,197,80,11, graphics.getRGB(32,32,32));
graphics.fill_rect(261,198,80,10, graphics.getRGB(0,0,0));
graphics.bprint(268,199, "("+help.String(ed.levx+1)+","+help.String(ed.levy+1)+")",196, 196, 255 - help.glow, false);
}
else
{
//FillRect(graphics.backBuffer, 0,230,72,240, graphics.RGB(32,32,32));
//FillRect(graphics.backBuffer, 0,231,71,240, graphics.RGB(0,0,0));
//graphics.fill_rect(0,230,72,240, graphics.RGB(32,32,32));
//graphics.fill_rect(0,231,71,240, graphics.RGB(0,0,0));
if(room->roomname!="")
{
if (graphics.translucentroomname)
{
graphics.footerrect.y = 230+ed.roomnamehide;
SDL_BlitSurface(graphics.footerbuffer, NULL, graphics.backBuffer, &graphics.footerrect);
}
else
{
FillRect(graphics.backBuffer, 0,230+ed.roomnamehide,320,10, graphics.getRGB(0,0,0));
}
graphics.footerrect.y = 230 + ed.roomnamehide;
graphics.set_blendmode(SDL_BLENDMODE_BLEND);
graphics.fill_rect(&graphics.footerrect, graphics.getRGBA(0, 0, 0, graphics.translucentroomname ? 127 : 255));
graphics.set_blendmode(SDL_BLENDMODE_NONE);
graphics.bprint(5,231+ed.roomnamehide,room->roomname, 196, 196, 255 - help.glow, true);
graphics.bprint(4, 222, loc::gettext("SPACE ^ SHIFT ^"), 196, 196, 255 - help.glow, false);
graphics.bprint(268,222, "("+help.String(ed.levx+1)+","+help.String(ed.levy+1)+")",196, 196, 255 - help.glow, false);
@@ -1505,12 +1516,12 @@ void editorrender(void)
}
fillboxabs(0, 117,menuwidth+17,140,graphics.getRGB(64,64,64));
FillRect(graphics.backBuffer, 0,118,menuwidth+16,140, graphics.getRGB(0,0,0));
graphics.fill_rect(0,118,menuwidth+16,140, graphics.getRGB(0,0,0));
for (size_t i = 0; i < SDL_arraysize(shiftmenuoptions); i++)
graphics.Print(4, 120+i*10, shiftmenuoptions[i], 164,164,164,false);
fillboxabs(220, 207,100,60,graphics.getRGB(64,64,64));
FillRect(graphics.backBuffer, 221,208,160,60, graphics.getRGB(0,0,0));
graphics.fill_rect(221,208,160,60, graphics.getRGB(0,0,0));
graphics.Print(224, 210, loc::gettext("S: Save Map"),164,164,164,false);
graphics.Print(224, 220, loc::gettext("L: Load Map"),164,164,164,false);
}
@@ -1584,8 +1595,8 @@ void editorrender(void)
short banner_y = 120 - textheight/2 - 5;
float alpha = graphics.lerp(ed.oldnotedelay, ed.notedelay);
FillRect(graphics.backBuffer, 0, banner_y, 320, 10+textheight, graphics.getRGB(92,92,92));
FillRect(graphics.backBuffer, 0, banner_y+1, 320, 8+textheight, graphics.getRGB(0,0,0));
graphics.fill_rect(0, banner_y, 320, 10+textheight, graphics.getRGB(92,92,92));
graphics.fill_rect(0, banner_y+1, 320, 8+textheight, graphics.getRGB(0,0,0));
graphics.PrintWrap(0,banner_y+5, wrapped, 196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), true);
}
@@ -1857,14 +1868,13 @@ static void editormenuactionpress(void)
break;
case 4:
//Load level
ed.settingsmod=false;
graphics.backgrounddrawn=false;
ed.settingsmod = false;
map.nexttowercolour();
ed.keydelay = 6;
ed.getlin(TEXT_LOAD, loc::gettext("Enter map filename to load:"), &(ed.filename));
game.mapheld=true;
graphics.backgrounddrawn=false;
game.mapheld = true;
graphics.backgrounddrawn = false;
break;
case 5:
//Save level
@@ -1873,8 +1883,8 @@ static void editormenuactionpress(void)
ed.keydelay = 6;
ed.getlin(TEXT_SAVE, loc::gettext("Enter map filename to save as:"), &(ed.filename));
game.mapheld=true;
graphics.backgrounddrawn=false;
game.mapheld = true;
graphics.backgrounddrawn = false;
break;
case 6:
/* Game options */
@@ -1938,14 +1948,15 @@ static void editormenuactionpress(void)
ed.keydelay = 6;
ed.getlin(TEXT_SAVE, loc::gettext("Enter map filename to save as:"), &(ed.filename));
game.mapheld=true;
graphics.backgrounddrawn=false;
game.mapheld = true;
graphics.backgrounddrawn = false;
break;
case 1:
//Quit without saving
music.playef(11);
music.fadeout();
graphics.fademode = FADE_START_FADEOUT;
graphics.backgrounddrawn = false;
break;
case 2:
//Go back to editor
@@ -2076,7 +2087,6 @@ void editorinput(void)
{
ed.settingsmod = true;
}
graphics.backgrounddrawn=false;
if (ed.settingsmod)
{
@@ -2540,15 +2550,26 @@ void editorinput(void)
else if (key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL])
{
// Ctrl modifiers
int numtiles;
int texturewidth;
int textureheight;
if (cl.getroomprop(ed.levx, ed.levy)->tileset == 0)
{
numtiles = (((int) graphics.tiles.size()) / 40) * 40;
if (graphics.query_texture(graphics.grphx.im_tiles, NULL, NULL, &texturewidth, &textureheight) != 0)
{
return;
}
}
else
{
numtiles = (((int) graphics.tiles2.size()) / 40) * 40;
if (graphics.query_texture(graphics.grphx.im_tiles2, NULL, NULL, &texturewidth, &textureheight) != 0)
{
return;
}
}
const int numtiles = (int) (texturewidth / 8) * (textureheight / 8);
ed.dmtileeditor=10;
if(left_pressed)
{
@@ -2583,13 +2604,11 @@ void editorinput(void)
if (key.keymap[SDLK_F1])
{
ed.switch_tileset(true);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
if (key.keymap[SDLK_F2])
{
ed.switch_tilecol(true);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
if (key.keymap[SDLK_F3])
@@ -2600,7 +2619,6 @@ void editorinput(void)
if (key.keymap[SDLK_w])
{
ed.switch_warpdir(true);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
@@ -2659,13 +2677,11 @@ void editorinput(void)
if(key.keymap[SDLK_F1])
{
ed.switch_tileset(false);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
if(key.keymap[SDLK_F2])
{
ed.switch_tilecol(false);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
if(key.keymap[SDLK_F3])
@@ -2703,11 +2719,11 @@ void editorinput(void)
cl.setroomdirectmode(ed.levx, ed.levy, 1);
ed.note=loc::gettext("Direct Mode Enabled");
}
graphics.backgrounddrawn=false;
graphics.backgrounddrawn = false;
ed.notedelay=45;
ed.updatetiles=true;
ed.keydelay=6;
ed.notedelay = 45;
ed.updatetiles = true;
ed.keydelay = 6;
}
if(key.keymap[SDLK_1]) ed.drawmode=0;
if(key.keymap[SDLK_2]) ed.drawmode=1;
@@ -2730,7 +2746,6 @@ void editorinput(void)
if(key.keymap[SDLK_w])
{
ed.switch_warpdir(false);
graphics.backgrounddrawn = false;
ed.keydelay = 6;
}
if(key.keymap[SDLK_e])
@@ -2848,7 +2863,6 @@ void editorinput(void)
}
music.haltdasmusik();
graphics.backgrounddrawn=false;
ed.returneditoralpha = 1000; // Let's start it higher than 255 since it gets clamped
ed.oldreturneditoralpha = 1000;
script.startgamemode(Start_EDITORPLAYTESTING);
@@ -2891,45 +2905,45 @@ void editorinput(void)
if(up_pressed)
{
ed.keydelay=6;
graphics.backgrounddrawn=false;
ed.keydelay = 6;
ed.levy--;
ed.updatetiles=true;
ed.changeroom=true;
ed.updatetiles = true;
ed.changeroom = true;
graphics.backgrounddrawn = false;
}
else if(down_pressed)
{
ed.keydelay=6;
graphics.backgrounddrawn=false;
ed.keydelay = 6;
ed.levy++;
ed.updatetiles=true;
ed.changeroom=true;
ed.updatetiles = true;
ed.changeroom = true;
graphics.backgrounddrawn = false;
}
else if(left_pressed)
{
ed.keydelay=6;
graphics.backgrounddrawn=false;
ed.keydelay = 6;
ed.levx--;
ed.updatetiles=true;
ed.changeroom=true;
ed.updatetiles = true;
ed.changeroom = true;
graphics.backgrounddrawn = false;
}
else if(right_pressed)
{
ed.keydelay=6;
graphics.backgrounddrawn=false;
ed.keydelay = 6;
ed.levx++;
ed.updatetiles=true;
ed.changeroom=true;
ed.updatetiles = true;
ed.changeroom = true;
graphics.backgrounddrawn = false;
}
if(ed.levx<0) ed.levx+=cl.mapwidth;
if(ed.levx>= cl.mapwidth) ed.levx-=cl.mapwidth;
if(ed.levy<0) ed.levy+=cl.mapheight;
if(ed.levy>=cl.mapheight) ed.levy-=cl.mapheight;
if(key.keymap[SDLK_SPACE])
if (ed.levx < 0) ed.levx += cl.mapwidth;
if (ed.levx >= cl.mapwidth) ed.levx -= cl.mapwidth;
if (ed.levy < 0) ed.levy += cl.mapheight;
if (ed.levy >= cl.mapheight) ed.levy -= cl.mapheight;
if (key.keymap[SDLK_SPACE])
{
ed.spacemod = !ed.spacemod;
ed.keydelay=6;
ed.keydelay = 6;
}
}
@@ -4248,6 +4262,8 @@ void editorclass::switch_tileset(const bool reversed)
note = buffer;
notedelay = 45;
updatetiles = true;
graphics.backgrounddrawn = false;
}
void editorclass::switch_tilecol(const bool reversed)
@@ -4270,6 +4286,8 @@ void editorclass::switch_tilecol(const bool reversed)
notedelay = 45;
note = loc::gettext("Tileset Colour Changed");
updatetiles = true;
graphics.backgrounddrawn = false;
}
void editorclass::clamp_tilecol(const int rx, const int ry, const bool wrap)
@@ -4381,6 +4399,8 @@ void editorclass::switch_warpdir(const bool reversed)
}
notedelay = 45;
graphics.backgrounddrawn = false;
}
#endif /* NO_CUSTOM_LEVELS and NO_EDITOR */