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

386 Commits

Author SHA1 Message Date
TerryCavanagh
8b73a38ed2 don't apply linegap to certain special textboxes
level complete, game complete and "You have rescued a crew member!"
2024-02-01 20:03:17 +01:00
TerryCavanagh
cc1528aacc add a one pixel gap between each line in textboxes (main game only) 2024-02-01 20:03:17 +01:00
mothbeanie
7ff2e818cd Revert text image fading
This reverts the following commits:

- 29f05c41b1
- f1bf1f683c
- a7b22919ae
- 2ed1aac67d

Recently, text images were changed to fade in with textboxes, where
before they previously appeared after the fade. This created a charming
effect where the images would appear to "load in" once the textbox
finishes fading in. This behavior really complements the retro
aesthetic the game is going for. Changing it to a fade is a needless
change in direction, as it was not a bug in the first place and looked
good already.

Additionally, custom levels have used text images (levelcomplete and
gamecomplete) in creative ways by replacing them with something else
to show as 'foreground' or as a cutscene image. Changing text images
to fade has unintended consequences for levels that have utilized
them in this fashion.
2024-01-10 17:43:03 -08:00
Misa
29f05c41b1 Fix warnings when calculating image color
This fixes warnings about narrowing and missing a component of the
struct.
2024-01-10 08:27:34 -08:00
AllyTally
f1bf1f683c Fix text images not fading
While a7b22919ae makes text sprites
modulate their RGB values, text images continued using alpha,
despite alpha blending not even being enabled, so the initial
commit didn't work right either.
2024-01-10 07:57:54 -08:00
Dav999
ff25e18945 Move author face to the right for RTL languages
This is quite a last-minute thing that was almost getting called off by
me discovering a critical segfault just now in testing this (whew) but
this shouldn't hurt.
2024-01-10 07:57:40 -08:00
Misa
a7b22919ae Modulate text sprite RGB instead of using alpha
Using actual alpha is prone to bugs with doubling alpha, etc. if there
are multiple sprites on top of each other.
2024-01-09 19:22:40 -08:00
Misa
2ed1aac67d Fade text box overlays with text box
Currently, it's a bit jarring that text box overlays (which are text box
images, e.g. Level Complete and Game Complete, and sprites, e.g. the
crewmates) will suddenly appear when their text box has fully faded in
and suddenly disappear once it starts fading out.

This makes it so that text box overlays will be faded in and out
smoothly along with the rest of the text box fading in and out.

Transparent text boxes are not affected, as they do not fade in and out
at all. Thus, text box overlays in transparent text boxes will still
suddenly appear and disappear as usual.
2024-01-09 18:38:40 -08:00
Misa
40f6f83328 Add border to indicate taking screenshot
Originally, I was thinking of adding a notification text that you took a
screenshot, but this is better because it is language-agnostic and it
doesn't contribute to potential UI clutter/clashing.

It flashes yellow if the screenshot successfully saved, and red if it
didn't.
2024-01-09 15:48:41 -08:00
Misa
93ec2c6cca Upscale screenshots 2x
The plan is to have Steam screenshots always be 2x, but in the VVVVVV
screenshots directory (for F6 keybind) save both 1x and 2x.

Again, just for now, the 2x screenshot is being saved to a temporary
location for testing and will get proper timestamps later.
2024-01-09 15:48:41 -08:00
Misa
f05827f268 Add support for internal screenshots
"But people already have screenshot tools", you might protest. The
rationale is simple: If you play with any video setting other than 1x
windowed (no stretching and no letterbox), then your screenshot will be
too big if you want the internal resolution of 320x240, and downscaling
will be an inconvenience.

The point is to make screenshots based off of internal resolution so
they are always pixel perfect and ideally never have to be altered once
taken.

I've added the keybind of F6 to do this.

Right now it saves to a temporary test location with the same filename;
future commits will save to properly-timestamped filenames.
2024-01-09 15:48:41 -08:00
Dav999
060fe6938d Add support for right-aligned roomtext
This is mostly so people making levels in an RTL language have a more
pleasant and logical experience. If roomtext is placed in a level set
to RTL, it will get p1=1, which makes that roomtext right-aligned.
Because, imagine for English you click to place roomtext, and the text
runs left of where you clicked, which wouldn't be logical.

Since it's an entity-bound property, switching RTL on and off either in
the editor or via a script does not affect existing entities.
2024-01-09 13:13:04 -08:00
Dav999
25bdf0866a Make left/right key input correct for RTL menus
Instead of just up/down, you can also control menus with left/right.
Which is illogical in Arabic... No big deal, I imagined this code
to become much worse than it did. (And action sets is probably gonna
refactor the whole thing anyway)
2024-01-08 19:17:44 -08:00
Dav999
2b22f7cda2 Add PR_RTL_XFLIP to some important places
Okay, the "Font:" thing needed some local code after all, because both
the interface font as well as the level font are used there. But it's
good enough - all the other places can just use the flag.

