mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
dual:: a system to change parameters in one of the two maps, currently used only in ge_land_selection
This commit is contained in:
parent
f509dd0db0
commit
bc8da03ce0
@ -331,23 +331,23 @@ void ge_land_selection() {
|
||||
dialog::lastItem().color = linf[l].color;
|
||||
dialog::lastItem().value += validclasses[land_validity(l).quality_level];
|
||||
dialog::add_action([l] {
|
||||
if(landvisited[l]) dialog::do_if_confirmed([l] {
|
||||
if(landvisited[l]) dialog::do_if_confirmed(dual::mayboth([l] {
|
||||
stop_game_and_switch_mode(tactic::on ? rg::tactic : rg::nothing);
|
||||
firstland = specialland = l;
|
||||
start_game();
|
||||
popScreen();
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
dialog::addBreak(50);
|
||||
if(chaosUnlocked && !quotient && !euclid && !sphere) {
|
||||
dialog::addItem(XLAT("Chaos mode"), '1');
|
||||
dialog::add_action([] {
|
||||
dialog::add_action(dual::mayboth([] {
|
||||
if(chaosUnlocked) dialog::do_if_confirmed([] {
|
||||
stop_game_and_switch_mode(rg::chaos);
|
||||
start_game();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
dialog::addItem(XLAT("next page"), '-');
|
||||
|
||||
@ -355,6 +355,7 @@ void ge_land_selection() {
|
||||
validity_info();
|
||||
dialog::addBreak(25);
|
||||
|
||||
dual::add_choice();
|
||||
dialog::addBack();
|
||||
dialog::display();
|
||||
|
||||
|
8
hyper.h
8
hyper.h
@ -5453,11 +5453,17 @@ namespace dual {
|
||||
// 0 = dualmode off, 1 = in dualmode (no game chosen), 2 = in dualmode (working on one of subgames)
|
||||
extern int state;
|
||||
extern int currently_loaded, main_side;
|
||||
bool affect_both;
|
||||
|
||||
bool movepc(int d, int subdir, bool checkonly);
|
||||
extern transmatrix player_orientation[2];
|
||||
|
||||
void add_choice();
|
||||
|
||||
bool split(reaction_t what);
|
||||
void split_or_do(reaction_t what);
|
||||
bool may_split(reaction_t what);
|
||||
void may_split_or_do(reaction_t what);
|
||||
void switch_to(int i);
|
||||
void in_subscreen(reaction_t what);
|
||||
|
||||
@ -5466,6 +5472,8 @@ namespace dual {
|
||||
|
||||
void disable();
|
||||
void enable();
|
||||
|
||||
inline reaction_t mayboth(reaction_t what) { return [=] { may_split_or_do(what); }; }
|
||||
}
|
||||
|
||||
}
|
@ -281,6 +281,39 @@ namespace dual {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void add_choice() {
|
||||
if(!state) return;
|
||||
dialog::addSelItem(XLAT("subgame affected"),
|
||||
XLAT(affect_both ? "both" : main_side == 0 ? "left" : "right"), '`');
|
||||
dialog::add_action([] () {
|
||||
affect_both = !affect_both;
|
||||
if(!affect_both) {
|
||||
main_side = !main_side;
|
||||
switch_to(main_side);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void split_or_do(reaction_t what) {
|
||||
if(split(what)) return;
|
||||
else what();
|
||||
}
|
||||
|
||||
bool may_split(reaction_t what) {
|
||||
if(state == 1 && affect_both) {
|
||||
split(what);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void may_split_or_do(reaction_t what) {
|
||||
if(state == 1 && affect_both) {
|
||||
split(what);
|
||||
}
|
||||
else what();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user