Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
sfml_helper.h
Go to the documentation of this file.
1#ifndef SFML_HELPER_H
2#define SFML_HELPER_H
3
5
6#include "ccfwd.h"
7#include "chess_color.h"
8#include "screen_rect.h"
9#include "piece_action_type.h"
10
11#include <SFML/Graphics.hpp>
12
14sf::Color f_health_to_color(const double f);
15
17sf::Color f_shield_to_color(const double f);
18
20std::vector<sf::Mouse::Button> get_all_sfml_buttons() noexcept;
21
23std::vector<sf::Keyboard::Key> get_all_sfml_keys() noexcept;
24
26bool is_shift_pressed() noexcept;
27
30std::string key_str_to_resource_name(std::string key_str);
31
33void set_rect(sf::RectangleShape& rectangle, const screen_coordinate& screen_size);
34
36void set_rect(sf::RectangleShape& rectangle, const screen_rect& screen_rect);
37
40void set_text_position(sf::Text& text, const screen_rect& screen_rect);
41
43void test_sfml_helper();
44
46std::string to_inverted_resource_name(const sf::Keyboard::Key k);
47
49std::string to_resource_name(const sf::Keyboard::Key k);
50
52std::string to_resource_name(const sf::Mouse::Button k);
53
55std::string to_str(const sf::Keyboard::Key k);
56
58std::string to_str(const sf::Mouse::Button k);
59
61std::string to_one_char_str(const sf::Keyboard::Key);
62
64sf::Color to_sfml_color(const chess_color color) noexcept;
65
67sf::Color to_sfml_color(
68 const chess_color color,
69 const piece_action_type t
70) noexcept;
71
72#endif // SFML_HELPER_H
chess_color
A chess piece color.
Definition chess_color.h:10
The coordinate on a screen.
Definition screen_coordinate.h:12
A rectangle-shaped area on the screen.
Definition screen_rect.h:15
piece_action_type
The type of actions a piece can do.
Definition piece_action_type.h:9
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_pro...
Definition sfml_helper.cpp:74
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.
Definition sfml_helper.cpp:35
std::vector< sf::Keyboard::Key > get_all_sfml_keys() noexcept
Get all the SFML keys.
Definition sfml_helper.cpp:55
void test_sfml_helper()
Tes these function.
Definition sfml_helper.cpp:176
std::vector< sf::Mouse::Button > get_all_sfml_buttons() noexcept
Get all the SFML mouse buttons.
Definition sfml_helper.cpp:45
bool is_shift_pressed() noexcept
Determine if the left or right shift has been pressed.
Definition sfml_helper.cpp:66
std::string to_resource_name(const sf::Keyboard::Key k)
Convert an SFML key to a filename, as used by input_prompt_textures}.
Definition sfml_helper.cpp:631
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 ...
Definition sfml_helper.cpp:153
void set_rect(sf::RectangleShape &rectangle, const screen_coordinate &screen_size)
Make 'rectangle' have the same size as the screen_coordinat}.
Definition sfml_helper.cpp:124
std::string to_str(const sf::Keyboard::Key k)
Convert an SFML key to a string.
Definition sfml_helper.cpp:642
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.
Definition sfml_helper.cpp:25
std::string to_inverted_resource_name(const sf::Keyboard::Key k)
Convert an SFML key to a filename, as used by input_prompt_textures}.
Definition sfml_helper.cpp:618
std::string to_one_char_str(const sf::Keyboard::Key)
Convert a key to its one-character description.
Definition sfml_helper.cpp:520
sf::Color to_sfml_color(const chess_color color) noexcept
Convert chess_color to sf::Color.
Definition sfml_helper.cpp:566