Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Functions
sfml_helper.cpp File Reference
#include "sfml_helper.h"
#include "../magic_enum/include/magic_enum/magic_enum.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include <cassert>
#include <cmath>
Include dependency graph for sfml_helper.cpp:

Functions

std::string button_str_to_resource_name (std::string button_str)
 
sf::Color f_health_to_color (const double f)
 Convert a fraction of health (i.e. a value e [0.0, 1.0] to a color.
 
sf::Color f_shield_to_color (const double f)
 Convert a fraction of shield (i.e. a value e [0.0, 1.0] to a color.
 
std::vector< sf::Mouse::Button > get_all_sfml_buttons () noexcept
 Get all the SFML mouse buttons.
 
std::vector< sf::Keyboard::Key > get_all_sfml_keys () noexcept
 Get all the SFML keys.
 
bool is_shift_pressed () noexcept
 Determine if the left or right shift has been pressed.
 
std::string key_str_to_resource_name (std::string key_str)
 Convert an SFML key that has already been converted to a filename to a filename, as used by input_prompt_textures}.
 
void set_rect (sf::RectangleShape &rectangle, const screen_coordinate &screen_size)
 Make 'rectangle' have the same size as the screen_coordinat}.
 
void set_rect (sf::RectangleShape &rectangle, const screen_rect &screen_rect)
 Make 'rectangle' have the same size and position as the 'screen_rect'.
 
void set_text_position (sf::Text &text, const screen_rect &screen_rect)
 Make 'text' have the same size and position as the 'screen_rect' Assumes the text already has a font and has text.
 
void test_sfml_helper ()
 Tes these function.
 
std::string to_one_char_str (const sf::Keyboard::Key k)
 Convert a key to its one-character description.
 
sf::Color to_sfml_color (const chess_color color) noexcept
 Convert chess_color to sf::Color.
 
sf::Color to_sfml_color (const chess_color color, const piece_action_type t) noexcept
 Convert chess_color to sf::Color.
 
std::string to_inverted_resource_name (const sf::Keyboard::Key k)
 Convert an SFML key to a filename, as used by input_prompt_textures}.
 
std::string to_resource_name (const sf::Keyboard::Key k)
 Convert an SFML key to a filename, as used by input_prompt_textures}.
 
std::string to_resource_name (const sf::Mouse::Button k)
 Convert an SFML mouse button to a filename, as used by input_prompt_textures}.
 
std::string to_str (const sf::Keyboard::Key k)
 Convert an SFML key to a string.
 
std::string to_str (const sf::Mouse::Button k)
 Convert an SFML mouse button to a string.
 

Function Documentation

◆ button_str_to_resource_name()

std::string button_str_to_resource_name ( std::string  button_str)

◆ f_health_to_color()

sf::Color f_health_to_color ( const double  f)

Convert a fraction of health (i.e. a value e [0.0, 1.0] to a color.

◆ f_shield_to_color()

sf::Color f_shield_to_color ( const double  f)

Convert a fraction of shield (i.e. a value e [0.0, 1.0] to a color.

◆ get_all_sfml_buttons()

std::vector< sf::Mouse::Button > get_all_sfml_buttons ( )
noexcept

Get all the SFML mouse buttons.

◆ get_all_sfml_keys()

std::vector< sf::Keyboard::Key > get_all_sfml_keys ( )
noexcept

Get all the SFML keys.

◆ is_shift_pressed()

bool is_shift_pressed ( )
noexcept

Determine if the left or right shift has been pressed.

◆ key_str_to_resource_name()

std::string key_str_to_resource_name ( std::string  key_str)

Convert an SFML key that has already been converted to a filename to a filename, as used by input_prompt_textures}.

◆ set_rect() [1/2]

void set_rect ( sf::RectangleShape &  rectangle,
const screen_coordinate screen_size 
)

Make 'rectangle' have the same size as the screen_coordinat}.

◆ set_rect() [2/2]

void set_rect ( sf::RectangleShape &  rectangle,
const screen_rect screen_rect 
)

Make 'rectangle' have the same size and position as the 'screen_rect'.

◆ set_text_position()

void set_text_position ( sf::Text &  text,
const screen_rect screen_rect 
)

Make 'text' have the same size and position as the 'screen_rect' Assumes the text already has a font and has text.

◆ test_sfml_helper()

void test_sfml_helper ( )

Tes these function.

◆ to_inverted_resource_name()

std::string to_inverted_resource_name ( const sf::Keyboard::Key  k)

Convert an SFML key to a filename, as used by input_prompt_textures}.

◆ to_one_char_str()

std::string to_one_char_str ( const sf::Keyboard::Key  k)

Convert a key to its one-character description.

◆ to_resource_name() [1/2]

std::string to_resource_name ( const sf::Keyboard::Key  k)

Convert an SFML key to a filename, as used by input_prompt_textures}.

◆ to_resource_name() [2/2]

std::string to_resource_name ( const sf::Mouse::Button  k)

Convert an SFML mouse button to a filename, as used by input_prompt_textures}.

◆ to_sfml_color() [1/2]

sf::Color to_sfml_color ( const chess_color  color)
noexcept

Convert chess_color to sf::Color.

◆ to_sfml_color() [2/2]

sf::Color to_sfml_color ( const chess_color  color,
const piece_action_type  t 
)
noexcept

Convert chess_color to sf::Color.

◆ to_str() [1/2]

std::string to_str ( const sf::Keyboard::Key  k)

Convert an SFML key to a string.

◆ to_str() [2/2]

std::string to_str ( const sf::Mouse::Button  k)

Convert an SFML mouse button to a string.