1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-05 02:39:41 +01:00
Commit graph

22 commits

Author SHA1 Message Date
Info Teddy
2709de9cf0 Make fast path using FillRect() when opaque
FillRect() is similar enough to memset when blending isn't used, so the
game will take a fast path drawing the roomname background when the
background is opaque.
2020-01-25 23:29:37 -05:00
Info Teddy
2f85c2a8dc Draw room names with text outline
This makes it easier to see if you have a translucent room name
background.
2020-01-25 23:29:37 -05:00
Info Teddy
df83c2d494 Add an accessibility option to be able to see through the roomname
This is the variable dwgfx.translucentroomname and <translucentroomname>
in unlock.vvv.

This lets you see through the black background of the roomname at the
bottom of the screen, i.e. it makes the roomname background translucent.
So you can see if someone decides to hide pesky spikes there.
2020-01-25 23:29:37 -05:00
Info Teddy
c49ae404af Convert roomname background to a surface, then draw that
The roomname background used to just be a simple SDL_Rect that was drawn
using SDL_FillRect with a color of 0. Unfortunately, it seems that you
cannot use transparent colors with SDL_FillRect, it just defaults to
being fully opaque. However, you CAN draw surfaces with translucency,
which seems like the easiest thing to do. But the first step is to
convert the roomname background to an SDL_Surface.