Notably, I also used this for the menus, since the existing ones are
kinda LTR-oriented, and it's something that we don't *really* have to
do, but I think it shows we care!
2024-01-08 19:17:44 -08:00
Dav999
3588168c4d Right-align textboxes in RTL languages
Most of this diff is just moving some existing code around, and
changing inline things to variables that could be changed more easily.
2024-01-08 19:17:44 -08:00
Misa
e318d6f176 Fix regression: Tower BG lerps in reverse direction
This is the same as commit 70357a65bf
("Fix regression: Warp BG lerps in reverse direction"), but for the
tower background.

This bug is most visible when moving the camera in a tower using
invincibility, or holding down ACTION during the credits scroll.
2023-12-29 14:11:08 -08:00
Misa
af35be5bb6 Name conditionals in text box loop
With the recent change to drawing overlays (images and sprites) from
PR #1058, it's starting to get a bit hairy. This names the conditionals
responsible for determining if the text box is transparent (checking
that all of its RGB is 0) and if overlays should be drawn or not (which
is now either when it's opaque or transparent).
2023-11-28 19:07:49 -08:00
Reese Rivers
44a889efeb Changed timing of textsprites in transparent textboxes
Textsprites and textimages no longer wait for the opacity
value in order to display within transparent textboxes.
Text sprites in normal opaque textboxes are not affected
by this change.
2023-11-28 19:07:49 -08:00
Misa
70357a65bf Fix regression: Warp BG lerps in reverse direction
This fixes a regression caused by PR #923 (the PR that moved rendering
to be GPU-based) where the interpolation of the horizontal and vertical
warp backgrounds (in over-30-FPS mode) was in the wrong direction, which
makes them look blurry.

This happens because the arguments to the `lerp` function were in the
wrong, reverse order.

On the VVVVVV Discord server, Ally raised the argument that they were in
the same order before she made the changes; therefore the previous code
was also incorrect and it wasn't her fault. However, this argument is
incorrect, because in that case, the reverse order _is_ the correct
order.

The reason that it's now the wrong order is because the output of `lerp`
is now being used as the argument to a source rectangle. Previously, the
output of `lerp` was being used as the offset argument to
`ScrollSurface`, which is analogous to being a destination rectangle.

Fixes #1038.
2023-11-27 13:29:06 -08:00
AllyTally
103b4d36a1 Add textimage for levelcomplete and gamecomplete
`levelcomplete` and `gamecomplete` were hardcoded using textbox colors
which were offset by 1. This PR fixes that, no longer requiring
slightly-off colors, and instead adding a new property to textboxes
which tell the game to display either level complete or game complete.
2023-11-19 15:07:25 -08:00
AllyTally
b5c9508dd4 Finish implementing sprites in textboxes
This commit adjusts the Y position for flip-mode, and makes the main
game use this new system.
2023-11-19 15:07:25 -08:00
AllyTally
76ea4488af Initial implementation of textbox sprites
This commit adds a system for displaying sprites in textboxes, meant to
replace the hardcoded system in the main game. This does not support
levelcomplete.png and gamecomplete.png yet, which will most likely just
be special cases.
2023-11-19 15:07:25 -08:00
Dav999
9045e26d3e 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-10-31 22:31:41 -07:00
Misa
ea1a014145 Fix memory leak with ApplyFilter
The intention of the recent refactor was to make it so that the
temporary surfaces would be allocated only once, when the mode is
enabled, and be freed upon exit.

To do this, Graphics.cpp owns the pointers, and passes them to
ApplyFilter to modify. Except ApplyFilter doesn't actually modify the
pointers, because it's only a single pointer, not a pointer-to-pointer.
So every frame of rendering it would actually be creating a new surface
and leaking memory.

To fix this, they need to be pointer-to-pointer variables that get
modified.

I also added error logs in case the surface creation failed.
2023-10-27 10:25:42 -07:00
Dav999
74a94ae1a8 Reference both cases for "Complete the game" in code
We had two separate cases for translators for this string (a
"TO UNLOCK:" one and a secret lab trophy one) but I forgot to use
the latter in the code, so both places in the game were using the
former. This is now fixed.
2023-09-20 15:29:23 -07:00
Misa
1bf0d11c9e Fix regression: Linear filter persistence
This fixes #1013 by axing the use of SDL_HINT_RENDER_SCALE_QUALITY and
instead using SDL_SetTextureScaleMode.

The hint is unwieldy to use, and since #923, has resulted in a
regression where starting the game in filtered mode then switching to
nearest results in scaled textures still being filtered.

