diff --git a/cfg-tools/apps/scanner-check/CDlgMgr.cpp b/cfg-tools/apps/scanner-check/CDlgMgr.cpp index 85290c0..851e933 100644 --- a/cfg-tools/apps/scanner-check/CDlgMgr.cpp +++ b/cfg-tools/apps/scanner-check/CDlgMgr.cpp @@ -1121,12 +1121,12 @@ std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver) static void trans_code_json(std::wstring& json) { - size_t pos = json.find(L"(L\""); + size_t pos = json.find(L"(\""); if (pos == std::wstring::npos) return; - json.erase(0, pos + 3); + json.erase(0, pos + 2); pos = json.rfind(L'\"'); if (pos != std::wstring::npos) json.erase(pos); @@ -1188,8 +1188,13 @@ void CDlgMgr::add_param_from_config(CComboBox* param_ctrl, CComboBox* val_ctrl, } void CDlgMgr::reload(std::wstring& cont) { - if (cont.find(L"static std::wstring") == 0) + bool code_jsn = false; + + if (cont.find(L"static std::string") == 0) + { trans_code_json(cont); + code_jsn = true; + } known_file_util::IJsonW* jsn = known_file_util::create_jsonW(); if (jsn->attach(cont.c_str())) @@ -1270,6 +1275,75 @@ void CDlgMgr::reload(std::wstring& cont) } write->release(); } + else + { + int nv = 0; + if (child->get_value(L"vid-to", nv)) + { + FIND_DATA(combo_param_, GetCount, PARAM_VID, ind); + if (ind != -1) + { + wchar_t hex[40] = { 0 }; + + swprintf_s(hex, _countof(hex) - 1, L"%04x", nv); + combo_param_.SetCurSel(ind); + OnCbnSelchangeComboParam(); + ::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex); + OnBnClickedButtonAddParam(); + } + } + if (child->get_value(L"pid-to", nv)) + { + FIND_DATA(combo_param_, GetCount, PARAM_PID, ind); + if (ind != -1) + { + wchar_t hex[40] = { 0 }; + + swprintf_s(hex, _countof(hex) - 1, L"%04x", nv); + combo_param_.SetCurSel(ind); + OnCbnSelchangeComboParam(); + ::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex); + OnBnClickedButtonAddParam(); + } + } + if (child->get_value(L"speed-mode", nv)) + { + FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind); + if (ind != -1) + { + combo_param_.SetCurSel(ind); + OnCbnSelchangeComboParam(); + SetDlgItemInt(IDC_EDIT_PARAM_VAL, nv); + OnBnClickedButtonAddParam(); + } + } + if (child->get_value(L"sleep-time", nv)) + { + ind = -1; + for (int i = 0; i < combo_param_.GetCount(); ++i) + { + DWORD_PTR data = combo_param_.GetItemData(i); + if (data != PARAM_VID && data != PARAM_PID && data != PARAM_SPEED) + { + known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data; + if (wcscmp(jsn->key(), L"time-to-sleep") == 0) + { + ind = i; + break; + } + } + } + if (ind != -1) + { + combo_param_.SetCurSel(ind); + OnCbnSelchangeComboParam(); + ind = combo_param_val_.FindStringExact(-1, L"\u4E94\u5206\u949F"); + if (ind != -1) + combo_param_val_.SetCurSel(ind); + OnBnClickedButtonAddParam(); + } + } + } child->release(); } @@ -1279,10 +1353,12 @@ void CDlgMgr::reload(std::wstring& cont) { known_file_util::IJsonW* tpl = NULL; child->get_value(L"name", &val); - ind = find_template(&combo_param_, val, &tpl); + if (child->get_value(L"ver", id)) + ::PostMessage(GetParent()->m_hWnd, WM_SET_CODE_VER, 0, (LPARAM)id); + id = find_template(&combo_, val, &tpl); if (tpl) { - combo_.SetCurSel(ind); + combo_.SetCurSel(id); OnBnClickedButtonAdd(); FIND_DATA(list_, GetItemCount, tpl, id); if (id != -1) diff --git a/cfg-tools/apps/scanner-check/page.h b/cfg-tools/apps/scanner-check/page.h index 42720ba..e8aef63 100644 --- a/cfg-tools/apps/scanner-check/page.h +++ b/cfg-tools/apps/scanner-check/page.h @@ -9,6 +9,7 @@ #define WM_TO_ITEM_MGR_TAB WM_USER + 102 #define WM_TEST_ITEM_CHANGED WM_USER + 103 #define WM_REFRESH_TEST_ITEM WM_USER + 104 +#define WM_SET_CODE_VER WM_USER + 105 // WPARAM: unused, LPARAM: ver #include #include diff --git a/cfg-tools/apps/scanner-check/scanner-checkDlg.cpp b/cfg-tools/apps/scanner-check/scanner-checkDlg.cpp index 5c4d579..4383510 100644 --- a/cfg-tools/apps/scanner-check/scanner-checkDlg.cpp +++ b/cfg-tools/apps/scanner-check/scanner-checkDlg.cpp @@ -48,6 +48,7 @@ BEGIN_MESSAGE_MAP(CscannercheckDlg, CDialogEx) ON_MESSAGE(WM_TO_ITEM_MGR_TAB, &CscannercheckDlg::on_to_item_manager_tab) ON_MESSAGE(WM_TEST_ITEM_CHANGED, &CscannercheckDlg::on_test_item_changed) ON_MESSAGE(WM_REFRESH_TEST_ITEM, &CscannercheckDlg::on_refresh_test_items) + ON_MESSAGE(WM_SET_CODE_VER, &CscannercheckDlg::on_set_code_ver) END_MESSAGE_MAP() void CscannercheckDlg::add_page(const wchar_t* title, CDialogEx* child) @@ -265,4 +266,10 @@ LRESULT CscannercheckDlg::on_refresh_test_items(WPARAM wp, LPARAM lp) return 0; } +LRESULT CscannercheckDlg::on_set_code_ver(WPARAM wp, LPARAM lp) +{ + SetDlgItemInt(IDC_EDIT_VER, (UINT)lp); + + return 0; +} diff --git a/cfg-tools/apps/scanner-check/scanner-checkDlg.h b/cfg-tools/apps/scanner-check/scanner-checkDlg.h index b0a892b..a3c5105 100644 --- a/cfg-tools/apps/scanner-check/scanner-checkDlg.h +++ b/cfg-tools/apps/scanner-check/scanner-checkDlg.h @@ -48,5 +48,6 @@ public: afx_msg LRESULT on_to_item_manager_tab(WPARAM, LPARAM); afx_msg LRESULT on_test_item_changed(WPARAM wp, LPARAM lp); afx_msg LRESULT on_refresh_test_items(WPARAM wp, LPARAM lp); + afx_msg LRESULT on_set_code_ver(WPARAM wp, LPARAM lp); afx_msg void OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult); }; diff --git a/cfg-tools/solution/Release/scanner-check.exe b/cfg-tools/solution/Release/scanner-check.exe index b3c0004..0d90b43 100644 Binary files a/cfg-tools/solution/Release/scanner-check.exe and b/cfg-tools/solution/Release/scanner-check.exe differ