Skip to content

Commit a174747

Browse files
committed
Merge branch 'master' into discordintegration
2 parents 129b84c + 006fe68 commit a174747

File tree

83 files changed

+2631
-274
lines changed

Some content is hidden

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

83 files changed

+2631
-274
lines changed

Client/core/CClientVariables.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: core/CClientVariables.cpp
66
* PURPOSE: Managed storage of client variables (cvars)
@@ -331,6 +331,7 @@ void CClientVariables::LoadDefaults()
331331
DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time
332332
DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on
333333
DEFAULT("allow_screen_upload", 1); // 0-off 1-on
334+
DEFAULT("allow_external_sounds", 1); // 0-off 1-on
334335
DEFAULT("max_clientscript_log_kb", 5000); // Max size in KB (0-No limit)
335336
DEFAULT("display_fullscreen_style", 0); // 0-standard 1-borderless 2-borderless keep res 3-borderless stretch
336337
DEFAULT("display_windowed", 0); // 0-off 1-on

Client/core/CCore.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,10 @@ void CCore::OnDeviceRestore()
18631863
void CCore::OnPreFxRender()
18641864
{
18651865
// Don't do nothing if nothing won't be drawn
1866+
1867+
if (CGraphics::GetSingleton().HasPrimitive3DPreGUIQueueItems())
1868+
CGraphics::GetSingleton().DrawPrimitive3DPreGUIQueue();
1869+
18661870
if (!CGraphics::GetSingleton().HasLine3DPreGUIQueueItems())
18671871
return;
18681872

Client/core/CGUI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
#include "CNewsBrowser.h"
1314
#include <game/CGame.h>
1415
#include <windowsx.h>
1516

Client/core/CGUI.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class CLocalGUI;
2929
#include "CSetCursorPosHook.h"
3030
#include "CSingleton.h"
3131
#include "CVersionUpdater.h"
32-
#include "CNewsBrowser.h"
3332

3433
#include <windows.h>
3534

Client/core/CNewsBrowser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,16 @@ void CNewsBrowser::CreateGUI()
167167
m_pButtonOK->SetPosition(CVector2D(560.0f - 60, 480.0f - 30));
168168
m_pButtonOK->SetZOrderingEnabled(false);
169169

170+
// News link
171+
m_pButtonNewsLink = reinterpret_cast<CGUIButton*>(pManager->CreateButton(m_pWindow, _("Visit latest news article")));
172+
m_pButtonNewsLink->SetSize(CVector2D(180, 40), false);
173+
m_pButtonNewsLink->SetPosition(CVector2D(560.0f - 250, 480.0f - 30));
174+
m_pButtonNewsLink->SetZOrderingEnabled(false);
175+
170176
// Set up the events
171177
m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));
172178
m_pButtonOK->SetClickHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));
179+
m_pButtonNewsLink->SetClickHandler(GUI_CALLBACK(&CNewsBrowser::OnNewsLinkButtonClick, this));
173180

174181
// Create the tab panel and necessary tabs
175182
m_pTabPanel = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow));
@@ -375,3 +382,13 @@ bool CNewsBrowser::OnOKButtonClick(CGUIElement* pElement)
375382
m_pWindow->SetVisible(false);
376383
return true;
377384
}
385+
386+
bool CNewsBrowser::OnNewsLinkButtonClick(CGUIElement* pElement)
387+
{
388+
// Visit the website
389+
ShellExecuteNonBlocking("open", "https://mtasa.com/news");
390+
391+
// Close the window
392+
m_pWindow->SetVisible(false);
393+
return true;
394+
}

Client/core/CNewsBrowser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class CNewsBrowser
3939
void CreateGUI();
4040
void DestroyGUI();
4141
bool OnOKButtonClick(CGUIElement* pElement);
42+
bool OnNewsLinkButtonClick(CGUIElement* pElement);
4243

4344
std::vector<SNewsItem> m_NewsitemList;
4445
CGUIWindow* m_pWindow;
4546
CGUITabPanel* m_pTabPanel;
4647
CGUIButton* m_pButtonOK;
48+
CGUIButton* m_pButtonNewsLink;
4749
std::vector<CGUITab*> m_TabList;
4850
std::vector<CGUIWindow*> m_TabContentList;
4951
};

Client/core/CSettings.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ void CSettings::CreateGUI()
376376
m_pCheckBoxAllowScreenUpload->GetPosition(vecTemp, false);
377377
m_pCheckBoxAllowScreenUpload->AutoSize(NULL, 20.0f);
378378

379+
m_pCheckBoxAllowExternalSounds = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Allow external sounds"), true));
380+
m_pCheckBoxAllowExternalSounds->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
381+
m_pCheckBoxAllowExternalSounds->GetPosition(vecTemp, false);
382+
m_pCheckBoxAllowExternalSounds->AutoSize(NULL, 20.0f);
383+
379384
m_pDiscordCheck = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Enable Discord Rich Presence"), true));
380385
m_pDiscordCheck->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
381386
m_pDiscordCheck->GetPosition(vecTemp, false);
@@ -1218,6 +1223,7 @@ void CSettings::CreateGUI()
12181223
m_pComboFxQuality->SetSelectionHandler(GUI_CALLBACK(&CSettings::OnFxQualityChanged, this));
12191224
m_pCheckBoxVolumetricShadows->SetClickHandler(GUI_CALLBACK(&CSettings::OnVolumetricShadowsClick, this));
12201225
m_pCheckBoxAllowScreenUpload->SetClickHandler(GUI_CALLBACK(&CSettings::OnAllowScreenUploadClick, this));
1226+
m_pCheckBoxAllowExternalSounds->SetClickHandler(GUI_CALLBACK(&CSettings::OnAllowExternalSoundsClick, this));
12211227
m_pCheckBoxCustomizedSAFiles->SetClickHandler(GUI_CALLBACK(&CSettings::OnCustomizedSAFilesClick, this));
12221228
m_pCheckBoxWindowed->SetClickHandler(GUI_CALLBACK(&CSettings::OnWindowedClick, this));
12231229
m_pCheckBoxDPIAware->SetClickHandler(GUI_CALLBACK(&CSettings::OnDPIAwareClick, this));
@@ -1516,6 +1522,11 @@ void CSettings::UpdateVideoTab()
15161522
CVARS_GET("discord_rich_presence", discordRichPresence);
15171523
m_pDiscordCheck->SetSelected(discordRichPresence);
15181524

1525+
// Allow external sounds
1526+
bool bAllowExternalSoundsEnabled;
1527+
CVARS_GET("allow_external_sounds", bAllowExternalSoundsEnabled);
1528+
m_pCheckBoxAllowExternalSounds->SetSelected(bAllowExternalSoundsEnabled);
1529+
15191530
// Customized sa files
15201531
m_pCheckBoxCustomizedSAFiles->SetSelected(GetApplicationSettingInt("customized-sa-files-request") != 0);
15211532
m_pCheckBoxCustomizedSAFiles->SetVisible(GetApplicationSettingInt("customized-sa-files-show") != 0);
@@ -3352,6 +3363,10 @@ void CSettings::SaveData()
33523363
g_pCore->GetDiscordManager()->Disconnect();
33533364
}
33543365

3366+
// Allow external sounds
3367+
bool bAllowExternalSoundsEnabled = m_pCheckBoxAllowExternalSounds->GetSelected();
3368+
CVARS_SET("allow_external_sounds", bAllowExternalSoundsEnabled);
3369+
33553370
// Grass
33563371
bool bGrassEnabled = m_pCheckBoxGrass->GetSelected();
33573372
CVARS_SET("grass", bGrassEnabled);
@@ -4355,6 +4370,24 @@ bool CSettings::OnAllowScreenUploadClick(CGUIElement* pElement)
43554370
return true;
43564371
}
43574372

4373+
//
4374+
// AllowExternalSounds
4375+
//
4376+
bool CSettings::OnAllowExternalSoundsClick(CGUIElement* pElement)
4377+
{
4378+
if (!m_pCheckBoxAllowExternalSounds->GetSelected() && !m_bShownAllowExternalSoundsMessage)
4379+
{
4380+
m_bShownAllowExternalSoundsMessage = true;
4381+
SString strMessage;
4382+
strMessage +=
4383+
_("Some scripts may play sounds, such as radio, from the internet."
4384+
"\n\nDisabling this setting may decrease network"
4385+
"\nbandwidth consumption.\n");
4386+
CCore::GetSingleton().ShowMessageBox(_("EXTERNAL SOUNDS"), strMessage, MB_BUTTON_OK | MB_ICON_INFO);
4387+
}
4388+
return true;
4389+
}
4390+
43584391
//
43594392
// CustomizedSAFiles
43604393
//

Client/core/CSettings.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: core/CSettings.h
66
* PURPOSE: Header file for in-game settings window class
@@ -153,6 +153,7 @@ class CSettings
153153
CGUICheckBox* m_pCheckBoxShowUnsafeResolutions;
154154
CGUICheckBox* m_pCheckBoxAllowScreenUpload;
155155
CGUICheckBox* m_pDiscordCheck = nullptr;
156+
CGUICheckBox* m_pCheckBoxAllowExternalSounds;
156157
CGUICheckBox* m_pCheckBoxCustomizedSAFiles;
157158
CGUICheckBox* m_pCheckBoxGrass;
158159
CGUICheckBox* m_pCheckBoxHeatHaze;
@@ -378,6 +379,7 @@ class CSettings
378379
bool OnFxQualityChanged(CGUIElement* pElement);
379380
bool OnVolumetricShadowsClick(CGUIElement* pElement);
380381
bool OnAllowScreenUploadClick(CGUIElement* pElement);
382+
bool OnAllowExternalSoundsClick(CGUIElement* pElement);
381383
bool OnCustomizedSAFilesClick(CGUIElement* pElement);
382384
bool ShowUnsafeResolutionsClick(CGUIElement* pElement);
383385
bool OnWindowedClick(CGUIElement* pElement);
@@ -444,6 +446,7 @@ class CSettings
444446
DWORD m_dwFrameCount;
445447
bool m_bShownVolumetricShadowsWarning;
446448
bool m_bShownAllowScreenUploadMessage;
449+
bool m_bShownAllowExternalSoundsMessage;
447450
int m_iMaxAnisotropic;
448451

449452
std::list<SKeyBindSection*> m_pKeyBindSections;

Client/core/Graphics/CGraphics.cpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "CMaterialLine3DBatcher.h"
1616
#include "CPrimitiveBatcher.h"
1717
#include "CPrimitiveMaterialBatcher.h"
18+
#include "CPrimitive3DBatcher.h"
19+
#include "CMaterialPrimitive3DBatcher.h"
1820
#include "CAspectRatioConverter.h"
1921
extern CCore* g_pCore;
2022
extern bool g_bInGTAScene;
@@ -58,6 +60,10 @@ CGraphics::CGraphics(CLocalGUI* pGUI)
5860
m_pLine3DBatcherPostGUI = new CLine3DBatcher(false);
5961
m_pMaterialLine3DBatcherPreGUI = new CMaterialLine3DBatcher(true);
6062
m_pMaterialLine3DBatcherPostGUI = new CMaterialLine3DBatcher(false);
63+
m_pPrimitive3DBatcherPreGUI = new CPrimitive3DBatcher(true);
64+
m_pPrimitive3DBatcherPostGUI = new CPrimitive3DBatcher(false);
65+
m_pMaterialPrimitive3DBatcherPreGUI = new CMaterialPrimitive3DBatcher(true, this);
66+
m_pMaterialPrimitive3DBatcherPostGUI = new CMaterialPrimitive3DBatcher(false, this);
6167
m_pPrimitiveBatcher = new CPrimitiveBatcher();
6268
m_pPrimitiveMaterialBatcher = new CPrimitiveMaterialBatcher(this);
6369

@@ -84,6 +90,10 @@ CGraphics::~CGraphics()
8490
SAFE_DELETE(m_pMaterialLine3DBatcherPostGUI);
8591
SAFE_DELETE(m_pPrimitiveBatcher);
8692
SAFE_DELETE(m_pPrimitiveMaterialBatcher);
93+
SAFE_DELETE(m_pPrimitive3DBatcherPreGUI);
94+
SAFE_DELETE(m_pPrimitive3DBatcherPostGUI);
95+
SAFE_DELETE(m_pMaterialPrimitive3DBatcherPreGUI);
96+
SAFE_DELETE(m_pMaterialPrimitive3DBatcherPostGUI);
8797
SAFE_DELETE(m_pScreenGrabber);
8898
SAFE_DELETE(m_pPixelsManager);
8999
SAFE_DELETE(m_pAspectRatioConverter);
@@ -855,13 +865,13 @@ void CGraphics::DrawCircleQueued(float fX, float fY, float fRadius, float fStart
855865
fStartAngle = D3DXToRadian(fStartAngle);
856866
fStopAngle = D3DXToRadian(fStopAngle);
857867
// Calculate each segment angle
858-
const float kfSegmentAngle = (fStopAngle - fStartAngle) / (siSegments - 1);
868+
const float kfSegmentAngle = (fStopAngle - fStartAngle) / siSegments;
859869

860870
// Add center point
861871
pVecVertices->push_back({fX, fY, 0.0f, ulColorCenter});
862872

863873
// And calculate all other vertices
864-
for (short siSeg = 0; siSeg < siSegments; siSeg++)
874+
for (short siSeg = 0; siSeg <= siSegments; siSeg++)
865875
{
866876
PrimitiveVertice vert;
867877
float curAngle = fStartAngle + siSeg * kfSegmentAngle;
@@ -898,6 +908,44 @@ void CGraphics::DrawPrimitiveQueued(std::vector<PrimitiveVertice>* pVecVertices,
898908
AddQueueItem(Item, bPostGUI);
899909
}
900910

911+
void CGraphics::DrawPrimitive3DQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI)
912+
{
913+
// Prevent queuing when minimized
914+
if (g_pCore->IsWindowMinimized())
915+
{
916+
delete pVecVertices;
917+
return;
918+
}
919+
920+
// Add it to the queue
921+
if (bPostGUI && !CCore::GetSingleton().IsMenuVisible())
922+
m_pPrimitive3DBatcherPostGUI->AddPrimitive(eType, pVecVertices);
923+
else
924+
m_pPrimitive3DBatcherPreGUI->AddPrimitive(eType, pVecVertices);
925+
}
926+
927+
void CGraphics::DrawMaterialPrimitive3DQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial, bool bPostGUI)
928+
{
929+
// Prevent queuing when minimized
930+
if (g_pCore->IsWindowMinimized())
931+
{
932+
delete pVecVertices;
933+
return;
934+
}
935+
936+
if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pMaterial))
937+
{
938+
// If material is a shader, use its current instance
939+
pMaterial = pShaderItem->m_pShaderInstance;
940+
}
941+
942+
// Add it to the queue
943+
if (bPostGUI && !CCore::GetSingleton().IsMenuVisible())
944+
m_pMaterialPrimitive3DBatcherPostGUI->AddPrimitive(eType, pMaterial, pVecVertices);
945+
else
946+
m_pMaterialPrimitive3DBatcherPreGUI->AddPrimitive(eType, pMaterial, pVecVertices);
947+
}
948+
901949
void CGraphics::DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial,
902950
bool bPostGUI)
903951
{
@@ -1437,7 +1485,10 @@ void CGraphics::OnDeviceCreate(IDirect3DDevice9* pDevice)
14371485
m_pMaterialLine3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
14381486
m_pMaterialLine3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
14391487
m_pPrimitiveBatcher->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
1440-
m_pPrimitiveMaterialBatcher->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
1488+
m_pPrimitive3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
1489+
m_pPrimitive3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
1490+
m_pMaterialPrimitive3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
1491+
m_pMaterialPrimitive3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
14411492
m_pRenderItemManager->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
14421493
m_pScreenGrabber->OnDeviceCreate(pDevice);
14431494
m_pPixelsManager->OnDeviceCreate(pDevice);
@@ -1513,6 +1564,8 @@ void CGraphics::DrawPostGUIQueue()
15131564
DrawQueue(m_PostGUIQueue);
15141565
m_pLine3DBatcherPostGUI->Flush();
15151566
m_pMaterialLine3DBatcherPostGUI->Flush();
1567+
m_pPrimitive3DBatcherPostGUI->Flush();
1568+
m_pMaterialPrimitive3DBatcherPostGUI->Flush();
15161569

15171570
// Both queues should be empty now, and there should be no outstanding refs
15181571
assert(m_PreGUIQueue.empty() && m_iDebugQueueRefs == 0);
@@ -1524,11 +1577,22 @@ void CGraphics::DrawLine3DPreGUIQueue()
15241577
m_pMaterialLine3DBatcherPreGUI->Flush();
15251578
}
15261579

1527-
bool CGraphics::HasLine3DPreGUIQueueItems()
1580+
void CGraphics::DrawPrimitive3DPreGUIQueue(void)
1581+
{
1582+
m_pPrimitive3DBatcherPreGUI->Flush();
1583+
m_pMaterialPrimitive3DBatcherPreGUI->Flush();
1584+
}
1585+
1586+
bool CGraphics::HasLine3DPreGUIQueueItems(void)
15281587
{
15291588
return m_pLine3DBatcherPreGUI->HasItems() || m_pMaterialLine3DBatcherPreGUI->HasItems();
15301589
}
15311590

1591+
bool CGraphics::HasPrimitive3DPreGUIQueueItems(void)
1592+
{
1593+
return m_pMaterialPrimitive3DBatcherPreGUI->HasItems() || m_pPrimitive3DBatcherPreGUI->HasItems();
1594+
}
1595+
15321596
void CGraphics::DrawQueue(std::vector<sDrawQueueItem>& Queue)
15331597
{
15341598
BeginDrawBatch();

0 commit comments

Comments
 (0)