diff --git a/geom-exp.cpp b/geom-exp.cpp index 4192cef0..689bb001 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -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(); diff --git a/hyper.h b/hyper.h index 7ba3daeb..5d0736d8 100644 --- a/hyper.h +++ b/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); }; } } } \ No newline at end of file diff --git a/multigame.cpp b/multigame.cpp index a49b4d41..b82c2311 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -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(); + } } }