mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 05:39:34 +00:00
Support [disallow_end_turn]reason= and use it in the tutorial
This commit is contained in:
parent
7034c8f97b
commit
ea9fddcd23
@ -82,6 +82,7 @@
|
||||
* [remove_sound_source] now accepts a comma-separated ID list
|
||||
* Support [filter_team] in [side] in addition to team_name=
|
||||
* Support an optional EXTRA_WML argument to {REMOVE_LABEL}.
|
||||
* Support [disallow_end_turn]reason=
|
||||
### Miscellaneous and bug fixes
|
||||
* Rest healing now happens on turn 2. (issue #3562)
|
||||
* Normal healing now happens on turn 1 for all sides except the first. (issue #3562)
|
||||
|
@ -132,7 +132,9 @@
|
||||
|
||||
# We don't want players ending their turn before the requisite actions have been completed
|
||||
# Therefor, we frequently disallow or allow end turn as needed
|
||||
[disallow_end_turn][/disallow_end_turn]
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have completed the lesson on movement!"
|
||||
[/disallow_end_turn]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
@ -519,6 +521,10 @@
|
||||
message= _"To attack the quintain, first select the attacker (Li’sar), then the target (the quintain). You will see an attack description. Click <b>Attack</b> when you’re ready."
|
||||
[/message]
|
||||
)}
|
||||
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have attacked the dummy!"
|
||||
[/disallow_end_turn]
|
||||
[/event]
|
||||
|
||||
# First time the student attacks the quintain
|
||||
@ -620,7 +626,9 @@
|
||||
[event]
|
||||
name=turn 2
|
||||
|
||||
[disallow_end_turn][/disallow_end_turn]
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have completed the lesson on healing!"
|
||||
[/disallow_end_turn]
|
||||
|
||||
# works around the situation that the player can't do anything anymore
|
||||
# if he disobeys orders - inserts [allow_end_turn][/allow_end_turn]
|
||||
@ -685,7 +693,9 @@
|
||||
[event]
|
||||
name=turn 3 refresh
|
||||
|
||||
[disallow_end_turn][/disallow_end_turn]
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have completed the lesson on recruiting!"
|
||||
[/disallow_end_turn]
|
||||
|
||||
{ALLOW_END_TURN_AFTER_ATTACK}
|
||||
|
||||
@ -815,7 +825,9 @@
|
||||
radius=1 # hexes next to the first quintain
|
||||
[/store_locations]
|
||||
|
||||
[disallow_end_turn][/disallow_end_turn]
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have completed the lesson on attacking!"
|
||||
[/disallow_end_turn]
|
||||
|
||||
{ALLOW_END_TURN_AFTER_ATTACK}
|
||||
|
||||
|
@ -175,7 +175,9 @@
|
||||
[/then]
|
||||
[/if]
|
||||
|
||||
[disallow_end_turn][/disallow_end_turn]
|
||||
[disallow_end_turn]
|
||||
reason=_"You cannot end your turn until you have recruited troops and captured a village!"
|
||||
[/disallow_end_turn]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
|
@ -702,7 +702,7 @@ function wml_actions.allow_end_turn(cfg)
|
||||
end
|
||||
|
||||
function wml_actions.disallow_end_turn(cfg)
|
||||
wesnoth.allow_end_turn(false)
|
||||
wesnoth.allow_end_turn(cfg.reason or false)
|
||||
end
|
||||
|
||||
function wml_actions.clear_menu_item(cfg)
|
||||
|
@ -294,7 +294,12 @@
|
||||
{SIMPLE_KEY add s_int}
|
||||
{SIMPLE_KEY current s_unsigned}
|
||||
[/tag]
|
||||
{EMPTY_TAG "allow_end_turn,disallow_end_turn" 0 infinite}
|
||||
{EMPTY_TAG "allow_end_turn" 0 infinite}
|
||||
[tag]
|
||||
name="disallow_end_turn"
|
||||
max=infinite
|
||||
{DEFAULT_KEY reason t_string ""}
|
||||
[/tag]
|
||||
[tag]
|
||||
name="capture_village"
|
||||
max=infinite
|
||||
|
@ -76,8 +76,14 @@ public:
|
||||
PHASE phase() const { return phase_; }
|
||||
void set_phase(PHASE phase) { phase_ = phase; }
|
||||
|
||||
const t_string& cannot_end_turn_reason() {
|
||||
return cannot_end_turn_reason_;
|
||||
}
|
||||
bool allow_end_turn() const { return can_end_turn_; }
|
||||
void set_allow_end_turn(bool value) { can_end_turn_ = value; }
|
||||
void set_allow_end_turn(bool value, const t_string& reason = "") {
|
||||
can_end_turn_ = value;
|
||||
cannot_end_turn_reason_ = reason;
|
||||
}
|
||||
|
||||
/** the last location where a select event fired. Used by wml menu items with needs_select=yes*/
|
||||
map_location last_selected;
|
||||
@ -112,6 +118,7 @@ private:
|
||||
config variables_;
|
||||
PHASE phase_;
|
||||
bool can_end_turn_;
|
||||
t_string cannot_end_turn_reason_;
|
||||
/// the scenario coming next (for campaigns)
|
||||
std::string next_scenario_;
|
||||
// the id of a scenario cannot change during a scenario
|
||||
|
@ -534,7 +534,11 @@ bool unmoved_units(
|
||||
bool menu_handler::end_turn(int side_num)
|
||||
{
|
||||
if(!gamedata().allow_end_turn()) {
|
||||
gui2::show_transient_message("", _("You cannot end your turn yet!"));
|
||||
t_string reason = gamedata().cannot_end_turn_reason();
|
||||
if(reason.empty()) {
|
||||
reason = _("You cannot end your turn yet!");
|
||||
}
|
||||
gui2::show_transient_message("", reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3668,7 +3668,16 @@ static int intf_debug_ai(lua_State *L)
|
||||
/// Allow undo sets the flag saying whether the event has mutated the game to false.
|
||||
int game_lua_kernel::intf_allow_end_turn(lua_State * L)
|
||||
{
|
||||
gamedata().set_allow_end_turn(luaW_toboolean(L, 1));
|
||||
bool allow;
|
||||
t_string reason;
|
||||
// The extra iststring is required to prevent totstring from converting a bool value
|
||||
if(luaW_iststring(L, 1) && luaW_totstring(L, 1, reason)) {
|
||||
allow = false;
|
||||
} else {
|
||||
allow = luaW_toboolean(L, 1);
|
||||
luaW_totstring(L, 2, reason);
|
||||
}
|
||||
gamedata().set_allow_end_turn(allow, reason);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user