1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00
Commit Graph

823 Commits

Author SHA1 Message Date
Misa
3f7ed4b94a Don't selectively undraw tiles in towers if backgrounds are off
The game for some reason had this thing where it would not draw the
diagonal background tiles if you had animated backgrounds turned off.
Which is weird, because spikes with that background are still drawn as
spikes with that background. And also, it doesn't do this for any of the
tower hallway rooms, which is inconsistent.

Better to simplify the logic in Render.cpp anyways by removing
graphics.drawtower_nobackground() and making it really clear what
exactly we'll do if backgrounds are turned off. ("Aren't we already not
drawing the background? What's this _nobackground() function for?")
2020-06-30 14:34:42 -04:00
Misa
2c18d28880 Add Flip Mode to game options if in M&P or in-game menu and unlocked
Flip Mode will now be in the game options menu if either:
 (1) You're playing the M&P version.
 (2) You have it unlocked and you came here from the in-game pause
     screen.

This is because if you're playing M&P, you'd have to close the game,
edit unlock.vvv, and re-launch the game to toggle Flip Mode, since
there's no other way to do so. And if you're playing the full version,
you'd have to save and exit your session in order to toggle Flip Mode.
2020-06-30 09:21:25 -04:00
Misa
7ce4f1173d Add "resize to nearest" graphics option
If you want your game window to simply be exactly 320x240, or 640x480,
or 960x720 etc. then it's really annoying that there's no easy way to do
this (to clarify, this is different from integer mode, which controls
the size of the game INSIDE the window). The easiest way would be having
to close the game, go into unlock.vvv, and edit the window size
manually. VCE has a 1x/2x/3x/4x graphics option to solve this, although
it does not account for actual monitor size (those 1x/2x/3x/4x modes are
all you get, whether or not you have a monitor too small for some of
them or too big for any of them to be what you want).

