mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 21:05:52 +00:00
parent
4c75f6cf66
commit
37293b2576
@ -37,6 +37,7 @@
|
||||
#include "../preferences.hpp"
|
||||
#include "../replay.hpp"
|
||||
#include "../replay_helper.hpp"
|
||||
#include "../resources.hpp"
|
||||
#include "../synced_context.hpp"
|
||||
#include "../terrain_filter.hpp"
|
||||
|
||||
@ -174,6 +175,8 @@ const std::string & wml_menu_item::image() const
|
||||
*/
|
||||
bool wml_menu_item::can_show(const map_location & hex, const game_data & data, filter_context & filter_con) const
|
||||
{
|
||||
if(is_synced_ && !resources::controller->can_use_synced_wml_menu())
|
||||
return false;
|
||||
// Failing the [show_if] tag means no show.
|
||||
if ( !show_if_.empty() && !conditional_passed(show_if_) )
|
||||
return false;
|
||||
|
@ -432,16 +432,8 @@ void play_controller::hotkey_handler::show_menu(const std::vector<std::string>&
|
||||
} else {
|
||||
cmd = &hotkey::get_hotkey_command(*i);
|
||||
}
|
||||
// Remove WML commands if they would not be allowed here
|
||||
if(*i == "wml") {
|
||||
if(!context_menu || !viewing_team_is_playing()
|
||||
|| events::commands_disabled || !viewing_team().is_local_human()
|
||||
|| (linger() && !game_config::debug)){
|
||||
i = items.erase(i);
|
||||
continue;
|
||||
}
|
||||
// Remove commands that can't be executed or don't belong in this type of menu
|
||||
} else if(!can_execute_command(*cmd)
|
||||
if(*i != "wml" && !can_execute_command(*cmd)
|
||||
|| (context_menu && !in_context_menu(cmd->id))) {
|
||||
i = items.erase(i);
|
||||
continue;
|
||||
|
@ -190,7 +190,6 @@ bool playsingle_controller::hotkey_handler::can_execute_command(const hotkey::ho
|
||||
|
||||
case hotkey::HOTKEY_WML:
|
||||
{
|
||||
|
||||
int prefixlen = wml_menu_hotkey_prefix.length();
|
||||
if(cmd.command.compare(0, prefixlen, wml_menu_hotkey_prefix) != 0) {
|
||||
return false;
|
||||
@ -200,7 +199,7 @@ bool playsingle_controller::hotkey_handler::can_execute_command(const hotkey::ho
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(**it).is_synced() || (viewing_team_is_playing() && !events::commands_disabled && viewing_team().is_local_human() && !linger() && !browse());
|
||||
return !(**it).is_synced() || play_controller_.can_use_synced_wml_menu();
|
||||
}
|
||||
case hotkey::HOTKEY_UNIT_HOLD_POSITION:
|
||||
case hotkey::HOTKEY_END_UNIT_TURN:
|
||||
|
@ -1043,3 +1043,9 @@ void play_controller::start_game()
|
||||
gui_->recalculate_minimap();
|
||||
}
|
||||
}
|
||||
|
||||
bool play_controller::can_use_synced_wml_menu() const
|
||||
{
|
||||
const team& viewing_team = get_teams_const()[gui_->viewing_team()];
|
||||
return gui_->viewing_team() == gui_->playing_team() && !events::commands_disabled && viewing_team.is_local_human() && !is_lingering() && !is_browsing();
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
actions::undo_list & get_undo_stack() { return *undo_stack_; }
|
||||
|
||||
bool is_browsing() const OVERRIDE;
|
||||
bool is_lingering() { return linger_; }
|
||||
bool is_lingering() const { return linger_; }
|
||||
|
||||
class hotkey_handler;
|
||||
virtual bool is_replay() { return false; }
|
||||
@ -211,6 +211,8 @@ public:
|
||||
|
||||
team& current_team();
|
||||
const team& current_team() const;
|
||||
|
||||
bool can_use_synced_wml_menu() const;
|
||||
protected:
|
||||
void play_slice_catch();
|
||||
game_display& get_display();
|
||||
|
Loading…
x
Reference in New Issue
Block a user