mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-10 15:59:53 +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_VR
|
||||
EX hookset<bool()> *hooks_vr_eye_view, *hooks_vr_eye_projection;
|
||||
EX hookset<bool()> hooks_vr_eye_view, hooks_vr_eye_projection;
|
||||
#endif
|
||||
|
||||
EX void eyewidth_translate(int ed) {
|
||||
|
@ -1332,7 +1332,7 @@ EX bool quickfind(eLand l) {
|
||||
#define I2000 (INVLUCK?600:2000)
|
||||
#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) {
|
||||
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();
|
||||
blizzardcells.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;
|
||||
|
||||
EX hookset<hrmap*()> *hooks_newmap;
|
||||
EX hookset<hrmap*()> hooks_newmap;
|
||||
|
||||
/** create a map in the current geometry */
|
||||
EX void initcells() {
|
||||
@ -1175,7 +1175,7 @@ EX void clearCellMemory() {
|
||||
gp::gp_adj.clear();
|
||||
}
|
||||
|
||||
auto cellhooks = addHook(clearmemory, 500, clearCellMemory);
|
||||
auto cellhooks = addHook(hooks_clearmemory, 500, clearCellMemory);
|
||||
|
||||
EX bool isNeighbor(cell *c1, cell *c2) {
|
||||
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 hookset<int()> *hooks_args;
|
||||
EX hookset<int()> hooks_args;
|
||||
|
||||
namespace arg {
|
||||
|
||||
@ -357,12 +357,13 @@ namespace arg {
|
||||
curphase = phase;
|
||||
callhooks(hooks_config);
|
||||
while(pos < isize(argument)) {
|
||||
for(auto& h: *hooks_args) {
|
||||
int r = h.second(); if(r == 2) return; if(r == 0) { lshift(); goto cont; }
|
||||
int r = callhandlers(1, hooks_args);
|
||||
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 }
|
||||
|
||||
auto ccm = addHook(clearmemory, 0, [] () {
|
||||
auto ccm = addHook(hooks_clearmemory, 0, [] () {
|
||||
heat::offscreen_heat.clear();
|
||||
heat::offscreen_fire.clear();
|
||||
princess::clear();
|
||||
|
@ -198,7 +198,7 @@ EX namespace brownian {
|
||||
vector<cell*> to_remove;
|
||||
for(auto p: futures) if(is_cell_removed(p.first)) to_remove.push_back(p.first);
|
||||
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); });
|
||||
|
||||
EX }
|
||||
@ -554,7 +554,7 @@ EX bool mightBeMine(cell *c) {
|
||||
return c->wall == waMineUnknown || c->wall == waMineMine;
|
||||
}
|
||||
|
||||
EX hookset<bool(cell*)> *hooks_mark;
|
||||
EX hookset<bool(cell*)> hooks_mark;
|
||||
|
||||
EX void performMarkCommand(cell *c) {
|
||||
if(!c) return;
|
||||
|
@ -1851,7 +1851,7 @@ ld xintval(const hyperpoint& h) {
|
||||
|
||||
EX ld backbrightness = .25;
|
||||
|
||||
purehookset hook_drawqueue;
|
||||
purehookset hooks_drawqueue;
|
||||
|
||||
constexpr int PMAX = int(PPR::MAX);
|
||||
int qp[PMAX], qp0[PMAX];
|
||||
@ -2037,7 +2037,7 @@ EX void draw_main() {
|
||||
}
|
||||
|
||||
#if CAP_VR
|
||||
EX hookset<bool()> *hooks_vr_draw_all;
|
||||
EX hookset<bool()> hooks_vr_draw_all;
|
||||
#endif
|
||||
|
||||
EX void drawqueue() {
|
||||
|
2722
fieldpattern.cpp
2722
fieldpattern.cpp
File diff suppressed because it is too large
Load Diff
@ -40,8 +40,8 @@ EX bool hide_player() {
|
||||
|
||||
#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(cell *c, const transmatrix& V)> *hooks_drawcell;
|
||||
EX hookset<bool(int sym, int uni)> hooks_handleKey;
|
||||
EX hookset<bool(cell *c, const transmatrix& V)> hooks_drawcell;
|
||||
EX purehookset hooks_frame, hooks_markers;
|
||||
|
||||
EX ld animation_factor = 1;
|
||||
@ -5154,7 +5154,7 @@ EX void clearAnimations() {
|
||||
fallanims.clear();
|
||||
}
|
||||
|
||||
auto graphcm = addHook(clearmemory, 0, [] () {
|
||||
auto graphcm = addHook(hooks_clearmemory, 0, [] () {
|
||||
DEBBI(DF_MEMORY, ("clear graph memory"));
|
||||
mouseover = centerover = lmouseover = NULL;
|
||||
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;
|
||||
int windtotal;
|
||||
|
||||
EX hookset<void(cell*)> *hooks_mouseover;
|
||||
EX hookset<void(cell*)> hooks_mouseover;
|
||||
|
||||
EX void 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) {
|
||||
help = h;
|
||||
|
@ -217,7 +217,7 @@ void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) {
|
||||
|
||||
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
|
||||
heptagon *createStep(heptagon *h, int d) {
|
||||
|
@ -689,7 +689,7 @@ EX namespace history {
|
||||
auto hookArg = addHook(hooks_args, 100, readArgs);
|
||||
#endif
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, [] () {
|
||||
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||
history::renderAutoband();
|
||||
history::on = false;
|
||||
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 hookset<bool()> *hooks_prestats;
|
||||
EX hookset<bool()> hooks_prestats;
|
||||
|
||||
#if CAP_SHAPES
|
||||
void drawMobileArrow(int i) {
|
||||
|
@ -29,7 +29,7 @@ void moreStack() {
|
||||
#endif
|
||||
|
||||
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) {
|
||||
using namespace hr;
|
||||
|
60
hyper.h
60
hyper.h
@ -438,8 +438,41 @@ struct movedir {
|
||||
|
||||
// shmup
|
||||
|
||||
template<class T> class hookset : public map<int, function<T>> {};
|
||||
typedef hookset<void()> *purehookset;
|
||||
template<class T>
|
||||
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;
|
||||
|
||||
@ -666,27 +699,16 @@ color_t darkena(color_t c, int lev, int a);
|
||||
|
||||
static const int DISTANCE_UNKNOWN = 127;
|
||||
|
||||
#include <functional>
|
||||
|
||||
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> int addHook(hookset<T>& m, int prio, U&& hook) {
|
||||
return m.add(prio, static_cast<U&&>(hook));
|
||||
}
|
||||
|
||||
template<class T, class... U> void callhooks(hookset<T> *h, U&&... args) {
|
||||
if(h) for(auto& p: *h) p.second(std::forward<U>(args)...);
|
||||
template<class T, class... U> void callhooks(const hookset<T>& h, 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) {
|
||||
if(h) for(auto& p: *h) {
|
||||
auto z = p.second(std::forward<U>(args)...);
|
||||
if(z != zero) return z;
|
||||
}
|
||||
return zero;
|
||||
template<class T, class V, class... U> V callhandlers(V zero, const hookset<T>& h, U&&... args) {
|
||||
return h.callhandlers(zero, static_cast<U&&>(args)...);
|
||||
}
|
||||
|
||||
string XLAT(string);
|
||||
|
@ -2104,8 +2104,8 @@ EX transmatrix& get_view_orientation() {
|
||||
return prod ? NLP : View;
|
||||
}
|
||||
|
||||
EX hookset<bool(const transmatrix&)> *hooks_rotate_view;
|
||||
EX hookset<bool(const hyperpoint&)> *hooks_shift_view;
|
||||
EX hookset<bool(const transmatrix&)> hooks_rotate_view;
|
||||
EX hookset<bool(const hyperpoint&)> hooks_shift_view;
|
||||
|
||||
/** rotate the view using the given rotation matrix */
|
||||
EX void rotate_view(transmatrix T) {
|
||||
|
@ -276,7 +276,7 @@ EX bool createOnSea(eLand old) {
|
||||
(old == laOcean && (chaosmode ? hrand(2) : !generatingEquidistant));
|
||||
}
|
||||
|
||||
EX hookset<eLand(eLand)> *hooks_nextland;
|
||||
EX hookset<eLand(eLand)> hooks_nextland;
|
||||
|
||||
EX eLand getNewLand(eLand old) {
|
||||
|
||||
|
@ -2463,7 +2463,7 @@ namespace mapeditor {
|
||||
}
|
||||
#endif
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, [] () {
|
||||
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||
if(mapeditor::painttype == 4)
|
||||
mapeditor::painttype = 0, mapeditor::paintwhat = 0,
|
||||
mapeditor::paintwhat_str = "clear monster";
|
||||
|
18
menus.cpp
18
menus.cpp
@ -959,18 +959,22 @@ EX void showStartMenu() {
|
||||
// -- overview --
|
||||
|
||||
#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); }); }
|
||||
#endif
|
||||
|
||||
EX hookset<named_functionality()> *hooks_o_key;
|
||||
EX hookset<named_functionality()> hooks_o_key;
|
||||
|
||||
EX named_functionality get_o_key() {
|
||||
|
||||
if(hooks_o_key) for(auto& h: *hooks_o_key) {
|
||||
auto res = h.second();
|
||||
if(res.first != "") return res;
|
||||
}
|
||||
auto res = callhandlers(named_functionality(), hooks_o_key);
|
||||
if (res != named_functionality()) return res;
|
||||
|
||||
#if CAP_DAILY
|
||||
if(daily::on)
|
||||
|
@ -82,7 +82,7 @@ void gamedata::restoregame() {
|
||||
gamedata_all(*this);
|
||||
}
|
||||
|
||||
EX hookset<void(gamedata*)> *hooks_gamedata;
|
||||
EX hookset<void(gamedata*)> hooks_gamedata;
|
||||
|
||||
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) {
|
||||
|
||||
@ -3017,7 +3017,7 @@ int read_pattern_args() {
|
||||
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
|
||||
|
||||
}
|
||||
|
@ -835,7 +835,7 @@ heptspin sview;
|
||||
#if CAP_COMMANDLINE
|
||||
auto hook =
|
||||
addHook(hooks_args, 100, readArgs)
|
||||
+ addHook(clearmemory, 0, []() {
|
||||
+ addHook(hooks_clearmemory, 0, []() {
|
||||
track_ready = false;
|
||||
track.clear();
|
||||
rti.clear();
|
||||
|
@ -169,8 +169,8 @@ string build_getter(string type, string name, int index) {
|
||||
#define GET(array, index) array "[" index "]"
|
||||
#endif
|
||||
|
||||
EX hookset<void(string&, string&)> *hooks_rayshader;
|
||||
EX hookset<bool(shared_ptr<raycaster>)> *hooks_rayset;
|
||||
EX hookset<void(string&, string&)> hooks_rayshader;
|
||||
EX hookset<bool(shared_ptr<raycaster>)> hooks_rayset;
|
||||
|
||||
void enable_raycaster() {
|
||||
if(geometry != last_geometry) reset_raycaster();
|
||||
|
@ -346,7 +346,7 @@ bool handleKey(int sym, int uni) {
|
||||
auto xhook = addHook(hooks_args, 100, readArgs)
|
||||
+ addHook(hooks_handleKey, 0, handleKey)
|
||||
+ 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) {
|
||||
using namespace tour;
|
||||
v.push_back(
|
||||
|
@ -1232,7 +1232,7 @@ auto hooks =
|
||||
#if CAP_COMMANDLINE
|
||||
addHook(hooks_args, 100, readArgs) +
|
||||
#endif
|
||||
addHook(clearmemory, 0, close) +
|
||||
addHook(hooks_clearmemory, 0, close) +
|
||||
addHook(hooks_prestats, 100, rogueviz_hud) +
|
||||
addHook(shmup::hooks_draw, 100, drawVertex) +
|
||||
addHook(shmup::hooks_describe, 100, describe_monster) +
|
||||
@ -1240,7 +1240,7 @@ auto hooks =
|
||||
addHook(hooks_o_key, 100, o_key) +
|
||||
|
||||
#if CAP_RVSLIDES
|
||||
addHook(tour::ss::extra_slideshows, 100, [] (bool view) {
|
||||
addHook(tour::ss::hooks_extra_slideshows, 100, [] (bool view) {
|
||||
if(!view) return 1;
|
||||
dialog::addBoolItem(XLAT("RogueViz Tour"), tour::ss::wts == &rvtour::rvslides[0], 'r');
|
||||
dialog::add_action([] { tour::ss::wts = rvtour::gen_rvtour(); popScreen(); });
|
||||
|
@ -107,11 +107,11 @@ namespace rogueviz {
|
||||
|
||||
extern colorpair dftcolor;
|
||||
|
||||
inline hookset<void(vertexdata&, cell*, shmup::monster*, int)> *hooks_drawvertex;
|
||||
inline hookset<bool(edgeinfo*, bool store)> *hooks_alt_edges;
|
||||
inline hookset<void(vertexdata&, cell*, shmup::monster*, int)> hooks_drawvertex;
|
||||
inline hookset<bool(edgeinfo*, bool store)> hooks_alt_edges;
|
||||
inline purehookset hooks_rvmenu;
|
||||
inline hookset<bool()> *hooks_rvmenu_replace;
|
||||
inline hookset<bool(int&, string&, FILE*)> *hooks_readcolor;
|
||||
inline hookset<bool()> hooks_rvmenu_replace;
|
||||
inline hookset<bool(int&, string&, FILE*)> hooks_readcolor;
|
||||
inline purehookset hooks_close;
|
||||
|
||||
void readcolor(const string& cfname);
|
||||
@ -121,7 +121,7 @@ namespace rogueviz {
|
||||
|
||||
namespace rvtour {
|
||||
using namespace hr::tour;
|
||||
inline hookset<void(vector<slide>&)> *hooks_build_rvtour;
|
||||
inline hookset<void(vector<slide>&)> hooks_build_rvtour;
|
||||
slide *gen_rvtour();
|
||||
|
||||
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)
|
||||
|
||||
+ addHook(clearmemory, 40, [] () {
|
||||
+ addHook(hooks_clearmemory, 40, [] () {
|
||||
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 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) {
|
||||
int tk = tkills();
|
||||
@ -2456,7 +2456,7 @@ EX void fixStorage() {
|
||||
for(monster *m: restore) m->store();
|
||||
}
|
||||
|
||||
EX hookset<bool(int)> *hooks_turn;
|
||||
EX hookset<bool(int)> hooks_turn;
|
||||
|
||||
EX void turn(int delta) {
|
||||
|
||||
@ -2771,7 +2771,7 @@ EX bool boatAt(cell *c) {
|
||||
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() {
|
||||
for(mit it = monstersAt.begin(); it != monstersAt.end(); it++)
|
||||
@ -2833,7 +2833,7 @@ EX void virtualRebase(shmup::monster *m) {
|
||||
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) {
|
||||
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_removecells, 0, [] () {
|
||||
for(mit it = monstersAt.begin(); it != monstersAt.end();) {
|
||||
|
@ -83,7 +83,7 @@ int musfadeval = 2000;
|
||||
|
||||
eLand cid = laNone;
|
||||
|
||||
hookset<bool(eLand&)> *hooks_music;
|
||||
hookset<bool(eLand&)> hooks_music;
|
||||
|
||||
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() {
|
||||
if(audio && musicvolume) {
|
||||
@ -218,7 +218,7 @@ string wheresounds = SOUNDDESTDIR;
|
||||
string wheresounds = HYPERPATH "sounds/";
|
||||
#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) {
|
||||
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. */
|
||||
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. */
|
||||
EX void welcomeMessage() {
|
||||
@ -144,7 +144,7 @@ EX void welcomeMessage() {
|
||||
}
|
||||
|
||||
/** \brief These hooks are called at the start of initgame. */
|
||||
EX hookset<void()> *hooks_initgame;
|
||||
EX hookset<void()> hooks_initgame;
|
||||
|
||||
/** \brief initialize the game */
|
||||
EX void initgame() {
|
||||
@ -1249,11 +1249,11 @@ eModel default_model() {
|
||||
return mdDisk;
|
||||
}
|
||||
|
||||
EX purehookset on_geometry_change;
|
||||
EX purehookset hooks_on_geometry_change;
|
||||
|
||||
EX void set_geometry(eGeometry target) {
|
||||
bool was_default = pmodel == default_model();
|
||||
callhooks(on_geometry_change);
|
||||
callhooks(hooks_on_geometry_change);
|
||||
if(geometry != target) {
|
||||
int old_DIM = GDIM;
|
||||
stop_game();
|
||||
@ -1500,10 +1500,10 @@ EX void stop_game_and_switch_mode(char switchWhat IS(rg::nothing)) {
|
||||
switch_game_mode(switchWhat);
|
||||
}
|
||||
|
||||
EX purehookset clearmemory;
|
||||
EX purehookset hooks_clearmemory;
|
||||
|
||||
EX void clearMemory() {
|
||||
callhooks(clearmemory);
|
||||
callhooks(hooks_clearmemory);
|
||||
}
|
||||
|
||||
EX bool fixseed = false;
|
||||
@ -1547,7 +1547,7 @@ EX void initAll() {
|
||||
polygonal::solve();
|
||||
}
|
||||
|
||||
EX purehookset final_cleanup;
|
||||
EX purehookset hooks_final_cleanup;
|
||||
|
||||
EX void finishAll() {
|
||||
achievement_final(!items[itOrbSafety]);
|
||||
@ -1561,11 +1561,11 @@ EX void finishAll() {
|
||||
#endif
|
||||
|
||||
achievement_close();
|
||||
callhooks(final_cleanup);
|
||||
callhooks(hooks_final_cleanup);
|
||||
}
|
||||
|
||||
|
||||
auto cgm = addHook(clearmemory, 40, [] () {
|
||||
auto cgm = addHook(hooks_clearmemory, 40, [] () {
|
||||
pathq.clear();
|
||||
dcal.clear();
|
||||
clearshadow();
|
||||
|
@ -1721,7 +1721,7 @@ int textureArgs() {
|
||||
|
||||
auto texture_hook =
|
||||
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;
|
||||
|
||||
|
8
tour.cpp
8
tour.cpp
@ -115,7 +115,7 @@ EX function<bool(eLand)> showland;
|
||||
EX string slidecommand;
|
||||
|
||||
/** \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 */
|
||||
EX void presentation(presmode mode) {
|
||||
@ -377,13 +377,13 @@ EX namespace ss {
|
||||
|
||||
string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*(";
|
||||
|
||||
EX hookset<int(bool)> *extra_slideshows;
|
||||
EX hookset<int(bool)> hooks_extra_slideshows;
|
||||
|
||||
EX void slideshow_menu() {
|
||||
dialog::init(XLAT("slideshows"), forecolor, 150, 100);
|
||||
dialog::addBoolItem(XLAT("Guided Tour"), wts == default_slides, 't');
|
||||
dialog::add_action([] { wts = default_slides; popScreen(); });
|
||||
callhooks(extra_slideshows, true);
|
||||
callhooks(hooks_extra_slideshows, true);
|
||||
dialog::addBack();
|
||||
dialog::display();
|
||||
}
|
||||
@ -438,7 +438,7 @@ EX namespace ss {
|
||||
}
|
||||
dialog::addBreak(50);
|
||||
bool b = false;
|
||||
if(callhandlers(0, extra_slideshows, b)) {
|
||||
if(callhandlers(0, hooks_extra_slideshows, b)) {
|
||||
dialog::addItem(XLAT("change slideshow"), '1');
|
||||
dialog::add_action_push(slideshow_menu);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ auto wfc_hook =
|
||||
});
|
||||
#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 }
|
||||
|
||||
|
@ -799,7 +799,7 @@ EX namespace yendor {
|
||||
achievement_victory(false);
|
||||
}
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, [] () {
|
||||
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
||||
yendor::yii = NOYENDOR; yendor::yi.clear();
|
||||
}) + addHook(hooks_removecells, 0, [] () {
|
||||
eliminate_if(yendor::yi, [] (yendorinfo& i) {
|
||||
|
Loading…
Reference in New Issue
Block a user