I discussed this with flibit, and he said that VCE's approach (if it
accounted for monitor size) wouldn't work on high-retina displays or
high DPIs, because getting the actual multiplier to account for those
monitors is kind of a pain. So the next best thing would be to add an
option that resizes to the nearest perfect multiple of 320x240. That way
you could simply resize the window and let the game correct any
imperfect dimensions automatically.
2020-06-30 09:21:00 -04:00
Misa
e331abcd7e Fix Alt+Enter Glitch if not in glitchrunner mode
The Alt+Enter Glitch is a funny glitch where if you press any toggle
fullscreen keybind during a cutscene, Viridian will stop moving (if
they're being moved by a walk()) and ACTION will start being held down
for them. Meaning in most cases you can interrupt a walk and flip at the
same time.

This can obviously break cutscenes if a casual just wants to toggle
fullscreen, so I'm fixing it. But it will be unfixed in glitchrunner
mode in case you want to glitch out custom levels (I know I do).

More information on the Alt+Enter Glitch is available here:
https://gitgud.io/infoteddy/vvvvvv-knowledge/blob/master/bugs/bugs.md#the-altenter-glitch
(The page is a bit outdated, some bugs have been fixed in 2.3 already.)
2020-06-30 00:20:03 -04:00
Misa
35c540449e Add being able to disable unfocus pause
It's sometimes unwanted by people, and it's unwanted enough that there
exist instructions to hexedit the binary to remove it (
https://distractionware.com/forum/index.php?topic=3247.0 ).

Fun fact, the unfocus pause didn't exist in 2.0.
2020-06-29 22:59:16 -04:00
Misa
3f077ee56a Don't gray out invincibility/slowdown in intermission
When I re-enabled them for intermissions earlier, I forgot to un-gray
them out.
2020-06-29 22:59:16 -04:00
Ethan Lee
e85d5a8714
Merge pull request #326 from InfoTeddy/general-refactors
Refactor how custom level stats are stored, read, and written
2020-06-29 22:31:03 -04:00
Misa
b9bf2cc1c5 Unindent loadcustomlevelstats from previous commit
Done in a separate commit to reduce diff noise.
2020-06-29 18:47:45 -07:00
Misa
be9c405ddd Use returns and don't have rest of loadcustomlevelstats in an 'else'
This will cut down on unnecessary indentation levels.
2020-06-29 18:44:54 -07:00
Misa
9a008dc77c Refactor how custom level stats are stored, read, and written
There were a few problems with the old way of doing things:

(1) Level stats were an ad-hoc object. Basically, it's an object whose
attributes are stored in separate arrays, instead of being an actual
object with its attributes stored in one array.
(2) Level filenames with pipes in them could cause trouble. This is
because the filename attribute array was stored in the XML by being
separated by pipes.
(3) There was an arbitrary limit of only having 200 level stats, for
whatever reason.

To remedy this issue, I've made a new struct named CustomLevelStat that
is a proper object. The separate attribute arrays have been replaced
with a proper vector, which also doesn't have a size limit.

For compatibility with versions 2.2 and below, I've kept being able to
read the old format. This only happens if the new format doesn't exist.
However, I also WRITE the old format as well, in case you want to go
back to version 2.2 or below for whatever reason. It's slightly
wasteful to have both, but that way there's no risk of breaking
compatibility.
2020-06-29 18:39:22 -07:00
Ethan Lee
38a42b484d
Merge pull request #322 from Dav999-v/auto-center-menu
Make menus automatically centered and narrowed
2020-06-29 19:10:39 -04:00
Misa
f64e9237c4 Display centiseconds on time trial result and Game Complete
Centiseconds won't be saved to any save file or anything. This is just
to make speedrunning a bit more competitive, being able to know the
precise time of a time trial or full game run.

The time trial par time on the result screen always has ".99" after it.
This is basically due to the game comparing the number of seconds to the
par number of seconds using less-than-or-equal-to instead of simply
less-than.
2020-06-29 19:09:11 -04:00
Misa
ad27a5c154 Reset width of player in mapclass::resetplayer()
The width of the player can be changed by using the Gravitron OoB
glitch. It will not be reset if the game is in glitchrunner mode.
2020-06-29 19:08:22 -04:00
Misa
66d19d4cf4 Disable two-frame delay fix in glitchrunner mode
The two-frame delay can be utilized to trigger a glitch that spawns
entities in the wrong room.
2020-06-29 19:08:22 -04:00
Misa
d4592cd6b3 Add special case to color gray Warp Zone entities gray
The only reason why gray Warp Zone entities were green originally was
because there is a giant concatenated list of tileset+tilecol
combinations, and by using tileset 3 tilecol 6 you're using the entry
of tileset 4 tilecol 0, which is the green Ship tileset.

So without interfering with the green Ship tileset's entry, I've decided
that the best thing to do is to just add special cases. The enemy color
was easy enough to fix. The platform color was also easy to fix.
However, there exist no existing textures for gray conveyors, so at that
point I decided to just tint the existing green one gray, and then I did
the same for platforms.
2020-06-29 19:07:45 -04:00
Misa
584f73f0a4 Add BlitSurfaceTinted()
This will be used to change the color of existing textures while
preserving their lightness values.
2020-06-29 19:07:45 -04:00
Dav999-v
cc538a0965 Merge remote-tracking branch 'upstream/master' into auto-center-menu
Fix one conflict.
2020-06-29 23:40:10 +02:00
Dav999-v
803d0f45de Document menu width limit better
The reason for the menu width to be limited to 272 pixels was rather
undocumented in the code, now the comment explains more about it.
2020-06-29 23:18:33 +02:00
Misa
ebd381c228 Fix the two-frame-delay when entering a room with an "init" script
This patch is very kludge-y, but at least it fixes a semi-noticeable
visual issue in custom levels that use internal scripts to spawn
entities when loading a room.

Basically, the problem here is that when the game checks for script
boxes and sets newscript, newscript has already been processed for that
frame, and when the game does load a script, script.run() has already
been processed for that frame.

That issue can be fixed, but it turns out that due to my over-30-FPS
game loop changes, there's now ANOTHER visible frame of delay between
room load and entity creation, because the render function gets called
in between the script being loaded at the end of gamelogic() and the
script actually getting run.

So... I have to temporary move script.run() to the end of gamelogic()
(in map.twoframedelayfix()), and make sure it doesn't get run next
frame, because double-evaluations are bad. To do that, I have to
introduce the kludge variable script.dontrunnextframe, which does
exactly as it says.

And with all that work, the two-frame (now three-frame) delay is fixed.
2020-06-29 15:42:51 -04:00
Misa
baf879d9fd Remove unused tmap vars from mapclass
These used to be relevant when the main game tilemaps were stored in
strings, but now they no longer are.
2020-06-29 15:42:51 -04:00
Misa
e1a114d1a5 Un-fix hitbox persistence in map.resetplayer()
It's annoying for casuals to have to close the game if they manage to
get themselves to turn into VVVVVV-Man, but it's amusing enough to
glitchrunners that they mess about with VVVVVV-Man in the main game,
clipping through walls everywhere (well, they call it Big Viridian, but
still).
2020-06-29 15:12:35 -04:00
Misa
387ee4dc79 Un-hardreset certain variables for glitchrunner mode
Ironically enough, resetting more variables in script.hardreset() makes
the glitchy fadeout system even more glitchy. Resetting map.towermode,
for example, makes it so that if you're in towers when you quit to the
menu, script.hardreset() makes it so that the game thinks you're no
longer inbounds (because it no longer thinks you're in a tower and thus
considers coordinates in the space of 40x30 tiles to be inbounds instead
of 40x700 or 40x100 tiles to be inbounds), calls map.gotoroom(), which
resets the gamestate to 0. So if we're using the old system, it's better
to reset only as much as needed.

And furthermore, we shouldn't be relying on script.hardreset() to
initialize variables for us. That should be done at the class
constructor level. So I've gone ahead and initialized the variables in
class constructors, too.
2020-06-29 15:12:35 -04:00
Misa
cb8540d7bd Restore janky gamestate-based quit-to-title system in glitchrunnermode
This was fixed in 2.3 because one of the side effects of this janky
system was being able to accidentally immediately quit to the title if
the screen was black during a cutscene, which is something very likely
to happen to casual players.

Anyway, credits warp uses this gamestate-based system because it
utilizes quitting to the title screen doing gamestate 80. From there,
you increment the gamestate to gamestate 94 to use the Space Station 2
expo script.
2020-06-29 15:12:35 -04:00
Misa
9bab6bd0cb Don't hardreset() game.advancetext in glitchrunner mode
This is the second part of what is necessary for credits warp to work.

The speedrunners call this "text storage". You need to get the
advancetext prompt up without a text box in order to be able to
increment the gamestate without bound. In 2.0, script.hardreset() reset
the text boxes, but not the prompt.
2020-06-29 15:12:35 -04:00
Misa
5848330e66 Re-enable unbounded gamestate increment in glitchrunner mode
This is the first part of what is necessary for credits warp to work.

If the "- Press ACTION to advance text -" prompt is up, and you manage
to keep it up, then you can indefinitely increment the gamestate by
pressing ACTION.

This is first used in credits warp to teleport to the start of Space
Station 2 (by utilizing the Eurogame expo script, triggered by a
gamestate), and then again later by using a teleporter that has a high
gamestate number to increment to the [C[C[C[C[Captain!] cutscene.
2020-06-29 15:12:35 -04:00
Misa
779083b417 Add glitchrunner mode, in game options
Glitchrunner mode is intended to re-enable glitches that existed in
older versions of VVVVVV. These glitches were removed because they could
legitimately affect a casual player's experience. Glitches like various
R-pressing screwery, Space Station 1 skip, telejumping, Gravitron
out-of-bounds, etc. will not be patched.
2020-06-29 15:12:35 -04:00
Dav999-v
46d5fc6576 Correct minimum horizontal spacing check
It should've checked the final spacing and not the intermediate maximum
value. I had changed some things around, and now the minimum spacing
was 5 instead of 0 by mistake.
2020-06-29 02:58:38 +02:00
Dav999-v
0023c821db Make menus automatically centered and narrowed
All menus had a hardcoded X position (offset to an arbitrary starting
point of 110) and a hardcoded horizontal spacing for the "staircasing"
(mostly 30 pixels, but for some specific menus hardcoded to 15, 20 or
something else). Not all menus were centered, and seem to have been
manually made narrower (with lower horizontal spacing) whenever text
ran offscreen during development.

This system may already be hard to work with in an English-only menu
system, since you may need to adjust horizontal spacing or positioning
when adding an option. The main reason I made this change is that it's
even less optimal when menu options have to be translated, since
maximum string lengths are hard to determine, and it's easy to have
menu options running offscreen, especially when not all menus are
checked for all languages and when options could be added in the middle
of a menu after translations of that menu are already checked.

Now, menus are automatically centered based on their options, and they
are automatically made narrower if they won't fit with the default
horizontal spacing of 30 pixels (with some padding). The game.menuxoff
variable for the menu X position is now also offset to 0 instead of 110

The _default_ horizontal spacing can be changed on a per-menu basis,
and most menus (not all) which already had a narrower spacing set,
retain that as a maximum spacing, simply because they looked odd with
30 pixels of spacing (especially the main menu). They will be made even
narrower automatically if needed. In the most extreme case, the spacing
can go down to 0 and options will be displayed right below each other.
This isn't in the usual style of the game, but at least we did the best
we could to prevent options running offscreen.

The only exception to automatic menu centering and narrowing is the
list of player levels, because it's a special case and existing
behavior would be better than automatic centering there.
2020-06-29 02:09:52 +02:00
Misa
18b34d0066 Add logs if a Graphics func was stopped from indexing OoB
This doesn't happen too often, but it'll be useful to people making
custom levels so they know that it can happen, when it does.
2020-06-28 15:48:48 -04:00
Misa
c95c1ab250 Add bounds check to textbox functions that use m
It seems to be a bit bad to blindly use `m` without checking it. In
fact, this has caused a few segfaults already, actually.
2020-06-28 15:48:48 -04:00
Misa
a0f10d80e5 Refactor, de-duplicate, and clean up tilesheet processing
The tilesheets in question are font.png, tiles.png, tiles2.png,
tiles3.png, entcolours.png, teleporter.png, sprites.png, and
flipsprites.png.

This patch removes the hardcoded dimensions when scanning the
tilesheets, because it's simpler that way. It also de-duplicates it so
it isn't a bunch of copy-paste, by using macros. (I had to use macros
because it was the easiest way to optionally pass in some extra code in
the innermost for-loop.)

Also, if the dimensions of a scanned tilesheet aren't exactly multiples
of the dimensions of the tile unit for that given tilesheet (e.g. if the
dimensions of a scanned tiles.png are not exact multiples of 8), then an
SDL_SimpleMessageBox will show up with the error message, a puts() of
the error message will be called, and the program will exit.
2020-06-28 08:44:35 -04:00
Misa
7627a37216 Change a '||' to a '=='
Whoops.
2020-06-28 08:41:19 -04:00
Misa
9363cf4c40 Fix Game::anything_unlocked() always evaluating to true
Whoops.
2020-06-28 08:41:00 -04:00
Misa
22738cdb97 Remove unused/useless vars music.custompd/musicfade(in)/volume
I have no idea why these are here, but it'll simplify readability and
reduce the chance of confusion if I remove them.
2020-06-27 17:23:07 -04:00
Misa
facb079b35 Fix resumemusic/musicfadein not working
It seems like they were unfinished. This commit makes them properly
work.

When a track is stopped with stopmusic() or musicfadeout(),
resumemusic() will resume from where the track stopped. musicfadein()
does the same but does it with a gradual fade instead of suddenly
playing it at full volume.

I changed several interfaces around for this. First, setting currentsong
to -1 when music is stopped is handled in the hook callback that gets
called by SDL_mixer whenever the music stops. Otherwise, it'd be
problematic if currentsong was set to -1 when the song starts fading out
instead of when the song actually ends.

Also, music.play() has a few optional arguments now, to reduce the
copying-and-pasting of music code.

Lastly, we have to roll our own tracker of music length by using
SDL_GetPerformanceCounter(), because there's no way to get the music
position if a song fades out. (We could implicitly keep the music
position if we abruptly stopped the song using Mix_PauseMusic(), and
resume it using Mix_ResumeMusic(), but ignoring the fact that those two
functions are also used on the unfocus-pause (which, as it turns out, is
basically a non-issue because the unfocus-pause can use some other
functions), there's no equivalent for fading out, i.e. there's no
"fade out and pause when it fully fades out" function in SDL_mixer.) And
then we have to account for the unfocus-pause in our manual tracker.

Other than that, these commands are now fully functional.
2020-06-27 17:23:07 -04:00
Misa
2662cd4d06 Refactor KeyPoll::Poll() to use case-switch statements
Reduces the amount of copy-pasted if-expressions.
2020-06-27 17:23:07 -04:00
Misa
a87ebd2945 Remove unnecessary middleman game.infocus
It does the same thing as key.isActive, so no need to make it a separate
variable.
2020-06-27 17:23:07 -04:00
Misa
5052391f60 Make warpdir only re-draw BG if targeted room is current room
It's unnecessary to re-draw the background if you're modifying the warp
direction of some other room.
2020-06-26 10:22:05 -04:00
Misa
1cbecdda86 Use returntomenu(timetrials) instead of returnmenu in timetrialcomplete3
This fixes a corner case where using gamestate 82 from the editor would
put you in a softlock because it would return to the editor settings
menu, which only functions in EDITORMODE and results in a softlock in
TITLEMODE.
2020-06-25 20:27:51 -04:00
Ethan Lee
9804fbc383 Fix gamecontrollerdb.txt path 2020-06-23 19:08:08 -04:00
Misa
94a67ca0aa Only check Secret Lab/Time Trial/NDM for slowdown if ingame_titlemode
This is already done for invincibility. It's kind of unnecessary, but
it's just to make sure if for some reason in the future variables like
insecretlab/intimetrial/nodeathmode don't get reset when exiting to the
menu.
2020-06-23 15:23:57 -04:00
Misa
a3f171b018 Allow toggling invincibility/slowdown in intermission replays
inspecial() includes being in intermission replays, but it's not
necessary to disable invincibility/slowdown for them.
2020-06-23 15:23:57 -04:00
Misa
65f84b15f4 Fix deltaframe tower BG flicker when exiting menu in H/V warp room
To fix this annoying flicker (which, btw, took me WAY too long to do), I
had to introduce yet another kludge variable to signal that the
horizontal/vertical warp background should be re-initialized on the
pause screen.

I think I could technically keep the 'graphics.backgrounddrawn = false;'
in maplogic() and remove the 'graphics.backgrounddrawn = false;' in
Game::returntopausemenu(), but I'm keeping that other one around because
it doesn't hurt and just as a general precaution and safety measure.
2020-06-23 15:23:57 -04:00
Misa
16ebb807db Set backgrounddrawn to false when returning to pause menu
This makes it so the tower background doesn't persist and scroll upwards
if you exit the menu in a warp zone horizontal or vertical room.

Ugh, and while we're on the subject of separating the in-game tower
background and the menu tower background, could we PLEASE separate the
horizontal / vertical warp backgrounds from the tower backgrounds, too?!
2020-06-23 15:23:57 -04:00
Misa
441e7babd7 Fix Flip Mode persisting in in-game options menu
Now graphics.flipmode is turned off when going into the menu, and turned
back on if necessary when exiting.
2020-06-23 15:23:57 -04:00
Misa
c5a5589ce5 Allow pressing Esc to close Esc menu
Another thing that's annoyed me a lot is being unable to simply press
Esc to close the pause menu. You'd have to hover over the "return to
game" or "keep playing" option. This would be even more annoying with
more options on the menu, so allowing to press Esc is a nice
quality-of-life thing.
2020-06-23 15:23:57 -04:00
Misa
f6d73c62ec Allow pressing Esc to go back to pause menu from quit prompt
Allowing for more actions makes things feel smoother.
2020-06-23 15:23:57 -04:00
Misa
b63347b70c Prevent menu input if fading out
Otherwise you could keep re-pressing ACTION on the "yes" option and keep
stalling it until it finally faded out, or quickly go back past menu
options or something.
2020-06-23 15:23:57 -04:00
Misa
3c5ed04678 Make "no, keep playing" go back to pause menu
This is so the menus can stack on top of each other. Well, technically
they don't, but it's the same thing.
2020-06-23 15:23:57 -04:00
Misa
f6330c57fd Reset map.bypos when entering options menus in-game
Otherwise the menu background would have this rendering glitch where the
bypos of the in-game tower wouldn't divide easily and have a bunch of
jitters in an otherwise smooth but overall still somewhat smooth
background.
2020-06-23 15:23:57 -04:00