Files
o3de/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.h
T
Zaladane a5d4eb5d44 Asset Bundler GUI (#427)
The AssetBundler is a new ToolsApplication that allows users to work through the entire Asset Bundling process without ever touching a command line.

* Integrating github/AssetBundler through commit 1d65018

* Asset Bundler bug fixes: platform initialization and GUI styling (#5)

* fixed enabled platform initialization

* fixed the cached engine root. This fixed some of my Seeds tab data issues. The default Engine Seed List appeared, and was able to display the contents on screen.

* updated my notes of active bugs

* changed some casing in various include lines to hopefully fix my linux build

* another include fix for linux

* AssetBundler GUI is now compiling on Mac

* removed some things off of my todo list because the mac build fix actually fixed the visuals! everything's the right color again

* removed the word Lumberyard from the bundler

* Asset bundler bug fixes - Bundles, Gems, and Tests (#9)

* Fixed the Bundle loading and generation problem. Turned out to be a FileWatcher issue.

* turns out gem loading wasn't broken, there were just no existing SeedListFiles for any of the gems loaded by the AutomatedTesting project. I added a default SeedListFile for the PrimitiveAssets Gem.

* fixed some failing AssetBundler Gem tests

* Misunderstood the need to have default seed lists for asset-only gems. removing the previously created seed list file

* Asset bundler bug fixes: Seeds Tab display issues and _dependencies.xml loading (#10)

* Fixed the Project Source column in the Seeds tab

* The AssetBundler will no longer attempt to copy a template version of the ProjectName_dependencies.xml file into your active project. However, it will throw an error if you do not have one. A follow-up ticket has been cut to address this issue.

* updated the AssetBundler icon. This one matches the current style guides

* PR feedback: pass a const ref instead of a value

* PR feedback: safer conversion from a string_view to a QString

Co-authored-by: alexpete <alexpete@amazon.com>
2021-04-30 15:42:10 -07:00

165 lines
5.6 KiB
C++

/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <source/utils/applicationManager.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/containers/vector.h>
#include <AzFramework/Asset/AssetCatalog.h>
#include <AzFramework/Platform/PlatformDefaults.h>
#include <QCoreApplication>
#include <QDir>
#include <QMap>
#include <QSettings>
#include <QSharedPointer>
#include <QString>
#include <QFileSystemWatcher>
#endif
namespace AssetBundler
{
enum AssetBundlingFileType : int
{
SeedListFileType = 0,
AssetListFileType,
BundleSettingsFileType,
BundleFileType,
RulesFileType,
NumBundlingFileTypes
};
class MainWindow;
class GUIApplicationManager
: public ApplicationManager
{
Q_OBJECT
public:
struct Config
{
// These default values are used if the values can't be read from AssetBundlerConfig.ini,
// and the call to defaultConfig fails.
// Error Log
int logTypeColumnWidth = -1;
int logSourceColumnWidth = -1;
// General File Tables
int fileTableWidth = -1;
int fileNameColumnWidth = -1;
// Seeds Tab
int checkBoxColumnWidth = -1;
int seedListFileNameColumnWidth = -1;
int projectNameColumnWidth = -1;
int seedListContentsNameColumnWidth = -1;
// Asset Lists Tab
int assetListFileNameColumnWidth = -1;
int assetListPlatformColumnWidth = -1;
int productAssetNameColumnWidth = -1;
int productAssetRelativePathColumnWidth = -1;
};
/*!
* Loads the button config data from a settings object.
*/
static Config loadConfig(QSettings& settings);
/*!
* Returns default button config data.
*/
static Config defaultConfig();
explicit GUIApplicationManager(int* argc, char*** argv, QObject* parent = 0);
virtual ~GUIApplicationManager();
bool Init() override;
bool Run() override;
AZStd::string GetCurrentProjectFolder() { return m_currentProjectFolder; }
AZStd::string GetAssetBundlingFolder() { return m_assetBundlingFolder; }
AZStd::string GetSeedListsFolder() { return m_seedListsFolder; }
AZStd::string GetAssetListsFolder() { return m_assetListsFolder; }
AZStd::string GetRulesFolder() { return m_rulesFolder; }
AZStd::string GetBundleSettingsFolder() { return m_bundleSettingsFolder; }
AZStd::string GetBundlesFolder() { return m_bundlesFolder; }
AZStd::string GetCurrentProjectCacheFolder() { return m_currentProjectCacheFolder; }
AzFramework::PlatformFlags GetEnabledPlatforms() { return m_enabledPlatforms; }
void AddWatchedPath(const QString& path);
void AddWatchedPaths(const QSet<QString>& paths);
void RemoveWatchedPath(const QString& path);
void RemoveWatchedPaths(const QSet<QString>& paths);
////////////////////////////////////////////////////////////////////////////////////////////
// Override the ApplicationManager TraceMessageBus methods so that messages go through MainWindow and not the CLI
bool OnPreError(const char* window, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* message) override;
bool OnPreWarning(const char* /*window*/, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* /*message*/) override;
bool OnPrintf(const char* /*window*/, const char* /*message*/) override;
////////////////////////////////////////////////////////////////////////////////////////////
const Config& GetConfig() { return m_config; }
Q_SIGNALS:
void ShowWindow();
void UpdateTab(const AZStd::string& directory);
void UpdateFiles(AssetBundlingFileType fileType, const AZStd::vector<AZStd::string>& absoluteFilePaths);
protected Q_SLOTS:
void DirectoryChanged(const QString& directory);
void FileChanged(const QString& path);
void ApplyConfig();
private:
/**
* Generates directory information for all paths used in this tool
* @return void on success, error message on failure
*/
AZ::Outcome<void, AZStd::string> InitializePaths();
QSharedPointer<QCoreApplication> m_qApp;
Config m_config;
QSharedPointer<MainWindow> m_mainWindow;
AZStd::string m_currentProjectFolder;
AZStd::string m_assetBundlingFolder;
AZStd::string m_seedListsFolder;
AZStd::string m_assetListsFolder;
AZStd::string m_rulesFolder;
AZStd::string m_bundleSettingsFolder;
AZStd::string m_bundlesFolder;
AZStd::string m_currentProjectCacheFolder;
AzFramework::PlatformFlags m_enabledPlatforms = AzFramework::PlatformFlags::Platform_NONE;
AZStd::unique_ptr<AzToolsFramework::PlatformAddressedAssetCatalogManager> m_platformCatalogManager;
bool m_isInitializing = false;
QFileSystemWatcher m_fileWatcher;
};
} // namespace AssetBundler