Skip to content

Commit

Permalink
Merge pull request #761 from Berthalamew/development
Browse files Browse the repository at this point in the history
imgui + ingame ui changes
  • Loading branch information
Berthalamew authored Dec 9, 2024
2 parents d48cafa + 728357b commit 2200e4f
Show file tree
Hide file tree
Showing 28 changed files with 153 additions and 534 deletions.
1 change: 0 additions & 1 deletion xlive/Blam/Engine/game/game_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ static void game_globals_prepare_lmao_representation(s_game_globals_custom_repre
s_model_definition* mode_chief_mp = (s_model_definition*)tag_get_fast(mode_chief_mp_datum);
s_model_variant* base_variant = mode_chief_mp->variants[0];
s_model_variant* new_variant = (s_model_variant*)tag_injection_extend_block(&mode_chief_mp->variants, mode_chief_mp->variants.type_size(), 1);
//MetaExtender::add_tag_block2<s_model_variant>((unsigned long)std::addressof(mode_chief_mp->variants));
new_variant->name = 0xABABABA;
new_variant->dialogue.group = base_variant->dialogue.group;
new_variant->dialogue.index = base_variant->dialogue.index;
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/geometry/geometry_definitions_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ struct geometry_point_data
{
tag_block<geometry_point> raw_points;
data_reference runtime_point_data; // Data size: 1048544
tag_block<geometry_rigid_point_group> rigidPointGroups;
tag_block<geometry_rigid_point_group> rigid_point_groups;
tag_block<uint16> vertex_point_indices;
};
ASSERT_STRUCT_SIZE(geometry_point_data, 32);
Expand Down
2 changes: 0 additions & 2 deletions xlive/Blam/Engine/input/input_abstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

#include "input_abstraction.h"

#include "game/game_time.h"
#include "game/players.h"
#include "saved_games/cartographer_player_profile.h"

#include "H2MOD/GUI/imgui_integration/imgui_handler.h"
#include "H2MOD/Modules/Shell/Config.h"

/* globals */

Expand Down
36 changes: 26 additions & 10 deletions xlive/Blam/Engine/interface/screens/screen_main_menu.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "stdafx.h"
#include "stdafx.h"
#include "screen_main_menu.h"

#include "screen_4way_signin.h"
#include "screen_settings.h"
#include "screen_campaign_options_dialog.h"

#include "game/preferences.h"
#include "interface/user_interface_memory.h"

#include "interface/user_interface_controller.h"
#include "interface/user_interface_globals.h"
#include "interface/user_interface_memory.h"
Expand All @@ -17,11 +19,6 @@
#include "tag_files/global_string_ids.h"
#include "shell/shell.h"


/* macro defines */

#define k_main_menu_list_name "main menu list"

/* enums */

enum e_main_menu_list_items : uint16
Expand Down Expand Up @@ -52,7 +49,23 @@ enum e_main_menu_list_skin_texts
k_number_of_main_menu_list_skin_texts
};

/* forward declarations*/
/* constants */

const char* k_main_menu_list_name = "main menu list";
const wchar_t* k_online_button_text[k_language_count] =
{
L"ONLINE",
L"オンライン",
L"ONLINE",
L"EN LÍNEA"
L"EN LIGNE",
L"IN LINEA",
L"온라인",
L"在线的",
L"ONLINE"
};

/* prototypes */

bool __cdecl screen_show_campaign_options_without_achievement(e_controller_index controller_index);
bool __cdecl screen_show_screen_4way_signin_splitscreen_offline(e_controller_index controller_index);
Expand Down Expand Up @@ -132,6 +145,7 @@ void c_main_menu_list::update_list_items(c_list_item_widget* item, int32 skin_in
c_text_widget* item_text = item->try_find_text_widget(_main_menu_list_skin_text_main);
item->set_item_transitioning();

const e_language language = get_current_language();
if (item_text)
{
switch (DATUM_INDEX_TO_ABSOLUTE_INDEX(item->get_last_data_index()))
Expand All @@ -140,7 +154,9 @@ void c_main_menu_list::update_list_items(c_list_item_widget* item, int32 skin_in
item_text->set_text_from_string_id(_string_id_campaign);
break;
case _item_xbox_live:
item_text->set_text_from_string_id(_string_id_xbox_live);
// TODO: if we ever do a map recompile grab the text from the stringid again
//item_text->set_text_from_string_id(_string_id_xbox_live);
item_text->set_text(k_online_button_text[language]);
break;
case _item_splitscreen:
item_text->set_text_from_string_id(_string_id_splitscreen);
Expand All @@ -158,9 +174,9 @@ void c_main_menu_list::update_list_items(c_list_item_widget* item, int32 skin_in
item_text->set_text_from_string_id(_string_id_invalid);
}


item_text->set_visible(true);
}
return;
}

void c_main_menu_list::handle_item_pressed_event(s_event_record** pevent, datum* pitem_index)
Expand Down
3 changes: 2 additions & 1 deletion xlive/Blam/Engine/main/game_preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void __cdecl global_preferences_initialize(void)
return;
}

