// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Common.h"
enum class PixelFormat : unsigned;
enum class DirectorySearchOption;
class TextureData;
///
/// Helper functions for the editor.
///
class EditorUtilities
{
public:
enum class ApplicationImageType
{
Icon,
SplashScreen,
};
///
/// Updates the Win32 executable file icon.
///
/// The exe path.
/// The icon image data.
/// True if fails, otherwise false.
static bool UpdateExeIcon(const String& path, const TextureData& icon);
static bool GetApplicationImage(const Guid& imageId, TextureData& imageData, ApplicationImageType type = ApplicationImageType::Icon);
static bool GetTexture(const Guid& textureId, TextureData& textureData);
static bool ExportApplicationImage(const Guid& iconId, int32 width, int32 height, PixelFormat format, const String& path, ApplicationImageType type = ApplicationImageType::Icon);
static bool ExportApplicationImage(const TextureData& icon, int32 width, int32 height, PixelFormat format, const String& path);
public:
static bool FindWDKBin(String& outputWdkBinPath);
static bool GenerateCertificate(const String& name, const String& outputPfxFilePath);
static bool GenerateCertificate(const String& name, const String& outputPfxFilePath, const String& outputCerFilePath, const String& outputPvkFilePath);
public:
///
/// Replaces the given text with other one in the files.
///
/// The relative or absolute path to the directory to search.
/// The search string to match against the names of files in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
/// One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.
/// The text to replace.
/// The value to replace to.
/// True if failed, otherwise false.
static bool ReplaceInFiles(const String& folderPath, const Char* searchPattern, DirectorySearchOption searchOption, const String& findWhat, const String& replaceWith);
///
/// Replaces the given text with other one in the file.
///
/// The file to process.
/// The text to replace.
/// The value to replace to.
/// True if failed, otherwise false.
static bool ReplaceInFile(const StringView& file, const StringView& findWhat, const StringView& replaceWith);
};