2021-02-20 05:51:25 +01:00
|
|
|
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)
|
2020-02-10 01:53:01 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
#define ED_DEFINITION
|
|
|
|
#include "Editor.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-19 21:43:29 +02:00
|
|
|
#include <string>
|
|
|
|
#include <utf8/unchecked.h>
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
#include "CustomLevels.h"
|
2021-03-19 05:14:40 +01:00
|
|
|
#include "DeferCallbacks.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
#include "Entity.h"
|
2020-07-19 21:43:29 +02:00
|
|
|
#include "Enums.h"
|
2021-02-20 05:51:25 +01:00
|
|
|
#include "Game.h"
|
2020-07-19 21:43:29 +02:00
|
|
|
#include "Graphics.h"
|
2021-02-20 05:51:25 +01:00
|
|
|
#include "GraphicsUtil.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
#include "KeyPoll.h"
|
|
|
|
#include "Map.h"
|
2020-07-19 21:43:29 +02:00
|
|
|
#include "Music.h"
|
Extern `gameScreen`, remove `screenbuffer`
I know earlier I removed the gameScreen extern in favor of using
screenbuffer, but that was only to be consistent. After further
consideration, I have found that it's actually really stupid.
There's no reason to be accessing it through screenbuffer, and it's
probably an artifact of 2.0-2.2 passing stack-allocated otherwise-global
classes everywhere through function arguments. Also, it leads to stupid
bugs where screenbuffer could potentially be NULL, which has already
resulted in various annoying crashes in the past. Although those could
be fixed by simply initializing screenbuffer at the very top of main(),
but, why not just scrap the whole thing anyway?
So that's what I'm doing.
As a nice side effect, I've removed the transitive include of Screen.h
from Graphics.h. This could've been done already since it only includes
it for the pointer anyway, but it's still good to do it now.
2021-12-25 08:56:47 +01:00
|
|
|
#include "Screen.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
#include "Script.h"
|
2020-07-19 21:05:41 +02:00
|
|
|
#include "UtilityClass.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
editorclass::editorclass(void)
|
|
|
|
{
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::reset(void)
|
|
|
|
{
|
|
|
|
roomnamehide=0;
|
|
|
|
zmod=false;
|
|
|
|
xmod=false;
|
|
|
|
cmod=false;
|
|
|
|
vmod=false;
|
|
|
|
hmod=false;
|
|
|
|
bmod=false;
|
|
|
|
spacemod=false;
|
|
|
|
spacemenu=0;
|
|
|
|
shiftmenu=false;
|
|
|
|
shiftkey=false;
|
|
|
|
saveandquit=false;
|
|
|
|
note="";
|
|
|
|
notedelay=0;
|
|
|
|
oldnotedelay=0;
|
|
|
|
deletekeyheld=false;
|
|
|
|
textmod = TEXT_NONE;
|
|
|
|
|
|
|
|
titlemod=false;
|
|
|
|
creatormod=false;
|
|
|
|
desc1mod=false;
|
|
|
|
desc2mod=false;
|
|
|
|
desc3mod=false;
|
|
|
|
websitemod=false;
|
|
|
|
settingsmod=false;
|
|
|
|
warpmod=false; //Two step process
|
|
|
|
warpent=-1;
|
|
|
|
|
|
|
|
boundarymod=0;
|
|
|
|
boundarytype=0;
|
|
|
|
boundx1=0;
|
|
|
|
boundx2=0;
|
|
|
|
boundy1=0;
|
|
|
|
boundy2=0;
|
|
|
|
|
|
|
|
textent=0;
|
|
|
|
scripttexttype=0;
|
|
|
|
|
|
|
|
drawmode=0;
|
|
|
|
dmtile=0;
|
|
|
|
dmtileeditor=0;
|
|
|
|
entcol=0;
|
|
|
|
|
|
|
|
tilex=0;
|
|
|
|
tiley=0;
|
|
|
|
levx=0;
|
|
|
|
levy=0;
|
|
|
|
keydelay=0;
|
|
|
|
lclickdelay=0;
|
|
|
|
savekey=false;
|
|
|
|
loadkey=false;
|
|
|
|
updatetiles=true;
|
|
|
|
changeroom=true;
|
|
|
|
|
|
|
|
entframe=0;
|
|
|
|
entframedelay=0;
|
|
|
|
|
|
|
|
SDL_zeroa(kludgewarpdir);
|
|
|
|
|
|
|
|
hooklist.clear();
|
|
|
|
|
|
|
|
sb.clear();
|
|
|
|
|
|
|
|
clearscriptbuffer();
|
|
|
|
sbx=0;
|
|
|
|
sby=0;
|
|
|
|
pagey=0;
|
|
|
|
scripteditmod=false;
|
|
|
|
sbscript="null";
|
|
|
|
scripthelppage=0;
|
|
|
|
scripthelppagedelay=0;
|
|
|
|
|
|
|
|
hookmenupage=0;
|
|
|
|
hookmenu=0;
|
|
|
|
|
|
|
|
returneditoralpha = 0;
|
|
|
|
oldreturneditoralpha = 0;
|
|
|
|
|
|
|
|
ghosts.clear();
|
|
|
|
currentghosts = 0;
|
|
|
|
|
|
|
|
loaded_filepath = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::gethooks(void)
|
|
|
|
{
|
|
|
|
//Scan through the script and create a hooks list based on it
|
|
|
|
hooklist.clear();
|
|
|
|
for (size_t i = 0; i < script.customscripts.size(); i++)
|
|
|
|
{
|
|
|
|
Script& script_ = script.customscripts[i];
|
|
|
|
|
|
|
|
hooklist.push_back(script_.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void editorclass::loadhookineditor(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
//Find hook t in the scriptclass, then load it into the editor
|
|
|
|
clearscriptbuffer();
|
|
|
|
|
|
|
|
for(size_t i = 0; i < script.customscripts.size(); i++)
|
|
|
|
{
|
|
|
|
Script& script_ = script.customscripts[i];
|
|
|
|
|
|
|
|
if(script_.name == t)
|
|
|
|
{
|
|
|
|
sb = script_.contents;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sb.empty())
|
|
|
|
{
|
|
|
|
//Always have one line or we'll have problems
|
|
|
|
sb.resize(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void editorclass::addhooktoscript(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
//Adds hook+the scriptbuffer to the end of the scriptclass
|
|
|
|
removehookfromscript(t);
|
|
|
|
Script script_;
|
|
|
|
script_.name = t;
|
|
|
|
script_.contents = sb;
|
|
|
|
script.customscripts.push_back(script_);
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void editorclass::removehookfromscript(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
/* Find hook t in the scriptclass, then removes it (and any other code with it)
|
|
|
|
* When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */
|
|
|
|
size_t i;
|
|
|
|
for (i = script.customscripts.size() - 1; i + 1 > 0; --i)
|
|
|
|
{
|
|
|
|
if (script.customscripts[i].name == t)
|
|
|
|
{
|
|
|
|
script.customscripts.erase(script.customscripts.begin() + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void editorclass::removehook(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
//Check the hooklist for the hook t. If it's there, remove it from here and the script
|
|
|
|
size_t i;
|
|
|
|
removehookfromscript(t);
|
|
|
|
/* When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */
|
|
|
|
for (i = hooklist.size() - 1; i + 1 > 0; --i)
|
|
|
|
{
|
|
|
|
if (hooklist[i] == t)
|
|
|
|
{
|
|
|
|
hooklist.erase(hooklist.begin() + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void editorclass::addhook(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
//Add an empty function to the list in both editor and script
|
|
|
|
removehook(t);
|
|
|
|
hooklist.push_back(t);
|
|
|
|
addhooktoscript(t);
|
|
|
|
}
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
bool editorclass::checkhook(const std::string& t)
|
2021-02-21 00:40:11 +01:00
|
|
|
{
|
|
|
|
//returns true if hook t already is in the list
|
|
|
|
for(size_t i=0; i<hooklist.size(); i++)
|
|
|
|
{
|
|
|
|
if(hooklist[i]==t) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void editorclass::clearscriptbuffer(void)
|
|
|
|
{
|
|
|
|
sb.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::removeline(int t)
|
|
|
|
{
|
|
|
|
//Remove line t from the script
|
|
|
|
if((int)sb.size()>1)
|
|
|
|
{
|
|
|
|
sb.erase(sb.begin() + t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::insertline(int t)
|
|
|
|
{
|
|
|
|
//insert a blank line into script at line t
|
|
|
|
sb.insert(sb.begin() + t, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::getlin(const enum textmode mode, const std::string& prompt, std::string* ptr)
|
|
|
|
{
|
|
|
|
textmod = mode;
|
|
|
|
textptr = ptr;
|
|
|
|
textdesc = prompt;
|
|
|
|
key.enabletextentry();
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
key.keybuffer = *ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
key.keybuffer = "";
|
|
|
|
textptr = &(key.keybuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldenttext = key.keybuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static void addedentity( int xp, int yp, int tp, int p1 = 0, int p2 = 0, int p3 = 0, int p4 = 0, int p5 = 320, int p6 = 240)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 00:56:59 +01:00
|
|
|
CustomEntity entity;
|
2020-03-01 21:24:43 +01:00
|
|
|
|
|
|
|
entity.x=xp;
|
|
|
|
entity.y=yp;
|
|
|
|
entity.t=tp;
|
|
|
|
entity.p1=p1;
|
|
|
|
entity.p2=p2;
|
|
|
|
entity.p3=p3;
|
|
|
|
entity.p4=p4;
|
|
|
|
entity.p5=p5;
|
|
|
|
entity.p6=p6;
|
|
|
|
entity.scriptname="";
|
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities.push_back(entity);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static void removeedentity( int t )
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities.erase(customentities.begin() + t);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static int edentat( int xp, int yp )
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
for(size_t i=0; i<customentities.size(); i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].x==xp && customentities[i].y==yp) return i;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static void fillbox( int x, int y, int x2, int y2, int c )
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, x, y, x2-x, 1, c);
|
|
|
|
FillRect(graphics.backBuffer, x, y2-1, x2-x, 1, c);
|
|
|
|
FillRect(graphics.backBuffer, x, y, 1, y2-y, c);
|
|
|
|
FillRect(graphics.backBuffer, x2-1, y, 1, y2-y, c);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static void fillboxabs( int x, int y, int x2, int y2, int c )
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, x, y, x2, 1, c);
|
|
|
|
FillRect(graphics.backBuffer, x, y+y2-1, x2, 1, c);
|
|
|
|
FillRect(graphics.backBuffer, x, y, 1, y2, c);
|
|
|
|
FillRect(graphics.backBuffer, x+x2-1, y, 1, y2, c);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static void editormenurender(int tr, int tg, int tb)
|
2020-04-16 05:55:34 +02:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
extern editorclass ed;
|
2020-04-17 00:19:17 +02:00
|
|
|
switch (game.currentmenuname)
|
2020-04-16 05:55:34 +02:00
|
|
|
{
|
2020-04-17 00:19:17 +02:00
|
|
|
case Menu::ed_settings:
|
2020-04-16 05:55:34 +02:00
|
|
|
graphics.bigprint( -1, 75, "Map Settings", tr, tg, tb, true);
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
if (game.currentmenuoption == 3)
|
|
|
|
{
|
|
|
|
if (!game.ghostsenabled)
|
|
|
|
graphics.Print(2, 230, "Editor ghost trail is OFF", tr/2, tg/2, tb/2);
|
|
|
|
else
|
|
|
|
graphics.Print(2, 230, "Editor ghost trail is ON", tr, tg, tb);
|
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
case Menu::ed_desc:
|
2020-04-16 05:55:34 +02:00
|
|
|
if(ed.titlemod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.bigprint( -1, 35, key.keybuffer+"_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.bigprint( -1, 35, key.keybuffer+" ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
graphics.bigprint( -1, 35, cl.title, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
if(ed.creatormod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 60, "by " + key.keybuffer+ "_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 60, "by " + key.keybuffer+ " ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
graphics.Print( -1, 60, "by " + cl.creator, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
if(ed.websitemod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 70, key.keybuffer+"_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 70, key.keybuffer+" ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.Print( -1, 70, cl.website, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
if(ed.desc1mod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 90, key.keybuffer+"_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 90, key.keybuffer+" ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.Print( -1, 90, cl.Desc1, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
if(ed.desc2mod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 100, key.keybuffer+"_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 100, key.keybuffer+" ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.Print( -1, 100, cl.Desc2, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
if(ed.desc3mod)
|
|
|
|
{
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 110, key.keybuffer+"_", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.Print( -1, 110, key.keybuffer+" ", tr, tg, tb, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.Print( -1, 110, cl.Desc3, tr, tg, tb, true);
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
case Menu::ed_music:
|
2020-07-01 03:40:18 +02:00
|
|
|
{
|
2020-04-16 05:55:34 +02:00
|
|
|
graphics.bigprint( -1, 65, "Map Music", tr, tg, tb, true);
|
|
|
|
|
|
|
|
graphics.Print( -1, 85, "Current map music:", tr, tg, tb, true);
|
2020-07-01 03:40:18 +02:00
|
|
|
std::string songname;
|
2021-02-21 00:40:11 +01:00
|
|
|
switch(cl.levmusic)
|
2020-04-16 05:55:34 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "No background music";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "1: Pushing Onwards";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "2: Positive Force";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "3: Potential for Anything";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "4: Passion for Exploring";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
2020-07-01 03:41:20 +02:00
|
|
|
case 5:
|
|
|
|
songname = "N/A: Pause";
|
|
|
|
break;
|
2020-04-16 05:55:34 +02:00
|
|
|
case 6:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "5: Presenting VVVVVV";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
2020-07-01 03:41:20 +02:00
|
|
|
case 7:
|
|
|
|
songname = "N/A: Plenary";
|
|
|
|
break;
|
2020-04-16 05:55:34 +02:00
|
|
|
case 8:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "6: Predestined Fate";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
2020-07-01 03:41:20 +02:00
|
|
|
case 9:
|
|
|
|
songname = "N/A: ecroF evitisoP";
|
|
|
|
break;
|
2020-04-16 05:55:34 +02:00
|
|
|
case 10:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "7: Popular Potpourri";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 11:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "8: Pipe Dream";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 12:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "9: Pressure Cooker";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 13:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "10: Paced Energy";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
case 14:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "11: Piercing the Sky";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
2020-07-01 03:41:20 +02:00
|
|
|
case 15:
|
|
|
|
songname = "N/A: Predestined Fate Remix";
|
|
|
|
break;
|
2020-04-16 05:55:34 +02:00
|
|
|
default:
|
2020-07-01 03:40:18 +02:00
|
|
|
songname = "?: something else";
|
2020-04-16 05:55:34 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-07-01 03:40:18 +02:00
|
|
|
graphics.Print( -1, 120, songname, tr, tg, tb, true);
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
2020-07-01 03:40:18 +02:00
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
case Menu::ed_quit:
|
2020-04-16 05:55:34 +02:00
|
|
|
graphics.bigprint( -1, 90, "Save before", tr, tg, tb, true);
|
|
|
|
graphics.bigprint( -1, 110, "quitting?", tr, tg, tb, true);
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2020-04-16 05:55:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorrender(void)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-09-28 04:15:06 +02:00
|
|
|
extern editorclass ed;
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(ed.levx, ed.levy);
|
2021-03-24 19:59:36 +01:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
//Draw grid
|
|
|
|
|
2021-02-26 00:37:03 +01:00
|
|
|
ClearSurface(graphics.backBuffer);
|
2020-01-01 21:29:24 +01:00
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(8,8,8)); //a simple grid
|
|
|
|
if(i%4==0) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(16,16,16));
|
|
|
|
if(j%4==0) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(16,16,16));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Minor guides
|
2020-03-31 21:52:10 +02:00
|
|
|
if(i==9) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(24,24,24));
|
|
|
|
if(i==30) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(24,24,24));
|
|
|
|
if(j==6 || j==7) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(24,24,24));
|
|
|
|
if(j==21 || j==22) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(24,24,24));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Major guides
|
2020-03-31 21:52:10 +02:00
|
|
|
if(i==20 || i==19) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(32,32,32));
|
|
|
|
if(j==14) fillbox(i*8, j*8, (i*8)+7, (j*8)+7, graphics.getRGB(32,32,32));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Or draw background
|
|
|
|
if(!ed.settingsmod)
|
|
|
|
{
|
2021-03-24 19:59:36 +01:00
|
|
|
switch(room->warpdir)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
case 1:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawbackground(3);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawbackground(4);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawbackground(5);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Draw map, in function
|
|
|
|
int temp;
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->tileset==0 || room->tileset==10)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
for (int j = 0; j < 30; j++)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2020-04-02 00:42:22 +02:00
|
|
|
if(temp>0) graphics.drawtile(i*8,j*8,temp);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 30; j++)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2020-04-02 00:47:35 +02:00
|
|
|
if(temp>0) graphics.drawtile2(i*8,j*8,temp);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Edge tile fix
|
|
|
|
|
|
|
|
//Buffer the sides of the new room with tiles from other rooms, to ensure no gap problems.
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
//left edge
|
|
|
|
if(ed.freewrap((ed.levx*40)-1,j+(ed.levy*30))==1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
//right edge
|
|
|
|
if(ed.freewrap((ed.levx*40)+40,j+(ed.levy*30))==1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 318,j*8, 2,8, graphics.getRGB(255 - help.glow, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
|
|
|
if(ed.freewrap((ed.levx*40)+i,(ed.levy*30)-1)==1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, i*8,0, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.freewrap((ed.levx*40)+i,30+(ed.levy*30))==1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, i*8,238, 8,2, graphics.getRGB(255 - help.glow, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Draw entities
|
|
|
|
obj.customplatformtile=game.customcol*12;
|
|
|
|
|
2020-07-03 04:28:35 +02:00
|
|
|
int temp2=edentat(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30));
|
2020-01-27 02:15:49 +01:00
|
|
|
|
2020-09-25 19:35:03 +02:00
|
|
|
// Special case for drawing gray entities
|
2021-03-24 19:59:36 +01:00
|
|
|
bool custom_gray = room->tileset == 3 && room->tilecol == 6;
|
2020-09-25 19:35:03 +02:00
|
|
|
colourTransform gray_ct;
|
|
|
|
gray_ct.colour = 0xFFFFFFFF;
|
|
|
|
|
2020-01-27 02:15:49 +01:00
|
|
|
// Draw entities backward to remain accurate with ingame
|
2021-02-21 01:01:39 +01:00
|
|
|
for (int i = customentities.size() - 1; i >= 0; i--)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
point tpoint;
|
|
|
|
SDL_Rect drawRect;
|
|
|
|
|
Fix variables shadowing other variables
In C++, when you have two variables in different scopes with the same
name, the inner scope wins. Except you have to be really careful because
sometimes they're not (#507). So it's better to just always have unique
variable names and make sure to never clash a name with a variable in an
outer scope - after all, the C++ compiler and standard might be fine
with it, but that doesn't mean humans can't make mistakes reading or
writing it.
Usually I just renamed the inner variables, but for tx/ty in editor.cpp,
I just got rid of the ridiculous overcomplicated modulo calculations and
replaced them with actual simple modulo calculations, because the
existing ones were just ridiculous. Actually, somebody ought to find
every instance of the overcomplicated modulos and replace them with the
actual good ones, because it's really stupid, quite frankly...
2020-11-04 09:37:46 +01:00
|
|
|
//if() on screen
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].x / 40 == ed.levx && customentities[i].y / 30 == ed.levy)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
switch(customentities[i].t)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
case 1: //Entities
|
2020-09-25 19:35:03 +02:00
|
|
|
if (custom_gray) {
|
|
|
|
graphics.setcol(18);
|
|
|
|
ed.entcolreal = graphics.ct.colour;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.drawsprite((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);
|
|
|
|
if(customentities[i].p1==3) 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);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255,164,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2: //Threadmills & platforms
|
2020-09-16 00:21:34 +02:00
|
|
|
if (!INBOUNDS_VEC(obj.customplatformtile, graphics.entcolours))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
tpoint.x = (customentities[i].x*8)- (ed.levx*40*8);
|
|
|
|
tpoint.y = (customentities[i].y*8)- (ed.levy*30*8);
|
2020-03-31 21:52:10 +02:00
|
|
|
drawRect = graphics.tiles_rect;
|
2020-01-01 21:29:24 +01:00
|
|
|
drawRect.x += tpoint.x;
|
|
|
|
drawRect.y += tpoint.y;
|
2020-10-11 22:56:17 +02:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2020-09-25 19:35:03 +02:00
|
|
|
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
|
|
|
|
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
|
|
|
|
drawRect.x += 8;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1<=4)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "V", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
|
|
|
if(customentities[i].p1==1) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "^", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
|
|
|
if(customentities[i].p1==2) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
|
|
|
if(customentities[i].p1==3) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), ">", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1==5)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), ">>>>", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[i].p1==6)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), "<<<<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1>=7)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
tpoint.x = (customentities[i].x*8)- (ed.levx*40*8)+32;
|
|
|
|
tpoint.y = (customentities[i].y*8)- (ed.levy*30*8);
|
2020-03-31 21:52:10 +02:00
|
|
|
drawRect = graphics.tiles_rect;
|
2020-01-01 21:29:24 +01:00
|
|
|
drawRect.x += tpoint.x;
|
|
|
|
drawRect.y += tpoint.y;
|
2020-10-11 22:56:17 +02:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2020-09-25 19:35:03 +02:00
|
|
|
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
|
|
|
|
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
|
|
|
|
drawRect.x += 8;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1==7)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8), "> > > > ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),64,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[i].p1==8)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8), "< < < < ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),64,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: //Disappearing Platform
|
2020-09-16 00:21:34 +02:00
|
|
|
if (!INBOUNDS_VEC(obj.customplatformtile, graphics.entcolours))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
tpoint.x = (customentities[i].x*8)- (ed.levx*40*8);
|
|
|
|
tpoint.y = (customentities[i].y*8)- (ed.levy*30*8);
|
2020-03-31 21:52:10 +02:00
|
|
|
drawRect = graphics.tiles_rect;
|
2020-01-01 21:29:24 +01:00
|
|
|
drawRect.x += tpoint.x;
|
|
|
|
drawRect.y += tpoint.y;
|
2020-10-11 22:56:17 +02:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2020-09-25 19:35:03 +02:00
|
|
|
if (custom_gray) BlitSurfaceTinted(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect, gray_ct);
|
|
|
|
else BlitSurfaceStandard(graphics.entcolours[obj.customplatformtile],NULL, graphics.backBuffer, &drawRect);
|
|
|
|
drawRect.x += 8;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), "////", 255 - help.glow, 255 - help.glow, 255 - help.glow, false);
|
2021-08-28 21:59:46 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 9: //Shiny Trinket
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),22,196,196,196);
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 10: //Checkpoints
|
2021-02-21 01:01:39 +01:00
|
|
|
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);
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 11: //Gravity lines
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1==0) //Horizontal
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx = customentities[i].p2;
|
|
|
|
int tx2 = tx + customentities[i].p3/8;
|
|
|
|
int ty = customentities[i].y % 30;
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, (tx*8),(ty*8)+4, (tx2-tx)*8,1, graphics.getRGB(194,194,194));
|
2021-02-21 01:01:39 +01:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else //Vertical
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx = customentities[i].x % 40;
|
|
|
|
int ty = customentities[i].p2;
|
|
|
|
int ty2 = ty + customentities[i].p3/8;
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, (tx*8)+3,(ty*8), 1,(ty2-ty)*8, graphics.getRGB(194,194,194));
|
2021-02-21 01:01:39 +01:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13://Warp tokens
|
2021-02-21 01:01:39 +01:00
|
|
|
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);
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
|
2020-07-03 04:28:35 +02:00
|
|
|
if(temp2==i)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
"("+help.String(customentities[i].p1/40 + 1)+","+help.String(customentities[i].p2/30 + 1)+")",210,210,255);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 15: //Crewmates
|
2021-02-21 01:01:39 +01:00
|
|
|
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));
|
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 16: //Start
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1==0) //Left
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),0,graphics.col_crewcyan);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[i].p1==1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),3,graphics.col_crewcyan);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(255, 255, 164));
|
2020-01-01 21:29:24 +01:00
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8)-12,(customentities[i].y*8)- (ed.levy*30*8)-8,"START",255,255,255);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8)-12,(customentities[i].y*8)- (ed.levy*30*8)-8,"START",196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 17: //Roomtext
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].scriptname.length()<1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(96,96,96));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int length = utf8::unchecked::distance(customentities[i].scriptname.begin(), customentities[i].scriptname.end());
|
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),length*8,8,graphics.getRGB(96,96,96));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), customentities[i].scriptname, 196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 18: //Terminals
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int usethistile = customentities[i].p1;
|
|
|
|
int usethisy = (customentities[i].y % 30) * 8;
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
// Not a boolean: just swapping 0 and 1, leaving the rest alone
|
|
|
|
if (usethistile == 0)
|
|
|
|
{
|
|
|
|
usethistile = 1; // Unflipped
|
|
|
|
}
|
|
|
|
else if (usethistile == 1)
|
|
|
|
{
|
|
|
|
usethistile = 0; // Flipped;
|
|
|
|
usethisy -= 8;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.drawsprite((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));
|
2020-07-03 04:28:35 +02:00
|
|
|
if(temp2==i)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
case 19: //Script Triggers
|
2021-02-21 01:01:39 +01:00
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),customentities[i].p1*8,customentities[i].p2*8,graphics.getRGB(255,164,255));
|
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,255));
|
2020-07-03 04:28:35 +02:00
|
|
|
if(temp2==i)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 50: //Warp lines
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].p1>=2) //Horizontal
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx=customentities[i].x-(ed.levx*40);
|
|
|
|
int tx2=customentities[i].x-(ed.levx*40);
|
|
|
|
int ty=customentities[i].y-(ed.levy*30);
|
|
|
|
if (customentities[i].p4 != 1)
|
2020-06-30 23:42:34 +02:00
|
|
|
{
|
|
|
|
// Unlocked
|
|
|
|
while(ed.free(tx,ty)==0) tx--;
|
|
|
|
while(ed.free(tx2,ty)==0) tx2++;
|
|
|
|
tx++;
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[i].p2=tx;
|
|
|
|
customentities[i].p3=(tx2-tx)*8;
|
2020-06-30 23:42:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Locked
|
2021-02-21 01:01:39 +01:00
|
|
|
tx = customentities[i].p2;
|
|
|
|
tx2 = tx + customentities[i].p3/8;
|
2020-06-30 23:42:34 +02:00
|
|
|
}
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((tx*8),(ty*8)+1, (tx2-tx)*8,6, graphics.getRGB(194, 255, 255));
|
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else //Vertical
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx=customentities[i].x-(ed.levx*40);
|
|
|
|
int ty=customentities[i].y-(ed.levy*30);
|
|
|
|
int ty2=customentities[i].y-(ed.levy*30);
|
|
|
|
if (customentities[i].p4 != 1)
|
2020-06-30 23:42:34 +02:00
|
|
|
{
|
|
|
|
// Unlocked
|
|
|
|
while(ed.free(tx,ty)==0) ty--;
|
|
|
|
while(ed.free(tx,ty2)==0) ty2++;
|
|
|
|
ty++;
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[i].p2=ty;
|
|
|
|
customentities[i].p3=(ty2-ty)*8;
|
2020-06-30 23:42:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Locked
|
2021-02-21 01:01:39 +01:00
|
|
|
ty = customentities[i].p2;
|
|
|
|
ty2 = ty + customentities[i].p3/8;
|
2020-06-30 23:42:34 +02:00
|
|
|
}
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((tx*8)+1,(ty*8), 6,(ty2-ty)*8, graphics.getRGB(194, 255, 255));
|
|
|
|
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164, 255, 255));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Need to also check warp point destinations
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].t==13 && ed.warpent!=i)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if (customentities[i].p1 / 40 == ed.levx && customentities[i].p2 / 30 == ed.levy)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
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);
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),16,16,graphics.getRGB(96, 64, 64));
|
2021-02-21 01:01:39 +01:00
|
|
|
if(ed.tilex+(ed.levx*40)==customentities[i].p1 && ed.tiley+(ed.levy*30)==customentities[i].p2)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
"("+help.String(customentities[i].x/40 + 1)+","+help.String(customentities[i].y/30 + 1)+")",190,190,225);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.boundarymod>0)
|
|
|
|
{
|
|
|
|
if(ed.boundarymod==1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs(ed.tilex*8, ed.tiley*8, 8,8,graphics.getRGB(210 + help.glow/2, 191 + help.glow, 255 - help.glow/2));
|
|
|
|
fillboxabs((ed.tilex*8)+2, (ed.tiley*8)+2, 4,4,graphics.getRGB(105 + help.glow/4, 100 + help.glow/2, 128 - help.glow/4));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.boundarymod==2)
|
|
|
|
{
|
|
|
|
if((ed.tilex*8)+8<=ed.boundx1 || (ed.tiley*8)+8<=ed.boundy1)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs(ed.boundx1, ed.boundy1, 8, 8,graphics.getRGB(210 + help.glow/2, 191 + help.glow, 255 - help.glow/2));
|
|
|
|
fillboxabs(ed.boundx1+2, ed.boundy1+2, 4, 4,graphics.getRGB(105 + help.glow/4, 100 + help.glow/2, 128 - help.glow/4));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs(ed.boundx1, ed.boundy1, (ed.tilex*8)+8-ed.boundx1,(ed.tiley*8)+8-ed.boundy1,graphics.getRGB(210 + help.glow/2, 191 + help.glow, 255 - help.glow/2));
|
|
|
|
fillboxabs(ed.boundx1+2, ed.boundy1+2, (ed.tilex*8)+8-ed.boundx1-4,(ed.tiley*8)+8-ed.boundy1-4,graphics.getRGB(105 + help.glow/4, 100 + help.glow/2, 128 - help.glow/4));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Draw boundaries
|
2021-08-28 22:03:04 +02:00
|
|
|
if(room->enemyx1!=0 || room->enemyy1!=0
|
|
|
|
|| room->enemyx2!=320 || room->enemyy2!=240)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-03-24 19:59:36 +01:00
|
|
|
fillboxabs( room->enemyx1, room->enemyy1,
|
|
|
|
room->enemyx2-room->enemyx1,
|
|
|
|
room->enemyy2-room->enemyy1,
|
2021-08-28 21:59:46 +02:00
|
|
|
graphics.getRGB(255-(help.glow/2),64,64));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-08-28 22:03:04 +02:00
|
|
|
if(room->platx1!=0 || room->platy1!=0
|
|
|
|
|| room->platx2!=320 || room->platy2!=240)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-03-24 19:59:36 +01:00
|
|
|
fillboxabs( room->platx1, room->platy1,
|
|
|
|
room->platx2-room->platx1,
|
|
|
|
room->platy2-room->platy1,
|
2021-08-28 21:59:46 +02:00
|
|
|
graphics.getRGB(64,64,255-(help.glow/2)));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
//Draw ghosts (spooky!)
|
|
|
|
if (game.ghostsenabled) {
|
2021-02-26 00:37:03 +01:00
|
|
|
ClearSurface(graphics.ghostbuffer);
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
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 :)
|
2020-06-14 03:35:12 +02:00
|
|
|
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy
|
2020-09-08 09:31:44 +02:00
|
|
|
|| !INBOUNDS_VEC(ed.ghosts[i].frame, graphics.sprites))
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
continue;
|
|
|
|
point tpoint;
|
|
|
|
tpoint.x = ed.ghosts[i].x;
|
|
|
|
tpoint.y = ed.ghosts[i].y;
|
2020-06-13 02:34:19 +02:00
|
|
|
graphics.setcolreal(ed.ghosts[i].realcol);
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
Uint32 alpha = graphics.ct.colour & graphics.backBuffer->format->Amask;
|
|
|
|
Uint32 therest = graphics.ct.colour & 0x00FFFFFF;
|
|
|
|
alpha = (3 * (alpha >> 24) / 4) << 24;
|
|
|
|
graphics.ct.colour = therest | alpha;
|
|
|
|
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, graphics.ct);
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 11:24:55 +02:00
|
|
|
SDL_BlitSurface(graphics.ghostbuffer, NULL, graphics.backBuffer, NULL);
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
}
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
//Draw Cursor
|
|
|
|
switch(ed.drawmode)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 12: //Single point
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),(ed.tiley*8),8,8, graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
case 13://2x2
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),(ed.tiley*8),16,16, graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7://Platform
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),(ed.tiley*8),32,8, graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 14: //X if not on edge
|
|
|
|
if(ed.tilex==0 || ed.tilex==39 || ed.tiley==0 || ed.tiley==29)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),(ed.tiley*8),8,8, graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print((ed.tilex*8),(ed.tiley*8),"X",255,0,0);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
case 15:
|
|
|
|
case 16: //2x3
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),(ed.tiley*8),16,24, graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.drawmode<3)
|
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
if(ed.bmod && ed.drawmode<2)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8),0,8,240,graphics.getRGB(32, 32, 200));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.hmod && ed.drawmode<2)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs(0,(ed.tiley*8),320,8,graphics.getRGB(32, 32, 200));
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
|
|
|
else if(ed.vmod && ed.drawmode<2)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8)-32,(ed.tiley*8)-32,24+48,24+48, graphics.getRGB(32, 32, 200));
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.cmod && ed.drawmode<2)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8)-24,(ed.tiley*8)-24,24+32,24+32, graphics.getRGB(32, 32, 200));
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.xmod && ed.drawmode<2)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8)-16,(ed.tiley*8)-16,24+16,24+16, graphics.getRGB(32, 32, 200));
|
2020-08-01 21:23:56 +02:00
|
|
|
}
|
|
|
|
else if(ed.zmod && ed.drawmode<2)
|
|
|
|
{
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs((ed.tilex*8)-8,(ed.tiley*8)-8,24,24, graphics.getRGB(32, 32, 200));
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//If in directmode, show current directmode tile
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->directmode==1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Tile box for direct mode
|
|
|
|
int t2=0;
|
|
|
|
if(ed.dmtileeditor>0)
|
|
|
|
{
|
|
|
|
if(ed.dmtileeditor<=4)
|
|
|
|
{
|
2021-03-10 00:42:55 +01:00
|
|
|
t2=graphics.lerp((4-ed.dmtileeditor+1)*12, (4-ed.dmtileeditor)*12);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Draw five lines of the editor
|
|
|
|
temp=ed.dmtile-(ed.dmtile%40);
|
|
|
|
temp-=80;
|
2020-03-31 21:52:10 +02:00
|
|
|
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));
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->tileset==0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-08-23 06:13:28 +02:00
|
|
|
const int numtiles = (((int) graphics.tiles.size()) / 40) * 40;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-08-23 06:13:28 +02:00
|
|
|
graphics.drawtile(i*8,0-t2,(temp+numtiles+i)%numtiles);
|
|
|
|
graphics.drawtile(i*8,8-t2,(temp+numtiles+40+i)%numtiles);
|
|
|
|
graphics.drawtile(i*8,16-t2,(temp+numtiles+80+i)%numtiles);
|
|
|
|
graphics.drawtile(i*8,24-t2,(temp+numtiles+120+i)%numtiles);
|
|
|
|
graphics.drawtile(i*8,32-t2,(temp+numtiles+160+i)%numtiles);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-23 06:13:28 +02:00
|
|
|
const int numtiles = (((int) graphics.tiles2.size()) / 40) * 40;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-08-23 06:13:28 +02:00
|
|
|
graphics.drawtile2(i*8,0-t2,(temp+numtiles+i)%numtiles);
|
|
|
|
graphics.drawtile2(i*8,8-t2,(temp+numtiles+40+i)%numtiles);
|
|
|
|
graphics.drawtile2(i*8,16-t2,(temp+numtiles+80+i)%numtiles);
|
|
|
|
graphics.drawtile2(i*8,24-t2,(temp+numtiles+120+i)%numtiles);
|
|
|
|
graphics.drawtile2(i*8,32-t2,(temp+numtiles+160+i)%numtiles);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//Highlight our little block
|
2021-09-07 05:08:00 +02:00
|
|
|
fillboxabs(((ed.dmtile%40)*8)-2,16-t2-2,12,12,graphics.getRGB(255 - help.glow, 196, 196));
|
2020-08-01 22:27:03 +02:00
|
|
|
fillboxabs(((ed.dmtile%40)*8)-1,16-t2-1,10,10,graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.dmtileeditor>0 && t2<=30)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2, 45-t2, "Tile:", 196, 196, 255 - help.glow, false);
|
|
|
|
graphics.bprint(58, 45-t2, help.String(ed.dmtile), 196, 196, 255 - help.glow, false);
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 44,44-t2,10,10, graphics.getRGB(255 - help.glow, 196, 196));
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 45,45-t2,8,8, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->tileset==0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(45,45-t2,ed.dmtile);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-02 00:47:35 +02:00
|
|
|
graphics.drawtile2(45,45-t2,ed.dmtile);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2, 12, "Tile:", 196, 196, 255 - help.glow, false);
|
|
|
|
graphics.bprint(58, 12, help.String(ed.dmtile), 196, 196, 255 - help.glow, false);
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 44,11,10,10, graphics.getRGB(255 - help.glow, 196, 196));
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 45,12,8,8, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->tileset==0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(45,12,ed.dmtile);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-02 00:47:35 +02:00
|
|
|
graphics.drawtile2(45,12,ed.dmtile);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw GUI
|
|
|
|
if(ed.boundarymod>0)
|
|
|
|
{
|
|
|
|
if(ed.boundarymod==1)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,230,320,240, graphics.getRGB(32,32,32));
|
|
|
|
FillRect(graphics.backBuffer, 0,231,320,240, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
switch(ed.boundarytype)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "SCRIPT BOX: Click on top left", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "ENEMY BOUNDS: Click on top left", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "PLATFORM BOUNDS: Click on top left", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "COPY TILES: Click on top left", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "Click on top left", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.boundarymod==2)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,230,320,240, graphics.getRGB(32,32,32));
|
|
|
|
FillRect(graphics.backBuffer, 0,231,320,240, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
switch(ed.boundarytype)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "SCRIPT BOX: Click on bottom right", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "ENEMY BOUNDS: Click on bottom right", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "PLATFORM BOUNDS: Click on bottom right", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "COPY TILES: Click on bottom right", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "Click on bottom right", 255,255,255, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.scripteditmod)
|
|
|
|
{
|
|
|
|
//Elaborate C64 BASIC menu goes here!
|
2021-08-28 21:59:46 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,0,320,240, graphics.getRGB(123, 111, 218));
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 14,16,292,208, graphics.getRGB(61, 48, 162));
|
2020-01-01 21:29:24 +01:00
|
|
|
switch(ed.scripthelppage)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,28,"**** VVVVVV SCRIPT EDITOR ****", 123, 111, 218, true);
|
|
|
|
graphics.Print(16,44,"PRESS ESC TO RETURN TO MENU", 123, 111, 218, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(!ed.hooklist.empty())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
for(int i=0; i<9; i++)
|
|
|
|
{
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(ed.hookmenupage+i<(int)ed.hooklist.size())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
if(ed.hookmenupage+i==ed.hookmenu)
|
|
|
|
{
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
std::string tstring="> " + ed.hooklist[(ed.hooklist.size()-1)-(ed.hookmenupage+i)] + " <";
|
2020-07-03 23:54:23 +02:00
|
|
|
for (size_t ii = 0; ii < tstring.length(); ii++)
|
|
|
|
{
|
|
|
|
tstring[ii] = SDL_toupper(tstring[ii]);
|
|
|
|
}
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,68+(i*16),tstring,123, 111, 218, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,68+(i*16),ed.hooklist[(ed.hooklist.size()-1)-(ed.hookmenupage+i)],123, 111, 218, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,110,"NO SCRIPT IDS FOUND", 123, 111, 218, true);
|
|
|
|
graphics.Print(16,130,"CREATE A SCRIPT WITH EITHER", 123, 111, 218, true);
|
|
|
|
graphics.Print(16,140,"THE TERMINAL OR SCRIPT BOX TOOLS", 123, 111, 218, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
//Current scriptname
|
2021-09-07 05:08:00 +02:00
|
|
|
FillRect(graphics.backBuffer, 14,226,292,12, graphics.getRGB(61, 48, 162));
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,228,"CURRENT SCRIPT: " + ed.sbscript, 123, 111, 218, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
//Draw text
|
|
|
|
for(int i=0; i<25; i++)
|
|
|
|
{
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(i+ed.pagey<(int)ed.sb.size())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16,20+(i*8),ed.sb[i+ed.pagey], 123, 111, 218, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//Draw cursor
|
|
|
|
if(ed.entframe<2)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(16+(ed.sbx*8),20+(ed.sby*8),"_",123, 111, 218, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.settingsmod)
|
|
|
|
{
|
2020-04-29 20:15:23 +02:00
|
|
|
if(!game.colourblindmode)
|
|
|
|
{
|
2020-11-03 00:23:53 +01:00
|
|
|
graphics.drawtowerbackground(graphics.titlebg);
|
2020-04-29 20:15:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-26 00:37:03 +01:00
|
|
|
ClearSurface(graphics.backBuffer);
|
2020-04-29 20:15:23 +02:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-01-08 02:37:38 +01:00
|
|
|
int tr = graphics.titlebg.r - (help.glow / 4) - int(fRandom() * 4);
|
|
|
|
int tg = graphics.titlebg.g - (help.glow / 4) - int(fRandom() * 4);
|
|
|
|
int tb = graphics.titlebg.b - (help.glow / 4) - int(fRandom() * 4);
|
2020-01-01 21:29:24 +01:00
|
|
|
if (tr < 0) tr = 0;
|
|
|
|
if(tr>255) tr=255;
|
|
|
|
if (tg < 0) tg = 0;
|
|
|
|
if(tg>255) tg=255;
|
|
|
|
if (tb < 0) tb = 0;
|
|
|
|
if(tb>255) tb=255;
|
2020-04-16 05:55:34 +02:00
|
|
|
editormenurender(tr, tg, tb);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
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
|
|
|
graphics.drawmenu(tr, tg, tb);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
else if (ed.textmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
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.Print(4, 224, ed.textdesc, 255, 255, 255, false);
|
|
|
|
std::string input = key.keybuffer;
|
|
|
|
if (ed.entframe < 2)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
input += "_";
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
input += " ";
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
graphics.Print(4, 232, input, 196, 196, 255 - help.glow, true);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.warpmod)
|
|
|
|
{
|
|
|
|
//placing warp token
|
2020-03-31 21:52:10 +02:00
|
|
|
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.Print(4, 224, "Left click to place warp destination", 196, 196, 255 - help.glow, false);
|
|
|
|
graphics.Print(4, 232, "Right click to cancel", 196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ed.spacemod)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,208,320,240, graphics.getRGB(32,32,32));
|
|
|
|
FillRect(graphics.backBuffer, 0,209,320,240, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Draw little icons for each thingy
|
|
|
|
int tx=6, ty=211, tg=32;
|
|
|
|
|
|
|
|
if(ed.spacemenu==0)
|
|
|
|
{
|
|
|
|
for(int i=0; i<10; i++)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 4+(ed.drawmode*tg), 209,20,20,graphics.getRGB(64,64,64));
|
2020-01-01 21:29:24 +01:00
|
|
|
//0:
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx,ty,83);
|
|
|
|
graphics.drawtile(tx+8,ty,83);
|
|
|
|
graphics.drawtile(tx,ty+8,83);
|
|
|
|
graphics.drawtile(tx+8,ty+8,83);
|
2020-01-01 21:29:24 +01:00
|
|
|
//1:
|
|
|
|
tx+=tg;
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx,ty,680);
|
|
|
|
graphics.drawtile(tx+8,ty,680);
|
|
|
|
graphics.drawtile(tx,ty+8,680);
|
|
|
|
graphics.drawtile(tx+8,ty+8,680);
|
2020-01-01 21:29:24 +01:00
|
|
|
//2:
|
|
|
|
tx+=tg;
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx+4,ty+4,8);
|
2020-01-01 21:29:24 +01:00
|
|
|
//3:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawsprite(tx,ty,22,196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
//4:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawsprite(tx,ty,21,196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
//5:
|
|
|
|
tx+=tg;
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx,ty+4,3);
|
|
|
|
graphics.drawtile(tx+8,ty+4,4);
|
2020-01-01 21:29:24 +01:00
|
|
|
//6:
|
|
|
|
tx+=tg;
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx,ty+4,24);
|
|
|
|
graphics.drawtile(tx+8,ty+4,24);
|
2020-01-01 21:29:24 +01:00
|
|
|
//7:
|
|
|
|
tx+=tg;
|
2020-04-02 00:42:22 +02:00
|
|
|
graphics.drawtile(tx,ty+4,1);
|
|
|
|
graphics.drawtile(tx+8,ty+4,1);
|
2020-01-01 21:29:24 +01:00
|
|
|
//8:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawsprite(tx,ty,78+ed.entframe,196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
//9:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, tx+2,ty+8,12,1,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Fix editor tool menu inconsistencies
This patch de-duplicates the tool drawing code a bit in the menu that
gets brought up when you press Space in the level editor, as well as
fixes several bugs related to the fact that the original author(s) of
the code decided to copy-paste everything. (It was most likely Terry,
judging by the distinct lack of whitespace between tokens in the code.)
There are two "pages" of tools that get shown when you open the tool
menu, according to your currently-selected tool.
1. On the first page, your currently-selected tool gets a brighter
outline. However, on the second page, the code to draw the outline over
your currently-selected tool is missing. So I've fixed that.
2. On the first page, the glyph indicator next to the tool icon also
gets brighter when you have that tool selected. However, on the
second page, the code that drew the brighter-colored indicator got
ran before the code that drew the normal-colored indicator, so this
was never shown. This is also fixed.
3. The glyph indicator of the gravity line tool didn't get brighter when
you had it selected, due to its special-cased copy-pasted code
drawing its brighter color before drawing its normal color. This has
also been fixed.
4. Lastly, the tool menu no longer draws the brighter-colored glyphs on
top of the normal-colored glyphs. Instead, the menu will simply draw
the brighter-colored glyphs and will not draw the normal-colored
glyphs in the first place. This is because double-drawing text like
this will look bad if the user has a custom font.png that has
translucent pixels, like I do.
All of these bugs have been fixed by paying off the technical debt of
copy-pasting code.
2021-01-11 06:10:03 +01:00
|
|
|
for (int i = 0; i < 10; i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
fillboxabs(4+(i*tg), 209,20,20,graphics.getRGB(96,96,96));
|
Fix editor tool menu inconsistencies
This patch de-duplicates the tool drawing code a bit in the menu that
gets brought up when you press Space in the level editor, as well as
fixes several bugs related to the fact that the original author(s) of
the code decided to copy-paste everything. (It was most likely Terry,
judging by the distinct lack of whitespace between tokens in the code.)
There are two "pages" of tools that get shown when you open the tool
menu, according to your currently-selected tool.
1. On the first page, your currently-selected tool gets a brighter
outline. However, on the second page, the code to draw the outline over
your currently-selected tool is missing. So I've fixed that.
2. On the first page, the glyph indicator next to the tool icon also
gets brighter when you have that tool selected. However, on the
second page, the code that drew the brighter-colored indicator got
ran before the code that drew the normal-colored indicator, so this
was never shown. This is also fixed.
3. The glyph indicator of the gravity line tool didn't get brighter when
you had it selected, due to its special-cased copy-pasted code
drawing its brighter color before drawing its normal color. This has
also been fixed.
4. Lastly, the tool menu no longer draws the brighter-colored glyphs on
top of the normal-colored glyphs. Instead, the menu will simply draw
the brighter-colored glyphs and will not draw the normal-colored
glyphs in the first place. This is because double-drawing text like
this will look bad if the user has a custom font.png that has
translucent pixels, like I do.
All of these bugs have been fixed by paying off the technical debt of
copy-pasting code.
2021-01-11 06:10:03 +01:00
|
|
|
const int col = i == ed.drawmode ? 255 : 164;
|
|
|
|
const std::string glyph = i == 9 ? "0" : help.String(i + 1);
|
|
|
|
graphics.Print(22 + i*tg - 4, 225 - 4, glyph, col, col, col, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
fillboxabs(4+(ed.drawmode*tg), 209,20,20,graphics.getRGB(200,200,200));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 232, "1/2", 196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i=0; i<7; i++)
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 4+(i*tg), 209,20,20,graphics.getRGB(32,32,32));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 4+((ed.drawmode-10)*tg), 209,20,20,graphics.getRGB(64,64,64));
|
2020-01-01 21:29:24 +01:00
|
|
|
//10:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(tx,ty,"A",196, 196, 255 - help.glow, false);
|
|
|
|
graphics.Print(tx+8,ty,"B",196, 196, 255 - help.glow, false);
|
|
|
|
graphics.Print(tx,ty+8,"C",196, 196, 255 - help.glow, false);
|
|
|
|
graphics.Print(tx+8,ty+8,"D",196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
//11:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawsprite(tx,ty,17,196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
//12:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
fillboxabs(tx+4,ty+4,8,8,graphics.getRGB(96,96,96));
|
2020-01-01 21:29:24 +01:00
|
|
|
//13:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawsprite(tx,ty,18+(ed.entframe%2),196,196,196);
|
2020-01-01 21:29:24 +01:00
|
|
|
//14:
|
|
|
|
tx+=tg;
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, tx+6,ty+2,4,12,graphics.getRGB(255,255,255));
|
2020-01-01 21:29:24 +01:00
|
|
|
//15:
|
|
|
|
tx+=tg;
|
2020-05-02 22:53:19 +02:00
|
|
|
graphics.drawsprite(tx,ty,186,graphics.col_crewblue);
|
2020-01-01 21:29:24 +01:00
|
|
|
//16:
|
|
|
|
tx+=tg;
|
2020-05-02 22:53:19 +02:00
|
|
|
graphics.drawsprite(tx,ty,184,graphics.col_crewcyan);
|
2020-03-31 21:52:10 +02:00
|
|
|
|
Fix editor tool menu inconsistencies
This patch de-duplicates the tool drawing code a bit in the menu that
gets brought up when you press Space in the level editor, as well as
fixes several bugs related to the fact that the original author(s) of
the code decided to copy-paste everything. (It was most likely Terry,
judging by the distinct lack of whitespace between tokens in the code.)
There are two "pages" of tools that get shown when you open the tool
menu, according to your currently-selected tool.
1. On the first page, your currently-selected tool gets a brighter
outline. However, on the second page, the code to draw the outline over
your currently-selected tool is missing. So I've fixed that.
2. On the first page, the glyph indicator next to the tool icon also
gets brighter when you have that tool selected. However, on the
second page, the code that drew the brighter-colored indicator got
ran before the code that drew the normal-colored indicator, so this
was never shown. This is also fixed.
3. The glyph indicator of the gravity line tool didn't get brighter when
you had it selected, due to its special-cased copy-pasted code
drawing its brighter color before drawing its normal color. This has
also been fixed.
4. Lastly, the tool menu no longer draws the brighter-colored glyphs on
top of the normal-colored glyphs. Instead, the menu will simply draw
the brighter-colored glyphs and will not draw the normal-colored
glyphs in the first place. This is because double-drawing text like
this will look bad if the user has a custom font.png that has
translucent pixels, like I do.
All of these bugs have been fixed by paying off the technical debt of
copy-pasting code.
2021-01-11 06:10:03 +01:00
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
fillboxabs(4 + i*tg, 209, 20, 20, graphics.getRGB(96, 96, 96));
|
|
|
|
const int col = i + 10 == ed.drawmode ? 255 : 164;
|
|
|
|
static const char glyphs[] = "RTYUIOP";
|
|
|
|
graphics.Print(22 + i*tg - 4, 225 - 4, std::string(1, glyphs[i]), col, col, col, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
fillboxabs(4 + (ed.drawmode - 10) * tg, 209, 20, 20, graphics.getRGB(200, 200, 200));
|
2020-03-31 21:52:10 +02:00
|
|
|
|
|
|
|
graphics.Print(4, 232, "2/2", 196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(128, 232, "< and > keys change tool", 196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,198,120,10, graphics.getRGB(32,32,32));
|
|
|
|
FillRect(graphics.backBuffer, 0,199,119,9, graphics.getRGB(0,0,0));
|
2020-01-01 21:29:24 +01:00
|
|
|
switch(ed.drawmode)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "1: Walls",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "2: Backing",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "3: Spikes",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "4: Trinkets",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "5: Checkpoint",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "6: Disappear",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "7: Conveyors",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "8: Moving",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "9: Enemies",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "0: Grav Line",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 10:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "R: Roomtext",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 11:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "T: Terminal",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 12:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "Y: Script Box",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 13:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "U: Warp Token",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 14:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "I: Warp Lines",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 15:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "O: Crewmate",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 16:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,199, "P: Start Point",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 260,198,80,10, graphics.getRGB(32,32,32));
|
|
|
|
FillRect(graphics.backBuffer, 261,199,80,9, 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);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
//FillRect(graphics.backBuffer, 0,230,72,240, graphics.RGB(32,32,32));
|
|
|
|
//FillRect(graphics.backBuffer, 0,231,71,240, graphics.RGB(0,0,0));
|
2021-03-24 19:59:36 +01:00
|
|
|
if(room->roomname!="")
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
if (graphics.translucentroomname)
|
2020-01-25 05:43:04 +01:00
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.footerrect.y = 230+ed.roomnamehide;
|
|
|
|
SDL_BlitSurface(graphics.footerbuffer, NULL, graphics.backBuffer, &graphics.footerrect);
|
2020-01-25 05:43:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,230+ed.roomnamehide,320,10, graphics.getRGB(0,0,0));
|
2020-01-25 05:43:04 +01:00
|
|
|
}
|
2021-03-24 19:59:36 +01:00
|
|
|
graphics.bprint(5,231+ed.roomnamehide,room->roomname, 196, 196, 255 - help.glow, true);
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(4, 222, "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);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(4, 232, "SPACE ^ SHIFT ^", 196, 196, 255 - help.glow, false);
|
|
|
|
graphics.bprint(268,232, "("+help.String(ed.levx+1)+","+help.String(ed.levy+1)+")",196, 196, 255 - help.glow, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.shiftmenu)
|
|
|
|
{
|
2021-01-11 05:26:21 +01:00
|
|
|
fillboxabs(0, 117,171+8,140,graphics.getRGB(64,64,64));
|
|
|
|
FillRect(graphics.backBuffer, 0,118,170+8,140, graphics.getRGB(0,0,0));
|
|
|
|
graphics.Print(4, 120, "F1: Change Tileset",164,164,164,false);
|
|
|
|
graphics.Print(4, 130, "F2: Change Colour",164,164,164,false);
|
|
|
|
graphics.Print(4, 140, "F3: Change Enemies",164,164,164,false);
|
|
|
|
graphics.Print(4, 150, "F4: Enemy Bounds",164,164,164,false);
|
|
|
|
graphics.Print(4, 160, "F5: Platform Bounds",164,164,164,false);
|
|
|
|
|
|
|
|
graphics.Print(4, 180, "F9: Reload Resources",164,164,164,false);
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.Print(4, 190, "F10: Direct Mode",164,164,164,false);
|
|
|
|
|
|
|
|
graphics.Print(4, 210, "W: Change Warp Dir",164,164,164,false);
|
|
|
|
graphics.Print(4, 220, "E: Change Roomname",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.Print(224, 210, "S: Save Map",164,164,164,false);
|
|
|
|
graphics.Print(224, 220, "L: Load Map",164,164,164,false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!ed.settingsmod && !ed.scripteditmod)
|
|
|
|
{
|
|
|
|
//Same as above, without borders
|
|
|
|
switch(ed.drawmode)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "1: Walls",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "2: Backing",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "3: Spikes",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "4: Trinkets",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "5: Checkpoint",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "6: Disappear",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "7: Conveyors",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "8: Moving",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "9: Enemies",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "0: Grav Line",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 10:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "R: Roomtext",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 11:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "T: Terminal",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 12:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "Y: Script Box",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 13:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "U: Warp Token",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 14:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "I: Warp Lines",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 15:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "O: Crewmate",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
case 16:
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.bprint(2,2, "P: Start Point",196, 196, 255 - help.glow);
|
2020-01-01 21:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-02 19:42:39 +02:00
|
|
|
if(ed.notedelay>0 || ed.oldnotedelay>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-05-02 19:42:39 +02:00
|
|
|
float alpha = graphics.lerp(ed.oldnotedelay, ed.notedelay);
|
2020-03-31 21:52:10 +02:00
|
|
|
FillRect(graphics.backBuffer, 0,115,320,18, graphics.getRGB(92,92,92));
|
|
|
|
FillRect(graphics.backBuffer, 0,116,320,16, graphics.getRGB(0,0,0));
|
2020-05-02 19:42:39 +02:00
|
|
|
graphics.Print(0,121, ed.note,196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), true);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.drawfade();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-27 04:29:40 +02:00
|
|
|
graphics.render();
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorrenderfixed(void)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-09-28 04:15:06 +02:00
|
|
|
extern editorclass ed;
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(ed.levx, ed.levy);
|
2020-05-02 22:53:19 +02:00
|
|
|
graphics.updatetitlecolours();
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
game.customcol=cl.getlevelcol(room->tileset, room->tilecol)+1;
|
|
|
|
ed.entcol=cl.getenemycol(game.customcol);
|
2020-05-02 22:53:19 +02:00
|
|
|
|
|
|
|
graphics.setcol(ed.entcol);
|
|
|
|
ed.entcolreal = graphics.ct.colour;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-06-13 02:24:08 +02:00
|
|
|
if (game.ghostsenabled)
|
|
|
|
{
|
2020-06-13 02:34:19 +02:00
|
|
|
for (size_t i = 0; i < ed.ghosts.size(); i++)
|
|
|
|
{
|
|
|
|
GhostInfo& ghost = ed.ghosts[i];
|
|
|
|
|
|
|
|
if ((int) i > ed.currentghosts || ghost.rx != ed.levx || ghost.ry != ed.levy)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
graphics.setcol(ghost.col);
|
|
|
|
ghost.realcol = graphics.ct.colour;
|
|
|
|
}
|
|
|
|
|
2020-06-13 02:24:08 +02:00
|
|
|
if (ed.currentghosts + 1 < (int)ed.ghosts.size()) {
|
|
|
|
ed.currentghosts++;
|
|
|
|
if (ed.zmod) ed.currentghosts++;
|
|
|
|
} else {
|
|
|
|
ed.currentghosts = (int)ed.ghosts.size() - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-29 19:37:56 +02:00
|
|
|
if (!ed.settingsmod)
|
|
|
|
{
|
2021-03-24 19:59:36 +01:00
|
|
|
switch(room->warpdir)
|
2020-04-29 19:37:56 +02:00
|
|
|
{
|
|
|
|
case 1:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-04-29 19:37:56 +02:00
|
|
|
graphics.updatebackground(3);
|
|
|
|
break;
|
2020-04-29 20:06:03 +02:00
|
|
|
case 2:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-04-29 20:06:03 +02:00
|
|
|
graphics.updatebackground(4);
|
|
|
|
break;
|
2020-04-30 00:37:39 +02:00
|
|
|
case 3:
|
2021-02-21 00:40:11 +01:00
|
|
|
graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy);
|
2020-04-30 00:37:39 +02:00
|
|
|
graphics.updatebackground(5);
|
|
|
|
break;
|
2020-04-29 19:37:56 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-30 00:25:01 +02:00
|
|
|
else if (!game.colourblindmode)
|
|
|
|
{
|
2020-11-03 00:23:53 +01:00
|
|
|
graphics.updatetowerbackground(graphics.titlebg);
|
2020-04-30 00:25:01 +02:00
|
|
|
}
|
2021-03-10 00:36:05 +01:00
|
|
|
|
|
|
|
/* Correct gravity lines */
|
2021-02-21 01:01:39 +01:00
|
|
|
for (size_t i = 0; i < customentities.size(); ++i)
|
2021-03-10 00:36:05 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if (customentities[i].x / 40 != ed.levx
|
|
|
|
|| customentities[i].y / 30 != ed.levy
|
|
|
|
|| customentities[i].t != 11
|
2021-03-10 00:36:05 +01:00
|
|
|
/* Is the gravity line locked? */
|
2021-02-21 01:01:39 +01:00
|
|
|
|| customentities[i].p4 == 1)
|
2021-03-10 00:36:05 +01:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-02-21 01:01:39 +01:00
|
|
|
if (customentities[i].p1 == 0)
|
2021-03-10 00:36:05 +01:00
|
|
|
{
|
|
|
|
/* Horizontal */
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx = customentities[i].x % 40;
|
2021-03-10 00:36:05 +01:00
|
|
|
int tx2 = tx;
|
2021-02-21 01:01:39 +01:00
|
|
|
int ty = customentities[i].y % 30;
|
2021-03-10 00:36:05 +01:00
|
|
|
while (!ed.spikefree(tx, ty))
|
|
|
|
{
|
|
|
|
--tx;
|
|
|
|
}
|
|
|
|
while (!ed.spikefree(tx2, ty))
|
|
|
|
{
|
|
|
|
++tx2;
|
|
|
|
}
|
|
|
|
++tx;
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[i].p2 = tx;
|
|
|
|
customentities[i].p3 = (tx2 - tx) * 8;
|
2021-03-10 00:36:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Vertical */
|
2021-02-21 01:01:39 +01:00
|
|
|
int tx = customentities[i].x % 40;
|
|
|
|
int ty = customentities[i].y % 30;
|
2021-03-10 00:36:05 +01:00
|
|
|
int ty2 = ty;
|
|
|
|
/* Unlocked */
|
|
|
|
while (!ed.spikefree(tx, ty))
|
|
|
|
{
|
|
|
|
--ty;
|
|
|
|
}
|
|
|
|
while (!ed.spikefree(tx, ty2))
|
|
|
|
{
|
|
|
|
++ty2;
|
|
|
|
}
|
|
|
|
++ty;
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[i].p2 = ty;
|
|
|
|
customentities[i].p3 = (ty2 - ty) * 8;
|
2021-03-10 00:36:05 +01:00
|
|
|
}
|
|
|
|
}
|
2021-03-10 00:41:19 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.getroomprop(ed.levx, ed.levy)->directmode == 1)
|
2021-03-10 00:41:19 +01:00
|
|
|
{
|
|
|
|
if (ed.dmtileeditor > 0)
|
|
|
|
{
|
|
|
|
ed.dmtileeditor--;
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 06:04:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.dmtileeditor = 0;
|
|
|
|
}
|
2021-03-10 00:42:06 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.getroomprop(ed.levx, ed.levy)->roomname != "")
|
2021-03-10 00:42:06 +01:00
|
|
|
{
|
|
|
|
if (ed.tiley < 28)
|
|
|
|
{
|
|
|
|
if (ed.roomnamehide > 0)
|
|
|
|
{
|
|
|
|
ed.roomnamehide--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ed.roomnamehide < 12)
|
|
|
|
{
|
|
|
|
ed.roomnamehide++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 06:05:36 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ed.tiley < 28)
|
|
|
|
{
|
|
|
|
ed.roomnamehide = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.roomnamehide = 12;
|
|
|
|
}
|
|
|
|
}
|
2020-11-08 00:47:49 +01:00
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorlogic(void)
|
2020-11-08 00:47:49 +01:00
|
|
|
{
|
|
|
|
extern editorclass ed;
|
|
|
|
//Misc
|
|
|
|
help.updateglow();
|
|
|
|
|
|
|
|
graphics.titlebg.bypos -= 2;
|
|
|
|
graphics.titlebg.bscroll = -2;
|
|
|
|
|
|
|
|
ed.entframedelay--;
|
|
|
|
if(ed.entframedelay<=0)
|
|
|
|
{
|
|
|
|
ed.entframe=(ed.entframe+1)%4;
|
|
|
|
ed.entframedelay=8;
|
|
|
|
}
|
|
|
|
|
|
|
|
ed.oldnotedelay = ed.notedelay;
|
|
|
|
if(ed.notedelay>0)
|
|
|
|
{
|
|
|
|
ed.notedelay--;
|
|
|
|
}
|
2020-04-29 19:37:56 +02:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
if (graphics.fademode == 1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Return to game
|
2020-11-03 00:23:53 +01:00
|
|
|
graphics.titlebg.colstate = 10;
|
2020-01-01 21:29:24 +01:00
|
|
|
map.nexttowercolour();
|
Clean up all exit paths to the menu to use common code
There are multiple different exit paths to the main menu. In 2.2, they
all had a bunch of copy-pasted code. In 2.3 currently, most of them use
game.quittomenu(), but there are some stragglers that still use
hand-copied code.
This is a bit of a problem, because all exit paths should consistently
have FILESYSTEM_unmountassets(), as part of the 2.3 feature of per-level
custom assets. Furthermore, most (but not all) of the paths call
script.hardreset() too, and some of the stragglers don't. So there could
be something persisting through to the title screen (like a really long
flash/shake timer) that could only persist if exiting to the title
screen through those paths.
But, actually, it seems like there's a good reason for some of those to
not call script.hardreset() - namely, dying or completing No Death Mode
and completing a Time Trial presents some information onscreen that
would get reset by script.hardreset(), so I'll fix that in a later
commit.
So what I've done for this commit is found every exit path that didn't
already use game.quittomenu(), and made them use game.quittomenu(). As
well, some of them had special handling that existed on top of them
already having a corresponding entry in game.quittomenu() (but the path
would take the special handling because it never did game.quittomenu()),
so I removed that special handling as well (e.g. exiting from a custom
level used returntomenu(Menu::levellist) when quittomenu() already had
that same returntomenu()).
The menu that exiting from the level editor returns to is now handled in
game.quittomenu() as well, where the map.custommode branch now also
checks for map.custommodeforreal. Unfortunately, it seems like entering
the level editor doesn't properly initialize map.custommode, so entering
the level editor now initializes map.custommode, too.
I've also taken the music.play(6) out of game.quittomenu(), because not
all exit paths immediately play Presenting VVVVVV, so all exit paths
that DO immediately play Presenting VVVVVV now have music.play(6)
special-cased for them, which is fine enough for me.
Here is the list of all exit paths to the menu:
- Exiting through the pause menu (without glitchrunner mode)
- Exiting through the pause menu (with glitchrunner mode)
- Completing a custom level
- Completing a Time Trial
- Dying in No Death Mode
- Completing No Death Mode
- Completing an Intermission replay
- Exiting from the level editor
- Completing the main game
2021-01-07 23:20:37 +01:00
|
|
|
game.quittomenu();
|
|
|
|
music.play(6); //should be before game.quittomenu()
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.settingsmod=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 05:14:40 +01:00
|
|
|
static void creategameoptions(void)
|
|
|
|
{
|
|
|
|
game.createmenu(Menu::options);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nextbgcolor(void)
|
|
|
|
{
|
|
|
|
map.nexttowercolour();
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-03-19 05:20:05 +01:00
|
|
|
static void editormenuactionpress(void)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
extern editorclass ed;
|
2020-04-17 00:19:17 +02:00
|
|
|
switch (game.currentmenuname)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2020-04-17 00:19:17 +02:00
|
|
|
case Menu::ed_desc:
|
2020-04-16 06:01:00 +02:00
|
|
|
switch (game.currentmenuoption)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2020-04-16 06:01:00 +02:00
|
|
|
case 0:
|
2020-04-16 05:52:21 +02:00
|
|
|
ed.titlemod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 01:04:50 +01:00
|
|
|
key.keybuffer=cl.title;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-16 05:52:21 +02:00
|
|
|
ed.creatormod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 01:04:50 +01:00
|
|
|
key.keybuffer=cl.creator;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-16 05:52:21 +02:00
|
|
|
ed.desc1mod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 00:40:11 +01:00
|
|
|
key.keybuffer=cl.Desc1;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-04-16 05:52:21 +02:00
|
|
|
ed.websitemod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 00:40:11 +01:00
|
|
|
key.keybuffer=cl.website;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-04-26 04:25:30 +02:00
|
|
|
game.returnmenu();
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
2021-06-11 21:52:28 +02:00
|
|
|
music.playef(11);
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
case Menu::ed_settings:
|
2020-04-16 06:01:00 +02:00
|
|
|
switch (game.currentmenuoption)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2020-04-16 06:01:00 +02:00
|
|
|
case 0:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Change level description stuff
|
|
|
|
music.playef(11);
|
2020-04-16 06:53:36 +02:00
|
|
|
game.createmenu(Menu::ed_desc);
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Enter script editormode
|
|
|
|
music.playef(11);
|
|
|
|
ed.scripteditmod=true;
|
|
|
|
ed.clearscriptbuffer();
|
|
|
|
key.keybuffer="";
|
|
|
|
ed.hookmenupage=0;
|
|
|
|
ed.hookmenu=0;
|
|
|
|
ed.scripthelppage=0;
|
|
|
|
ed.scripthelppagedelay=0;
|
|
|
|
ed.sby=0;
|
|
|
|
ed.sbx=0, ed.pagey=0;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-16 05:52:21 +02:00
|
|
|
music.playef(11);
|
2020-04-16 06:53:36 +02:00
|
|
|
game.createmenu(Menu::ed_music);
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2021-02-21 00:40:11 +01:00
|
|
|
if(cl.levmusic>0) music.play(cl.levmusic);
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
music.playef(11);
|
|
|
|
game.ghostsenabled = !game.ghostsenabled;
|
|
|
|
break;
|
|
|
|
case 4:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Load level
|
|
|
|
ed.settingsmod=false;
|
|
|
|
graphics.backgrounddrawn=false;
|
|
|
|
map.nexttowercolour();
|
|
|
|
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_LOAD, "Enter map filename to load:", &(ed.filename));
|
2020-04-16 05:52:21 +02:00
|
|
|
game.mapheld=true;
|
|
|
|
graphics.backgrounddrawn=false;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
case 5:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Save level
|
|
|
|
ed.settingsmod=false;
|
|
|
|
map.nexttowercolour();
|
|
|
|
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_SAVE, "Enter map filename to save as:", &(ed.filename));
|
2020-04-16 05:52:21 +02:00
|
|
|
game.mapheld=true;
|
|
|
|
graphics.backgrounddrawn=false;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
case 6:
|
2021-04-09 12:09:12 +02:00
|
|
|
/* Game options */
|
Add graphic options and game options to editor settings
This is a small quality-of-life tweak that makes it so if you're in the
middle of editing a level, you don't have to save the level, exit to the
menu, change whatever setting you wanted, re-enter the editor, and type
in the level name, just to change one setting. This is the same as
adding Graphic Options and Game Options to the in-game pause menu,
except for the editor, too.
To do this, I'm reusing Game::returntopausemenu() (because all of its
callers are the same callers for returning to editor settings) and
renamed it to returntoingame(), then added a variable named
ingame_editormode to Game. When we're in the options menus but still in
the editor, BOTH ingame_titlemode and ingame_editormode will be true.
2021-03-19 03:52:30 +01:00
|
|
|
music.playef(11);
|
|
|
|
game.gamestate = TITLEMODE;
|
|
|
|
game.ingame_titlemode = true;
|
|
|
|
game.ingame_editormode = true;
|
|
|
|
|
2021-04-09 12:09:12 +02:00
|
|
|
DEFER_CALLBACK(creategameoptions);
|
2021-03-19 05:14:40 +01:00
|
|
|
DEFER_CALLBACK(nextbgcolor);
|
Add graphic options and game options to editor settings
This is a small quality-of-life tweak that makes it so if you're in the
middle of editing a level, you don't have to save the level, exit to the
menu, change whatever setting you wanted, re-enter the editor, and type
in the level name, just to change one setting. This is the same as
adding Graphic Options and Game Options to the in-game pause menu,
except for the editor, too.
To do this, I'm reusing Game::returntopausemenu() (because all of its
callers are the same callers for returning to editor settings) and
renamed it to returntoingame(), then added a variable named
ingame_editormode to Game. When we're in the options menus but still in
the editor, BOTH ingame_titlemode and ingame_editormode will be true.
2021-03-19 03:52:30 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-04-16 05:52:21 +02:00
|
|
|
music.playef(11);
|
2020-04-16 06:53:36 +02:00
|
|
|
game.createmenu(Menu::ed_quit);
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
case Menu::ed_music:
|
2020-04-16 06:01:00 +02:00
|
|
|
switch (game.currentmenuoption)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2020-04-16 06:01:00 +02:00
|
|
|
case 0:
|
2021-03-05 09:55:57 +01:00
|
|
|
case 1:
|
|
|
|
switch (game.currentmenuoption)
|
|
|
|
{
|
|
|
|
case 0:
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.levmusic++;
|
2021-03-05 09:55:57 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.levmusic--;
|
2021-03-05 09:55:57 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.levmusic = (cl.levmusic % 16 + 16) % 16;
|
|
|
|
if(cl.levmusic>0)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
music.play(cl.levmusic);
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
music.haltdasmusik();
|
|
|
|
}
|
|
|
|
music.playef(11);
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
2021-03-05 09:55:57 +01:00
|
|
|
case 2:
|
2020-04-16 05:52:21 +02:00
|
|
|
music.playef(11);
|
|
|
|
music.fadeout();
|
2020-04-26 04:25:30 +02:00
|
|
|
game.returnmenu();
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
case Menu::ed_quit:
|
2020-04-16 06:01:00 +02:00
|
|
|
switch (game.currentmenuoption)
|
2020-04-16 05:52:21 +02:00
|
|
|
{
|
2020-04-16 06:01:00 +02:00
|
|
|
case 0:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Saving and quit
|
|
|
|
ed.saveandquit=true;
|
|
|
|
|
|
|
|
ed.settingsmod=false;
|
|
|
|
map.nexttowercolour();
|
|
|
|
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_SAVE, "Enter map filename to save as:", &(ed.filename));
|
2020-04-16 05:52:21 +02:00
|
|
|
game.mapheld=true;
|
|
|
|
graphics.backgrounddrawn=false;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Quit without saving
|
|
|
|
music.playef(11);
|
|
|
|
music.fadeout();
|
|
|
|
graphics.fademode = 2;
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-16 05:52:21 +02:00
|
|
|
//Go back to editor
|
|
|
|
music.playef(11);
|
2020-04-26 04:25:30 +02:00
|
|
|
game.returnmenu();
|
2020-04-16 05:52:21 +02:00
|
|
|
map.nexttowercolour();
|
2020-04-16 06:01:00 +02:00
|
|
|
break;
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
2020-04-17 00:19:17 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2020-04-16 05:52:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorinput(void)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-09-28 04:15:06 +02:00
|
|
|
extern editorclass ed;
|
2021-08-05 22:12:15 +02:00
|
|
|
if (graphics.fademode == 3 /* fading out */)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
game.mx = (float) key.mx;
|
|
|
|
game.my = (float) key.my;
|
|
|
|
ed.tilex=(game.mx - (game.mx%8))/8;
|
|
|
|
ed.tiley=(game.my - (game.my%8))/8;
|
Extern `gameScreen`, remove `screenbuffer`
I know earlier I removed the gameScreen extern in favor of using
screenbuffer, but that was only to be consistent. After further
consideration, I have found that it's actually really stupid.
There's no reason to be accessing it through screenbuffer, and it's
probably an artifact of 2.0-2.2 passing stack-allocated otherwise-global
classes everywhere through function arguments. Also, it leads to stupid
bugs where screenbuffer could potentially be NULL, which has already
resulted in various annoying crashes in the past. Although those could
be fixed by simply initializing screenbuffer at the very top of main(),
but, why not just scrap the whole thing anyway?
So that's what I'm doing.
As a nice side effect, I've removed the transitive include of Screen.h
from Graphics.h. This could've been done already since it only includes
it for the pointer anyway, but it's still good to do it now.
2021-12-25 08:56:47 +01:00
|
|
|
if (gameScreen.scalingMode == 1) {
|
2020-01-12 10:09:32 +01:00
|
|
|
// In this mode specifically, we have to fix the mouse coordinates
|
|
|
|
int winwidth, winheight;
|
Extern `gameScreen`, remove `screenbuffer`
I know earlier I removed the gameScreen extern in favor of using
screenbuffer, but that was only to be consistent. After further
consideration, I have found that it's actually really stupid.
There's no reason to be accessing it through screenbuffer, and it's
probably an artifact of 2.0-2.2 passing stack-allocated otherwise-global
classes everywhere through function arguments. Also, it leads to stupid
bugs where screenbuffer could potentially be NULL, which has already
resulted in various annoying crashes in the past. Although those could
be fixed by simply initializing screenbuffer at the very top of main(),
but, why not just scrap the whole thing anyway?
So that's what I'm doing.
As a nice side effect, I've removed the transitive include of Screen.h
from Graphics.h. This could've been done already since it only includes
it for the pointer anyway, but it's still good to do it now.
2021-12-25 08:56:47 +01:00
|
|
|
gameScreen.GetWindowSize(&winwidth, &winheight);
|
2020-01-12 10:09:32 +01:00
|
|
|
ed.tilex = ed.tilex * 320 / winwidth;
|
|
|
|
ed.tiley = ed.tiley * 240 / winheight;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 04:40:24 +02:00
|
|
|
bool up_pressed = key.isDown(SDLK_UP) || key.isDown(SDL_CONTROLLER_BUTTON_DPAD_UP);
|
|
|
|
bool down_pressed = key.isDown(SDLK_DOWN) || key.isDown(SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
|
|
|
bool left_pressed = key.isDown(SDLK_LEFT) || key.isDown(SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
|
|
|
bool right_pressed = key.isDown(SDLK_RIGHT) || key.isDown(SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
2020-07-01 02:39:32 +02:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
game.press_left = false;
|
|
|
|
game.press_right = false;
|
|
|
|
game.press_action = false;
|
|
|
|
game.press_map = false;
|
2021-04-19 08:23:44 +02:00
|
|
|
game.press_interact = false;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 02:39:32 +02:00
|
|
|
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_a) || key.controllerWantsLeft(false))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.press_left = true;
|
|
|
|
}
|
2020-07-01 02:39:32 +02:00
|
|
|
if (key.isDown(KEYBOARD_RIGHT) || key.isDown(KEYBOARD_d) || key.controllerWantsRight(false))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.press_right = true;
|
|
|
|
}
|
2020-07-01 02:39:32 +02:00
|
|
|
if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.press_action = true;
|
|
|
|
};
|
|
|
|
|
2020-06-01 01:31:02 +02:00
|
|
|
if (key.keymap[SDLK_F9] && (ed.keydelay==0)) {
|
|
|
|
ed.keydelay = 30;
|
|
|
|
ed.note="Reloaded resources";
|
|
|
|
ed.notedelay=45;
|
|
|
|
graphics.reloadresources();
|
|
|
|
}
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
|
|
|
|
if (key.isDown(27) && !ed.settingskey)
|
|
|
|
{
|
|
|
|
ed.settingskey=true;
|
2020-07-01 08:17:26 +02:00
|
|
|
if (ed.textmod)
|
|
|
|
{
|
|
|
|
key.disabletextentry();
|
|
|
|
if (ed.textmod >= FIRST_ENTTEXT && ed.textmod <= LAST_ENTTEXT)
|
|
|
|
{
|
|
|
|
*ed.textptr = ed.oldenttext;
|
|
|
|
if (ed.oldenttext == "")
|
|
|
|
{
|
|
|
|
removeedentity(ed.textent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ed.textmod = TEXT_NONE;
|
|
|
|
|
|
|
|
ed.shiftmenu = false;
|
|
|
|
ed.shiftkey = false;
|
|
|
|
}
|
Axe manual state trackers and use SDL_IsTextInputActive()
After looking at pull request #446, I got a bit annoyed that we have TWO
variables, key.textentrymode and ed.textentry, that we rolled ourselves
to track the state of something SDL already provides us a function to
easily query: SDL_IsTextInputActive(). We don't need to have either of
these two variables, and we shouldn't.
So that's what I do in this patch. Both variables have been axed in
favor of using this function, and I just made a wrapper out of it, named
key.textentry().
For bonus points, this gets rid of the ugly NO_CUSTOM_LEVELS and
NO_EDITOR ifdef in main.cpp, since text entry is enabled when entering
the script list and disabled when exiting it. This makes the code there
easier to read, too.
Furthermore, apparently key.textentrymode was initialized to *true*
instead of false... for whatever reason. But that's gone now, too.
Now, you'd think there wouldn't be any downside to using
SDL_IsTextInputActive(). After all, it's a function that SDL itself
provides, right?
Wrong. For whatever reason, it seems like text input is active *from the
start of the program*, meaning that what would happen is I would go into
the editor, and find that I can't move around nor place tiles nor
anything else. Then I would press Esc, and then suddenly become able to
do those things I wanted to do before.
I have no idea why the above happens, but all I can do is to just insert
an SDL_StopTextInput() immediately after the SDL_Init() in main.cpp. Of
course, I have to surround it with an SDL_IsTextInputActive() check to
make sure I don't do anything extraneous by stopping input when it's
already stopped.
2020-08-13 08:43:25 +02:00
|
|
|
else if (key.textentry())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
key.disabletextentry();
|
|
|
|
ed.titlemod=false;
|
|
|
|
ed.desc1mod=false;
|
|
|
|
ed.desc2mod=false;
|
|
|
|
ed.desc3mod=false;
|
|
|
|
ed.websitemod=false;
|
|
|
|
ed.creatormod=false;
|
2021-06-11 21:52:28 +02:00
|
|
|
music.playef(11);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
ed.shiftmenu=false;
|
|
|
|
ed.shiftkey=false;
|
|
|
|
}
|
|
|
|
else if(ed.boundarymod>0)
|
|
|
|
{
|
|
|
|
ed.boundarymod=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2021-02-22 09:28:43 +01:00
|
|
|
music.playef(11);
|
|
|
|
if (ed.settingsmod)
|
|
|
|
{
|
|
|
|
if (ed.scripteditmod)
|
|
|
|
{
|
|
|
|
ed.scripteditmod = false;
|
|
|
|
}
|
|
|
|
else if (ed.settingsmod)
|
|
|
|
{
|
|
|
|
if (game.currentmenuname == Menu::ed_settings)
|
|
|
|
{
|
|
|
|
ed.settingsmod = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game.returnmenu();
|
|
|
|
map.nexttowercolour();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.settingsmod = true;
|
|
|
|
}
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.backgrounddrawn=false;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-26 04:37:33 +02:00
|
|
|
if (ed.settingsmod)
|
|
|
|
{
|
2021-04-18 18:55:11 +02:00
|
|
|
bool edsettings_in_stack = game.currentmenuname == Menu::ed_settings;
|
|
|
|
if (!edsettings_in_stack)
|
2020-04-26 04:37:33 +02:00
|
|
|
{
|
2021-04-18 18:55:11 +02:00
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < game.menustack.size(); ++i)
|
2020-04-26 04:37:33 +02:00
|
|
|
{
|
2021-04-18 18:55:11 +02:00
|
|
|
if (game.menustack[i].name == Menu::ed_settings)
|
|
|
|
{
|
|
|
|
edsettings_in_stack = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-04-26 04:37:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (edsettings_in_stack)
|
|
|
|
{
|
|
|
|
game.returntomenu(Menu::ed_settings);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game.createmenu(Menu::ed_settings);
|
|
|
|
}
|
|
|
|
map.nexttowercolour();
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!key.isDown(27))
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
//hook select menu
|
|
|
|
if(ed.keydelay>0) ed.keydelay--;
|
|
|
|
|
2020-07-01 02:39:32 +02:00
|
|
|
if(up_pressed && ed.keydelay<=0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
ed.hookmenu--;
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:39:32 +02:00
|
|
|
if(down_pressed && ed.keydelay<=0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
ed.hookmenu++;
|
|
|
|
}
|
|
|
|
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(ed.hookmenu>=(int)ed.hooklist.size())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
ed.hookmenu=ed.hooklist.size()-1;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
if(ed.hookmenu<0) ed.hookmenu=0;
|
|
|
|
|
|
|
|
if(ed.hookmenu<ed.hookmenupage)
|
|
|
|
{
|
|
|
|
ed.hookmenupage=ed.hookmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.hookmenu>=ed.hookmenupage+9)
|
|
|
|
{
|
|
|
|
ed.hookmenupage=ed.hookmenu+8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!key.keymap[SDLK_BACKSPACE]) ed.deletekeyheld=0;
|
|
|
|
|
2020-04-03 21:23:37 +02:00
|
|
|
if(key.keymap[SDLK_BACKSPACE] && ed.deletekeyheld==0 && !ed.hooklist.empty())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.deletekeyheld=1;
|
|
|
|
music.playef(2);
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
ed.removehook(ed.hooklist[(ed.hooklist.size()-1)-ed.hookmenu]);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!game.press_action && !game.press_left && !game.press_right
|
2020-07-01 02:39:32 +02:00
|
|
|
&& !up_pressed && !down_pressed && !key.isDown(27)) game.jumpheld = false;
|
2020-01-01 21:29:24 +01:00
|
|
|
if (!game.jumpheld)
|
|
|
|
{
|
|
|
|
if (game.press_action || game.press_left || game.press_right || game.press_map
|
2020-07-01 02:39:32 +02:00
|
|
|
|| up_pressed || down_pressed || key.isDown(27))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.jumpheld = true;
|
|
|
|
}
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if ((game.press_action || game.press_map) && !ed.hooklist.empty())
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.mapheld=true;
|
|
|
|
ed.scripthelppage=1;
|
2020-08-18 00:39:19 +02:00
|
|
|
key.enabletextentry();
|
2020-01-01 21:29:24 +01:00
|
|
|
key.keybuffer="";
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
ed.sbscript=ed.hooklist[(ed.hooklist.size()-1)-ed.hookmenu];
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.loadhookineditor(ed.sbscript);
|
|
|
|
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
ed.sby=ed.sb.size()-1;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.pagey=0;
|
|
|
|
while(ed.sby>=20)
|
|
|
|
{
|
|
|
|
ed.pagey++;
|
|
|
|
ed.sby--;
|
|
|
|
}
|
|
|
|
key.keybuffer=ed.sb[ed.pagey+ed.sby];
|
2020-01-31 19:25:37 +01:00
|
|
|
ed.sbx = utf8::unchecked::distance(ed.sb[ed.pagey+ed.sby].begin(), ed.sb[ed.pagey+ed.sby].end());
|
2021-08-12 04:43:33 +02:00
|
|
|
music.playef(11);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.scripthelppage==1)
|
|
|
|
{
|
|
|
|
//Script editor!
|
|
|
|
if (key.isDown(27))
|
|
|
|
{
|
|
|
|
ed.scripthelppage=0;
|
|
|
|
game.jumpheld = true;
|
|
|
|
//save the script for use again!
|
|
|
|
ed.addhook(ed.sbscript);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ed.keydelay>0) ed.keydelay--;
|
|
|
|
|
2020-07-01 02:39:32 +02:00
|
|
|
if(up_pressed && ed.keydelay<=0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
ed.sby--;
|
|
|
|
if(ed.sby<=5)
|
|
|
|
{
|
|
|
|
if(ed.pagey>0)
|
|
|
|
{
|
|
|
|
ed.pagey--;
|
|
|
|
ed.sby++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ed.sby<0) ed.sby=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key.keybuffer=ed.sb[ed.pagey+ed.sby];
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:39:32 +02:00
|
|
|
if(down_pressed && ed.keydelay<=0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(ed.sby+ed.pagey<(int)ed.sb.size()-1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.sby++;
|
|
|
|
if(ed.sby>=20)
|
|
|
|
{
|
|
|
|
ed.pagey++;
|
|
|
|
ed.sby--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key.keybuffer=ed.sb[ed.pagey+ed.sby];
|
|
|
|
}
|
|
|
|
|
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 03:17:46 +01:00
|
|
|
if(key.linealreadyemptykludge)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
key.linealreadyemptykludge=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(key.pressedbackspace && ed.sb[ed.pagey+ed.sby]=="" && ed.keydelay<=0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Remove this line completely
|
|
|
|
ed.removeline(ed.pagey+ed.sby);
|
|
|
|
ed.sby--;
|
|
|
|
if(ed.sby<=5)
|
|
|
|
{
|
|
|
|
if(ed.pagey>0)
|
|
|
|
{
|
|
|
|
ed.pagey--;
|
|
|
|
ed.sby++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ed.sby<0) ed.sby=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key.keybuffer=ed.sb[ed.pagey+ed.sby];
|
2020-01-19 03:39:39 +01:00
|
|
|
ed.keydelay=6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2021-04-20 20:29:50 +02:00
|
|
|
/* Remove all pipes, they are the line separator in the XML
|
|
|
|
* When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */
|
|
|
|
{size_t i; for (i = key.keybuffer.length() - 1; i + 1 > 0; --i)
|
|
|
|
{
|
|
|
|
if (key.keybuffer[i] == '|')
|
|
|
|
{
|
|
|
|
key.keybuffer.erase(key.keybuffer.begin() + i);
|
|
|
|
}
|
|
|
|
}}
|
2020-09-28 00:14:42 +02:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.sb[ed.pagey+ed.sby]=key.keybuffer;
|
2020-01-31 19:25:37 +01:00
|
|
|
ed.sbx = utf8::unchecked::distance(ed.sb[ed.pagey+ed.sby].begin(), ed.sb[ed.pagey+ed.sby].end());
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
if(!game.press_map && !key.isDown(27)) game.mapheld=false;
|
|
|
|
if (!game.mapheld)
|
|
|
|
{
|
|
|
|
if(game.press_map)
|
|
|
|
{
|
|
|
|
game.mapheld=true;
|
|
|
|
//Continue to next line
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
if(ed.sby+ed.pagey>=(int)ed.sb.size()) //we're on the last line
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.sby++;
|
|
|
|
if(ed.sby>=20)
|
|
|
|
{
|
|
|
|
ed.pagey++;
|
|
|
|
ed.sby--;
|
|
|
|
}
|
|
|
|
key.keybuffer=ed.sb[ed.pagey+ed.sby];
|
2020-01-31 19:25:37 +01:00
|
|
|
ed.sbx = utf8::unchecked::distance(ed.sb[ed.pagey+ed.sby].begin(), ed.sb[ed.pagey+ed.sby].end());
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//We're not, insert a line instead
|
|
|
|
ed.sby++;
|
|
|
|
if(ed.sby>=20)
|
|
|
|
{
|
|
|
|
ed.pagey++;
|
|
|
|
ed.sby--;
|
|
|
|
}
|
|
|
|
ed.insertline(ed.sby+ed.pagey);
|
|
|
|
key.keybuffer="";
|
|
|
|
ed.sbx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
else if (ed.textmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
*ed.textptr = key.keybuffer;
|
|
|
|
|
|
|
|
if (!game.press_map && !key.isDown(27))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
game.mapheld = false;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
if (!game.mapheld && game.press_map)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
game.mapheld = true;
|
|
|
|
key.disabletextentry();
|
|
|
|
switch (ed.textmod)
|
|
|
|
{
|
2020-07-01 08:35:59 +02:00
|
|
|
case TEXT_GOTOROOM:
|
|
|
|
{
|
2021-02-12 02:02:32 +01:00
|
|
|
char coord_x[16];
|
|
|
|
char coord_y[16];
|
|
|
|
|
|
|
|
const char* comma = SDL_strchr(key.keybuffer.c_str(), ',');
|
|
|
|
|
|
|
|
bool valid_input = comma != NULL;
|
|
|
|
|
|
|
|
if (valid_input)
|
|
|
|
{
|
|
|
|
SDL_strlcpy(
|
|
|
|
coord_x,
|
|
|
|
key.keybuffer.c_str(),
|
Remove `VVV_min/max` in favor of `SDL_min/max`
VVV_min/max are functions that only operate on ints, and SDL_min/max are
macros that operate on any type but double-evaluate everything.
I know I more-or-less said earlier that SDL_min/max were dumb but I've
changed my mind and think it's better to use them, taking care to make
sure you don't double-evaluate, rather than trying to generate your own
litany of functions with either your own hand-rolled generation macros,
C++ templates, C11 generics, or GCC extensions (that last one you'd
technically use in a macro but it doesn't really matter), all of which
have more downsides than just not double-evaluating.
And the upside of not double-evaluating is that you're disencouraged
from having really complicated single-line min/max expressions and
encouraged to precompute the values beforehand anyway so the final
min/max is more readable. And furthermore you'll notice when you
yourself end up doing double-evaluations anyway. I removed a couple
instances of Graphics::len() being double-evaluated in this commit (as
well as cleaned up some other min/max-using code). Although the only
downside to those double-evaluations was unnecessary computation,
rather than checking the wrong result or having multiple side effects,
thankfully, it's still good to minimize double-evaluations where
possible.
2021-12-23 01:43:31 +01:00
|
|
|
SDL_min((size_t) (comma - key.keybuffer.c_str() + 1), sizeof(coord_x))
|
2021-02-12 02:02:32 +01:00
|
|
|
);
|
|
|
|
SDL_strlcpy(coord_y, &comma[1], sizeof(coord_y));
|
|
|
|
|
|
|
|
valid_input = is_number(coord_x) && is_number(coord_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!valid_input)
|
2020-07-01 08:35:59 +02:00
|
|
|
{
|
|
|
|
ed.note = "[ ERROR: Invalid format ]";
|
|
|
|
ed.notedelay = 45;
|
|
|
|
break;
|
|
|
|
}
|
2021-02-12 02:02:32 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
ed.levx = clamp(help.Int(coord_x) - 1, 0, cl.mapwidth - 1);
|
|
|
|
ed.levy = clamp(help.Int(coord_y) - 1, 0, cl.mapheight - 1);
|
2020-07-01 08:35:59 +02:00
|
|
|
graphics.backgrounddrawn = false;
|
|
|
|
break;
|
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
case TEXT_LOAD:
|
|
|
|
{
|
|
|
|
std::string loadstring = ed.filename + ".vvvvvv";
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.load(loadstring))
|
2020-07-01 08:17:26 +02:00
|
|
|
{
|
|
|
|
// don't use filename, it has the full path
|
|
|
|
char buffer[64];
|
|
|
|
SDL_snprintf(buffer, sizeof(buffer), "[ Loaded map: %s.vvvvvv ]", ed.filename.c_str());
|
|
|
|
ed.note = buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.note = "[ ERROR: Could not load level ]";
|
|
|
|
}
|
|
|
|
ed.notedelay = 45;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TEXT_SAVE:
|
|
|
|
{
|
|
|
|
std::string savestring = ed.filename + ".vvvvvv";
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.save(savestring))
|
2020-07-01 08:17:26 +02:00
|
|
|
{
|
|
|
|
char buffer[64];
|
|
|
|
SDL_snprintf(buffer, sizeof(buffer), "[ Saved map: %s.vvvvvv ]", ed.filename.c_str());
|
|
|
|
ed.note = buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.note = "[ ERROR: Could not save level! ]";
|
|
|
|
ed.saveandquit = false;
|
|
|
|
}
|
|
|
|
ed.notedelay = 45;
|
|
|
|
|
|
|
|
if (ed.saveandquit)
|
|
|
|
{
|
|
|
|
graphics.fademode = 2; // quit editor
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TEXT_SCRIPT:
|
|
|
|
ed.clearscriptbuffer();
|
|
|
|
if (!ed.checkhook(key.keybuffer))
|
|
|
|
{
|
|
|
|
ed.addhook(key.keybuffer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ed.shiftmenu = false;
|
|
|
|
ed.shiftkey = false;
|
|
|
|
ed.textmod = TEXT_NONE;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 08:17:26 +02:00
|
|
|
}
|
Axe manual state trackers and use SDL_IsTextInputActive()
After looking at pull request #446, I got a bit annoyed that we have TWO
variables, key.textentrymode and ed.textentry, that we rolled ourselves
to track the state of something SDL already provides us a function to
easily query: SDL_IsTextInputActive(). We don't need to have either of
these two variables, and we shouldn't.
So that's what I do in this patch. Both variables have been axed in
favor of using this function, and I just made a wrapper out of it, named
key.textentry().
For bonus points, this gets rid of the ugly NO_CUSTOM_LEVELS and
NO_EDITOR ifdef in main.cpp, since text entry is enabled when entering
the script list and disabled when exiting it. This makes the code there
easier to read, too.
Furthermore, apparently key.textentrymode was initialized to *true*
instead of false... for whatever reason. But that's gone now, too.
Now, you'd think there wouldn't be any downside to using
SDL_IsTextInputActive(). After all, it's a function that SDL itself
provides, right?
Wrong. For whatever reason, it seems like text input is active *from the
start of the program*, meaning that what would happen is I would go into
the editor, and find that I can't move around nor place tiles nor
anything else. Then I would press Esc, and then suddenly become able to
do those things I wanted to do before.
I have no idea why the above happens, but all I can do is to just insert
an SDL_StopTextInput() immediately after the SDL_Init() in main.cpp. Of
course, I have to surround it with an SDL_IsTextInputActive() check to
make sure I don't do anything extraneous by stopping input when it's
already stopped.
2020-08-13 08:43:25 +02:00
|
|
|
else if (key.textentry())
|
2020-07-01 08:17:26 +02:00
|
|
|
{
|
|
|
|
if(ed.titlemod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
cl.title=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.creatormod)
|
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
cl.creator=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.websitemod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.website=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc1mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc1=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc2mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc2=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc3mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc3=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!game.press_map && !key.isDown(27)) game.mapheld=false;
|
|
|
|
if (!game.mapheld)
|
|
|
|
{
|
|
|
|
if(game.press_map)
|
|
|
|
{
|
|
|
|
game.mapheld=true;
|
2020-07-01 08:17:26 +02:00
|
|
|
if(ed.titlemod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
cl.title=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.titlemod=false;
|
|
|
|
}
|
|
|
|
else if(ed.creatormod)
|
|
|
|
{
|
2021-02-21 01:04:50 +01:00
|
|
|
cl.creator=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.creatormod=false;
|
|
|
|
}
|
|
|
|
else if(ed.websitemod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.website=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.websitemod=false;
|
|
|
|
}
|
|
|
|
else if(ed.desc1mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc1=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc2mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc2=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc3mod)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.Desc3=key.keybuffer;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.desc3mod=false;
|
|
|
|
}
|
|
|
|
key.disabletextentry();
|
|
|
|
|
|
|
|
if(ed.desc1mod)
|
|
|
|
{
|
|
|
|
ed.desc1mod=false;
|
|
|
|
|
|
|
|
ed.desc2mod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 00:40:11 +01:00
|
|
|
key.keybuffer=cl.Desc2;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.desc2mod)
|
|
|
|
{
|
|
|
|
ed.desc2mod=false;
|
|
|
|
|
|
|
|
ed.desc3mod=true;
|
|
|
|
key.enabletextentry();
|
2021-02-21 00:40:11 +01:00
|
|
|
key.keybuffer=cl.Desc3;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-06-11 21:52:28 +02:00
|
|
|
music.playef(11);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ed.settingsmod)
|
|
|
|
{
|
|
|
|
if (!game.press_action && !game.press_left && !game.press_right
|
2020-07-01 02:39:32 +02:00
|
|
|
&& !up_pressed && !down_pressed) game.jumpheld = false;
|
2020-01-01 21:29:24 +01:00
|
|
|
if (!game.jumpheld)
|
|
|
|
{
|
|
|
|
if (game.press_action || game.press_left || game.press_right || game.press_map
|
2020-07-01 02:39:32 +02:00
|
|
|
|| up_pressed || down_pressed)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.jumpheld = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(game.menustart)
|
|
|
|
{
|
2020-07-01 02:39:32 +02:00
|
|
|
if (game.press_left || up_pressed)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.currentmenuoption--;
|
|
|
|
}
|
2020-07-01 02:39:32 +02:00
|
|
|
else if (game.press_right || down_pressed)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
game.currentmenuoption++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor menu creation code
Firstly, menu options are no longer ad-hoc objects, and are added by
using Game::option() (this is the biggest change). This removes the
vector Game::menuoptionsactive, and Game::menuoptions is now a vector of
MenuOption instead of std::string.
Secondly, the manual tracker variable of the amount of menu options,
Game::nummenuoptions, has been removed, in favor of using vectors
properly and using Game::menuoptions::size().
As a result, a lot of copy-pasted code has been removed from
Game::createmenu(), mostly due to having to have different versions of
menus depending on whether or not we have certain defines, or having an
mmmmmm.vvv file inside the VVVVVV directory. In the old days, you
couldn't just add or remove a menu option conveniently, you had to
shuffle around the position of every other menu option too, which
resulted in lots of copy-pasted code. But now this copy-pasted code has
been de-duplicated, at least in Game::createmenu().
2020-04-15 06:50:17 +02:00
|
|
|
if (game.currentmenuoption < 0) game.currentmenuoption = game.menuoptions.size()-1;
|
|
|
|
if (game.currentmenuoption >= (int) game.menuoptions.size() ) game.currentmenuoption = 0;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
if (game.press_action)
|
|
|
|
{
|
2020-04-16 05:52:21 +02:00
|
|
|
editormenuactionpress();
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
else if (ed.keydelay > 0)
|
|
|
|
{
|
|
|
|
ed.keydelay--;
|
|
|
|
}
|
|
|
|
else if (key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL])
|
|
|
|
{
|
|
|
|
// Ctrl modifiers
|
2021-08-23 06:13:28 +02:00
|
|
|
int numtiles;
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.getroomprop(ed.levx, ed.levy)->tileset == 0)
|
2021-08-23 06:13:28 +02:00
|
|
|
{
|
|
|
|
numtiles = (((int) graphics.tiles.size()) / 40) * 40;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numtiles = (((int) graphics.tiles2.size()) / 40) * 40;
|
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
ed.dmtileeditor=10;
|
|
|
|
if(left_pressed)
|
|
|
|
{
|
|
|
|
ed.dmtile--;
|
|
|
|
ed.keydelay=3;
|
2021-08-23 06:13:28 +02:00
|
|
|
if(ed.dmtile<0) ed.dmtile+=numtiles;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
else if(right_pressed)
|
|
|
|
{
|
|
|
|
ed.dmtile++;
|
|
|
|
ed.keydelay=3;
|
|
|
|
|
2021-08-23 06:13:28 +02:00
|
|
|
if(ed.dmtile>=numtiles) ed.dmtile-=numtiles;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
if(up_pressed)
|
|
|
|
{
|
|
|
|
ed.dmtile-=40;
|
|
|
|
ed.keydelay=3;
|
2021-08-23 06:13:28 +02:00
|
|
|
if(ed.dmtile<0) ed.dmtile+=numtiles;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
else if(down_pressed)
|
|
|
|
{
|
|
|
|
ed.dmtile+=40;
|
|
|
|
ed.keydelay=3;
|
|
|
|
|
2021-08-23 06:13:28 +02:00
|
|
|
if(ed.dmtile>=numtiles) ed.dmtile-=numtiles;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key.keymap[SDLK_LSHIFT] || key.keymap[SDLK_RSHIFT])
|
|
|
|
{
|
|
|
|
// Shift modifiers
|
2020-07-01 06:53:11 +02:00
|
|
|
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])
|
|
|
|
{
|
|
|
|
ed.switch_enemy(true);
|
|
|
|
ed.keydelay=6;
|
|
|
|
}
|
2021-08-23 05:51:51 +02:00
|
|
|
if (key.keymap[SDLK_w])
|
|
|
|
{
|
|
|
|
ed.switch_warpdir(true);
|
|
|
|
graphics.backgrounddrawn = false;
|
|
|
|
ed.keydelay = 6;
|
|
|
|
}
|
2020-07-01 06:53:11 +02:00
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if (up_pressed || down_pressed || left_pressed || right_pressed)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
if(up_pressed)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.mapheight--;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
else if(down_pressed)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.mapheight++;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
else if(left_pressed)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.mapwidth--;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
else if(right_pressed)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.mapwidth++;
|
2020-07-01 05:39:36 +02:00
|
|
|
}
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
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;
|
|
|
|
ed.note = "Mapsize is now [" + help.String(cl.mapwidth) + "," + help.String(cl.mapheight) + "]";
|
2020-07-01 05:39:36 +02:00
|
|
|
ed.notedelay=45;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ed.shiftkey)
|
|
|
|
{
|
|
|
|
if(ed.shiftmenu)
|
|
|
|
{
|
|
|
|
ed.shiftmenu=false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.shiftmenu=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ed.shiftkey=true;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
else
|
|
|
|
{
|
2020-07-01 05:39:36 +02:00
|
|
|
// No modifiers
|
|
|
|
ed.shiftkey=false;
|
|
|
|
if(key.keymap[SDLK_F1])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-08-23 05:44:18 +02:00
|
|
|
ed.switch_tileset(false);
|
2020-07-01 06:39:10 +02:00
|
|
|
graphics.backgrounddrawn = false;
|
|
|
|
ed.keydelay = 6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_F2])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-08-23 05:44:18 +02:00
|
|
|
ed.switch_tilecol(false);
|
2020-07-01 06:39:10 +02:00
|
|
|
graphics.backgrounddrawn = false;
|
|
|
|
ed.keydelay = 6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_F3])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-08-23 05:44:18 +02:00
|
|
|
ed.switch_enemy(false);
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.keydelay=6;
|
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_F4])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
ed.boundarytype=1;
|
|
|
|
ed.boundarymod=1;
|
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_F5])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
ed.boundarytype=2;
|
|
|
|
ed.boundarymod=1;
|
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_F10])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
if(cl.getroomprop(ed.levx, ed.levy)->directmode==1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomdirectmode(ed.levx, ed.levy, 0);
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.note="Direct Mode Disabled";
|
2021-08-23 05:56:47 +02:00
|
|
|
/* Kludge fix for rainbow BG here... */
|
2021-02-21 00:40:11 +01:00
|
|
|
if (cl.getroomprop(ed.levx, ed.levy)->tileset == 2
|
|
|
|
&& cl.getroomprop(ed.levx, ed.levy)->tilecol == 6)
|
2021-08-23 05:56:47 +02:00
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomtilecol(ed.levx, ed.levy, 0);
|
2021-08-23 05:56:47 +02:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomdirectmode(ed.levx, ed.levy, 1);
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.note="Direct Mode Enabled";
|
|
|
|
}
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.backgrounddrawn=false;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
if(key.keymap[SDLK_3]) ed.drawmode=2;
|
|
|
|
if(key.keymap[SDLK_4]) ed.drawmode=3;
|
|
|
|
if(key.keymap[SDLK_5]) ed.drawmode=4;
|
|
|
|
if(key.keymap[SDLK_6]) ed.drawmode=5;
|
|
|
|
if(key.keymap[SDLK_7]) ed.drawmode=6;
|
|
|
|
if(key.keymap[SDLK_8]) ed.drawmode=7;
|
|
|
|
if(key.keymap[SDLK_9]) ed.drawmode=8;
|
|
|
|
if(key.keymap[SDLK_0]) ed.drawmode=9;
|
|
|
|
if(key.keymap[SDLK_r]) ed.drawmode=10;
|
|
|
|
if(key.keymap[SDLK_t]) ed.drawmode=11;
|
|
|
|
if(key.keymap[SDLK_y]) ed.drawmode=12;
|
|
|
|
if(key.keymap[SDLK_u]) ed.drawmode=13;
|
|
|
|
if(key.keymap[SDLK_i]) ed.drawmode=14;
|
|
|
|
if(key.keymap[SDLK_o]) ed.drawmode=15;
|
|
|
|
if(key.keymap[SDLK_p]) ed.drawmode=16;
|
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_w])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-08-23 05:51:21 +02:00
|
|
|
ed.switch_warpdir(false);
|
|
|
|
graphics.backgrounddrawn = false;
|
|
|
|
ed.keydelay = 6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_e])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
2021-02-21 00:40:11 +01:00
|
|
|
ed.getlin(TEXT_ROOMNAME, "Enter new room name:", const_cast<std::string*>(&(cl.getroomprop(ed.levx, ed.levy)->roomname)));
|
2020-01-01 21:29:24 +01:00
|
|
|
game.mapheld=true;
|
|
|
|
}
|
2020-07-01 08:35:59 +02:00
|
|
|
if (key.keymap[SDLK_g])
|
|
|
|
{
|
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_GOTOROOM, "Enter room coordinates x,y:", NULL);
|
|
|
|
game.mapheld=true;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Save and load
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_s])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_SAVE, "Enter map filename to save map as:", &(ed.filename));
|
2020-01-01 21:29:24 +01:00
|
|
|
game.mapheld=true;
|
|
|
|
}
|
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_l])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.keydelay = 6;
|
|
|
|
ed.getlin(TEXT_LOAD, "Enter map filename to load:", &(ed.filename));
|
2020-01-01 21:29:24 +01:00
|
|
|
game.mapheld=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!game.press_map) game.mapheld=false;
|
|
|
|
if (!game.mapheld)
|
|
|
|
{
|
|
|
|
if(game.press_map)
|
|
|
|
{
|
|
|
|
game.mapheld=true;
|
|
|
|
|
|
|
|
//Ok! Scan the room for the closest checkpoint
|
|
|
|
int testeditor=-1;
|
|
|
|
int startpoint=0;
|
|
|
|
//First up; is there a start point on this screen?
|
2021-02-21 01:01:39 +01:00
|
|
|
for(size_t i=0; i<customentities.size(); i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//if() on screen
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].t==16 && testeditor==-1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
int tx=customentities[i].x/40;
|
|
|
|
int ty=customentities[i].y/30;
|
2020-01-01 21:29:24 +01:00
|
|
|
if(tx==ed.levx && ty==ed.levy)
|
|
|
|
{
|
|
|
|
testeditor=i;
|
|
|
|
startpoint=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(testeditor==-1)
|
|
|
|
{
|
|
|
|
//Ok, settle for a check point
|
2021-02-21 01:01:39 +01:00
|
|
|
for(size_t i=0; i<customentities.size(); i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//if() on screen
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].t==10 && testeditor==-1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
int tx=customentities[i].x/40;
|
|
|
|
int ty=customentities[i].y/30;
|
2020-01-01 21:29:24 +01:00
|
|
|
if(tx==ed.levx && ty==ed.levy)
|
|
|
|
{
|
|
|
|
testeditor=i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(testeditor==-1)
|
|
|
|
{
|
|
|
|
ed.note="ERROR: No checkpoint to spawn at";
|
|
|
|
ed.notedelay=45;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
ed.currentghosts = 0;
|
2020-01-01 21:29:24 +01:00
|
|
|
if(startpoint==0)
|
|
|
|
{
|
|
|
|
//Checkpoint spawn
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
int tx=customentities[testeditor].x/40;
|
|
|
|
int ty=customentities[testeditor].y/30;
|
2021-02-21 01:01:39 +01:00
|
|
|
game.edsavex = (customentities[testeditor].x%40)*8 - 4;
|
|
|
|
game.edsavey = (customentities[testeditor].y%30)*8;
|
2020-01-01 21:29:24 +01:00
|
|
|
game.edsaverx = 100+tx;
|
|
|
|
game.edsavery = 100+ty;
|
2021-02-21 01:01:39 +01:00
|
|
|
if (customentities[testeditor].p1 == 0) // NOT a bool check!
|
Fix spawning from an exotic checkpoint setting invalid gravitycontrol
An exotic checkpoint is a checkpoint with a sprite that is neither the
flipped checkpoint nor unflipped checkpoint. More specifically, it's a
checkpoint whose edentity p1 attribute is something other than 0 or 1.
Normally, whenever you touch an exotic checkpoint in-game, your
savepoint's y-position and gravitycontrol don't get touched. However, in
the editor, spawning from an exotic checkpoint means that your
gravitycontrol gets set to a value that is neither 0 nor 1. In this
invalid gravitycontrol state, Viridian is treated like they're flipped,
but they cannot unflip.
This is an inconsistency between the editor and in-game, so I'm fixing
it. Now, spawning from an exotic checkpoint in the editor will just set
your gravitycontrol to 0, i.e. unflipped.
2020-10-06 08:04:58 +02:00
|
|
|
{
|
|
|
|
game.edsavegc = 1;
|
2020-10-06 08:13:07 +02:00
|
|
|
game.edsavey -= 2;
|
Fix spawning from an exotic checkpoint setting invalid gravitycontrol
An exotic checkpoint is a checkpoint with a sprite that is neither the
flipped checkpoint nor unflipped checkpoint. More specifically, it's a
checkpoint whose edentity p1 attribute is something other than 0 or 1.
Normally, whenever you touch an exotic checkpoint in-game, your
savepoint's y-position and gravitycontrol don't get touched. However, in
the editor, spawning from an exotic checkpoint means that your
gravitycontrol gets set to a value that is neither 0 nor 1. In this
invalid gravitycontrol state, Viridian is treated like they're flipped,
but they cannot unflip.
This is an inconsistency between the editor and in-game, so I'm fixing
it. Now, spawning from an exotic checkpoint in the editor will just set
your gravitycontrol to 0, i.e. unflipped.
2020-10-06 08:04:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game.edsavegc = 0;
|
2020-10-06 08:13:07 +02:00
|
|
|
game.edsavey -= 7;
|
Fix spawning from an exotic checkpoint setting invalid gravitycontrol
An exotic checkpoint is a checkpoint with a sprite that is neither the
flipped checkpoint nor unflipped checkpoint. More specifically, it's a
checkpoint whose edentity p1 attribute is something other than 0 or 1.
Normally, whenever you touch an exotic checkpoint in-game, your
savepoint's y-position and gravitycontrol don't get touched. However, in
the editor, spawning from an exotic checkpoint means that your
gravitycontrol gets set to a value that is neither 0 nor 1. In this
invalid gravitycontrol state, Viridian is treated like they're flipped,
but they cannot unflip.
This is an inconsistency between the editor and in-game, so I'm fixing
it. Now, spawning from an exotic checkpoint in the editor will just set
your gravitycontrol to 0, i.e. unflipped.
2020-10-06 08:04:58 +02:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
game.edsavedir = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Start point spawn
|
Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.
As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.
Thus, we get statements that look like
(a - (a % b)) / b
And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.
`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.
Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.
To find all of these, I used the command
rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'
which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-25 02:21:46 +02:00
|
|
|
int tx=customentities[testeditor].x/40;
|
|
|
|
int ty=customentities[testeditor].y/30;
|
2021-02-21 01:01:39 +01:00
|
|
|
game.edsavex = (customentities[testeditor].x%40)*8 - 4;
|
|
|
|
game.edsavey = (customentities[testeditor].y%30)*8;
|
2020-01-01 21:29:24 +01:00
|
|
|
game.edsaverx = 100+tx;
|
|
|
|
game.edsavery = 100+ty;
|
|
|
|
game.edsavegc = 0;
|
2020-10-06 08:13:07 +02:00
|
|
|
game.edsavey++;
|
2021-02-21 01:01:39 +01:00
|
|
|
game.edsavedir=1-customentities[testeditor].p1;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2020-04-04 00:44:04 +02:00
|
|
|
music.haltdasmusik();
|
2020-03-31 21:52:10 +02:00
|
|
|
graphics.backgrounddrawn=false;
|
2020-02-10 03:23:12 +01:00
|
|
|
ed.returneditoralpha = 1000; // Let's start it higher than 255 since it gets clamped
|
2020-05-02 19:49:41 +02:00
|
|
|
ed.oldreturneditoralpha = 1000;
|
2020-03-31 21:38:52 +02:00
|
|
|
script.startgamemode(21);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:49:57 +02:00
|
|
|
ed.hmod = key.keymap[SDLK_h];
|
|
|
|
ed.vmod = key.keymap[SDLK_v];
|
|
|
|
ed.bmod = key.keymap[SDLK_b];
|
|
|
|
ed.cmod = key.keymap[SDLK_c];
|
|
|
|
ed.xmod = key.keymap[SDLK_x];
|
|
|
|
ed.zmod = key.keymap[SDLK_z];
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_COMMA])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 05:39:36 +02:00
|
|
|
ed.drawmode--;
|
|
|
|
ed.keydelay=6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-07-01 05:39:36 +02:00
|
|
|
else if(key.keymap[SDLK_PERIOD])
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-07-01 05:39:36 +02:00
|
|
|
ed.drawmode++;
|
|
|
|
ed.keydelay=6;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if(ed.drawmode<0)
|
|
|
|
{
|
|
|
|
ed.drawmode=16;
|
|
|
|
if(ed.spacemod) ed.spacemenu=0;
|
|
|
|
}
|
|
|
|
if(ed.drawmode>16) ed.drawmode=0;
|
|
|
|
if(ed.drawmode>9)
|
|
|
|
{
|
|
|
|
if(ed.spacemod) ed.spacemenu=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ed.spacemod) ed.spacemenu=0;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 05:39:36 +02:00
|
|
|
if(up_pressed)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
graphics.backgrounddrawn=false;
|
|
|
|
ed.levy--;
|
|
|
|
ed.updatetiles=true;
|
|
|
|
ed.changeroom=true;
|
|
|
|
}
|
|
|
|
else if(down_pressed)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
graphics.backgrounddrawn=false;
|
|
|
|
ed.levy++;
|
|
|
|
ed.updatetiles=true;
|
|
|
|
ed.changeroom=true;
|
|
|
|
}
|
|
|
|
else if(left_pressed)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
graphics.backgrounddrawn=false;
|
|
|
|
ed.levx--;
|
|
|
|
ed.updatetiles=true;
|
|
|
|
ed.changeroom=true;
|
|
|
|
}
|
|
|
|
else if(right_pressed)
|
|
|
|
{
|
|
|
|
ed.keydelay=6;
|
|
|
|
graphics.backgrounddrawn=false;
|
|
|
|
ed.levx++;
|
|
|
|
ed.updatetiles=true;
|
|
|
|
ed.changeroom=true;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
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;
|
2020-07-01 05:39:36 +02:00
|
|
|
if(key.keymap[SDLK_SPACE])
|
|
|
|
{
|
|
|
|
ed.spacemod = !ed.spacemod;
|
|
|
|
ed.keydelay=6;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ed.settingsmod)
|
|
|
|
{
|
|
|
|
if(ed.boundarymod>0)
|
|
|
|
{
|
|
|
|
if(key.leftbutton)
|
|
|
|
{
|
|
|
|
if(ed.lclickdelay==0)
|
|
|
|
{
|
|
|
|
if(ed.boundarymod==1)
|
|
|
|
{
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
ed.boundx1=(ed.tilex*8);
|
|
|
|
ed.boundy1=(ed.tiley*8);
|
|
|
|
ed.boundarymod=2;
|
|
|
|
}
|
|
|
|
else if(ed.boundarymod==2)
|
|
|
|
{
|
Fix attempts to place enemy/plat bounds & scripts with bad corner order
There is a certain ordering of which corners you click on to place enemy
and platform boundaries, and script boxes. You must first click on the
top-left corner, then click on the bottom-right corner. The visual box
that is drawn after you've first clicked on the top-left corner clearly
shows this intended way of doing things.
However, it seems like despite the visuals, the game didn't properly
prevent you from clicking on the corners in the wrong way. If you placed
it from top-right to bottom-left, or bottom-left to top-right, then the
game would place the boxes accordingly, and they would have a weird
shape where two of its opposite sides would just be missing. But,
placing them from bottom-right to top-left is prevented accordingly.
The bug comes down to a simple use of "or", instead of the correct
"and". This isn't the first time the wrong conjunction was used in a
conditional... (8260bb2696f4843b3e6a29b0c4deea7ba6779aea, #136)
Since the code block that the if-statement guards is the code that will
execute if the corners placed were correct, the if-statement thus should
be written in the positive case and use a more restrictive "and",
instead of the negative case, which would use a more looser "or". There
are less cases that are correct than cases which are incorrect - in this
case, there is only 1 correct way of doing things (top-left to
bottom-right), compared to 3 incorrect ways of doing things (top-right
to bottom-left, bottom-left to top-right, bottom-right to top-left) - so
when thinking of positive cases, you should be using "and".
Or, you can always just test it. This bug has been in the game since
2.0, so it seems like no one just tested that incorrect input actually
didn't work.
2021-01-09 09:27:53 +01:00
|
|
|
if((ed.tilex*8)+8>=ed.boundx1 && (ed.tiley*8)+8>=ed.boundy1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.boundx2=(ed.tilex*8)+8;
|
|
|
|
ed.boundy2=(ed.tiley*8)+8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.boundx2=ed.boundx1+8;
|
|
|
|
ed.boundy2=ed.boundy1+8;
|
|
|
|
}
|
|
|
|
if(ed.boundarytype==0)
|
|
|
|
{
|
|
|
|
//Script trigger
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.lclickdelay=1;
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.textent=customentities.size();
|
2020-01-01 21:29:24 +01:00
|
|
|
addedentity((ed.boundx1/8)+(ed.levx*40),(ed.boundy1/8)+ (ed.levy*30),19,
|
|
|
|
(ed.boundx2-ed.boundx1)/8, (ed.boundy2-ed.boundy1)/8);
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.getlin(TEXT_SCRIPT, "Enter script name:", &(customentities[ed.textent].scriptname));
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.boundarytype==1)
|
|
|
|
{
|
|
|
|
//Enemy bounds
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomenemyx1(ed.levx, ed.levy, ed.boundx1);
|
|
|
|
cl.setroomenemyy1(ed.levx, ed.levy, ed.boundy1);
|
|
|
|
cl.setroomenemyx2(ed.levx, ed.levy, ed.boundx2);
|
|
|
|
cl.setroomenemyy2(ed.levx, ed.levy, ed.boundy2);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.boundarytype==2)
|
|
|
|
{
|
|
|
|
//Platform bounds
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomplatx1(ed.levx, ed.levy, ed.boundx1);
|
|
|
|
cl.setroomplaty1(ed.levx, ed.levy, ed.boundy1);
|
|
|
|
cl.setroomplatx2(ed.levx, ed.levy, ed.boundx2);
|
|
|
|
cl.setroomplaty2(ed.levx, ed.levy, ed.boundy2);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.boundarytype==3)
|
|
|
|
{
|
|
|
|
//Copy
|
|
|
|
}
|
|
|
|
ed.boundarymod=0;
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.lclickdelay=0;
|
|
|
|
}
|
|
|
|
if(key.rightbutton)
|
|
|
|
{
|
|
|
|
ed.boundarymod=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.warpmod)
|
|
|
|
{
|
|
|
|
//Placing warp token
|
|
|
|
if(key.leftbutton)
|
|
|
|
{
|
|
|
|
if(ed.lclickdelay==0)
|
|
|
|
{
|
|
|
|
if(ed.free(ed.tilex, ed.tiley)==0)
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[ed.warpent].p1=ed.tilex+(ed.levx*40);
|
|
|
|
customentities[ed.warpent].p2=ed.tiley+(ed.levy*30);
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.warpmod=false;
|
|
|
|
ed.warpent=-1;
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.lclickdelay=0;
|
|
|
|
}
|
|
|
|
if(key.rightbutton)
|
|
|
|
{
|
|
|
|
removeedentity(ed.warpent);
|
|
|
|
ed.warpmod=false;
|
|
|
|
ed.warpent=-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Mouse input
|
|
|
|
if(key.leftbutton)
|
|
|
|
{
|
|
|
|
if(ed.lclickdelay==0)
|
|
|
|
{
|
|
|
|
//Depending on current mode, place something
|
|
|
|
if(ed.drawmode==0)
|
|
|
|
{
|
|
|
|
//place tiles
|
|
|
|
//Are we in direct mode?
|
2021-02-21 00:40:11 +01:00
|
|
|
if(cl.getroomprop(ed.levx, ed.levy)->directmode>=1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-06-17 23:49:57 +02:00
|
|
|
if(ed.bmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<30; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, i, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.hmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(i, ed.tiley, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.vmod)
|
|
|
|
{
|
|
|
|
for(int j=-4; j<5; j++)
|
|
|
|
{
|
|
|
|
for(int i=-4; i<5; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.cmod)
|
|
|
|
{
|
|
|
|
for(int j=-3; j<4; j++)
|
|
|
|
{
|
|
|
|
for(int i=-3; i<4; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.xmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
for(int j=-2; j<3; j++)
|
|
|
|
{
|
|
|
|
for(int i=-2; i<3; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.zmod)
|
|
|
|
{
|
|
|
|
for(int j=-1; j<2; j++)
|
|
|
|
{
|
|
|
|
for(int i=-1; i<2; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, ed.dmtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-17 23:49:57 +02:00
|
|
|
if(ed.bmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<30; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, i, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.hmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(i, ed.tiley, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.vmod)
|
|
|
|
{
|
|
|
|
for(int j=-4; j<5; j++)
|
|
|
|
{
|
|
|
|
for(int i=-4; i<5; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.cmod)
|
|
|
|
{
|
|
|
|
for(int j=-3; j<4; j++)
|
|
|
|
{
|
|
|
|
for(int i=-3; i<4; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.xmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
for(int j=-2; j<3; j++)
|
|
|
|
{
|
|
|
|
for(int i=-2; i<3; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.zmod)
|
|
|
|
{
|
|
|
|
for(int j=-1; j<2; j++)
|
|
|
|
{
|
|
|
|
for(int i=-1; i<2; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==1)
|
|
|
|
{
|
|
|
|
//place background tiles
|
2020-06-17 23:49:57 +02:00
|
|
|
if(ed.bmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<30; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, i, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.hmod)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(i, ed.tiley, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.vmod)
|
|
|
|
{
|
|
|
|
for(int j=-4; j<5; j++)
|
|
|
|
{
|
|
|
|
for(int i=-4; i<5; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.cmod)
|
|
|
|
{
|
|
|
|
for(int j=-3; j<4; j++)
|
|
|
|
{
|
|
|
|
for(int i=-3; i<4; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.xmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
for(int j=-2; j<3; j++)
|
|
|
|
{
|
|
|
|
for(int i=-2; i<3; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.zmod)
|
|
|
|
{
|
|
|
|
for(int j=-1; j<2; j++)
|
|
|
|
{
|
|
|
|
for(int i=-1; i<2; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==2)
|
|
|
|
{
|
|
|
|
//place spikes
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
int tmp=edentat(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30));
|
|
|
|
if(tmp==-1)
|
|
|
|
{
|
|
|
|
//Room text and script triggers can be placed in walls
|
|
|
|
if(ed.drawmode==10)
|
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.lclickdelay=1;
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.textent=customentities.size();
|
2020-01-01 21:29:24 +01:00
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),17);
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.getlin(TEXT_ROOMTEXT, "Enter roomtext:", &(customentities[ed.textent].scriptname));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.drawmode==12) //Script Trigger
|
|
|
|
{
|
|
|
|
ed.boundarytype=0;
|
|
|
|
ed.boundx1=ed.tilex*8;
|
|
|
|
ed.boundy1=ed.tiley*8;
|
|
|
|
ed.boundarymod=2;
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(tmp==-1 && ed.free(ed.tilex,ed.tiley)==0)
|
|
|
|
{
|
|
|
|
if(ed.drawmode==3)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
if(cl.numtrinkets()<100)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),9);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-23 15:43:53 +01:00
|
|
|
ed.note="ERROR: Max number of trinkets is 100";
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.notedelay=45;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==4)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),10, 1);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==5)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),3);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==6)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),2,5);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==7)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),2,0);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==8)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),1,0);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==9)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),11,0);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==11)
|
|
|
|
{
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.lclickdelay=1;
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.textent=customentities.size();
|
2020-01-01 21:29:24 +01:00
|
|
|
addedentity(ed.tilex+(ed.levx*40),ed.tiley+ (ed.levy*30),18,0);
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.getlin(TEXT_SCRIPT, "Enter script name:", &(customentities[ed.textent].scriptname));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else if(ed.drawmode==13)
|
|
|
|
{
|
|
|
|
ed.warpmod=true;
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.warpent=customentities.size();
|
2020-01-01 21:29:24 +01:00
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),13);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==14)
|
|
|
|
{
|
|
|
|
//Warp lines
|
Remove checks to prevent having both warp lines/BGs in editor
It's perfectly acceptable to have both warp lines and a warping
background in the same room. Many levels do this exact thing, I would
say at least 30 or so levels, many of them popular and played by many,
and this has never caused any issues at all.
All that having both warp lines and warp BG does is make it so the
warping of the warping background gets overriden by the warp lines, but
make it so the background is still a warp background. So in effect, you
can have a warp background without any warping. This is perfectly
defined behavior. Except, for whatever reason, it's unintentional, and
the editor tries to prevent you from doing it.
Key word being "tries". The code to prevent having both warp types is
bugged (at least when you change the warp BG. The check when you place
warp lines seems to be solid). It compares the p1 and p2 attributes of
warp lines to the x-coordinate and y-coordinate of the room, despite p1
and p2 having nothing to do with room coordinates. p1 is the type of the
warp line and should be treated as an enum, and p2 is the offset of the
warp line from the top/left of the screen. This results in this check
sometimes working if you're unlucky, but never actually working properly
most of the time. This means people can first place warp lines, and then
change the warp background later, to have both warp lines and a warp
background.
Having these checks just further complicates the code, makes it more
error-prone, and just inconveniences people when they want to do
something that's perfectly fine to do. So it's best if we just remove
these checks.
2020-09-06 05:02:27 +02:00
|
|
|
if(ed.tilex==0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
Remove checks to prevent having both warp lines/BGs in editor
It's perfectly acceptable to have both warp lines and a warping
background in the same room. Many levels do this exact thing, I would
say at least 30 or so levels, many of them popular and played by many,
and this has never caused any issues at all.
All that having both warp lines and warp BG does is make it so the
warping of the warping background gets overriden by the warp lines, but
make it so the background is still a warp background. So in effect, you
can have a warp background without any warping. This is perfectly
defined behavior. Except, for whatever reason, it's unintentional, and
the editor tries to prevent you from doing it.
Key word being "tries". The code to prevent having both warp types is
bugged (at least when you change the warp BG. The check when you place
warp lines seems to be solid). It compares the p1 and p2 attributes of
warp lines to the x-coordinate and y-coordinate of the room, despite p1
and p2 having nothing to do with room coordinates. p1 is the type of the
warp line and should be treated as an enum, and p2 is the offset of the
warp line from the top/left of the screen. This results in this check
sometimes working if you're unlucky, but never actually working properly
most of the time. This means people can first place warp lines, and then
change the warp background later, to have both warp lines and a warp
background.
Having these checks just further complicates the code, makes it more
error-prone, and just inconveniences people when they want to do
something that's perfectly fine to do. So it's best if we just remove
these checks.
2020-09-06 05:02:27 +02:00
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,0);
|
|
|
|
}
|
|
|
|
else if(ed.tilex==39)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,1);
|
|
|
|
}
|
|
|
|
else if(ed.tiley==0)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,2);
|
|
|
|
}
|
|
|
|
else if(ed.tiley==29)
|
|
|
|
{
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,3);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Remove checks to prevent having both warp lines/BGs in editor
It's perfectly acceptable to have both warp lines and a warping
background in the same room. Many levels do this exact thing, I would
say at least 30 or so levels, many of them popular and played by many,
and this has never caused any issues at all.
All that having both warp lines and warp BG does is make it so the
warping of the warping background gets overriden by the warp lines, but
make it so the background is still a warp background. So in effect, you
can have a warp background without any warping. This is perfectly
defined behavior. Except, for whatever reason, it's unintentional, and
the editor tries to prevent you from doing it.
Key word being "tries". The code to prevent having both warp types is
bugged (at least when you change the warp BG. The check when you place
warp lines seems to be solid). It compares the p1 and p2 attributes of
warp lines to the x-coordinate and y-coordinate of the room, despite p1
and p2 having nothing to do with room coordinates. p1 is the type of the
warp line and should be treated as an enum, and p2 is the offset of the
warp line from the top/left of the screen. This results in this check
sometimes working if you're unlucky, but never actually working properly
most of the time. This means people can first place warp lines, and then
change the warp background later, to have both warp lines and a warp
background.
Having these checks just further complicates the code, makes it more
error-prone, and just inconveniences people when they want to do
something that's perfectly fine to do. So it's best if we just remove
these checks.
2020-09-06 05:02:27 +02:00
|
|
|
ed.note="ERROR: Warp lines must be on edges";
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.notedelay=45;
|
|
|
|
}
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==15) //Crewmate
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
if(cl.numcrewmates()<100)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-05-20 03:18:01 +02:00
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),15,int(fRandom() * 6));
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-23 15:43:53 +01:00
|
|
|
ed.note="ERROR: Max number of crewmates is 100";
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.notedelay=45;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ed.drawmode==16) //Start Point
|
|
|
|
{
|
|
|
|
//If there is another start point, destroy it
|
2021-02-21 01:01:39 +01:00
|
|
|
for(size_t i=0; i<customentities.size(); i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].t==16)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
removeedentity(i);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),16,0);
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
|
|
|
}
|
Fix undefined behavior with left-click logic in editor
There's an if-else chain that first deals with figuring out if there's
an entity where your left-click happened, and to do this it uses
edentat(), which returns a sentinel value of -1 if there is NOT an
entity where your cursor is.
It's very important to check that the value returned ISN'T -1 before you
start indexing the 'edentity' vector, since if you DO index it with that
-1, it'll result in Undefined Behavior because you're doing an
out-of-bounds array access.
Now, here's what the if-else chain looked like before:
if(tmp==-1 && ed.free(ed.tilex,ed.tiley)==0)
{
...
}
else if(edentity[tmp].t==1)
The bug here is very subtle but it was an easy oversight. Basically, if
'ed.free' ended up not being zero, control flow would jump to the next
"else if" over, which then ends up asking for the -1th index of
'edentity', which is Undefined Behavior.
This undefined behavior has now resulted in a crash on my system after
TerryCavanagh/VVVVVV#172, due it shuffling things around juuuuust enough
such that this UB would end up resulting in a segfault instead of
chugging along and working fine. For me and my system, this meant that
if my first left-click in the editor upon opening the game was me
placing down a tile and not placing down an entity, the game would
crash. But, it would be fine if I first placed down an entity and then
afterwards placed down tiles, because it's UB.
And I'm almost certain this was the cause of the very strange bug where
you couldn't hold down left-click for the foreground-placing tool (but
you COULD for the background-placing tool) that seemed to occur most
often on Windows (TerryCavanagh/VVVVVV#25).
The solution to this is to stick in another conditional in the tree
before any indexing occurs, such that there's no way any other
conditionals with the indexing in the conditional tree could end up
being hit. In summary, the if-else chain looks like this now:
if(tmp==-1 && ed.free(ed.tilex,ed.tiley)==0)
{
...
}
else if(tmp == -1)
{
//Important! Do nothing, or else Undefined Behavior will happen
}
else if(edentity[tmp].t==1)
2020-03-02 06:25:29 +01:00
|
|
|
else if(tmp == -1)
|
|
|
|
{
|
|
|
|
//Important! Do nothing, or else Undefined Behavior will happen
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==1)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%4;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==2)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[tmp].p1>=5)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%9;
|
|
|
|
if(customentities[tmp].p1<5) customentities[tmp].p1=5;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%4;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==10)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
// If it's not textured as a checkpoint, leave it alone
|
2021-02-21 01:01:39 +01:00
|
|
|
if (customentities[tmp].p1 == 0 || customentities[tmp].p1 == 1)
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%2;
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==11)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%2;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==15)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%6;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==16)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1=(customentities[tmp].p1+1)%2;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==17)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.getlin(TEXT_ROOMTEXT, "Enter roomtext:", &(customentities[tmp].scriptname));
|
2020-01-27 11:15:25 +01:00
|
|
|
ed.textent=tmp;
|
2020-01-01 21:29:24 +01:00
|
|
|
ed.lclickdelay=1;
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
else if(customentities[tmp].t==18 || customentities[tmp].t==19)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.lclickdelay=1;
|
2020-07-01 08:17:26 +02:00
|
|
|
ed.textent=tmp;
|
2021-02-21 01:01:39 +01:00
|
|
|
ed.getlin(TEXT_SCRIPT, "Enter script name:", &(customentities[ed.textent].scriptname));
|
|
|
|
if (customentities[tmp].t == 18
|
|
|
|
&& (customentities[tmp].p1 == 0 || customentities[tmp].p1 == 1))
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
{
|
|
|
|
// Flip the terminal, but if it's not textured as a terminal leave it alone
|
2021-02-21 01:01:39 +01:00
|
|
|
customentities[tmp].p1 = (customentities[tmp].p1 + 1) % 2;
|
Improve support for retextured checkpoints and terminals in the editor
Retextured checkpoints have always been in the game, but clicking on
them in the editor would lead to them losing their retextured-ness. So,
checkpoints should be left alone if their p1 isn't either 0 or 1. Also,
they don't show up properly in the editor, so that's fixed, too.
Retextured and flipped terminals were added in 2.3, and show up properly
in-game, but don't properly show up in the editor, either. So now they
show up in the editor. Additionally, clicking on them will flip the
terminal as well, but only if its p1 is 0 or 1, just like checkpoints
now do.
2021-01-12 02:19:20 +01:00
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.lclickdelay=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(key.rightbutton)
|
|
|
|
{
|
|
|
|
//place tiles
|
2020-08-01 21:23:56 +02:00
|
|
|
if(ed.drawmode < 2) {
|
|
|
|
if(ed.bmod)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=0; i<30; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, i, 0);
|
|
|
|
}
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.hmod)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(i, ed.tiley, 0);
|
|
|
|
}
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.vmod)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int j=-4; j<5; j++)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=-4; i<5; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 0);
|
|
|
|
}
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.cmod)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int j=-3; j<4; j++)
|
2020-06-17 23:49:57 +02:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=-3; i<4; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 0);
|
|
|
|
}
|
2020-06-17 23:49:57 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.xmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int j=-2; j<3; j++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=-2; i<3; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 0);
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else if(ed.zmod)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int j=-1; j<2; j++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2020-08-01 21:23:56 +02:00
|
|
|
for(int i=-1; i<2; i++)
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex+i, ed.tiley+j, 0);
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 21:23:56 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, 0);
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ed.placetilelocal(ed.tilex, ed.tiley, 0);
|
|
|
|
}
|
2021-02-21 01:01:39 +01:00
|
|
|
for(size_t i=0; i<customentities.size(); i++)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
2021-02-21 01:01:39 +01:00
|
|
|
if(customentities[i].x==ed.tilex + (ed.levx*40)&& customentities[i].y==ed.tiley+ (ed.levy*30))
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
removeedentity(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(key.middlebutton)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
ed.dmtile=cl.gettile(ed.levx, ed.levy, ed.tilex, ed.tiley);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-21 00:40:11 +01:00
|
|
|
if(ed.updatetiles && cl.getroomprop(ed.levx, ed.levy)->directmode==0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
ed.updatetiles=false;
|
|
|
|
//Correctly set the tiles in the current room
|
2021-02-21 00:40:11 +01:00
|
|
|
switch(cl.getroomprop(ed.levx, ed.levy)->tileset)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
case 0: //The Space Station
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
int temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2021-03-24 19:26:19 +01:00
|
|
|
if(temp>=3 && temp<80)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix spikes
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp==2 || temp>=680)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix background
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.backedgetile(i, j) + ed.backbase(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix tiles
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.edgetile(i, j) + ed.base(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: //Outside
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
int temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2021-03-24 19:26:19 +01:00
|
|
|
if(temp>=3 && temp<80)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix spikes
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp==2 || temp>=680)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix background
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.outsideedgetile(i, j) + ed.backbase(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix tiles
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.edgetile(i, j) + ed.base(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: //Lab
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
int temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2021-03-24 19:26:19 +01:00
|
|
|
if(temp>=3 && temp<80)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix spikes
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.labspikedir(
|
|
|
|
i,
|
|
|
|
j,
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.getroomprop(ed.levx, ed.levy)->tilecol
|
2021-03-24 19:26:19 +01:00
|
|
|
)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp==2 || temp>=680)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix background
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, 713);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix tiles
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.edgetile(i, j) + ed.base(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: //Warp Zone/Intermission
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
int temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2021-03-24 19:26:19 +01:00
|
|
|
if(temp>=3 && temp<80)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix spikes
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp==2 || temp>=680)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix background
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, 713);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix tiles
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.edgetile(i, j) + ed.base(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: //The ship
|
|
|
|
for(int j=0; j<30; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<40; i++)
|
|
|
|
{
|
2021-02-21 00:40:11 +01:00
|
|
|
int temp=cl.gettile(ed.levx, ed.levy, i, j);
|
2021-03-24 19:26:19 +01:00
|
|
|
if(temp>=3 && temp<80)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix spikes
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j));
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp==2 || temp>=680)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix background
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.backedgetile(i, j) + ed.backbase(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2021-03-24 19:26:19 +01:00
|
|
|
else if(temp>0)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
//Fix tiles
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.settile(
|
2021-03-24 19:26:19 +01:00
|
|
|
ed.levx,
|
|
|
|
ed.levy,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
ed.edgetile(i, j) + ed.base(ed.levx, ed.levy)
|
|
|
|
);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: //The Tower
|
|
|
|
break;
|
|
|
|
case 6: //Custom Set 1
|
|
|
|
break;
|
|
|
|
case 7: //Custom Set 2
|
|
|
|
break;
|
|
|
|
case 8: //Custom Set 3
|
|
|
|
break;
|
|
|
|
case 9: //Custom Set 4
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
int editorclass::getenemyframe(int t)
|
|
|
|
{
|
|
|
|
switch(t)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 78;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return 88;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return 36;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return 164;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return 68;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return 48;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return 176;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
return 168;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
return 112;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
return 114;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 78;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::placetilelocal( int x, int y, int t )
|
|
|
|
{
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
cl.settile(levx, levy, x, y, t);
|
|
|
|
}
|
|
|
|
updatetiles=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::base( int x, int y )
|
|
|
|
{
|
|
|
|
//Return the base tile for the given tileset and colour
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(x, y);
|
2021-02-21 00:40:11 +01:00
|
|
|
if(room->tileset==0) //Space Station
|
|
|
|
{
|
|
|
|
if(room->tilecol>=22)
|
|
|
|
{
|
|
|
|
return 483 + ((room->tilecol-22)*3);
|
|
|
|
}
|
|
|
|
else if(room->tilecol>=11)
|
|
|
|
{
|
|
|
|
return 283 + ((room->tilecol-11)*3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 83 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(room->tileset==1) //Outside
|
|
|
|
{
|
|
|
|
return 480 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
else if(room->tileset==2) //Lab
|
|
|
|
{
|
|
|
|
return 280 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
else if(room->tileset==3) //Warp Zone/Intermission
|
|
|
|
{
|
|
|
|
return 80 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
else if(room->tileset==4) //SHIP
|
|
|
|
{
|
|
|
|
return 101 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::backbase( int x, int y )
|
|
|
|
{
|
|
|
|
//Return the base tile for the background of the given tileset and colour
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(x, y);
|
2021-02-21 00:40:11 +01:00
|
|
|
if(room->tileset==0) //Space Station
|
|
|
|
{
|
|
|
|
//Pick depending on tilecol
|
|
|
|
switch(room->tilecol)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 5:
|
|
|
|
case 26:
|
|
|
|
return 680; //Blue
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 16:
|
|
|
|
case 23:
|
|
|
|
return 683; //Yellow
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
case 12:
|
|
|
|
case 21:
|
|
|
|
return 686; //Greeny Cyan
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
case 24:
|
|
|
|
case 28:
|
|
|
|
case 30:
|
|
|
|
return 689; //Green
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
case 29:
|
|
|
|
return 692; //Orange
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 6:
|
|
|
|
case 11:
|
|
|
|
case 22:
|
|
|
|
case 27:
|
|
|
|
return 695; //Red
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 10:
|
|
|
|
case 15:
|
|
|
|
case 19:
|
|
|
|
case 31:
|
|
|
|
return 698; //Pink
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
case 18:
|
|
|
|
return 701; //Dark Blue
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
case 13:
|
|
|
|
case 17:
|
|
|
|
case 25:
|
|
|
|
return 704; //Cyan
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 680;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(room->tileset==1) //outside
|
|
|
|
{
|
|
|
|
return 680 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
else if(room->tileset==2) //Lab
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(room->tileset==3) //Warp Zone/Intermission
|
|
|
|
{
|
|
|
|
return 120 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
else if(room->tileset==4) //SHIP
|
|
|
|
{
|
|
|
|
return 741 + (room->tilecol*3);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::at( int x, int y )
|
|
|
|
{
|
|
|
|
if(x<0) return at(0,y);
|
|
|
|
if(y<0) return at(x,0);
|
|
|
|
if(x>=40) return at(39,y);
|
|
|
|
if(y>=30) return at(x,29);
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
return cl.gettile(levx, levy, x, y);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::freewrap( int x, int y )
|
|
|
|
{
|
|
|
|
if(x<0) return freewrap(x+(cl.mapwidth*40),y);
|
|
|
|
if(y<0) return freewrap(x,y+(cl.mapheight*30));
|
|
|
|
if(x>=(cl.mapwidth*40)) return freewrap(x-(cl.mapwidth*40),y);
|
|
|
|
if(y>=(cl.mapheight*30)) return freewrap(x,y-(cl.mapheight*30));
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<(cl.mapwidth*40) && y<(cl.mapheight*30))
|
|
|
|
{
|
|
|
|
if(cl.getabstile(x, y)==0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(cl.getabstile(x, y)>=2 && cl.getabstile(x, y)<80)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(cl.getabstile(x, y)>=680)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::backonlyfree( int x, int y )
|
|
|
|
{
|
|
|
|
//Returns 1 if tile is a background tile, 0 otherwise
|
|
|
|
if(x<0) return backonlyfree(0,y);
|
|
|
|
if(y<0) return backonlyfree(x,0);
|
|
|
|
if(x>=40) return backonlyfree(39,y);
|
|
|
|
if(y>=30) return backonlyfree(x,29);
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)>=680)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::backfree( int x, int y )
|
|
|
|
{
|
|
|
|
//Returns 0 if tile is not a block or background tile, 1 otherwise
|
|
|
|
if(x<0) return backfree(0,y);
|
|
|
|
if(y<0) return backfree(x,0);
|
|
|
|
if(x>=40) return backfree(39,y);
|
|
|
|
if(y>=30) return backfree(x,29);
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)==0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::spikefree( int x, int y )
|
|
|
|
{
|
|
|
|
//Returns 0 if tile is not a block or spike, 1 otherwise
|
|
|
|
if(x==-1) return free(0,y);
|
|
|
|
if(y==-1) return free(x,0);
|
|
|
|
if(x==40) return free(39,y);
|
|
|
|
if(y==30) return free(x,29);
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)==0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)>=680)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::free( int x, int y )
|
|
|
|
{
|
|
|
|
//Returns 0 if tile is not a block, 1 otherwise
|
|
|
|
if(x==-1) return free(0,y);
|
|
|
|
if(y==-1) return free(x,0);
|
|
|
|
if(x==40) return free(39,y);
|
|
|
|
if(y==30) return free(x,29);
|
|
|
|
|
|
|
|
if(x>=0 && y>=0 && x<40 && y<30)
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)==0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(cl.gettile(levx, levy, x, y)>=2 && cl.gettile(levx, levy, x, y)<80)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(cl.gettile(levx, levy, x, y)>=680)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::match( int x, int y )
|
|
|
|
{
|
|
|
|
if(free(x-1,y)==0 && free(x,y-1)==0 && free(x+1,y)==0 && free(x,y+1)==0) return 0;
|
|
|
|
|
|
|
|
if(free(x-1,y)==0 && free(x,y-1)==0) return 10;
|
|
|
|
if(free(x+1,y)==0 && free(x,y-1)==0) return 11;
|
|
|
|
if(free(x-1,y)==0 && free(x,y+1)==0) return 12;
|
|
|
|
if(free(x+1,y)==0 && free(x,y+1)==0) return 13;
|
|
|
|
|
|
|
|
if(free(x,y-1)==0) return 1;
|
|
|
|
if(free(x-1,y)==0) return 2;
|
|
|
|
if(free(x,y+1)==0) return 3;
|
|
|
|
if(free(x+1,y)==0) return 4;
|
|
|
|
if(free(x-1,y-1)==0) return 5;
|
|
|
|
if(free(x+1,y-1)==0) return 6;
|
|
|
|
if(free(x-1,y+1)==0) return 7;
|
|
|
|
if(free(x+1,y+1)==0) return 8;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::outsidematch( int x, int y )
|
|
|
|
{
|
|
|
|
|
|
|
|
if(backonlyfree(x-1,y)==0 && backonlyfree(x+1,y)==0) return 2;
|
|
|
|
if(backonlyfree(x,y-1)==0 && backonlyfree(x,y+1)==0) return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::backmatch( int x, int y )
|
|
|
|
{
|
|
|
|
//Returns the first position match for a border
|
|
|
|
// 5 1 6
|
|
|
|
// 2 X 4
|
|
|
|
// 7 3 8
|
|
|
|
if(backfree(x-1,y)==0 && backfree(x,y-1)==0 && backfree(x+1,y)==0 && backfree(x,y+1)==0) return 0;
|
|
|
|
|
|
|
|
if(backfree(x-1,y)==0 && backfree(x,y-1)==0) return 10;
|
|
|
|
if(backfree(x+1,y)==0 && backfree(x,y-1)==0) return 11;
|
|
|
|
if(backfree(x-1,y)==0 && backfree(x,y+1)==0) return 12;
|
|
|
|
if(backfree(x+1,y)==0 && backfree(x,y+1)==0) return 13;
|
|
|
|
|
|
|
|
if(backfree(x,y-1)==0) return 1;
|
|
|
|
if(backfree(x-1,y)==0) return 2;
|
|
|
|
if(backfree(x,y+1)==0) return 3;
|
|
|
|
if(backfree(x+1,y)==0) return 4;
|
|
|
|
if(backfree(x-1,y-1)==0) return 5;
|
|
|
|
if(backfree(x+1,y-1)==0) return 6;
|
|
|
|
if(backfree(x-1,y+1)==0) return 7;
|
|
|
|
if(backfree(x+1,y+1)==0) return 8;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::edgetile( int x, int y )
|
|
|
|
{
|
|
|
|
switch(match(x,y))
|
|
|
|
{
|
|
|
|
case 14:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
return 80;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
return 82;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
return 160;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
return 162;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return 81;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return 120;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return 161;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return 122;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return 42;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return 41;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
return 2;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::outsideedgetile( int x, int y )
|
|
|
|
{
|
|
|
|
switch(outsidematch(x,y))
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int editorclass::backedgetile( int x, int y )
|
|
|
|
{
|
|
|
|
switch(backmatch(x,y))
|
|
|
|
{
|
|
|
|
case 14:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
return 80;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
return 82;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
return 160;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
return 162;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return 81;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return 120;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return 161;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return 122;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return 42;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return 41;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
return 2;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::labspikedir( int x, int y, int t )
|
|
|
|
{
|
|
|
|
// a slightly more tricky case
|
|
|
|
if(free(x,y+1)==1) return 63 + (t*2);
|
|
|
|
if(free(x,y-1)==1) return 64 + (t*2);
|
|
|
|
if(free(x-1,y)==1) return 51 + (t*2);
|
|
|
|
if(free(x+1,y)==1) return 52 + (t*2);
|
|
|
|
return 63 + (t*2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int editorclass::spikedir( int x, int y )
|
|
|
|
{
|
|
|
|
if(free(x,y+1)==1) return 8;
|
|
|
|
if(free(x,y-1)==1) return 9;
|
|
|
|
if(free(x-1,y)==1) return 49;
|
|
|
|
if(free(x+1,y)==1) return 50;
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::switch_tileset(const bool reversed)
|
|
|
|
{
|
|
|
|
const char* tilesets[] = {"Space Station", "Outside", "Lab", "Warp Zone", "Ship"};
|
|
|
|
|
|
|
|
int tiles = cl.getroomprop(levx, levy)->tileset;
|
|
|
|
|
|
|
|
if (reversed)
|
|
|
|
{
|
|
|
|
tiles--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tiles++;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int modulus = SDL_arraysize(tilesets);
|
Add `POS_MOD` macro and use for all positive modulos
This macro is to make it so it won't be error-prone to write the
semi-confusing `(a % b + b) % b` statement, and you can just use an easy
macro instead.
Currently, the only places a positive modulo is needed is when switching
tilesets, enemies, and warp directions in the editor, as well as when
getting a tile in the tower, since towers just repeat themselves
vertically. Towers used this weird while-loop to sort of emulate a
modulo, which isn't half-bad, but is unnecessary, and I don't think any
compiler would recognize it as a modulo. (And if it's not optimized to a
proper modulo... what happens if the number being moduloed is really,
really big?)
2021-09-25 02:48:15 +02:00
|
|
|
tiles = POS_MOD(tiles, modulus);
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomtileset(levx, levy, tiles);
|
|
|
|
|
|
|
|
clamp_tilecol(levx, levy, false);
|
|
|
|
|
|
|
|
char buffer[64];
|
|
|
|
SDL_snprintf(buffer, sizeof(buffer), "Now using %s Tileset", tilesets[tiles]);
|
|
|
|
|
|
|
|
note = buffer;
|
|
|
|
notedelay = 45;
|
|
|
|
updatetiles = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::switch_tilecol(const bool reversed)
|
|
|
|
{
|
|
|
|
int tilecol = cl.getroomprop(levx, levy)->tilecol;
|
|
|
|
|
|
|
|
if (reversed)
|
|
|
|
{
|
|
|
|
tilecol--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tilecol++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl.setroomtilecol(levx, levy, tilecol);
|
|
|
|
|
|
|
|
clamp_tilecol(levx, levy, true);
|
|
|
|
|
|
|
|
notedelay = 45;
|
|
|
|
note = "Tileset Colour Changed";
|
|
|
|
updatetiles = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::clamp_tilecol(const int rx, const int ry, const bool wrap)
|
|
|
|
{
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(rx, ry);
|
2021-02-21 00:40:11 +01:00
|
|
|
const int tileset = room->tileset;
|
|
|
|
int tilecol = room->tilecol;
|
|
|
|
|
|
|
|
int mincol = -1;
|
|
|
|
int maxcol = 5;
|
|
|
|
|
|
|
|
// Only Space Station allows tileset -1
|
|
|
|
if (tileset != 0)
|
|
|
|
{
|
|
|
|
mincol = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (tileset)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
maxcol = 31;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
maxcol = 7;
|
|
|
|
break;
|
2021-10-29 02:27:13 +02:00
|
|
|
case 2:
|
|
|
|
if (room->directmode)
|
|
|
|
{
|
|
|
|
maxcol = 6;
|
|
|
|
}
|
|
|
|
break;
|
2021-02-21 00:40:11 +01:00
|
|
|
case 3:
|
|
|
|
maxcol = 6;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
maxcol = 29;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If wrap is true, wrap-around, otherwise just cap
|
|
|
|
if (tilecol > maxcol)
|
|
|
|
{
|
|
|
|
tilecol = (wrap ? mincol : maxcol);
|
|
|
|
}
|
|
|
|
if (tilecol < mincol)
|
|
|
|
{
|
|
|
|
tilecol = (wrap ? maxcol : mincol);
|
|
|
|
}
|
|
|
|
|
|
|
|
cl.setroomtilecol(rx, ry, tilecol);
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::switch_enemy(const bool reversed)
|
|
|
|
{
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(levx, levy);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
int enemy = room->enemytype;
|
|
|
|
|
|
|
|
if (reversed)
|
|
|
|
{
|
|
|
|
enemy--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
enemy++;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int modulus = 10;
|
Add `POS_MOD` macro and use for all positive modulos
This macro is to make it so it won't be error-prone to write the
semi-confusing `(a % b + b) % b` statement, and you can just use an easy
macro instead.
Currently, the only places a positive modulo is needed is when switching
tilesets, enemies, and warp directions in the editor, as well as when
getting a tile in the tower, since towers just repeat themselves
vertically. Towers used this weird while-loop to sort of emulate a
modulo, which isn't half-bad, but is unnecessary, and I don't think any
compiler would recognize it as a modulo. (And if it's not optimized to a
proper modulo... what happens if the number being moduloed is really,
really big?)
2021-09-25 02:48:15 +02:00
|
|
|
enemy = POS_MOD(enemy, modulus);
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomenemytype(levx, levy, enemy);
|
|
|
|
|
|
|
|
note = "Enemy Type Changed";
|
|
|
|
notedelay = 45;
|
|
|
|
}
|
|
|
|
|
|
|
|
void editorclass::switch_warpdir(const bool reversed)
|
|
|
|
{
|
|
|
|
static const int modulus = 4;
|
2021-02-21 00:45:48 +01:00
|
|
|
const RoomProperty* const room = cl.getroomprop(levx, levy);
|
2021-02-21 00:40:11 +01:00
|
|
|
|
|
|
|
int warpdir = room->warpdir;
|
|
|
|
|
|
|
|
if (reversed)
|
|
|
|
{
|
|
|
|
--warpdir;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++warpdir;
|
|
|
|
}
|
|
|
|
|
Add `POS_MOD` macro and use for all positive modulos
This macro is to make it so it won't be error-prone to write the
semi-confusing `(a % b + b) % b` statement, and you can just use an easy
macro instead.
Currently, the only places a positive modulo is needed is when switching
tilesets, enemies, and warp directions in the editor, as well as when
getting a tile in the tower, since towers just repeat themselves
vertically. Towers used this weird while-loop to sort of emulate a
modulo, which isn't half-bad, but is unnecessary, and I don't think any
compiler would recognize it as a modulo. (And if it's not optimized to a
proper modulo... what happens if the number being moduloed is really,
really big?)
2021-09-25 02:48:15 +02:00
|
|
|
warpdir = POS_MOD(warpdir, modulus);
|
2021-02-21 00:40:11 +01:00
|
|
|
cl.setroomwarpdir(levx, levy, warpdir);
|
|
|
|
|
|
|
|
switch (warpdir)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
note = "Room warping disabled";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
note = "Room warps horizontally";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
note = "Room warps vertically";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
note = "Room warps in all directions";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
notedelay = 45;
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:51:25 +01:00
|
|
|
#endif /* NO_CUSTOM_LEVELS and NO_EDITOR */
|