/* type of game.. */ static void game_timed_out( void) { if(player_controlling_game()) { set_game_state(_close_game); } else { set_game_state(_switch_demo); } }
static void handle_game_key(const SDL_Event &event) { SDL_Keycode key = event.key.keysym.sym; SDL_Scancode sc = event.key.keysym.scancode; bool changed_screen_mode = false; bool changed_prefs = false; if (!game_is_networked && (event.key.keysym.mod & KMOD_CTRL) && CheatsActive) { int type_of_cheat = process_keyword_key(key); if (type_of_cheat != NONE) handle_keyword(type_of_cheat); } if (Console::instance()->input_active()) { switch(key) { case SDLK_RETURN: case SDLK_KP_ENTER: Console::instance()->enter(); break; case SDLK_ESCAPE: Console::instance()->abort(); break; case SDLK_BACKSPACE: Console::instance()->backspace(); break; case SDLK_DELETE: Console::instance()->del(); break; case SDLK_UP: Console::instance()->up_arrow(); break; case SDLK_DOWN: Console::instance()->down_arrow(); break; case SDLK_LEFT: Console::instance()->left_arrow(); break; case SDLK_RIGHT: Console::instance()->right_arrow(); break; case SDLK_HOME: Console::instance()->line_home(); break; case SDLK_END: Console::instance()->line_end(); break; case SDLK_a: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->line_home(); break; case SDLK_b: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->left_arrow(); break; case SDLK_d: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->del(); break; case SDLK_e: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->line_end(); break; case SDLK_f: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->right_arrow(); break; case SDLK_h: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->backspace(); break; case SDLK_k: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->forward_clear(); break; case SDLK_n: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->down_arrow(); break; case SDLK_p: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->up_arrow(); break; case SDLK_t: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->transpose(); break; case SDLK_u: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->clear(); break; case SDLK_w: if (event.key.keysym.mod & KMOD_CTRL) Console::instance()->delete_word(); break; } } else { if (sc == SDL_SCANCODE_ESCAPE) // (ZZZ) Quit gesture (now safer) { if(!player_controlling_game()) do_menu_item_command(mGame, iQuitGame, false); else { if(get_ticks_since_local_player_in_terminal() > 1 * TICKS_PER_SECOND) { if(!game_is_networked) { do_menu_item_command(mGame, iQuitGame, false); } else { #if defined(__APPLE__) && defined(__MACH__) screen_printf("If you wish to quit, press Command-Q"); #else screen_printf("If you wish to quit, press Alt+Q."); #endif } } } } else if (input_preferences->shell_key_bindings[_key_volume_up].count(sc)) { changed_prefs = SoundManager::instance()->AdjustVolumeUp(Sound_AdjustVolume()); } else if (input_preferences->shell_key_bindings[_key_volume_down].count(sc)) { changed_prefs = SoundManager::instance()->AdjustVolumeDown(Sound_AdjustVolume()); } else if (input_preferences->shell_key_bindings[_key_switch_view].count(sc)) { walk_player_list(); render_screen(NONE); } else if (input_preferences->shell_key_bindings[_key_zoom_in].count(sc)) { if (zoom_overhead_map_in()) PlayInterfaceButtonSound(Sound_ButtonSuccess()); else PlayInterfaceButtonSound(Sound_ButtonFailure()); } else if (input_preferences->shell_key_bindings[_key_zoom_out].count(sc)) { if (zoom_overhead_map_out()) PlayInterfaceButtonSound(Sound_ButtonSuccess()); else PlayInterfaceButtonSound(Sound_ButtonFailure()); } else if (input_preferences->shell_key_bindings[_key_inventory_left].count(sc)) { if (player_controlling_game()) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); scroll_inventory(-1); } else decrement_replay_speed(); } else if (input_preferences->shell_key_bindings[_key_inventory_right].count(sc)) { if (player_controlling_game()) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); scroll_inventory(1); } else increment_replay_speed(); } else if (input_preferences->shell_key_bindings[_key_toggle_fps].count(sc)) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); extern bool displaying_fps; displaying_fps = !displaying_fps; } else if (input_preferences->shell_key_bindings[_key_activate_console].count(sc)) { if (game_is_networked) { #if !defined(DISABLE_NETWORKING) Console::instance()->activate_input(InGameChatCallbacks::SendChatMessage, InGameChatCallbacks::prompt()); #endif PlayInterfaceButtonSound(Sound_ButtonSuccess()); } else if (Console::instance()->use_lua_console()) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); Console::instance()->activate_input(ExecuteLuaString, ">"); } else { PlayInterfaceButtonSound(Sound_ButtonFailure()); } } else if (input_preferences->shell_key_bindings[_key_show_scores].count(sc)) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); { extern bool ShowScores; ShowScores = !ShowScores; } } else if (sc == SDL_SCANCODE_F1) // Decrease screen size { if (!graphics_preferences->screen_mode.hud) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.hud = true; changed_screen_mode = changed_prefs = true; } else { int mode = alephone::Screen::instance()->FindMode(get_screen_mode()->width, get_screen_mode()->height); if (mode < alephone::Screen::instance()->GetModes().size() - 1) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.width = alephone::Screen::instance()->ModeWidth(mode + 1); graphics_preferences->screen_mode.height = alephone::Screen::instance()->ModeHeight(mode + 1); graphics_preferences->screen_mode.auto_resolution = false; graphics_preferences->screen_mode.hud = false; changed_screen_mode = changed_prefs = true; } else PlayInterfaceButtonSound(Sound_ButtonFailure()); } } else if (sc == SDL_SCANCODE_F2) // Increase screen size { if (graphics_preferences->screen_mode.hud) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.hud = false; changed_screen_mode = changed_prefs = true; } else { int mode = alephone::Screen::instance()->FindMode(get_screen_mode()->width, get_screen_mode()->height); int automode = get_screen_mode()->fullscreen ? 0 : 1; if (mode > automode) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.width = alephone::Screen::instance()->ModeWidth(mode - 1); graphics_preferences->screen_mode.height = alephone::Screen::instance()->ModeHeight(mode - 1); if ((mode - 1) == automode) graphics_preferences->screen_mode.auto_resolution = true; graphics_preferences->screen_mode.hud = true; changed_screen_mode = changed_prefs = true; } else PlayInterfaceButtonSound(Sound_ButtonFailure()); } } else if (sc == SDL_SCANCODE_F3) // Resolution toggle { if (!OGL_IsActive()) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.high_resolution = !graphics_preferences->screen_mode.high_resolution; changed_screen_mode = changed_prefs = true; } else PlayInterfaceButtonSound(Sound_ButtonFailure()); } else if (sc == SDL_SCANCODE_F4) // Reset OpenGL textures { #ifdef HAVE_OPENGL if (OGL_IsActive()) { // Play the button sound in advance to get the full effect of the sound PlayInterfaceButtonSound(Sound_OGL_Reset()); OGL_ResetTextures(); } else #endif PlayInterfaceButtonSound(Sound_ButtonInoperative()); } else if (sc == SDL_SCANCODE_F5) // Make the chase cam switch sides { if (ChaseCam_IsActive()) PlayInterfaceButtonSound(Sound_ButtonSuccess()); else PlayInterfaceButtonSound(Sound_ButtonInoperative()); ChaseCam_SwitchSides(); } else if (sc == SDL_SCANCODE_F6) // Toggle the chase cam { PlayInterfaceButtonSound(Sound_ButtonSuccess()); ChaseCam_SetActive(!ChaseCam_IsActive()); } else if (sc == SDL_SCANCODE_F7) // Toggle tunnel vision { PlayInterfaceButtonSound(Sound_ButtonSuccess()); SetTunnelVision(!GetTunnelVision()); } else if (sc == SDL_SCANCODE_F8) // Toggle the crosshairs { PlayInterfaceButtonSound(Sound_ButtonSuccess()); player_preferences->crosshairs_active = !player_preferences->crosshairs_active; Crosshairs_SetActive(player_preferences->crosshairs_active); changed_prefs = true; } else if (sc == SDL_SCANCODE_F9) // Screen dump { dump_screen(); } else if (sc == SDL_SCANCODE_F10) // Toggle the position display { PlayInterfaceButtonSound(Sound_ButtonSuccess()); { extern bool ShowPosition; ShowPosition = !ShowPosition; } } else if (sc == SDL_SCANCODE_F11) // Decrease gamma level { if (graphics_preferences->screen_mode.gamma_level) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.gamma_level--; change_gamma_level(graphics_preferences->screen_mode.gamma_level); changed_prefs = true; } else PlayInterfaceButtonSound(Sound_ButtonFailure()); } else if (sc == SDL_SCANCODE_F12) // Increase gamma level { if (graphics_preferences->screen_mode.gamma_level < NUMBER_OF_GAMMA_LEVELS - 1) { PlayInterfaceButtonSound(Sound_ButtonSuccess()); graphics_preferences->screen_mode.gamma_level++; change_gamma_level(graphics_preferences->screen_mode.gamma_level); changed_prefs = true; } else PlayInterfaceButtonSound(Sound_ButtonFailure()); } else { if (get_game_controller() == _demo) set_game_state(_close_game); } } if (changed_screen_mode) { screen_mode_data temp_screen_mode = graphics_preferences->screen_mode; temp_screen_mode.fullscreen = get_screen_mode()->fullscreen; change_screen_mode(&temp_screen_mode, true); render_screen(0); } if (changed_prefs) write_preferences(); }
static void change_panel_state( short player_index, short panel_side_index) { short state, make_sound= FALSE; struct side_data *side= get_side_data(panel_side_index); struct player_data *player= get_player_data(player_index); struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type); state= GET_CONTROL_PANEL_STATUS(side); /* Do the right thing, based on the panel type.. */ switch (definition->panel_class) { case _panel_is_oxygen_refuel: case _panel_is_shield_refuel: case _panel_is_double_shield_refuel: case _panel_is_triple_shield_refuel: #ifndef VULCAN player->control_panel_side_index= player->control_panel_side_index==panel_side_index ? NONE : panel_side_index; state= get_recharge_status(panel_side_index); SET_CONTROL_PANEL_STATUS(side, state); if (!state) set_control_panel_texture(side); #endif break; case _panel_is_computer_terminal: #ifndef VULCAN if (get_game_state()==_game_in_progress && !PLAYER_HAS_CHEATED(player) && !PLAYER_HAS_MAP_OPEN(player)) { /* this will handle changing levels, if necessary (i.e., if weÕre finished) */ enter_computer_interface(player_index, side->control_panel_permutation, calculate_level_completion_state()); } #endif break; case _panel_is_tag_switch: if (definition->item==NONE || (!state && try_and_subtract_player_item(player_index, definition->item))) { state= !state; make_sound= set_tagged_light_statuses(side->control_panel_permutation, state); if (try_and_change_tagged_platform_states(side->control_panel_permutation, state)) make_sound= TRUE; if (!side->control_panel_permutation) make_sound= TRUE; if (make_sound) { SET_CONTROL_PANEL_STATUS(side, state); set_control_panel_texture(side); } } break; case _panel_is_light_switch: state= !state; make_sound= set_light_status(side->control_panel_permutation, state); break; case _panel_is_platform_switch: state= !state; make_sound= try_and_change_platform_state(get_polygon_data(side->control_panel_permutation)->permutation, state); break; case _panel_is_pattern_buffer: #ifndef VULCAN if (dynamic_world->tick_count-player->ticks_at_last_successful_save>MINIMUM_RESAVE_TICKS && player_controlling_game() && !PLAYER_HAS_CHEATED(local_player) && !game_is_networked) { play_control_panel_sound(panel_side_index, _activating_sound); // fade_out_background_music(30); /* Assume a successful save- prevents vidding of the save game key.. */ player->ticks_at_last_successful_save= dynamic_world->tick_count; if (!save_game()) { // AMR 3/12/97 vidding happens with InputSprocket with this here //player->ticks_at_last_successful_save= 0; } // fade_in_background_music(30); } #endif break; default: halt(); } if (make_sound) { play_control_panel_sound(panel_side_index, state ? _activating_sound : _deactivating_sound); } return; }