修复JSON工具BUG
This commit is contained in:
parent
66803c9b29
commit
9aa6a96434
|
@ -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)
|
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)
|
if (pos == std::wstring::npos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
json.erase(0, pos + 3);
|
json.erase(0, pos + 2);
|
||||||
pos = json.rfind(L'\"');
|
pos = json.rfind(L'\"');
|
||||||
if (pos != std::wstring::npos)
|
if (pos != std::wstring::npos)
|
||||||
json.erase(pos);
|
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)
|
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);
|
trans_code_json(cont);
|
||||||
|
code_jsn = true;
|
||||||
|
}
|
||||||
|
|
||||||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW();
|
known_file_util::IJsonW* jsn = known_file_util::create_jsonW();
|
||||||
if (jsn->attach(cont.c_str()))
|
if (jsn->attach(cont.c_str()))
|
||||||
|
@ -1270,6 +1275,75 @@ void CDlgMgr::reload(std::wstring& cont)
|
||||||
}
|
}
|
||||||
write->release();
|
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();
|
child->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,10 +1353,12 @@ void CDlgMgr::reload(std::wstring& cont)
|
||||||
{
|
{
|
||||||
known_file_util::IJsonW* tpl = NULL;
|
known_file_util::IJsonW* tpl = NULL;
|
||||||
child->get_value(L"name", &val);
|
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)
|
if (tpl)
|
||||||
{
|
{
|
||||||
combo_.SetCurSel(ind);
|
combo_.SetCurSel(id);
|
||||||
OnBnClickedButtonAdd();
|
OnBnClickedButtonAdd();
|
||||||
FIND_DATA(list_, GetItemCount, tpl, id);
|
FIND_DATA(list_, GetItemCount, tpl, id);
|
||||||
if (id != -1)
|
if (id != -1)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define WM_TO_ITEM_MGR_TAB WM_USER + 102
|
#define WM_TO_ITEM_MGR_TAB WM_USER + 102
|
||||||
#define WM_TEST_ITEM_CHANGED WM_USER + 103
|
#define WM_TEST_ITEM_CHANGED WM_USER + 103
|
||||||
#define WM_REFRESH_TEST_ITEM WM_USER + 104
|
#define WM_REFRESH_TEST_ITEM WM_USER + 104
|
||||||
|
#define WM_SET_CODE_VER WM_USER + 105 // WPARAM: unused, LPARAM: ver
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -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_TO_ITEM_MGR_TAB, &CscannercheckDlg::on_to_item_manager_tab)
|
||||||
ON_MESSAGE(WM_TEST_ITEM_CHANGED, &CscannercheckDlg::on_test_item_changed)
|
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_REFRESH_TEST_ITEM, &CscannercheckDlg::on_refresh_test_items)
|
||||||
|
ON_MESSAGE(WM_SET_CODE_VER, &CscannercheckDlg::on_set_code_ver)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
void CscannercheckDlg::add_page(const wchar_t* title, CDialogEx* child)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CscannercheckDlg::on_set_code_ver(WPARAM wp, LPARAM lp)
|
||||||
|
{
|
||||||
|
SetDlgItemInt(IDC_EDIT_VER, (UINT)lp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,5 +48,6 @@ public:
|
||||||
afx_msg LRESULT on_to_item_manager_tab(WPARAM, LPARAM);
|
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_test_item_changed(WPARAM wp, LPARAM lp);
|
||||||
afx_msg LRESULT on_refresh_test_items(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);
|
afx_msg void OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue