Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f0053fb
onTransferBoxStateChange event
CrosRoad95 Nov 19, 2017
9955117
3 patches found by Citizen01
CrosRoad95 Nov 19, 2017
89537a4
event name back to onTransferBoxStateChange
CrosRoad95 Nov 19, 2017
fd6e0d5
removed 2 spaces
CrosRoad95 Nov 19, 2017
4ea4e76
another 2 space removed
CrosRoad95 Nov 19, 2017
096bfc1
bettern name for event
CrosRoad95 Dec 11, 2017
daf09b0
Update CResourceFileDownloadManager.cpp
CrosRoad95 Dec 11, 2017
a73b0b0
Merge branch 'master' into onTransferBoxStateChange-event
CrosRoad95 Jul 2, 2018
f29f36a
rebuilded
CrosRoad95 Jul 2, 2018
1fe5300
Merge branch 'master' into onTransferBoxStateChange-event
CrosRoad95 Jul 23, 2018
cd8ac81
added option to allow server control transfer box
CrosRoad95 Jul 23, 2018
df074ae
Revert "added option to allow server control transfer box"
CrosRoad95 Jul 23, 2018
ea99866
Revert "Revert "added option to allow server control transfer box""
CrosRoad95 Jul 23, 2018
174ea6b
fix cclientgame
CrosRoad95 Jul 23, 2018
8c8e745
Update CClientGame.cpp
CrosRoad95 Jul 23, 2018
0ce4601
Update CClientGame.cpp
CrosRoad95 Jul 23, 2018
ad4ac2d
Update CClientGame.cpp
CrosRoad95 Jul 23, 2018
56bf466
update cluaguidefs.cpp
CrosRoad95 Jul 23, 2018
ac4f151
updated CLuaGUIDefs
CrosRoad95 Jul 23, 2018
a52c7db
Merge branch 'master' into onTransferBoxStateChange-event
CrosRoad95 Jul 23, 2018
2524450
renamed transfebox to transferbox
CrosRoad95 Jul 23, 2018
a8b80b2
update CLuaGUIDefs
CrosRoad95 Jul 23, 2018
18b1b58
fix
CrosRoad95 Aug 28, 2018
9afabc6
Merge remote-tracking branch 'origin/onTransferBoxStateChange-event' …
CrosRoad95 Aug 28, 2018
a8a7326
fix
CrosRoad95 Aug 28, 2018
e3c9933
Merge branch 'master' into onTransferBoxStateChange-event
qaisjp Jan 1, 2019
f7b26b0
Fix merge
qaisjp Jan 1, 2019
69bd0ea
fix test
CrosRoad95 Jan 2, 2019
0b485ab
Merge branch 'master' into onTransferBoxStateChange-event
CrosRoad95 Jan 2, 2019
179e24e
Merge remote-tracking branch 'origin/onTransferBoxStateChange-event' …
CrosRoad95 Jan 2, 2019
66dd5c8
unnuke branch
CrosRoad95 Jan 2, 2019
8eacde0
Merge remote-tracking branch 'upstream/master' into onTransferBoxStat…
patrikjuvonen Feb 23, 2019
bcc50db
Clean up the PR, see further details
patrikjuvonen Feb 23, 2019
cea7ac5
Merge remote-tracking branch 'upstream/master' into onTransferBoxStat…
patrikjuvonen Apr 27, 2019
db03982
Update make_uname.bat
patrikjuvonen May 28, 2019
1ab9eb1
Merge remote-tracking branch 'upstream/master' into onTransferBoxStat…
patrikjuvonen May 28, 2019
c7aa9b2
Merge branch 'master' into onTransferBoxStateChange-event
qaisjp Apr 2, 2020
7645255
Merge branch 'master' into onTransferBoxStateChange-event
StrixG Oct 25, 2020
9d31838
Use new parser
StrixG Oct 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void CClientVariables::LoadDefaults()
DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time
DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on
DEFAULT("allow_screen_upload", 1); // 0-off 1-on
DEFAULT("allow_server_control_transferbox", 1); // 0-off 1-on
DEFAULT("allow_external_sounds", 1); // 0-off 1-on
DEFAULT("max_clientscript_log_kb", 5000); // Max size in KB (0-No limit)
DEFAULT("display_fullscreen_style", 0); // 0-standard 1-borderless 2-borderless keep res 3-borderless stretch
Expand Down
28 changes: 28 additions & 0 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ void CSettings::CreateGUI()
m_pCheckBoxAllowScreenUpload->GetPosition(vecTemp, false);
m_pCheckBoxAllowScreenUpload->AutoSize(NULL, 20.0f);

m_pCheckBoxAllowTransferBoxControl =
reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Allow server to control transfer box"), true));
m_pCheckBoxAllowTransferBoxControl->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
m_pCheckBoxAllowTransferBoxControl->GetPosition(vecTemp, false);
m_pCheckBoxAllowTransferBoxControl->AutoSize(NULL, 20.0f);

m_pCheckBoxAllowExternalSounds = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Allow external sounds"), true));
m_pCheckBoxAllowExternalSounds->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
m_pCheckBoxAllowExternalSounds->GetPosition(vecTemp, false);
Expand Down Expand Up @@ -1218,6 +1224,7 @@ void CSettings::CreateGUI()
m_pComboFxQuality->SetSelectionHandler(GUI_CALLBACK(&CSettings::OnFxQualityChanged, this));
m_pCheckBoxVolumetricShadows->SetClickHandler(GUI_CALLBACK(&CSettings::OnVolumetricShadowsClick, this));
m_pCheckBoxAllowScreenUpload->SetClickHandler(GUI_CALLBACK(&CSettings::OnAllowScreenUploadClick, this));
m_pCheckBoxAllowTransferBoxControl->SetClickHandler(GUI_CALLBACK(&CSettings::OnAllowTransferBoxControl, this));
m_pCheckBoxAllowExternalSounds->SetClickHandler(GUI_CALLBACK(&CSettings::OnAllowExternalSoundsClick, this));
m_pCheckBoxCustomizedSAFiles->SetClickHandler(GUI_CALLBACK(&CSettings::OnCustomizedSAFilesClick, this));
m_pCheckBoxWindowed->SetClickHandler(GUI_CALLBACK(&CSettings::OnWindowedClick, this));
Expand Down Expand Up @@ -1512,6 +1519,11 @@ void CSettings::UpdateVideoTab()
CVARS_GET("allow_screen_upload", bAllowScreenUploadEnabled);
m_pCheckBoxAllowScreenUpload->SetSelected(bAllowScreenUploadEnabled);

// Allow transfer box control
bool bAllowServerTransferBoxControl;
CVARS_GET("allow_server_control_transferbox", bAllowServerTransferBoxControl);
m_pCheckBoxAllowTransferBoxControl->SetSelected(bAllowServerTransferBoxControl);

// Allow external sounds
bool bAllowExternalSoundsEnabled;
CVARS_GET("allow_external_sounds", bAllowExternalSoundsEnabled);
Expand Down Expand Up @@ -3344,6 +3356,10 @@ void CSettings::SaveData()
bool bAllowScreenUploadEnabled = m_pCheckBoxAllowScreenUpload->GetSelected();
CVARS_SET("allow_screen_upload", bAllowScreenUploadEnabled);

// Allow transfer box control
bool bAllowServerTransferBoxControl = m_pCheckBoxAllowTransferBoxControl->GetSelected();
CVARS_SET("allow_server_control_transferbox", bAllowServerTransferBoxControl);

// Allow external sounds
bool bAllowExternalSoundsEnabled = m_pCheckBoxAllowExternalSounds->GetSelected();
CVARS_SET("allow_external_sounds", bAllowExternalSoundsEnabled);
Expand Down Expand Up @@ -4351,6 +4367,18 @@ bool CSettings::OnAllowScreenUploadClick(CGUIElement* pElement)
return true;
}

bool CSettings::OnAllowTransferBoxControl(CGUIElement* pElement)
{
bool bAllowTransferBoxControl = m_pCheckBoxAllowTransferBoxControl->GetSelected();
CVARS_SET("allow_server_control_transferbox", bAllowTransferBoxControl);

// Enable default transfer box now if script control is disabled
if (!bAllowTransferBoxControl)
g_pCore->GetGUI()->SetTransferBoxEnabled(true);

return true;
}

//
// AllowExternalSounds
//
Expand Down
2 changes: 2 additions & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class CSettings
CGUICheckBox* m_pCheckBoxDeviceSelectionDialog;
CGUICheckBox* m_pCheckBoxShowUnsafeResolutions;
CGUICheckBox* m_pCheckBoxAllowScreenUpload;
CGUICheckBox* m_pCheckBoxAllowTransferBoxControl;
CGUICheckBox* m_pCheckBoxAllowExternalSounds;
CGUICheckBox* m_pCheckBoxCustomizedSAFiles;
CGUICheckBox* m_pCheckBoxGrass;
Expand Down Expand Up @@ -378,6 +379,7 @@ class CSettings
bool OnFxQualityChanged(CGUIElement* pElement);
bool OnVolumetricShadowsClick(CGUIElement* pElement);
bool OnAllowScreenUploadClick(CGUIElement* pElement);
bool OnAllowTransferBoxControl(CGUIElement* pElement);
bool OnAllowExternalSoundsClick(CGUIElement* pElement);
bool OnCustomizedSAFilesClick(CGUIElement* pElement);
bool ShowUnsafeResolutionsClick(CGUIElement* pElement);
Expand Down
8 changes: 6 additions & 2 deletions Client/gui/CGUI_Impl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: gui/CGUI_Impl.h
* PURPOSE: Graphical User Interface module class
Expand Down Expand Up @@ -255,9 +255,12 @@ class CGUI_Impl : public CGUI, public CGUITabList
void ClearInputHandlers(eInputChannel channel);
void ClearSystemKeys();

bool IsTransferBoxVisible() { return m_bTransferBoxVisible; };
bool IsTransferBoxVisible() const { return m_bTransferBoxVisible; };
void SetTransferBoxVisible(bool bVisible) { m_bTransferBoxVisible = bVisible; };

bool IsTransferBoxEnabled() const { return m_bTransferBoxEnabled; };
void SetTransferBoxEnabled(bool bEnabled) { m_bTransferBoxEnabled = bEnabled; };

bool Event_CharacterKey(const CEGUI::EventArgs& e);
bool Event_KeyDown(const CEGUI::EventArgs& e);
bool Event_MouseClick(const CEGUI::EventArgs& e);
Expand Down Expand Up @@ -350,6 +353,7 @@ class CGUI_Impl : public CGUI, public CGUITabList
std::list<SString> m_GuiWorkingDirectoryStack;

bool m_bTransferBoxVisible;
bool m_bTransferBoxEnabled = true;

bool m_HasSchemeLoaded;
SString m_CurrentSchemeName;
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2917,6 +2917,8 @@ void CClientGame::AddBuiltInEvents()
// Misc events
m_Events.AddEvent("onClientFileDownloadComplete", "fileName, success", NULL, false);

m_Events.AddEvent("onClientTransferBoxProgressChange", "downloaded, total", NULL, false);

m_Events.AddEvent("onClientWeaponFire", "ped, x, y, z", NULL, false);

m_Events.AddEvent("onClientWorldSound", "group, index, x, y, z", nullptr, false);
Expand Down
18 changes: 17 additions & 1 deletion Client/mods/deathmatch/logic/CResourceFileDownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,26 @@ void CResourceFileDownloadManager::DoPulse()
return;
}

bool bAllowTransferBoxControl = g_pCore->GetCVars()->GetValue("allow_server_control_transferbox", false);
if (!bAllowTransferBoxControl && !GetTransferBox()->IsEnabled())
GetTransferBox()->SetEnabled(true);

if (GetTransferBox()->IsEnabled() && !GetTransferBox()->IsVisible())
GetTransferBox()->Show();

// Update progress box
GetTransferBox()->SetInfo(uiDownloadSizeTotal);
GetTransferBox()->DoPulse();

// Call onClientTransferBoxProgressChange if client allows control over it
if (bAllowTransferBoxControl)
{
CLuaArguments Arguments;
Arguments.PushNumber(uiDownloadSizeTotal);
Arguments.PushNumber(GetTransferBox()->GetTotalSize());
g_pClientGame->GetLocalPlayer()->CallEvent("onClientTransferBoxProgressChange", Arguments, false);
}

// Check if completed downloading current group
if (m_ActiveFileDownloadList.empty())
{
Expand Down Expand Up @@ -228,7 +244,7 @@ bool CResourceFileDownloadManager::BeginResourceFileDownload(CDownloadableResour
options.bIsLocal = g_pClientGame->IsLocalGame();
SString* pstrContext = MakeDownloadContextString(pResourceFile);
SString strFilename = pResourceFile->GetName();
bool bUniqueDownload = pHTTP->QueueFile(strHTTPDownloadURLFull, strFilename, pstrContext, StaticDownloadFinished, options);
bool bUniqueDownload = pHTTP->QueueFile(strHTTPDownloadURLFull, strFilename, pstrContext, StaticDownloadFinished, options);
if (!bUniqueDownload)
{
// TODO - If piggybacking on another matching download, then adjust progress bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CResourceFileDownloadManager
void DownloadFinished(const SHttpDownloadResult& result);
SString* MakeDownloadContextString(CDownloadableResource* pDownloadableResource);
CDownloadableResource* ResolveDownloadContextString(SString* pString);
double GetTotalSize() const { return g_pClientGame->GetTransferBox()->GetTotalSize(); };

std::vector<CDownloadableResource*> m_PendingFileDownloadList;
std::vector<CDownloadableResource*> m_ActiveFileDownloadList;
Expand Down
35 changes: 24 additions & 11 deletions Client/mods/deathmatch/logic/CTransferBox.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/logic/CTransferBox.cpp
* PURPOSE: Transfer box GUI
Expand All @@ -11,11 +11,11 @@

#include <StdInc.h>

#define TRANSFERBOX_HEIGHT 58
#define TRANSFERBOX_ICONSIZE 20
#define TRANSFERBOX_PROGRESSHEIGHT 28
#define TRANSFERBOX_YSTART 20
#define TRANSFERBOX_SPACER 11
#define TRANSFERBOX_HEIGHT 58
#define TRANSFERBOX_ICONSIZE 20
#define TRANSFERBOX_PROGRESSHEIGHT 28
#define TRANSFERBOX_YSTART 20
#define TRANSFERBOX_SPACER 11

CTransferBox::CTransferBox()
{
Expand Down Expand Up @@ -83,20 +83,23 @@ CTransferBox::CTransferBox()
CTransferBox::~CTransferBox()
{
for (unsigned int i = 0; i < TRANSFERBOX_FRAMES; i++)
{
delete m_pIcon[i];
}

if (m_pWindow != NULL)
if (m_pWindow != nullptr)
delete m_pWindow;
if (m_pInfo != NULL)

if (m_pInfo != nullptr)
delete m_pInfo;
if (m_pProgress != NULL)

if (m_pProgress != nullptr)
delete m_pProgress;
}

void CTransferBox::Show()
{
if (!IsEnabled())
return;

m_pWindow->SetVisible(true);
g_pCore->GetGUI()->SetTransferBoxVisible(true);
}
Expand All @@ -109,6 +112,16 @@ void CTransferBox::Hide()
m_dTotalSize = 0;
}

bool CTransferBox::IsEnabled() const
{
return g_pCore->GetGUI()->IsTransferBoxEnabled();
}

void CTransferBox::SetEnabled(bool bEnabled) const
{
g_pCore->GetGUI()->SetTransferBoxEnabled(bEnabled);
}

void CTransferBox::SetInfo(double dDownloadSizeNow, CTransferBox::Type eTransferType)
{
// Convert to reasonable units
Expand Down
19 changes: 8 additions & 11 deletions Client/mods/deathmatch/logic/CTransferBox.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/logic/CTransferBox.h
* PURPOSE: Header for transfer box class
Expand All @@ -11,11 +11,8 @@

#pragma once

#define TRANSFERBOX_FRAMES 10
#define TRANSFERBOX_DELAY 50

#include "CClientCommon.h"
#include <gui/CGUI.h>
#define TRANSFERBOX_FRAMES 10
#define TRANSFERBOX_DELAY 50

class CTransferBox
{
Expand All @@ -34,14 +31,14 @@ class CTransferBox
void Hide();

void SetInfo(double dDownloadSizeNow, CTransferBox::Type eTransferType = CTransferBox::NORMAL);

void DoPulse();
bool IsVisible() const { return m_pWindow->IsVisible(); };

bool OnCancelClick(CGUIElement* pElement);

bool IsVisible() { return m_pWindow->IsVisible(); };
bool IsEnabled() const;
void SetEnabled(bool bEnabled) const;

void AddToTotalSize(double dSize) { m_dTotalSize += dSize; };
void AddToTotalSize(double dSize) { m_dTotalSize += dSize; };
double GetTotalSize() const { return m_dTotalSize; };

private:
CGUIWindow* m_pWindow;
Expand Down
21 changes: 21 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaGUIDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*****************************************************************************/

#include "StdInc.h"
#include "lua/CLuaFunctionParser.h"

static const SFixedArray<const char*, MAX_CHATBOX_LAYOUT_CVARS> g_chatboxLayoutCVars = {{
"chat_font",
Expand Down Expand Up @@ -49,6 +50,8 @@ void CLuaGUIDefs::LoadFunctions()
{"isMainMenuActive", GUIIsMainMenuActive},
{"isMTAWindowActive", GUIIsMTAWindowActive},
{"isTransferBoxActive", GUIIsTransferBoxActive},
{"isTransferBoxEnabled", ArgumentParser<GUIIsTransferBoxEnabled>},
{"setTransferBoxEnabled", ArgumentParser<GUISetTransferBoxEnabled>},

{"guiCreateWindow", GUICreateWindow},
{"guiCreateLabel", GUICreateLabel},
Expand Down Expand Up @@ -4061,3 +4064,21 @@ int CLuaGUIDefs::GUIGetCursorType(lua_State* luaVM)
lua_pushstring(luaVM, EnumToString(eType));
return 1;
}

bool CLuaGUIDefs::GUISetTransferBoxEnabled(bool bEnabled)
{
bool bAllowed = false;
g_pCore->GetCVars()->Get("allow_server_control_transferbox", bAllowed);
if (bAllowed && bEnabled != g_pClientGame->GetTransferBox()->IsEnabled())
{
g_pClientGame->GetTransferBox()->SetEnabled(bEnabled);
return true;
}

return false;
}

bool CLuaGUIDefs::GUIIsTransferBoxEnabled()
{
return g_pClientGame->GetTransferBox()->IsEnabled();
}
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaGUIDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class CLuaGUIDefs : public CLuaDefs
LUA_DECLARE(GUIComboBoxIsOpen);
LUA_DECLARE(GUIGetCursorType);

static bool GUIIsTransferBoxEnabled();
static bool GUISetTransferBoxEnabled(bool bEnabled);

private:
static void AddGuiElementClass(lua_State* luaVM);
static void AddGuiFontClass(lua_State* luaVM);
Expand Down
19 changes: 11 additions & 8 deletions Client/sdk/gui/CGUI.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: sdk/gui/CGUI.h
* PURPOSE: Graphical User Interface module interface
Expand Down Expand Up @@ -38,14 +38,14 @@ class CGUI;
#include "CGUITypes.h"

// Path defines for CGUI
#define CGUI_ICON_MESSAGEBOX_INFO "cgui\\images\\info.png"
#define CGUI_ICON_MESSAGEBOX_QUESTION "cgui\\images\\question.png"
#define CGUI_ICON_MESSAGEBOX_WARNING "cgui\\images\\warning.png"
#define CGUI_ICON_MESSAGEBOX_ERROR "cgui\\images\\error.png"
#define CGUI_ICON_SERVER_PASSWORD "cgui\\images\\locked.png"
#define CGUI_ICON_MESSAGEBOX_INFO "cgui\\images\\info.png"
#define CGUI_ICON_MESSAGEBOX_QUESTION "cgui\\images\\question.png"
#define CGUI_ICON_MESSAGEBOX_WARNING "cgui\\images\\warning.png"
#define CGUI_ICON_MESSAGEBOX_ERROR "cgui\\images\\error.png"
#define CGUI_ICON_SERVER_PASSWORD "cgui\\images\\locked.png"
#define CGUI_GetMaxTextExtent(...) GetMaxTextExtent(__VA_ARGS__, SString())

#define CHECK_CHANNEL(channel) assert ( (channel) >= 0 && (channel) < INPUT_CHANNEL_COUNT )
#define CHECK_CHANNEL(channel) assert((channel) >= 0 && (channel) < INPUT_CHANNEL_COUNT)

class CGUI
{
Expand Down Expand Up @@ -164,9 +164,12 @@ class CGUI
virtual void ClearInputHandlers(eInputChannel channel) = 0;
virtual void ClearSystemKeys() = 0;

virtual bool IsTransferBoxVisible() = 0;
virtual bool IsTransferBoxVisible() const = 0;
virtual void SetTransferBoxVisible(bool bVisible) = 0;

virtual bool IsTransferBoxEnabled() const = 0;
virtual void SetTransferBoxEnabled(bool bEnabled) = 0;

virtual void CleanDeadPool() = 0;

virtual CGUIWindow* LoadLayout(CGUIElement* pParent, const SString& strFilename) = 0;
Expand Down