Skip to content

Commit

Permalink
Updated draw_string
Browse files Browse the repository at this point in the history
Added `e_text_style`
  • Loading branch information
twist84 committed Dec 6, 2024
1 parent 5cb0f7f commit 8cb85da
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 132 deletions.
2 changes: 1 addition & 1 deletion game/source/ai/ai_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void ai_debug_string(char const* string, short tab_stop_count, short const* tab_
if (!color)
color = global_real_argb_white;

interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);

draw_string.set_color(color);
draw_string.set_tab_stops(tab_stops, tab_stop_count);
Expand Down
6 changes: 3 additions & 3 deletions game/source/camera/director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ void __cdecl director_render()
interface_get_current_display_settings(nullptr, nullptr, nullptr, &bounds);
bounds.y0 += 80;

draw_string.set_font(4);
draw_string.set_style(-1);
draw_string.set_justification(0);
draw_string.set_font(_large_body_text_font);
draw_string.set_style(_text_style_plain);
draw_string.set_justification(_text_justification_left);
draw_string.set_bounds(&bounds);
draw_string.set_color(global_real_argb_white);
draw_string.draw(&font_cache, rasterizer_string.get_string());
Expand Down
2 changes: 1 addition & 1 deletion game/source/data_mining/data_mine_usability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void data_mine_render_mission_segment()
bounds.x1 = SHRT_MAX;
bounds.y1 = SHRT_MAX;

interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);

draw_string.set_color(global_real_argb_yellow);
draw_string.set_tab_stops(NULL, 0);
Expand Down
4 changes: 2 additions & 2 deletions game/source/hs/hs_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void render_debug_scripting()
// short tab_stops[] { 250, 300, 350 };
// c_rasterizer_draw_string draw_string{};
// c_font_cache_mt_safe font_cache{};
// interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
// interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
// draw_string.set_tab_stops(tab_stops, NUMBEROF(tab_stops));
//
// csnzprintf(buffer, sizeof(buffer), "script name\tLine \tsleep time\tfunction");
Expand Down Expand Up @@ -436,7 +436,7 @@ void render_debug_scripting_globals()
// c_font_cache_mt_safe font_cache{};
// short tab_stops[]{ 300 };
// struct scenario* scenario = global_scenario_get();
// interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
// interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
// draw_string.set_tab_stops(tab_stops, NUMBEROF(tab_stops));
//
// csnzprintf(buffer, sizeof(buffer), "|n|n|nglobal name|tvalue");
Expand Down
12 changes: 6 additions & 6 deletions game/source/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ void __cdecl interface_initialize_for_new_map()
INVOKE(0x00AAE620, interface_initialize_for_new_map);
}

void __cdecl interface_set_bitmap_text_draw_mode(c_draw_string* draw_string, long font_id, long text_style, long text_justification, dword a5, short interface_tag_index, short color_block_index)
void __cdecl interface_set_bitmap_text_draw_mode(c_draw_string* draw_string, e_font_id interface_font, e_text_style style, e_text_justification justification, dword flags, short color_table_index, short color_index)
{
//INVOKE(0x00AAE630, interface_set_bitmap_text_draw_mode, draw_string, font_id, text_style, text_justification, a5, interface_tag_index, color_block_index);
//INVOKE(0x00AAE630, interface_set_bitmap_text_draw_mode, draw_string, interface_font, style, justification, flags, color_table_index, color_index);

real_argb_color color{};
interface_get_real_argb_color(interface_tag_index, color_block_index, &color);
interface_get_real_argb_color(color_table_index, color_index, &color);

real_argb_color shadow_color{};
shadow_color.color = *global_real_rgb_black;
shadow_color.alpha = color.alpha;

draw_string->set_font(font_id);
draw_string->set_style(text_style);
draw_string->set_justification(text_justification);
draw_string->set_font(interface_font);
draw_string->set_style(style);
draw_string->set_justification(justification);
draw_string->set_color(&color);
draw_string->set_shadow_color(&shadow_color);
}
Expand Down
5 changes: 4 additions & 1 deletion game/source/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "cseries/cseries.hpp"

struct c_draw_string;
enum e_font_id;
enum e_text_style;
enum e_text_justification;

extern void __cdecl interface_dispose();
extern void __cdecl interface_dispose_from_old_map();
Expand All @@ -11,6 +14,6 @@ extern real_argb_color* __cdecl interface_get_real_argb_color(short interface_re
extern real_argb_color* __cdecl interface_get_rgb_color(short interface_reference_index, short color_block_index, real_argb_color* color_out);
extern void __cdecl interface_initialize();
extern void __cdecl interface_initialize_for_new_map();
extern void __cdecl interface_set_bitmap_text_draw_mode(c_draw_string* draw_string, long font_id, long text_style, long text_justification, dword a5, short interface_tag_index, short color_block_index);
extern void __cdecl interface_set_bitmap_text_draw_mode(c_draw_string* draw_string, e_font_id font_id, e_text_style text_style, e_text_justification text_justification, dword a5, short interface_tag_index, short color_block_index);
extern void __cdecl interface_splitscreen_render();

5 changes: 5 additions & 0 deletions game/source/interface/user_interface_text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ enum e_utf32 : dword
_utf32_bonus_round_target_score = 0xE464
};

