From 7b31e3576b8a8cc5a821575c30383975a52e5c3a Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 22 Aug 2020 15:34:07 +0800 Subject: [PATCH] add error window for materializer --- README.md | 2 +- SuperScriptMaterializer.sln | 24 ++-- .../SuperScriptMaterializer.vcxproj | 113 +++++------------- SuperScriptMaterializer/vt_menu.cpp | 88 ++++++++++---- SuperScriptMaterializer/vt_menu.h | 2 + 5 files changed, 114 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index a9a9d4e..a1dfa91 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The inspiration came from: * This project does not give ability to edit hidden scripts within the file. It simply exports and views. * The latest commit may not be stable to use, please visit the Release page to get a stable version. -* The development cycle of this program is very long. If you use a version before the first official version, you need to rebuild all the data because the previous version is not compatible with the official version. +* If you change the version (including the version before the first stable version), then you need to rebuild all the data, because the data between the various versions may not be compatible with each other. ## Requirements diff --git a/SuperScriptMaterializer.sln b/SuperScriptMaterializer.sln index 491a735..215b4ac 100644 --- a/SuperScriptMaterializer.sln +++ b/SuperScriptMaterializer.sln @@ -17,18 +17,18 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|Any CPU.ActiveCfg = VT5|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|Any CPU.Build.0 = VT5|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x64.ActiveCfg = VT5|x64 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x64.Build.0 = VT5|x64 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.ActiveCfg = VT35|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.Build.0 = VT35|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|Any CPU.ActiveCfg = VT5|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|Any CPU.Build.0 = VT5|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x64.ActiveCfg = VT5|x64 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x64.Build.0 = VT5|x64 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.ActiveCfg = VT5|Win32 - {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.Build.0 = VT5|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|Any CPU.ActiveCfg = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|Any CPU.Build.0 = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x64.ActiveCfg = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x64.Build.0 = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.ActiveCfg = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.Build.0 = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|Any CPU.ActiveCfg = VT5Release|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|Any CPU.Build.0 = VT5Release|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x64.ActiveCfg = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x64.Build.0 = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.ActiveCfg = VT5Debug|Win32 + {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.Build.0 = VT5Debug|Win32 {6D751BF5-87D6-4123-94B3-34721938CF04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D751BF5-87D6-4123-94B3-34721938CF04}.Debug|x64.ActiveCfg = Debug|Any CPU {6D751BF5-87D6-4123-94B3-34721938CF04}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj index a88e5ee..a80dcce 100644 --- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj +++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj @@ -1,30 +1,14 @@ - - VT35 + + VT5Debug Win32 - - VT35 - x64 - - - VT4 + + VT5Release Win32 - - VT4 - x64 - - - VT5 - Win32 - - - VT5 - x64 - 16.0 @@ -33,29 +17,19 @@ 10.0 - - v142 - - - v142 - - + v142 DynamicLibrary Dynamic MultiByte - - v142 + DynamicLibrary - Dynamic + false + v142 + true MultiByte - - - v142 - - - v142 + Dynamic @@ -63,33 +37,28 @@ - + E:\Virtools\Virtools Dev 5.0\InterfacePlugins\ true Temp\$(Configuration)\ - - E:\Virtools\Virtools Dev 4.0\InterfacePlugins\ - true + + E:\Virtools\Virtools Dev 5.0\InterfacePlugins\ Temp\$(Configuration)\ - + EditAndContinue - - - EditAndContinue - - - + Level3 D:\CppLib\SQLite\sqlite-amalgamation-3310100;E:\Virtools\Virtools Dev 5.0\Sdk\Includes;%(AdditionalIncludeDirectories) Disabled WIN32;_WINDOWS;_USRDLL;VIRTOOLS_5;VX_MEM_RELEASE;%(PreprocessorDefinitions) EnableFastChecks + true E:\Virtools\Virtools Dev 5.0\InterfacePlugins\$(ProjectName).dll @@ -103,47 +72,31 @@ SuperScriptMaterializer.def - + Level3 - D:\CppLib\SQLite\sqlite-amalgamation-3310100;E:\Virtools\Virtools Dev 4.0\Sdk\Includes;%(AdditionalIncludeDirectories) Disabled - WIN32;_WINDOWS;_USRDLL;VIRTOOLS_4;VX_MEM_RELEASE;%(PreprocessorDefinitions) + + + true + + + false + Default + D:\CppLib\SQLite\sqlite-amalgamation-3310100;E:\Virtools\Virtools Dev 5.0\Sdk\Includes;%(AdditionalIncludeDirectories) + ProgramDatabase + WIN32;_WINDOWS;_USRDLL;VIRTOOLS_5;VX_MEM_RELEASE;_RELEASE;%(PreprocessorDefinitions) EnableFastChecks - E:\Virtools\Virtools Dev 4.0\InterfacePlugins\$(ProjectName).dll - - - D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100;E:\Virtools\Virtools Dev 4.0\Sdk\Lib\Win32\Release;%(AdditionalLibraryDirectories) - vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib;sqlite3.lib;%(AdditionalDependencies) - true - E:\Virtools\Virtools Dev 4.0\InterfacePlugins\$(ProjectName).pdb Windows + true + true SuperScriptMaterializer.def - - - - - SuperScriptMaterializer.def - - - - - SuperScriptMaterializer.def - - - - - SuperScriptMaterializer.def - - - VIRTOOLS_35;%(PreprocessorDefinitions) - - - - - SuperScriptMaterializer.def + E:\Virtools\Virtools Dev 5.0\InterfacePlugins\$(ProjectName).dll + D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100;E:\Virtools\Virtools Dev 5.0\Sdk\Lib\Win32\Release;%(AdditionalLibraryDirectories) + vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib;sqlite3.lib;%(AdditionalDependencies) + E:\Virtools\Virtools Dev 5.0\InterfacePlugins\$(ProjectName).pdb diff --git a/SuperScriptMaterializer/vt_menu.cpp b/SuperScriptMaterializer/vt_menu.cpp index edd57f7..e09fda4 100644 --- a/SuperScriptMaterializer/vt_menu.cpp +++ b/SuperScriptMaterializer/vt_menu.cpp @@ -48,6 +48,9 @@ void UpdateMenu() { s_Plugininterface->AddPluginMenuItem(s_MainMenu, 0, "Export all scripts"); s_Plugininterface->AddPluginMenuItem(s_MainMenu, 1, "Export environment"); + s_Plugininterface->AddPluginMenuItem(s_MainMenu, -1, NULL, TRUE); + s_Plugininterface->AddPluginMenuItem(s_MainMenu, 2, "Report bug"); + s_Plugininterface->AddPluginMenuItem(s_MainMenu, 3, "Plugin homepage"); //===========================freeze chirs241097 code for future expand //s_Plugininterface->AddPluginMenuItem(s_MainMenu, -1, NULL, TRUE); @@ -68,31 +71,24 @@ void PluginMenuCallback(int commandID) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CKContext* ctx = s_Plugininterface->GetCKContext(); - OPENFILENAME ofn; - char* file = (char*)malloc(1024 * sizeof(char)); - ZeroMemory(&ofn, sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.lpstrFile = file; - ofn.lpstrFile[0] = '\0'; - ofn.nMaxFile = 1024; - ofn.lpstrFilter = "Database file(*.db)\0*.db\0"; - ofn.lpstrDefExt = "db"; - ofn.lpstrFileTitle = NULL; - ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; - ofn.Flags = OFN_EXPLORER; - if (GetSaveFileName(&ofn)) { - //make sure file is not exist - DeleteFile(file); - - //switch mode + //switch mode +#if defined(_RELEASE) + try { +#endif switch (commandID) { case 0: { + //init file + std::string file; + OpenFileDialog(&file); + if (file.empty()) + break; + DeleteFile(file.c_str()); + //init resources scriptDatabase* _db = new scriptDatabase(); dbScriptDataStructHelper* _helper = new dbScriptDataStructHelper(); - _db->open(file); + _db->open(file.c_str()); _helper->init(ctx->GetParameterManager()); //iterate item @@ -103,14 +99,23 @@ void PluginMenuCallback(int commandID) { _db->close(); delete _helper; delete _db; + + ctx->OutputToConsole("[Super Script Materializer] Done"); } break; case 1: { + //init file + std::string file; + OpenFileDialog(&file); + if (file.empty()) + break; + DeleteFile(file.c_str()); + //init envDatabase* _db = new envDatabase(); dbEnvDataStructHelper* _helper = new dbEnvDataStructHelper(); - _db->open(file); + _db->open(file.c_str()); _helper->init(); //iterate parameter operation/param @@ -126,10 +131,49 @@ void PluginMenuCallback(int commandID) { _db->close(); delete _helper; delete _db; + + ctx->OutputToConsole("[Super Script Materializer] Done"); } break; + case 2: + ShellExecute(NULL, "open", "https://github.com/yyc12345/SuperScriptMaterializer/issues", NULL, NULL, SW_SHOWNORMAL); + break; + case 3: + ShellExecute(NULL, "open", "https://github.com/yyc12345/SuperScriptMaterializer", NULL, NULL, SW_SHOWNORMAL); + break; } - ctx->OutputToConsole("[Super Script Materializer] Done"); +#if defined(_RELEASE) + } catch (const std::exception & e) { + std::string errstr; + errstr = "An error occurs, application will exit. Please report to developer with this window and reproduce step.\nError message: "; + errstr += e.what(); + AfxMessageBox(errstr.c_str(), MB_OK | MB_ICONSTOP); + exit(1); } - free(file); +#endif +} + + +BOOL OpenFileDialog(std::string* returned_file) { + returned_file->clear(); + + char* file = (char*)malloc(1024 * sizeof(char)); + BOOL status; + OPENFILENAME OpenFileStruct; + ZeroMemory(&OpenFileStruct, sizeof(OPENFILENAME)); + OpenFileStruct.lStructSize = sizeof(OPENFILENAME); + OpenFileStruct.lpstrFile = file; + OpenFileStruct.lpstrFile[0] = '\0'; + OpenFileStruct.nMaxFile = 1024; + OpenFileStruct.lpstrFilter = "Database file(*.db)\0*.db\0"; + OpenFileStruct.lpstrDefExt = "db"; + OpenFileStruct.lpstrFileTitle = NULL; + OpenFileStruct.nMaxFileTitle = 0; + OpenFileStruct.lpstrInitialDir = NULL; + OpenFileStruct.Flags = OFN_EXPLORER; + if (status = GetSaveFileName(&OpenFileStruct)) + *returned_file = file; + + free(file); + return status; } diff --git a/SuperScriptMaterializer/vt_menu.h b/SuperScriptMaterializer/vt_menu.h index 86c6376..1213a47 100644 --- a/SuperScriptMaterializer/vt_menu.h +++ b/SuperScriptMaterializer/vt_menu.h @@ -11,4 +11,6 @@ void RemoveMenu(); void UpdateMenu(); void PluginMenuCallback(int commandID); +BOOL OpenFileDialog(std::string* returned_file); + #endif \ No newline at end of file