Cleanup tools & main rendering

Tools were a mess, spread all over the code with hundreds of `else-if`
statements. Instead of magic numbers denoting tools, an enum has been
created, and logic has been extracted into simple switch/cases, shared
logic being deduplicated.

The base of a state system for the editor has been created as well,
laying a good path for further organization improvements. Because of
this, the entire editor no longer gets drawn underneath the menus,
except for a few pieces which I haven't extracted yet. Either way,
this should be good for performance, if that was a concern.
This commit is contained in:
AllyTally
2023-03-02 02:45:22 -04:00
committed by Misa Elizabeth Kai
parent e3612afbd3
commit 34cc15505b
6 changed files with 1213 additions and 1378 deletions

View File

@@ -209,6 +209,13 @@ public:
int fill_rect(int x, int y, int w, int h, SDL_Color color);
int fill_rect(SDL_Color color);
int draw_rect(const SDL_Rect* rect, int r, int g, int b, int a);
int draw_rect(int x, int y, int w, int h, int r, int g, int b, int a);
int draw_rect(int x, int y, int w, int h, int r, int g, int b);
int draw_rect(const SDL_Rect* rect, int r, int g, int b);
int draw_rect(const SDL_Rect* rect, SDL_Color color);
int draw_rect(int x, int y, int w, int h, SDL_Color color);
void map_tab(int opt, const char* text, bool selected = false);
void map_option(int opt, int num_opts, const std::string& text, bool selected = false);
@@ -249,20 +256,12 @@ public:
#ifndef NO_CUSTOM_LEVELS
bool shouldrecoloroneway(const int tilenum, const bool mounted);
#endif
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
void drawtile2( int x, int y, int t );
void drawtile( int x, int y, int t );
void drawtowertile( int x, int y, int t );
void drawtowertile3( int x, int y, int t, TowerBG& bg_obj );
void drawtile3(int x, int y, int t, int off, int height_subtract = 0);
void drawtile2(int x, int y, int t);
void drawtile(int x, int y, int t);
void drawmap(void);
void drawforetile(int x, int y, int t);
void drawforetile2(int x, int y, int t);
void drawforetile3(int x, int y, int t, int off);
void drawrect(int x, int y, int w, int h, int r, int g, int b);
void drawtowermap(void);