The proper solution is to use SDL_SetTextureScaleMode on the two
textures that are drawn to the final screen: gameTexture and
tempShakeTexture.
2023-09-09 20:07:49 -07:00
Misa
5467dbe3d8 Remove trailing whitespace in textboxcommsrelay 2023-09-09 19:59:36 -07:00
AllyTally
a537492d9c Remove NO_EDITOR/NO_CUSTOM_LEVELS, disable editor on Steam Deck
This commit removes the `NO_EDITOR` and `NO_CUSTOM_LEVELS` defines,
which cleans up the code a lot, and they weren't really needed anyways.

This commit also disables the editor on the Steam Deck, and adds a
program argument to re-enable the editor, `-enable-editor`.
2023-08-25 09:50:27 -07:00
Dav999
3d7e9a47dd Fix various CJK positioning problems
- ERROR/WARNING screen title was overlapping with message
- Crewmate screen names and rescued statuses were overlapping with each
  other
- Textboxes on Level Complete screen were overlapping with each other
  and the crewmate was not vertically centered in the box
- Some strings were running into each other in flip mode, instead of
  being moved out of each other (PR_CJK_HIGH and PR_CJK_LOW worked the
  wrong way around because of FLIP macros being applied to Y coords)
- In-game esc menu was "bouncy" with selected menu options because of a
  hardcoded 16 pixel offset
- Bindings in the gamepad menu were overlapping with each other
- Some Super Gravitron "Best Time" labels and values were a little too
  close
2023-08-12 15:52:58 -07:00
AllyTally
fd4232e9fd Make gravity lines render when screen effects are off 2023-06-15 10:44:40 -07:00
AllyTally
a6ff75d32e Remove unused drawing overloads 2023-06-08 15:47:39 -07:00
AllyTally
254c46b846 Fix missing parentheses 2023-06-08 15:47:39 -07:00
AllyTally
aa8e731eb9 Fix a couple issues 2023-06-08 15:47:39 -07:00
AllyTally
b533731108 More misc cleanup 2023-06-08 15:47:39 -07:00
AllyTally
8b1dcecd5a Replace drawrect with draw_rect
Turns out `graphics.drawrect` exists. Well, not anymore!
This was another function from before the renderer rewrite which tried
to draw a rectangle by using four filled rectangles. We can draw
outline rectangles properly now, so let's make sure everywhere does it!
2023-06-08 15:47:39 -07:00
AllyTally
d1b9f4f410 Some formatting fixes 2023-06-08 15:47:39 -07:00
AllyTally
d93d773a8a Remove line_rect and prect
`prect` just wasn't needed as it was used in one place, and
`line_rect` isn't used anymore.
2023-06-08 15:47:39 -07:00
AllyTally
81ad7ed9d6 Clean up background drawing code
As #974 states, the lab background only ever uses the first generated
value from `backboxint`, so let's change it to a normal variable
instead of an array. Also, stars don't need their width/height set to
2 constantly... they never change in the first place, Terry!
2023-06-08 15:47:39 -07:00
AllyTally
5089bc373e Add more draw functions, make less code use rectangles
Some code still used rectangles to draw things like lines and pixels,
so this commit adds more draw functions to support drawing lines and
pixels without directly using the renderer.

Aside from making generated minimaps draw points instead of 1x1
rectangles, this commit also batches the point drawing for an
additional speed increase.
2023-06-08 15:47:39 -07:00
Misa
14d034e4c6 Use enums for swngame
This replaces the swngame int variable with a named enum and enforces
strict typechecking on it.

Strict typechecking is okay here as the swngame variable is not part of
the API surface of the game in any way and is completely internal.

And just to make things clear, I've added a SWN_NONE enum to use for
initialization, because previously it was being initialized to 0, even
though 0 was the Gravitron.
2023-06-05 17:57:23 -07:00
Misa
414b0647aa Correct orientation of Game Saved clock in Flip Mode
The clock on the Game Saved quicksave screen has always been upside-down
in Flip Mode. And technically, the trinket was too, but this was
unnoticeable because the default trinket sprite is symmetrical.

To fix this, draw flipsprites.png if these sprites are being drawn in
Flip Mode instead of sprites.png.
2023-06-05 17:57:23 -07:00
Misa
474cdc092e Use levelDirError for graphics errors too
This will actually do several things:

(1) Make the tile size checks apply to the appropriate graphics files
    once again.
(2) Make the game print a fallback error message if the error message
    hasn't been set on the levelDirError error screen.
(3) Use levelDirError for graphics errors too.
(4) Make the error message for tile size checks failing specify both
    width and height, not just a square dimension.
(5) Make the error messages mentioned above translatable.

