Skip to content

Commit

Permalink
Implemented set_color_values_from_profile
Browse files Browse the repository at this point in the history
`c_start_menu_settings_appearance_colors::set_color_values_from_profile`

TODO: pull profile data from disk
  • Loading branch information
twist84 committed Sep 20, 2024
1 parent 0a16d87 commit 6aad572
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 44 deletions.
2 changes: 2 additions & 0 deletions game/game.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
<ClCompile Include="source\interface\gui_pregame_setup_manager.cpp" />
<ClCompile Include="source\interface\gui_screens\boot_betrayer\gui_screen_boot_betrayer.cpp" />
<ClCompile Include="source\interface\gui_screens\player_select\gui_player_select_screen_widget.cpp" />
<ClCompile Include="source\interface\gui_screens\start_menu\panes\settings_appearance_colors\start_menu_settings_appearance_colors.cpp" />
<ClCompile Include="source\interface\gui_screens\start_menu\panes\settings_appearance_model\start_menu_settings_appearance_model.cpp" />
<ClCompile Include="source\interface\overhead_map.cpp" />
<ClCompile Include="source\interface\user_interface_main_menu_music.cpp" />
Expand Down Expand Up @@ -856,6 +857,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
<ClInclude Include="source\interface\gui_screens\motd_popup\gui_screen_motd_popup.hpp" />
<ClInclude Include="source\interface\gui_screens\player_select\gui_player_select_screen_widget.hpp" />
<ClInclude Include="source\interface\gui_screens\start_menu\panes\hq\start_menu_headquarters.hpp" />
<ClInclude Include="source\interface\gui_screens\start_menu\panes\settings_appearance_colors\start_menu_settings_appearance_colors.hpp" />
<ClInclude Include="source\interface\gui_screens\start_menu\panes\settings_appearance_model\start_menu_settings_appearance_model.hpp" />
<ClInclude Include="source\interface\gui_screens\start_menu\start_menu_pane_screen_widget.hpp" />
<ClInclude Include="source\interface\overhead_map.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions game/game.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,9 @@
<ClCompile Include="source\objects\target_tracking.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\interface\gui_screens\start_menu\panes\settings_appearance_colors\start_menu_settings_appearance_colors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\camera\camera.hpp">
Expand Down Expand Up @@ -3800,6 +3803,9 @@
<ClInclude Include="source\motor\motor_system.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\interface\gui_screens\start_menu\panes\settings_appearance_colors\start_menu_settings_appearance_colors.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource\resource.rc">
Expand Down
1 change: 1 addition & 0 deletions game/source/cache/cache_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ void apply_globals_instance_modification(cache_file_tag_instance* instance, e_in
break;
case _instance_modification_stage_after_scenario_tags_loaded:
{
UPDATE_STATIC_RUNTIME_DATA(game_globals);
}
break;
}
Expand Down
42 changes: 42 additions & 0 deletions game/source/game/game_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@
#include "memory/thread_local.hpp"
#include "scenario/scenario.hpp"

rgb_color const k_player_colors[]
{
{ .value = 0x6E6E6E }, // Steel
{ .value = 0xB9B9B9 }, // Silver
{ .value = 0xE3E3E3 }, // White
{ .value = 0xA73B3B }, // Red
{ .value = 0xE07373 }, // Mauve
{ .value = 0xF28D8D }, // Salmon
{ .value = 0xDF9600 }, // Orange
{ .value = 0xFBB862 }, // Coral
{ .value = 0xFFD2A7 }, // Peach
{ .value = 0xD4B632 }, // Gold
{ .value = 0xF0CD35 }, // Yellow
{ .value = 0xFFDF84 }, // Pale
{ .value = 0x63801C }, // Sage
{ .value = 0x9BB06C }, // Green
{ .value = 0xDAF1A9 }, // Olive
{ .value = 0x388489 }, // Teal
{ .value = 0x55C4C9 }, // Aqua
{ .value = 0x9CEFEF }, // Cyan
{ .value = 0x3B659E }, // Blue
{ .value = 0x6094DF }, // Cobalt
{ .value = 0xA3BFF6 }, // Sapphire
{ .value = 0x60479B }, // Violet
{ .value = 0x9C81E9 }, // Orchid
{ .value = 0xD0C4FF }, // Lavender
{ .value = 0x900051 }, // Crimson
{ .value = 0xD8458F }, // Rubine
{ .value = 0xFF96C3 }, // Pink
{ .value = 0x5D4016 }, // Brown
{ .value = 0xB69679 }, // Tan
{ .value = 0xE4C6AC }, // Khaki
};

c_typed_tag_block<rgb_color> s_game_globals::profile_colors{};

