void enter_screen(void) { if (world_view->overhead_map_active) set_overhead_map_status(false); if (world_view->terminal_mode_active) set_terminal_status(false); // Adding this view-effect resetting here since initialize_world_view() no longer resets it world_view->effect = NONE; // Set screen to selected size in_game = true; change_screen_mode(&screen_mode, true); PrevFullscreen = screen_mode.fullscreen; #if defined(HAVE_OPENGL) && !defined(MUST_RELOAD_VIEW_CONTEXT) // if MUST_RELOAD_VIEW_CONTEXT, we know this just happened in // change_screen_mode if (screen_mode.acceleration == _opengl_acceleration) OGL_StartRun(); #endif #ifdef HAVE_OPENGL if (OGL_IsActive()) OGL_HUDActive = true; else OGL_HUDActive = false; #endif // Reset modifier key status SDL_SetModState(KMOD_NONE); }
// Fader stuff bool OGL_FaderActive() { if (!OGL_IsActive()) return false; OGL_ConfigureData& ConfigureData = Get_OGL_ConfigureData(); return TEST_FLAG(ConfigureData.Flags,OGL_Flag_Fader); }
static void process_screen_click(const SDL_Event &event) { int x = event.button.x, y = event.button.y; #ifdef HAVE_OPENGL if (OGL_IsActive()) OGL_Blitter::WindowToScreen(x, y); #endif portable_process_screen_click(x, y, has_cheat_modifiers()); }
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(); }
/* origin,origin_polygon_index,yaw,pitch,roll,etc. have probably changed since last call */ void render_view( struct view_data *view, struct bitmap_definition *destination) { update_view_data(view); /* clear the render flags */ objlist_clear(render_flags, RENDER_FLAGS_BUFFER_SIZE); ResetOverheadMap(); /* #ifdef AUTOMAP_DEBUG memset(automap_lines, 0, (dynamic_world->line_count/8+((dynamic_world->line_count%8)?1:0)*sizeof(byte))); memset(automap_polygons, 0, (dynamic_world->polygon_count/8+((dynamic_world->polygon_count%8)?1:0)*sizeof(byte))); #endif */ if(view->terminal_mode_active) { /* Render the computer interface. */ render_computer_interface(view); } else { // LP: the render objects have a pointer to the current view in them, // so that one can get rid of redundant references to it in them. // LP: now from the visibility-tree class /* build the render tree, regardless of map mode, so the automap updates while active */ RenderVisTree.view = view; RenderVisTree.build_render_tree(); /* do something complicated and difficult to explain */ if (!view->overhead_map_active || map_is_translucent()) { // LP: now from the polygon-sorter class /* sort the render tree (so we have a depth-ordering of polygons) and accumulate clipping information for each polygon */ RenderSortPoly.view = view; RenderSortPoly.sort_render_tree(); // LP: now from the object-placement class /* build the render object list by looking at the sorted render tree */ RenderPlaceObjs.view = view; RenderPlaceObjs.build_render_object_list(); // LP addition: set the current rasterizer to whichever is appropriate here RasterizerClass *RasPtr; #ifdef HAVE_OPENGL if (OGL_IsActive()) RasPtr = (graphics_preferences->screen_mode.acceleration == _shader_acceleration) ? &Rasterizer_Shader : &Rasterizer_OGL; else { #endif // The software renderer needs this but the OpenGL one doesn't... Rasterizer_SW.screen = destination; RasPtr = &Rasterizer_SW; #ifdef HAVE_OPENGL } #endif // Set its view: RasPtr->SetView(*view); // Start rendering main view RasPtr->Begin(); // LP: now from the clipping/rasterizer class #ifdef HAVE_OPENGL RenderRasterizerClass *RenPtr = (graphics_preferences->screen_mode.acceleration == _shader_acceleration) ? &Render_Shader : &Render_Classic; #else RenderRasterizerClass *RenPtr = &Render_Classic; #endif /* render the object list, back to front, doing clipping on each surface before passing it to the texture-mapping code */ RenPtr->view = view; RenPtr->RasPtr = RasPtr; RenPtr->render_tree(); // LP: won't put this into a separate class /* render the playerÕs weapons, etc. */ render_viewer_sprite_layer(view, RasPtr); // Finish rendering main view RasPtr->End(); } if (view->overhead_map_active) { /* if the overhead map is active, render it */ render_overhead_map(view); } } }