a5d4eb5d44
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>
112 lines
5.1 KiB
C++
112 lines
5.1 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
|
|
|
|
#include <AzCore/std/containers/unordered_set.h>
|
|
#include <AzCore/std/containers/vector.h>
|
|
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
|
#include <AzCore/std/string/string.h>
|
|
|
|
#include <AzCore/Outcome/Outcome.h>
|
|
#include <AzFramework/Platform/PlatformDefaults.h>
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QModelIndex>
|
|
#include <QSet>
|
|
#include <QString>
|
|
|
|
|
|
namespace AssetBundler
|
|
{
|
|
|
|
extern const char* DateTimeFormat;
|
|
|
|
//! Provides an abstract model that can be subclassed to create table models used to store information about files found on-disk.
|
|
class AssetBundlerAbstractFileTableModel
|
|
: public QAbstractTableModel
|
|
{
|
|
public:
|
|
|
|
enum DataRoles
|
|
{
|
|
SortRole = Qt::UserRole + 1,
|
|
};
|
|
|
|
explicit AssetBundlerAbstractFileTableModel(QObject* parent = nullptr);
|
|
virtual ~AssetBundlerAbstractFileTableModel() {}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Pure virtual functions
|
|
virtual AZStd::vector<AZStd::string> CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& platforms, const QString& project = QString()) = 0;
|
|
virtual bool DeleteFile(const QModelIndex& index) = 0;
|
|
virtual void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) = 0;
|
|
virtual bool WriteToDisk(const AZStd::string& key) = 0;
|
|
|
|
//! Returns the absolute path of the file at the given index on success, returns an empty string on failure.
|
|
virtual AZStd::string GetFileAbsolutePath(const QModelIndex& index) const = 0;
|
|
|
|
virtual int GetFileNameColumnIndex() const = 0;
|
|
virtual int GetTimeStampColumnIndex() const = 0;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//! Reload all the data based on the watched folders and files
|
|
virtual void Reload(const char* fileExtension, const QSet<QString>& watchedFolders, const QSet<QString>& watchedFiles = QSet<QString>(), const AZStd::unordered_map<AZStd::string, AZStd::string>& pathToProjectNameMap = AZStd::unordered_map<AZStd::string, AZStd::string>());
|
|
|
|
virtual void ReloadFiles(const AZStd::vector<AZStd::string>& absoluteFilePathList, AZStd::unordered_map<AZStd::string, AZStd::string> pathToProjectNameMap = AZStd::unordered_map<AZStd::string, AZStd::string>());
|
|
|
|
bool Save(const QModelIndex& selectedIndex);
|
|
|
|
bool SaveAll();
|
|
|
|
bool HasUnsavedChanges() const;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// QAbstractTableModel overrides
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
protected:
|
|
//! Verifies input index is in range and returns the associated key.
|
|
//! Throws an error and returns an empty string if the input index is out of range.
|
|
AZStd::string GetFileKey(const QModelIndex& index) const;
|
|
|
|
//! Returns an ordered list of every file key in the model.
|
|
//! If a proxy model is not used, the order of this list will also be the display order.
|
|
const AZStd::vector<AZStd::string>& GetAllFileKeys() const;
|
|
|
|
//! Get the index row if the file info is stored in the model
|
|
//! Returns -1 if the file key doesn't exist.
|
|
int GetIndexRowByKey(const AZStd::string& key) const;
|
|
|
|
//! Adds input key to the end of the list of all keys and notifies the view that a row has been added.
|
|
//! When subclassing, instantiate all data associated with this key so the view can update properly.
|
|
void AddFileKey(const AZStd::string& key);
|
|
|
|
//! Verifies input index, signals to the view that rows will be removed, and removes the key found at the input index.
|
|
//! When subclassing, be sure to remove all data associated with the key at this index before calling this function.
|
|
//! Returns true if the index is successfully removed, and false on failure
|
|
bool RemoveFileKey(const QModelIndex& index);
|
|
|
|
//! Delete a file from the disk and remove it from the model by its key
|
|
bool DeleteFileByKey(const AZStd::string& key);
|
|
|
|
AZStd::unordered_set<AZStd::string> m_keysWithUnsavedChanges;
|
|
|
|
private:
|
|
//! When subclassing: store file information in a map, and add the keys to this vector.
|
|
//! Provides a 1:1 mapping between a QModelIndex::row value and a key.
|
|
AZStd::vector<AZStd::string> m_fileListKeys;
|
|
};
|
|
|
|
} // namespace AssetBundler
|