The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CVideo Class Reference

#include <video.hpp>

Inheritance diagram for CVideo:
Inheritance graph

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, intcurrent_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 ()
 
surfacegetSurface ()
 
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::twindowget_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 CVideoget_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::twindowwindow
 
bool mode_changed_
 
bool fake_screen_
 
video_event_handler event_handler_
 
int help_string_
 
int updatesLocked_
 

Static Private Attributes

static CVideosingleton_ = nullptr
 

Detailed Description

Definition at line 58 of file video.hpp.

Member Enumeration Documentation

Enumerator
NO_FAKE 
FAKE 
FAKE_TEST 

Definition at line 60 of file video.hpp.

Enumerator
TO_RES 
TO_FULLSCREEN 
TO_WINDOWED 
TO_MAXIMIZED_WINDOW 

Definition at line 66 of file video.hpp.

Constructor & Destructor Documentation

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_.

Member Function Documentation

void CVideo::blit_surface ( int  x,
int  y,
surface  surf,
SDL_Rect *  srcrect = nullptr,
SDL_Rect *  clip_rect = nullptr 
)
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().

void CVideo::clear_help_string ( int  handle)
std::pair< int, int > CVideo::current_resolution ( )

Definition at line 615 of file video.cpp.

References getSurface().

Referenced by get_available_resolutions(), set_resolution(), and gui2::set_resolution_list().

void CVideo::delay ( unsigned int  milliseconds)
static
bool CVideo::faked ( ) const
inline
void CVideo::flip ( )
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().

static CVideo& CVideo::get_singleton ( )
inlinestatic
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 ( )
int CVideo::getx ( ) const
int CVideo::gety ( ) const
bool CVideo::init_window ( )
void CVideo::initSDL ( )
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

Definition at line 620 of file video.cpp.

References window.

Referenced by set_fullscreen().

void CVideo::lock_updates ( bool  value)
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.

Parameters
widthThe width of the buffer.
heightThe height of the buffer.
bppThe 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 ( )

Definition at line 115 of file video.cpp.

References window.

Referenced by display::display().

void CVideo::set_fullscreen ( bool  ison)
int CVideo::set_help_string ( const std::string str)
void CVideo::set_resolution ( const std::pair< int, int > &  res)

Set the resolution.

Parameters
widthThe new width.
heightThe new height.
Returns
The status true if width and height are the size of the framebuffer, false otherwise.

Definition at line 696 of file video.cpp.

Referenced by do_preferences_dialog().

void CVideo::set_resolution ( const unsigned  width,
const unsigned  height 
)
void CVideo::set_window_icon ( surface icon)

Sets the icon of the main window.

Parameters
iconThe 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.

Parameters
titleThe 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 
)
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
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.

Member Data Documentation

const int CVideo::DefaultBpp = 32
static

Definition at line 79 of file video.hpp.

video_event_handler CVideo::event_handler_
private

Definition at line 239 of file video.hpp.

Referenced by init_window().

bool CVideo::fake_screen_
private

Definition at line 237 of file video.hpp.

Referenced by faked(), flip(), make_fake(), and setMode().

int CVideo::help_string_
private

Definition at line 242 of file video.hpp.

Referenced by clear_all_help_strings(), clear_help_string(), and set_help_string().

bool CVideo::mode_changed_
private

Definition at line 233 of file video.hpp.

Referenced by modeChanged(), and setMode().

CVideo * CVideo::singleton_ = nullptr
staticprivate

Definition at line 213 of file video.hpp.

Referenced by CVideo(), get_singleton(), and ~CVideo().

int CVideo::updatesLocked_
private

Definition at line 244 of file video.hpp.

Referenced by lock_updates(), and update_locked().

boost::scoped_ptr<sdl::twindow> CVideo::window
private

The documentation for this class was generated from the following files: