Skip to content

Commit d6af2a0

Browse files
committed
tweak: priority and art tweaks for pre-ui + enb fix
1 parent 8555df4 commit d6af2a0

11 files changed

Lines changed: 90 additions & 15 deletions

File tree

code/components/glue/src/GtaNui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,12 @@ static InitFunction initFunction([]()
586586
InputHook::QueryInputTarget.Connect([](std::vector<InputTarget*>& targets)
587587
{
588588
return nuiGi.QueryInputTarget(targets);
589-
});
589+
}, 20);
590590

591591
InputHook::DeprecatedOnWndProc.Connect([](HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, bool& pass, LRESULT& lresult)
592592
{
593593
nuiGi.OnWndProc(hWnd, msg, wParam, lParam, pass, lresult);
594-
});
594+
}, 20);
595595

596596
InputHook::QueryMayLockCursor.Connect([](int& a)
597597
{

code/components/legacy-game-re3/src/Init.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "Clock.h"
2727
#include "Streaming.h"
2828

29+
DLL_IMPORT ID3D11Device* GetRawD3D11Device();
30+
2931
struct Re3InitStruct
3032
{
3133
void* context;
@@ -74,6 +76,7 @@ static InitFunction initFunction([]()
7476
inited = false;
7577
bWantsGameplay = false;
7678
initedGameplay = false;
79+
nui::SetHideCursor(false);
7780
}
7881
else
7982
{
@@ -133,6 +136,7 @@ static InitFunction initFunction([]()
133136
if (initedGameplay)
134137
{
135138
nui::PostFrameMessage("mpMenu", R"({ "type": "exitGameplay" })");
139+
nui::SetHideCursor(false);
136140
}
137141

138142
inited = true;
@@ -180,6 +184,7 @@ static InitFunction initFunction([]()
180184
{
181185
if (wcscmp(type, L"enterGameplay") == 0)
182186
{
187+
nui::SetHideCursor(true);
183188
bWantsGameplay = true;
184189
}
185190
});
@@ -224,7 +229,7 @@ static InitFunction initFunction([]()
224229

225230
D3D11_TEXTURE2D_DESC tgtDesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_D24_UNORM_S8_UINT, w, h, 1, 1, D3D11_BIND_DEPTH_STENCIL);
226231

227-
auto d3d = GetD3D11Device();
232+
auto d3d = GetRawD3D11Device();
228233
d3d->CreateTexture2D(&tgtDesc, nullptr, &depthTexture);
229234

230235
D3D11_DEPTH_STENCIL_VIEW_DESC dsDesc = CD3D11_DEPTH_STENCIL_VIEW_DESC(depthTexture, D3D11_DSV_DIMENSION_TEXTURE2D);
@@ -239,7 +244,7 @@ static InitFunction initFunction([]()
239244
Re3InitStruct data;
240245
data.backBuffer = bb;
241246
data.backBufferDS = ds;
242-
data.context = GetD3D11Device();
247+
data.context = GetRawD3D11Device();
243248
data.inited = &inited;
244249

245250
SetThreadName(-1, "zRE3");

code/components/nui-core/include/CefOverlay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ namespace nui
300300
void OVERLAY_DECL KeepInput(bool keepInput);
301301
bool OVERLAY_DECL HasMainUI();
302302
void OVERLAY_DECL SetMainUI(bool enable);
303+
void OVERLAY_DECL SetHideCursor(bool hide);
303304

304305
void ProcessInput();
305306

code/components/nui-core/src/CefOverlay.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "memdbgon.h"
1919

2020
bool g_mainUIFlag = true;
21+
bool g_shouldHideCursor;
2122

2223
fwEvent<const wchar_t*, const wchar_t*> nui::OnInvokeNative;
2324
fwEvent<bool> nui::OnDrawBackground;
@@ -100,6 +101,11 @@ namespace nui
100101
nui::GiveFocus(enable);
101102
}
102103

104+
DLL_EXPORT void SetHideCursor(bool hide)
105+
{
106+
g_shouldHideCursor = hide;
107+
}
108+
103109
static std::unordered_map<std::string, fwRefContainer<NUIWindow>> windowList;
104110
static std::shared_mutex windowListMutex;
105111

code/components/nui-core/src/NUIInitialize.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,14 @@ static HRESULT CopyResourceHook(ID3D11DeviceContext* cxt, ID3D11Resource* dst, I
374374

375375
#pragma comment(lib, "dxgi.lib")
376376

377+
static ID3D11DeviceContext* g_origImContext;
378+
static ID3D11Device* g_origDevice;
379+
380+
DLL_EXPORT ID3D11Device* GetRawD3D11Device()
381+
{
382+
return g_origDevice;
383+
}
384+
377385
static HRESULT D3D11CreateDeviceHook(_In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, _COM_Outptr_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext)
378386
{
379387
if (!pAdapter)
@@ -422,14 +430,52 @@ static HRESULT D3D11CreateDeviceHook(_In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER
422430
}
423431
#endif
424432

433+
if (ppImmediateContext && *ppImmediateContext)
434+
{
435+
g_origImContext = *ppImmediateContext;
436+
g_origImContext->AddRef();
437+
}
438+
else if (ppDevice && *ppDevice)
439+
{
440+
(*ppDevice)->GetImmediateContext(&g_origImContext);
441+
}
442+
443+
if (ppDevice)
444+
{
445+
g_origDevice = *ppDevice;
446+
}
447+
448+
return hr;
449+
}
450+
451+
static HRESULT (*g_origD3D11CreateDeviceMain)(_In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, _COM_Outptr_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext);
452+
453+
static HRESULT D3D11CreateDeviceHookMain(_In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, _COM_Outptr_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext)
454+
{
455+
auto hr = g_origD3D11CreateDeviceMain(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext);
456+
457+
// hook e.g. GetImmediateContext here if needed
458+
425459
return hr;
426460
}
427461

428462
void HookLibGL(HMODULE libGL)
429463
{
464+
wchar_t systemDir[MAX_PATH];
465+
GetSystemDirectoryW(systemDir, std::size(systemDir));
466+
467+
auto sysDll = LoadLibraryW(va(L"%s\\d3d11.dll", systemDir));
468+
auto mainDll = LoadLibraryW(L"d3d11.dll");
469+
430470
MH_Initialize();
431471
MH_CreateHook(GetProcAddress(libGL, "glTexParameterf"), glTexParameterfHook, (void**)&g_origglTexParameterf);
432-
MH_CreateHook(GetProcAddress(LoadLibraryW(L"d3d11.dll"), "D3D11CreateDevice"), D3D11CreateDeviceHook, (void**)&g_origD3D11CreateDevice);
472+
MH_CreateHook(GetProcAddress(sysDll, "D3D11CreateDevice"), D3D11CreateDeviceHook, (void**)&g_origD3D11CreateDevice);
473+
474+
// hook any wrapper dll too
475+
if (mainDll != sysDll)
476+
{
477+
MH_CreateHook(GetProcAddress(mainDll, "D3D11CreateDevice"), D3D11CreateDeviceHookMain, (void**)&g_origD3D11CreateDeviceMain);
478+
}
433479

434480
MH_EnableHook(MH_ALL_HOOKS);
435481
}

code/components/nui-core/src/NUIRenderCallbacks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern nui::GameInterface* g_nuiGi;
77
#include "memdbgon.h"
88

99
extern bool g_hasCursor;
10+
extern bool g_shouldHideCursor;
1011
extern POINT g_cursorPos;
1112

1213
extern bool g_isDragging;
@@ -86,7 +87,7 @@ static HookFunction initFunction([] ()
8687
}
8788
});
8889

89-
if (nui::HasMainUI() || g_hasCursor)
90+
if ((nui::HasMainUI() || g_hasCursor) && !g_shouldHideCursor)
9091
{
9192
POINT cursorPos = g_cursorPos;
9293

ext/cfx-ui/src/app/app-nav.component.scss

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ $itemHeight: $appNavHeight*.5;
3939
color: gtv($theme, textColour);
4040
};
4141

42+
text-shadow: 0 0 0.8vh rgba(0, 0, 0, .5);
43+
4244
svg {
4345
width: $itemHeight;
4446
height: $itemHeight;
@@ -49,16 +51,20 @@ $itemHeight: $appNavHeight*.5;
4951

5052
vertical-align: middle;
5153

54+
filter: drop-shadow(0 0 0.45vh rgba(0, 0, 0, .5));
55+
5256
:host-context(.game-rdr3) & {
5357
fill: #d80d0d;
5458
height: $itemHeight * 1.8;
5559
width: $itemHeight * 1.8;
5660
}
5761

5862
:host-context(.game-gta5) & {
59-
height: $itemHeight * 1.3;
60-
width: $itemHeight * 1.3;
61-
padding-right: 0.5vh;
63+
height: $itemHeight * 1.2;
64+
width: $itemHeight * 1.2;
65+
margin-right: 0.5vh;
66+
67+
transform: scale(-1, 1);
6268
}
6369
}
6470

@@ -86,7 +92,10 @@ $itemHeight: $appNavHeight*.5;
8692
padding: 1vh;
8793
position: relative;
8894

95+
filter: drop-shadow(0 0 0.8vh rgba(0, 0, 0, .5));
96+
8997
.new {
98+
filter: none;
9099
font-size: 1vh;
91100
position: absolute;
92101
bottom: 0.25vh;
@@ -200,6 +209,8 @@ $itemHeight: $appNavHeight*.5;
200209

201210
transition: all .2s ease;
202211

212+
text-shadow: 0 0 0.75vh rgba(0, 0, 0, .5);
213+
203214
span {
204215
display: block;
205216
}

ext/cfx-ui/src/app/app-nav.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class AppNavComponent {
6868

6969
goThere() {
7070
(<any>window).invokeNative('enterGameplay', '');
71-
document.body.style.display = 'none';
71+
document.body.style.visibility = 'hidden';
7272
}
7373

7474
exitGame() {

ext/cfx-ui/src/app/game.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export class CfxGameService extends GameService {
333333
window.addEventListener('message', (event) => {
334334
switch (event.data.type) {
335335
case 'exitGameplay':
336-
document.body.style.display = 'block';
336+
document.body.style.visibility = 'visible';
337337
break;
338338
case 'connectFailed':
339339
this.zone.run(() => this.invokeConnectFailed(this.lastServer, event.data.message));

ext/cfx-ui/src/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
<body>
1212

1313
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="Height: 0px; width: 0px;">
14-
<symbol id="logo-gta5" viewBox="0 0 342 390.5">
15-
<g transform="matrix(1,0,0,-1,-124.2,606.4)">
16-
<path d="m 125.8,215.9 85.1,0 c 1.9,0 7.4,18.3 16.7,54.9 32.3,112.4 50.9,178.1 55.7,197.2 l -54.9,54.1 -1.6,0 C 219.4,499 185.2,397.2 124.2,216.7 l 1.6,-0.8 z m 163.8,275.2 0.8,0 c 1.1,4.5 1.6,7.2 1.6,8 l 0,1.6 c -15.9,16.7 -33.7,34.5 -53.3,53.3 -2.1,-3.2 -3.2,-5.8 -3.2,-8 l 0,-0.8 c 19.9,-20.5 37.9,-38.5 54.1,-54.1 z M 393,429 l 0.8,0 c -10.9,34.5 -17.5,52.2 -19.9,53.3 L 254.6,600.8 c -1.3,0 -4.2,-8.5 -8.7,-25.4 L 393,429 Z m -22.3,65.3 0.8,0 c -24.4,74 -37.4,111.3 -39,112.1 l -73.2,0 0,-0.8 C 286.4,578 323.5,540.9 370.7,494.3 Z m 43.8,-128.1 0.8,0 c -2.7,13 -9,23.1 -19.1,30.2 -31,31.8 -62,62.8 -93,93 l -0.8,0 c 1.9,-10.9 6.1,-19.1 12.7,-24.7 l 99.4,-98.5 z m 50.1,-150.3 1.6,0.8 c -22.8,67.9 -35,102.9 -36.6,105 l -109.8,108.9 0,-0.8 c 4.2,-16.7 24.7,-88 61.2,-213.9 l 83.6,0 z" />
14+
<symbol id="logo-gta5" viewBox="0 0 542 622">
15+
<g>
16+
<polygon points="261.7,169.9 258.5,180.9 175.9,98.3 181,82.8 262.8,164.6 "/>
17+
<polygon points="426.1,281.5 192.6,48 206.2,7.1 398.8,199.7 "/>
18+
<polygon points="130.4,620.9 2,620.9 164.3,133 248,216.8 "/>
19+
<polygon points="539.2,620.9 410.9,620.9 311.3,280 482.8,451.5 "/>
20+
<polygon points="214.6,2 332.9,2 392.1,179.5 "/>
21+
<polygon points="459.6,382 292.2,214.6 283.6,185.4 449.3,351 "/>
1722
</g>
1823
</symbol>
1924

0 commit comments

Comments
 (0)