diff --git a/ScreenHandler.h b/ScreenHandler.h index ccdf80d..ec0c651 100644 --- a/ScreenHandler.h +++ b/ScreenHandler.h @@ -3,6 +3,7 @@ #include "Rectangle.h" #include "Styles.h" #include "RC.h" +#include "Texture.h" #include #include #include @@ -277,23 +278,44 @@ class ScreenHandler } } - void print_screen_buffer(Color bg_color) const + void print_screen_buffer(Color bg_color, drawing::Texture* texture = nullptr, const RC& pos = {}) const { - std::vector> colored_str; - colored_str.resize(NR*(NC + 1)); - int i = 0; - for (int r = 0; r < NR; ++r) + if (texture != nullptr) { - for (int c = 0; c < NC; ++c) + for (int r = 0; r < NR; ++r) + { + auto rl = r - pos.r; + for (int c = 0; c < NC; ++c) + { + auto cl = c - pos.c; + + drawing::Textel textel; + textel.ch = screen_buffer[r][c]; + textel.fg_color = fg_color_buffer[r][c]; + textel.bg_color = bg_color_buffer[r][c]; + + texture->set_textel(rl, cl, textel); + } + } + } + else + { + std::vector> colored_str; + colored_str.resize(NR*(NC + 1)); + int i = 0; + for (int r = 0; r < NR; ++r) { - Color bg_col_buf = bg_color_buffer[r][c]; - if (bg_col_buf == Color::Transparent || bg_col_buf == Color::Transparent2) - bg_col_buf = bg_color; - colored_str[i++] = { screen_buffer[r][c], fg_color_buffer[r][c], bg_col_buf }; + for (int c = 0; c < NC; ++c) + { + Color bg_col_buf = bg_color_buffer[r][c]; + if (bg_col_buf == Color::Transparent || bg_col_buf == Color::Transparent2) + bg_col_buf = bg_color; + colored_str[i++] = { screen_buffer[r][c], fg_color_buffer[r][c], bg_col_buf }; + } + colored_str[i++] = { '\n', Color::Default, Color::Default }; } - colored_str[i++] = { '\n', Color::Default, Color::Default }; + m_text->print_complex(colored_str); } - m_text->print_complex(colored_str); } void print_screen_buffer_chars() const