Skip to content

Commit 1e8b9f4

Browse files
committed
Overlay: fix display while in-game, add game_mode to globals
1 parent 152b9db commit 1e8b9f4

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

src/game_addrs.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Game
1717
{
1818
inline D3DXVECTOR2 original_resolution{ 640, 480 };
1919

20+
inline int* game_mode = nullptr;
2021
inline GameState* current_mode = nullptr;
2122
inline int* game_start_progress_code = nullptr;
2223
inline int* file_load_progress_code = nullptr;
@@ -198,6 +199,7 @@ namespace Game
198199

199200
inline void init()
200201
{
202+
game_mode = Module::exe_ptr<int>(0x380258);
201203
current_mode = Module::exe_ptr<GameState>(0x38026C);
202204
game_start_progress_code = Module::exe_ptr<int>(0x4367A8);
203205
file_load_progress_code = Module::exe_ptr<int>(0x436718);

src/overlay/hooks_overlay.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -104,41 +104,42 @@ class D3DHooks : public Hook
104104
{
105105
IDirect3DDevice9* d3ddev = Game::D3DDevice();
106106

107-
if (Settings::UILetterboxing == 1 && Game::is_in_game())
108-
return; // disable letterboxing while in-game
109-
110-
// Backup existing cullmode and set to none, otherwise we won't get drawn
111-
DWORD prevCullMode = D3DCULL_NONE;
112-
d3ddev->GetRenderState(D3DRS_CULLMODE, &prevCullMode);
113-
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
114-
115-
// Seems these SetRenderState/SetTexture calls are needed for DGVoodoo to render letterbox while imgui is active
116-
// DXVK/D3D9 seem to work fine without them
117-
// TODO: the game keeps its own copies of the render states so it can update them if needed, should we update the games copy here?
107+
// Only show letterboxing if not in game, or UILetterboxing is 2
108+
if (!Game::is_in_game() || Settings::UILetterboxing == 2)
118109
{
119-
// Set render states
120-
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
121-
d3ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
122-
d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);
123-
124-
// Set texture stage states to avoid any texture influence
125-
d3ddev->SetTexture(0, NULL);
126-
d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
127-
d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
128-
}
110+
// Backup existing cullmode and set to none, otherwise we won't get drawn
111+
DWORD prevCullMode = D3DCULL_NONE;
112+
d3ddev->GetRenderState(D3DRS_CULLMODE, &prevCullMode);
113+
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
114+
115+
// Seems these SetRenderState/SetTexture calls are needed for DGVoodoo to render letterbox while imgui is active
116+
// DXVK/D3D9 seem to work fine without them
117+
// TODO: the game keeps its own copies of the render states so it can update them if needed, should we update the games copy here?
118+
{
119+
// Set render states
120+
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
121+
d3ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
122+
d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);
123+
124+
// Set texture stage states to avoid any texture influence
125+
d3ddev->SetTexture(0, NULL);
126+
d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
127+
d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
128+
}
129129

130-
// Set FVF and stream source
131-
d3ddev->SetFVF(CUSTOMFVF);
132-
d3ddev->SetStreamSource(0, LetterboxVertex, 0, sizeof(CUSTOMVERTEX));
130+
// Set FVF and stream source
131+
d3ddev->SetFVF(CUSTOMFVF);
132+
d3ddev->SetStreamSource(0, LetterboxVertex, 0, sizeof(CUSTOMVERTEX));
133133

134-
// Draw left border
135-
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
134+
// Draw left border
135+
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
136136

137-
// Draw right border
138-
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
137+
// Draw right border
138+
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
139139

140-
// Restore original cullmode
141-
d3ddev->SetRenderState(D3DRS_CULLMODE, prevCullMode);
140+
// Restore original cullmode
141+
d3ddev->SetRenderState(D3DRS_CULLMODE, prevCullMode);
142+
}
142143
}
143144

144145
if (overlayInited)

src/overlay/overlay.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ void Overlay_GlobalsWindow()
5858
ImGui::Separator();
5959
ImGui::Text("Info");
6060
EVWORK_CAR* car = Game::pl_car();
61-
ImGui::Text("Game state id: %d", *Game::current_mode);
61+
ImGui::Text("game_mode: %d", *Game::game_mode);
62+
ImGui::Text("current_mode: %d", *Game::current_mode);
6263
ImGui::Text("Car kind: %d", int(car->car_kind_11));
6364
ImGui::Text("Car position: %.3f %.3f %.3f", car->position_14.x, car->position_14.y, car->position_14.z);
6465
ImGui::Text("OnRoadPlace coli %d, stg %d, section %d",

0 commit comments

Comments
 (0)