Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 359043e

Browse files
Merge branch 'master' into feature/remove-all-domains
2 parents 0f49e69 + 5837aaf commit 359043e

File tree

144 files changed

+109936
-102960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+109936
-102960
lines changed

‎Client/core/CAdditionalVertexStreamManager.cpp‎

Lines changed: 265 additions & 59 deletions
Large diffs are not rendered by default.

‎Client/core/CAdditionalVertexStreamManager.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ class CAdditionalVertexStreamManager
8484
void OnVertexBufferRangeInvalidated(IDirect3DVertexBuffer9* pStreamData, uint Offset, uint Size);
8585

8686
static CAdditionalVertexStreamManager* GetSingleton();
87+
static CAdditionalVertexStreamManager* GetExistingSingleton();
88+
static void DestroySingleton();
8789

8890
protected:
89-
void SetAdditionalVertexStream(SCurrentStateInfo& renderState);
91+
bool SetAdditionalVertexStream(SCurrentStateInfo& renderState);
9092
bool UpdateCurrentStateInfo(SCurrentStateInfo& state);
9193
bool UpdateAdditionalStreamContent(SCurrentStateInfo& state, SAdditionalStreamInfo* pAdditionalStreamInfo, uint ReadOffsetStart, uint ReadSize,
9294
uint WriteOffsetStart, uint WriteSize);

‎Client/core/CClientVariables.cpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ void CClientVariables::ValidateValues()
265265
ClampValue("voicevolume", 0.0f, 1.0f);
266266
ClampValue("mapalpha", 0, 255);
267267
ClampValue("mapimage", 0, 1);
268+
ClampValue("borderless_gamma_power", 0.5f, 2.0f);
269+
ClampValue("borderless_brightness_scale", 0.5f, 2.0f);
270+
ClampValue("borderless_contrast_scale", 0.5f, 2.0f);
271+
ClampValue("borderless_saturation_scale", 0.5f, 2.0f);
272+
ClampValue("borderless_gamma_enabled", false, true);
273+
ClampValue("borderless_brightness_enabled", false, true);
274+
ClampValue("borderless_contrast_enabled", false, true);
275+
ClampValue("borderless_saturation_enabled", false, true);
276+
ClampValue("borderless_apply_windowed", false, true);
277+
ClampValue("borderless_apply_fullscreen", false, true);
268278
}
269279

270280
void CClientVariables::LoadDefaults()
@@ -348,6 +358,24 @@ void CClientVariables::LoadDefaults()
348358
DEFAULT("display_fullscreen_style", 0); // 0-standard 1-borderless 2-borderless keep res 3-borderless stretch
349359
DEFAULT("display_windowed", 0); // 0-off 1-on
350360
DEFAULT("multimon_fullscreen_minimize", 1); // 0-off 1-on
361+
DEFAULT("borderless_gamma_power", 0.95f); // Gamma exponent applied to windowed gamma ramp (1.0 = unchanged)
362+
DEFAULT("borderless_brightness_scale", 1.03f); // Brightness multiplier for windowed gamma ramp (1.0 = unchanged)
363+
DEFAULT("borderless_contrast_scale", 1.0f); // Contrast multiplier for borderless presentation (1.0 = unchanged)
364+
DEFAULT("borderless_saturation_scale", 1.0f); // Saturation multiplier for borderless presentation (1.0 = unchanged)
365+
DEFAULT("borderless_enable_srgb", false); // Enable sRGB correction when running borderless
366+
DEFAULT("borderless_gamma_enabled", false); // Apply gamma adjustment while borderless tuning active
367+
DEFAULT("borderless_brightness_enabled", false); // Apply brightness adjustment while borderless tuning active
368+
DEFAULT("borderless_contrast_enabled", false); // Apply contrast adjustment while borderless tuning active
369+
DEFAULT("borderless_saturation_enabled", false); // Apply saturation adjustment while borderless tuning active
370+
DEFAULT("borderless_apply_windowed", false); // Apply display adjustments while windowed/borderless
371+
DEFAULT("borderless_apply_fullscreen", false); // Apply display adjustments while in exclusive fullscreen
372+
373+
if (Exists("borderless_enable_srgb"))
374+
{
375+
bool legacyEnable = false;
376+
Get("borderless_enable_srgb", legacyEnable);
377+
Set("borderless_apply_windowed", legacyEnable);
378+
}
351379
DEFAULT("vertical_aim_sensitivity", 0.0015f); // 0.0015f is GTA default setting
352380
DEFAULT("process_priority", 0); // 0-normal 1-above normal 2-high
353381
DEFAULT("process_dpi_aware", false); // Enable DPI awareness in core initialization

