mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix gravity/warp lines being modified during draw
While warp lines were being drawn, they also got resized to automatically fit between collision. In renderfixed, gravity lines are resized the same way. Doing logic while drawing is very poor practice, so resizing of these has been moved into logic, and merged together. Aside from some more cleanup, this commit also removes the very poorly done right click emulation, when you hold CTRL and click. It never worked well in the past, and even requires a right click to use, so there's not really any point to keeping it around.
This commit is contained in:
parent
84c6d44c52
commit
7b5ef40926
2 changed files with 128 additions and 153 deletions
|
@ -977,6 +977,66 @@ static void draw_edgeguides(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void update_entities(void)
|
||||
{
|
||||
extern editorclass ed;
|
||||
|
||||
for (size_t i = 0; i < customentities.size(); ++i)
|
||||
{
|
||||
CustomEntity* entity = &customentities[i];
|
||||
|
||||
if (entity->x / 40 != ed.levx || entity->y / 30 != ed.levy)
|
||||
{
|
||||
// It's not in this room, so just continue
|
||||
continue;
|
||||
}
|
||||
|
||||
bool grav_line = (entity->t == 11);
|
||||
bool warp_line = (entity->t == 50);
|
||||
|
||||
if ((grav_line || warp_line) && entity->p4 != 1)
|
||||
{
|
||||
// If it's a grav line or a warp line, and it's not locked
|
||||
if ((grav_line && entity->p1 == 0) || (warp_line && entity->p1 >= 2))
|
||||
{
|
||||
/* Horizontal */
|
||||
int tx = entity->x % 40;
|
||||
int tx2 = tx;
|
||||
int ty = entity->y % 30;
|
||||
while (!ed.spikefree(tx, ty))
|
||||
{
|
||||
--tx;
|
||||
}
|
||||
while (!ed.spikefree(tx2, ty))
|
||||
{
|
||||
++tx2;
|
||||
}
|
||||
++tx;
|
||||
entity->p2 = tx;
|
||||
entity->p3 = (tx2 - tx) * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Vertical */
|
||||
int tx = entity->x % 40;
|
||||
int ty = entity->y % 30;
|
||||
int ty2 = ty;
|
||||
while (!ed.spikefree(tx, ty))
|
||||
{
|
||||
--ty;
|
||||
}
|
||||
while (!ed.spikefree(tx, ty2))
|
||||
{
|
||||
++ty2;
|
||||
}
|
||||
++ty;
|
||||
entity->p2 = ty;
|
||||
entity->p3 = (ty2 - ty) * 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_entities(void)
|
||||
{
|
||||
extern editorclass ed;
|
||||
|
@ -1200,50 +1260,17 @@ static void draw_entities(void)
|
|||
case 50: // Warp Lines
|
||||
if (entity->p1 >= 2) // Horizontal
|
||||
{
|
||||
int left = x / 8;
|
||||
int right = left;
|
||||
int tile_y = y / 8;
|
||||
|
||||
if (entity->p4 != 1)
|
||||
{
|
||||
// Unlocked
|
||||
while (ed.free(left, tile_y) == 0) left--;
|
||||
while (ed.free(right, tile_y) == 0) right++;
|
||||
left++;
|
||||
entity->p2 = left;
|
||||
entity->p3 = (right - left) * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Locked
|
||||
left = entity->p2;
|
||||
right = left + entity->p3 / 8;
|
||||
}
|
||||
int left = entity->p2;
|
||||
int right = left + entity->p3 / 8;
|
||||
|
||||
graphics.draw_rect((left * 8), y + 1, (right - left) * 8, 6, graphics.getRGB(194, 255, 255));
|
||||
graphics.draw_rect(x, y, 8, 8, graphics.getRGB(164, 255, 255));
|
||||
}
|
||||
else // Vertical
|
||||
{
|
||||
int tile_x = x / 8;
|
||||
int top = y / 8;
|
||||
int bottom = top;
|
||||
|
||||
if (entity->p4 != 1)
|
||||
{
|
||||
// Unlocked
|
||||
while (ed.free(tile_x, top) == 0) top--;
|
||||
while (ed.free(tile_x, bottom) == 0) bottom++;
|
||||
top++;
|
||||
entity->p2 = top;
|
||||
entity->p3 = (bottom - top) * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Locked
|
||||
top = entity->p2;
|
||||
bottom = top + entity->p3 / 8;
|
||||
}
|
||||
int top = entity->p2;
|
||||
int bottom = top + entity->p3 / 8;
|
||||
|
||||
graphics.draw_rect(x + 1, (top * 8), 6, (bottom - top) * 8, graphics.getRGB(194, 255, 255));
|
||||
graphics.draw_rect(x, y, 8, 8, graphics.getRGB(164, 255, 255));
|
||||
|
@ -1418,6 +1445,8 @@ static void draw_cursor(void)
|
|||
|
||||
static void draw_tile_toolbox(int tileset)
|
||||
{
|
||||
extern editorclass ed;
|
||||
|
||||
// Tile toolbox for direct mode
|
||||
int t2 = 0;
|
||||
if (ed.dmtileeditor > 0)
|
||||
|
@ -1898,12 +1927,13 @@ void editorrenderfixed(void)
|
|||
ghost.realcol = graphics.getcol(ghost.col);
|
||||
}
|
||||
|
||||
if (ed.currentghosts + 1 < (int) ed.ghosts.size()) {
|
||||
ed.currentghosts++;
|
||||
if (ed.zmod) ed.currentghosts++;
|
||||
} else {
|
||||
ed.currentghosts = (int) ed.ghosts.size() - 1;
|
||||
if (ed.zmod)
|
||||
{
|
||||
ed.currentghosts++;
|
||||
}
|
||||
|
||||
ed.currentghosts = SDL_min(ed.currentghosts, ed.ghosts.size());
|
||||
}
|
||||
|
||||
if (!ed.settingsmod)
|
||||
|
@ -1931,57 +1961,6 @@ void editorrenderfixed(void)
|
|||
graphics.updatetowerbackground(graphics.titlebg);
|
||||
}
|
||||
|
||||
/* Correct gravity lines */
|
||||
for (size_t i = 0; i < customentities.size(); ++i)
|
||||
{
|
||||
if (customentities[i].x / 40 != ed.levx
|
||||
|| customentities[i].y / 30 != ed.levy
|
||||
|| customentities[i].t != 11
|
||||
/* Is the gravity line locked? */
|
||||
|| customentities[i].p4 == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (customentities[i].p1 == 0)
|
||||
{
|
||||
/* Horizontal */
|
||||
int tx = customentities[i].x % 40;
|
||||
int tx2 = tx;
|
||||
int ty = customentities[i].y % 30;
|
||||
while (!ed.spikefree(tx, ty))
|
||||
{
|
||||
--tx;
|
||||
}
|
||||
while (!ed.spikefree(tx2, ty))
|
||||
{
|
||||
++tx2;
|
||||
}
|
||||
++tx;
|
||||
customentities[i].p2 = tx;
|
||||
customentities[i].p3 = (tx2 - tx) * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Vertical */
|
||||
int tx = customentities[i].x % 40;
|
||||
int ty = customentities[i].y % 30;
|
||||
int ty2 = ty;
|
||||
/* Unlocked */
|
||||
while (!ed.spikefree(tx, ty))
|
||||
{
|
||||
--ty;
|
||||
}
|
||||
while (!ed.spikefree(tx, ty2))
|
||||
{
|
||||
++ty2;
|
||||
}
|
||||
++ty;
|
||||
customentities[i].p2 = ty;
|
||||
customentities[i].p3 = (ty2 - ty) * 8;
|
||||
}
|
||||
}
|
||||
|
||||
if (cl.getroomprop(ed.levx, ed.levy)->directmode == 1)
|
||||
{
|
||||
if (ed.dmtileeditor > 0)
|
||||
|
@ -2042,10 +2021,9 @@ void editorlogic(void)
|
|||
}
|
||||
|
||||
ed.oldnotedelay = ed.notedelay;
|
||||
if(ed.notedelay>0)
|
||||
{
|
||||
ed.notedelay--;
|
||||
}
|
||||
ed.notedelay = SDL_max(ed.notedelay - 1, 0);
|
||||
|
||||
update_entities();
|
||||
|
||||
if (graphics.fademode == FADE_FULLY_BLACK)
|
||||
{
|
||||
|
@ -2214,7 +2192,9 @@ static void editormenuactionpress(void)
|
|||
cl.levmusic--;
|
||||
break;
|
||||
}
|
||||
cl.levmusic = (cl.levmusic % 16 + 16) % 16;
|
||||
|
||||
cl.levmusic = POS_MOD(cl.levmusic, 16);
|
||||
|
||||
if (cl.levmusic > 0)
|
||||
{
|
||||
music.play(cl.levmusic);
|
||||
|
@ -2223,6 +2203,7 @@ static void editormenuactionpress(void)
|
|||
{
|
||||
music.haltdasmusik();
|
||||
}
|
||||
|
||||
music.playef(11);
|
||||
break;
|
||||
case 2:
|
||||
|
@ -2445,11 +2426,6 @@ void editorinput(void)
|
|||
ed.settingskey=false;
|
||||
}
|
||||
|
||||
if(key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL])
|
||||
{
|
||||
if(key.leftbutton) key.rightbutton=true;
|
||||
}
|
||||
|
||||
if(ed.scripteditmod)
|
||||
{
|
||||
if(ed.scripthelppage==0)
|
||||
|
@ -2989,10 +2965,9 @@ void editorinput(void)
|
|||
cl.mapwidth++;
|
||||
}
|
||||
|
||||
if(cl.mapwidth<1) cl.mapwidth=1;
|
||||
if(cl.mapheight<1) cl.mapheight=1;
|
||||
if(cl.mapwidth>=cl.maxwidth) cl.mapwidth=cl.maxwidth;
|
||||
if(cl.mapheight>=cl.maxheight) cl.mapheight=cl.maxheight;
|
||||
cl.mapwidth = SDL_clamp(cl.mapwidth, 1, cl.maxwidth);
|
||||
cl.mapheight = SDL_clamp(cl.mapheight, 1, cl.maxheight);
|
||||
|
||||
char buffer[3*SCREEN_WIDTH_CHARS + 1];
|
||||
vformat_buf(
|
||||
buffer, sizeof(buffer),
|
||||
|
@ -3000,6 +2975,7 @@ void editorinput(void)
|
|||
"width:int, height:int",
|
||||
cl.mapwidth, cl.mapheight
|
||||
);
|
||||
|
||||
ed.note = buffer;
|
||||
ed.notedelay = 45;
|
||||
}
|
||||
|
@ -3259,10 +3235,9 @@ void editorinput(void)
|
|||
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;
|
||||
ed.levx = POS_MOD(ed.levx, cl.mapwidth);
|
||||
ed.levy = POS_MOD(ed.levy, cl.mapheight);
|
||||
|
||||
if (key.keymap[SDLK_SPACE])
|
||||
{
|
||||
ed.spacemod = !ed.spacemod;
|
||||
|
|
|
@ -185,9 +185,9 @@ static const inline struct ImplFunc* get_gamestate_funcs(
|
|||
FUNC_LIST_BEGIN(EDITORMODE)
|
||||
{Func_fixed, flipmodeoff},
|
||||
{Func_input, editorinput},
|
||||
{Func_fixed, editorlogic},
|
||||
{Func_fixed, editorrenderfixed},
|
||||
{Func_delta, editorrender},
|
||||
{Func_fixed, editorlogic},
|
||||
FUNC_LIST_END
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue