From cb3931550fdc9006a1fb2d930523632a6ea1ea18 Mon Sep 17 00:00:00 2001 From: Albert Frengki <75172149+AlberttFrgk@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:58:11 +0700 Subject: [PATCH] Revert "" This reverts commit 0e2f06ffa8f58f41979448686df2b8d2df11fd18. --- Game/src/main.cpp | 86 ++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/Game/src/main.cpp b/Game/src/main.cpp index 77d9452..c6c1e98 100644 --- a/Game/src/main.cpp +++ b/Game/src/main.cpp @@ -4,8 +4,11 @@ // STD Headers #include #include -#include -#include +#include + +#if __linux__ +#include +#endif // Game Headers #include "./Data/Util/Util.hpp" @@ -17,9 +20,6 @@ #include "Configuration.h" #include "MsgBox.h" -// SDL Headers -#include - #if _WIN32 extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; @@ -28,7 +28,7 @@ extern "C" { } #endif -int Run(int argc, wchar_t** argv) +int Run(int argc, wchar_t **argv) { try { Configuration::SetDefaultConfiguration(defaultConfiguration); @@ -40,6 +40,8 @@ int Run(int argc, wchar_t** argv) #if _WIN32 if (SetCurrentDirectoryW((LPWSTR)parentPath.wstring().c_str()) == FALSE) { + std::cout << "GetLastError(): " << GetLastError() << ", with path: " << parentPath.string(); + MessageBoxA(NULL, "Failed to set directory!", "EstGame Error", MB_ICONERROR); return -1; } @@ -81,8 +83,7 @@ int Run(int argc, wchar_t** argv) } return 0; - } - catch (std::exception& e) { + } catch (std::exception &e) { MsgBox::ShowOut("EstGame Error", e.what(), MsgBoxType::OK, MsgBoxFlags::BTN_ERROR); return -1; } @@ -94,37 +95,42 @@ int HandleStructualException(int code) MessageBoxA(NULL, ("Uncaught exception: " + std::to_string(code)).c_str(), "FATAL ERROR", MB_ICONERROR); return EXCEPTION_EXECUTE_HANDLER; } +#endif -// SDL expects an SDL_main function as the entry point -int SDL_main(int argc, char* argv[]) -{ - const char* retVal = setlocale(LC_ALL, "en_US.UTF-8"); - if (retVal == nullptr) { - MessageBoxA(NULL, "setlocale(): Failed to set locale!", "EstGame Error", MB_ICONERROR); - return -1; - } +// // if not DEBUG +// #if !defined(_DEBUG) && _WIN32 +// int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { +// const char* retVal = setlocale(LC_ALL, "en_US.UTF-8"); +// if (retVal == nullptr) { +// MessageBoxA(NULL, "setlocale(): Failed to set locale!", "EstGame Error", MB_ICONERROR); +// return -1; +// } - // Convert command line arguments - int wargc = 0; - wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); +// int argc = 0; +// wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc); - int ret = 0; +// int ret = 0; - __try { - ret = Run(wargc, wargv); - } - __except (HandleStructualException(GetExceptionCode())) { - ret = -1; - } +// __try { +// ret = Run(argc, argv); +// } - LocalFree(wargv); +// __except (HandleStructualException(GetExceptionCode())) { +// ret = -1; +// } - return ret; -} -#else -int main(int argc, char* argv[]) +// LocalFree(argv); + +// return ret; +// } + +// #else + +// #endif + +int main(int argc, char *argv[]) { - const char* retVal = setlocale(LC_ALL, "en_US.UTF-8"); + const char *retVal = setlocale(LC_ALL, "en_US.UTF-8"); if (retVal == nullptr) { #if _WIN32 MessageBoxA(NULL, "setlocale(): Failed to set locale!", "EstGame Error", MB_ICONERROR); @@ -134,7 +140,7 @@ int main(int argc, char* argv[]) return -1; } - wchar_t** wargv = new wchar_t* [argc]; + wchar_t **wargv = new wchar_t *[argc]; for (int i = 0; i < argc; i++) { size_t len = mbstowcs(NULL, argv[i], 0) + 1; wargv[i] = new wchar_t[len]; @@ -143,10 +149,11 @@ int main(int argc, char* argv[]) int ret = 0; -#if _MSC_VER && !defined(NDEBUG) +#if _WIN32 & _MSC_VER & NDEBUG __try { ret = Run(argc, wargv); } + __except (HandleStructualException(GetExceptionCode())) { ret = -1; } @@ -162,4 +169,13 @@ int main(int argc, char* argv[]) return ret; } -#endif + +// #include "./Engine/LuaScripting.h" + +// int main() { +// LuaScripting lua = { std::filesystem::current_path() / "Skins" / "Default" / "Scripts" }; +// lua.Update(0.0); + +// auto val = lua.GetSprite(SkinGroup::Playing, "JamLogo"); +// return 0; +// }