void __cdecl game_preferences_flag_dirty()
void __cdecl game_preferences_flag_dirty(void)
{
INVOKE(0x323D2, 0x25994, game_preferences_flag_dirty);
return;
}
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/main/game_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ e_language get_current_language(void);

void __cdecl global_preferences_initialize(void);

void __cdecl game_preferences_flag_dirty();
void __cdecl game_preferences_flag_dirty(void);
4 changes: 2 additions & 2 deletions xlive/Blam/Engine/main/interpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ s_interpolation_data* g_target_interpolation_frame_data = NULL;
real32 g_interpolator_delta = 0.0f;
bool g_update_in_progress = false;
bool interpolation_enabled = false;
c_static_flags<k_maximum_objects_per_map> g_interpolator_object_updated;
c_static_flags<k_maximum_objects_per_map> g_interpolator_object_interpolation_updated;
c_static_flags_no_init<k_maximum_objects_per_map> g_interpolator_object_updated;
c_static_flags_no_init<k_maximum_objects_per_map> g_interpolator_object_interpolation_updated;

void halo_interpolator_initialize()
{
Expand Down
6 changes: 5 additions & 1 deletion xlive/Blam/Engine/memory/static_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ class c_static_flags_no_init
}

protected:
uint32 m_flags[k_maximum_bit_count / LONG_BITS];
/*
We do : "+ (k_maximum_bit_count % LONG_BITS > 0)" so we can make sure we have enough space
when m_flags is not perfectly divisible by LONG_BITS. It adds an extra element if the condition is true
*/
uint32 m_flags[k_maximum_bit_count / LONG_BITS + (k_maximum_bit_count % LONG_BITS > 0)];
};

template<size_t k_maximum_bit_count>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ void __cdecl rasterizer_dx9_render_crossfade(real32 lower, real32 upper);

void rasterizer_dx9_screen_effect_apply_patches(void)
{
PatchCall(Memory::GetAddress(0x191BB1), rasterizer_dx9_postprocess_scene);

// fix bloom in splitscreen
// to note that for some reason bloom is disabled by design (both in H2v and H2x) in splitscreen mode
// possibly because of the additional rendering/processing overhead
Expand Down
9 changes: 0 additions & 9 deletions xlive/H2MOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "render/render_lod_new.h"
#include "render/render_weather.h"
#include "saved_games/game_state_procs.h"
#include "shell/shell.h"
#include "shell/shell_windows.h"
#include "simulation/simulation.h"
#include "simulation/simulation_players.h"
Expand All @@ -76,7 +75,6 @@
#include "H2MOD/GUI/ImGui_Integration/Console/CommandCollection.h"
#include "H2MOD/GUI/ImGui_Integration/ImGui_Handler.h"
#include "H2MOD/Modules/Accounts/AccountLogin.h"
#include "H2MOD/Modules/CustomMenu/CustomLanguage.h"
#include "H2MOD/Modules/CustomVariantSettings/CustomVariantSettings.h"
#include "H2MOD/Modules/DirectorHooks/DirectorHooks.h"
#include "H2MOD/Modules/EventHandler/EventHandler.hpp"
Expand All @@ -88,9 +86,6 @@
#include "H2MOD/Modules/MainMenu/Ranks.h"
#include "H2MOD/Modules/MapManager/MapManager.h"
#include "H2MOD/Modules/MainLoopPatches/RunLoop/RunLoop.h"
#ifndef NDEBUG
#include "H2MOD/Modules/ObserverMode/ObserverMode.h"
#endif
#include "camera/editor_camera.h"
#include "camera/first_person_camera.h"
#include "camera/following_camera.h"
Expand Down Expand Up @@ -1153,7 +1148,6 @@ void H2MOD::Initialize()
// Apply patches
game_apply_pre_winmain_patches();

custom_language_initialize();
main_loop_apply_patches();

if (!Memory::IsDedicatedServer())
Expand All @@ -1169,9 +1163,6 @@ void H2MOD::Initialize()
RenderHooks::Initialize();
DirectorHooks::Initialize();
ImGuiHandler::WeaponOffsets::Initialize();
#ifndef NDEBUG
ObserverMode::Initialize();
#endif
TEST_N_DEF(PC3);
}
else
Expand Down
36 changes: 14 additions & 22 deletions xlive/H2MOD/GUI/XLiveRendering.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "stdafx.h"

#include "XLiveRendering.h"

#include "imgui.h"

#include "backends/imgui_impl_dx9.h"
#include "rasterizer/dx9/rasterizer_dx9_main.h"

#include "H2MOD/GUI/ImGui_Integration/ImGui_Handler.h"
#include "H2MOD/Modules/Accounts/AccountLogin.h"
Expand All @@ -17,7 +19,6 @@ bool displayXyz = false;
bool doDrawIMGUI = false;

HWND H2hWnd;
LPDIRECT3DDEVICE9 g_pD3DDevice9;
D3DPRESENT_PARAMETERS g_d3dPresentParameters;

IDirect3DTexture9* Primitive = NULL;
Expand All @@ -30,19 +31,16 @@ const char CompileTime[] = __TIME__;
int verticalRes = 0;
int horizontalRes = 0;