‎Client/core/CCore.cpp‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ CCore::CCore()
146146
// Setup our hooks.
147147
ApplyHooks();
148148

149+
m_pModelCacheManager = nullptr;
150+
m_iDummyProgressValue = 0;
151+
m_DummyProgressTimerHandle = NULL;
152+
m_bDummyProgressUpdateAlways = false;
153+
149154
m_iUnminimizeFrameCounter = 0;
150155
m_bDidRecreateRenderTargets = false;
151156
m_fMinStreamingMemory = 0;
@@ -187,10 +192,27 @@ CCore::~CCore()
187192
// Remove input hook
188193
CMessageLoopHook::GetSingleton().RemoveHook();
189194

195+
if (m_bWindowsTimerEnabled)
196+
{
197+
KillTimer(GetHookedWindow(), IDT_TIMER1);
198+
m_bWindowsTimerEnabled = false;
199+
}
200+
201+
extern int ms_iDummyProgressTimerCounter;
202+
203+
if (m_DummyProgressTimerHandle != NULL)
204+
{
205+
DeleteTimerQueueTimer(NULL, m_DummyProgressTimerHandle, INVALID_HANDLE_VALUE);
206+
m_DummyProgressTimerHandle = NULL;
207+
ms_iDummyProgressTimerCounter = 0;
208+
}
209+
190210
// Delete the mod manager
191211
delete m_pModManager;
192212
SAFE_DELETE(m_pMessageBox);
193213

214+
SAFE_DELETE(m_pModelCacheManager);
215+
194216
// Destroy early subsystems
195217
m_bModulesLoaded = false;
196218
DestroyNetwork();
@@ -225,6 +247,8 @@ CCore::~CCore()
225247
DestroyGUI();
226248
DestroyXML();
227249

250+
SAFE_DELETE(g_pLocalization);
251+
228252
// Delete keybinds
229253
delete m_pKeyBinds;
230254

@@ -1072,6 +1096,16 @@ void CCore::CreateXML()
10721096
if (!m_pConfigFile)
10731097
{
10741098
assert(false);
1099+
1100+
if (m_pXML)
1101+
{
1102+
using PFNReleaseXMLInterface = void (*)();
1103+
if (auto pfnRelease = reinterpret_cast<PFNReleaseXMLInterface>(m_XMLModule.GetFunctionPointer("ReleaseXMLInterface")))
1104+
pfnRelease();
1105+
}
1106+
1107+
m_pXML = NULL;
1108+
m_XMLModule.UnloadModule();
10751109
return;
10761110
}
10771111

@@ -1123,10 +1157,14 @@ void CCore::DestroyXML()
11231157
{
11241158
SaveConfig(true);
11251159
delete m_pConfigFile;
1160+
m_pConfigFile = nullptr;
11261161
}
11271162

11281163
if (m_pXML)
11291164
{
1165+
using PFNReleaseXMLInterface = void (*)();
1166+
if (auto pfnRelease = reinterpret_cast<PFNReleaseXMLInterface>(m_XMLModule.GetFunctionPointer("ReleaseXMLInterface")))
1167+
pfnRelease();
11301168
m_pXML = NULL;
11311169
}
11321170

‎Client/core/CMainMenu.cpp‎

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -358,33 +358,64 @@ CMainMenu::CMainMenu(CGUI* pManager)
358358

