[General]: Cleanup dvar usage (#744)

This commit is contained in:
Edo 2023-01-29 12:54:51 +00:00 committed by GitHub
parent d428207560
commit d00ba58658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 185 additions and 176 deletions

View File

@ -3,6 +3,8 @@
namespace Components namespace Components
{ {
Dvar::Var D3D9Ex::RUseD3D9Ex;
#pragma region D3D9Device #pragma region D3D9Device
HRESULT D3D9Ex::D3D9Device::QueryInterface(REFIID riid, void** ppvObj) HRESULT D3D9Ex::D3D9Device::QueryInterface(REFIID riid, void** ppvObj)
@ -630,7 +632,7 @@ namespace Components
#pragma region D3D9 #pragma region D3D9
HRESULT __stdcall D3D9Ex::D3D9::QueryInterface(REFIID riid, void** ppvObj) HRESULT WINAPI D3D9Ex::D3D9::QueryInterface(REFIID riid, void** ppvObj)
{ {
*ppvObj = nullptr; *ppvObj = nullptr;
@ -644,84 +646,84 @@ namespace Components
return hRes; return hRes;
} }
ULONG __stdcall D3D9Ex::D3D9::AddRef() ULONG WINAPI D3D9Ex::D3D9::AddRef()
{ {
return m_pIDirect3D9->AddRef(); return m_pIDirect3D9->AddRef();
} }
ULONG __stdcall D3D9Ex::D3D9::Release() ULONG WINAPI D3D9Ex::D3D9::Release()
{ {
ULONG count = m_pIDirect3D9->Release(); ULONG count = m_pIDirect3D9->Release();
if (!count) delete this; if (!count) delete this;
return count; return count;
} }
HRESULT __stdcall D3D9Ex::D3D9::RegisterSoftwareDevice(void* pInitializeFunction) HRESULT WINAPI D3D9Ex::D3D9::RegisterSoftwareDevice(void* pInitializeFunction)
{ {
return m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction); return m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction);
} }
UINT __stdcall D3D9Ex::D3D9::GetAdapterCount() UINT WINAPI D3D9Ex::D3D9::GetAdapterCount()
{ {
return m_pIDirect3D9->GetAdapterCount(); return m_pIDirect3D9->GetAdapterCount();
} }
HRESULT __stdcall D3D9Ex::D3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) HRESULT WINAPI D3D9Ex::D3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier)
{ {
return m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier); return m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
} }
UINT __stdcall D3D9Ex::D3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) UINT WINAPI D3D9Ex::D3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format)
{ {
return m_pIDirect3D9->GetAdapterModeCount(Adapter, Format); return m_pIDirect3D9->GetAdapterModeCount(Adapter, Format);
} }
HRESULT __stdcall D3D9Ex::D3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) HRESULT WINAPI D3D9Ex::D3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode)
{ {
return m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode); return m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode);
} }
HRESULT __stdcall D3D9Ex::D3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) HRESULT WINAPI D3D9Ex::D3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode)
{ {
return m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode); return m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode);
} }
HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) HRESULT WINAPI D3D9Ex::D3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
{ {
return m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed); return m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed);
} }
HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) HRESULT WINAPI D3D9Ex::D3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
{ {
return m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); return m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
} }
HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) HRESULT WINAPI D3D9Ex::D3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels)
{ {
return m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); return m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
} }
HRESULT __stdcall D3D9Ex::D3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) HRESULT WINAPI D3D9Ex::D3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
{ {
return m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); return m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
} }
HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) HRESULT WINAPI D3D9Ex::D3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
{ {
return m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat); return m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat);
} }
HRESULT __stdcall D3D9Ex::D3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) HRESULT WINAPI D3D9Ex::D3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps)
{ {
return m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps); return m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps);
} }
HMONITOR __stdcall D3D9Ex::D3D9::GetAdapterMonitor(UINT Adapter) HMONITOR WINAPI D3D9Ex::D3D9::GetAdapterMonitor(UINT Adapter)
{ {
return m_pIDirect3D9->GetAdapterMonitor(Adapter); return m_pIDirect3D9->GetAdapterMonitor(Adapter);
} }
HRESULT __stdcall D3D9Ex::D3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) HRESULT WINAPI D3D9Ex::D3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
{ {
HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
*ppReturnedDeviceInterface = new D3D9Ex::D3D9Device(*ppReturnedDeviceInterface); *ppReturnedDeviceInterface = new D3D9Ex::D3D9Device(*ppReturnedDeviceInterface);
@ -730,28 +732,26 @@ namespace Components
#pragma endregion #pragma endregion
IDirect3D9* __stdcall D3D9Ex::Direct3DCreate9Stub(UINT sdk) IDirect3D9* CALLBACK D3D9Ex::Direct3DCreate9Stub(UINT sdk)
{ {
if (Dvar::Var("r_useD3D9Ex").get<bool>()) if (RUseD3D9Ex.get<bool>())
{ {
IDirect3D9Ex* test = nullptr; IDirect3D9Ex* test = nullptr;
if (FAILED(Direct3DCreate9Ex(sdk, &test))) return nullptr; if (FAILED(Direct3DCreate9Ex(sdk, &test))) return nullptr;
return (new D3D9Ex::D3D9(test)); return (new D3D9(test));
}
else
{
return Direct3DCreate9(sdk);
} }
return Direct3DCreate9(sdk);
} }
D3D9Ex::D3D9Ex() D3D9Ex::D3D9Ex()
{ {
if (Dedicated::IsEnabled()) return; if (Dedicated::IsEnabled()) return;
Dvar::Register<bool>("r_useD3D9Ex", false, Game::DVAR_ARCHIVE, "Use extended d3d9 interface!"); RUseD3D9Ex = Dvar::Register<bool>("r_useD3D9Ex", false, Game::DVAR_ARCHIVE, "Use extended d3d9 interface!");
// Hook Interface creation // Hook Interface creation
Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub); Utils::Hook::Set(0x6D74D0, Direct3DCreate9Stub);
} }
} }

View File

@ -8,132 +8,131 @@ namespace Components
D3D9Ex(); D3D9Ex();
private: private:
class D3D9Device : public IDirect3DDevice9 class D3D9Device : public IDirect3DDevice9
{ {
public: public:
D3D9Device(IDirect3DDevice9* pOriginal) : m_pIDirect3DDevice9(pOriginal) {}; D3D9Device(IDirect3DDevice9* pOriginal) : m_pIDirect3DDevice9(pOriginal) {}
virtual ~D3D9Device() {}; virtual ~D3D9Device() = default;
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override; HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj) override;
ULONG __stdcall AddRef() override; ULONG WINAPI AddRef() override;
ULONG __stdcall Release() override; ULONG WINAPI Release() override;
HRESULT __stdcall TestCooperativeLevel() override; HRESULT WINAPI TestCooperativeLevel() override;
UINT __stdcall GetAvailableTextureMem() override; UINT WINAPI GetAvailableTextureMem() override;
HRESULT __stdcall EvictManagedResources() override; HRESULT WINAPI EvictManagedResources() override;
HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9) override; HRESULT WINAPI GetDirect3D(IDirect3D9** ppD3D9) override;
HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps) override; HRESULT WINAPI GetDeviceCaps(D3DCAPS9* pCaps) override;
HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) override; HRESULT WINAPI GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) override;
HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) override; HRESULT WINAPI GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) override;
HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) override; HRESULT WINAPI SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) override;
void __stdcall SetCursorPosition(int X, int Y, DWORD Flags) override; void WINAPI SetCursorPosition(int X, int Y, DWORD Flags) override;
BOOL __stdcall ShowCursor(BOOL bShow) override; BOOL WINAPI ShowCursor(BOOL bShow) override;
HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) override; HRESULT WINAPI CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) override;
HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) override; HRESULT WINAPI GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) override;
UINT __stdcall GetNumberOfSwapChains() override; UINT WINAPI GetNumberOfSwapChains() override;
HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) override; HRESULT WINAPI Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) override;
HRESULT __stdcall Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) override; HRESULT WINAPI Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) override;
HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) override; HRESULT WINAPI GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) override;
HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) override; HRESULT WINAPI GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) override;
HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs) override; HRESULT WINAPI SetDialogBoxMode(BOOL bEnableDialogs) override;
void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) override; void WINAPI SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) override;
void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) override; void WINAPI GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) override;
HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) override; HRESULT WINAPI UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) override;
HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) override; HRESULT WINAPI UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) override;
HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) override; HRESULT WINAPI GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) override;
HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) override; HRESULT WINAPI GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) override;
HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) override; HRESULT WINAPI StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) override;
HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) override; HRESULT WINAPI ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) override;
HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override; HRESULT WINAPI CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) override;
HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) override; HRESULT WINAPI SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) override;
HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) override; HRESULT WINAPI GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) override;
HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) override; HRESULT WINAPI SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) override;
HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) override; HRESULT WINAPI GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) override;
HRESULT __stdcall BeginScene() override; HRESULT WINAPI BeginScene() override;
HRESULT __stdcall EndScene() override; HRESULT WINAPI EndScene() override;
HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) override; HRESULT WINAPI Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) override;
HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) override; HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) override;
HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) override; HRESULT WINAPI GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) override;
HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) override; HRESULT WINAPI MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) override;
HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport) override; HRESULT WINAPI SetViewport(CONST D3DVIEWPORT9* pViewport) override;
HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport) override; HRESULT WINAPI GetViewport(D3DVIEWPORT9* pViewport) override;
HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial) override; HRESULT WINAPI SetMaterial(CONST D3DMATERIAL9* pMaterial) override;
HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial) override; HRESULT WINAPI GetMaterial(D3DMATERIAL9* pMaterial) override;
HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT9* pLight) override; HRESULT WINAPI SetLight(DWORD Index, CONST D3DLIGHT9* pLight) override;
HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight) override; HRESULT WINAPI GetLight(DWORD Index, D3DLIGHT9* pLight) override;
HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable) override; HRESULT WINAPI LightEnable(DWORD Index, BOOL Enable) override;
HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable) override; HRESULT WINAPI GetLightEnable(DWORD Index, BOOL* pEnable) override;
HRESULT __stdcall SetClipPlane(DWORD Index, CONST float* pPlane) override; HRESULT WINAPI SetClipPlane(DWORD Index, CONST float* pPlane) override;
HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane) override; HRESULT WINAPI GetClipPlane(DWORD Index, float* pPlane) override;
HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) override; HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) override;
HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) override; HRESULT WINAPI GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) override;
HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) override; HRESULT WINAPI CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) override;
HRESULT __stdcall BeginStateBlock() override; HRESULT WINAPI BeginStateBlock() override;
HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB) override; HRESULT WINAPI EndStateBlock(IDirect3DStateBlock9** ppSB) override;
HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) override; HRESULT WINAPI SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) override;
HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus) override; HRESULT WINAPI GetClipStatus(D3DCLIPSTATUS9* pClipStatus) override;
HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) override; HRESULT WINAPI GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) override;
HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) override; HRESULT WINAPI SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) override;
HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) override; HRESULT WINAPI GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) override;
HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) override; HRESULT WINAPI SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) override;
HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) override; HRESULT WINAPI GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) override;
HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) override; HRESULT WINAPI SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) override;
HRESULT __stdcall ValidateDevice(DWORD* pNumPasses) override; HRESULT WINAPI ValidateDevice(DWORD* pNumPasses) override;
HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) override; HRESULT WINAPI SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) override;
HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) override; HRESULT WINAPI GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) override;
HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber) override; HRESULT WINAPI SetCurrentTexturePalette(UINT PaletteNumber) override;
HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber) override; HRESULT WINAPI GetCurrentTexturePalette(UINT *PaletteNumber) override;
HRESULT __stdcall SetScissorRect(CONST RECT* pRect) override; HRESULT WINAPI SetScissorRect(CONST RECT* pRect) override;
HRESULT __stdcall GetScissorRect(RECT* pRect) override; HRESULT WINAPI GetScissorRect(RECT* pRect) override;
HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware) override; HRESULT WINAPI SetSoftwareVertexProcessing(BOOL bSoftware) override;
BOOL __stdcall GetSoftwareVertexProcessing() override; BOOL WINAPI GetSoftwareVertexProcessing() override;
HRESULT __stdcall SetNPatchMode(float nSegments) override; HRESULT WINAPI SetNPatchMode(float nSegments) override;
float __stdcall GetNPatchMode() override; float WINAPI GetNPatchMode() override;
HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) override; HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) override;
HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) override; HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) override;
HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override; HRESULT WINAPI DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override;
HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override; HRESULT WINAPI DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override;
HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) override; HRESULT WINAPI ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) override;
HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) override; HRESULT WINAPI CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) override;
HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) override; HRESULT WINAPI SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) override;
HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) override; HRESULT WINAPI GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) override;
HRESULT __stdcall SetFVF(DWORD FVF) override; HRESULT WINAPI SetFVF(DWORD FVF) override;
HRESULT __stdcall GetFVF(DWORD* pFVF) override; HRESULT WINAPI GetFVF(DWORD* pFVF) override;
HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) override; HRESULT WINAPI CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) override;
HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader) override; HRESULT WINAPI SetVertexShader(IDirect3DVertexShader9* pShader) override;
HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader) override; HRESULT WINAPI GetVertexShader(IDirect3DVertexShader9** ppShader) override;
HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) override; HRESULT WINAPI SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) override;
HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override; HRESULT WINAPI GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) override; HRESULT WINAPI SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) override;
HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override; HRESULT WINAPI GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) override; HRESULT WINAPI SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) override;
HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override; HRESULT WINAPI GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) override; HRESULT WINAPI SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) override;
HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) override; HRESULT WINAPI GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) override;
HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider) override; HRESULT WINAPI SetStreamSourceFreq(UINT StreamNumber, UINT Divider) override;
HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) override; HRESULT WINAPI GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) override;
HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData) override; HRESULT WINAPI SetIndices(IDirect3DIndexBuffer9* pIndexData) override;
HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData) override; HRESULT WINAPI GetIndices(IDirect3DIndexBuffer9** ppIndexData) override;
HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) override; HRESULT WINAPI CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) override;
HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader) override; HRESULT WINAPI SetPixelShader(IDirect3DPixelShader9* pShader) override;
HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader) override; HRESULT WINAPI GetPixelShader(IDirect3DPixelShader9** ppShader) override;
HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) override; HRESULT WINAPI SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) override;
HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override; HRESULT WINAPI GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) override;
HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) override; HRESULT WINAPI SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) override;
HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override; HRESULT WINAPI GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) override;
HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) override; HRESULT WINAPI SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) override;
HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override; HRESULT WINAPI GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) override;
HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) override; HRESULT WINAPI DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) override;
HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) override; HRESULT WINAPI DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) override;
HRESULT __stdcall DeletePatch(UINT Handle) override; HRESULT WINAPI DeletePatch(UINT Handle) override;
HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) override; HRESULT WINAPI CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) override;
private: private:
IDirect3DDevice9 *m_pIDirect3DDevice9; IDirect3DDevice9 *m_pIDirect3DDevice9;
@ -145,28 +144,30 @@ namespace Components
D3D9(IDirect3D9Ex *pOriginal) : m_pIDirect3D9(pOriginal) {}; D3D9(IDirect3D9Ex *pOriginal) : m_pIDirect3D9(pOriginal) {};
virtual ~D3D9() {}; virtual ~D3D9() {};
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj) override; HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj) override;
ULONG __stdcall AddRef() override; ULONG WINAPI AddRef() override;
ULONG __stdcall Release() override; ULONG WINAPI Release() override;
HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction) override; HRESULT WINAPI RegisterSoftwareDevice(void* pInitializeFunction) override;
UINT __stdcall GetAdapterCount() override; UINT WINAPI GetAdapterCount() override;
HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) override; HRESULT WINAPI GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) override;
UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) override; UINT WINAPI GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) override;
HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) override; HRESULT WINAPI EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) override;
HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) override; HRESULT WINAPI GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) override;
HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) override; HRESULT WINAPI CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) override;
HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) override; HRESULT WINAPI CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) override;
HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) override; HRESULT WINAPI CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) override;
HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) override; HRESULT WINAPI CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) override;
HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) override; HRESULT WINAPI CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) override;
HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) override; HRESULT WINAPI GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) override;
HMONITOR __stdcall GetAdapterMonitor(UINT Adapter) override; HMONITOR WINAPI GetAdapterMonitor(UINT Adapter) override;
HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) override; HRESULT WINAPI CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) override;
private: private:
IDirect3D9 *m_pIDirect3D9; IDirect3D9 *m_pIDirect3D9;
}; };
static IDirect3D9* __stdcall Direct3DCreate9Stub(UINT sdk); static Dvar::Var RUseD3D9Ex;
static IDirect3D9* CALLBACK Direct3DCreate9Stub(UINT sdk);
}; };
} }

