cc3dsfs/source/TextRectanglePool.cpp
Lorenzooone 64dec0a515
Some checks are pending
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 -DCMAKE_PARALLEL_MSVC=TRUE name:Windows VS2022 Win32 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 -DCMAKE_PARALLEL_MSVC=TRUE name:Windows VS2022 x64 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 -DCMAKE_PARALLEL_MSVC=TRUE name:Windows VS2022 ARM os:windows-2022]) (push) Waiting to run
CD / Create Pi Mono Setup (push) Blocked by required conditions
CD / Publishing (push) Blocked by required conditions
Make the software compatible with lower end hardware
2025-04-27 02:39:46 +02:00

49 lines
1.6 KiB
C++

#include "TextRectangle.hpp"
#include "TextRectanglePool.hpp"
TextRectanglePool::TextRectanglePool(bool font_load_success, sf::Font *text_font) {
this->font_load_success = font_load_success;
this->text_font = text_font;
this->num_loaded_text_rectangles = 0;
this->text_rectangles_list = NULL;
}
TextRectanglePool::~TextRectanglePool() {
if(this->num_loaded_text_rectangles > 0) {
for(int i = 0; i < this->num_loaded_text_rectangles; i++)
delete this->text_rectangles_list[i];
delete []this->text_rectangles_list;
}
this->num_loaded_text_rectangles = 0;
}
void TextRectanglePool::request_num_text_rectangles(int num_wanted_text_rectangles) {
if(this->num_loaded_text_rectangles > num_wanted_text_rectangles)
return;
TextRectangle** new_text_rectangle_ptrs = new TextRectangle*[num_wanted_text_rectangles];
// Copy other TextRectangles to new list
for(int i = 0; i < this->num_loaded_text_rectangles; i++) {
new_text_rectangle_ptrs[i] = this->text_rectangles_list[i];
}
// Create new TextRectangles
for(int i = this->num_loaded_text_rectangles; i < num_wanted_text_rectangles; i++) {
new_text_rectangle_ptrs[i] = new TextRectangle(this->font_load_success, *this->text_font);
}
if(this->num_loaded_text_rectangles > 0)
delete []this->text_rectangles_list;
this->text_rectangles_list = new_text_rectangle_ptrs;
this->num_loaded_text_rectangles = num_wanted_text_rectangles;
}
TextRectangle* TextRectanglePool::get_text_rectangle(int index) {
if((this->num_loaded_text_rectangles <= index) || (index < 0))
return NULL;
return this->text_rectangles_list[index];
}