diff options
Diffstat (limited to 'Editor')
-rw-r--r-- | Editor/EditorMain.cpp | 12 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 2 | ||||
-rw-r--r-- | Editor/GUI/GUIWindow.cpp | 2 | ||||
-rw-r--r-- | Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp | 8 | ||||
-rw-r--r-- | Editor/Scripting/EditorGUI/EditorGUI.bind.cpp | 11 | ||||
-rw-r--r-- | Editor/Scripting/EditorScripting.cpp | 20 | ||||
-rw-r--r-- | Editor/Utils/Log.cpp | 94 | ||||
-rw-r--r-- | Editor/Utils/Log.h | 22 |
8 files changed, 29 insertions, 142 deletions
diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp index 9745598..1606e94 100644 --- a/Editor/EditorMain.cpp +++ b/Editor/EditorMain.cpp @@ -35,13 +35,6 @@ static int MainLoop() return (INT)msg.wParam; }
-void OpenLogTags()
-{
- //log_open_tag("WndProc");
- //log_open_tag("Menu");
- log_open_tag("Scripting");
-}
-
void InitLuaState()
{
LuaBind::VM vm;
@@ -61,11 +54,10 @@ int main() int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #endif {
- OpenLogTags();
- WindowUtil::Init();
-
InitLuaState();
+ WindowUtil::Init();
+
ContainnerWindow* wnd = new ContainnerWindow();
Vector2f min = Vector2f(100, 100);
Vector2f max = Vector2f(700, 700);
diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 42d2623..307ab86 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -6,7 +6,7 @@ #include "Runtime/Math/Rect.h" #include "Runtime/LuaBind/LuaBind.h" #include "Runtime/Utilities/Singleton.h" -#include "Editor/Utils/Log.h" +#include "Runtime/Debug/Log.h" #include "Runtime/Graphics/OpenGL.h" #include "Runtime/Utilities/UtilMacros.h" #include "Editor/Utils/HelperFuncs.h" diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index e58b620..3df0370 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -56,7 +56,7 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara case WM_MOUSEWHEEL: // 在这个子窗口滚动 { - log_info("WM_MOUSEWHEEL"); + log_info("WndProc","WM_MOUSEWHEEL"); // quick check if mouse is in our window RECT rc; diff --git a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp index f51b6b4..265ea2e 100644 --- a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp +++ b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp @@ -10,6 +10,14 @@ LUA_BIND_REGISTRY(ContainnerWindow) LUA_BIND_POSTPROCESS(ContainnerWindow) { + LUA_BIND_REGISTER_ENUM(state, "EShowMode", + { "NormalWindow", ShowMode::kShowNormalWindow }, + { "ShowPopupMenu", ShowMode::kShowPopupMenu }, + { "Utility ", ShowMode::kShowUtility }, + { "NoShadow", ShowMode::kShowNoShadow }, + { "MainWindow", ShowMode::kShowMainWindow }, + { "AuxWindow", ShowMode::kShowAuxWindow } + ); } LUA_BIND_IMPL_METHOD(ContainnerWindow, _SetTitle) diff --git a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp index be97638..57c45ca 100644 --- a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp +++ b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp @@ -1,21 +1,18 @@ #include "Editor/GUI/EditorWindows.h" // GameLab.Editor.GUI -void luaopen_GameLab_Editor_GUI(lua_State* L) +int luaopen_GameLab_Editor_GUI(lua_State* L) { + log_info("Scripting", "luaopen_GameLab_Editor_GUI()"); + LUA_BIND_STATE(L); state.PushGlobalNamespace(); - state.PushNamespace("GameLab"); state.PushNamespace("Editor"); state.PushNamespace("GUI"); state.RegisterFactory<ContainnerWindow>(); - state.PopNamespace();// EditorGUI - state.PopNamespace();// GameLab - state.PopNamespace();// Editor - state.PopNamespace();// Global - + return 1; }
\ No newline at end of file diff --git a/Editor/Scripting/EditorScripting.cpp b/Editor/Scripting/EditorScripting.cpp index 235636a..65fa8c4 100644 --- a/Editor/Scripting/EditorScripting.cpp +++ b/Editor/Scripting/EditorScripting.cpp @@ -1,22 +1,28 @@ #include "EditorScripting.h" -#include "Editor/Utils/Log.h" +#include "Runtime/Debug/Log.h" // GameLab.Editor -extern void luaopen_GameLab_Editor_GUI(lua_State* L); // GameLab.Editor.GUI -extern void luaopen_GameLab_Editor_GUILayout(lua_State* L); // GameLab.Editor.GUILayout -extern void luaopen_GameLab_Editor_IMGUI(lua_State* L); // GameLab.Editor.IMGUI -extern void luaopen_GameLab_Editor_Resource(lua_State* L); // GameLab.Editor.Resource +extern int luaopen_GameLab_Editor_GUI(lua_State* L); // GameLab.Editor.GUI +extern int luaopen_GameLab_Editor_GUILayout(lua_State* L); // GameLab.Editor.GUILayout +extern int luaopen_GameLab_Editor_IMGUI(lua_State* L); // GameLab.Editor.IMGUI +extern int luaopen_GameLab_Editor_Resource(lua_State* L); // GameLab.Editor.Resource // GameLab.Engine +extern int luaopen_GameLab_Engine_Rendering(lua_State* L); // GameLab.Engine.Rendering // GameLab -extern void luaopen_GameLab_Debug(lua_State* L); +extern int luaopen_GameLab_Debug(lua_State* L); + +#define openlib(cfunc) \ + lua_pushcfunction(L, cfunc);\ + lua_call(L, 0, 0); bool SetupGameLabEditorScripting(lua_State* L) { log_info("Scripting", "SetupGameLabEditorScripting()"); - luaopen_GameLab_Editor_GUI(L); + openlib(luaopen_GameLab_Debug); + openlib(luaopen_GameLab_Editor_GUI); return true; } diff --git a/Editor/Utils/Log.cpp b/Editor/Utils/Log.cpp deleted file mode 100644 index 9ec7d42..0000000 --- a/Editor/Utils/Log.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#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 deleted file mode 100644 index d66f705..0000000 --- a/Editor/Utils/Log.h +++ /dev/null @@ -1,22 +0,0 @@ -#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); |