1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-22 01:17:39 +00:00

cleanup mapeditor

This commit is contained in:
Zeno Rogue
2019-08-10 01:15:41 +02:00
parent 4422b910c0
commit 4ec7652861
3 changed files with 26 additions and 50 deletions

View File

@@ -7664,7 +7664,13 @@ EX void normalscreen() {
describeMouseover(); describeMouseover();
} }
vector< function<void()> > screens = { normalscreen }; EX vector< function<void()> > screens = { normalscreen };
#if HDR
template<class T> 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; EX int cmode;

37
hyper.h
View File

@@ -880,12 +880,6 @@ typedef function<bool()> bool_reaction_t;
#define HELPFUN(x) (help_delegate = x, "HELPFUN") #define HELPFUN(x) (help_delegate = x, "HELPFUN")
extern vector< function<void()> > screens;
template<class T> 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 { struct display_data {
transmatrix view_matrix; // current rotation, relative to viewctr transmatrix view_matrix; // current rotation, relative to viewctr
transmatrix player_matrix; // player-relative view transmatrix player_matrix; // player-relative view
@@ -929,29 +923,6 @@ extern display_data *current_display;
typedef function<int(cell*)> cellfunction; typedef function<int(cell*)> cellfunction;
namespace mapeditor {
#if CAP_EDIT
extern map<int, cell*> 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 // passable flags
#define SAGEMELT .1 #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 PPR operator - (PPR x, int y) { return PPR(int(x) - y); }
inline int operator - (PPR x, PPR y) { return int(x) - int(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_NONE 0x000000FF
#define OUTLINE_FRIEND 0x00FF00FF #define OUTLINE_FRIEND 0x00FF00FF
#define OUTLINE_ENEMY 0xFF0000FF #define OUTLINE_ENEMY 0xFF0000FF
@@ -2296,7 +2263,6 @@ static const int USERLAYERS = 32;
struct usershape { usershapelayer d[USERLAYERS]; }; struct usershape { usershapelayer d[USERLAYERS]; };
extern array<map<int, usershape*>, mapeditor::USERSHAPEGROUPS> usershapes;
void initShape(int sg, int id); void initShape(int sg, int id);
extern int usershape_changes; extern int usershape_changes;
@@ -2623,14 +2589,13 @@ static const color_t NOCOLOR = 0;
static const int max_vec = (1<<14); static const int max_vec = (1<<14);
extern bool needConfirmationEvenIfSaved(); extern bool needConfirmationEvenIfSaved();
#define EX
#define EXT(z)
} }
#define IS(z) = z #define IS(z) = z
#include "autohdr.h" #include "autohdr.h"
#undef IS #undef IS
#define IS(z) #define IS(z)
#define EX
namespace hr { namespace hr {
inline bool movepcto(const movedir& md) { return movepcto(md.d, md.subdir); } inline bool movepcto(const movedir& md) { return movepcto(md.d, md.subdir); }

View File

@@ -3,7 +3,12 @@
namespace hr { namespace hr {
namespace mapeditor { EX namespace mapeditor {
#if HDR
enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor, sgWall };
static const int USERSHAPEGROUPS = 5;
#endif
hyperpoint lstart; hyperpoint lstart;
cell *lstartcell; cell *lstartcell;
@@ -53,11 +58,11 @@ namespace mapeditor {
} }
#if CAP_EDIT #if CAP_EDIT
map<int, cell*> modelcell; EX map<int, cell*> modelcell;
void handleKeyMap(int sym, int uni); void handleKeyMap(int sym, int uni);
void applyModelcell(cell *c) { EX void applyModelcell(cell *c) {
if(patterns::whichPattern == 'H') return; if(patterns::whichPattern == 'H') return;
auto si = patterns::getpatterninfo0(c); auto si = patterns::getpatterninfo0(c);
cell *c2 = modelcell[si.id]; cell *c2 = modelcell[si.id];
@@ -539,9 +544,9 @@ namespace mapstream {
namespace mapeditor { namespace mapeditor {
bool drawplayer = true; EX bool drawplayer = true;
cell *drawcell; EX cell *drawcell;
#if CAP_EDIT #if CAP_EDIT
int paintwhat = 0; 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); displayButton(8, vid.yres-8-fs*2, XLAT("ESC = return to the game"), SDLK_ESCAPE, 0);
} }
void showMapEditor() { EX void showMapEditor() {
cmode = sm::MAP; cmode = sm::MAP;
gamescreen(0); gamescreen(0);
@@ -708,7 +713,7 @@ namespace mapeditor {
return 1; return 1;
} }
eShapegroup drawcellShapeGroup() { EX eShapegroup drawcellShapeGroup() {
if(drawcell == cwt.at && drawplayer) return sgPlayer; if(drawcell == cwt.at && drawplayer) return sgPlayer;
if(drawcell->wall == waEditStatue) return sgWall; if(drawcell->wall == waEditStatue) return sgWall;
if(drawcell->monst) return sgMonster; if(drawcell->monst) return sgMonster;
@@ -716,7 +721,7 @@ namespace mapeditor {
return sgFloor; return sgFloor;
} }
int drawcellShapeID() { EX int drawcellShapeID() {
if(drawcell == cwt.at && drawplayer) return vid.cs.charid; if(drawcell == cwt.at && drawplayer) return vid.cs.charid;
if(drawcell->wall == waEditStatue) return drawcell->wparam; if(drawcell->wall == waEditStatue) return drawcell->wparam;
if(drawcell->monst) return drawcell->monst; if(drawcell->monst) return drawcell->monst;
@@ -1234,7 +1239,7 @@ namespace mapeditor {
#define EDITING_TRIANGLES (DIM == 3) #define EDITING_TRIANGLES (DIM == 3)
void showDrawEditor() { EX void showDrawEditor() {
#if CAP_POLY #if CAP_POLY
cmode = sm::DRAW; cmode = sm::DRAW;
gamescreen(0); gamescreen(0);
@@ -1994,7 +1999,7 @@ namespace mapeditor {
});;; });;;
#endif #endif
void initdraw(cell *c) { EX void initdraw(cell *c) {
#if CAP_EDIT #if CAP_EDIT
mapeditor::drawcell = c; mapeditor::drawcell = c;
ew.c = c; ew.c = c;
@@ -2071,7 +2076,7 @@ namespace mapeditor {
#endif #endif
#if CAP_POLY #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 #if !CAP_EDIT
return false; return false;
#else #else
@@ -2212,7 +2217,7 @@ namespace mapeditor {
} }
#endif #endif
void map_settings() { EX void map_settings() {
cmode = sm::SIDE | sm::MAYDARK; cmode = sm::SIDE | sm::MAYDARK;
gamescreen(1); gamescreen(1);
@@ -2241,7 +2246,7 @@ namespace mapeditor {
dialog::addBack(); dialog::addBack();
dialog::display(); dialog::display();
} }
} EX }
#if CAP_EDIT #if CAP_EDIT
EX string levelfile = "hyperrogue.lev"; EX string levelfile = "hyperrogue.lev";