[LYN-3319] Removed some unused Editor dialogs.

This commit is contained in:
Chris Galvan
2021-04-28 11:23:40 -05:00
parent 167b7f36a6
commit 28b5a1427c
10 changed files with 0 additions and 789 deletions
@@ -1,51 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "DuplicatedObjectsHandlerDlg.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <Dialogs/ui_DuplicatedObjectsHandlerDlg.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
CDuplicatedObjectsHandlerDlg::CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent)
: QDialog(pParent)
, m_ui(new Ui::DuplicatedObjectsHandlerDlg)
{
m_ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
m_ui->textBrowser->setPlainText(msg);
connect(m_ui->buttonOverride, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn);
connect(m_ui->buttonCreateCopies, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn);
}
CDuplicatedObjectsHandlerDlg::~CDuplicatedObjectsHandlerDlg()
{
}
void CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn()
{
m_result = eResult_Override;
accept();
}
void CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn()
{
m_result = eResult_CreateCopies;
accept();
}
#include <Dialogs/moc_DuplicatedObjectsHandlerDlg.cpp>
@@ -1,57 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
#define CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QDialog>
#endif
namespace Ui
{
class DuplicatedObjectsHandlerDlg;
}
class CDuplicatedObjectsHandlerDlg
: public QDialog
{
Q_OBJECT
public:
CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent = nullptr);
virtual ~CDuplicatedObjectsHandlerDlg();
enum EResult
{
eResult_None,
eResult_Override,
eResult_CreateCopies
};
EResult GetResult() const
{
return m_result;
}
protected:
EResult m_result;
void OnBnClickedOverrideBtn();
void OnBnClickedCreateCopiesBtn();
QScopedPointer<Ui::DuplicatedObjectsHandlerDlg> m_ui;
};
#endif // CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DuplicatedObjectsHandlerDlg</class>
<widget class="QDialog" name="DuplicatedObjectsHandlerDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>204</height>
</rect>
</property>
<property name="windowTitle">
<string>Duplicated Objects Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonOverride">
<property name="text">
<string>Override</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCreateCopies">
<property name="text">
<string>Create Copies</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>DuplicatedObjectsHandlerDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>258</x>
<y>183</y>
</hint>
<hint type="destinationlabel">
<x>190</x>
<y>184</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -1,218 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "EditorDefs.h"
#include "NewEntityDialog.h"
// Qt
#include <QPushButton>
#include <QToolTip>
#include <QMessageBox>
// Editor
#include "Dialogs/QT/ui_NewEntityDialog.h"
NewEntityDialog::NewEntityDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::NewEntityDialog)
{
entityNameValidator = new EntityNameValidator(this);
ui->setupUi(this);
ui->entityName->setFocus();
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
connect(ui->entityName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
connect(ui->categoryName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
SetCategoryCompleterPath((Path::GetEditingGameDataFolder() + "/Scripts/Entities").c_str());
SetNameValidatorPath((Path::GetEditingGameDataFolder() + "/Entities").c_str());
}
NewEntityDialog::~NewEntityDialog()
{
SAFE_DELETE(entityNameValidator);
SAFE_DELETE(folderNameCompleter);
delete ui;
}
void NewEntityDialog::SetCategoryCompleterPath(CryStringT<char> path)
{
SAFE_DELETE(folderNameCompleter);
QDirIterator directoryIt(QString::fromLocal8Bit(path.c_str(), path.length()), QDir::NoDotAndDotDot | QDir::AllDirs, QDirIterator::Subdirectories);
baseDir = directoryIt.path() + "/";
QStringList dirs;
while (directoryIt.hasNext())
{
QString dir = directoryIt.next().remove(baseDir);
dirs.append(dir);
}
folderNameCompleter = new QCompleter(dirs);
folderNameCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
folderNameCompleter->setCaseSensitivity(Qt::CaseInsensitive);
ui->categoryName->setCompleter(folderNameCompleter);
}
void NewEntityDialog::SetNameValidatorPath(CryStringT<char> path)
{
QDir dir(QString::fromLocal8Bit(path.c_str(), path.length()));
nameBaseDir = dir.path() + "/";
}
void NewEntityDialog::ValidateInput()
{
int cursorPos = ui->entityName->cursorPosition();
QString text = ui->entityName->text();
bool validText = entityNameValidator->validate(text, cursorPos);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(validText);
}
void NewEntityDialog::accept()
{
if (ui->categoryName->text().isEmpty()
&& QMessageBox::question(this, "Are you sure?", "Create entity without category?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
return;
}
const char* devRoot = gEnv->pFileIO->GetAlias("@engroot@");
QString devRootPath(devRoot);
QFile entTemplateFile(devRootPath + "/Editor/NewEntityTemplate.ent_template");
QFile luaTemplateFile(devRootPath + "/Editor/NewEntityTemplate.lua_template");
QFile entDestFile(nameBaseDir + ui->entityName->text() + ".ent");
QFile luaDestFile(baseDir + ui->categoryName->text() + "/" + ui->entityName->text() + ".lua");
if (!entTemplateFile.exists() || !luaTemplateFile.exists())
{
QMessageBox::critical(this, tr("Missing Template Files"), tr("In order to create default entities the NewEntityTemplate.lua and NewEntityTemplate.ent template files must exist in the Templates folder!"));
return;
}
//generate the .ent file
QDir pathMaker(nameBaseDir);
pathMaker.mkpath(pathMaker.path());
QString entFileString;
if (!entTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open template file for ent : %s", entTemplateFile.fileName().toUtf8().constData());
return;
}
else
{
entFileString = entTemplateFile.readAll();
entTemplateFile.close();
}
entFileString.replace(QString("[CATEGORY_NAME]"), ui->categoryName->text());
entFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
if (!entDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open destination file for ent : %s", entDestFile.fileName().toUtf8().constData());
return;
}
else
{
entDestFile.write(entFileString.toUtf8());
entDestFile.close();
}
//generate the .lua file
pathMaker.setPath(baseDir);
pathMaker.mkpath(ui->categoryName->text() + "/");
QString luaFileString;
if (!luaTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open template file for lua : %s", luaTemplateFile.fileName().toUtf8().constData());
return;
}
else
{
luaFileString = luaTemplateFile.readAll();
luaTemplateFile.close();
}
luaFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
if (!luaDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open destination file for lua : %s", luaDestFile.fileName().toUtf8().constData());
return;
}
else
{
luaDestFile.write(luaFileString.toUtf8());
luaDestFile.close();
}
if (ui->openLuaCB->isChecked())
{
CFileUtil::EditTextFile(luaDestFile.fileName().toLocal8Bit().data());
}
QDialog::accept();
}
QValidator::State NewEntityDialog::EntityNameValidator::validate(QString& input, [[maybe_unused]] int& pos) const
{
if (!m_Parent)
{
return Invalid;
}
if (input.isEmpty())
{
return Invalid;
}
if (input.contains("/"))
{
return Invalid;
}
QString fileBaseName = m_Parent->ui->entityName->text();
// Characters
const char* notAllowedChars = ",^@=+{}[]~!?:&*\"|#%<>$\"'();`' ";
for (const char* c = notAllowedChars; *c; c++)
{
if (fileBaseName.contains(QLatin1Char(*c)))
{
const QChar qc = QLatin1Char(*c);
if (qc.isSpace())
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Name may not contain white space."), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
}
else
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Invalid character \"%1\".").arg(qc), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
}
return Invalid;
}
}
QString filename(m_Parent->nameBaseDir + m_Parent->ui->entityName->text() + ".ent");
QFile newFile(filename);
if (newFile.exists())
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Filename already exists!"), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
return Invalid;
}
return Acceptable;
}
#include <Dialogs/QT/moc_NewEntityDialog.cpp>
@@ -1,69 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef NEWENTITYDIALOG_H
#define NEWENTITYDIALOG_H
#if !defined(Q_MOC_RUN)
#include <QDialog>
#include <QCompleter>
#include <QDirIterator>
#include <QStringListModel>
#include <QValidator>
#include <QEvent>
#include <QLineEdit>
#endif
namespace Ui {
class NewEntityDialog;
}
class NewEntityDialog
: public QDialog
{
Q_OBJECT
public:
explicit NewEntityDialog(QWidget* parent = 0);
~NewEntityDialog();
private:
Ui::NewEntityDialog* ui;
QString baseDir = "";
QString nameBaseDir = "";
QCompleter* folderNameCompleter = NULL;
void SetCategoryCompleterPath(CryStringT<char> path);
void SetNameValidatorPath(CryStringT<char> path);
virtual void accept();
class EntityNameValidator
: public QValidator
{
public:
explicit EntityNameValidator(NewEntityDialog* parent = 0)
: QValidator(parent)
, m_Parent(parent)
{
}
virtual State validate(QString& input, int& pos) const;
NewEntityDialog* m_Parent;
};
EntityNameValidator* entityNameValidator;
public slots:
void ValidateInput();
};
#endif // NEWENTITYDIALOG_H
@@ -1,161 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewEntityDialog</class>
<widget class="QDialog" name="NewEntityDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>111</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::PreventContextMenu</enum>
</property>
<property name="windowTitle">
<string>New Entity</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>false</bool>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLineEdit" name="entityName">
<property name="geometry">
<rect>
<x>110</x>
<y>10</y>
<width>281</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Entity Name:</string>
</property>
<property name="buddy">
<cstring>entityName</cstring>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Entity Category:</string>
</property>
<property name="buddy">
<cstring>categoryName</cstring>
</property>
</widget>
<widget class="QLineEdit" name="categoryName">
<property name="geometry">
<rect>
<x>110</x>
<y>40</y>
<width>281</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="openLuaCB">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>141</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Open Lua After Creating</string>
</property>
</widget>
</widget>
<tabstops>
<tabstop>entityName</tabstop>
<tabstop>categoryName</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NewEntityDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NewEntityDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>