This replaces the FillRect()s with SDL_BlitSurface() in the three places
roomnames are drawn: in towerrender, in gamerender, and in editorrender.
2020-01-25 23:29:37 -05:00
Info Teddy
f6fa8dd84c De-duplicate the roomname printing code in the editor
For some reason, there are two lines that have been copy-pasted the
exact same way and in the exact same place, namely being at the end of
each branch of the if-else conditional, which makes them be executed no
matter what. If they're going to be executed no matter what, we might as
well make it clearer and take those two lines out of each branch.
2020-01-25 23:29:37 -05:00
Fredrik Ljungdahl
2ec1106741 Fix level editor not using LoadTiXmlDocument 2020-01-24 16:45:18 -05:00
Dav999-v
3dee27db7b Remove superfluous whitespace in entity XML data in level files (#119)
An earlier change caused TinyXml to prettyprint specifically the
contents of entities (script names and roomtext) a bit more than
before in level files, and added an unusually high amount of whitespace
(particularly, it added an empty line to every entity). This happens
because, for some reason, an empty string is explicitly being added
when creating an entity XML element. The line is so mysterious it feels
like it probably somehow solved a nasty bug long ago and shouldn't be
touched, but it was probably just a mistake, and with all that
whitespace it doesn't look good.
2020-01-24 14:25:21 -05:00
Info Teddy
cd7cc317b5 Up the trinkets/crewmates limit to 100
2.2 will handle this just fine, because there are 100 slots allocated
for trinkets and crewmates, and it will save and load all 100 slots just
fine. Except, it only resets the first 20 slots when starting a level
from the beginning, but that's minor and already fixed in 2.3 anyway.

This commit makes it so you can now place up to one hundred trinkets and
crewmates in the editor.
2020-01-23 10:00:26 -05:00
Terry Cavanagh
782ce95d11
Merge pull request #115 from FredrIQ/master
Make the level editor use font outlines
2020-01-23 14:59:53 +01:00
Fredrik Ljungdahl
76792e652a Don't outline entity directions (looks odd and can never be hard to see) 2020-01-23 14:53:35 +01:00
Info Teddy
e8fd134a43 Fix X and Y coordinates getting reversed in editorclass::reset()
When editorclass::reset() was resetting the contents of the level
previously, it was mixing up the X and Y bounds. The Y bound was
supposed to be 30*maxheight, and the X bound was supposed to be
40*maxwidth. Instead, it took 30*maxwidth as its Y bound and
40*maxheight as its X bound.

Then, when it actually indexes the contents vector to set each tile to
0, it used 30*maxwidth instead of 40*maxwidth.

The difference between width and height is a bit hard to spot, but one
thing you can do to remember the difference is to remember the fact that
X corresponds with width, and Y corresponds with height. Also, rooms are
40 by 30 tiles, and so X (and therefore width) should correspond with
40, and Y (and therefore height) should correspond with 30.

As a result of mixing up the variables, whenever you played a 20x20 map,
quit the level and then started making a new 20x20 map, the tiles of the
last four rows of the previous map would persist, from y=16 (1-indexed)
all the way to y=20 (1-indexed).

I don't recall anyone ever running into this bug before, which is a bit
strange. But if no one truly has ever ran into this bug before, then I'm
genuinely surprised.

While working on the patch to fix the enemy type room property of each
room not getting reset, and testing the fix, I noticed that for some
reason some contents of the previous level I played in order to test the
enemy type property persisting was ALSO persisting alongside the enemy
type property.

Then I read the code and when I realized that the X and Y bounds were
getting mixed up I groaned. Very loudly.
2020-01-23 08:42:35 -05:00
Info Teddy
8e9970d619 Reset enemy type in editorclass::reset()
This fixes a bug where if you loaded a level, then started making a new
level in the editor, the enemy types from the previous level would
persist.

While working on VVVVVV: Community Edition and adding a new room
property for enemy speed, I noticed that enemy type was not getting
reset at all. After some testing, I confirmed that this was the case. So
this bug is fixed now.
2020-01-23 08:39:55 -05:00
Fredrik Ljungdahl
ca9f577fc4 Make the level editor use font outlines for text appropriately 2020-01-23 14:23:56 +01:00
Info Teddy
31efc9b3ce Fix out-of-bounds array access in findstartpoint()
Out-of-bounds array access is Undefined Behavior, which means Bad
Things.

In this particular case, it was indexing an array by using the
`testeditor` variable. Which is fine, except it was indexing that array
*in a conditional that only happens if `testeditor` is -1*. So it was
indexing an array at position -1, which is Out of Bounds and is Not
Good.
2020-01-22 07:46:46 -05:00
Info Teddy
2c2acc93e6 Reset Direct Mode in editorclass::reset()
There's a long-standing issue where the Direct Mode status of the loaded
custom map in memory never resets properly. So if you load a level with
a certain layout of Direct Mode rooms, that same layout will be
preserved if you start making a new level in the editor. This commit
fixes that issue.
2020-01-19 21:46:52 -08:00
Info Teddy
916f182ce6 Set ed.keydelay when backspacing an empty line
Similar to 2ebccbc3e9, there's also a
long-standing bug where if you backspace an empty line (and this time,
the line IS actually already empty, not merely
emptied-earlier-in-the-frame), the game will quickly delete more blank
lines if there are any above the blank line you deleted. Again, this is
annoying too, if you so happen to need to use lots of blank lines.

To fix this, it's simple - just set ed.keydelay to 6 when the game
backspaces an empty line. Then it won't be so trigger-happy in deleting
blank lines.
2020-01-19 08:37:14 -05:00
Info Teddy
2687090ac2 Fix frame-ordering backspacing empty line bug in script editor
There is a long-standing bug with the script editor where if you delete
the last character of a line, it IMMEDIATELY deletes the line you're on,
and then moves your cursor back to the previous line. This is annoying,
to say the least.

The reason for this is that, in the sequence of events that happens in
one frame (known as frame ordering), the code that backspaces one
character from the line when you press Backspace is ran BEFORE the code
to remove an empty line if you backspace it is ran. The former is
located in key.Poll(), and the latter is located in editorinput().

Thus, when you press Backspace, the game first runs key.Poll(), sees
that you've pressed Backspace, and dutifully removes the last character
from a line. The line is now empty. Then, when the game gets around to
the "Are you pressing Backspace on an empty line?" check in
editorinput(), it thinks that you're pressing Backspace on an empty
line, and then does the usual line-removing stuff.

And actually, when it does the check in editorinput(), it ACTUALLY asks
"Are you pressing Backspace on THIS frame and was the line empty LAST
frame?" because it's checking against its own copy of the input buffer,
before copying the input buffer to its own local copy. So the problem
only happens if you press and hold Backspace for more than 1 frame.
It's a small consolation prize for this annoyance, getting to
tap-tap-tap Backspace in the hopes that you only press it for 1 frame,
while in the middle of something more important to do like, oh I don't
know, writing a script.

So there are two potential solutions here:

 (1) Just change the frame ordering around.

     This is risky to say the least, because I'm not sure what behavior
     depends on exactly which frame order. It's not like it's key.Poll()
     and then IMMEDIATELY afterwards editorinput() is run, it's more
     like key.Poll(), some things that obviously depend on key.Poll()
     running before them, and THEN editorinput(). Also, editorinput() is
     only one possible thing that could be ran afterwards, on the next
     frame we could be running something else entirely instead.

 (2) Add a kludge variable to signal when the line is ALREADY empty so
     the game doesn't re-check the already-empty line and conclude that
     you're already immediately backspacing an empty line.

I went with (2) for this commit, and I've added the kludge variable
key.linealreadyemptykludge.

However, that by itself isn't enough to fix it. It only adds about a
frame or so of delay before the game goes right back to saying "Oh,
you're ALREADY somehow pressing backspace again? I'll just delete this
line real quick" and the behavior is basically the same as before,
except now you have to hit Backspace for TWO frames or less instead of
one in order to not have it happen.

What we need is to have a delay set as well, when the game deletes the
last line of a char. So I set ed.keydelay to 6 as well if editorinput()
sses that key.linealreadyemptykludge is on.
2020-01-19 08:37:14 -05:00
Info Teddy
b1d6b7f395 Fix off-by-one in script editor letting you type on a nonexistent line
For a long time, the script editor has had a bug where it would let you
put the cursor on a nonexistent script line, which would APPEAR to be
the last line of the script... but in reality, it WASN'T the last line
of the script, and in fact, the ACTUAL last line was the line ABOVE the
script.

So, if you typed anything on this nonexistent line, it would appear to
get erased when exiting the script. Thus, people have (erroneously)
misdiagnosed this as the script editor somehow being trigger-happy and
erasing lines when it shouldn't be, when in reality it should've have
let you gone onto that line in the first place!
2020-01-19 00:33:20 -05:00
Info Teddy
3247d3be41 Correct capitalization of song names
This corrects things like "Passion for exploring" and "Passion For
Exploring" to be "Passion for Exploring".
2020-01-15 22:05:37 -08:00
Info Teddy
3e9bd3aaac Fix scaling editor mouse coords properly in stretch mode
Now your cursor will properly align with the editor's cursor if you're
in stretch mode.

Closes #27.
2020-01-12 10:52:14 -05:00
Dav999-v
b884b7e4e9 Replace TiXmlDocument load and save functions by PHYSFS
The TinyXml functions to load and save files don't properly support
unicode file paths on Windows, so in order to support that properly, I
saw no other option than to do the actual loading and saving via PHYSFS
(or to use the Windows API on Windows and retain doc.LoadFile and
doc.SaveFile on other OSes, but that'd be more complicated and
unnecessary, we already have PHYSFS, right?).

There are two new functions in FileSystemUtils:
bool FILESYSTEM_saveTiXmlDocument(const char *name, TiXmlDocument *doc)
bool FILESYSTEM_loadTiXmlDocument(const char *name, TiXmlDocument *doc)

Any instances of doc.SaveFile(<FULL_PATH>) have been replaced by
FILESYSTEM_saveTiXmlDocument(<VVVVVV_FOLDER_PATH>, &doc), where
<FULL_PATH> included the full path to the saves or levels directory,
and <VVVVVV_FOLDER_PATH> only includes the path relative to the VVVVVV
directory.
When loading a document, a TiXmlDocument used to be created with a full
path in its constructor and doc.LoadFile() would then be called, now a
TiXmlDocument is constructed with no path name and
FILESYSTEM_loadTiXmlDocument(<VVVVVV_FOLDER_PATH>, &doc) is called.
2020-01-12 10:44:11 -05:00
Ethan Lee
f7c0321b71 Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00