long get_map_minor_version()
{
if (global_scenario)
Expand All @@ -12,6 +48,12 @@ long get_map_minor_version()
return 0xFFFFFFFF;
}

void s_game_globals::update_static_runtime_data()
{
profile_colors.count = NUMBEROF(k_player_colors);
profile_colors.address = (void*)&k_player_colors;
}

void s_game_globals::update_reference_names()
{
UPDATE_REFERENCE_NAME(ai_globals_ref);
Expand Down
3 changes: 3 additions & 0 deletions game/source/game/game_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ struct s_game_globals
c_typed_tag_block<s_game_globals_shield_boost> shield_boost;
c_typed_tag_block<s_global_material_definition, 'sort'> materials;

static c_typed_tag_block<rgb_color> profile_colors;

c_typed_tag_reference<MULTIPLAYER_GLOBALS_TAG> multiplayer_globals;
c_typed_tag_reference<SURVIVAL_MODE_GLOBALS_TAG> survival_mode_globals;
c_typed_tag_block<cinematics_globals_block> cinematics_globals;
Expand Down Expand Up @@ -215,6 +217,7 @@ struct s_game_globals
};
static_assert(sizeof(damage_reporting_type_block) == 0x24);

void update_static_runtime_data();
void update_reference_names();
};
static_assert(sizeof(s_game_globals) == 0x608);
Expand Down
12 changes: 12 additions & 0 deletions game/source/hf2p/hf2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "game/game_engine_util.hpp"
#include "game/multiplayer_definitions.hpp"
#include "game/players.hpp"
#include "interface/c_controller.hpp"
#include "main/console.hpp"
#include "math/color_math.hpp"
#include "memory/module.hpp"
Expand Down Expand Up @@ -194,6 +195,17 @@ void __cdecl hf2p_game_update()

DECLFUNC(0x005A4430, void, __cdecl, s_s3d_player_armor_configuration_loadout*, dword)(&loadout, mainmenu_unit_index);

// #TODO: when we have full control over player profile and player customization maybe update and use this
//c_player_profile_interface* player_profile = controller_get(_controller_index0)->get_player_profile_interface();
//e_player_color_index primary_change_color = player_profile->get_primary_change_color();
//e_player_color_index secondary_change_color = player_profile->get_secondary_change_color();
//
//if (VALID_INDEX(primary_change_color, k_number_of_player_colors))
// loadout.colors[_color_type_primary] = s_game_globals::profile_colors[primary_change_color];
//
//if (VALID_INDEX(secondary_change_color, k_number_of_player_colors))
// loadout.colors[_color_type_secondary] = s_game_globals::profile_colors[secondary_change_color];

for (long color_index = 0; color_index < k_color_type_count; color_index++)
{
rgb_color& color = loadout.colors[color_index];
Expand Down
5 changes: 5 additions & 0 deletions game/source/interface/c_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ bool __cdecl controller_has_centered_crosshair(e_controller_index controller_ind
return controller_centered_crosshair;
}

c_player_profile_interface* c_controller_interface::get_player_profile_interface()
{
return &m_player_profile;
}

bool c_controller_interface::is_attached() const
{
return m_state_flags.test(_controller_state_flag_attached);
Expand Down
1 change: 1 addition & 0 deletions game/source/interface/c_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct c_controller_interface
k_controller_state_flags
};

c_player_profile_interface* get_player_profile_interface();
bool is_attached() const;
bool in_use() const;
bool is_signed_in_to_machine() const;
Expand Down
5 changes: 5 additions & 0 deletions game/source/interface/c_gui_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ c_gui_text_widget* c_gui_widget::get_child_text_widget(string_id name)
return (c_gui_text_widget*)get_child_widget(_gui_widget_type_text, name);
}

e_controller_index c_gui_widget::get_any_responding_controller() const
{
return DECLFUNC(0x00AB8900, e_controller_index, __thiscall, c_gui_widget const*)(this);
}

c_gui_widget* c_gui_widget::get_child_widget(e_gui_widget_type widget_type, string_id name)
{
return DECLFUNC(0x00AB8B00, c_gui_widget*, __thiscall, c_gui_widget*, e_gui_widget_type, string_id)(this, widget_type, name);
Expand Down
1 change: 1 addition & 0 deletions game/source/interface/c_gui_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ struct c_gui_widget
c_gui_text_widget* get_child_text_widget(string_id name);
c_gui_widget* get_first_child_widget_by_type(e_gui_widget_type widget_type);

e_controller_index get_any_responding_controller() const;
void __thiscall get_unprojected_bounds(gui_real_rectangle2d* unprojected_bounds, bool a3, bool a4, bool a5);

//protected:
Expand Down
Loading

0 comments on commit 6aad572

Please sign in to comment.