git mv Code\Sandbox\Plugins Code/Editor/Plugins
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
if(NOT PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) # For PAL_TRAIT_BUILD_P4PLUGIN_SUPPORTED
|
||||
|
||||
if(NOT PAL_TRAIT_BUILD_P4PLUGIN_SUPPORTED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
ly_add_target(
|
||||
NAME PerforcePlugin MODULE
|
||||
NAMESPACE Legacy
|
||||
OUTPUT_SUBDIRECTORY EditorPlugins
|
||||
AUTOMOC
|
||||
AUTOUIC
|
||||
FILES_CMAKE
|
||||
perforceplugin_files.cmake
|
||||
COMPILE_DEFINITIONS
|
||||
PRIVATE
|
||||
PLUGIN_EXPORTS
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
.
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
Legacy::CryCommon
|
||||
Legacy::EditorLib
|
||||
)
|
||||
|
||||
ly_add_dependencies(Editor PerforcePlugin)
|
||||
set_property(GLOBAL APPEND PROPERTY LY_EDITOR_PLUGINS $<TARGET_FILE_NAME:Legacy::PerforcePlugin>)
|
||||
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "PerforcePlugin_precompiled.h"
|
||||
#include "PerforcePlugin.h"
|
||||
#include "PasswordDlg.h"
|
||||
#include <ui_settings.h> // generated
|
||||
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/CheckBox.h>
|
||||
#include <AzToolsFramework/UI/UICore/ProgressShield.hxx>
|
||||
|
||||
#include <QTimer>
|
||||
#include <AzCore/std/bind/bind.h>
|
||||
|
||||
namespace PerforceConnection
|
||||
{
|
||||
const char* const PerforceUser = "P4USER";
|
||||
const char* const PerforceServer = "P4PORT";
|
||||
const char* const PerforceClient = "P4CLIENT";
|
||||
const char* const PerforceCharset = "P4CHARSET";
|
||||
|
||||
using namespace AzToolsFramework;
|
||||
PerforceConfigDialog::PerforceConfigDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
this->setWindowFlags(Qt::Dialog
|
||||
| Qt::MSWindowsFixedSizeDialogHint
|
||||
| Qt::WindowStaysOnTopHint);
|
||||
m_ui = new Ui::P4SettingsDialog();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
SourceControlState state = SourceControlState::Disabled;
|
||||
SourceControlConnectionRequestBus::BroadcastResult(state, &SourceControlConnectionRequestBus::Events::GetSourceControlState);
|
||||
|
||||
bool onlineMode = state == SourceControlState::Disabled ? false : true;
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(m_ui->workOnlineCheckbox);
|
||||
m_ui->workOnlineCheckbox->setChecked(onlineMode);
|
||||
}
|
||||
}
|
||||
|
||||
void PerforceConfigDialog::RetrieveSettings()
|
||||
{
|
||||
m_retrievedSettings.insert_key(PerforceClient);
|
||||
m_retrievedSettings.insert_key(PerforceUser);
|
||||
m_retrievedSettings.insert_key(PerforceServer);
|
||||
m_retrievedSettings.insert_key(PerforceCharset);
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
int numSettingsToGet = m_retrievedSettings.size();
|
||||
|
||||
auto applySettingResultFunction = [this, &numSettingsToGet](AZStd::string setting, const SourceControlSettingInfo& info) -> void
|
||||
{
|
||||
m_retrievedSettings[setting] = info;
|
||||
--numSettingsToGet;
|
||||
};
|
||||
|
||||
using SCRequestBus = AzToolsFramework::SourceControlConnectionRequestBus;
|
||||
for (const auto& kvp : m_retrievedSettings)
|
||||
{
|
||||
auto boundLocal = AZStd::bind<void>(applySettingResultFunction, kvp.first.c_str(), AZStd::placeholders::_1);
|
||||
SCRequestBus::Broadcast(&SCRequestBus::Events::GetConnectionSetting, kvp.first.c_str(), boundLocal);
|
||||
}
|
||||
|
||||
auto waitForAllSettings = [&numSettingsToGet](int&, int&)
|
||||
{
|
||||
return numSettingsToGet == 0;
|
||||
};
|
||||
// Wait for completion
|
||||
ProgressShield::LegacyShowAndWait(this, tr("Getting settings"), waitForAllSettings);
|
||||
|
||||
// wrinkle in the plan - charset might have (SERVER)charset applied to it. So ask for one more.
|
||||
m_charsetKey = PerforceCharset;
|
||||
if (m_retrievedSettings[PerforceServer].IsAvailable())
|
||||
{
|
||||
AZStd::string charsetNameWithServerAddress = AZStd::string::format("P4_%s_CHARSET", m_retrievedSettings[PerforceServer].m_value.c_str());
|
||||
// ask for one more
|
||||
numSettingsToGet = 1;
|
||||
auto boundLocal = AZStd::bind<void>(applySettingResultFunction, charsetNameWithServerAddress.c_str(), AZStd::placeholders::_1);
|
||||
SCRequestBus::Broadcast(&SCRequestBus::Events::GetConnectionSetting, charsetNameWithServerAddress.c_str(), boundLocal);
|
||||
ProgressShield::LegacyShowAndWait(this, tr("Getting settings"), waitForAllSettings);
|
||||
|
||||
// did we get a value?
|
||||
if (m_retrievedSettings[charsetNameWithServerAddress].IsAvailable())
|
||||
{
|
||||
m_charsetKey = charsetNameWithServerAddress;
|
||||
}
|
||||
}
|
||||
|
||||
// which CHARSET do we pick? we prefer (servername) charset, but will fall back to just P4CHARSET
|
||||
for (const auto& value : m_retrievedSettings)
|
||||
{
|
||||
const AZStd::string& settingName = value.first;
|
||||
const SourceControlSettingInfo& info = value.second;
|
||||
ApplyValueToControl(GetControlForSetting(settingName), info);
|
||||
}
|
||||
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
QLineEdit* PerforceConfigDialog::GetControlForSetting(const AZStd::string& settingName) const
|
||||
{
|
||||
if (settingName == PerforceClient)
|
||||
{
|
||||
return m_ui->workspaceEdit;
|
||||
}
|
||||
else if (settingName == PerforceUser)
|
||||
{
|
||||
return m_ui->userEdit;
|
||||
}
|
||||
else if (settingName == PerforceServer)
|
||||
{
|
||||
return m_ui->serverEdit;
|
||||
}
|
||||
else if (settingName == m_charsetKey)
|
||||
{
|
||||
return m_ui->charsetEdit;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PerforceConfigDialog::~PerforceConfigDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void PerforceConfigDialog::ApplyValueToControl(QLineEdit* targetControl, const SourceControlSettingInfo& value)
|
||||
{
|
||||
if (targetControl)
|
||||
{
|
||||
if (value.IsAvailable())
|
||||
{
|
||||
targetControl->setText(QString::fromUtf8(value.m_value.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
targetControl->setText(QString(""));
|
||||
}
|
||||
|
||||
if (value.IsSettable())
|
||||
{
|
||||
targetControl->setReadOnly(false);
|
||||
targetControl->setEnabled(true);
|
||||
targetControl->setToolTip("");
|
||||
}
|
||||
else
|
||||
{
|
||||
targetControl->setReadOnly(true);
|
||||
targetControl->setEnabled(false);
|
||||
QString toolTip;
|
||||
QString ttDescStart("Cannot change this value - it is currently being overridden by");
|
||||
if (value.m_status == SourceControlSettingStatus::Config)
|
||||
{
|
||||
if (!value.m_context.empty())
|
||||
{
|
||||
toolTip = tr("%1 config file: %2.").arg(ttDescStart).arg(QString::fromUtf8(value.m_context.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTip = tr("%1 a config file.").arg(ttDescStart);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTip = tr("%1 your system environment. Please check your environment variables in your system's control panel").arg(ttDescStart);
|
||||
}
|
||||
targetControl->setToolTip(toolTip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PerforceConfigDialog::on_workOnlineCheckbox_toggled(bool newState)
|
||||
{
|
||||
m_ui->workspaceEdit->setEnabled(false);
|
||||
m_ui->userEdit->setEnabled(false);
|
||||
m_ui->serverEdit->setEnabled(false);
|
||||
m_ui->charsetEdit->setEnabled(false);
|
||||
|
||||
if (newState)
|
||||
{
|
||||
// we only fetch settings if we are working online.
|
||||
QTimer::singleShot(0, this, &PerforceConfigDialog::RetrieveSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->workspaceEdit->setText(tr("(offline)"));
|
||||
m_ui->userEdit->setText(tr("(offline)"));
|
||||
m_ui->serverEdit->setText(tr("(offline)"));
|
||||
m_ui->charsetEdit->setText(tr("(offline)"));
|
||||
}
|
||||
}
|
||||
|
||||
void PerforceConfigDialog::Apply()
|
||||
{
|
||||
bool onlineMode = m_ui->workOnlineCheckbox->isChecked();
|
||||
{
|
||||
using SCRequestBus = AzToolsFramework::SourceControlConnectionRequestBus;
|
||||
SCRequestBus::Broadcast(&SCRequestBus::Events::EnableSourceControl, onlineMode);
|
||||
}
|
||||
|
||||
if (onlineMode)
|
||||
{
|
||||
// work online!
|
||||
// apply all the settings.
|
||||
// you may only apply some of the settings - the ones that are either 'set' or 'unset'
|
||||
// only set values that are not already that value
|
||||
// and charset is special in that you must set it as eitehr CHARSET or override the server.
|
||||
ApplySetting(PerforceUser);
|
||||
ApplySetting(PerforceServer);
|
||||
ApplySetting(PerforceClient);
|
||||
ApplySetting(m_charsetKey.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool PerforceConfigDialog::ApplySetting(const char* key)
|
||||
{
|
||||
if (!m_retrievedSettings[key].IsSettable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QLineEdit* source = GetControlForSetting(key);
|
||||
if (!source)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string newValue = source->text().toUtf8().data();
|
||||
if (newValue.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newValue == m_retrievedSettings[key].m_value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// again, charset is special in that it can under certain circumstances take the form P4_SERVERNAME_CHARSET instead of just P4CHARSET
|
||||
|
||||
if (m_charsetKey == key)
|
||||
{
|
||||
// if its already P4CHARSET then we don't care.
|
||||
if (m_charsetKey != PerforceCharset)
|
||||
{
|
||||
QLineEdit* hostSource = GetControlForSetting(PerforceServer);
|
||||
if (!hostSource)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_charsetKey = AZStd::string::format("P4_%s_CHARSET", hostSource->text().toUtf8().data());
|
||||
key = m_charsetKey.c_str();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool succeeded = false;
|
||||
bool complete = false;
|
||||
auto respCallback = [&succeeded, &complete, newValue](const SourceControlSettingInfo& info)
|
||||
{
|
||||
succeeded = (info.m_value == newValue);
|
||||
complete = true;
|
||||
};
|
||||
|
||||
auto waitForDone = [&complete](int&, int&)
|
||||
{
|
||||
return complete;
|
||||
};
|
||||
|
||||
using SCRequestBus = AzToolsFramework::SourceControlConnectionRequestBus;
|
||||
SCRequestBus::Broadcast(&SCRequestBus::Events::SetConnectionSetting, key, newValue.c_str(), respCallback);
|
||||
ProgressShield::LegacyShowAndWait(this, tr("Applying settings"), waitForDone);
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
bool OpenPasswordDlg()
|
||||
{
|
||||
PerforceConfigDialog dialog;
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
dialog.Apply();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace PerforceConnection
|
||||
|
||||
#include <moc_PasswordDlg.cpp>
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <AzToolsFramework/SourceControl/SourceControlAPI.h> // for SouceControlSettingInfo
|
||||
#endif
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
namespace Ui {
|
||||
class P4SettingsDialog;
|
||||
} // namespace Ui
|
||||
|
||||
namespace PerforceConnection
|
||||
{
|
||||
class PerforceConfigDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PerforceConfigDialog(QWidget* pParent = nullptr);
|
||||
virtual ~PerforceConfigDialog();
|
||||
|
||||
bool GetWorkOffline() const;
|
||||
void SetWorkOffline(bool value);
|
||||
|
||||
public Q_SLOTS:
|
||||
void RetrieveSettings();
|
||||
// auto-bound slots
|
||||
void on_workOnlineCheckbox_toggled(bool newState);
|
||||
|
||||
void Apply();
|
||||
|
||||
private:
|
||||
Ui::P4SettingsDialog* m_ui;
|
||||
|
||||
AZStd::unordered_map<AZStd::string, AzToolsFramework::SourceControlSettingInfo> m_retrievedSettings;
|
||||
AZStd::string m_charsetKey;
|
||||
|
||||
void ApplyValueToControl(QLineEdit* targetControl, const AzToolsFramework::SourceControlSettingInfo& value);
|
||||
bool ApplySetting(const char* key);
|
||||
QLineEdit* GetControlForSetting(const AZStd::string& settingName) const;
|
||||
};
|
||||
|
||||
bool OpenPasswordDlg();
|
||||
} // namespace PerforceConnection
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "PerforcePlugin_precompiled.h"
|
||||
#include "PerforcePlugin.h"
|
||||
#include "PerforceSourceControl.h"
|
||||
#include "Include/ISourceControl.h"
|
||||
#include "Include/IEditorClassFactory.h"
|
||||
|
||||
extern CPerforceSourceControl* g_pPerforceControl;
|
||||
|
||||
namespace PluginInfo
|
||||
{
|
||||
const char* kName = "Perforce Client";
|
||||
const char* kGUID = "{FD5F1023-8F02-4051-89FA-DF1F038863A2}";
|
||||
const int kVersion = 1;
|
||||
}
|
||||
|
||||
void CPerforcePlugin::Release()
|
||||
{
|
||||
GetIEditor()->GetClassFactory()->UnregisterClass(g_pPerforceControl->ClassName().toUtf8().data());
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CPerforcePlugin::ShowAbout()
|
||||
{
|
||||
}
|
||||
|
||||
const char* CPerforcePlugin::GetPluginGUID()
|
||||
{
|
||||
return PluginInfo::kGUID;
|
||||
}
|
||||
|
||||
DWORD CPerforcePlugin::GetPluginVersion()
|
||||
{
|
||||
return PluginInfo::kVersion;
|
||||
}
|
||||
|
||||
const char* CPerforcePlugin::GetPluginName()
|
||||
{
|
||||
return PluginInfo::kName;
|
||||
}
|
||||
|
||||
bool CPerforcePlugin::CanExitNow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPerforcePlugin::Serialize([[maybe_unused]] FILE* hFile, [[maybe_unused]] bool bIsStoring)
|
||||
{
|
||||
}
|
||||
|
||||
void CPerforcePlugin::ResetContent()
|
||||
{
|
||||
}
|
||||
|
||||
bool CPerforcePlugin::CreateUIElements()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPerforcePlugin::OnEditorNotify(EEditorNotifyEvent aEventId)
|
||||
{
|
||||
if (eNotify_OnInit == aEventId)
|
||||
{
|
||||
g_pPerforceControl->Init();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_PERFORCEPLUGIN_PERFORCEPLUGIN_H
|
||||
#define CRYINCLUDE_PERFORCEPLUGIN_PERFORCEPLUGIN_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Include/IPlugin.h>
|
||||
|
||||
class CPerforcePlugin
|
||||
: public IPlugin
|
||||
{
|
||||
public:
|
||||
void Release();
|
||||
void ShowAbout();
|
||||
const char* GetPluginGUID();
|
||||
DWORD GetPluginVersion();
|
||||
const char* GetPluginName();
|
||||
bool CanExitNow();
|
||||
void Serialize(FILE* hFile, bool bIsStoring);
|
||||
void ResetContent();
|
||||
bool CreateUIElements();
|
||||
void OnEditorNotify(EEditorNotifyEvent aEventId);
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_PERFORCEPLUGIN_PERFORCEPLUGIN_H
|
||||
@@ -0,0 +1,4 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,71 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_P4 ICON "res\\p4.ico"
|
||||
IDI_P4_ERROR ICON "res\\p4_error.ico"
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/PlatformDef.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRY Stuff ////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#include <platform.h>
|
||||
#include "Util/EditorUtils.h"
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "PerforcePlugin_precompiled.h"
|
||||
#include "CryFile.h"
|
||||
#include "PerforceSourceControl.h"
|
||||
#include "PasswordDlg.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
|
||||
#include <Util/PathUtil.h>
|
||||
#include <AzCore/base.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
CryCriticalSection g_cPerforceValues;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
ULONG STDMETHODCALLTYPE CPerforceSourceControl::Release()
|
||||
{
|
||||
if ((--m_ref) == 0)
|
||||
{
|
||||
g_cPerforceValues.Lock();
|
||||
delete this;
|
||||
g_cPerforceValues.Unlock();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_ref;
|
||||
}
|
||||
}
|
||||
|
||||
void CPerforceSourceControl::Init()
|
||||
{
|
||||
UpdateSourceControlState();
|
||||
}
|
||||
|
||||
void CPerforceSourceControl::ShowSettings()
|
||||
{
|
||||
if (PerforceConnection::OpenPasswordDlg())
|
||||
{
|
||||
UpdateSourceControlState();
|
||||
}
|
||||
}
|
||||
|
||||
void CPerforceSourceControl::SetSourceControlState(SourceControlState state)
|
||||
{
|
||||
AUTO_LOCK(g_cPerforceValues);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case SourceControlState::Disabled:
|
||||
m_connectionState = ConnectivityState::Disconnected;
|
||||
break;
|
||||
|
||||
case SourceControlState::Active:
|
||||
m_connectionState = ConnectivityState::Connected;
|
||||
break;
|
||||
|
||||
case SourceControlState::ConfigurationInvalid:
|
||||
m_connectionState = ConnectivityState::BadConfiguration;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPerforceSourceControl::UpdateSourceControlState()
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
SourceControlState state = SourceControlState::Disabled;
|
||||
SourceControlConnectionRequestBus::BroadcastResult(state,
|
||||
&SourceControlConnectionRequestBus::Events::GetSourceControlState);
|
||||
|
||||
SetSourceControlState(state);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IEditorClassFactory.h"
|
||||
#include "Include/IEditorClassFactory.h"
|
||||
|
||||
#include "Include/ISourceControl.h"
|
||||
|
||||
|
||||
class CPerforceSourceControl
|
||||
: public ISourceControl
|
||||
, public IClassDesc
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CPerforceSourceControl() = default;
|
||||
virtual ~CPerforceSourceControl() = default;
|
||||
|
||||
void Init();
|
||||
|
||||
// ISourceControl
|
||||
void SetSourceControlState(SourceControlState state) override;
|
||||
ConnectivityState GetConnectivityState() override { return m_connectionState; };
|
||||
void ShowSettings() override;
|
||||
|
||||
// from IClassDesc
|
||||
virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_SCM_PROVIDER; };
|
||||
REFGUID ClassID()
|
||||
{
|
||||
// {3c209e66-0728-4d43-897d-168962d5c8b5}
|
||||
static const GUID guid = {
|
||||
0x3c209e66, 0x0728, 0x4d43, { 0x89, 0x7d, 0x16, 0x89, 0x62, 0xd5, 0xc8, 0xb5 }
|
||||
};
|
||||
return guid;
|
||||
}
|
||||
virtual QString ClassName() { return "Perforce source control"; };
|
||||
virtual QString Category() { return "SourceControl"; };
|
||||
virtual void ShowAbout() {};
|
||||
|
||||
// from IUnknown
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(const IID& riid, void** ppvObj)
|
||||
{
|
||||
if (riid == __uuidof(ISourceControl) /* && m_pIntegrator*/)
|
||||
{
|
||||
*ppvObj = this;
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE AddRef() { return ++m_ref; };
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
private:
|
||||
void UpdateSourceControlState();
|
||||
|
||||
ULONG m_ref{ 0 };
|
||||
ConnectivityState m_connectionState{ ConnectivityState::Disconnected };
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_BUILD_P4PLUGIN_SUPPORTED FALSE)
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_BUILD_P4PLUGIN_SUPPORTED TRUE)
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_BUILD_P4PLUGIN_SUPPORTED TRUE)
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "PerforcePlugin_precompiled.h"
|
||||
|
||||
#include "PerforcePlugin.h"
|
||||
|
||||
#include "Include/ISourceControl.h"
|
||||
#include "Include/IEditorClassFactory.h"
|
||||
#include "PerforceSourceControl.h"
|
||||
|
||||
#include <AzCore/PlatformDef.h>
|
||||
|
||||
CPerforceSourceControl* g_pPerforceControl = 0;
|
||||
|
||||
|
||||
PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam)
|
||||
{
|
||||
if (pInitParam->pluginVersion != SANDBOX_PLUGIN_SYSTEM_VERSION)
|
||||
{
|
||||
pInitParam->outErrorCode = IPlugin::eError_VersionMismatch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ModuleInitISystem(GetIEditor()->GetSystem(), "PerforcePlugin");
|
||||
g_pPerforceControl = new CPerforceSourceControl();
|
||||
pInitParam->pIEditorInterface->GetClassFactory()->RegisterClass(g_pPerforceControl);
|
||||
return new CPerforcePlugin();
|
||||
}
|
||||
|
||||
#ifdef AZ_PLATFORM_WINDOWS
|
||||
HINSTANCE g_hInstance = 0;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, ULONG fdwReason, [[maybe_unused]] LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hinstDLL;
|
||||
//DisableThreadLibraryCalls(hInstance);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
settings.ui
|
||||
main.cpp
|
||||
PasswordDlg.cpp
|
||||
PasswordDlg.h
|
||||
PerforcePlugin.cpp
|
||||
PerforcePlugin.h
|
||||
PerforcePlugin.qrc
|
||||
PerforceSourceControl.cpp
|
||||
PerforceSourceControl.h
|
||||
resource.h
|
||||
PerforcePlugin_precompiled.h
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define IDI_P4 104
|
||||
#define IDI_P4_ERROR 106
|
||||
#define IDC_ERROR 1004
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 107
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1010
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>P4SettingsDialog</class>
|
||||
<widget class="QDialog" name="P4SettingsDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>358</width>
|
||||
<height>160</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>358</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>358</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Perforce Settings</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="1,1,1,1,1" columnstretch="1,2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="userEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Charset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serverEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Workspace:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="workspaceEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>User:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="charsetEdit"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Work Online</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="workOnlineCheckbox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>serverEdit</tabstop>
|
||||
<tabstop>userEdit</tabstop>
|
||||
<tabstop>workspaceEdit</tabstop>
|
||||
<tabstop>charsetEdit</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>P4SettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>236</x>
|
||||
<y>202</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>P4SettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>304</x>
|
||||
<y>202</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user