added new : commands: clear, w, wq, q, debug, n
This commit is contained in:
parent
5eb90eb099
commit
0c165f81c9
4 changed files with 30 additions and 6 deletions
|
@ -1008,8 +1008,8 @@ void display::draw_minimap(int x, int y, int w, int h)
|
|||
const int xbox = static_cast<int>(xscaling*xpos_/(zoom_*0.75));
|
||||
const int ybox = static_cast<int>(yscaling*ypos_/zoom_);
|
||||
|
||||
const int wbox = static_cast<int>(xscaling*map_area().w/(zoom_*0.75) - xscaling);
|
||||
const int hbox = static_cast<int>(yscaling*map_area().h/zoom_ - yscaling);
|
||||
const int wbox = static_cast<int>(xscaling*map_area().w/(zoom_*0.75) - xscaling) + 3;
|
||||
const int hbox = static_cast<int>(yscaling*map_area().h/zoom_ - yscaling) + 3;
|
||||
|
||||
const Uint32 boxcolour = SDL_MapRGB(surf->format,0xFF,0xFF,0xFF);
|
||||
const surface screen(screen_.getSurface());
|
||||
|
@ -2231,6 +2231,11 @@ void display::add_chat_message(const std::string& speaker, int side, const std::
|
|||
prune_chat_messages();
|
||||
}
|
||||
|
||||
void display::clear_chat_messages()
|
||||
{
|
||||
prune_chat_messages(true);
|
||||
}
|
||||
|
||||
void display::prune_chat_messages(bool remove_all)
|
||||
{
|
||||
const int message_ttl = remove_all ? 0 : 1200000;
|
||||
|
|
|
@ -309,6 +309,7 @@ public:
|
|||
|
||||
enum MESSAGE_TYPE { MESSAGE_PUBLIC, MESSAGE_PRIVATE };
|
||||
void add_chat_message(const std::string& speaker, int side, const std::string& msg, MESSAGE_TYPE type);
|
||||
void clear_chat_messages();
|
||||
|
||||
//function to draw the image of a unit at a certain location
|
||||
//x,y: pixel location on screen to draw the unit
|
||||
|
|
|
@ -922,6 +922,7 @@ bool turn_info::can_execute_command(hotkey::HOTKEY_COMMAND command) const
|
|||
case hotkey::HOTKEY_QUIT_GAME:
|
||||
case hotkey::HOTKEY_SEARCH:
|
||||
case hotkey::HOTKEY_HELP:
|
||||
case hotkey::HOTKEY_USER_CMD:
|
||||
return true;
|
||||
|
||||
case hotkey::HOTKEY_SAVE_GAME:
|
||||
|
@ -938,7 +939,6 @@ bool turn_info::can_execute_command(hotkey::HOTKEY_COMMAND command) const
|
|||
case hotkey::HOTKEY_SPEAK_ALLY:
|
||||
case hotkey::HOTKEY_SPEAK_ALL:
|
||||
case hotkey::HOTKEY_CHAT_LOG:
|
||||
case hotkey::HOTKEY_USER_CMD:
|
||||
return network::nconnections() > 0;
|
||||
|
||||
case hotkey::HOTKEY_REDO:
|
||||
|
@ -1401,15 +1401,20 @@ void turn_info::save_game(const std::string& message, gui::DIALOG_TYPE dialog_ty
|
|||
stream << state_of_game_.label << " " << string_table["turn"]
|
||||
<< " " << status_.turn();
|
||||
std::string label = stream.str();
|
||||
if(dialog_type == gui::NULL_DIALOG && message != "") {
|
||||
label = message;
|
||||
}
|
||||
|
||||
const int res = dialogs::get_save_name(gui_,message,string_table["save_game_label"],&label,dialog_type);
|
||||
const int res = dialog_type == gui::NULL_DIALOG ? 0 : dialogs::get_save_name(gui_,message,string_table["save_game_label"],&label,dialog_type);
|
||||
|
||||
if(res == 0) {
|
||||
config snapshot;
|
||||
write_game_snapshot(snapshot);
|
||||
try {
|
||||
recorder.save_game(gameinfo_,label,snapshot,state_of_game_.starting_pos);
|
||||
gui::show_dialog(gui_,NULL,"",string_table["save_confirm_message"], gui::OK_ONLY);
|
||||
if(dialog_type != gui::NULL_DIALOG) {
|
||||
gui::show_dialog(gui_,NULL,"",string_table["save_confirm_message"], gui::OK_ONLY);
|
||||
}
|
||||
} catch(gamestatus::save_game_failed& e) {
|
||||
gui::show_dialog(gui_,NULL,"",string_table["save_game_failed"],gui::MESSAGE);
|
||||
//do not bother retrying, since the user can just try to save the game again
|
||||
|
@ -2139,6 +2144,19 @@ void turn_info::do_command(const std::string& str)
|
|||
ban["username"] = data;
|
||||
|
||||
network::send_data(cfg);
|
||||
} else if(cmd == "clear") {
|
||||
gui_.clear_chat_messages();
|
||||
} else if(cmd == "w") {
|
||||
save_game(data,gui::NULL_DIALOG);
|
||||
} else if(cmd == "wq") {
|
||||
save_game(data,gui::NULL_DIALOG);
|
||||
throw end_level_exception(QUIT);
|
||||
} else if(cmd == "q!" || cmd == "q") {
|
||||
throw end_level_exception(QUIT);
|
||||
} else if(cmd == "debug") {
|
||||
game_config::debug = (data != "off") ? true : false;
|
||||
} else if(cmd == "n" && game_config::debug) {
|
||||
throw end_level_exception(VICTORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ struct dialog_button
|
|||
|
||||
enum { ESCAPE_DIALOG=-3 };
|
||||
|
||||
enum DIALOG_TYPE { MESSAGE, OK_ONLY, YES_NO, OK_CANCEL, CANCEL_ONLY, CLOSE_ONLY };
|
||||
enum DIALOG_TYPE { MESSAGE, OK_ONLY, YES_NO, OK_CANCEL, CANCEL_ONLY, CLOSE_ONLY, NULL_DIALOG };
|
||||
|
||||
struct check_item {
|
||||
check_item(const std::string& label, bool checked) : label(label), checked(checked) {}
|
||||
|
|
Loading…
Add table
Reference in a new issue