diff options
author | chai <chaifix@163.com> | 2021-10-17 11:14:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-17 11:14:00 +0800 |
commit | d35db57d457132dd9d83fa2bd51491b148530655 (patch) | |
tree | b5a29675f091f268577b5991988c723f273b0bd1 | |
parent | 7b0a6d1fe0117cf42a5776aaabda2db78599e5b8 (diff) |
*GUI
-rw-r--r-- | DefaultContent/Libraries/Framework/Animation/Animation.lua (renamed from DefaultAssets/Libraries/Framework/Animation/Animation.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Class.lua (renamed from DefaultAssets/Libraries/Framework/Class.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Core/Camera.lua (renamed from DefaultAssets/Libraries/Framework/Core/Camera.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Core/Component.lua (renamed from DefaultAssets/Libraries/Framework/Core/Component.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Core/Game.lua (renamed from DefaultAssets/Libraries/Framework/Core/Game.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Core/GameObject.lua (renamed from DefaultAssets/Libraries/Framework/Core/GameObject.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Core/Sprite.lua (renamed from DefaultAssets/Libraries/Framework/Core/Sprite.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Math/Matrix44.lua (renamed from DefaultAssets/Libraries/Framework/Math/Matrix44.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Math/Quaternion.lua (renamed from DefaultAssets/Libraries/Framework/Math/Quaternion.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Math/Vector2.lua (renamed from DefaultAssets/Libraries/Framework/Math/Vector2.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Math/Vector3.lua (renamed from DefaultAssets/Libraries/Framework/Math/Vector3.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Math/Vector4.lua (renamed from DefaultAssets/Libraries/Framework/Math/Vector4.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Utils/EventCenter.lua (renamed from DefaultAssets/Libraries/Framework/Utils/EventCenter.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Utils/StateMachine.lua (renamed from DefaultAssets/Libraries/Framework/Utils/StateMachine.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/Utils/Util.lua (renamed from DefaultAssets/Libraries/Framework/Utils/Util.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Libraries/Framework/init.lua (renamed from DefaultAssets/Libraries/Framework/init.lua) | 0 | ||||
-rw-r--r-- | DefaultContent/Textures/blank.png (renamed from DefaultAssets/Textures/blank.png) | bin | 188 -> 188 bytes | |||
-rw-r--r-- | Documents/架构.xlsx | bin | 0 -> 6625 bytes | |||
-rw-r--r-- | Editor/EditorMain.cpp | 105 | ||||
-rw-r--r-- | Editor/EditorManager.cpp | 18 | ||||
-rw-r--r-- | Editor/EditorManager.h | 32 | ||||
-rw-r--r-- | Editor/GUI/ContainnerWindow.cpp | 291 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.cpp | 171 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 89 | ||||
-rw-r--r-- | Editor/GUI/GUIWindow.cpp | 211 | ||||
-rw-r--r-- | Editor/GUI/MenuController.h | 11 | ||||
-rw-r--r-- | Editor/GUI/MenuManager.cpp | 61 | ||||
-rw-r--r-- | Editor/GUI/MenuManager.h | 30 | ||||
-rw-r--r-- | Editor/GUI/SplitWindow.cpp (renamed from Editor/GUI/MenuController.cpp) | 0 | ||||
-rw-r--r-- | Editor/GUI/WinUtils.cpp | 4 | ||||
-rw-r--r-- | Editor/GUI/WindowManager.cpp | 17 | ||||
-rw-r--r-- | Editor/GUI/WindowUtil.cpp | 19 | ||||
-rw-r--r-- | Editor/Utils/HelperFuncs.cpp | 136 | ||||
-rw-r--r-- | Editor/Utils/HelperFuncs.h | 8 | ||||
-rw-r--r-- | Editor/Utils/Log.cpp | 94 | ||||
-rw-r--r-- | Editor/Utils/Log.h | 22 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj | 24 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj.filters | 179 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj.user | 5 | ||||
-rw-r--r-- | Resources/Icon/GameLab.ico | bin | 0 -> 32870 bytes | |||
-rw-r--r-- | Resources/readme.txt | 1 | ||||
-rw-r--r-- | Runtime/Utilities/Assert.h | 2 |
42 files changed, 1242 insertions, 288 deletions
diff --git a/DefaultAssets/Libraries/Framework/Animation/Animation.lua b/DefaultContent/Libraries/Framework/Animation/Animation.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Animation/Animation.lua +++ b/DefaultContent/Libraries/Framework/Animation/Animation.lua diff --git a/DefaultAssets/Libraries/Framework/Class.lua b/DefaultContent/Libraries/Framework/Class.lua index 78c577c..78c577c 100644 --- a/DefaultAssets/Libraries/Framework/Class.lua +++ b/DefaultContent/Libraries/Framework/Class.lua diff --git a/DefaultAssets/Libraries/Framework/Core/Camera.lua b/DefaultContent/Libraries/Framework/Core/Camera.lua index 5fcfbe7..5fcfbe7 100644 --- a/DefaultAssets/Libraries/Framework/Core/Camera.lua +++ b/DefaultContent/Libraries/Framework/Core/Camera.lua diff --git a/DefaultAssets/Libraries/Framework/Core/Component.lua b/DefaultContent/Libraries/Framework/Core/Component.lua index 00bf2ca..00bf2ca 100644 --- a/DefaultAssets/Libraries/Framework/Core/Component.lua +++ b/DefaultContent/Libraries/Framework/Core/Component.lua diff --git a/DefaultAssets/Libraries/Framework/Core/Game.lua b/DefaultContent/Libraries/Framework/Core/Game.lua index 51ce25f..51ce25f 100644 --- a/DefaultAssets/Libraries/Framework/Core/Game.lua +++ b/DefaultContent/Libraries/Framework/Core/Game.lua diff --git a/DefaultAssets/Libraries/Framework/Core/GameObject.lua b/DefaultContent/Libraries/Framework/Core/GameObject.lua index ee0d143..ee0d143 100644 --- a/DefaultAssets/Libraries/Framework/Core/GameObject.lua +++ b/DefaultContent/Libraries/Framework/Core/GameObject.lua diff --git a/DefaultAssets/Libraries/Framework/Core/Sprite.lua b/DefaultContent/Libraries/Framework/Core/Sprite.lua index 47cb50d..47cb50d 100644 --- a/DefaultAssets/Libraries/Framework/Core/Sprite.lua +++ b/DefaultContent/Libraries/Framework/Core/Sprite.lua diff --git a/DefaultAssets/Libraries/Framework/Math/Matrix44.lua b/DefaultContent/Libraries/Framework/Math/Matrix44.lua index b572f74..b572f74 100644 --- a/DefaultAssets/Libraries/Framework/Math/Matrix44.lua +++ b/DefaultContent/Libraries/Framework/Math/Matrix44.lua diff --git a/DefaultAssets/Libraries/Framework/Math/Quaternion.lua b/DefaultContent/Libraries/Framework/Math/Quaternion.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Math/Quaternion.lua +++ b/DefaultContent/Libraries/Framework/Math/Quaternion.lua diff --git a/DefaultAssets/Libraries/Framework/Math/Vector2.lua b/DefaultContent/Libraries/Framework/Math/Vector2.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Math/Vector2.lua +++ b/DefaultContent/Libraries/Framework/Math/Vector2.lua diff --git a/DefaultAssets/Libraries/Framework/Math/Vector3.lua b/DefaultContent/Libraries/Framework/Math/Vector3.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Math/Vector3.lua +++ b/DefaultContent/Libraries/Framework/Math/Vector3.lua diff --git a/DefaultAssets/Libraries/Framework/Math/Vector4.lua b/DefaultContent/Libraries/Framework/Math/Vector4.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Math/Vector4.lua +++ b/DefaultContent/Libraries/Framework/Math/Vector4.lua diff --git a/DefaultAssets/Libraries/Framework/Utils/EventCenter.lua b/DefaultContent/Libraries/Framework/Utils/EventCenter.lua index 664ecba..664ecba 100644 --- a/DefaultAssets/Libraries/Framework/Utils/EventCenter.lua +++ b/DefaultContent/Libraries/Framework/Utils/EventCenter.lua diff --git a/DefaultAssets/Libraries/Framework/Utils/StateMachine.lua b/DefaultContent/Libraries/Framework/Utils/StateMachine.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Utils/StateMachine.lua +++ b/DefaultContent/Libraries/Framework/Utils/StateMachine.lua diff --git a/DefaultAssets/Libraries/Framework/Utils/Util.lua b/DefaultContent/Libraries/Framework/Utils/Util.lua index e69de29..e69de29 100644 --- a/DefaultAssets/Libraries/Framework/Utils/Util.lua +++ b/DefaultContent/Libraries/Framework/Utils/Util.lua diff --git a/DefaultAssets/Libraries/Framework/init.lua b/DefaultContent/Libraries/Framework/init.lua index 8b96176..8b96176 100644 --- a/DefaultAssets/Libraries/Framework/init.lua +++ b/DefaultContent/Libraries/Framework/init.lua diff --git a/DefaultAssets/Textures/blank.png b/DefaultContent/Textures/blank.png Binary files differindex 877e031..877e031 100644 --- a/DefaultAssets/Textures/blank.png +++ b/DefaultContent/Textures/blank.png diff --git a/Documents/架构.xlsx b/Documents/架构.xlsx Binary files differnew file mode 100644 index 0000000..15e2235 --- /dev/null +++ b/Documents/架构.xlsx diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp index 8868d88..9d77862 100644 --- a/Editor/EditorMain.cpp +++ b/Editor/EditorMain.cpp @@ -2,46 +2,95 @@ #include <vector>
#include "GUI/EditorWindows.h"
#include "Runtime/Scripting/LuaBind.h"
+#include "EditorManager.h"
+#include "Runtime/Graphics/OpenGL.h"
+
+// Editor
+
static int MainMessageLoop() {
- BOOL returnValue; - MSG msg, lastMsg; - msg.message = WM_NULL; - std::vector<MSG> messages; - PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); - bool isQuitSignaled = msg.message == WM_QUIT; -
- while (!isQuitSignaled)
- {
- MSG msg; - while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0) - { - TranslateMessage(&msg); - DispatchMessage(&msg); + BOOL returnValue; + MSG msg, lastMsg; + msg.message = WM_NULL; + std::vector<MSG> messages; + PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); + bool isQuitSignaled = msg.message == WM_QUIT; +
+ while (!isQuitSignaled)
+ {
+ MSG msg; + while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0) + { + TranslateMessage(&msg); + DispatchMessage(&msg); - if (msg.message == WM_QUIT) - isQuitSignaled = true; + if (msg.message == WM_QUIT) + isQuitSignaled = true; - - } + } - }
+ }
- return (INT)msg.wParam; + return (INT)msg.wParam; +}
+
+void OpenLogTags()
+{
+ //log_open_tag("WndProc");
+ //log_open_tag("Menu");
}
+#ifdef GAMELAB_DEBUG
+int main() +#else int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +#endif {
- RegisterWindowClasses();
+ OpenLogTags();
+ WindowUtil::Init();
+
+ ContainnerWindow* wnd = new ContainnerWindow();
+ Vector2f min = Vector2f(100, 100);
+ Vector2f max = Vector2f(700, 700);
+ wnd->Init(Rectf(400, 400, 800, 500), ContainnerWindow::kShowMainWindow, min, max);
+ wnd->SetTitle("GameLab");
+ wnd->SetIcon("./Icon/GameLab.ico");
+
+ EditorManager::Instance()->SetMainWindow(wnd);
+ MenuManager::Instance()->Init();
+
+ GUIWindow* guiWnd = new GUIWindow();
+ guiWnd->Init();
+ guiWnd->SetContainnerWindow(wnd);
+ Rectf position;
+ position.x = 0;
+ position.y = 0;
+ position.width = 200;
+ position.height = 200;
+ guiWnd->SetPosition(position);
+
+ GUIWindow* guiWnd2 = new GUIWindow();
+ guiWnd2->Init();
+ guiWnd2->SetContainnerWindow(wnd);
+ position.x = 200;
+ position.y = 0;
+ position.width = 200;
+ position.height = 200;
+ guiWnd2->SetPosition(position);
+
+ // init gl
+ wglMakeCurrent(guiWnd2->GetDC(), guiWnd2->GetRC());
+ if (!gladLoadGL()) {
+ log_error("ʼGL");
+ }
- ContainnerWindow* wnd = new ContainnerWindow();
+ // force repaint
+ wnd->DoPaint();
+ guiWnd->DoPaint();
+ guiWnd2->DoPaint();
- Vector2f min = Vector2f(100, 100);
- Vector2f max = Vector2f(700, 700);
- wnd->Init(Rectf(400, 400, 500, 500), ContainnerWindow::kShowMainWindow, min, max);
+ MainMessageLoop();
- MainMessageLoop();
-
- return 0;
+ return 0;
}
\ No newline at end of file diff --git a/Editor/EditorManager.cpp b/Editor/EditorManager.cpp new file mode 100644 index 0000000..6f589d9 --- /dev/null +++ b/Editor/EditorManager.cpp @@ -0,0 +1,18 @@ +#include "EditorManager.h" + +#ifdef GAMELAB_DEBUG +const std::string EditorDefine::kResourceRoot = ""; +#else +const std::string EditorDefine::kResourceRoot = "./"; +#endif + + +void EditorManager::SetMainWindow(ContainnerWindow* wnd) +{ + m_MainWindow = wnd; +} + +ContainnerWindow* EditorManager::GetMainWindow() +{ + return m_MainWindow; +} diff --git a/Editor/EditorManager.h b/Editor/EditorManager.h new file mode 100644 index 0000000..6e6da19 --- /dev/null +++ b/Editor/EditorManager.h @@ -0,0 +1,32 @@ +#pragma once + +#include <string> +#include <windows.h> + +#include "Runtime/Utilities/Singleton.h" + +#include "./GUI/EditorWindows.h" +#include "./GUI/MenuManager.h" + +class EditorDefine +{ +public: + static const std::string kResourceRoot; +}; + +class EditorUtil +{ +public : + +}; + +class EditorManager : public Singleton<EditorManager> +{ +public: + void SetMainWindow(ContainnerWindow* wnd); + ContainnerWindow* GetMainWindow(); + +private: + ContainnerWindow* m_MainWindow; + +}; diff --git a/Editor/GUI/ContainnerWindow.cpp b/Editor/GUI/ContainnerWindow.cpp new file mode 100644 index 0000000..5e6c356 --- /dev/null +++ b/Editor/GUI/ContainnerWindow.cpp @@ -0,0 +1,291 @@ +#include <string> + +#include "EditorWindows.h" +#include "WinUtils.h" +#include "Editor/Utils/HelperFuncs.h" +#include "MenuManager.h" +#include "Runtime/Utilities/Assert.h" + +using namespace std; + +static PAINTSTRUCT ps; +LRESULT CALLBACK ContainnerWindow::ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + log_info("WndProc", "ContainnerWindow::ContainerWndProc()"); + + ContainnerWindow *self = (ContainnerWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (!self) + { + log_warning("Nullptr ContainnerWindow"); + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + switch (message) + { + case WM_MENUSELECT: + { + if (self->m_ShowMode != ShowMode::kShowMainWindow) + return 0; + uint menuId = LOWORD(wParam); + uint flags = HIWORD(wParam); + HMENU menu = (HMENU)lParam; + MenuManager::Instance()->HandleMenuItemEvent(menu, menuId, flags); + return 0; + } + case WM_SETICON: + return WM_SETICON; + case WM_PAINT: + { + log_info("WM_PAINT"); + self->SetAsRenderContext(); + glEnable(GL_BLEND); + float c = 26 / 255.f; + glClearColor(c, c, c, 1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glFlush(); + BeginPaint(self->m_Window, &ps); + EndPaint(self->m_Window, &ps); + UpdateWindow(self->m_Window); + return 0; + } + } + + long flag = DefWindowProcW(hWnd, message, wParam, lParam); + return flag; +} + +ContainnerWindow::ContainnerWindow() +{ +} + +ContainnerWindow::~ContainnerWindow() +{ + +} + +void ContainnerWindow::DoPaint() +{ + SetWindowLongPtr(m_Window, GWLP_USERDATA, (LONG_PTR)this); + SendMessage(m_Window, WM_PAINT, 0, 0); +} + +void ContainnerWindow::SetAsRenderContext() +{ + Assert(m_DC != NULL); + Assert(m_RC != NULL); + Assert(wglMakeCurrent(m_DC, m_RC)); + RECT rect; + GetWindowRect(m_Window, &rect); + glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top); +} + +bool ContainnerWindow::SetRenderContext() +{ + m_DC = ::GetDC(m_Window); + if (!m_DC) + log_error("Can't create DC"); + + int bits = 32; + + //static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be + //{ + // sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor + // 1, // Version Number + // PFD_DRAW_TO_WINDOW | // Format Must Support Window + // PFD_SUPPORT_OPENGL | // Format Must Support OpenGL + // PFD_DOUBLEBUFFER, // Must Support Double Buffering + // PFD_TYPE_RGBA, // Request An RGBA Format + // bits, // Select Our Color Depth + // 0, 0, 0, 0, 0, 0, // Color Bits Ignored + // 0, // No Alpha Buffer + // 0, // Shift Bit Ignored + // 0, // No Accumulation Buffer + // 0, 0, 0, 0, // Accumulation Bits Ignored + // 16, // 16Bit Z-Buffer (Depth Buffer) + // 0, // No Stencil Buffer + // 0, // No Auxiliary Buffer + // PFD_MAIN_PLANE, // Main Drawing Layer + // 0, // Reserved + // 0, 0, 0 // Layer Masks Ignored + //}; + static PIXELFORMATDESCRIPTOR pfd; + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + + GLuint PixelFormat; + + if (!(PixelFormat = ChoosePixelFormat(m_DC, &pfd))) // Did Windows Find A Matching Pixel Format? + { + MessageBox(NULL, "Can't Find A Suitable PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + + if (!SetPixelFormat(m_DC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format? + { + MessageBox(NULL, "Can't Set The PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + + int pf = 0; + DescribePixelFormat(m_DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + + if (!(m_RC = wglCreateContext(m_DC))) // Are We Able To Get A Rendering Context? + { + MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + +} + +HWND ContainnerWindow::GetWindowHandle() +{ + return m_Window; +} + +// ʼ +void ContainnerWindow::Init(Rectf pixelRect, int showMode, const Vector2f& minSize, const Vector2f& maxSize) +{ + // Aux windows are mac only. on windows they look just like normal utility windows. + if (showMode == kShowAuxWindow) + showMode = kShowUtility; + + m_ShowMode = static_cast<ShowMode>(showMode); + m_IsClosing = false; + m_InMenuLoop = false; + m_CloseFromScriptDontShutdown = false; + + bool shouldMaximize = false; + if (showMode == kShowMainWindow) + { + //shouldMaximize = s_IsMainWindowMaximized = EditorPrefs::GetBool(kIsMainWindowMaximized, false); + //GetRestoredMainWindowDimensions(); + } + + RECT rect; + rect.left = pixelRect.x; + rect.right = pixelRect.x + pixelRect.width; + rect.top = pixelRect.y; + rect.bottom = pixelRect.y + pixelRect.height; + m_InternalRect.x = m_InternalRect.y = m_InternalRect.width = m_InternalRect.height = 0.0f; + + DWORD windowStyle = 0; + DWORD extendedStyle = 0; + LPCWSTR windowClass = WindowUtil::kContainerWindowClassName; + + switch (showMode) { + // GUIPanelķ + case kShowNormalWindow: + windowStyle = WS_POPUP | WS_CLIPCHILDREN | WS_THICKFRAME; + extendedStyle = WS_EX_TOOLWINDOW; + break; + // ڣ˵ + case kShowMainWindow: + windowStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; + extendedStyle = 0; + break; + case kShowPopupMenu: + windowStyle = WS_POPUP | WS_CLIPCHILDREN; + extendedStyle = WS_EX_TOOLWINDOW; + windowClass = WindowUtil::kPopupWindowClassName; + break; + case kShowNoShadow: + windowStyle = WS_POPUP | WS_CLIPCHILDREN; + extendedStyle = WS_EX_TOOLWINDOW; + break; + case kShowUtility: + windowStyle = WS_POPUP | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU; + extendedStyle = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW; + break; + default: + // ErrorString("Unknown container show mode"); + break; + } + + HWND parentWindow = NULL; + if (showMode == kShowMainWindow) + { + parentWindow = NULL; + } + else + { + // parentWindow = GetMainEditorWindow(); + } + + bool notSizeable = (minSize == maxSize) && (minSize != Vector2f::zero); + if (notSizeable) + windowStyle &= ~(WS_THICKFRAME); + + AdjustWindowRectEx(&rect, windowStyle, showMode == kShowMainWindow, extendedStyle); + int extraX = rect.right - rect.left - 200; + int extraY = rect.bottom - rect.top - 200; + + m_MinSize.x = minSize.x + extraX; + m_MinSize.y = minSize.y + extraY; + m_MaxSize.x = maxSize.x + extraX; + m_MaxSize.y = maxSize.y + extraY; + + //if (showMode == kShowUtility) + // s_ZUtilityWindows.push_back(m_ContainerListNode); + // Create window + m_Window = CreateWindowExW( + extendedStyle, + windowClass, + L"", + windowStyle, + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + parentWindow, + NULL, + winutils::GetInstanceHandle(), + NULL + ); + SetWindowLongPtr(m_Window, GWLP_USERDATA, (LONG_PTR)this); + //UpdateMaxMaximizedRect(); + + if (pixelRect.width > 10 || pixelRect.height > 10) + { + //SetRect(pixelRect); + if (shouldMaximize) + SetWindowLong(m_Window, GWL_STYLE, windowStyle | WS_MAXIMIZE); + } + + if (showMode == kShowMainWindow) + { + //SetMainEditorWindow(m_Window); + //HMENU menu = GetMainMenuHandle(); + //if (menu) + // SetMenu(m_Window, menu); + //GetApplication().UpdateMainWindowTitle(); + //GetApplication().UpdateDocumentEdited(); + } + ShowWindow(m_Window, SW_SHOW); + + //s_ContainerWindows.insert(this); + + //ShowInTaskbarIfNoMainWindow(m_Window); + + SetRenderContext(); +} + +void ContainnerWindow::SetTitle(const char* title) +{ + SetWindowTextA(m_Window, title); +} + +void ContainnerWindow::SetIcon(LPCSTR iconName) +{ + Assert(m_ShowMode == ShowMode::kShowMainWindow); + + HICON hWindowIcon = (HICON )LoadImage(winutils::GetInstanceHandle(), iconName, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE); + if (hWindowIcon == NULL) + log_error("icon error: " + to_string(GetLastError())); + if (SendMessage(m_Window, WM_SETICON, ICON_BIG, (LPARAM)hWindowIcon) != WM_SETICON) + log_error("icon error: " + to_string(GetLastError())); + if (SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon) != WM_SETICON) + log_error("icon error: " + to_string(GetLastError())); +} diff --git a/Editor/GUI/EditorWindows.cpp b/Editor/GUI/EditorWindows.cpp deleted file mode 100644 index 6d24dbd..0000000 --- a/Editor/GUI/EditorWindows.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "EditorWindows.h"
-#include "WinUtils.h"
-
-static const wchar_t* kContainerWindowClassName = L"GameLabContainerWndClass"; -static const wchar_t* kPopupWindowClassName = L"GameLabPopupWndClass"; -static const wchar_t* kViewportClassName = L"GameLabViewportWndClass"; -static const char* kIsMainWindowMaximized = "IsMainWindowMaximized"; - -static ATOM s_ContainerWindowClassAtom; -static ATOM s_PopupWindowClassAtom; -static ATOM s_GUIViewClassAtom; -
-void RegisterWindowClasses()
-{
- s_ContainerWindowClassAtom = winutils::RegisterWindowClass(kContainerWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW); - s_PopupWindowClassAtom = winutils::RegisterWindowClass(kPopupWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW | CS_DROPSHADOW);//CS_HREDRAWȣˮƽ仯ʱػ桢CS_VREDRAW߶ȣֱ仯ʱػ - s_GUIViewClassAtom = winutils::RegisterWindowClass(kViewportClassName, GUIView::GUIViewWndProc, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS); -}
-
-LRESULT CALLBACK ContainnerWindow::ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- long flag = DefWindowProcW(hWnd, message, wParam, lParam); - return flag; -}
-
-ContainnerWindow::ContainnerWindow()
-{
-}
-
-
-ContainnerWindow::~ContainnerWindow()
-{
-
-}
-
-void ContainnerWindow::Init(Rectf pixelRect, int showMode, const Vector2f& minSize, const Vector2f& maxSize)
-{ - // Aux windows are mac only. on windows they look just like normal utility windows. - if (showMode == kShowAuxWindow) - showMode = kShowUtility; - - m_ShowMode = static_cast<ShowMode>(showMode); - m_IsClosing = false; - m_InMenuLoop = false; - m_CloseFromScriptDontShutdown = false; - - bool shouldMaximize = false; - if (showMode == kShowMainWindow) - { - //shouldMaximize = s_IsMainWindowMaximized = EditorPrefs::GetBool(kIsMainWindowMaximized, false); - //GetRestoredMainWindowDimensions(); - } - - RECT rect = { 120, 120, 220, 220 }; - m_InternalRect.x = m_InternalRect.y = m_InternalRect.width = m_InternalRect.height = 0.0f; - - DWORD windowStyle = 0; - DWORD extendedStyle = 0; - LPCWSTR windowClass = kContainerWindowClassName; - - switch (showMode) { - // GUIPanelķ - case kShowNormalWindow: - windowStyle = WS_POPUP | WS_CLIPCHILDREN | WS_THICKFRAME; - extendedStyle = WS_EX_TOOLWINDOW; - break; - // ڣ˵ - case kShowMainWindow: - windowStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; - extendedStyle = 0; - break; - case kShowPopupMenu: - windowStyle = WS_POPUP | WS_CLIPCHILDREN; - extendedStyle = WS_EX_TOOLWINDOW; - windowClass = kPopupWindowClassName; - break; - case kShowNoShadow: - windowStyle = WS_POPUP | WS_CLIPCHILDREN; - extendedStyle = WS_EX_TOOLWINDOW; - break; - case kShowUtility: - windowStyle = WS_POPUP | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU; - extendedStyle = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW; - break; - default: - // ErrorString("Unknown container show mode"); - break; - } - - HWND parentWindow = NULL; - if (showMode == kShowMainWindow) - { - parentWindow = NULL; - } - else - { - // parentWindow = GetMainEditorWindow(); - } - - bool notSizeable = (minSize == maxSize) && (minSize != Vector2f::zero); - if (notSizeable) - windowStyle &= ~(WS_THICKFRAME); - - AdjustWindowRectEx(&rect, windowStyle, showMode == kShowMainWindow, extendedStyle); - int extraX = rect.right - rect.left - 200; - int extraY = rect.bottom - rect.top - 200; - - m_MinSize.x = minSize.x + extraX; - m_MinSize.y = minSize.y + extraY; - m_MaxSize.x = maxSize.x + extraX; - m_MaxSize.y = maxSize.y + extraY; - - - //if (showMode == kShowUtility) - // s_ZUtilityWindows.push_back(m_ContainerListNode); - // Create window - m_Window = CreateWindowExW( - extendedStyle, - windowClass, - L"", - windowStyle, - rect.left, - rect.top, - rect.right - rect.left, - rect.bottom - rect.top, - parentWindow, - NULL, - winutils::GetInstanceHandle(), - NULL - ); - SetWindowLongPtr(m_Window, GWLP_USERDATA, (LONG_PTR)this); - //UpdateMaxMaximizedRect(); - - if (pixelRect.width > 10 || pixelRect.height > 10) - { - //SetRect(pixelRect); - if (shouldMaximize) - SetWindowLong(m_Window, GWL_STYLE, windowStyle | WS_MAXIMIZE); - } - - - if (showMode == kShowMainWindow) - { - //SetMainEditorWindow(m_Window); - //HMENU menu = GetMainMenuHandle(); - //if (menu) - // SetMenu(m_Window, menu); - //GetApplication().UpdateMainWindowTitle(); - //GetApplication().UpdateDocumentEdited(); - } - ShowWindow(m_Window, SW_SHOW); - - //s_ContainerWindows.insert(this); - - //ShowInTaskbarIfNoMainWindow(m_Window);
-
-}
-
-//------------------------------------------------------------------------------------------------------------------
-
-LRESULT CALLBACK GUIView::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- long flag = DefWindowProcW(hWnd, message, wParam, lParam); - return flag; -} - -void GUIView::DoPaint() -{
-
- -}
\ No newline at end of file diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 4bd33ec..33d99c1 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -2,15 +2,38 @@ #define EDITOR_WINDOW_H #include <windows.h> +#include <vector> #include "Runtime/Math/Rect.h" #include "Runtime/Scripting/LuaBind.h" +#include "Runtime/Utilities/Singleton.h" +#include "Editor/Utils/Log.h" +#include "Runtime/Graphics/OpenGL.h" -void RegisterWindowClasses(); +class GUIWindow; + +class WindowUtil +{ +public : + static void Init(); + + static const wchar_t* kContainerWindowClassName; + static const wchar_t* kPopupWindowClassName; + static const wchar_t* kGUIWindowClassName; +}; + +class WindowManager : Singleton<WindowManager> +{ +public: + static Vector2f GetMousePosition(); + static GUIWindow* GetMouseOverWindow(); +}; // һcontainner windowжviewport class ContainnerWindow { public: + static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + enum ShowMode { kShowNormalWindow = 0, // normal window with max/min/close buttons kShowPopupMenu = 1, // popup menu - no title bar @@ -23,12 +46,22 @@ public: ContainnerWindow(); ~ContainnerWindow(); - static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - void Init(Rectf size, int showMode, const Vector2f& minSize, const Vector2f& maxSize); + void SetTitle(const char* title); + void SetIcon(LPCSTR iconName); + void SetAsRenderContext(); + void DoPaint(); + + HWND GetWindowHandle(); + HDC GetDC() { return m_DC; } + HGLRC GetRC() { return m_RC; } private: + bool SetRenderContext(); + HWND m_Window; + HDC m_DC; + HGLRC m_RC; POINT m_Size; ShowMode m_ShowMode; // bool m_IsClosing; @@ -40,20 +73,62 @@ private: }; +// ڻ +class WindowBase +{ +}; + +// ڣ +class SplitWindow : public WindowBase +{ +public: + enum SplitMode + { + Horizontal, + Vertical, + }; + + SplitMode GetSplitMode() { return m_SplitMode; } + +private: + SplitMode m_SplitMode; + + GUIWindow* m_GUIWindow; + std::vector<GUIWindow*> m_GUIWindows; -// ڵĵӴڣ¼ӦơֵĵԪ -class GUIView +}; + +// GUIڣ¼ӦơֵĵԪ +// unityһĵطһGUIWindowֻһEditorWindowһҳΪʵʿҷֺٻƵлҳUEblender +// ôҲڱȽϺ֯ +class GUIWindow : public WindowBase { public: static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + static void RepaintAll(); + void Init(); void DoPaint(); + void SetContainnerWindow(ContainnerWindow* wnd); + void Focus(); + void SetPosition(Rectf position); + void SetAsRenderContext(); + + void OnFocus(); + void OnLostFocus(); + + HDC GetDC() { return m_DC; } + HGLRC GetRC() { return m_RC; } private: - HWND m_View; + bool SetRenderContext(); - LuaBind::Ref m_Script; + ContainnerWindow* m_ContainnerWindow; + HWND m_Handle; + HDC m_DC; + HGLRC m_RC; + LuaBind::Ref m_Script; }; diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp new file mode 100644 index 0000000..e13770e --- /dev/null +++ b/Editor/GUI/GUIWindow.cpp @@ -0,0 +1,211 @@ +#include "EditorWindows.h" +#include "WinUtils.h" +#include "Runtime/Graphics/OpenGL.h" + +static PAINTSTRUCT ps; +LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + log_info("WndProc", "GUIWindow::GUIViewWndProc(), hWnd=" /*+ (long)hWnd*/); + + GUIWindow* wnd = (GUIWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (!wnd) + { + log_warning("GUIWindow::GUIViewWndProc(), lParamΪ"); + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + switch (message) + { + case WM_PAINT: + { + log_info("WM_PAINT"); + wnd->SetAsRenderContext(); + glEnable(GL_BLEND); + glClearColor(1,0,0,1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glFlush(); + BeginPaint(wnd->m_Handle, &ps); + EndPaint(wnd->m_Handle, &ps); + UpdateWindow(wnd->m_Handle); + return 0; + } + } + + long flag = DefWindowProcW(hWnd, message, wParam, lParam); + return flag; +} + +void GUIWindow::RepaintAll() +{ +} + +////////////////////////////////////////////////////////////////////////////////////////// + +void GUIWindow::Init() +{ + log_info("Init GUIWindow " /*+ (long)this*/); + + DWORD windowStyle = WS_CHILD; + //DWORD windowStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; + DWORD extendedStyle = WS_EX_TOOLWINDOW; + + Rectf pixelRect; + pixelRect.x = 0; + pixelRect.y = 0; + pixelRect.width = 32; + pixelRect.height = 32; + + RECT rc; + rc.left = pixelRect.x; + rc.top = pixelRect.y; + rc.right = pixelRect.x + pixelRect.width; + rc.bottom = pixelRect.y + pixelRect.height; + AdjustWindowRectEx(&rc, windowStyle, FALSE, extendedStyle); + + m_Handle = CreateWindowExW( + extendedStyle, + WindowUtil::kGUIWindowClassName, + L"", + windowStyle, + rc.left, + rc.top, + rc.right - rc.left, + rc.bottom - rc.top, + HWND_MESSAGE, // message only + NULL, + winutils::GetInstanceHandle(), + NULL + ); + + SetWindowLongPtr(m_Handle, GWLP_USERDATA, (LONG_PTR)this); + + ShowWindow(m_Handle, SW_SHOW); + + if (!SetRenderContext()) + log_error("Failed to setup rendering context"); + + log_info("Created GUIWindow " /*+ (long)this*/); +} + +bool GUIWindow::SetRenderContext() +{ + m_DC = ::GetDC(m_Handle); + if (!m_DC) + log_error("Can't create DC"); + + int bits = 32; + + //static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be + //{ + // sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor + // 1, // Version Number + // PFD_DRAW_TO_WINDOW | // Format Must Support Window + // PFD_SUPPORT_OPENGL | // Format Must Support OpenGL + // PFD_DOUBLEBUFFER, // Must Support Double Buffering + // PFD_TYPE_RGBA, // Request An RGBA Format + // bits, // Select Our Color Depth + // 0, 0, 0, 0, 0, 0, // Color Bits Ignored + // 0, // No Alpha Buffer + // 0, // Shift Bit Ignored + // 0, // No Accumulation Buffer + // 0, 0, 0, 0, // Accumulation Bits Ignored + // 16, // 16Bit Z-Buffer (Depth Buffer) + // 0, // No Stencil Buffer + // 0, // No Auxiliary Buffer + // PFD_MAIN_PLANE, // Main Drawing Layer + // 0, // Reserved + // 0, 0, 0 // Layer Masks Ignored + //}; + static PIXELFORMATDESCRIPTOR pfd; + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + + GLuint PixelFormat; + + if (!(PixelFormat = ChoosePixelFormat(m_DC, &pfd))) // Did Windows Find A Matching Pixel Format? + { + MessageBox(NULL, "Can't Find A Suitable PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + + if (!SetPixelFormat(m_DC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format? + { + MessageBox(NULL, "Can't Set The PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + + int pf = 0; + DescribePixelFormat(m_DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + + if (!(m_RC = wglCreateContext(m_DC))) // Are We Able To Get A Rendering Context? + { + MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } + + return true; +} + +void GUIWindow::DoPaint() +{ + SetWindowLongPtr(m_Handle, GWLP_USERDATA,(LONG_PTR ) this); + SendMessage(m_Handle, WM_PAINT, 0, 0); +} + +void GUIWindow::OnFocus() +{ +} + +void GUIWindow::OnLostFocus() +{ +} + +void GUIWindow::SetPosition(Rectf position) +{ + log_info("GUIWindow::SetPosition()"); + RECT rc; + rc.left = position.x; + rc.top = position.y; + rc.right = position.x + position.width; + rc.bottom = position.y + position.height; + ::SetWindowPos(m_Handle, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOZORDER); +} + +void GUIWindow::SetAsRenderContext() +{ + Assert(m_DC != NULL); + Assert(m_RC != NULL); + Assert(wglMakeCurrent(m_DC, m_RC)); + RECT rect; + GetWindowRect(m_Handle, &rect); + glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top); +} + +void GUIWindow::Focus() +{ + log_info("Focus GUIWindow " + (long)this); + if (m_Handle) + { + if (::GetForegroundWindow() != m_ContainnerWindow->GetWindowHandle()) + ::SetForegroundWindow(m_ContainnerWindow->GetWindowHandle()); + SetFocus(m_Handle); + } +} + +void GUIWindow::SetContainnerWindow(ContainnerWindow* wnd) +{ + Assert(wnd != NULL); + + m_ContainnerWindow = wnd; + + if (wnd->GetWindowHandle() != m_Handle) + { + HWND parentWindowHandle = wnd->GetWindowHandle(); + if (::GetParent(m_Handle) != parentWindowHandle) + ::SetParent(m_Handle, parentWindowHandle); + ::ShowWindow(m_Handle, SW_SHOWNORMAL); + } +}
\ No newline at end of file diff --git a/Editor/GUI/MenuController.h b/Editor/GUI/MenuController.h deleted file mode 100644 index 9abe9e5..0000000 --- a/Editor/GUI/MenuController.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef MENU_CONTROLLER_H -#define MENU_CONTROLLER_H - -// menu item - -class MenuController { - -}; - - -#endif
\ No newline at end of file diff --git a/Editor/GUI/MenuManager.cpp b/Editor/GUI/MenuManager.cpp new file mode 100644 index 0000000..53dfd5a --- /dev/null +++ b/Editor/GUI/MenuManager.cpp @@ -0,0 +1,61 @@ +//https://stackoverflow.com/questions/30135494/win32-api-c-menu-bar +//https://docs.microsoft.com/en-us/windows/win32/menurc/using-menus + +#include <string> + +#include "MenuManager.h" +#include "../EditorManager.h" + +const int IDM_FILE_NEW = 10; +const int IDM_ASSET = 20; + +using namespace std; + +MenuManager::MenuManager() + : m_Menus() +{ +} + +void MenuManager::Init() +{ + ContainnerWindow* mainWnd = EditorManager::Instance()->GetMainWindow(); + Assert(mainWnd != NULL); + + HMENU hMenubar = CreateMenu(); + + HMENU hMenu = CreateMenu(); + HMENU hSubMenu = CreatePopupMenu(); + HMENU asserMenu = CreateMenu(); + + AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New"); + AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL); + + AppendMenuW(asserMenu, MF_STRING, IDM_ASSET, L"Import &mail &assets"); + AppendMenuW(hSubMenu, MF_STRING | MF_POPUP, (UINT_PTR)asserMenu, L"Import &mail"); + AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, L"&Import"); + + AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File"); + + AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW + 5, L"New 2"); + //InsertMenu(hMenu, 1, MF_SEPARATOR | MF_BYPOSITION, 0, NULL); + + SetMenu(mainWnd->GetWindowHandle(), hMenubar); + +} + +void MenuManager::AddMenuItem(std::string name, int order) +{ + log_info("Menu", " Add menu item \"" + name + "\""); + +} + +void MenuManager::HandleMenuItemEvent(HMENU menu, unsigned int menuId, unsigned int flags) +{ + log_info("Menu", "menuId=" + to_string(menuId) + ", flags=" + to_string(flags)); + + if (flags & MF_CHECKED) // clicked + { + log_info("Menu", "checked"); + + } +}
\ No newline at end of file diff --git a/Editor/GUI/MenuManager.h b/Editor/GUI/MenuManager.h new file mode 100644 index 0000000..8d0339d --- /dev/null +++ b/Editor/GUI/MenuManager.h @@ -0,0 +1,30 @@ +#ifndef MENU_CONTROLLER_H +#define MENU_CONTROLLER_H + +#include <string> +#include <unordered_map> +#include <windows.h> + +#include "Runtime/Utilities/Singleton.h" + +class MenuItem +{ + +}; + +class MenuManager : public Singleton<MenuManager> +{ +public: + MenuManager(); + + void Init(); + void AddMenuItem(std::string name, int order = 0); + void HandleMenuItemEvent(HMENU menu, unsigned int menuId, unsigned int flags); + +private: + std::unordered_map<std::string, HMENU> m_Menus; + +}; + + +#endif
\ No newline at end of file diff --git a/Editor/GUI/MenuController.cpp b/Editor/GUI/SplitWindow.cpp index e69de29..e69de29 100644 --- a/Editor/GUI/MenuController.cpp +++ b/Editor/GUI/SplitWindow.cpp diff --git a/Editor/GUI/WinUtils.cpp b/Editor/GUI/WinUtils.cpp index e7b2d5b..84d0e37 100644 --- a/Editor/GUI/WinUtils.cpp +++ b/Editor/GUI/WinUtils.cpp @@ -7,6 +7,10 @@ namespace winutils HINSTANCE GetInstanceHandle() { + if (gInstanceHandle == NULL) + { + gInstanceHandle = GetModuleHandle(NULL); + } return gInstanceHandle; }
diff --git a/Editor/GUI/WindowManager.cpp b/Editor/GUI/WindowManager.cpp new file mode 100644 index 0000000..add2066 --- /dev/null +++ b/Editor/GUI/WindowManager.cpp @@ -0,0 +1,17 @@ +#include "EditorWindows.h" +#include "WinUtils.h" + +GUIWindow* WindowManager::GetMouseOverWindow() +{ + return NULL; +} + +Vector2f WindowManager::GetMousePosition() +{ + POINT pt; + if (!GetCursorPos(&pt)) + return Vector2f(0, 0); + + return Vector2f(pt.x, pt.y); + +} diff --git a/Editor/GUI/WindowUtil.cpp b/Editor/GUI/WindowUtil.cpp new file mode 100644 index 0000000..fc32719 --- /dev/null +++ b/Editor/GUI/WindowUtil.cpp @@ -0,0 +1,19 @@ +#include "EditorWindows.h" +#include "WinUtils.h" + +const wchar_t* WindowUtil::kContainerWindowClassName = L"GameLabContainerWndClass"; +const wchar_t* WindowUtil::kPopupWindowClassName = L"GameLabPopupWndClass"; +const wchar_t* WindowUtil::kGUIWindowClassName = L"GUIViewWindowClassName"; + +static ATOM ContainerWindowClassAtom; +static ATOM PopupWindowClassAtom; +static ATOM GUIViewClassAtom; + +void WindowUtil::Init() +{ + log_info("WindowUtil::Init()"); + + ContainerWindowClassAtom = winutils::RegisterWindowClass(kContainerWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW); + PopupWindowClassAtom = winutils::RegisterWindowClass(kPopupWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW | CS_DROPSHADOW);//CS_HREDRAWȣˮƽ仯ʱػ桢CS_VREDRAW߶ȣֱ仯ʱػ + GUIViewClassAtom = winutils::RegisterWindowClass(kGUIWindowClassName, GUIWindow::GUIViewWndProc, CS_HREDRAW | CS_VREDRAW | CS_DROPSHADOW); +}
\ No newline at end of file diff --git a/Editor/Utils/HelperFuncs.cpp b/Editor/Utils/HelperFuncs.cpp new file mode 100644 index 0000000..fd91d85 --- /dev/null +++ b/Editor/Utils/HelperFuncs.cpp @@ -0,0 +1,136 @@ +#include "HelperFuncs.h" +#include <string.h> +#include <windows.h> +#include <dbghelp.h> +#include <process.h> +#include <exception> +#include <locale.h> +#include <stdlib.h> + +using namespace std; + +#pragma comment(lib,"Dbghelp.lib") + +std::string to_string(const char* cstr) +{ + string s(cstr); + return s; +} + +void _Exceptor() +{ + throw exception(); +} + +//https://stackoverflow.com/questions/22467604/ +const int MaxNameLen = 256; +void printStack(CONTEXT* ctx) //Prints stack trace based on context record +{ + BOOL result; + HANDLE process; + HANDLE thread; + HMODULE hModule; + + STACKFRAME64 stack; + ULONG frame; + DWORD64 displacement; + + DWORD disp; + IMAGEHLP_LINE64 *line; + + char buffer[sizeof(SYMBOL_INFO) + 2000 * sizeof(TCHAR)]; + char name[MaxNameLen]; + char module[MaxNameLen]; + PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + + memset(&stack, 0, sizeof(STACKFRAME64)); + + process = GetCurrentProcess(); + thread = GetCurrentThread(); + displacement = 0; +#if !defined(_M_AMD64) + stack.AddrPC.Offset = (*ctx).Eip; + stack.AddrPC.Mode = AddrModeFlat; + stack.AddrStack.Offset = (*ctx).Esp; + stack.AddrStack.Mode = AddrModeFlat; + stack.AddrFrame.Offset = (*ctx).Ebp; + stack.AddrFrame.Mode = AddrModeFlat; +#endif + + SymInitialize(process, NULL, TRUE); //load symbols + + for (frame = 0; ; frame++) + { + //get next call from stack + result = StackWalk64 + ( +#if defined(_M_AMD64) + IMAGE_FILE_MACHINE_AMD64 +#else + IMAGE_FILE_MACHINE_I386 +#endif + , + process, + thread, + &stack, + ctx, + NULL, + SymFunctionTableAccess64, + SymGetModuleBase64, + NULL + ); + + if (!result) break; + + //get symbol name for address + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = 2000; + SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, pSymbol); + + line = (IMAGEHLP_LINE64 *)malloc(sizeof(IMAGEHLP_LINE64)); + line->SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + //try to get line + if (SymGetLineFromAddr64(process, stack.AddrPC.Offset, &disp, line)) + { + printf("\tat %s in %s: line: %lu: address: 0x%0X\n", pSymbol->Name, line->FileName, line->LineNumber, pSymbol->Address); + } + else + { + //failed to get line + printf("\tat %s, address 0x%0X.\n", pSymbol->Name, pSymbol->Address); + hModule = NULL; + lstrcpyA(module, ""); + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCTSTR)(stack.AddrPC.Offset), &hModule); + + //at least print module name + if (hModule != NULL)GetModuleFileNameA(hModule, module, MaxNameLen); + + printf("in %s\n", module); + } + + free(line); + line = NULL; + } +} + +int seh_filter(_EXCEPTION_POINTERS* ex) +{ + printf("*** Exception 0x%x occured ***\n\n", ex->ExceptionRecord->ExceptionCode); + printStack(ex->ContextRecord); + + return EXCEPTION_EXECUTE_HANDLER; +} + +void PrintCallStack() +{ + __try + { + _Exceptor(); + } + __except (seh_filter(GetExceptionInformation())) + { + printf("Exception \n"); + } +}
\ No newline at end of file diff --git a/Editor/Utils/HelperFuncs.h b/Editor/Utils/HelperFuncs.h new file mode 100644 index 0000000..2ee7932 --- /dev/null +++ b/Editor/Utils/HelperFuncs.h @@ -0,0 +1,8 @@ +#pragma once + +#include <iostream> +#include <windows.h> + +std::string to_string(const char* cstr); + +extern void PrintCallStack();
\ No newline at end of file diff --git a/Editor/Utils/Log.cpp b/Editor/Utils/Log.cpp new file mode 100644 index 0000000..9ec7d42 --- /dev/null +++ b/Editor/Utils/Log.cpp @@ -0,0 +1,94 @@ +#include "log.h" +#include <iostream> +#include <ctime> +#include <unordered_set> +#include "HelperFuncs.h" + +using namespace std; + +//long g_LogTags = LogTag::All; +unordered_set<string> s_OpenTags; + +#ifdef GAMELAB_DEBUG +// https://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c +// Get current date/time, format is YYYY-MM-DD.HH:mm:ss +const std::string currentDateTime() { + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); + // Visit http://en.cppreference.com/w/cpp/chrono/c/strftime + // for more information about date/time format + strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct); + + return buf; +} + +void log_open_tag(std::string tag) +{ + s_OpenTags.insert(tag); +} + +// https://stackoverflow.com/questions/4053837/colorizing-text-in-the-console-with-c + +void log_info(std::string log) +{ + cout << "\x1B[97m" << currentDateTime() << " [Info] " << log << "\033[0m" << endl; +} + +void log_warning(std::string log) +{ + cout << "\x1B[93m" << currentDateTime() << " [Wanning] " << log << "\033[0m" << endl; +} + +void log_error(std::string log) +{ + cout << "\x1B[91m" << currentDateTime() << " [Error] " << log << "\033[0m" << endl; +} + +void log_error_null_param(std::string funcName, std::string param) +{ + log_error("Null parameter in " + funcName + " called " + param); +} + +void log_info(string tag, std::string log) +{ + if (s_OpenTags.count(tag) <= 0) + return; + log_info("[" + tag + "] " + log); +} +void log_warning(string tag, std::string log) +{ + if (s_OpenTags.count(tag) <= 0) + return; + log_warning("[" + tag + "] " + log); +} +void log_error(string tag, std::string log) +{ + if (s_OpenTags.count(tag) <= 0) + return; + log_error("[" + tag + "] " + log); +} +#else +void log_open_tag(std::string tag) {} +void log_info(std::string log) +{ +} + +void log_warning(std::string log) +{ +} + +void log_error(std::string log) +{ +} + +void log_error_null_param(std::string funcName, std::string param) +{ +} + +void log_info(string tag, std::string log) {} +void log_warning(string tag, std::string log) {} +void log_error(string tag, std::string log) {} + +#endif
\ No newline at end of file diff --git a/Editor/Utils/Log.h b/Editor/Utils/Log.h new file mode 100644 index 0000000..d66f705 --- /dev/null +++ b/Editor/Utils/Log.h @@ -0,0 +1,22 @@ +#pragma once +#include <string> + +//enum LogTag : unsigned long +//{ +// +// All = ~0 +//}; +// +//extern long g_LogTags; + +void log_open_tag(std::string tag); + +void log_info(std::string log); +void log_warning(std::string log); +void log_error(std::string log); + +void log_error_null_param(std::string funcName, std::string param); + +void log_info(std::string tag, std::string log); +void log_warning(std::string tag, std::string log); +void log_error(std::string tag, std::string log); diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj index c682fe5..6418165 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj +++ b/Projects/VisualStudio/Editor/Editor.vcxproj @@ -87,11 +87,12 @@ <Optimization>Disabled</Optimization> <SDLCheck>true</SDLCheck> <ConformanceMode>true</ConformanceMode> - <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>$(SolutionDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GAMELAB_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>$(SolutionDir)..\..\;$(SolutionDir)..\..\ThirdParty\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ClCompile> <Link> - <SubSystem>Windows</SubSystem> + <SubSystem>Console</SubSystem> + <AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> @@ -142,10 +143,17 @@ </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\..\..\Editor\EditorMain.cpp" /> + <ClCompile Include="..\..\..\Editor\EditorManager.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\ContainnerWindow.cpp" /> <ClCompile Include="..\..\..\Editor\GUI\Dock.cpp" /> - <ClCompile Include="..\..\..\Editor\GUI\EditorWindows.cpp" /> - <ClCompile Include="..\..\..\Editor\GUI\MenuController.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\WindowManager.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\GUIWindow.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\MenuManager.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\SplitWindow.cpp" /> + <ClCompile Include="..\..\..\Editor\GUI\WindowUtil.cpp" /> <ClCompile Include="..\..\..\Editor\GUI\WinUtils.cpp" /> + <ClCompile Include="..\..\..\Editor\Utils\HelperFuncs.cpp" /> + <ClCompile Include="..\..\..\Editor\Utils\Log.cpp" /> <ClCompile Include="..\..\..\Runtime\Math\Vector2.cpp" /> <ClCompile Include="..\..\..\Runtime\Math\Vector3.cpp" /> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindCFunctions.cpp" /> @@ -161,10 +169,14 @@ <ClCompile Include="..\..\..\Runtime\Utilities\Utf8.cpp" /> </ItemGroup> <ItemGroup> + <ClInclude Include="..\..\..\Editor\EditorManager.h" /> <ClInclude Include="..\..\..\Editor\GUI\Dock.h" /> <ClInclude Include="..\..\..\Editor\GUI\EditorWindows.h" /> - <ClInclude Include="..\..\..\Editor\GUI\MenuController.h" /> + <ClInclude Include="..\..\..\Editor\GUI\MenuManager.h" /> + <ClInclude Include="..\..\..\Editor\GUI\Rect.h" /> <ClInclude Include="..\..\..\Editor\GUI\WinUtils.h" /> + <ClInclude Include="..\..\..\Editor\Utils\HelperFuncs.h" /> + <ClInclude Include="..\..\..\Editor\Utils\Log.h" /> <ClInclude Include="..\..\..\Runtime\Math\AABB.h" /> <ClInclude Include="..\..\..\Runtime\Math\FloatConversion.h" /> <ClInclude Include="..\..\..\Runtime\Math\Rect.h" /> diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters index 982bd5b..de41fde 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters @@ -1,177 +1,230 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> - <Filter Include="GUI"> - <UniqueIdentifier>{87a57ef1-78d8-42b8-b179-ce1bbb5c4f8b}</UniqueIdentifier> + <Filter Include="Editor"> + <UniqueIdentifier>{37e66f64-a2fe-4adf-b435-e2e42ea17414}</UniqueIdentifier> + </Filter> + <Filter Include="Runtime"> + <UniqueIdentifier>{376fd2a5-5333-4bcb-9122-a112c40d5287}</UniqueIdentifier> </Filter> - <Filter Include="Math"> + <Filter Include="Runtime\Math"> <UniqueIdentifier>{ed31f129-996f-4a1c-b8d5-5c3d74139940}</UniqueIdentifier> </Filter> - <Filter Include="Utilities"> + <Filter Include="Runtime\Utilities"> <UniqueIdentifier>{61174975-2b52-426f-b871-d33e1bf956d4}</UniqueIdentifier> </Filter> - <Filter Include="Scripting"> + <Filter Include="Editor\Utils"> + <UniqueIdentifier>{e7e5a875-cafb-48df-9659-8f88d0377208}</UniqueIdentifier> + </Filter> + <Filter Include="Editor\GUI"> + <UniqueIdentifier>{87a57ef1-78d8-42b8-b179-ce1bbb5c4f8b}</UniqueIdentifier> + </Filter> + <Filter Include="Runtime\Scripting"> <UniqueIdentifier>{f9573ff2-4a53-4953-806e-f0ce0c586910}</UniqueIdentifier> </Filter> + <Filter Include="Runtime\Graphics"> + <UniqueIdentifier>{6c7e1979-1cd3-40c7-98e1-f063c325d642}</UniqueIdentifier> + </Filter> + <Filter Include="Editor\IMGUI"> + <UniqueIdentifier>{47032dd6-dca2-478f-b594-d08c0b22e119}</UniqueIdentifier> + </Filter> + <Filter Include="Editor\Scripting"> + <UniqueIdentifier>{bfc8b148-db9d-403d-96b9-32c946e15402}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="..\..\..\Editor\GUI\MenuController.cpp"> - <Filter>GUI</Filter> - </ClCompile> <ClCompile Include="..\..\..\Editor\GUI\Dock.cpp"> - <Filter>GUI</Filter> - </ClCompile> - <ClCompile Include="..\..\..\Editor\GUI\EditorWindows.cpp"> - <Filter>GUI</Filter> + <Filter>Editor\GUI</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Math\Vector2.cpp"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Math\Vector3.cpp"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Utilities\Base64.cpp"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Utilities\Utf8.cpp"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClCompile> <ClCompile Include="..\..\..\Editor\GUI\WinUtils.cpp"> - <Filter>GUI</Filter> + <Filter>Editor\GUI</Filter> </ClCompile> - <ClCompile Include="..\..\..\Editor\EditorMain.cpp" /> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindCFunctions.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindClass.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindEnum.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindMemberRef.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindRef.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindRefTable.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindState.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindVM.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClCompile> <ClCompile Include="..\..\..\Runtime\Scripting\LuaBindWatchDog.cpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\ContainnerWindow.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\GUIWindow.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\SplitWindow.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\Utils\Log.cpp"> + <Filter>Editor\Utils</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\WindowUtil.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\WindowManager.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\EditorMain.cpp"> + <Filter>Editor</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\EditorManager.cpp"> + <Filter>Editor</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\GUI\MenuManager.cpp"> + <Filter>Editor\GUI</Filter> + </ClCompile> + <ClCompile Include="..\..\..\Editor\Utils\HelperFuncs.cpp"> + <Filter>Editor\Utils</Filter> </ClCompile> </ItemGroup> <ItemGroup> - <ClInclude Include="..\..\..\Editor\GUI\MenuController.h"> - <Filter>GUI</Filter> - </ClInclude> <ClInclude Include="..\..\..\Editor\GUI\Dock.h"> - <Filter>GUI</Filter> + <Filter>Editor\GUI</Filter> </ClInclude> <ClInclude Include="..\..\..\Editor\GUI\EditorWindows.h"> - <Filter>GUI</Filter> + <Filter>Editor\GUI</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Math\AABB.h"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Math\FloatConversion.h"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Math\Rect.h"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Math\Vector2.h"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Math\Vector3.h"> - <Filter>Math</Filter> + <Filter>Runtime\Math</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Assert.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Base64.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Exception.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\NonCopyable.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Singleton.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Type.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\UIDGenerator.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\Utf8.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Utilities\UtilMacros.h"> - <Filter>Utilities</Filter> + <Filter>Runtime\Utilities</Filter> </ClInclude> <ClInclude Include="..\..\..\Editor\GUI\WinUtils.h"> - <Filter>GUI</Filter> + <Filter>Editor\GUI</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBind.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindCFunctions.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindClass.hpp"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindConfig.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindEnum.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindGlobalState.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindInternal.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindMemberRef.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindRef.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindRefTable.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindState.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindUtility.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindVM.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </ClInclude> <ClInclude Include="..\..\..\Runtime\Scripting\LuaBindWatchDog.h"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> + </ClInclude> + <ClInclude Include="..\..\..\Editor\Utils\Log.h"> + <Filter>Editor\Utils</Filter> + </ClInclude> + <ClInclude Include="..\..\..\Editor\GUI\Rect.h"> + <Filter>Editor\GUI</Filter> + </ClInclude> + <ClInclude Include="..\..\..\Editor\EditorManager.h"> + <Filter>Editor</Filter> + </ClInclude> + <ClInclude Include="..\..\..\Editor\Utils\HelperFuncs.h"> + <Filter>Editor\Utils</Filter> + </ClInclude> + <ClInclude Include="..\..\..\Editor\GUI\MenuManager.h"> + <Filter>Editor\GUI</Filter> </ClInclude> </ItemGroup> <ItemGroup> <None Include="..\..\..\Runtime\Scripting\LuaBindClass.inc"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </None> <None Include="..\..\..\Runtime\Scripting\LuaBindState.inc"> - <Filter>Scripting</Filter> + <Filter>Runtime\Scripting</Filter> </None> </ItemGroup> </Project>
\ No newline at end of file diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.user b/Projects/VisualStudio/Editor/Editor.vcxproj.user index be25078..db52b6c 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.user +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.user @@ -1,4 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\Resources</LocalDebuggerWorkingDirectory> + <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> + </PropertyGroup> </Project>
\ No newline at end of file diff --git a/Resources/Icon/GameLab.ico b/Resources/Icon/GameLab.ico Binary files differnew file mode 100644 index 0000000..ae94a7d --- /dev/null +++ b/Resources/Icon/GameLab.ico diff --git a/Resources/readme.txt b/Resources/readme.txt new file mode 100644 index 0000000..e3b0dc5 --- /dev/null +++ b/Resources/readme.txt @@ -0,0 +1 @@ +编辑器用的资源
\ No newline at end of file diff --git a/Runtime/Utilities/Assert.h b/Runtime/Utilities/Assert.h index 4eb7b7a..526ca32 100644 --- a/Runtime/Utilities/Assert.h +++ b/Runtime/Utilities/Assert.h @@ -3,7 +3,7 @@ #include <assert.h> -#define Assert(c) assert(c) +#define Assert(c) assert((c)) #define DebugAssertIf(c) assert(c) #define AssertIf(c) assert(c) |