Skip to content

Commit

Permalink
Path to font needs to be added to app constructor if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tkz789 committed Oct 20, 2024
1 parent 606214b commit e6efcfa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/Graphics/SFML_GraphicsBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class SFML_GraphicsBridge: public BartaGraphicsBridgeInterface {
public:
SFML_GraphicsBridge(
std::unique_ptr<ResourceContainerInterface> resourceContainer = std::make_unique<NullResourceContainer>(),
const std::string& repositoryDir = ""
const std::filesystem::path& filePath = ""
) noexcept;
SFML_GraphicsBridge(const std::filesystem::path& filePath) noexcept;
SFML_GraphicsBridge(const SFML_GraphicsBridge&) noexcept = delete;
SFML_GraphicsBridge(SFML_GraphicsBridge&&) noexcept = delete;
SFML_GraphicsBridge& operator=(const SFML_GraphicsBridge&) noexcept = delete;
Expand Down
9 changes: 5 additions & 4 deletions include/pch.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once

// STL
#include <array>
#include <filesystem>
#include <iostream>
#include <sstream>
#include <limits>
#include <list>
#include <memory>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <array>

// SFML
#pragma GCC diagnostic push
Expand All @@ -18,12 +19,12 @@
#pragma GCC diagnostic pop

// other headers
#include <math.h>
#include <chrono>
#include <math.h>

// DEBUG
#include <iomanip>
#include <stdexcept>

// C++ 20+
#include <concepts>
#include <concepts>
12 changes: 9 additions & 3 deletions lib/Graphics/SFML_GraphicsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@

Barta::SFML_GraphicsBridge::SFML_GraphicsBridge(
std::unique_ptr<ResourceContainerInterface> resourceContainer,
const std::string& repositoryDir
const std::filesystem::path& fontPath
) noexcept:
sf_window(nullptr),
resourceMatcher(std::make_unique<SpriteResourceMatcher>(std::move(resourceContainer))),
arialFont(std::make_unique<sf::Font>()) {
if (!repositoryDir.empty()) {
arialFont->loadFromFile(repositoryDir + "\\fonts\\arial.ttf");
if (!fontPath.empty()) {
std::cout << fontPath << std::endl;
arialFont->loadFromFile(fontPath);
}
}

Barta::SFML_GraphicsBridge::SFML_GraphicsBridge(
const std::filesystem::path& fontPath
) noexcept:
SFML_GraphicsBridge(std::make_unique<Barta::NullResourceContainer>(), fontPath) {}

Barta::SFML_GraphicsBridge::~SFML_GraphicsBridge() {
delete this->sf_window;
}
Expand Down

0 comments on commit e6efcfa

Please sign in to comment.