1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 05:58:30 +02:00

Clean up scripts in the editor

Scripts used a weird "hook" system, where script names were extracted
into their own list. This was completely unneeded, so it has been
replaced with using the script.customscripts vector directly.

The script editor has been cleaned up, so the cursor's Y position is
relative to the entire script, rather than what's just displaying on
the screen currently. This simplifies a lot of code, and I don't know
why it was done the other way in the first place.

The script selector and script editor cursors have been sped up, since
both lists can be massive, and waiting 6 frames per line is extremely
slow and boring. This is still slow and boring, but we don't have
proper input repetition yet.
This commit is contained in:
AllyTally 2023-03-09 13:10:58 -04:00 committed by Misa Elizabeth Kai
parent 9c26f51931
commit 6cae666c76
5 changed files with 287 additions and 357 deletions

View File

@ -1424,10 +1424,6 @@ next:
}
}
#ifndef NO_EDITOR
ed.gethooks();
#endif
loc::loadtext_custom(_path.c_str());
font::load_custom(level_font_name.c_str());

File diff suppressed because it is too large Load Diff

View File

@ -195,7 +195,6 @@ public:
std::string filename;
std::string loaded_filepath;
int drawmode;
int tilex, tiley;
int keydelay, lclickdelay;
bool savekey, loadkey;
@ -211,50 +210,47 @@ public:
union
{
int desc; // Which description row we're changing
int textent; // Entity ID for text prompt
int text_entity; // Entity ID for text prompt
};
bool xmod, zmod, cmod, vmod, bmod, hmod, spacemod;
bool x_modifier, z_modifier, c_modifier, v_modifier, b_modifier, h_modifier, toolbox_open;
int roomnamehide;
bool saveandquit;
bool shiftmenu, shiftkey;
bool help_open, shiftkey;
bool settingskey;
int warpent;
int warp_token_entity;
bool updatetiles, changeroom;
bool deletekeyheld;
bool backspace_held;
//Script editor stuff
void removeline(int t);
void insertline(int t);
void remove_line(int t);
void insert_line(int t);
std::vector<std::string> sb;
std::string sbscript;
int sbx, sby;
int pagey;
std::vector<std::string> script_buffer;
std::string current_script;
int script_cursor_x, script_cursor_y;
int script_offset;
int lines_visible;
//Functions for interfacing with the script:
void addhook(const std::string& t);
void removehook(const std::string& t);
void addhooktoscript(const std::string& t);
void removehookfromscript(const std::string& t);
void loadhookineditor(const std::string& t);
void clearscriptbuffer(void);
void gethooks(void);
bool checkhook(const std::string& t);
std::vector<std::string> hooklist;
void create_script(const std::string& name, const std::vector<std::string>& contents);
void create_script(const std::string& name);
void remove_script(const std::string& name);
void load_script_in_editor(const std::string& name);
void clear_script_buffer(void);
bool script_exists(const std::string& name);
int hookmenupage, hookmenu;
int script_list_offset, selected_script;
//Direct Mode variables
int dmtile;
int dmtileeditor;
int direct_mode_tile;
int direct_mode_drawer;
int returneditoralpha;
int oldreturneditoralpha;
int return_message_timer;
int old_return_message_timer;
std::vector<GhostInfo> ghosts;
int currentghosts;
int current_ghosts;
};
void editorrender(void);

View File

@ -1954,7 +1954,7 @@ void gamerender(void)
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)
if(map.custommode && !map.custommodeforreal && !game.advancetext){
//Return to level editor
int alpha = graphics.lerp(ed.oldreturneditoralpha, ed.returneditoralpha);
int alpha = graphics.lerp(ed.old_return_message_timer, ed.return_message_timer);
if (alpha > 100)
{

View File

@ -117,10 +117,10 @@ void gamerenderfixed(void)
map.updateroomnames();
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)
ed.oldreturneditoralpha = ed.returneditoralpha;
if (map.custommode && !map.custommodeforreal && ed.returneditoralpha > 0)
ed.old_return_message_timer = ed.return_message_timer;
if (map.custommode && !map.custommodeforreal && ed.return_message_timer > 0)
{
ed.returneditoralpha -= 15;
ed.return_message_timer -= 15;
}
// Editor ghosts!