Created
May 3, 2024 21:30
-
-
Save twist84/ee12f04c38cbc9e760d9b94967b56e2c to your computer and use it in GitHub Desktop.
WIP `c_status_line_string_cache` Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "console.hpp" | |
c_status_line_string_cache::c_status_line_string_cache() : | |
m_font_cache(), | |
m_string(), | |
m_alpha(), | |
m_color(), | |
m_text_justification() | |
{ | |
m_text_justifications8.set_all(0); | |
m_text_justifications14.set_all(0); | |
} | |
c_status_line_string_cache::~c_status_line_string_cache() | |
{ | |
m_font_cache.~m_font_cache(); | |
} | |
void c_status_line_string_cache::flush() | |
{ | |
if (!m_string.is_empty()) | |
{ | |
draw_string_internal(m_string.get_string(), m_alpha, m_color, m_text_justification); | |
m_string.clear(); | |
} | |
} | |
void c_status_line_string_cache::add_string(char const* string, real alpha, real_rgb_color const& color, long text_justification) | |
{ | |
add_string_internal(string, alpha, color, text_justification); | |
add_string_internal("|n", alpha, color, text_justification); | |
m_text_justifications14[text_justification]++; | |
} | |
void c_status_line_string_cache::add_string_internal(char const* string, real alpha, real_rgb_color const& color, long text_justification) | |
{ | |
// #TODO: implement me | |
} | |
void c_status_line_string_cache::draw_string_internal(char const* string, real alpha, real_rgb_color const& color, long text_justification) | |
{ | |
real_argb_color string_color; | |
real_argb_color shadow_color; | |
string_color.alpha = alpha; | |
string_color.color = color; | |
shadow_color.alpha = alpha; | |
shadow_color.color = *global_real_rgb_black; | |
c_rasterizer_draw_string draw_string; | |
draw_string.set_color(&string_color); | |
draw_string.set_shadow_color(&shadow_color); | |
draw_string.set_justification(text_justification); | |
if (m_text_justifications8[text_justification] <= 0) | |
{ | |
draw_string.draw(&m_font_cache, string); | |
} | |
else | |
{ | |
for (long i = 1; i < m_text_justifications8[text_justification]; i++) | |
draw_string.draw_more(&m_font_cache, "|n"); | |
draw_string.set_justification(text_justification); | |
draw_string.draw_more(&m_font_cache, string); | |
} | |
m_text_justifications8[text_justification] += m_text_justifications14[text_justification]; | |
m_text_justifications14[text_justification] = 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class c_status_line_string_cache | |
{ | |
public: | |
c_status_line_string_cache(); | |
~c_status_line_string_cache(); | |
void flush(); | |
void add_string(char const* string, real alpha, real_rgb_color const& color, long text_justification); | |
private: | |
void add_string_internal(char const* string, real alpha, real_rgb_color const& color, long text_justification); | |
void draw_string_internal(char const* string, real alpha, real_rgb_color const& color, long text_justification); | |
protected: | |
c_font_cache_mt_safe m_font_cache; | |
c_static_array<long, k_text_justification_count> m_text_justifications8; | |
c_static_array<long, k_text_justification_count> m_text_justifications14; | |
c_static_string<256> m_string; | |
real m_alpha; | |
real_rgb_color m_color; | |
long m_text_justification; | |
}; | |
static_assert(sizeof(c_status_line_string_cache) == 0x134); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment