Add Win32 MessageBox

Add Prefab Manager
This commit is contained in:
Sri Sham Haran 2022-10-26 20:21:47 +08:00
parent 51489ecb3b
commit 1018454f2e
5 changed files with 150 additions and 62 deletions

View File

@ -1,62 +0,0 @@
[Window][MainStatusBar]
Pos=0,1060
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=1920,1012
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,142
Size=494,690
Collapsed=0
DockId=0x00000007,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1649,48
Size=271,1012
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=494,92
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=648,48
Size=2519,1319
Collapsed=0
DockId=0x00000002,0
[Window][ Viewport]
Pos=496,48
Size=1151,1012
Collapsed=0
DockId=0x00000002,0
[Window][ Asset Browser]
Pos=0,834
Size=494,226
Collapsed=0
DockId=0x00000008,0
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=8,79 Size=1920,1012 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1992,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=494,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Split=Y Selected=0xE096E5AE
DockNode ID=0x00000007 Parent=0x00000004 SizeRef=494,690 Selected=0xE096E5AE
DockNode ID=0x00000008 Parent=0x00000004 SizeRef=494,226 Selected=0xB128252A
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1151,1036 CentralNode=1 Selected=0xB41284E7
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=271,1036 Selected=0xE7039252

View File

@ -0,0 +1,56 @@
#include "SHpch.h"
#include "SHPrefabManager.h"
namespace SHADE
{
SHPrefabManager::PrefabMap SHPrefabManager::prefabMap{};
void SHPrefabManager::AddPrefab(AssetID const& prefabAssetID) noexcept
{
prefabMap.insert({ prefabAssetID, {} });
}
void SHPrefabManager::RemovePrefab(AssetID const& prefabAssetID) noexcept
{
prefabMap.erase(prefabAssetID);
}
void SHPrefabManager::ClearPrefab(AssetID const& prefabAssetID) noexcept
{
if (prefabMap.contains(prefabAssetID))
{
prefabMap[prefabAssetID].clear();
}
}
void SHPrefabManager::UpdateAllPrefabEntities(AssetID const& prefabAssetID) noexcept
{
//Loop through all entities and deserialize new data
}
void SHPrefabManager::AddEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept
{
if (prefabMap.contains(prefabAssetID))
{
prefabMap[prefabAssetID].insert(eid);
}
}
void SHPrefabManager::RemoveEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept
{
if (prefabMap.contains(prefabAssetID))
{
prefabMap[prefabAssetID].erase(eid);
}
}
void SHPrefabManager::Clear() noexcept
{
prefabMap.clear();
}
bool SHPrefabManager::Empty() noexcept
{
return prefabMap.empty();
}
}

View File

@ -0,0 +1,28 @@
#pragma once
#include "Assets/SHAssetMacros.h"
#include "ECS_Base/SHECSMacros.h"
#include <unordered_set>
#include <unordered_map>
namespace SHADE
{
class SHPrefabManager
{
public:
using PrefabMap = std::unordered_map<AssetID, std::unordered_set<EntityID>>;
static void AddPrefab(AssetID const& prefabAssetID) noexcept;
static void RemovePrefab(AssetID const& prefabAssetID) noexcept;
static void ClearPrefab(AssetID const& prefabAssetID) noexcept;
static void UpdateAllPrefabEntities(AssetID const& prefabAssetID) noexcept;
static void AddEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept;
static void RemoveEntity(AssetID const& prefabAssetID, EntityID const& eid) noexcept;
static void Clear() noexcept;
static bool Empty() noexcept;
private:
static PrefabMap prefabMap;
};
}

View File

@ -0,0 +1,31 @@
#include "SHpch.h"
#include "SHWinDialog.h"
#include <Windows.h>
#include <shobjidl.h>
namespace SHADE
{
void SHWinDialog::DisplayMessageBox(MessageBoxType const& messageBoxType, std::string const& title, std::string const& text)
{
if(messageBoxType == MessageBoxType::MB_MAX)
return;
UINT flags = MB_APPLMODAL | MB_SETFOREGROUND | MB_OK;
flags |= static_cast<UINT>(messageBoxType);
const std::wstring wTitle(title.begin(), title.end());
const std::wstring wText(text.begin(), text.end());
MessageBox(GetDesktopWindow(), wText.data(), wTitle.data(), flags);
}
std::vector<std::string> SHWinDialog::DisplayOpenDialog(OpenSaveConfig const& openSaveConfig)
{
return {};
}
std::vector<std::string> SHWinDialog::DisplaySaveAsDialog(OpenSaveConfig const& openSaveConfig)
{
return{};
}
}

View File

@ -0,0 +1,35 @@
#pragma once
#include <string>
#include <vector>
namespace SHADE
{
//https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
enum class MessageBoxType
{
MB_ERROR = 0x00000010L,
MB_QUESTION = 0x00000020L,
MB_WARNING = 0x00000030L,
MB_INFO = 0x00000040L,
MB_MAX = 0
};
struct OpenSaveConfig
{
using Extension = std::string;
using Extensions = std::vector<Extension>;
using FileTypeDesc = std::pair<std::string, Extensions>;
using FilterList = std::vector<FileTypeDesc>;
std::string title = "Open";
bool openFolders = false;
FilterList filterList{};
};
struct SHWinDialog
{
static void DisplayMessageBox(MessageBoxType const& messageBoxType, std::string const& title, std::string const& text);
static std::vector<std::string> DisplayOpenDialog(OpenSaveConfig const& openSaveConfig);
static std::vector<std::string> DisplaySaveAsDialog(OpenSaveConfig const& openSaveConfig);
};
}