Fixed bug #7138: [end turn] should be locked if you can not end turn.

This commit is contained in:
Philippe Plantier 2005-03-14 22:26:38 +00:00
parent 02e9109a2e
commit 7f2df479da
3 changed files with 26 additions and 5 deletions

View file

@ -2147,6 +2147,22 @@ const theme::menu* display::menu_pressed()
return NULL;
}
void display::enable_menu(const std::string& item, bool enable)
{
for(std::vector<theme::menu>::const_iterator menu = theme_.menus().begin();
menu != theme_.menus().end(); ++menu) {
std::vector<std::string>::const_iterator hasitem =
std::find(menu->items().begin(), menu->items().end(), item);
if(hasitem != menu->items().end()) {
const size_t index = menu - theme_.menus().begin();
wassert(index < buttons_.size());
buttons_[index].enable(enable);
}
}
}
void display::begin_game()
{
in_game_ = true;
@ -2217,7 +2233,7 @@ void display::remove_observer(const std::string& name)
}
namespace {
const int max_chat_messages = 6;
const unsigned int max_chat_messages = 6;
const int chat_message_border = 5;
const int chat_message_x = 10;
const int chat_message_y = 10;
@ -2288,7 +2304,7 @@ void display::clear_chat_messages()
void display::prune_chat_messages(bool remove_all)
{
const int message_ttl = remove_all ? 0 : 1200000;
const unsigned int message_ttl = remove_all ? 0 : 1200000;
if(chat_messages_.empty() == false && (chat_messages_.front().created_at+message_ttl < SDL_GetTicks() || chat_messages_.size() > max_chat_messages)) {
const int movement = font::get_floating_label_rect(chat_messages_.front().handle).h;

View file

@ -304,6 +304,9 @@ public:
const theme::menu* menu_pressed();
//finds the menu which has a given item in it, and enables or disables it.
void enable_menu(const std::string& item, bool enable);
void add_observer(const std::string& name);
void remove_observer(const std::string& name);
const std::set<std::string>& observers() const { return observers_; }
@ -482,7 +485,7 @@ private:
int speaker_handle;
int handle;
int created_at;
Uint32 created_at;
};
void prune_chat_messages(bool remove_all=false);

View file

@ -154,6 +154,8 @@ turn_info::turn_info(game_data& gameinfo, game_state& state_of_game,
path_turns_(0), end_turn_(false), start_ncmd_(-1), textbox_(textbox), replay_sender_(replay_sender)
{
enemies_visible_ = enemies_visible();
gui_.enable_menu("endturn", !browse_);
}
void turn_info::turn_slice()
@ -2801,7 +2803,7 @@ void turn_info::tab_textbox()
return;
}
if(last_space == -1) {
if(last_space == std::string::npos) {
beginning = true;
semiword = text;
}else{
@ -2822,7 +2824,7 @@ void turn_info::tab_textbox()
if(guess.size() == 0) {
guess = name;
}else{
int i;
size_t i;
for(i=0; (i < guess.size()) || (i < name.size()); i++) {
if(guess[i] != name[i]) {
break;