refactor: add a dialog for choosing export encoding
This commit is contained in:
@@ -22,6 +22,10 @@ PRIVATE
|
|||||||
# Utilities
|
# Utilities
|
||||||
Utilities.cpp
|
Utilities.cpp
|
||||||
Database.cpp
|
Database.cpp
|
||||||
|
# MFC parts
|
||||||
|
ExportDialog.cpp
|
||||||
|
# Resources file
|
||||||
|
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:Materializer.rc>"
|
||||||
# Defination file
|
# Defination file
|
||||||
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:Materializer.def>"
|
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:Materializer.def>"
|
||||||
)
|
)
|
||||||
@@ -33,7 +37,6 @@ FILES
|
|||||||
# Headers
|
# Headers
|
||||||
# Misc
|
# Misc
|
||||||
stdafx.hpp
|
stdafx.hpp
|
||||||
resource.h
|
|
||||||
# Main
|
# Main
|
||||||
PluginMain.hpp
|
PluginMain.hpp
|
||||||
StandaloneMain.hpp
|
StandaloneMain.hpp
|
||||||
@@ -43,6 +46,9 @@ FILES
|
|||||||
Utilities.hpp
|
Utilities.hpp
|
||||||
Database.hpp
|
Database.hpp
|
||||||
DataTypes.hpp
|
DataTypes.hpp
|
||||||
|
# MFC Parts
|
||||||
|
resource.h
|
||||||
|
ExportDialog.hpp
|
||||||
)
|
)
|
||||||
# Setup header infomations
|
# Setup header infomations
|
||||||
target_include_directories(VSWMaterializer
|
target_include_directories(VSWMaterializer
|
||||||
@@ -69,10 +75,12 @@ PROPERTIES
|
|||||||
CXX_EXTENSION OFF
|
CXX_EXTENSION OFF
|
||||||
)
|
)
|
||||||
# Setup MFC used in shared library
|
# Setup MFC used in shared library
|
||||||
set_target_properties(VSWMaterializer
|
if (MATERIALIZER_BUILD_TYPE STREQUAL "plugin")
|
||||||
PROPERTIES
|
set_target_properties(VSWMaterializer
|
||||||
CMAKE_MFC_FLAG 2
|
PROPERTIES
|
||||||
)
|
CMAKE_MFC_FLAG 2
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
# MSVC specific correction
|
# MSVC specific correction
|
||||||
target_compile_definitions(VSWMaterializer
|
target_compile_definitions(VSWMaterializer
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdafx.hpp"
|
#include "stdafx.hpp"
|
||||||
#include "GenericDataTypes.hpp"
|
#include <GenericHelper.hpp>
|
||||||
|
|
||||||
namespace VSW::Materializer::DataTypes {
|
namespace VSW::Materializer::DataTypes {
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdafx.hpp"
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
namespace YYCC::Materializer {
|
namespace VSW::Materializer {
|
||||||
|
|
||||||
namespace ExportScript {
|
namespace ExportScript {
|
||||||
void Export(CKContext* ctx, YYCC::yycc_u8string_view& db_path);
|
void Export(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ExportDocument {
|
namespace ExportDocument {
|
||||||
void Export(CKContext* ctx, YYCC::yycc_u8string_view& db_path);
|
void Export(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ExportEnvironment {
|
namespace ExportEnvironment {
|
||||||
void Export(CKContext* ctx, YYCC::yycc_u8string_view& db_path);
|
void Export(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
255
materializer/ExportDialog.cpp
Normal file
255
materializer/ExportDialog.cpp
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
#if defined(MATERIALIZER_PLUGIN)
|
||||||
|
|
||||||
|
#include "ExportDialog.hpp"
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace VSW::Materializer {
|
||||||
|
|
||||||
|
class ExportDialogSetting {
|
||||||
|
public:
|
||||||
|
static ExportDialogSetting& GetSingleton();
|
||||||
|
private:
|
||||||
|
static YYCC::yycc_u8string GetConfigFilePath();
|
||||||
|
ExportDialogSetting() :
|
||||||
|
m_LastFilePath(YYCC_U8("last-file-path"), YYCC_U8("")),
|
||||||
|
m_Encoding(YYCC_U8("encoding"), CP_ACP),
|
||||||
|
m_Mgr(ExportDialogSetting::GetConfigFilePath(), UINT64_C(0), {
|
||||||
|
&m_LastFilePath, &m_Encoding
|
||||||
|
}) {
|
||||||
|
m_Mgr.Load();
|
||||||
|
}
|
||||||
|
~ExportDialogSetting() {
|
||||||
|
m_Mgr.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
YYCC::ConfigManager::StringSetting m_LastFilePath;
|
||||||
|
YYCC::ConfigManager::NumberSetting<UINT> m_Encoding;
|
||||||
|
YYCC::ConfigManager::CoreManager m_Mgr;
|
||||||
|
};
|
||||||
|
ExportDialogSetting& ExportDialogSetting::GetSingleton() {
|
||||||
|
static ExportDialogSetting g_Singleton;
|
||||||
|
return g_Singleton;
|
||||||
|
}
|
||||||
|
YYCC::yycc_u8string ExportDialogSetting::GetConfigFilePath() {
|
||||||
|
// get path to executable virtools
|
||||||
|
YYCC::yycc_u8string u8_virtools_path;
|
||||||
|
if (!YYCC::WinFctHelper::GetModuleFileName(NULL, u8_virtools_path))
|
||||||
|
u8_virtools_path.clear();
|
||||||
|
// get its parent folder and append with cfg file name
|
||||||
|
std::filesystem::path virtools_path(YYCC::FsPathPatch::FromUTF8Path(u8_virtools_path.c_str()));
|
||||||
|
return YYCC::FsPathPatch::ToUTF8Path(virtools_path.parent_path() / YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("vsw_materializer.cfg")));
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ExportDialogHelper {
|
||||||
|
|
||||||
|
#define RADIOBTN_GETCHECK(instance) (instance.GetCheck() == BST_CHECKED)
|
||||||
|
#define RADIOBTN_SETCHECK(instance, stmt) (instance.SetCheck((stmt) ? BST_CHECKED : BST_UNCHECKED))
|
||||||
|
|
||||||
|
static bool ValidateCodePage(UINT code_page) {
|
||||||
|
CPINFOEXW cpinfo;
|
||||||
|
return GetCPInfoExW(code_page, 0, &cpinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetCWndText(CWnd* ctl, const YYCC::yycc_u8string_view& val) {
|
||||||
|
ctl->SetWindowTextA(YYCC::EncodingHelper::UTF8ToChar(val, CP_ACP).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
YYCC::yycc_u8string GetCWndText(CWnd* ctl) {
|
||||||
|
// Ref: https://learn.microsoft.com/zh-cn/cpp/mfc/reference/cwnd-class?view=msvc-170#getwindowtext
|
||||||
|
CString recv;
|
||||||
|
ctl->GetWindowTextA(recv);
|
||||||
|
return YYCC::EncodingHelper::CharToUTF8((LPCSTR)recv, CP_ACP);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportDialog dialog
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(ExportDialog, CDialogEx)
|
||||||
|
|
||||||
|
ExportDialog::ExportDialog(CWnd* pParent /*=nullptr*/)
|
||||||
|
: CDialogEx(IDD_EXPORT_DIALOG, pParent),
|
||||||
|
m_InitialDatabaseType(InitialDatabaseType::Script),
|
||||||
|
m_DatabaseFileCache(),
|
||||||
|
m_DatabaseFileResult(), m_EncodingResult(CP_ACP) {}
|
||||||
|
|
||||||
|
ExportDialog::~ExportDialog() {}
|
||||||
|
|
||||||
|
void ExportDialog::DoDataExchange(CDataExchange* pDX) {
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, IDC_EDIT1, m_DatabaseFile);
|
||||||
|
DDX_Control(pDX, IDC_RADIO1, m_EncodingSystem);
|
||||||
|
DDX_Control(pDX, IDC_RADIO2, m_EncodingCustom);
|
||||||
|
DDX_Control(pDX, IDC_EDIT2, m_EncodingCustom_Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(ExportDialog, CDialogEx)
|
||||||
|
// ===== Buttons =====
|
||||||
|
ON_BN_CLICKED(IDOK, &ExportDialog::OnBtnOkClicked)
|
||||||
|
ON_BN_CLICKED(IDCANCEL, &ExportDialog::OnBtnCancelClicked)
|
||||||
|
ON_BN_CLICKED(IDC_BUTTON1, &ExportDialog::OnBtnBrowseClicked)
|
||||||
|
// ===== Radio Buttons =====
|
||||||
|
ON_BN_CLICKED(IDC_RADIO1, &ExportDialog::OnBtnEncodingClicked)
|
||||||
|
ON_BN_CLICKED(IDC_RADIO2, &ExportDialog::OnBtnEncodingClicked)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
#pragma region Initial Settings
|
||||||
|
|
||||||
|
void ExportDialog::SetInitialDatabaseType(InitialDatabaseType db_type) {
|
||||||
|
m_InitialDatabaseType = db_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Result Getter
|
||||||
|
|
||||||
|
const YYCC::yycc_u8string& ExportDialog::GetDatabaseFileResult() {
|
||||||
|
return m_DatabaseFileResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT ExportDialog::GetEncodingResult() {
|
||||||
|
return m_EncodingResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
// ExportDialog message handlers
|
||||||
|
|
||||||
|
#pragma region Event Handler
|
||||||
|
|
||||||
|
BOOL ExportDialog::OnInitDialog() {
|
||||||
|
CDialogEx::OnInitDialog();
|
||||||
|
|
||||||
|
// Read settings from config manager
|
||||||
|
auto& config_manager = ExportDialogSetting::GetSingleton();
|
||||||
|
auto u8_last_path = config_manager.m_LastFilePath.Get();
|
||||||
|
if (!u8_last_path.empty()) {
|
||||||
|
auto last_path = YYCC::FsPathPatch::FromUTF8Path(u8_last_path.c_str());
|
||||||
|
switch (m_InitialDatabaseType) {
|
||||||
|
case InitialDatabaseType::Script:
|
||||||
|
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("script.db")));
|
||||||
|
break;
|
||||||
|
case InitialDatabaseType::Document:
|
||||||
|
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("doc.db")));
|
||||||
|
break;
|
||||||
|
case InitialDatabaseType::Environment:
|
||||||
|
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("env.db")));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("invalid initial database type");
|
||||||
|
}
|
||||||
|
u8_last_path = YYCC::FsPathPatch::ToUTF8Path(last_path);
|
||||||
|
}
|
||||||
|
PushDatabaseFile(u8_last_path);
|
||||||
|
PushEncoding(config_manager.m_Encoding.Get());
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnBtnOkClicked() {
|
||||||
|
// ===== Collect input settings =====
|
||||||
|
m_DatabaseFileResult = PullDatabaseFile();
|
||||||
|
m_EncodingResult = PullEncoding();
|
||||||
|
if (m_DatabaseFileResult.empty()) {
|
||||||
|
MessageBoxW(m_hWnd, L"Exported database file should not be empty!", L"Setting Error", MB_OK + MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!ExportDialogHelper::ValidateCodePage(m_EncodingResult)) {
|
||||||
|
MessageBoxW(m_hWnd, L"Invalid encoding!", L"Setting Error", MB_OK + MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check done. sync settings to config manager
|
||||||
|
auto& config_manager = ExportDialogSetting::GetSingleton();
|
||||||
|
config_manager.m_LastFilePath.Set(m_DatabaseFileResult);
|
||||||
|
config_manager.m_Encoding.Set(m_EncodingResult);
|
||||||
|
|
||||||
|
CDialogEx::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnBtnCancelClicked() {
|
||||||
|
CDialogEx::OnCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnBtnBrowseClicked() {
|
||||||
|
// configure dialog properties
|
||||||
|
YYCC::DialogHelper::FileDialog dialog_settings;
|
||||||
|
auto& dialog_filter = dialog_settings.ConfigreFileTypes();
|
||||||
|
dialog_filter.Add(YYCC_U8("Database File (*.db)"), { YYCC_U8("*.db") });
|
||||||
|
dialog_settings.SetOwner(this->m_hWnd);
|
||||||
|
switch (m_InitialDatabaseType) {
|
||||||
|
case InitialDatabaseType::Script:
|
||||||
|
dialog_settings.SetInitFileName(YYCC_U8("script.db"));
|
||||||
|
break;
|
||||||
|
case InitialDatabaseType::Document:
|
||||||
|
dialog_settings.SetInitFileName(YYCC_U8("doc.db"));
|
||||||
|
break;
|
||||||
|
case InitialDatabaseType::Environment:
|
||||||
|
dialog_settings.SetInitFileName(YYCC_U8("env.db"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("invalid initial database type");
|
||||||
|
}
|
||||||
|
|
||||||
|
// open directory picker and assign it if user click ok.
|
||||||
|
YYCC::yycc_u8string picked_file;
|
||||||
|
if (YYCC::DialogHelper::SaveFileDialog(dialog_settings, picked_file)) {
|
||||||
|
PushDatabaseFile(picked_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnBtnEncodingClicked() {
|
||||||
|
UpdateLayouts();
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Assist Functions
|
||||||
|
|
||||||
|
const YYCC::yycc_u8string& ExportDialog::PullDatabaseFile() {
|
||||||
|
return m_DatabaseFileCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::PushDatabaseFile(const YYCC::yycc_u8string& data) {
|
||||||
|
m_DatabaseFileCache = data;
|
||||||
|
ExportDialogHelper::SetCWndText(&m_DatabaseFile, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT ExportDialog::PullEncoding() {
|
||||||
|
if (RADIOBTN_GETCHECK(m_EncodingSystem)) return CP_ACP;
|
||||||
|
else if (RADIOBTN_GETCHECK(m_EncodingCustom)) {
|
||||||
|
UINT result;
|
||||||
|
if (!YYCC::ParserHelper::TryParse(ExportDialogHelper::GetCWndText(&m_EncodingCustom_Value), result))
|
||||||
|
result = static_cast<UINT>(-1);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error("invalid encoding selection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::PushEncoding(UINT data) {
|
||||||
|
RADIOBTN_SETCHECK(m_EncodingSystem, false);
|
||||||
|
RADIOBTN_SETCHECK(m_EncodingCustom, false);
|
||||||
|
|
||||||
|
if (data == CP_ACP) RADIOBTN_SETCHECK(m_EncodingSystem, true);
|
||||||
|
else {
|
||||||
|
RADIOBTN_SETCHECK(m_EncodingCustom, true);
|
||||||
|
ExportDialogHelper::SetCWndText(&m_EncodingCustom_Value, YYCC::ParserHelper::ToString(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateLayouts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::UpdateLayouts() {
|
||||||
|
// enable custom encoding input box according to selection.
|
||||||
|
m_EncodingCustom_Value.EnableWindow(RADIOBTN_GETCHECK(m_EncodingCustom));
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
71
materializer/ExportDialog.hpp
Normal file
71
materializer/ExportDialog.hpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
#if defined(MATERIALIZER_PLUGIN)
|
||||||
|
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
namespace VSW::Materializer {
|
||||||
|
|
||||||
|
// ExportDialog dialog
|
||||||
|
|
||||||
|
class ExportDialog : public CDialogEx {
|
||||||
|
DECLARE_DYNAMIC(ExportDialog)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ExportDialog(CWnd* pParent = nullptr); // standard constructor
|
||||||
|
virtual ~ExportDialog();
|
||||||
|
|
||||||
|
// Dialog Data
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_EXPORT_DIALOG };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnBtnOkClicked();
|
||||||
|
afx_msg void OnBtnCancelClicked();
|
||||||
|
afx_msg void OnBtnBrowseClicked();
|
||||||
|
afx_msg void OnBtnEncodingClicked();
|
||||||
|
|
||||||
|
// ===== Init Settings =====
|
||||||
|
public:
|
||||||
|
enum class InitialDatabaseType {
|
||||||
|
Script, Document, Environment
|
||||||
|
};
|
||||||
|
void SetInitialDatabaseType(InitialDatabaseType db_type);
|
||||||
|
protected:
|
||||||
|
InitialDatabaseType m_InitialDatabaseType;
|
||||||
|
|
||||||
|
// ===== Result =====
|
||||||
|
public:
|
||||||
|
const YYCC::yycc_u8string& GetDatabaseFileResult();
|
||||||
|
UINT GetEncodingResult();
|
||||||
|
private:
|
||||||
|
YYCC::yycc_u8string m_DatabaseFileResult;
|
||||||
|
UINT m_EncodingResult;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// ===== Controls =====
|
||||||
|
CEdit m_DatabaseFile;
|
||||||
|
CButton m_EncodingSystem;
|
||||||
|
CButton m_EncodingCustom;
|
||||||
|
CEdit m_EncodingCustom_Value;
|
||||||
|
// ===== Caches =====
|
||||||
|
YYCC::yycc_u8string m_DatabaseFileCache;
|
||||||
|
// ===== Pull & Push =====
|
||||||
|
const YYCC::yycc_u8string& PullDatabaseFile();
|
||||||
|
void PushDatabaseFile(const YYCC::yycc_u8string& data);
|
||||||
|
UINT PullEncoding();
|
||||||
|
void PushEncoding(UINT data);
|
||||||
|
// ===== Update Functions =====
|
||||||
|
void UpdateLayouts();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
162
materializer/Materializer.rc
Normal file
162
materializer/Materializer.rc
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Chinese (Simplified, PRC) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||||
|
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||||
|
#pragma code_page(936)
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // Chinese (Simplified, PRC) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
|
#pragma code_page(1252)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 2,0,0,0
|
||||||
|
PRODUCTVERSION 2,0,0,0
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x1L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "000904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "yyc12345"
|
||||||
|
VALUE "FileDescription", "Virtools Script Weaver - Materializer"
|
||||||
|
VALUE "FileVersion", "2.0.0.0"
|
||||||
|
VALUE "InternalName", "RCEditor.dll"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) yyc12345 2020-2024"
|
||||||
|
VALUE "OriginalFilename", "RCEditor.dll"
|
||||||
|
VALUE "ProductName", "Virtools Script Weaver"
|
||||||
|
VALUE "ProductVersion", "2.0.0.0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x9, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_EXPORT_DIALOG DIALOGEX 0, 0, 219, 134
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Export Setting"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,108,114,50,14
|
||||||
|
PUSHBUTTON "Cancel",IDCANCEL,162,114,50,14
|
||||||
|
EDITTEXT IDC_EDIT1,12,22,138,14,ES_AUTOHSCROLL | ES_READONLY
|
||||||
|
PUSHBUTTON "Browse",IDC_BUTTON1,156,22,50,14
|
||||||
|
CONTROL "System",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,66,39,10
|
||||||
|
CONTROL "Custom",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,108,66,40,10
|
||||||
|
EDITTEXT IDC_EDIT2,12,84,192,14,ES_AUTOHSCROLL
|
||||||
|
GROUPBOX "Database",IDC_STATIC,6,6,204,36
|
||||||
|
GROUPBOX "Encoding",IDC_STATIC,6,48,204,60
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO
|
||||||
|
BEGIN
|
||||||
|
IDD_EXPORT_DIALOG, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 212
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 127
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// AFX_DIALOG_LAYOUT
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_EXPORT_DIALOG AFX_DIALOG_LAYOUT
|
||||||
|
BEGIN
|
||||||
|
0
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // English resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "PluginMain.hpp"
|
#include "PluginMain.hpp"
|
||||||
#include "ExportCore.hpp"
|
#include "ExportCore.hpp"
|
||||||
|
#include "ExportDialog.hpp"
|
||||||
|
|
||||||
namespace VSW::Materializer::PluginMain {
|
namespace VSW::Materializer::PluginMain {
|
||||||
|
|
||||||
@@ -11,21 +12,34 @@ namespace VSW::Materializer::PluginMain {
|
|||||||
|
|
||||||
static void PluginMenuCallback(int command_id) {
|
static void PluginMenuCallback(int command_id) {
|
||||||
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||||
|
CKContext* ctx = g_Plugininterface->GetCKContext();
|
||||||
|
|
||||||
switch (command_id) {
|
switch (command_id) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
ExportDialog dialog;
|
||||||
|
dialog.SetInitialDatabaseType(ExportDialog::InitialDatabaseType::Script);
|
||||||
|
if (dialog.DoModal() == IDOK) {
|
||||||
|
ExportScript::Export(ctx, dialog.GetDatabaseFileResult(), dialog.GetEncodingResult());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
ExportDialog dialog;
|
||||||
|
dialog.SetInitialDatabaseType(ExportDialog::InitialDatabaseType::Document);
|
||||||
|
if (dialog.DoModal() == IDOK) {
|
||||||
|
ExportDocument::Export(ctx, dialog.GetDatabaseFileResult(), dialog.GetEncodingResult());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
ExportDialog dialog;
|
||||||
|
dialog.SetInitialDatabaseType(ExportDialog::InitialDatabaseType::Environment);
|
||||||
|
if (dialog.DoModal() == IDOK) {
|
||||||
|
ExportEnvironment::Export(ctx, dialog.GetDatabaseFileResult(), dialog.GetEncodingResult());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by RCEditor.rc
|
||||||
|
//
|
||||||
|
#define IDD_EXPORT_DIALOG 101
|
||||||
|
#define IDC_EDIT1 1001
|
||||||
|
#define IDC_BUTTON1 1002
|
||||||
|
#define IDC_RADIO1 1003
|
||||||
|
#define IDC_RADIO2 1004
|
||||||
|
#define IDC_EDIT2 1005
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 10003
|
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 10000
|
#define _APS_NEXT_CONTROL_VALUE 1006
|
||||||
#define _APS_NEXT_SYMED_VALUE 10000
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
@@ -4,7 +4,7 @@ add_library(VSWShared STATIC "")
|
|||||||
target_sources(VSWShared
|
target_sources(VSWShared
|
||||||
PRIVATE
|
PRIVATE
|
||||||
# Sources
|
# Sources
|
||||||
"GenericDataTypes.cpp"
|
"GenericHelper.cpp"
|
||||||
)
|
)
|
||||||
# Setup header files
|
# Setup header files
|
||||||
target_sources(VSWShared
|
target_sources(VSWShared
|
||||||
@@ -12,12 +12,18 @@ PUBLIC
|
|||||||
FILE_SET HEADERS
|
FILE_SET HEADERS
|
||||||
FILES
|
FILES
|
||||||
# Headers
|
# Headers
|
||||||
"GenericDataTypes.hpp"
|
"GenericHelper.hpp"
|
||||||
)
|
)
|
||||||
# Setup include directory
|
# Setup include directory
|
||||||
target_include_directories(VSWShared
|
target_include_directories(VSWShared
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
YYCC::YYCCommonplace
|
||||||
|
)
|
||||||
|
# Setup linked library
|
||||||
|
target_link_libraries(VSWShared
|
||||||
|
PUBLIC
|
||||||
|
YYCC::YYCCommonplace
|
||||||
)
|
)
|
||||||
# Setup C++ standard
|
# Setup C++ standard
|
||||||
set_target_properties(VSWShared
|
set_target_properties(VSWShared
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
namespace VSW::DataTypes {
|
|
||||||
|
|
||||||
enum class BehaviorLinkIOType : int {
|
|
||||||
Input,
|
|
||||||
Output
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class ParameterLinkIOType : int {
|
|
||||||
ParameterIn,
|
|
||||||
ParameterOut,
|
|
||||||
/// @brief When using this, ignore [index] and [input_is_bb], set [input_index] to -1
|
|
||||||
ParameterLocal,
|
|
||||||
/// @brief When using this, ignore [index] and [input_is_bb], set [input_index] to -1
|
|
||||||
ParameterTarget,
|
|
||||||
/// @brief When using this, ignore [index], and [input_is_bb] will become [input_is_dataarray]
|
|
||||||
pParameterAttribute
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
7
shared/GenericHelper.cpp
Normal file
7
shared/GenericHelper.cpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include "GenericHelper.hpp"
|
||||||
|
|
||||||
|
namespace VSW {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
46
shared/GenericHelper.hpp
Normal file
46
shared/GenericHelper.hpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <YYCCommonplace.hpp>
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
namespace VSW {
|
||||||
|
|
||||||
|
class Reporter {
|
||||||
|
public:
|
||||||
|
Reporter();
|
||||||
|
~Reporter();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void PrePrint(const YYCC::yycc_char8_t* strl);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Err(const YYCC::yycc_char8_t* strl);
|
||||||
|
void ErrF(const YYCC::yycc_char8_t* fmt, ...);
|
||||||
|
void Warn(const YYCC::yycc_char8_t* strl);
|
||||||
|
void WarnF(const YYCC::yycc_char8_t* fmt, ...);
|
||||||
|
void Info(const YYCC::yycc_char8_t* strl);
|
||||||
|
void InfoF(const YYCC::yycc_char8_t* fmt, ...);
|
||||||
|
void Debug(const YYCC::yycc_char8_t* strl);
|
||||||
|
void DebugF(const YYCC::yycc_char8_t* fmt, ...);
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace DataTypes {
|
||||||
|
|
||||||
|
enum class BehaviorLinkIOType : int {
|
||||||
|
Input,
|
||||||
|
Output
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ParameterLinkIOType : int {
|
||||||
|
ParameterIn,
|
||||||
|
ParameterOut,
|
||||||
|
/// @brief When using this, ignore [index] and [input_is_bb], set [input_index] to -1
|
||||||
|
ParameterLocal,
|
||||||
|
/// @brief When using this, ignore [index] and [input_is_bb], set [input_index] to -1
|
||||||
|
ParameterTarget,
|
||||||
|
/// @brief When using this, ignore [index], and [input_is_bb] will become [input_is_dataarray]
|
||||||
|
pParameterAttribute
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user