#include <video.hpp>
Classes | |
struct | error |
class | quit |
class | video_event_handler |
Public Types | |
enum | FAKE_TYPES { NO_FAKE, FAKE, FAKE_TEST } |
enum | MODE_EVENT { TO_RES, TO_FULLSCREEN, TO_WINDOWED, TO_MAXIMIZED_WINDOW } |
Public Member Functions | |
CVideo (FAKE_TYPES type=NO_FAKE) | |
~CVideo () | |
bool | non_interactive () |
bool | init_window () |
Initializes a new window, taking into account any preiously saved states. More... | |
void | setMode (int x, int y, const MODE_EVENT mode) |
void | set_fullscreen (bool ison) |
void | set_resolution (const std::pair< int, int > &res) |
Set the resolution. More... | |
void | set_resolution (const unsigned width, const unsigned height) |
std::pair< int, int > | current_resolution () |
bool | modeChanged () |
int | getx () const |
int | gety () const |
void | blit_surface (int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr) |
void | flip () |
surface & | getSurface () |
bool | isFullScreen () const |
void | make_fake () |
void | make_test_fake (const unsigned width=1024, const unsigned height=768, const unsigned bpp=DefaultBpp) |
Creates a fake frame buffer for the unit tests. More... | |
bool | faked () const |
int | set_help_string (const std::string &str) |
void | clear_help_string (int handle) |
void | clear_all_help_strings () |
void | lock_updates (bool value) |
bool | update_locked () const |
void | update_framebuffer () |
Uint8 | window_state () |
Wrapper for SDL_GetAppState. More... | |
void | set_window_title (const std::string &title) |
Sets the title of the main window. More... | |
void | set_window_icon (surface &icon) |
Sets the icon of the main window. More... | |
sdl::twindow * | get_window () |
std::vector< std::pair< int, int > > | get_available_resolutions (const bool include_current=false) |
Returns the list of available screen resolutions. More... | |
Static Public Member Functions | |
static CVideo & | get_singleton () |
static void | delay (unsigned int milliseconds) |
Static Public Attributes | |
static const int | DefaultBpp = 32 |
Private Member Functions | |
void | initSDL () |
Private Attributes | |
boost::scoped_ptr< sdl::twindow > | window |
bool | mode_changed_ |
bool | fake_screen_ |
video_event_handler | event_handler_ |
int | help_string_ |
int | updatesLocked_ |
Static Private Attributes | |
static CVideo * | singleton_ = nullptr |
enum CVideo::FAKE_TYPES |
enum CVideo::MODE_EVENT |
CVideo::CVideo | ( | FAKE_TYPES | type = NO_FAKE | ) |
Definition at line 215 of file video.cpp.
References FAKE, FAKE_TEST, initSDL(), make_fake(), make_test_fake(), NO_FAKE, and singleton_.
CVideo::~CVideo | ( | ) |
Definition at line 281 of file video.cpp.
References LOG_DP, and singleton_.
void CVideo::blit_surface | ( | int | x, |
int | y, | ||
surface | surf, | ||
SDL_Rect * | srcrect = nullptr , |
||
SDL_Rect * | clip_rect = nullptr |
||
) |
Definition at line 290 of file video.cpp.
References sdl::create_rect(), getSurface(), and sdl_blit().
Referenced by gui::dialog_frame::draw_border(), gui::slider::draw_contents(), gui::button::draw_contents(), gui::tristate_button::draw_contents(), gui::dialog_image::draw_contents(), gui::scrollbar::draw_contents(), draw_panel(), gui::menu::imgsel_style::draw_row(), mp::gamebrowser::draw_row(), gui::menu::imgsel_style::draw_row_bg(), battle_prediction_pane::draw_unit(), display::refresh_report(), storyscreen::part_ui::render_story_box(), storyscreen::part_ui::render_story_box_borders(), and storyscreen::part_ui::render_title_box().
void CVideo::clear_all_help_strings | ( | ) |
Definition at line 664 of file video.cpp.
References clear_help_string(), and help_string_.
Referenced by mp::ui::handle_event().
Definition at line 656 of file video.cpp.
References help_string_, and font::remove_floating_label().
Referenced by editor::location_palette::adjust_size(), clear_all_help_strings(), editor::location_palette::hide(), editor::editor_palette< t_translation::t_terrain >::hide(), gui::widget::process_help_string(), gui::menu::process_help_string(), and editor::location_palette::select_item().
Definition at line 615 of file video.cpp.
References getSurface().
Referenced by get_available_resolutions(), set_resolution(), and gui2::set_resolution_list().
Definition at line 490 of file video.cpp.
References game_config::no_delay.
Referenced by game_lua_kernel::intf_delay(), controller_base::play_slice(), gui::dialog::refresh(), storyscreen::part_ui::render_floating_images(), storyscreen::part_ui::render_story_box(), mp::run_lobby_loop(), about::show_about(), help::show_help(), the_end(), default_map_generator::user_config(), unit_animator::wait_for_end(), storyscreen::part_ui::wait_for_input(), and unit_animator::wait_until().
|
inline |
Definition at line 166 of file video.hpp.
References fake_screen_.
Referenced by display_chat_manager::add_chat_message(), gui2::tloadscreen::display(), display::display(), savegame::loadgame::load_game(), dialogs::network_transmission_dialog(), gui2::tpopup::show(), gui2::tdialog::show(), gui::dialog::show(), display::turbo_speed(), unit_display::unit_attack(), unit_display::unit_die(), unit_display::unit_draw_weapon(), unit_display::unit_healing(), unit_display::unit_recruited(), unit_display::unit_sheath_weapon(), and unit_display::wml_animation().
void CVideo::flip | ( | ) |
Definition at line 496 of file video.cpp.
References fake_screen_, GPU_Flip(), and window.
Referenced by gui2::event::thandler::draw(), gui::dialog::draw_contents(), display::flip(), storyscreen::part_ui::handle_interface(), gui::dialog::refresh(), storyscreen::part_ui::render_floating_images(), storyscreen::part_ui::render_story_box(), mp::run_lobby_loop(), about::show_about(), hotkey::show_binding_dialog(), help::show_help(), the_end(), and default_map_generator::user_config().
std::vector< std::pair< int, int > > CVideo::get_available_resolutions | ( | const bool | include_current = false | ) |
Returns the list of available screen resolutions.
Definition at line 576 of file video.cpp.
References current_resolution(), gui2::event::find(), i, preferences::min_allowed_height(), preferences::min_allowed_width(), sdl_display_index(), sort(), and window.
Referenced by gui2::set_resolution_list().
|
inlinestatic |
Definition at line 75 of file video.hpp.
References singleton_.
Referenced by events::chat_command_handler::do_display(), windows_tray_notification::get_window_handle(), help::unit_topic_generator::operator()(), events::peek_for_resize(), events::raise_resize_event(), editor::context_manager::set_window_title(), quit_confirmation::show_prompt(), preferences::theme(), preferences::turbo(), and editor::context_manager::~context_manager().
sdl::twindow * CVideo::get_window | ( | ) |
Definition at line 562 of file video.cpp.
References window.
Referenced by windows_tray_notification::get_window_handle().
surface & CVideo::getSurface | ( | ) |
Definition at line 22 of file dummy_video.cpp.
References dummy_screen_surface.
Referenced by blit_surface(), display::clear_screen(), current_resolution(), gui2::twindow::draw(), display::draw_all_panels(), gui::dialog_frame::draw_background(), gui::progress_bar::draw_contents(), gui::textbox::draw_contents(), gui::slider::draw_contents(), mp::wait::leader_preview_pane::draw_contents(), help::help_text_area::draw_contents(), gui::textbox::draw_cursor(), display::draw_image_for_report(), display::draw_minimap(), gui::menu::style::draw_row_bg(), font::draw_text(), enter_lobby_mode(), display::get_screen_surface(), gui::dialog::layout(), display::refresh_report(), storyscreen::part_ui::render_background(), storyscreen::part_ui::render_floating_images(), storyscreen::part_ui::render_story_box(), storyscreen::part_ui::render_title_box(), surface_restorer::restore(), display::screenshot(), display::scroll(), gui2::twindow::show(), about::show_about(), help::show_help(), the_end(), gui2::twindow::undraw(), and surface_restorer::update().
int CVideo::getx | ( | ) | const |
Definition at line 472 of file video.cpp.
References GPU_GetContextTarget(), and GPU_Target::w.
Referenced by gui::dialog::dialog(), gui::dialog::layout(), help::unit_topic_generator::operator()(), storyscreen::part_ui::prepare_background(), storyscreen::part_ui::prepare_geometry(), events::raise_resize_event(), storyscreen::part_ui::render_background(), storyscreen::part_ui::render_story_box(), mp::run_lobby_loop(), set_help_string(), hotkey::show_binding_dialog(), mp::ui::ui(), default_map_generator::user_config(), and display::w().
int CVideo::gety | ( | ) | const |
Definition at line 481 of file video.cpp.
References GPU_GetContextTarget(), and GPU_Target::h.
Referenced by gui::dialog::dialog(), dialogs::file_dialog::file_dialog(), display::h(), gui::dialog::layout(), gui::menu::max_items_onscreen(), storyscreen::part_ui::prepare_background(), storyscreen::part_ui::prepare_geometry(), events::raise_resize_event(), storyscreen::part_ui::render_background(), storyscreen::part_ui::render_story_box(), mp::run_lobby_loop(), set_help_string(), hotkey::show_binding_dialog(), mp::ui::ui(), and default_map_generator::user_config().
bool CVideo::init_window | ( | ) |
Initializes a new window, taking into account any preiously saved states.
Creates a new window instance.
Definition at line 390 of file video.cpp.
References event_handler_, preferences::fullscreen(), get_flags(), events::sdl_handler::join_global(), preferences::maximized(), preferences::min_allowed_height(), preferences::min_allowed_width(), preferences::resolution(), image::set_pixel_format(), update_framebuffer(), and window.
Referenced by game_launcher::init_video().
|
private |
Definition at line 241 of file video.cpp.
References ERR_DP, error(), GPU_DEFAULT_INIT_FLAGS, GPU_Init(), and game_config::path.
Referenced by CVideo().
bool CVideo::isFullScreen | ( | ) | const |
void CVideo::lock_updates | ( | bool | value | ) |
Definition at line 509 of file video.cpp.
References updatesLocked_.
Referenced by display::display(), update_locker::unlock_update(), and update_locker::update_locker().
void CVideo::make_fake | ( | ) |
Definition at line 355 of file video.cpp.
References fake_screen_, and image::set_pixel_format().
Referenced by CVideo(), and game_launcher::init_video().
void CVideo::make_test_fake | ( | const unsigned | width = 1024 , |
const unsigned | height = 768 , |
||
const unsigned | bpp = DefaultBpp |
||
) |
Creates a fake frame buffer for the unit tests.
width | The width of the buffer. |
height | The height of the buffer. |
bpp | The bpp of the buffer. |
Definition at line 362 of file video.cpp.
References image::set_pixel_format().
Referenced by CVideo(), and test_utils::get_fake_display().
bool CVideo::modeChanged | ( | ) |
Definition at line 465 of file video.cpp.
References mode_changed_.
Referenced by mp::run_lobby_loop().
bool CVideo::non_interactive | ( | ) |
void CVideo::set_fullscreen | ( | bool | ison | ) |
Definition at line 670 of file video.cpp.
References preferences::_set_fullscreen(), display::get_singleton(), isFullScreen(), preferences::maximized(), display::redraw_everything(), preferences::resolution(), setMode(), TO_FULLSCREEN, TO_MAXIMIZED_WINDOW, TO_WINDOWED, and window.
Referenced by hotkey::execute_command(), gui2::fullscreen(), and game_launcher::game_launcher().
int CVideo::set_help_string | ( | const std::string & | str | ) |
Definition at line 625 of file video.cpp.
References font::add_floating_label(), font::get_floating_label_rect(), getx(), gety(), help_string_, font::line_width(), font::move_floating_label(), font::remove_floating_label(), font::floating_label::set_bg_color(), font::floating_label::set_border_size(), font::floating_label::set_font_size(), font::floating_label::set_position(), and font::SIZE_LARGE.
Referenced by editor::location_palette::adjust_size(), editor::location_palette::hide(), editor::editor_palette< t_translation::t_terrain >::hide(), gui::widget::process_help_string(), gui::menu::process_help_string(), and editor::location_palette::select_item().
Set the resolution.
width | The new width. |
height | The new height. |
Definition at line 696 of file video.cpp.
Referenced by do_preferences_dialog().
void CVideo::set_resolution | ( | const unsigned | width, |
const unsigned | height | ||
) |
Definition at line 701 of file video.cpp.
References preferences::_set_maximized(), preferences::_set_resolution(), current_resolution(), display::get_singleton(), display::redraw_everything(), setMode(), and TO_RES.
Sets the icon of the main window.
icon | The new icon for the window. |
Definition at line 556 of file video.cpp.
References window.
Referenced by game_launcher::init_video().
void CVideo::set_window_title | ( | const std::string & | title | ) |
Sets the title of the main window.
title | The new title for the window. |
Definition at line 550 of file video.cpp.
References window.
Referenced by game_launcher::change_language(), game_launcher::init_video(), editor::context_manager::set_window_title(), and editor::context_manager::~context_manager().
void CVideo::setMode | ( | int | x, |
int | y, | ||
const MODE_EVENT | mode | ||
) |
Definition at line 431 of file video.cpp.
References fake_screen_, mode_changed_, image::set_pixel_format(), TO_FULLSCREEN, TO_MAXIMIZED_WINDOW, TO_RES, TO_WINDOWED, update_framebuffer(), and window.
Referenced by set_fullscreen(), and set_resolution().
void CVideo::update_framebuffer | ( | ) |
Definition at line 375 of file video.cpp.
References surface::assign(), and window.
Referenced by init_window(), events::peek_for_resize(), and setMode().
bool CVideo::update_locked | ( | ) | const |
Definition at line 517 of file video.cpp.
References updatesLocked_.
Referenced by display::draw(), display::redraw_everything(), display::scroll(), display::scroll_to_xy(), gui::dialog::show(), unit_display::unit_attack(), unit_display::unit_die(), unit_display::unit_draw_weapon(), unit_display::unit_healing(), unit_display::unit_recruited(), unit_display::unit_sheath_weapon(), display::update_display(), and unit_display::wml_animation().
Uint8 CVideo::window_state | ( | ) |
Wrapper for SDL_GetAppState.
Definition at line 522 of file video.cpp.
References SDL_APPACTIVE, SDL_APPINPUTFOCUS, SDL_APPMOUSEFOCUS, and window.
|
private |
Definition at line 239 of file video.hpp.
Referenced by init_window().
|
private |
|
private |
Definition at line 242 of file video.hpp.
Referenced by clear_all_help_strings(), clear_help_string(), and set_help_string().
|
private |
Definition at line 233 of file video.hpp.
Referenced by modeChanged(), and setMode().
|
staticprivate |
Definition at line 213 of file video.hpp.
Referenced by CVideo(), get_singleton(), and ~CVideo().
|
private |
Definition at line 244 of file video.hpp.
Referenced by lock_updates(), and update_locked().
|
private |
Definition at line 215 of file video.hpp.
Referenced by flip(), get_available_resolutions(), get_window(), init_window(), isFullScreen(), non_interactive(), set_fullscreen(), set_window_icon(), set_window_title(), setMode(), update_framebuffer(), and window_state().