mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-05-17 14:44:08 +00:00
rogueviz::magiccube:: using rv_hook
This commit is contained in:
parent
bb5eaf0fc5
commit
fbea016f03
@ -35,23 +35,6 @@ void build(crystal::coord co, int at) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void magic(int sides) {
|
|
||||||
stop_game();
|
|
||||||
if(sides < 0)
|
|
||||||
set_geometry(gCrystal344);
|
|
||||||
else
|
|
||||||
crystal::set_crystal(sides);
|
|
||||||
set_variation(eVariation::pure);
|
|
||||||
firstland = specialland = laCanvas;
|
|
||||||
patterns::whichCanvas = 'g';
|
|
||||||
patterns::canvasback = back;
|
|
||||||
check_cgi();
|
|
||||||
start_game();
|
|
||||||
|
|
||||||
build(crystal::c0, 0);
|
|
||||||
vizid = (void*) &magic;
|
|
||||||
}
|
|
||||||
|
|
||||||
void curveline(hyperpoint a, hyperpoint b, int lev) {
|
void curveline(hyperpoint a, hyperpoint b, int lev) {
|
||||||
if(lev>0) {
|
if(lev>0) {
|
||||||
hyperpoint c = mid(a, b);
|
hyperpoint c = mid(a, b);
|
||||||
@ -62,7 +45,6 @@ void curveline(hyperpoint a, hyperpoint b, int lev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool magic_markers(cell *c, const shiftmatrix& V) {
|
bool magic_markers(cell *c, const shiftmatrix& V) {
|
||||||
if(vizid != (void*) &magic) return false;
|
|
||||||
timerghost = false;
|
timerghost = false;
|
||||||
if(c->landparam == back) {
|
if(c->landparam == back) {
|
||||||
if(GDIM == 2) {
|
if(GDIM == 2) {
|
||||||
@ -91,22 +73,6 @@ bool magic_markers(cell *c, const shiftmatrix& V) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int readArgs() {
|
|
||||||
using namespace arg;
|
|
||||||
|
|
||||||
if(0) ;
|
|
||||||
else if(argis("-magic")) {
|
|
||||||
PHASEFROM(2);
|
|
||||||
shift(); magic(argi());
|
|
||||||
}
|
|
||||||
else if(argis("-magic3")) {
|
|
||||||
PHASEFROM(2);
|
|
||||||
magic(-1);
|
|
||||||
}
|
|
||||||
else return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void twos_to_fours(vector<int>& zeros, crystal::coord co, int d) {
|
void twos_to_fours(vector<int>& zeros, crystal::coord co, int d) {
|
||||||
if(d == crystal::get_dim()) {
|
if(d == crystal::get_dim()) {
|
||||||
int facetable[5][5];
|
int facetable[5][5];
|
||||||
@ -133,7 +99,6 @@ void twos_to_fours(vector<int>& zeros, crystal::coord co, int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool magic_rotate(cell *c) {
|
bool magic_rotate(cell *c) {
|
||||||
if(vizid != (void*) &magic) return false;
|
|
||||||
if(c->landparam != back) return false;
|
if(c->landparam != back) return false;
|
||||||
vector<int> zeros;
|
vector<int> zeros;
|
||||||
auto co = crystal::get_coord(c->master);
|
auto co = crystal::get_coord(c->master);
|
||||||
@ -151,7 +116,6 @@ bool magic_rotate(cell *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool magic_rugkey(int sym, int uni) {
|
bool magic_rugkey(int sym, int uni) {
|
||||||
if(vizid != (void*) &magic) return false;
|
|
||||||
if((cmode & sm::NORMAL) && uni == 'p') {
|
if((cmode & sm::NORMAL) && uni == 'p') {
|
||||||
rug::texturesize = 4096;
|
rug::texturesize = 4096;
|
||||||
if(rug::rugged) rug::close();
|
if(rug::rugged) rug::close();
|
||||||
@ -172,9 +136,43 @@ bool magic_rugkey(int sym, int uni) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto magichook = addHook(hooks_args, 100, readArgs) + addHook(hooks_drawcell, 100, magic_markers)
|
void magic(int sides) {
|
||||||
+ addHook(mine::hooks_mark, 150, magic_rotate)
|
stop_game();
|
||||||
+ addHook(hooks_handleKey, 150, magic_rugkey);
|
if(sides < 0)
|
||||||
|
set_geometry(gCrystal344);
|
||||||
|
else
|
||||||
|
crystal::set_crystal(sides);
|
||||||
|
set_variation(eVariation::pure);
|
||||||
|
firstland = specialland = laCanvas;
|
||||||
|
patterns::whichCanvas = 'g';
|
||||||
|
patterns::canvasback = back;
|
||||||
|
check_cgi();
|
||||||
|
start_game();
|
||||||
|
|
||||||
|
build(crystal::c0, 0);
|
||||||
|
|
||||||
|
rv_hook(hooks_drawcell, 100, magic_markers);
|
||||||
|
rv_hook(mine::hooks_mark, 150, magic_rotate);
|
||||||
|
rv_hook(hooks_handleKey, 150, magic_rugkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
int readArgs() {
|
||||||
|
using namespace arg;
|
||||||
|
|
||||||
|
if(0) ;
|
||||||
|
else if(argis("-magic")) {
|
||||||
|
PHASEFROM(2);
|
||||||
|
shift(); magic(argi());
|
||||||
|
}
|
||||||
|
else if(argis("-magic3")) {
|
||||||
|
PHASEFROM(2);
|
||||||
|
magic(-1);
|
||||||
|
}
|
||||||
|
else return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto magichook = addHook(hooks_args, 100, readArgs);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,6 +99,17 @@ namespace rogueviz {
|
|||||||
|
|
||||||
void storeall(int from = 0);
|
void storeall(int from = 0);
|
||||||
|
|
||||||
|
extern vector<reaction_t> cleanup;
|
||||||
|
|
||||||
|
template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) {
|
||||||
|
int p = addHook(m, prio, hook);
|
||||||
|
auto del = [&m, p] {
|
||||||
|
delHook(m, p);
|
||||||
|
};
|
||||||
|
if(tour::on) tour::on_restore(del);
|
||||||
|
else cleanup.push_back(del);
|
||||||
|
}
|
||||||
|
|
||||||
namespace anygraph {
|
namespace anygraph {
|
||||||
extern double R, alpha, T;
|
extern double R, alpha, T;
|
||||||
extern vector<pair<double, double> > coords;
|
extern vector<pair<double, double> > coords;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user