struct utf32
{
e_utf32 character;
};

enum e_controller_index;
struct c_font_cache_base;
struct c_user_interface_text
Expand Down
22 changes: 11 additions & 11 deletions game/source/main/main_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo3_alpha(e_co
short_rectangle2d bounds{};
interface_get_current_display_or_window_settings(NULL, NULL, NULL, &bounds);

draw_string.set_font(1);
draw_string.set_font(_body_text_font);
draw_string.set_color(0xB0FFFFFF);
draw_string.set_justification(2);
draw_string.set_justification(_text_justification_center);
short line_height = draw_string.get_line_height();

{
Expand All @@ -541,7 +541,7 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo3_alpha(e_co
}
}

draw_string.set_justification(1);
draw_string.set_justification(_text_justification_right);

{
real_rectangle2d rect{};
Expand Down Expand Up @@ -593,9 +593,9 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo3_beta(e_con
short_rectangle2d bounds{};
interface_get_current_display_or_window_settings(NULL, NULL, NULL, &bounds);

draw_string.set_font(1);
draw_string.set_font(_body_text_font);
draw_string.set_color(0xB0FFFFFF);
draw_string.set_justification(2);
draw_string.set_justification(_text_justification_center);
short line_height = draw_string.get_line_height();

{
Expand All @@ -611,7 +611,7 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo3_beta(e_con
}
}

draw_string.set_justification(1);
draw_string.set_justification(_text_justification_right);

{
real_rectangle2d rect{};
Expand Down Expand Up @@ -673,9 +673,9 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo4_pre_releas
short_rectangle2d bounds{};
interface_get_current_display_or_window_settings(NULL, NULL, NULL, &bounds);

draw_string.set_font(1);
draw_string.set_font(_body_text_font);
draw_string.set_color(0xB0FFFFFF);
draw_string.set_justification(1);
draw_string.set_justification(_text_justification_right);
short line_height = draw_string.get_line_height();

{
Expand All @@ -691,7 +691,7 @@ void __cdecl game_engine_render_frame_watermarks_for_controller_halo4_pre_releas
}
}

draw_string.set_justification(0);
draw_string.set_justification(_text_justification_right);

{
real_rectangle2d rect{};
Expand Down Expand Up @@ -732,8 +732,8 @@ void __cdecl game_engine_render_frame_watermarks(bool pregame)
spinner_states[spinner_state_index],
simulation_get_starting_up_description());

draw_string.set_font(6);
draw_string.set_justification(2);
draw_string.set_font(_full_screen_hud_message_font);
draw_string.set_justification(_text_justification_center);
draw_string.set_color(global_real_argb_white);

short_rectangle2d display_title_safe_pixel_bounds{};
Expand Down
2 changes: 1 addition & 1 deletion game/source/main/main_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void rasterizer_render_debug_frame_deltas()
if (rasterizer_globals.frame_deltas[i] > 2)
color = global_real_argb_red;

draw_string.set_justification(1);
draw_string.set_justification(_text_justification_right);
draw_string.set_color(color);
draw_string.set_bounds(&bounds);
draw_string.draw(&font_cache, string);
Expand Down
10 changes: 5 additions & 5 deletions game/source/physics/collision_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ c_status_line g_collision_debug_lightmap_status_line_blue_sh{};
void __cdecl collision_debug_initialize()
{
status_lines_initialize(g_collision_debug_status_lines, &g_collision_debug_status_lines_render, NUMBEROF(g_collision_debug_status_lines));
status_lines_set_flags(g_collision_debug_status_lines, _status_line_unknown_bit2, true, NUMBEROF(g_collision_debug_status_lines));
status_lines_set_flags(g_collision_debug_status_lines, _status_line_left_justify_bit, true, NUMBEROF(g_collision_debug_status_lines));

//status_lines_initialize(&g_collision_debug_lightmap_status_line, &collision_debug_lightmaps, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line, _status_line_unknown_bit2, true, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line, _status_line_left_justify_bit, true, 1);
//status_lines_initialize(&g_collision_debug_lightmap_status_line_red_sh, &collision_debug_lightmaps, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_red_sh, _status_line_unknown_bit2, true, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_red_sh, _status_line_left_justify_bit, true, 1);
//status_lines_initialize(&g_collision_debug_lightmap_status_line_green_sh, &collision_debug_lightmaps, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_green_sh, _status_line_unknown_bit2, true, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_green_sh, _status_line_left_justify_bit, true, 1);
//status_lines_initialize(&g_collision_debug_lightmap_status_line_blue_sh, &collision_debug_lightmaps, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_blue_sh, _status_line_unknown_bit2, true, 1);
//status_lines_set_flags(&g_collision_debug_lightmap_status_line_blue_sh, _status_line_left_justify_bit, true, 1);
}

void __cdecl collision_debug_dispose()
Expand Down
2 changes: 1 addition & 1 deletion game/source/render/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void __cdecl render_fullscreen_text(s_render_fullscreen_text_context const* cont
c_rasterizer_draw_string draw_string;
c_font_cache_mt_safe font_cache;

draw_string.set_font(-2);
draw_string.set_font(_font_id_fallback);
render_fullscreen_text_internal(context, &draw_string, &font_cache);
}
}
Expand Down
8 changes: 4 additions & 4 deletions game/source/render/render_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ void __cdecl render_debug_string_immediate(bool draw_immediately, short const* t
{
c_simple_font_draw_string draw_string;
draw_string.set_tab_stops(tab_stops, tab_stop_count);
interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
draw_string.draw(NULL, string);
}
else
Expand All @@ -1193,7 +1193,7 @@ void __cdecl render_debug_string_immediate(bool draw_immediately, short const* t
c_font_cache_mt_safe font_cache;

draw_string.set_tab_stops(tab_stops, tab_stop_count);
interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
draw_string.draw(&font_cache, string);
}
}
Expand Down Expand Up @@ -1236,7 +1236,7 @@ void __cdecl render_debug_string_at_point_immediate(real_point3d const* point, c
if (g_render_debug_globals->use_simple_font_text_rendering)
{
c_simple_font_draw_string draw_string;
interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
draw_string.set_shadow_color(global_real_argb_black);
draw_string.set_color(color);
draw_string.set_bounds(&bounds);
Expand All @@ -1249,7 +1249,7 @@ void __cdecl render_debug_string_at_point_immediate(real_point3d const* point, c
c_rasterizer_draw_string draw_string;
c_font_cache_mt_safe font_cache;

interface_set_bitmap_text_draw_mode(&draw_string, 0, -1, 0, 0, 5, 0);
interface_set_bitmap_text_draw_mode(&draw_string, _terminal_font, _text_style_plain, _text_justification_left, 0, 5, 0);
draw_string.set_shadow_color(global_real_argb_black);
draw_string.set_color(color);
draw_string.set_bounds(&bounds);
Expand Down
11 changes: 11 additions & 0 deletions game/source/shell/shell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ enum e_text_vertical_justification
k_text_vertical_justification_count
};

enum e_text_style
{
_text_style_plain = -1,
_text_style_bold,
_text_style_italic,
_text_style_condense,
_text_style_underline,

k_text_style_count
};

enum e_font_id
{
_font_id_fallback = -2,
Expand Down
35 changes: 19 additions & 16 deletions game/source/text/draw_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void c_draw_string::set_shadow_color(real_argb_color const* shadow_color)
m_shadow_color = *shadow_color;
}

void c_draw_string::set_style(long style)
void c_draw_string::set_style(e_text_style style)
{
m_style = style;
}
Expand Down Expand Up @@ -80,19 +80,19 @@ void c_draw_string::set_scale(real scale)
m_scale = scale;
}

void c_draw_string::set_font(long font_id)
void c_draw_string::set_font(e_font_id font_id)
{
if (font_id < 0)
font_id = 0;
font_id = _terminal_font;

if (font_id > 10)
font_id = 10;
font_id = _main_menu_font;

m_font_id = font_id;
m_font = font_get_header(font_id);
m_styled_font_header = font_get_header(font_id);
}

void c_draw_string::set_justification(long justification)
void c_draw_string::set_justification(e_text_justification justification)
{
m_justification = justification;
}
Expand All @@ -119,7 +119,7 @@ c_draw_string::c_draw_string() :
__vftable(reinterpret_cast<decltype(__vftable)>(0x0165DB98)),
m_flags(),
m_font_id(),
m_font(),
m_styled_font_header(),
m_style(),
m_justification(),
m_drop_shadow_style(),
Expand All @@ -131,16 +131,18 @@ c_draw_string::c_draw_string() :
m_tab_stop_count(),
m_tab_stops(),
m_bounds(),
m_text_bounds(),
m_clip(),
m_cursor(),
m_permutation_proc(),
m_permutation_proc_data(),
m_initial_indent(),
m_paragraph_indent(),
m_parse_string_state(),
__unknownF8(),
__unknownFA(),
__unknownFC(),
__unknownFE()
m_saved_parse_state(),
m_saved_tab_stop_index(),
m_saved_line_count(),
m_saved_tab_stop_line_count(),
m_saved_maximum_tab_stop_line_count()
{
DECLFUNC(0x00657010, void, __thiscall, c_draw_string*)(this);
}
Expand Down Expand Up @@ -181,9 +183,9 @@ bool c_simple_font_draw_string::s_character_group_render_data::is_full()

void c_simple_font_draw_string::s_character_group_render_data::reset()
{
__unknown0 = 0;
__unknown4 = 0;
__unknown8 = 0;
color = 0;
screen_x = 0;
screen_y = 0;
count = 0;
}

Expand All @@ -193,7 +195,8 @@ c_rasterizer_draw_string::c_rasterizer_draw_string() :
m_rotation(),
m_sine_rotation(),
m_cosine_rotation(),
__unknown114(),
m_use_shader_system(),
pad(),
m_render_data()
{
__vftable = reinterpret_cast<decltype(__vftable)>(0x01692AF0);
Expand Down
Loading

0 comments on commit 8cb85da

Please sign in to comment.