mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 17:40:36 +00:00
Merge pull request #106 from Quuxplusone/hooks-naming
Various severable "hookset" cleanups
This commit is contained in:
commit
07710758aa
@ -219,7 +219,7 @@ void setcameraangle(bool b) { }
|
|||||||
#if CAP_GL
|
#if CAP_GL
|
||||||
|
|
||||||
#if CAP_VR
|
#if CAP_VR
|
||||||
EX hookset<bool()> *hooks_vr_eye_view, *hooks_vr_eye_projection;
|
EX hookset<bool()> hooks_vr_eye_view, hooks_vr_eye_projection;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EX void eyewidth_translate(int ed) {
|
EX void eyewidth_translate(int ed) {
|
||||||
|
@ -1332,7 +1332,7 @@ EX bool quickfind(eLand l) {
|
|||||||
#define I2000 (INVLUCK?600:2000)
|
#define I2000 (INVLUCK?600:2000)
|
||||||
#define I10000 (INVLUCK?3000:10000)
|
#define I10000 (INVLUCK?3000:10000)
|
||||||
|
|
||||||
EX hookset<int(cell*, bool)> *hooks_wallchance;
|
EX hookset<int(cell*, bool)> hooks_wallchance;
|
||||||
|
|
||||||
EX int wallchance(cell *c, bool deepOcean) {
|
EX int wallchance(cell *c, bool deepOcean) {
|
||||||
int i = callhandlers(-1, hooks_wallchance, c, deepOcean);
|
int i = callhandlers(-1, hooks_wallchance, c, deepOcean);
|
||||||
|
@ -251,7 +251,7 @@ EX void drawArrowTraps() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ccm_blizzard = addHook(clearmemory, 0, [] () {
|
auto ccm_blizzard = addHook(hooks_clearmemory, 0, [] () {
|
||||||
arrowtraps.clear();
|
arrowtraps.clear();
|
||||||
blizzardcells.clear();
|
blizzardcells.clear();
|
||||||
bcells.clear();
|
bcells.clear();
|
||||||
|
4
cell.cpp
4
cell.cpp
@ -279,7 +279,7 @@ EX void eumerge(cell* c1, int s1, cell *c2, int s2, bool mirror) {
|
|||||||
|
|
||||||
// map<pair<eucoord, eucoord>, cell*> euclidean;
|
// map<pair<eucoord, eucoord>, cell*> euclidean;
|
||||||
|
|
||||||
EX hookset<hrmap*()> *hooks_newmap;
|
EX hookset<hrmap*()> hooks_newmap;
|
||||||
|
|
||||||
/** create a map in the current geometry */
|
/** create a map in the current geometry */
|
||||||
EX void initcells() {
|
EX void initcells() {
|
||||||
@ -1175,7 +1175,7 @@ EX void clearCellMemory() {
|
|||||||
gp::gp_adj.clear();
|
gp::gp_adj.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cellhooks = addHook(clearmemory, 500, clearCellMemory);
|
auto cellhooks = addHook(hooks_clearmemory, 500, clearCellMemory);
|
||||||
|
|
||||||
EX bool isNeighbor(cell *c1, cell *c2) {
|
EX bool isNeighbor(cell *c1, cell *c2) {
|
||||||
for(int i=0; i<c1->type; i++) if(c1->move(i) == c2) return true;
|
for(int i=0; i<c1->type; i++) if(c1->move(i) == c2) return true;
|
||||||
|
@ -347,7 +347,7 @@ int arg::readCommon() {
|
|||||||
|
|
||||||
EX purehookset hooks_config;
|
EX purehookset hooks_config;
|
||||||
|
|
||||||
EX hookset<int()> *hooks_args;
|
EX hookset<int()> hooks_args;
|
||||||
|
|
||||||
namespace arg {
|
namespace arg {
|
||||||
|
|
||||||
@ -357,12 +357,13 @@ namespace arg {
|
|||||||
curphase = phase;
|
curphase = phase;
|
||||||
callhooks(hooks_config);
|
callhooks(hooks_config);
|
||||||
while(pos < isize(argument)) {
|
while(pos < isize(argument)) {
|
||||||
for(auto& h: *hooks_args) {
|
int r = callhandlers(1, hooks_args);
|
||||||
int r = h.second(); if(r == 2) return; if(r == 0) { lshift(); goto cont; }
|
switch (r) {
|
||||||
|
case 0: lshift(); break;
|
||||||
|
case 1: printf("Unknown option: %s\n", argcs()); exit(3); break;
|
||||||
|
case 2: return;
|
||||||
|
default: assert(false);
|
||||||
}
|
}
|
||||||
printf("Unknown option: %s\n", argcs());
|
|
||||||
exit(3);
|
|
||||||
cont: ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3441,7 +3441,7 @@ EX namespace ca {
|
|||||||
}
|
}
|
||||||
EX }
|
EX }
|
||||||
|
|
||||||
auto ccm = addHook(clearmemory, 0, [] () {
|
auto ccm = addHook(hooks_clearmemory, 0, [] () {
|
||||||
heat::offscreen_heat.clear();
|
heat::offscreen_heat.clear();
|
||||||
heat::offscreen_fire.clear();
|
heat::offscreen_fire.clear();
|
||||||
princess::clear();
|
princess::clear();
|
||||||
|
@ -198,7 +198,7 @@ EX namespace brownian {
|
|||||||
vector<cell*> to_remove;
|
vector<cell*> to_remove;
|
||||||
for(auto p: futures) if(is_cell_removed(p.first)) to_remove.push_back(p.first);
|
for(auto p: futures) if(is_cell_removed(p.first)) to_remove.push_back(p.first);
|
||||||
for(auto r: to_remove) futures.erase(r);
|
for(auto r: to_remove) futures.erase(r);
|
||||||
}) + addHook(clearmemory, 0, [] () { futures.clear(); })
|
}) + addHook(hooks_clearmemory, 0, [] () { futures.clear(); })
|
||||||
+ addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(futures); });
|
+ addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(futures); });
|
||||||
|
|
||||||
EX }
|
EX }
|
||||||
@ -554,7 +554,7 @@ EX bool mightBeMine(cell *c) {
|
|||||||
return c->wall == waMineUnknown || c->wall == waMineMine;
|
return c->wall == waMineUnknown || c->wall == waMineMine;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool(cell*)> *hooks_mark;
|
EX hookset<bool(cell*)> hooks_mark;
|
||||||
|
|
||||||
EX void performMarkCommand(cell *c) {
|
EX void performMarkCommand(cell *c) {
|
||||||
if(!c) return;
|
if(!c) return;
|
||||||
|
@ -1851,7 +1851,7 @@ ld xintval(const hyperpoint& h) {
|
|||||||
|
|
||||||
EX ld backbrightness = .25;
|
EX ld backbrightness = .25;
|
||||||
|
|
||||||
purehookset hook_drawqueue;
|
purehookset hooks_drawqueue;
|
||||||
|
|
||||||
constexpr int PMAX = int(PPR::MAX);
|
constexpr int PMAX = int(PPR::MAX);
|
||||||
int qp[PMAX], qp0[PMAX];
|
int qp[PMAX], qp0[PMAX];
|
||||||
@ -2037,7 +2037,7 @@ EX void draw_main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CAP_VR
|
#if CAP_VR
|
||||||
EX hookset<bool()> *hooks_vr_draw_all;
|
EX hookset<bool()> hooks_vr_draw_all;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EX void drawqueue() {
|
EX void drawqueue() {
|
||||||
|
@ -1294,9 +1294,9 @@ discovery::~discovery() { schedule_destruction(); if(discoverer) discoverer->joi
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int hk =
|
int hk =
|
||||||
#if CAP_THREAD && MAXMDIM >= 4
|
#if CAP_THREAD
|
||||||
+ addHook(on_geometry_change, 100, [] { for(auto& d:discoveries) if(!d.second.is_suspended) d.second.suspend(); })
|
+ addHook(hooks_on_geometry_change, 100, [] { for(auto& d:discoveries) if(!d.second.is_suspended) d.second.suspend(); })
|
||||||
+ addHook(final_cleanup, 100, [] {
|
+ addHook(hooks_final_cleanup, 100, [] {
|
||||||
for(auto& d:discoveries) { d.second.schedule_destruction(); if(d.second.is_suspended) d.second.activate(); }
|
for(auto& d:discoveries) { d.second.schedule_destruction(); if(d.second.is_suspended) d.second.activate(); }
|
||||||
discoveries.clear();
|
discoveries.clear();
|
||||||
})
|
})
|
||||||
@ -1314,7 +1314,7 @@ int hk =
|
|||||||
#endif
|
#endif
|
||||||
+ 0;
|
+ 0;
|
||||||
|
|
||||||
EX purehookset on_geometry_change;
|
EX purehookset hooks_on_geometry_change;
|
||||||
|
|
||||||
EX int field_celldistance(cell *c1, cell *c2) {
|
EX int field_celldistance(cell *c1, cell *c2) {
|
||||||
if(geometry != gFieldQuotient) return DISTANCE_UNKNOWN;
|
if(geometry != gFieldQuotient) return DISTANCE_UNKNOWN;
|
||||||
|
@ -40,8 +40,8 @@ EX bool hide_player() {
|
|||||||
|
|
||||||
#define ADC(V,c) for(const transmatrix& V: current_display->all_drawn_copies[c])
|
#define ADC(V,c) for(const transmatrix& V: current_display->all_drawn_copies[c])
|
||||||
|
|
||||||
EX hookset<bool(int sym, int uni)> *hooks_handleKey;
|
EX hookset<bool(int sym, int uni)> hooks_handleKey;
|
||||||
EX hookset<bool(cell *c, const transmatrix& V)> *hooks_drawcell;
|
EX hookset<bool(cell *c, const transmatrix& V)> hooks_drawcell;
|
||||||
EX purehookset hooks_frame, hooks_markers;
|
EX purehookset hooks_frame, hooks_markers;
|
||||||
|
|
||||||
EX ld animation_factor = 1;
|
EX ld animation_factor = 1;
|
||||||
@ -5154,7 +5154,7 @@ EX void clearAnimations() {
|
|||||||
fallanims.clear();
|
fallanims.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto graphcm = addHook(clearmemory, 0, [] () {
|
auto graphcm = addHook(hooks_clearmemory, 0, [] () {
|
||||||
DEBBI(DF_MEMORY, ("clear graph memory"));
|
DEBBI(DF_MEMORY, ("clear graph memory"));
|
||||||
mouseover = centerover = lmouseover = NULL;
|
mouseover = centerover = lmouseover = NULL;
|
||||||
gmatrix.clear(); gmatrix0.clear(); current_display->all_drawn_copies.clear();
|
gmatrix.clear(); gmatrix0.clear(); current_display->all_drawn_copies.clear();
|
||||||
|
4
help.cpp
4
help.cpp
@ -772,7 +772,7 @@ EX void appendHelp(string s) {
|
|||||||
unsigned char lastval;
|
unsigned char lastval;
|
||||||
int windtotal;
|
int windtotal;
|
||||||
|
|
||||||
EX hookset<void(cell*)> *hooks_mouseover;
|
EX hookset<void(cell*)> hooks_mouseover;
|
||||||
|
|
||||||
EX void describeMouseover() {
|
EX void describeMouseover() {
|
||||||
DEBBI(DF_GRAPH, ("describeMouseover"));
|
DEBBI(DF_GRAPH, ("describeMouseover"));
|
||||||
@ -1017,7 +1017,7 @@ EX void showHelp() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool()> *hooks_default_help;
|
EX hookset<bool()> hooks_default_help;
|
||||||
|
|
||||||
EX void gotoHelp(const string& h) {
|
EX void gotoHelp(const string& h) {
|
||||||
help = h;
|
help = h;
|
||||||
|
@ -217,7 +217,7 @@ void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) {
|
|||||||
|
|
||||||
extern int hrand(int);
|
extern int hrand(int);
|
||||||
|
|
||||||
EX hookset<void(heptagon*, int)> *hooks_createStep;
|
EX hookset<void(heptagon*, int)> hooks_createStep;
|
||||||
|
|
||||||
// create h->move(d) if not created yet
|
// create h->move(d) if not created yet
|
||||||
heptagon *createStep(heptagon *h, int d) {
|
heptagon *createStep(heptagon *h, int d) {
|
||||||
|
@ -689,7 +689,7 @@ EX namespace history {
|
|||||||
auto hookArg = addHook(hooks_args, 100, readArgs);
|
auto hookArg = addHook(hooks_args, 100, readArgs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto hooks = addHook(clearmemory, 0, [] () {
|
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||||
history::renderAutoband();
|
history::renderAutoband();
|
||||||
history::on = false;
|
history::on = false;
|
||||||
history::killhistory.clear();
|
history::killhistory.clear();
|
||||||
|
2
hud.cpp
2
hud.cpp
@ -328,7 +328,7 @@ void displayglyph2(int cx, int cy, int buttonsize, int i) {
|
|||||||
|
|
||||||
EX bool nohud, nomenukey;
|
EX bool nohud, nomenukey;
|
||||||
|
|
||||||
EX hookset<bool()> *hooks_prestats;
|
EX hookset<bool()> hooks_prestats;
|
||||||
|
|
||||||
#if CAP_SHAPES
|
#if CAP_SHAPES
|
||||||
void drawMobileArrow(int i) {
|
void drawMobileArrow(int i) {
|
||||||
|
@ -29,7 +29,7 @@ void moreStack() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace hr {
|
namespace hr {
|
||||||
EX hookset<bool(int argc, char** argv)> *hooks_main;
|
EX hookset<bool(int argc, char** argv)> hooks_main;
|
||||||
|
|
||||||
EX int hyper_main(int argc, char **argv) {
|
EX int hyper_main(int argc, char **argv) {
|
||||||
using namespace hr;
|
using namespace hr;
|
||||||
|
60
hyper.h
60
hyper.h
@ -438,8 +438,41 @@ struct movedir {
|
|||||||
|
|
||||||
// shmup
|
// shmup
|
||||||
|
|
||||||
template<class T> class hookset : public map<int, function<T>> {};
|
template<class T>
|
||||||
typedef hookset<void()> *purehookset;
|
class hookset {
|
||||||
|
std::map<int, std::function<T>> *map_ = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
template<class U>
|
||||||
|
int add(int prio, U&& hook) {
|
||||||
|
if (map_ == nullptr) map_ = new std::map<int, std::function<T>>();
|
||||||
|
while (map_->count(prio)) {
|
||||||
|
prio++;
|
||||||
|
}
|
||||||
|
map_->emplace(prio, static_cast<U&&>(hook));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class... U>
|
||||||
|
void callhooks(U&&... args) const {
|
||||||
|
if (map_ == nullptr) return;
|
||||||
|
for (const auto& p : *map_) {
|
||||||
|
p.second(static_cast<U&&>(args)...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class V, class... U>
|
||||||
|
V callhandlers(V zero, U&&... args) const {
|
||||||
|
if (map_ == nullptr) return zero;
|
||||||
|
for (const auto& p : *map_) {
|
||||||
|
auto z = p.second(static_cast<U&&>(args)...);
|
||||||
|
if (z != zero) return z;
|
||||||
|
}
|
||||||
|
return zero;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using purehookset = hookset<void()>;
|
||||||
|
|
||||||
static const int NOHINT = -1;
|
static const int NOHINT = -1;
|
||||||
|
|
||||||
@ -666,27 +699,16 @@ color_t darkena(color_t c, int lev, int a);
|
|||||||
|
|
||||||
static const int DISTANCE_UNKNOWN = 127;
|
static const int DISTANCE_UNKNOWN = 127;
|
||||||
|
|
||||||
#include <functional>
|
template<class T, class U> int addHook(hookset<T>& m, int prio, U&& hook) {
|
||||||
|
return m.add(prio, static_cast<U&&>(hook));
|
||||||
template<class T, class U> int addHook(hookset<T>*& m, int prio, const U& hook) {
|
|
||||||
if(!m) m = new hookset<T> ();
|
|
||||||
while(m->count(prio)) {
|
|
||||||
prio++;
|
|
||||||
}
|
|
||||||
(*m)[prio] = hook;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... U> void callhooks(hookset<T> *h, U&&... args) {
|
template<class T, class... U> void callhooks(const hookset<T>& h, U&&... args) {
|
||||||
if(h) for(auto& p: *h) p.second(std::forward<U>(args)...);
|
return h.callhooks(static_cast<U&&>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&&... args) {
|
template<class T, class V, class... U> V callhandlers(V zero, const hookset<T>& h, U&&... args) {
|
||||||
if(h) for(auto& p: *h) {
|
return h.callhandlers(zero, static_cast<U&&>(args)...);
|
||||||
auto z = p.second(std::forward<U>(args)...);
|
|
||||||
if(z != zero) return z;
|
|
||||||
}
|
|
||||||
return zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string XLAT(string);
|
string XLAT(string);
|
||||||
|
@ -2104,8 +2104,8 @@ EX transmatrix& get_view_orientation() {
|
|||||||
return prod ? NLP : View;
|
return prod ? NLP : View;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool(const transmatrix&)> *hooks_rotate_view;
|
EX hookset<bool(const transmatrix&)> hooks_rotate_view;
|
||||||
EX hookset<bool(const hyperpoint&)> *hooks_shift_view;
|
EX hookset<bool(const hyperpoint&)> hooks_shift_view;
|
||||||
|
|
||||||
/** rotate the view using the given rotation matrix */
|
/** rotate the view using the given rotation matrix */
|
||||||
EX void rotate_view(transmatrix T) {
|
EX void rotate_view(transmatrix T) {
|
||||||
|
@ -276,7 +276,7 @@ EX bool createOnSea(eLand old) {
|
|||||||
(old == laOcean && (chaosmode ? hrand(2) : !generatingEquidistant));
|
(old == laOcean && (chaosmode ? hrand(2) : !generatingEquidistant));
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<eLand(eLand)> *hooks_nextland;
|
EX hookset<eLand(eLand)> hooks_nextland;
|
||||||
|
|
||||||
EX eLand getNewLand(eLand old) {
|
EX eLand getNewLand(eLand old) {
|
||||||
|
|
||||||
|
@ -2463,7 +2463,7 @@ namespace mapeditor {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto hooks = addHook(clearmemory, 0, [] () {
|
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||||
if(mapeditor::painttype == 4)
|
if(mapeditor::painttype == 4)
|
||||||
mapeditor::painttype = 0, mapeditor::paintwhat = 0,
|
mapeditor::painttype = 0, mapeditor::paintwhat = 0,
|
||||||
mapeditor::paintwhat_str = "clear monster";
|
mapeditor::paintwhat_str = "clear monster";
|
||||||
|
18
menus.cpp
18
menus.cpp
@ -959,18 +959,22 @@ EX void showStartMenu() {
|
|||||||
// -- overview --
|
// -- overview --
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
typedef pair<string, reaction_t> named_functionality;
|
struct named_functionality {
|
||||||
|
std::string first;
|
||||||
|
reaction_t second;
|
||||||
|
explicit named_functionality() = default;
|
||||||
|
explicit named_functionality(std::string s, reaction_t r) : first(std::move(s)), second(std::move(r)) {}
|
||||||
|
friend bool operator==(const named_functionality& a, const named_functionality& b) { return a.first == b.first; }
|
||||||
|
friend bool operator!=(const named_functionality& a, const named_functionality& b) { return a.first != b.first; }
|
||||||
|
};
|
||||||
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
|
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EX hookset<named_functionality()> *hooks_o_key;
|
EX hookset<named_functionality()> hooks_o_key;
|
||||||
|
|
||||||
EX named_functionality get_o_key() {
|
EX named_functionality get_o_key() {
|
||||||
|
auto res = callhandlers(named_functionality(), hooks_o_key);
|
||||||
if(hooks_o_key) for(auto& h: *hooks_o_key) {
|
if (res != named_functionality()) return res;
|
||||||
auto res = h.second();
|
|
||||||
if(res.first != "") return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CAP_DAILY
|
#if CAP_DAILY
|
||||||
if(daily::on)
|
if(daily::on)
|
||||||
|
@ -82,7 +82,7 @@ void gamedata::restoregame() {
|
|||||||
gamedata_all(*this);
|
gamedata_all(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<void(gamedata*)> *hooks_gamedata;
|
EX hookset<void(gamedata*)> hooks_gamedata;
|
||||||
|
|
||||||
EX namespace gamestack {
|
EX namespace gamestack {
|
||||||
|
|
||||||
|
@ -1666,7 +1666,7 @@ EX namespace patterns {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<int(cell*)> *hooks_generate_canvas;
|
EX hookset<int(cell*)> hooks_generate_canvas;
|
||||||
|
|
||||||
EX int generateCanvas(cell *c) {
|
EX int generateCanvas(cell *c) {
|
||||||
|
|
||||||
@ -3017,7 +3017,7 @@ int read_pattern_args() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ah_pattern = addHook(hooks_args, 0, read_pattern_args) + addHook(clearmemory, 100, [] { patterns::computed_nearer_map.clear(); patterns::computed_furthest_map.clear(); });
|
auto ah_pattern = addHook(hooks_args, 0, read_pattern_args) + addHook(hooks_clearmemory, 100, [] { patterns::computed_nearer_map.clear(); patterns::computed_furthest_map.clear(); });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,7 @@ heptspin sview;
|
|||||||
#if CAP_COMMANDLINE
|
#if CAP_COMMANDLINE
|
||||||
auto hook =
|
auto hook =
|
||||||
addHook(hooks_args, 100, readArgs)
|
addHook(hooks_args, 100, readArgs)
|
||||||
+ addHook(clearmemory, 0, []() {
|
+ addHook(hooks_clearmemory, 0, []() {
|
||||||
track_ready = false;
|
track_ready = false;
|
||||||
track.clear();
|
track.clear();
|
||||||
rti.clear();
|
rti.clear();
|
||||||
|
@ -169,8 +169,8 @@ string build_getter(string type, string name, int index) {
|
|||||||
#define GET(array, index) array "[" index "]"
|
#define GET(array, index) array "[" index "]"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EX hookset<void(string&, string&)> *hooks_rayshader;
|
EX hookset<void(string&, string&)> hooks_rayshader;
|
||||||
EX hookset<bool(shared_ptr<raycaster>)> *hooks_rayset;
|
EX hookset<bool(shared_ptr<raycaster>)> hooks_rayset;
|
||||||
|
|
||||||
void enable_raycaster() {
|
void enable_raycaster() {
|
||||||
if(geometry != last_geometry) reset_raycaster();
|
if(geometry != last_geometry) reset_raycaster();
|
||||||
|
@ -346,7 +346,7 @@ bool handleKey(int sym, int uni) {
|
|||||||
auto xhook = addHook(hooks_args, 100, readArgs)
|
auto xhook = addHook(hooks_args, 100, readArgs)
|
||||||
+ addHook(hooks_handleKey, 0, handleKey)
|
+ addHook(hooks_handleKey, 0, handleKey)
|
||||||
+ addHook(hooks_prestats, 0, frame)
|
+ addHook(hooks_prestats, 0, frame)
|
||||||
+ addHook(clearmemory, 40, [] () { snubon = false; } )
|
+ addHook(hooks_clearmemory, 40, [] () { snubon = false; } )
|
||||||
+ addHook(rvtour::hooks_build_rvtour, 142, [] (vector<tour::slide>& v) {
|
+ addHook(rvtour::hooks_build_rvtour, 142, [] (vector<tour::slide>& v) {
|
||||||
using namespace tour;
|
using namespace tour;
|
||||||
v.push_back(
|
v.push_back(
|
||||||
|
@ -1232,7 +1232,7 @@ auto hooks =
|
|||||||
#if CAP_COMMANDLINE
|
#if CAP_COMMANDLINE
|
||||||
addHook(hooks_args, 100, readArgs) +
|
addHook(hooks_args, 100, readArgs) +
|
||||||
#endif
|
#endif
|
||||||
addHook(clearmemory, 0, close) +
|
addHook(hooks_clearmemory, 0, close) +
|
||||||
addHook(hooks_prestats, 100, rogueviz_hud) +
|
addHook(hooks_prestats, 100, rogueviz_hud) +
|
||||||
addHook(shmup::hooks_draw, 100, drawVertex) +
|
addHook(shmup::hooks_draw, 100, drawVertex) +
|
||||||
addHook(shmup::hooks_describe, 100, describe_monster) +
|
addHook(shmup::hooks_describe, 100, describe_monster) +
|
||||||
@ -1240,7 +1240,7 @@ auto hooks =
|
|||||||
addHook(hooks_o_key, 100, o_key) +
|
addHook(hooks_o_key, 100, o_key) +
|
||||||
|
|
||||||
#if CAP_RVSLIDES
|
#if CAP_RVSLIDES
|
||||||
addHook(tour::ss::extra_slideshows, 100, [] (bool view) {
|
addHook(tour::ss::hooks_extra_slideshows, 100, [] (bool view) {
|
||||||
if(!view) return 1;
|
if(!view) return 1;
|
||||||
dialog::addBoolItem(XLAT("RogueViz Tour"), tour::ss::wts == &rvtour::rvslides[0], 'r');
|
dialog::addBoolItem(XLAT("RogueViz Tour"), tour::ss::wts == &rvtour::rvslides[0], 'r');
|
||||||
dialog::add_action([] { tour::ss::wts = rvtour::gen_rvtour(); popScreen(); });
|
dialog::add_action([] { tour::ss::wts = rvtour::gen_rvtour(); popScreen(); });
|
||||||
|
@ -107,11 +107,11 @@ namespace rogueviz {
|
|||||||
|
|
||||||
extern colorpair dftcolor;
|
extern colorpair dftcolor;
|
||||||
|
|
||||||
inline hookset<void(vertexdata&, cell*, shmup::monster*, int)> *hooks_drawvertex;
|
inline hookset<void(vertexdata&, cell*, shmup::monster*, int)> hooks_drawvertex;
|
||||||
inline hookset<bool(edgeinfo*, bool store)> *hooks_alt_edges;
|
inline hookset<bool(edgeinfo*, bool store)> hooks_alt_edges;
|
||||||
inline purehookset hooks_rvmenu;
|
inline purehookset hooks_rvmenu;
|
||||||
inline hookset<bool()> *hooks_rvmenu_replace;
|
inline hookset<bool()> hooks_rvmenu_replace;
|
||||||
inline hookset<bool(int&, string&, FILE*)> *hooks_readcolor;
|
inline hookset<bool(int&, string&, FILE*)> hooks_readcolor;
|
||||||
inline purehookset hooks_close;
|
inline purehookset hooks_close;
|
||||||
|
|
||||||
void readcolor(const string& cfname);
|
void readcolor(const string& cfname);
|
||||||
@ -121,7 +121,7 @@ namespace rogueviz {
|
|||||||
|
|
||||||
namespace rvtour {
|
namespace rvtour {
|
||||||
using namespace hr::tour;
|
using namespace hr::tour;
|
||||||
inline hookset<void(vector<slide>&)> *hooks_build_rvtour;
|
inline hookset<void(vector<slide>&)> hooks_build_rvtour;
|
||||||
slide *gen_rvtour();
|
slide *gen_rvtour();
|
||||||
|
|
||||||
template<class T> function<void(presmode)> roguevizslide(char c, const T& t) {
|
template<class T> function<void(presmode)> roguevizslide(char c, const T& t) {
|
||||||
|
@ -199,7 +199,7 @@ named_functionality o_key() {
|
|||||||
|
|
||||||
auto hchook = addHook(hooks_drawcell, 100, draw_snow)
|
auto hchook = addHook(hooks_drawcell, 100, draw_snow)
|
||||||
|
|
||||||
+ addHook(clearmemory, 40, [] () {
|
+ addHook(hooks_clearmemory, 40, [] () {
|
||||||
matrices_at.clear();
|
matrices_at.clear();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
10
shmup.cpp
10
shmup.cpp
@ -236,7 +236,7 @@ bool isBullet(monster *m) {
|
|||||||
bool isPlayer(monster *m) { return m->type == moPlayer; }
|
bool isPlayer(monster *m) { return m->type == moPlayer; }
|
||||||
bool isMonster(monster *m) { return m->type != moPlayer && m->type != moBullet; }
|
bool isMonster(monster *m) { return m->type != moPlayer && m->type != moBullet; }
|
||||||
|
|
||||||
EX hookset<bool(shmup::monster*)> *hooks_kill;
|
EX hookset<bool(shmup::monster*)> hooks_kill;
|
||||||
|
|
||||||
void killMonster(monster* m, eMonster who_kills, flagtype flags = 0) {
|
void killMonster(monster* m, eMonster who_kills, flagtype flags = 0) {
|
||||||
int tk = tkills();
|
int tk = tkills();
|
||||||
@ -2456,7 +2456,7 @@ EX void fixStorage() {
|
|||||||
for(monster *m: restore) m->store();
|
for(monster *m: restore) m->store();
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool(int)> *hooks_turn;
|
EX hookset<bool(int)> hooks_turn;
|
||||||
|
|
||||||
EX void turn(int delta) {
|
EX void turn(int delta) {
|
||||||
|
|
||||||
@ -2771,7 +2771,7 @@ EX bool boatAt(cell *c) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool(const transmatrix&, cell*, shmup::monster*)> *hooks_draw;
|
EX hookset<bool(const transmatrix&, cell*, shmup::monster*)> hooks_draw;
|
||||||
|
|
||||||
EX void clearMonsters() {
|
EX void clearMonsters() {
|
||||||
for(mit it = monstersAt.begin(); it != monstersAt.end(); it++)
|
for(mit it = monstersAt.begin(); it != monstersAt.end(); it++)
|
||||||
@ -2833,7 +2833,7 @@ EX void virtualRebase(shmup::monster *m) {
|
|||||||
virtualRebase(m->base, m->at);
|
virtualRebase(m->base, m->at);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hookset<bool(shmup::monster*, string&)> *hooks_describe;
|
EX hookset<bool(shmup::monster*, string&)> hooks_describe;
|
||||||
|
|
||||||
EX void addShmupHelp(string& out) {
|
EX void addShmupHelp(string& out) {
|
||||||
if(shmup::mousetarget && sqdist(mouseh, tC0(shmup::mousetarget->pat)) < .1) {
|
if(shmup::mousetarget && sqdist(mouseh, tC0(shmup::mousetarget->pat)) < .1) {
|
||||||
@ -2844,7 +2844,7 @@ EX void addShmupHelp(string& out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hooks = addHook(clearmemory, 0, shmup::clearMemory) +
|
auto hooks = addHook(hooks_clearmemory, 0, shmup::clearMemory) +
|
||||||
addHook(hooks_gamedata, 0, shmup::gamedata) +
|
addHook(hooks_gamedata, 0, shmup::gamedata) +
|
||||||
addHook(hooks_removecells, 0, [] () {
|
addHook(hooks_removecells, 0, [] () {
|
||||||
for(mit it = monstersAt.begin(); it != monstersAt.end();) {
|
for(mit it = monstersAt.begin(); it != monstersAt.end();) {
|
||||||
|
@ -83,7 +83,7 @@ int musfadeval = 2000;
|
|||||||
|
|
||||||
eLand cid = laNone;
|
eLand cid = laNone;
|
||||||
|
|
||||||
hookset<bool(eLand&)> *hooks_music;
|
hookset<bool(eLand&)> hooks_music;
|
||||||
|
|
||||||
bool music_out_of_focus = false;
|
bool music_out_of_focus = false;
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ EX void handlemusic() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hookset<bool(eLand&)> *hooks_resetmusic;
|
hookset<bool(eLand&)> hooks_resetmusic;
|
||||||
|
|
||||||
EX void resetmusic() {
|
EX void resetmusic() {
|
||||||
if(audio && musicvolume) {
|
if(audio && musicvolume) {
|
||||||
@ -218,7 +218,7 @@ string wheresounds = SOUNDDESTDIR;
|
|||||||
string wheresounds = HYPERPATH "sounds/";
|
string wheresounds = HYPERPATH "sounds/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hookset<bool(const string& s, int vol)> *hooks_sound;
|
hookset<bool(const string& s, int vol)> hooks_sound;
|
||||||
|
|
||||||
EX void playSound(cell *c, const string& fname, int vol) {
|
EX void playSound(cell *c, const string& fname, int vol) {
|
||||||
LATE( hr::playSound(c, fname, vol); )
|
LATE( hr::playSound(c, fname, vol); )
|
||||||
|
18
system.cpp
18
system.cpp
@ -76,7 +76,7 @@ bool do_use_special_land() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Hooks for welcomeMessage. Return true to capture. */
|
/** \brief Hooks for welcomeMessage. Return true to capture. */
|
||||||
EX hookset<bool()> *hooks_welcome_message;
|
EX hookset<bool()> hooks_welcome_message;
|
||||||
|
|
||||||
/** \brief Print the welcome message during the start of game. Depends on the current mode and other settings. */
|
/** \brief Print the welcome message during the start of game. Depends on the current mode and other settings. */
|
||||||
EX void welcomeMessage() {
|
EX void welcomeMessage() {
|
||||||
@ -144,7 +144,7 @@ EX void welcomeMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \brief These hooks are called at the start of initgame. */
|
/** \brief These hooks are called at the start of initgame. */
|
||||||
EX hookset<void()> *hooks_initgame;
|
EX hookset<void()> hooks_initgame;
|
||||||
|
|
||||||
/** \brief initialize the game */
|
/** \brief initialize the game */
|
||||||
EX void initgame() {
|
EX void initgame() {
|
||||||
@ -1249,11 +1249,11 @@ eModel default_model() {
|
|||||||
return mdDisk;
|
return mdDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX purehookset on_geometry_change;
|
EX purehookset hooks_on_geometry_change;
|
||||||
|
|
||||||
EX void set_geometry(eGeometry target) {
|
EX void set_geometry(eGeometry target) {
|
||||||
bool was_default = pmodel == default_model();
|
bool was_default = pmodel == default_model();
|
||||||
callhooks(on_geometry_change);
|
callhooks(hooks_on_geometry_change);
|
||||||
if(geometry != target) {
|
if(geometry != target) {
|
||||||
int old_DIM = GDIM;
|
int old_DIM = GDIM;
|
||||||
stop_game();
|
stop_game();
|
||||||
@ -1500,10 +1500,10 @@ EX void stop_game_and_switch_mode(char switchWhat IS(rg::nothing)) {
|
|||||||
switch_game_mode(switchWhat);
|
switch_game_mode(switchWhat);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX purehookset clearmemory;
|
EX purehookset hooks_clearmemory;
|
||||||
|
|
||||||
EX void clearMemory() {
|
EX void clearMemory() {
|
||||||
callhooks(clearmemory);
|
callhooks(hooks_clearmemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX bool fixseed = false;
|
EX bool fixseed = false;
|
||||||
@ -1547,7 +1547,7 @@ EX void initAll() {
|
|||||||
polygonal::solve();
|
polygonal::solve();
|
||||||
}
|
}
|
||||||
|
|
||||||
EX purehookset final_cleanup;
|
EX purehookset hooks_final_cleanup;
|
||||||
|
|
||||||
EX void finishAll() {
|
EX void finishAll() {
|
||||||
achievement_final(!items[itOrbSafety]);
|
achievement_final(!items[itOrbSafety]);
|
||||||
@ -1561,11 +1561,11 @@ EX void finishAll() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
achievement_close();
|
achievement_close();
|
||||||
callhooks(final_cleanup);
|
callhooks(hooks_final_cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto cgm = addHook(clearmemory, 40, [] () {
|
auto cgm = addHook(hooks_clearmemory, 40, [] () {
|
||||||
pathq.clear();
|
pathq.clear();
|
||||||
dcal.clear();
|
dcal.clear();
|
||||||
clearshadow();
|
clearshadow();
|
||||||
|
@ -1721,7 +1721,7 @@ int textureArgs() {
|
|||||||
|
|
||||||
auto texture_hook =
|
auto texture_hook =
|
||||||
addHook(hooks_args, 100, textureArgs)
|
addHook(hooks_args, 100, textureArgs)
|
||||||
+ addHook(clearmemory, 100, [] () { config.data.pixels_to_draw.clear(); });
|
+ addHook(hooks_clearmemory, 100, [] () { config.data.pixels_to_draw.clear(); });
|
||||||
|
|
||||||
int lastupdate;
|
int lastupdate;
|
||||||
|
|
||||||
|
8
tour.cpp
8
tour.cpp
@ -115,7 +115,7 @@ EX function<bool(eLand)> showland;
|
|||||||
EX string slidecommand;
|
EX string slidecommand;
|
||||||
|
|
||||||
/** \brief hooks to execute after calling presentation */
|
/** \brief hooks to execute after calling presentation */
|
||||||
EX hookset<void(int)> *hooks_slide;
|
EX hookset<void(int)> hooks_slide;
|
||||||
|
|
||||||
/** \brief call action(mode) for the current slide. Also sets up some default stuff */
|
/** \brief call action(mode) for the current slide. Also sets up some default stuff */
|
||||||
EX void presentation(presmode mode) {
|
EX void presentation(presmode mode) {
|
||||||
@ -377,13 +377,13 @@ EX namespace ss {
|
|||||||
|
|
||||||
string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*(";
|
string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*(";
|
||||||
|
|
||||||
EX hookset<int(bool)> *extra_slideshows;
|
EX hookset<int(bool)> hooks_extra_slideshows;
|
||||||
|
|
||||||
EX void slideshow_menu() {
|
EX void slideshow_menu() {
|
||||||
dialog::init(XLAT("slideshows"), forecolor, 150, 100);
|
dialog::init(XLAT("slideshows"), forecolor, 150, 100);
|
||||||
dialog::addBoolItem(XLAT("Guided Tour"), wts == default_slides, 't');
|
dialog::addBoolItem(XLAT("Guided Tour"), wts == default_slides, 't');
|
||||||
dialog::add_action([] { wts = default_slides; popScreen(); });
|
dialog::add_action([] { wts = default_slides; popScreen(); });
|
||||||
callhooks(extra_slideshows, true);
|
callhooks(hooks_extra_slideshows, true);
|
||||||
dialog::addBack();
|
dialog::addBack();
|
||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
@ -438,7 +438,7 @@ EX namespace ss {
|
|||||||
}
|
}
|
||||||
dialog::addBreak(50);
|
dialog::addBreak(50);
|
||||||
bool b = false;
|
bool b = false;
|
||||||
if(callhandlers(0, extra_slideshows, b)) {
|
if(callhandlers(0, hooks_extra_slideshows, b)) {
|
||||||
dialog::addItem(XLAT("change slideshow"), '1');
|
dialog::addItem(XLAT("change slideshow"), '1');
|
||||||
dialog::add_action_push(slideshow_menu);
|
dialog::add_action_push(slideshow_menu);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ auto wfc_hook =
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto cgm = addHook(clearmemory, 40, [] () { centers.clear(); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(centers, is_cell_removed); });
|
auto cgm = addHook(hooks_clearmemory, 40, [] () { centers.clear(); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(centers, is_cell_removed); });
|
||||||
|
|
||||||
EX }
|
EX }
|
||||||
|
|
||||||
|
@ -799,7 +799,7 @@ EX namespace yendor {
|
|||||||
achievement_victory(false);
|
achievement_victory(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hooks = addHook(clearmemory, 0, [] () {
|
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||||
yendor::yii = NOYENDOR; yendor::yi.clear();
|
yendor::yii = NOYENDOR; yendor::yi.clear();
|
||||||
}) + addHook(hooks_removecells, 0, [] () {
|
}) + addHook(hooks_removecells, 0, [] () {
|
||||||
eliminate_if(yendor::yi, [] (yendorinfo& i) {
|
eliminate_if(yendor::yi, [] (yendorinfo& i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user