From 4ec76528610f5a42989e0f5d5d04e3ff637c6814 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 10 Aug 2019 01:15:41 +0200 Subject: [PATCH] cleanup mapeditor --- graph.cpp | 8 +++++++- hyper.h | 37 +------------------------------------ mapeditor.cpp | 31 ++++++++++++++++++------------- 3 files changed, 26 insertions(+), 50 deletions(-) diff --git a/graph.cpp b/graph.cpp index 8c2a29cd..dae4ff7c 100644 --- a/graph.cpp +++ b/graph.cpp @@ -7664,7 +7664,13 @@ EX void normalscreen() { describeMouseover(); } -vector< function > screens = { normalscreen }; +EX vector< function > screens = { normalscreen }; + +#if HDR +template void pushScreen(const T& x) { screens.push_back(x); } +inline void popScreen() { if(isize(screens)>1) screens.pop_back(); } +inline void popScreenAll() { while(isize(screens)>1) popScreen(); } +#endif EX int cmode; diff --git a/hyper.h b/hyper.h index 6a2bab09..b26518f0 100644 --- a/hyper.h +++ b/hyper.h @@ -880,12 +880,6 @@ typedef function bool_reaction_t; #define HELPFUN(x) (help_delegate = x, "HELPFUN") -extern vector< function > screens; - -template void pushScreen(const T& x) { screens.push_back(x); } -inline void popScreen() { if(isize(screens)>1) screens.pop_back(); } -inline void popScreenAll() { while(isize(screens)>1) popScreen(); } - struct display_data { transmatrix view_matrix; // current rotation, relative to viewctr transmatrix player_matrix; // player-relative view @@ -929,29 +923,6 @@ extern display_data *current_display; typedef function cellfunction; -namespace mapeditor { -#if CAP_EDIT - extern map modelcell; -#endif - - extern bool drawplayer; - void applyModelcell(cell *c); - - extern cell *drawcell; - void initdraw(cell *c); - #if CAP_EDIT - void showMapEditor(); - void showDrawEditor(); - #endif - - enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor, sgWall }; - static const int USERSHAPEGROUPS = 5; - - bool haveUserShape(eShapegroup group, int id); - void draw_texture_ghosts(cell *c, const transmatrix& V); - void map_settings(); - } - // passable flags #define SAGEMELT .1 @@ -1227,10 +1198,6 @@ inline PPR operator + (PPR x, int y) { return PPR(int(x) + y); } inline PPR operator - (PPR x, int y) { return PPR(int(x) - y); } inline int operator - (PPR x, PPR y) { return int(x) - int(y); } -namespace mapeditor { - bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio = PPR::DEFAULT); - } - #define OUTLINE_NONE 0x000000FF #define OUTLINE_FRIEND 0x00FF00FF #define OUTLINE_ENEMY 0xFF0000FF @@ -2296,7 +2263,6 @@ static const int USERLAYERS = 32; struct usershape { usershapelayer d[USERLAYERS]; }; -extern array, mapeditor::USERSHAPEGROUPS> usershapes; void initShape(int sg, int id); extern int usershape_changes; @@ -2623,14 +2589,13 @@ static const color_t NOCOLOR = 0; static const int max_vec = (1<<14); extern bool needConfirmationEvenIfSaved(); -#define EX -#define EXT(z) } #define IS(z) = z #include "autohdr.h" #undef IS #define IS(z) +#define EX namespace hr { inline bool movepcto(const movedir& md) { return movepcto(md.d, md.subdir); } diff --git a/mapeditor.cpp b/mapeditor.cpp index 524124c6..90d06dca 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -3,7 +3,12 @@ namespace hr { -namespace mapeditor { +EX namespace mapeditor { + + #if HDR + enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor, sgWall }; + static const int USERSHAPEGROUPS = 5; + #endif hyperpoint lstart; cell *lstartcell; @@ -53,11 +58,11 @@ namespace mapeditor { } #if CAP_EDIT - map modelcell; + EX map modelcell; void handleKeyMap(int sym, int uni); - void applyModelcell(cell *c) { + EX void applyModelcell(cell *c) { if(patterns::whichPattern == 'H') return; auto si = patterns::getpatterninfo0(c); cell *c2 = modelcell[si.id]; @@ -539,9 +544,9 @@ namespace mapstream { namespace mapeditor { - bool drawplayer = true; + EX bool drawplayer = true; - cell *drawcell; + EX cell *drawcell; #if CAP_EDIT int paintwhat = 0; @@ -672,7 +677,7 @@ namespace mapeditor { displayButton(8, vid.yres-8-fs*2, XLAT("ESC = return to the game"), SDLK_ESCAPE, 0); } - void showMapEditor() { + EX void showMapEditor() { cmode = sm::MAP; gamescreen(0); @@ -708,7 +713,7 @@ namespace mapeditor { return 1; } - eShapegroup drawcellShapeGroup() { + EX eShapegroup drawcellShapeGroup() { if(drawcell == cwt.at && drawplayer) return sgPlayer; if(drawcell->wall == waEditStatue) return sgWall; if(drawcell->monst) return sgMonster; @@ -716,7 +721,7 @@ namespace mapeditor { return sgFloor; } - int drawcellShapeID() { + EX int drawcellShapeID() { if(drawcell == cwt.at && drawplayer) return vid.cs.charid; if(drawcell->wall == waEditStatue) return drawcell->wparam; if(drawcell->monst) return drawcell->monst; @@ -1234,7 +1239,7 @@ namespace mapeditor { #define EDITING_TRIANGLES (DIM == 3) - void showDrawEditor() { + EX void showDrawEditor() { #if CAP_POLY cmode = sm::DRAW; gamescreen(0); @@ -1994,7 +1999,7 @@ namespace mapeditor { });;; #endif - void initdraw(cell *c) { + EX void initdraw(cell *c) { #if CAP_EDIT mapeditor::drawcell = c; ew.c = c; @@ -2071,7 +2076,7 @@ namespace mapeditor { #endif #if CAP_POLY - bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio) { + EX bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio IS(PPR::DEFAULT)) { #if !CAP_EDIT return false; #else @@ -2212,7 +2217,7 @@ namespace mapeditor { } #endif - void map_settings() { + EX void map_settings() { cmode = sm::SIDE | sm::MAYDARK; gamescreen(1); @@ -2241,7 +2246,7 @@ namespace mapeditor { dialog::addBack(); dialog::display(); } - } +EX } #if CAP_EDIT EX string levelfile = "hyperrogue.lev";