It turns out that (1) didn't happen after #923 was merged, since #923
removed needing to process a tilesheet into a vector of surfaces for all
graphics files except sprites.png and flipsprites.png. Thus, the game
ended up only checking the correct tile sizes for those files only.

In the process of fixing this, I also got rid of the PROCESS_TILESHEET
macros and turned them into two different functions: One to make the
array, and one to check the tile size of the tilesheet.

I also did (2) just in case FILESYSTEM_levelDirHasError() returns false
even though we know we have an error.

And (3) is needed so things are unified and we have one user-facing
error message system when users load levels. To facilitate this, I
removed the title string, since it's really not needed.

Unfortunately, (1) doesn't apply to font.png again, but that's because
of the new font stuff and I'm not sure what Dav999 has in store for
error checking. But that's also why I did (4), because it looks like
tile sizes in font.png files can be different (i.e. non-square).
2023-05-17 17:11:26 -07:00
AllyTally
c6ebf5aeda Disable more flashing elements if a11y is on
For some reason, the accessibility option that was meant to disable
flashes doesn't disable ALL flashes, only screen flashes and screen
shaking. This commit disables a lot more, most importantly randomness
in colors, the player flashing on death/respawn, and teleporters
flashing.
2023-04-05 20:02:29 -07:00
Dav999-v
78128222e9 Make textbuttons() work for transparent text boxes
Misa asked me if this should only work for non-transparent textboxes,
and it shouldn't - that was kind of an oversight.

To make it work for transparent textboxes as well, I made a little
restructuring to avoid duplicating the code - fill_buttons() is now
called textbox_line(), and it replaces the direct accessing of the
textbox lines in the printing loops. The code that checks the width
of the textbox does not need to be copied, since the text box is
naturally not drawn for transparent text boxes.
2023-03-30 00:44:33 -07:00
Misa
98feeade02 Fix gray entities applying in main game
As reported by Lilithtreasure on the VVVVVV Discord server, it is
possible to get gray moving platforms and enemies in the main game.

This happens if you play the main game after loading a custom level with
a room that is gray at the same coordinates. E.g. if you play a custom
level with a gray room at (12, 4), then exit and go to Gantry and Dolly
in the main game which is also at (12, 4), then the platforms there
would be gray too.

This is because there is a missing map.custommode check.
2023-03-29 13:49:08 -07:00
AllyTally
efa1bad449 Unhardcode textbox colors in textbox arguments
There's a few places where textboxes are constructed through code, but
they pass in the color's RGB values in manually. This commit
unhardcodes most of them them, replacing them with a color lookup.

The ones that weren't changed are special cases, like `175, 174, 174`.
2023-03-29 13:48:44 -07:00
Dav999-v
e55e9efd9b Add controller button layout mappings
This adds mappings from SDL's Xbox-based SDL_GameControllerButton
constants, to glyphs for the following layouts:

- LAYOUT_NINTENDO_SWITCH_PRO,
- LAYOUT_NINTENDO_SWITCH_JOYCON_L,
- LAYOUT_NINTENDO_SWITCH_JOYCON_R,
- LAYOUT_DECK,
- LAYOUT_PLAYSTATION,
- LAYOUT_XBOX,
- LAYOUT_GENERIC,

There may still be errors in these, but they should be mostly correct.
I'm leaving it up to Ethan to make it show the correct button glyphs
for the correct controllers being connected (and possibly to fix these
mappings where needed).
2023-03-21 19:59:48 -07:00
Dav999-v
09365347b6 Replace ACTION in texts by {button} placeholders
Gamepads and the Steam Deck need "ACTION" to be replaced by a
controller glyph, so that's now possible.
2023-03-21 19:59:48 -07:00
Dav999-v
620365614d Add textbuttons() script command, make Violet's ENTER dialogue dynamic
Violet's dialogue now looks like this:

squeak(purple)
text(purple,0,0,2)
Remember that you can press {b_map}
to check where you are on the map!
position(purple,above)
textbuttons()
speak_active

The new textbuttons() command sets the next textbox to replace {b_map}
with the map button, and {b_int} with the interact button. The
remaining keys would be added as soon as they need to be added to
ActionSets.h as well.
2023-03-21 19:59:48 -07:00
AllyTally
34cc15505b Cleanup tools & main rendering
Tools were a mess, spread all over the code with hundreds of `else-if`
statements. Instead of magic numbers denoting tools, an enum has been
created, and logic has been extracted into simple switch/cases, shared
logic being deduplicated.

The base of a state system for the editor has been created as well,
laying a good path for further organization improvements. Because of
this, the entire editor no longer gets drawn underneath the menus,
except for a few pieces which I haven't extracted yet. Either way,
this should be good for performance, if that was a concern.
2023-03-21 15:41:49 -07:00