HoverRace
2.0
|
SDL-based software rendering. More...
#include <SdlDisplay.h>
Public Member Functions | |
SdlDisplay (const std::string &windowTitle="") | |
Constructor. More... | |
virtual | ~SdlDisplay () |
void | AttachView (ActiveText &model) override |
Attach the display-specific view. More... | |
void | AttachView (BaseContainer &model) override |
Attach the display-specific view. More... | |
void | AttachView (Button &model) override |
Attach the display-specific view. More... | |
void | AttachView (ClickRegion &model) override |
Attach the display-specific view. More... | |
void | AttachView (FillBox &model) override |
Attach the display-specific view. More... | |
void | AttachView (KeycapIcon &model) override |
Attach the display-specific view. More... | |
void | AttachView (Label &model) override |
Attach the display-specific view. More... | |
void | AttachView (Picture &model) override |
Attach the display-specific view. More... | |
void | AttachView (RuleLine &model) override |
Attach the display-specific view. More... | |
void | AttachView (ScreenFade &model) override |
Attach the display-specific view. More... | |
void | AttachView (Slider &model) override |
Attach the display-specific view. More... | |
void | AttachView (SymbolIcon &model) override |
Attach the display-specific view. More... | |
void | AttachView (Wallpaper &model) override |
Attach the display-specific view. More... | |
void | DrawUiTexture (SDL_Texture *texture, const Vec2 &relPos, uiLayoutFlags_t layoutFlags=0) |
Blit an SDL texture to the backbuffer with the current layout state. More... | |
void | DrawUiTexture (SDL_Texture *texture, const Vec2 &relPos, const Vec2 &scale, uiLayoutFlags_t layoutFlags=0) |
Blit a scaled SDL texture to the backbuffer with the current layout state. More... | |
void | Flip () override |
Rendering for the frame has completed; update the screen. More... | |
VideoServices::VideoBuffer & | GetLegacyDisplay () const override |
Retrieve the legacy (8-bit) framebuffer. More... | |
SDL_Renderer * | GetRenderer () const |
int | GetScreenHeight () const |
int | GetScreenWidth () const |
SDL_Window * | GetWindow () const |
std::shared_ptr< SdlTexture > | LoadRes (std::shared_ptr< Res< Texture >> res) |
Loads a texture resource. More... | |
TTF_Font * | LoadTtfFont (const UiFont &font, bool uiScale=true) |
Load the TTF font for a given name and size. More... | |
void | OnDesktopModeChanged (int width, int height) override |
Reconfigure the display when the desktop resolution has changed. More... | |
void | OnDisplayConfigChanged () override |
Reconfigure the display based on the new configuration. More... | |
void | Screenshot () override |
Take a screenshot. More... | |
Public Member Functions inherited from HoverRace::Display::Display | |
Display () | |
virtual | ~Display () |
uiLayoutFlags_t | AddUiLayoutFlags (uiLayoutFlags_t flags) noexcept |
Combine the current UI layout flags with new flags. More... | |
Vec2 | AddUiOrigin (const Vec2 &vec) noexcept |
Shift the current UI origin coordinates by an offset. More... | |
void | CleanTypeCaseCache () |
Clean up the cache of TypeCase instances. More... | |
displayConfigChangedSignal_t & | GetDisplayConfigChangedSignal () |
std::shared_ptr< TypeCase > | GetTypeCase (const UiFont &font) |
Retrieve or create the TypeCase for a particular font. More... | |
const Vec2 & | GetUiOffset () const noexcept |
const Vec2 & | GetUiOrigin () const noexcept |
Retrieve the current UI origin coordinates. More... | |
double | GetUiScale () const noexcept |
uiScaleChangedSignal_t & | GetUiScaleChangedSignal () |
const Vec2 & | GetUiScreenSize () const noexcept |
Retrieve the dimensions of the screen, in UI coordinates. More... | |
Vec2 | LayoutUiPosition (const Vec2 &relPos, uiLayoutFlags_t layoutFlags=0) noexcept |
void | SetUiLayoutFlags (uiLayoutFlags_t flags) noexcept |
Explicitly set the current UI layout flags. More... | |
void | SetUiOrigin (const Vec2 &vec) noexcept |
Explicitly set the UI origin coordinates. More... | |
Protected Member Functions | |
std::shared_ptr< TypeCase > | MakeTypeCase (const UiFont &font) override |
Create a new TypeCase for a given font. More... | |
Protected Member Functions inherited from HoverRace::Display::Display | |
void | FireDisplayConfigChangedSignal (int width, int height) const |
void | FireUiScaleChangedSignal (double scale) const |
Private Types | |
using | loadedFontKey = std::pair< std::string, int > |
using | loadedFonts_t = std::map< loadedFontKey, TTF_Font * > |
using | SUPER = Display |
Private Member Functions | |
void | ApplyVideoMode () |
Apply the current video configuration to the display. More... | |
Private Attributes | |
int | height |
VideoServices::VideoBuffer * | legacyDisplay |
loadedFonts_t | loadedFonts |
SDL_Renderer * | renderer |
int | width |
SDL_Window * | window |
std::string | windowTitle |
Additional Inherited Members | |
Public Types inherited from HoverRace::Display::Display | |
using | displayConfigChangedSignal_t = boost::signals2::signal< void(int, int)> |
using | uiScaleChangedSignal_t = boost::signals2::signal< void(double)> |
Public Attributes inherited from HoverRace::Display::Display | |
Styles | styles |
SDL-based software rendering.
|
private |
|
private |
|
private |
HoverRace::Display::SDL::SdlDisplay::SdlDisplay | ( | const std::string & | windowTitle = "" | ) |
Constructor.
This will create a new window with the specified title. Initial size and position will be pulled from the Config.
windowTitle | The window title. |
|
virtual |
|
private |
Apply the current video configuration to the display.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< ActiveText >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< BaseContainer >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< Button >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< ClickRegion >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< FillBox >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< KeycapIcon >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< Label >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< Picture >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< RuleLine >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< ScreenFade >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< Slider >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< SymbolIcon >.
|
overridevirtual |
Attach the display-specific view.
model | The view model. |
Implements HoverRace::Display::ViewAttacher< Wallpaper >.
void HoverRace::Display::SDL::SdlDisplay::DrawUiTexture | ( | SDL_Texture * | texture, |
const Vec2 & | relPos, | ||
uiLayoutFlags_t | layoutFlags = 0 |
||
) |
Blit an SDL texture to the backbuffer with the current layout state.
texture | The texture to blit (may be NULL ). |
relPos | The UI-space position, relative to the current UI origin. |
layoutFlags | Optional layout flags, from the view model. |
void HoverRace::Display::SDL::SdlDisplay::DrawUiTexture | ( | SDL_Texture * | texture, |
const Vec2 & | relPos, | ||
const Vec2 & | scale, | ||
uiLayoutFlags_t | layoutFlags = 0 |
||
) |
Blit a scaled SDL texture to the backbuffer with the current layout state.
texture | The texture to blit (may be NULL ). |
relPos | The UI-space position, relative to the current UI origin. |
scale | The scaling to apply to the texture. |
layoutFlags | Optional layout flags, from the view model. |
|
overridevirtual |
Rendering for the frame has completed; update the screen.
Implements HoverRace::Display::Display.
|
inlineoverridevirtual |
Retrieve the legacy (8-bit) framebuffer.
The legacy framebuffer provides an 8-bit surface for drawing. This framebuffer is drawn as the background layer since it doesn't have an alpha channel.
Implements HoverRace::Display::Display.
|
inline |
|
inline |
|
inline |
|
inline |
std::shared_ptr< SdlTexture > HoverRace::Display::SDL::SdlDisplay::LoadRes | ( | std::shared_ptr< Res< Texture >> | res | ) |
Loads a texture resource.
res | The resource (may be nullptr ). |
ResLoadExn |
TTF_Font * HoverRace::Display::SDL::SdlDisplay::LoadTtfFont | ( | const UiFont & | font, |
bool | uiScale = true |
||
) |
Load the TTF font for a given name and size.
The font is cached for future retrievals.
font | The font specification. |
uiScale | Apply the user-selected scaling. False is useful if scaling will be applied later. |
nullptr
). HoverRace::Exception | The font could not be loaded. |
|
overrideprotectedvirtual |
Create a new TypeCase for a given font.
This is called by GetTypeCase() when the TypeCase is not in the cache.
font | The normalized font. |
nullptr
. Implements HoverRace::Display::Display.
|
overridevirtual |
Reconfigure the display when the desktop resolution has changed.
This should be called whenever the desktop resolution changes, so the aspect ratio can be maintained in windowed mode.
width | The width of the desktop in pixels. |
height | The height of the desktop in pixels. |
Implements HoverRace::Display::Display.
|
overridevirtual |
Reconfigure the display based on the new configuration.
This should be called whenever the video configuration of Util::Config changes.
Reimplemented from HoverRace::Display::Display.
|
overridevirtual |
Take a screenshot.
Implements HoverRace::Display::Display.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |