1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-30 16:38:29 +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()); loc::loadtext_custom(_path.c_str());
font::load_custom(level_font_name.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 filename;
std::string loaded_filepath; std::string loaded_filepath;
int drawmode;
int tilex, tiley; int tilex, tiley;
int keydelay, lclickdelay; int keydelay, lclickdelay;
bool savekey, loadkey; bool savekey, loadkey;
@ -211,50 +210,47 @@ public:
union union
{ {
int desc; // Which description row we're changing 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; int roomnamehide;
bool saveandquit; bool saveandquit;
bool shiftmenu, shiftkey; bool help_open, shiftkey;
bool settingskey; bool settingskey;
int warpent; int warp_token_entity;
bool updatetiles, changeroom; bool updatetiles, changeroom;
bool deletekeyheld; bool backspace_held;
//Script editor stuff //Script editor stuff
void removeline(int t); void remove_line(int t);
void insertline(int t); void insert_line(int t);
std::vector<std::string> sb; std::vector<std::string> script_buffer;
std::string sbscript; std::string current_script;
int sbx, sby; int script_cursor_x, script_cursor_y;
int pagey; int script_offset;
int lines_visible; int lines_visible;
//Functions for interfacing with the script: //Functions for interfacing with the script:
void addhook(const std::string& t); void create_script(const std::string& name, const std::vector<std::string>& contents);
void removehook(const std::string& t); void create_script(const std::string& name);
void addhooktoscript(const std::string& t); void remove_script(const std::string& name);
void removehookfromscript(const std::string& t); void load_script_in_editor(const std::string& name);
void loadhookineditor(const std::string& t); void clear_script_buffer(void);
void clearscriptbuffer(void); bool script_exists(const std::string& name);
void gethooks(void);
bool checkhook(const std::string& t);
std::vector<std::string> hooklist;
int hookmenupage, hookmenu; int script_list_offset, selected_script;
//Direct Mode variables //Direct Mode variables
int dmtile; int direct_mode_tile;
int dmtileeditor; int direct_mode_drawer;
int returneditoralpha; int return_message_timer;
int oldreturneditoralpha; int old_return_message_timer;
std::vector<GhostInfo> ghosts; std::vector<GhostInfo> ghosts;
int currentghosts; int current_ghosts;
}; };
void editorrender(void); void editorrender(void);

View File

@ -1954,7 +1954,7 @@ void gamerender(void)
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) #if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)
if(map.custommode && !map.custommodeforreal && !game.advancetext){ if(map.custommode && !map.custommodeforreal && !game.advancetext){
//Return to level editor //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) if (alpha > 100)
{ {

View File

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