mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 01:20:37 +00:00
export more presentation functions
This commit is contained in:
parent
cf1cd09f81
commit
4486e9a017
@ -9,13 +9,7 @@ namespace rogueviz {
|
||||
namespace pres {
|
||||
|
||||
/* maks graphs in presentations */
|
||||
struct grapher {
|
||||
|
||||
ld minx, miny, maxx, maxy;
|
||||
|
||||
shiftmatrix T;
|
||||
|
||||
grapher(ld _minx, ld _miny, ld _maxx, ld _maxy) : minx(_minx), miny(_miny), maxx(_maxx), maxy(_maxy) {
|
||||
grapher::grapher(ld _minx, ld _miny, ld _maxx, ld _maxy) : minx(_minx), miny(_miny), maxx(_maxx), maxy(_maxy) {
|
||||
auto& cd = *current_display;
|
||||
|
||||
ld xpixels = 2 * min(cd.xcenter - cd.xmin, cd.xmax - cd.xcenter);
|
||||
@ -39,14 +33,15 @@ struct grapher {
|
||||
T.T = transpose(T.T);
|
||||
}
|
||||
|
||||
void line(hyperpoint h1, hyperpoint h2, color_t col) {
|
||||
void grapher::line(hyperpoint h1, hyperpoint h2, color_t col) {
|
||||
curvepoint(h1);
|
||||
curvepoint(h2);
|
||||
queuecurve(T, col, 0, PPR::LINE).flags |= POLY_FORCEWIDE;
|
||||
}
|
||||
|
||||
void arrow(hyperpoint h1, hyperpoint h2, ld sca) {
|
||||
line(h1, h2, 0xFF);
|
||||
void grapher::arrow(hyperpoint h1, hyperpoint h2, ld sca, color_t col) {
|
||||
line(h1, h2, col);
|
||||
if(!sca) return;
|
||||
hyperpoint h = h2 - h1;
|
||||
ld siz = hypot_d(2, h);
|
||||
h *= sca / siz;
|
||||
@ -54,10 +49,10 @@ struct grapher {
|
||||
curvepoint(h2 - spin(15*degree) * h);
|
||||
curvepoint(h2 - spin(-15*degree) * h);
|
||||
curvepoint(h2);
|
||||
queuecurve(T, 0xFF, 0xFF, PPR::LINE);
|
||||
queuecurve(T, col, col, PPR::LINE);
|
||||
}
|
||||
|
||||
shiftmatrix pos(ld x, ld y, ld sca) {
|
||||
shiftmatrix grapher::pos(ld x, ld y, ld sca) {
|
||||
transmatrix P = Id;
|
||||
P[0][0] = sca;
|
||||
P[1][1] = sca;
|
||||
@ -66,23 +61,12 @@ struct grapher {
|
||||
return T * P;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
hyperpoint p2(ld x, ld y) { return LDIM == 2 ? point3(x, y, 1) : point31(x, y, 0); }
|
||||
|
||||
/* temporary hooks */
|
||||
|
||||
using namespace hr::tour;
|
||||
|
||||
template<class T, class U> void add_temporary_hook(int mode, hookset<T>& m, int prio, U&& hook) {
|
||||
if(mode == pmStart) {
|
||||
int p = addHook(m, prio, hook);
|
||||
on_restore([&m, p] {
|
||||
delHook(m, p);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void add_stat(presmode mode, const bool_reaction_t& stat) {
|
||||
add_temporary_hook(mode, hooks_prestats, 200, stat);
|
||||
}
|
||||
@ -92,7 +76,7 @@ void no_other_hud(presmode mode) {
|
||||
clearMessages();
|
||||
}
|
||||
|
||||
void empty_screen(presmode mode, color_t col = 0xFFFFFFFF) {
|
||||
void empty_screen(presmode mode, color_t col) {
|
||||
if(mode == pmStart) {
|
||||
tour::slide_backup(nomap, true);
|
||||
tour::slide_backup(backcolor, col);
|
||||
@ -262,9 +246,6 @@ int phooks =
|
||||
}
|
||||
});
|
||||
|
||||
static ld angle = 0;
|
||||
static int dir = -1;
|
||||
|
||||
void use_angledir(presmode mode, bool reset) {
|
||||
if(mode == pmStart && reset)
|
||||
angle = 0, dir = -1;
|
||||
|
@ -169,6 +169,42 @@ function<void(presmode)> roguevizslide_action(char c, const T& t, const U& act)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void add_end(vector<slide>& s);
|
||||
|
||||
template<class T, class U> void add_temporary_hook(int mode, hookset<T>& m, int prio, U&& hook) {
|
||||
using namespace tour;
|
||||
if(mode == pmStart) {
|
||||
int p = addHook(m, prio, hook);
|
||||
on_restore([&m, p] {
|
||||
delHook(m, p);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* maks graphs in presentations */
|
||||
struct grapher {
|
||||
|
||||
ld minx, miny, maxx, maxy;
|
||||
|
||||
shiftmatrix T;
|
||||
|
||||
grapher(ld _minx, ld _miny, ld _maxx, ld _maxy);
|
||||
void line(hyperpoint h1, hyperpoint h2, color_t col);
|
||||
void arrow(hyperpoint h1, hyperpoint h2, ld sca, color_t col = 0xFF);
|
||||
shiftmatrix pos(ld x, ld y, ld sca);
|
||||
};
|
||||
|
||||
void add_stat(presmode mode, const bool_reaction_t& stat);
|
||||
void compare_projections(presmode mode, eModel a, eModel b);
|
||||
void no_other_hud(presmode mode);
|
||||
void empty_screen(presmode mode, color_t col = 0xFFFFFFFF);
|
||||
void show_picture(presmode mode, string s);
|
||||
void use_angledir(presmode mode, bool reset);
|
||||
|
||||
inline ld angle = 0;
|
||||
inline int dir = -1;
|
||||
hyperpoint p2(ld x, ld y);
|
||||
}
|
||||
|
||||
void createViz(int id, cell *c, transmatrix at);
|
||||
|
Loading…
Reference in New Issue
Block a user