int gui_messages_log_proc(int msg, DIALOG *d, int c __attribute__((unused))) { switch (msg) { case MSG_START: init_messages(d); break; case MSG_END: uninit_messages(); break; case MSG_NEW_LOG_TEXT: /* * Message indicating that there is a new message to be processed * and displayed. */ print_messages(d); break; case MSG_CLEAR_LOG_TEXT: clear_messages(d); break; } return D_O_K; }
int block_for_respawn() { static auto_mutex respawn_mutex; if (!check_monitoring(&client_actions)) { log_message_no_clients(); stop_message_queue(); return false; } if (respawn_waiting(&client_actions) || respawn_block.block(respawn_mutex)) { //NOTE: execution must stay outside of modules to prevent updates from blocking responses action_list_item *next_execute = remove_respawn(&client_actions); if (!next_execute) return false; allow_privileged_responses(); pid_t new_process = next_execute->execute_action(); block_messages(); clear_messages(); if (new_process < 0) delete next_execute; else if (!add_executed(&client_actions, new_process, next_execute)) { delete next_execute; return false; } } else return false; return message_queue_status(); }
void get_target(coord xp, coord yp, coord *x, coord *y) { char c; *x = xp; *y = yp; message("Which direction? "); c = getkey(); clear_messages(); switch (c) { case 'i': (*y)--; break; case 'j': (*x)--; break; case 'k': (*y)++; break; case 'l': (*x)++; break; default: (*x) = (*y) = -1; break; } }
void test_open_invalid_chunk_file(void) { grn_io *io; gchar *id_string; const gchar *expected_error_message = cut_take_printf("[column][index] file type must be 0x48: <%#04x>", 0); io = grn_io_create(context, path, 10, 10, 10, grn_io_auto, GRN_IO_EXPIRE_SEGMENT); cut_assert_not_null(io); id_string = grn_io_header(io); strcpy(id_string, "WRONG-ID"); grn_io_close(context, io); io = grn_io_create(context, cut_take_printf("%s.c", path), 10, 10, 10, grn_io_auto, GRN_IO_EXPIRE_SEGMENT); cut_assert_not_null(io); grn_io_close(context, io); clear_messages(); inverted_index = grn_ii_open(context, path, lexicon); cut_assert_null(inverted_index); cut_assert_equal_substring(expected_error_message, messages()->data, strlen(expected_error_message)); }
void more(void) { cursor(mbuffer_x, 0); set_color(C_WHITE); prtstr("(more)"); while (getkey() != ' '); clear_messages(); }
void test_open_invalid_segment_file(void) { grn_io *io; gchar *id_string; const gchar *expected_error_message = "system call error"; io = grn_io_create(context, path, 10, 10, 10, grn_io_auto, GRN_IO_EXPIRE_SEGMENT); cut_assert_not_null(io); id_string = grn_io_header(io); strcpy(id_string, "WRONG-ID"); grn_io_close(context, io); clear_messages(); inverted_index = grn_ii_open(context, path, lexicon); cut_assert_null(inverted_index); cut_assert_equal_substring(expected_error_message, messages()->data, strlen(expected_error_message)); }
bool command_executor::execute_command(const hotkey_command& cmd, int /*index*/, bool press) { // hotkey release handling if (!press) { switch(cmd.id) { // release a scroll key, un-apply scrolling in the given direction case HOTKEY_SCROLL_UP: scroll_up(false); break; case HOTKEY_SCROLL_DOWN: scroll_down(false); break; case HOTKEY_SCROLL_LEFT: scroll_left(false); break; case HOTKEY_SCROLL_RIGHT: scroll_right(false); break; default: return false; // nothing else handles a hotkey release } return true; } // hotkey press handling switch(cmd.id) { case HOTKEY_SCROLL_UP: scroll_up(true); break; case HOTKEY_SCROLL_DOWN: scroll_down(true); break; case HOTKEY_SCROLL_LEFT: scroll_left(true); break; case HOTKEY_SCROLL_RIGHT: scroll_right(true); break; case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_TERRAIN_DESCRIPTION: terrain_description(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_LABEL_SETTINGS: label_settings(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_KILL_UNIT: kill_unit(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_REPLAY_PLAY: play_replay(); break; case HOTKEY_REPLAY_RESET: reset_replay(); break; case HOTKEY_REPLAY_STOP: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_NEXT_MOVE: replay_next_move(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_REPLAY_EXIT: replay_exit(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_SELECT_HEX: select_hex(); break; case HOTKEY_DESELECT_HEX: deselect_hex(); break; case HOTKEY_MOVE_ACTION: move_action(); break; case HOTKEY_SELECT_AND_ACTION: select_and_action(); break; case HOTKEY_ACCELERATED: toggle_accelerated_speed(); break; case LUA_CONSOLE: lua_console(); break; case HOTKEY_ZOOM_IN: zoom_in(); break; case HOTKEY_ZOOM_OUT: zoom_out(); break; case HOTKEY_ZOOM_DEFAULT: zoom_default(); break; case HOTKEY_MAP_SCREENSHOT: map_screenshot(); break; case HOTKEY_QUIT_TO_DESKTOP: quit_confirmation::quit_to_desktop(); break; case HOTKEY_QUIT_GAME: quit_confirmation::quit_to_title(); break; default: return false; } return true; }
void play(int start_level) { coord opx, opy; BOOL quit = 0; /* * Build the current level. * * XXXX: Once it is possible to save/restore the map this no longer * must be done if the game was started by restoring a save file. */ d.dl = start_level; build_map(); create_population(); build_monster_map(); d.visited[0] = TRUE; /* Initial player position. */ place_player(d.stxu[d.dl], d.styu[d.dl]); /* Initial panel position. */ d.psx = d.psy = 0; /* * Standard stuff. */ do { /* Print all the new things. */ update_screen(d.px, d.py); /* The message line should be cleared in any case. */ clear_messages(); /* Memorize the old PC position. */ opx = d.px; opy = d.py; SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) quit = TRUE; if (event.type == SDL_KEYDOWN) game_keydown(event.key.keysym.sym); } int input = get_input(); if (input & PRESS_ESC) quit = TRUE; BOOL player_turn = move_monsters(); if (player_turn && d.pa.act == IDLE) { if (input & PRESS_LEFT) { set_dir_actor(&d.pa, LEFT); if (is_open(d.px - 1, d.py) && !is_monster_at(d.px - 1, d.py)) move_player(LEFT); } else if (input & PRESS_RIGHT) { set_dir_actor(&d.pa, RIGHT); if (is_open(d.px + 1, d.py) && !is_monster_at(d.px + 1, d.py)) move_player(RIGHT); } else if (input & PRESS_UP) { set_dir_actor(&d.pa, UP); if (is_open(d.px, d.py - 1) && !is_monster_at(d.px, d.py - 1)) move_player(UP); } else if (input & PRESS_DOWN) { set_dir_actor(&d.pa, DOWN); if (is_open(d.px, d.py + 1) && !is_monster_at(d.px, d.py + 1)) move_player(DOWN); } } else if (d.pa.act == MOVE) { animate_move_actor(&d.pa); } else if (d.pa.act == CHARGE) { animate_charge_actor(&d.pa); } else if (d.pa.act == ATTACK) { if (animate_attack_actor(&d.pa)) attack_monster_at(d.pa.tx, d.pa.ty); } d.opx = opx; d.opy = opy; } while (quit == FALSE); }
// // display_message() - Prints a message string to the top of the screen // // We use a 'printf' like function to dump a string on the message bar at the // top of the screen. // void display_message( const char* message ) { clear_messages(); // Don't leave ghost text up there mvprintw( MESSAGE_Y, MESSAGE_X, message ); }
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/) { switch(command) { case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_PLAY_REPLAY: play_replay(); break; case HOTKEY_RESET_REPLAY: reset_replay(); break; case HOTKEY_STOP_REPLAY: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_LEFT_MOUSE_CLICK: left_mouse_click(); break; case HOTKEY_RIGHT_MOUSE_CLICK: right_mouse_click(); break; default: return false; } return true; }
void init_messages(void) { clear_messages(); // Set end turn init_messages_turns(0); }