359359
CMainMenu::~CMainMenu()
360360
{
361-
// Destroy GUI items
362-
delete m_pBackground;
363-
delete m_pCanvas;
364-
delete m_pFiller;
365-
delete m_pFiller2;
366-
delete m_pLogo;
367-
delete m_pLatestNews;
368-
delete m_pVersion;
369-
delete m_pMenuArea;
370-
371-
// Destroy the menu items. Note: The disconnect item isn't always in the
372-
// list of menu items (it's only in there when we're in game). This means we
373-
// don't delete it when we iterate the list and delete it separately - the
374-
// menu item itself still exists even when it's no in the list of menu
375-
// items. Perhaps there should be a separate list of loaded items really.
376-
for (std::deque<sMenuItem*>::iterator it = m_menuItems.begin(); it != m_menuItems.end(); ++it)
361+
auto destroyElement = [this](auto*& element) {
362+
if (!element)
363+
return;
364+
m_pManager->DestroyElementRecursive(element);
365+
element = nullptr;
366+
};
367+
368+
for (uint i = 0; i < CORE_MTA_NEWS_ITEMS; ++i)
377369
{
378-
if ((*it) != m_pDisconnect)
370+
destroyElement(m_pNewsItemLabels[i]);
371+
destroyElement(m_pNewsItemShadowLabels[i]);
372+
destroyElement(m_pNewsItemDateLabels[i]);
373+
destroyElement(m_pNewsItemNEWLabels[i]);
374+
}
375+
376+
for (sMenuItem* pItem : m_menuItems)
377+
{
378+
if (!pItem || pItem == m_pDisconnect)
379+
continue;
380+
381+
if (pItem->image)
382+
{
383+
m_pManager->DestroyElementRecursive(pItem->image);
384+
pItem->image = nullptr;
385+
}
386+
387+
delete pItem;
388+
}
389+
m_menuItems.clear();
390+
m_unhoveredItems.clear();
391+
m_pHoveredItem = nullptr;
392+
393+
if (m_pDisconnect)
394+
{
395+
if (m_pDisconnect->image)
379396
{
380-
delete (*it)->image;
381-
delete (*it);
397+
m_pManager->DestroyElementRecursive(m_pDisconnect->image);
398+
m_pDisconnect->image = nullptr;
382399
}
400+
401+
delete m_pDisconnect;
402+
m_pDisconnect = nullptr;
383403
}
384404

385-
delete m_pDisconnect->image;
386-
delete m_pDisconnect;
405+
destroyElement(m_pMenuArea);
406+
destroyElement(m_pLogo);
407+
destroyElement(m_pLatestNews);
408+
destroyElement(m_pVersion);
409+
410+
destroyElement(m_pCanvas);
411+
destroyElement(m_pBackground);
412+
destroyElement(m_pFiller);
413+
destroyElement(m_pFiller2);
414+
387415
delete m_pLanguageSelector;
416+
m_pLanguageSelector = nullptr;
417+
delete m_pNewsBrowser;
418+
m_pNewsBrowser = nullptr;
388419
}
389420

390421
void CMainMenu::SetMenuVerticalPosition(int iPosY)

‎Client/core/CScreenGrabber.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ bool CScreenGrabber::GetBackBufferPixels(uint uiSizeX, uint uiSizeY, CBuffer& bu
242242
if (!m_pScreenShotTemp)
243243
{
244244
strOutError = "No ScreenShotTemp";
245+
SAFE_RELEASE(pD3DBackBufferSurface);
245246
return false;
246247
}
247248

@@ -251,6 +252,7 @@ bool CScreenGrabber::GetBackBufferPixels(uint uiSizeX, uint uiSizeY, CBuffer& bu
251252
if (FAILED(hr))
252253
{
253254
strOutError = SString("StretchRect failed (0x%08x)", hr);
255+
SAFE_RELEASE(pD3DBackBufferSurface);
254256
return false;
255257
}
256258

@@ -260,6 +262,7 @@ bool CScreenGrabber::GetBackBufferPixels(uint uiSizeX, uint uiSizeY, CBuffer& bu
260262
if (!m_pScreenShotTemp->ReadPixels(buffer, strOutError))
261263
{
262264
dassert(!strOutError.empty());
265+
SAFE_RELEASE(pD3DBackBufferSurface);
263266
return false;
264267
}
265268

‎Client/core/CScreenShot.cpp‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
#include "DXHook/CProxyDirect3DDevice9.h"
14+
#include <math.h>
1315
#include <libpng/png.h>
1416

1517
extern CCore* g_pCore;
@@ -38,6 +40,86 @@ static uint ms_uiHeight = 0;
3840
// whether we want to actually save photo in documents folder
3941
static bool savePhotoInDocuments = false;
4042

43+
namespace
44+
{
45+
float Clamp(float value, float minValue, float maxValue)
46+
{
47+
if (value < minValue)
48+
return minValue;
49+
if (value > maxValue)
50+
return maxValue;
51+
return value;
52+
}
53+
54+
void ApplyBorderlessAdjustmentsToBuffer(void* rawData, uint width, uint height)
55+
{
56+
if (!rawData || width == 0 || height == 0)
57+
return;
58+
59+
bool isBorderless = false;
60+
if (CVideoModeManagerInterface* videoModeManager = GetVideoModeManager())
61+
isBorderless = videoModeManager->IsDisplayModeWindowed() || videoModeManager->IsDisplayModeFullScreenWindow();
62+
63+
if (!isBorderless && ::g_pDeviceState)
64+
isBorderless = (::g_pDeviceState->CreationState.PresentationParameters.Windowed != 0);
65+
66+
float gammaPower = 1.0f;
67+
float brightnessScale = 1.0f;
68+
float contrastScale = 1.0f;
69+
float saturationScale = 1.0f;
70+
bool applyWindowed = true;
71+
bool applyFullscreen = false;
72+
::BorderlessGamma::FetchSettings(gammaPower, brightnessScale, contrastScale, saturationScale, applyWindowed, applyFullscreen);
73+
74+
const bool adjustmentsEnabled = isBorderless ? applyWindowed : applyFullscreen;
75+
if (!adjustmentsEnabled)
76+
return;
77+
78+
if (!::BorderlessGamma::ShouldApplyAdjustments(gammaPower, brightnessScale, contrastScale, saturationScale))
79+
return;
80+
81+
BYTE* data = static_cast<BYTE*>(rawData);
82+
const size_t pixelCount = static_cast<size_t>(width) * static_cast<size_t>(height);
83+
const float inv255 = 1.0f / 255.0f;
84+
const float contrastPivot = 0.5f;
85+
86+
for (size_t i = 0; i < pixelCount; ++i)
87+
{
88+
float r = Clamp(data[0] * inv255, 0.0f, 1.0f);
89+
float g = Clamp(data[1] * inv255, 0.0f, 1.0f);
90+
float b = Clamp(data[2] * inv255, 0.0f, 1.0f);
91+
92+
r = powf(r, gammaPower);
93+
g = powf(g, gammaPower);
94+
b = powf(b, gammaPower);
95+
96+
r *= brightnessScale;
97+
g *= brightnessScale;
98+
b *= brightnessScale;
99+
100+
r = (r - contrastPivot) * contrastScale + contrastPivot;
101+
g = (g - contrastPivot) * contrastScale + contrastPivot;
102+
b = (b - contrastPivot) * contrastScale + contrastPivot;
103+
104+
float luminance = Clamp(0.299f * r + 0.587f * g + 0.114f * b, 0.0f, 1.0f);
105+
106+
r = luminance + (r - luminance) * saturationScale;
107+
g = luminance + (g - luminance) * saturationScale;
108+
b = luminance + (b - luminance) * saturationScale;
109+
110+
r = Clamp(r, 0.0f, 1.0f);
111+
g = Clamp(g, 0.0f, 1.0f);
112+
b = Clamp(b, 0.0f, 1.0f);
113+
114+
data[0] = static_cast<BYTE>(r * 255.0f + 0.5f);
115+
data[1] = static_cast<BYTE>(g * 255.0f + 0.5f);
116+
data[2] = static_cast<BYTE>(b * 255.0f + 0.5f);
117+
118+
data += 4;
119+
}
120+
}
121+
} // namespace
122+
41123
void CScreenShot::InitiateScreenShot(bool bIsCameraShot)
42124
{
43125
if (ms_bScreenShot || ms_bIsSaving || IsRateLimited(bIsCameraShot))
@@ -109,6 +191,7 @@ void CScreenShot::CheckForScreenShot(bool bBeforeGUI)
109191

110192
if (uiDataSize == uiReqDataSize)
111193
{
194+
ApplyBorderlessAdjustmentsToBuffer(ms_ScreenShotBuffer.GetData(), ms_uiWidth, ms_uiHeight);
112195
// Start the save thread
113196
StartSaveThread();
114197
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /