diff --git a/README.md b/README.md index 0b3cb07..428cd7b 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,11 @@ Note: If you've already cloned this repo without using `--recursive` flag, just ``` - You should find the executables under `build/bin` + +## License + +This project is released under MIT license. See [LICENSE.md](LICENSE.md) for details. Note that this does not cover any of the submodules located under [vendor](vendors/) and assets located under [resources](resources/). + +- [sfml](vendors/sfml/) is covered under [Zlib](vendors/sfml/license.md) license. + +- [FiraCode-Regular.ttf](resourcs/FiraCode-Regular.ttf) is covered under [OFL-1.1](https://github.com/tonsky/FiraCode/blob/master/LICENSE) license. diff --git a/resources/FiraCode-Regular.ttf b/resources/FiraCode-Regular.ttf new file mode 100644 index 0000000..bd73685 Binary files /dev/null and b/resources/FiraCode-Regular.ttf differ diff --git a/resources/sfml-project-template.png b/resources/sfml-project-template.png deleted file mode 100644 index 27c3f3e..0000000 Binary files a/resources/sfml-project-template.png and /dev/null differ diff --git a/src/main.cpp b/src/main.cpp index 9be177e..2752199 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,23 +1,26 @@ #include #include +#include #include "Version.hpp" static void modifyCurrentWorkingDirectory(); +static void setupVersionTexts(sf::RenderWindow &window, sf::Font &font, sf::Text &templateVersion, sf::Text &sfmlVersion); int main() { modifyCurrentWorkingDirectory(); + + const auto clearColor = sf::Color(234, 240, 206); auto title = "Template-" + GetTemplateVersion() + "/SFML-" + GetSFMLVersion(); sf::RenderWindow window(sf::VideoMode(640, 360), title, sf::Style::Close); - sf::Texture texture; - sf::Sprite sprite; + sf::Font font; + sf::Text sfmlVersion; + sf::Text templateVersion; - if (texture.loadFromFile("resources/sfml-project-template.png")) + if (font.loadFromFile("resources/FiraCode-Regular.ttf")) { - sprite.setTexture(texture); - sprite.setOrigin({(float)texture.getSize().x / 2, (float)texture.getSize().y / 2}); - sprite.setPosition((float)window.getSize().x / 2, (float)window.getSize().y / 2); + setupVersionTexts(window, font, templateVersion, sfmlVersion); } while (window.isOpen()) @@ -31,14 +34,46 @@ int main() } } - window.clear(); - window.draw(sprite); + window.clear(clearColor); + window.draw(templateVersion); + window.draw(sfmlVersion); window.display(); } return 0; } +void setupVersionTexts(sf::RenderWindow &window, sf::Font &font, sf::Text &templateVersion, sf::Text &sfmlVersion) +{ + auto windowCenter = sf::Vector2f(window.getSize().x * 0.5f, window.getSize().y * 0.5f); + const auto characterSize = 65; + const auto outlineThickness = 4.f; + const auto fillColor = sf::Color(63, 51, 77); + const auto outlineColor = sf::Color(192, 197, 193); + + templateVersion.setFont(font); + templateVersion.setString("Template-v" + GetTemplateVersion()); + templateVersion.setCharacterSize(characterSize); + templateVersion.setFillColor(fillColor); + templateVersion.setOutlineColor(outlineColor); + templateVersion.setOutlineThickness(outlineThickness); + + auto textRect = templateVersion.getLocalBounds(); + templateVersion.setOrigin(textRect.left + textRect.width * 0.5f, textRect.top + textRect.height * 0.5f); + templateVersion.setPosition(windowCenter - sf::Vector2f(0.f, textRect.height)); + + sfmlVersion.setFont(font); + sfmlVersion.setString("SFML-v" + GetSFMLVersion()); + sfmlVersion.setCharacterSize(characterSize); + sfmlVersion.setFillColor(fillColor); + sfmlVersion.setOutlineColor(outlineColor); + sfmlVersion.setOutlineThickness(outlineThickness); + + textRect = sfmlVersion.getLocalBounds(); + sfmlVersion.setOrigin(textRect.left + textRect.width * 0.5f, textRect.top + textRect.height * 0.5f); + sfmlVersion.setPosition(windowCenter + sf::Vector2f(0.f, textRect.height)); +} + void modifyCurrentWorkingDirectory() { while (!std::filesystem::exists("resources"))