void XLiveRendering::InitializeD3D9(LPDIRECT3DDEVICE9 pD3D9Device, D3DPRESENT_PARAMETERS* presentParameters)
void XLiveRendering::InitializeD3D9(D3DPRESENT_PARAMETERS* presentParameters)
{
g_pD3DDevice9 = pD3D9Device;
// increase the Ref count
g_pD3DDevice9->AddRef();
memcpy(&g_d3dPresentParameters, presentParameters, sizeof(D3DPRESENT_PARAMETERS));

ImGuiHandler::Initalize(g_pD3DDevice9, presentParameters->hDeviceWindow);
ImGuiHandler::Initalize(presentParameters->hDeviceWindow);
}

void XLiveRendering::D3D9ReleaseResources()
{
ImGuiHandler::ReleaseTextures();
ImGuiHandler::release_motd_texture();
ImGui_ImplDX9_InvalidateDeviceObjects();
}

Expand All @@ -54,7 +52,7 @@ int WINAPI XLiveInitializeEx(XLIVE_INITIALIZE_INFO* pXii, DWORD dwVersion)
initialize_instance();

if (pXii->pD3D) {
XLiveRendering::InitializeD3D9((LPDIRECT3DDEVICE9)pXii->pD3D, (D3DPRESENT_PARAMETERS*)pXii->pD3DPP);
XLiveRendering::InitializeD3D9((D3DPRESENT_PARAMETERS*)pXii->pD3DPP);

snprintf(g_cartographer_build_text, NUMBEROF(g_cartographer_build_text), "Project Cartographer (v%s) - Build Time: %s %s", DLL_VERSION_STR, CompileDate, CompileTime);
}
Expand All @@ -78,20 +76,12 @@ int WINAPI XLiveUninitialize()

XLiveRendering::D3D9ReleaseResources();

if (g_pD3DDevice9)
{
g_pD3DDevice9->Release();
g_pD3DDevice9 = NULL;
}

return 0;
}

// #5005: XLiveOnCreateDevice
int WINAPI XLiveOnCreateDevice(IUnknown* pD3D, VOID* vD3DPP)
{
g_pD3DDevice9 = (LPDIRECT3DDEVICE9)pD3D;

{
//pPresent = (HRESULT(WINAPI*)(LPDIRECT3DDEVICE9 pDevice, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion)) *(DWORD_PTR*)(pDevice+17);
//VirtualProtect((LPVOID)(pDevice + 17), sizeof(DWORD_PTR), PAGE_EXECUTE_READWRITE, &dwPresent);
//*(DWORD_PTR*)(pDevice + 17) = (DWORD_PTR)hkPresent;
Expand All @@ -108,7 +98,7 @@ int WINAPI XLiveOnResetDevice(D3DPRESENT_PARAMETERS* pD3DPP)
//Have to invalidate ImGUI on device reset, otherwise it hangs the device in a reset loop.
//https://github.com/ocornut/imgui/issues/1464#issuecomment-347469716

ImGuiHandler::ReleaseTextures();
ImGuiHandler::release_motd_texture();
ImGui_ImplDX9_InvalidateDeviceObjects();
//LOG_TRACE_XLIVE("XLiveOnResetDevice");
return 0;
Expand All @@ -117,7 +107,7 @@ int WINAPI XLiveOnResetDevice(D3DPRESENT_PARAMETERS* pD3DPP)
// #5006 XLiveOnDestroyDevice
HRESULT WINAPI XLiveOnDestroyDevice()
{
ImGuiHandler::ReleaseTextures();
ImGuiHandler::release_motd_texture();
ImGui_ImplDX9_InvalidateDeviceObjects();
XLiveRendering::D3D9ReleaseResources();

Expand Down Expand Up @@ -169,11 +159,13 @@ HRESULT WINAPI XLiveRender()
static std::mutex renderMtx;
std::lock_guard lg(renderMtx);

if (!g_pD3DDevice9) {
IDirect3DDevice9Ex* device = rasterizer_dx9_device_get_interface();

if (!device) {
return E_UNEXPECTED;
}

if (FAILED(g_pD3DDevice9->TestCooperativeLevel())) {
if (FAILED(device->TestCooperativeLevel())) {
return E_UNEXPECTED;
}

Expand Down
3 changes: 1 addition & 2 deletions xlive/H2MOD/GUI/XLiveRendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ static CONST D3DCOLOR COLOR_BLACK_TRANSPARENT = D3DCOLOR_ARGB(150, 0, 0, 0);

namespace XLiveRendering
{
void InitializeD3D9(LPDIRECT3DDEVICE9 pD3D9Device, D3DPRESENT_PARAMETERS* presentParameters);
void InitializeD3D9(D3DPRESENT_PARAMETERS* presentParameters);
void D3D9ReleaseResources();
};

extern HWND H2hWnd;
extern LPDIRECT3DDEVICE9 g_pD3DDevice9;

extern char g_cartographer_build_text[256];

Expand Down
Loading

0 comments on commit 2200e4f

Please sign in to comment.