View File

@ -15,6 +15,10 @@ namespace Components
Dvar::Var Download::SV_wwwDownload; Dvar::Var Download::SV_wwwDownload;
Dvar::Var Download::SV_wwwBaseUrl; Dvar::Var Download::SV_wwwBaseUrl;
Dvar::Var Download::UIDlTimeLeft;
Dvar::Var Download::UIDlProgress;
Dvar::Var Download::UIDlTransRate;
Download::ClientDownload Download::CLDownload; Download::ClientDownload Download::CLDownload;
std::thread Download::ServerThread; std::thread Download::ServerThread;
@ -34,9 +38,9 @@ namespace Components
Scheduler::Once([] Scheduler::Once([]
{ {
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(0)); UIDlTimeLeft.set(Utils::String::FormatTimeSpan(0));
Dvar::Var("ui_dl_progress").set("(0/0) %"); UIDlProgress.set("(0/0) %");
Dvar::Var("ui_dl_transRate").set("0.0 MB/s"); UIDlTransRate.set("0.0 MB/s");
}, Scheduler::Pipeline::MAIN); }, Scheduler::Pipeline::MAIN);
Command::Execute("openmenu mod_download_popmenu", false); Command::Execute("openmenu mod_download_popmenu", false);
@ -373,8 +377,8 @@ namespace Components
Scheduler::Once([] Scheduler::Once([]
{ {
framePushed = false; framePushed = false;
Dvar::Var("ui_dl_progress").set(std::format("({}/{}) {}%", dlIndex, dlSize, dlProgress)); UIDlProgress.set(std::format("({}/{}) {}%", dlIndex, dlSize, dlProgress));
}, Scheduler::Pipeline::CLIENT); }, Scheduler::Pipeline::MAIN);
} }
auto delta = Game::Sys_Milliseconds() - fDownload->download->lastTimeStamp; auto delta = Game::Sys_Milliseconds() - fDownload->download->lastTimeStamp;
@ -402,8 +406,8 @@ namespace Components
Scheduler::Once([] Scheduler::Once([]
{ {
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(dlTimeLeft)); UIDlTimeLeft.set(Utils::String::FormatTimeSpan(dlTimeLeft));
Dvar::Var("ui_dl_transRate").set(Utils::String::FormatBandwidth(dlTsBytes, dlDelta)); UIDlTransRate.set(Utils::String::FormatBandwidth(dlTsBytes, dlDelta));
}, Scheduler::Pipeline::MAIN); }, Scheduler::Pipeline::MAIN);
} }
@ -686,9 +690,9 @@ namespace Components
{ {
Events::OnDvarInit([] Events::OnDvarInit([]
{ {
Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::DVAR_NONE, ""); UIDlTimeLeft = Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::DVAR_NONE, "");
Dvar::Register<const char*>("ui_dl_progress", "", Game::DVAR_NONE, ""); UIDlProgress = Dvar::Register<const char*>("ui_dl_progress", "", Game::DVAR_NONE, "");
Dvar::Register<const char*>("ui_dl_transRate", "", Game::DVAR_NONE, ""); UIDlTransRate = Dvar::Register<const char*>("ui_dl_transRate", "", Game::DVAR_NONE, "");
}); });
UIScript::Add("mod_download_cancel", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info) UIScript::Add("mod_download_cancel", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)

View File

@ -16,6 +16,10 @@ namespace Components
static Dvar::Var SV_wwwDownload; static Dvar::Var SV_wwwDownload;
static Dvar::Var SV_wwwBaseUrl; static Dvar::Var SV_wwwBaseUrl;
static Dvar::Var UIDlTimeLeft;
static Dvar::Var UIDlProgress;
static Dvar::Var UIDlTransRate;
private: private:
class ClientDownload class ClientDownload
{ {