1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-09-29 14:30:40 +00:00

rogueviz::sunflowers:: using rv_hook

This commit is contained in:
Zeno Rogue 2021-03-31 15:32:44 +02:00
parent 1aae969b6c
commit 91d339aa38

View File

@ -27,8 +27,6 @@ namespace rogueviz {
namespace sunflower { namespace sunflower {
bool on;
bool nodes; bool nodes;
ld qty = 100; ld qty = 100;
@ -60,7 +58,6 @@ vector<int> inext, inext2;
vector<int> fibs = {1, 2}; vector<int> fibs = {1, 2};
bool sunflower_cell(cell *c, shiftmatrix V) { bool sunflower_cell(cell *c, shiftmatrix V) {
if(!on) return false;
density = zdensity / 100; density = zdensity / 100;
ld qd; ld qd;
@ -151,12 +148,19 @@ void insert_param() {
param_f(distance_per_rug, "sunf"); param_f(distance_per_rug, "sunf");
} }
void show();
void enable() {
rv_hook(hooks_o_key, 80, [] (o_funcs& v) { v.push_back(named_dialog("sunflowers", show)); });
rv_hook(hooks_drawcell, 100, sunflower_cell);
}
int readArgs() { int readArgs() {
using namespace arg; using namespace arg;
if(0) ; if(0) ;
else if(argis("-sunflower-qd")) { else if(argis("-sunflower-qd")) {
on = true; enable();
infer = 'r'; infer = 'r';
shift_arg_formula(qty); shift_arg_formula(qty);
shift_arg_formula(zdensity); shift_arg_formula(zdensity);
@ -165,7 +169,7 @@ int readArgs() {
nohud = true; nohud = true;
} }
else if(argis("-sunflower-qr")) { else if(argis("-sunflower-qr")) {
on = true; enable();
infer = 'd'; infer = 'd';
shift_arg_formula(qty); shift_arg_formula(qty);
shift_arg_formula(range); shift_arg_formula(range);
@ -174,7 +178,7 @@ int readArgs() {
nohud = true; nohud = true;
} }
else if(argis("-sunflower-dr")) { else if(argis("-sunflower-dr")) {
on = true; enable();
infer = 'q'; infer = 'q';
shift_arg_formula(zdensity); shift_arg_formula(zdensity);
shift_arg_formula(range); shift_arg_formula(range);
@ -259,16 +263,10 @@ void show() {
dialog::display(); dialog::display();
} }
void o_key(o_funcs& v) {
if(on) v.push_back(named_dialog("sunflowers", show));
}
auto hook = 0 auto hook = 0
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
+ addHook(hooks_args, 100, readArgs) + addHook(hooks_args, 100, readArgs)
#endif #endif
+ addHook(hooks_o_key, 80, o_key)
+ addHook(hooks_drawcell, 100, sunflower_cell)
+ addHook(pres::hooks_build_rvtour, 144, [] (string s, vector<tour::slide>& v) { + addHook(pres::hooks_build_rvtour, 144, [] (string s, vector<tour::slide>& v) {
if(s != "mixed") return; if(s != "mixed") return;
using namespace tour; using namespace tour;
@ -302,7 +300,7 @@ auto hook = 0
if(mode == pmStart) { if(mode == pmStart) {
stop_game(); stop_game();
tour::slide_backup(on, true); enable();
tour::slide_backup(range, sphere ? 2 : euclid ? 10 : 4.3); tour::slide_backup(range, sphere ? 2 : euclid ? 10 : 4.3);
tour::slide_backup<ld>(zdensity, 1); tour::slide_backup<ld>(zdensity, 1);
tour::slide_backup(infer, 'q'); tour::slide_backup(infer, 'q');