From b6b39cb1468b799bd5b410b7b3e8d7671bcb7d6f Mon Sep 17 00:00:00 2001 From: wlix Date: Fri, 11 Sep 2020 22:05:42 +0900 Subject: [PATCH] v0.0.0.1 Released. --- README.TXT | 9 ++-- menu_launch.xml | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ ml_xml.cpp | 25 +++------- ml_xml.hpp | 4 ++ 4 files changed, 132 insertions(+), 24 deletions(-) create mode 100644 menu_launch.xml diff --git a/README.TXT b/README.TXT index 28379c3..3037519 100644 --- a/README.TXT +++ b/README.TXT @@ -30,11 +30,8 @@ DLLファイル 及び .xmlファイルを削除してください。 【使用方法】 - - - -【ランチャーメニューの設定】 - +メニューを右クリックするとコンテキストメニューを表示します。 +ランチャーに表示するものは同梱のxmlファイルを編集してください。 【ライセンス】 @@ -54,7 +51,7 @@ http://ttbase.coresv.com/uploader/ 【更新履歴】 -2020.09.10 v0.0.0.1 +2020.09.11 v0.0.0.1 ・初版作成 diff --git a/menu_launch.xml b/menu_launch.xml new file mode 100644 index 0000000..def9a66 --- /dev/null +++ b/menu_launch.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ml_xml.cpp b/ml_xml.cpp index b655d85..9ded918 100644 --- a/ml_xml.cpp +++ b/ml_xml.cpp @@ -7,7 +7,7 @@ XML_TEXT_ENCODING g_encoding = XML_TEXT_ENCODING::SHIFT_JIS; -std::wstring multi_to_wide(std::string const& src) { +std::wstring WINAPI multi_to_wide(std::string const& src) { auto const dest_size = ::MultiByteToWideChar(CP_ACP, 0U, src.data(), -1, nullptr, 0U); std::vector dest(dest_size, L'\0'); if (::MultiByteToWideChar(CP_ACP, 0U, src.data(), -1, dest.data(), dest.size()) == 0) { @@ -18,7 +18,7 @@ std::wstring multi_to_wide(std::string const& src) { return std::wstring(dest.begin(), dest.end()); } -std::wstring utf8_to_wide(std::string const& src) { +std::wstring WINAPI utf8_to_wide(std::string const& src) { auto const dest_size = ::MultiByteToWideChar(CP_UTF8, 0U, src.data(), -1, nullptr, 0U); std::vector dest(dest_size, L'\0'); if (::MultiByteToWideChar(CP_UTF8, 0U, src.data(), -1, dest.data(), dest.size()) == 0) { @@ -29,7 +29,7 @@ std::wstring utf8_to_wide(std::string const& src) { return std::wstring(dest.begin(), dest.end()); } -std::string utf16_to_utf8(std::u16string const& src) { +std::string WINAPI utf16_to_utf8(std::u16string const& src) { std::wstring_convert, char16_t> converter; return converter.to_bytes(src); } @@ -173,7 +173,7 @@ BOOL WINAPI LoadMenuItems(xml_node<>* parent_node, HMENU hMenu, MLMenu& mlm) { if (_strcmpi(node->name(), "item") == 0 || _strcmpi(node->name(), "execute") == 0) { MenuItem mi = { MenuItem::EXECUTE }; - mi.execute.Path = node->first_attribute("path")->value(); + mi.execute.Path = WrappedExpandEnvironmentStrings(attr_map["path"]); mi.execute.Param = WrappedExpandEnvironmentStrings(attr_map["param"]); mlm.MenuItems.push_back(mi); @@ -291,7 +291,6 @@ BOOL WINAPI LoadXML(LPCTSTR szFileName, MLMenu& mlm) { } xml_node<> *node = xml_doc.first_node(); - /* declaration */ if (_strcmpi(node->first_attribute("encoding")->value(), "Shift_JIS") == 0) { g_encoding = XML_TEXT_ENCODING::SHIFT_JIS; } else if (_strcmpi(node->first_attribute("encoding")->value(), "UTF-8") == 0 @@ -301,9 +300,6 @@ BOOL WINAPI LoadXML(LPCTSTR szFileName, MLMenu& mlm) { || _strcmpi(node->first_attribute("encoding")->value(), "UTF16") == 0) { g_encoding = XML_TEXT_ENCODING::UTF_16; } - TCHAR buff[512]; - wsprintf(buff, TEXT("%d"), g_encoding); - MessageBox(NULL, buff, TEXT("g_encoding"), MB_OK); node = node->next_sibling(); if (_strcmpi(node->name(), "menulaunch") != 0) { @@ -326,22 +322,15 @@ BOOL WINAPI LoadXML(LPCTSTR szFileName, MLMenu& mlm) { return TRUE; } -/* + BOOL WINAPI GetAttributes(xml_node<> *node, AttributeMap &attr_map) { for (xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute()) { - std::wstring buf; - if (g_encoding == XML_TEXT_ENCODING::SHIFT_JIS) { - buf = multi_to_wide(attr->value()); - } else if (g_encoding == XML_TEXT_ENCODING::UTF_8) { - buf = utf8_to_wide(attr->value()); - } else if (g_encoding == XML_TEXT_ENCODING::UTF_16) { - buf = utf8_to_wide(utf16_to_utf8((char16_t *)attr->value())); - } + std::wstring buf = to_mbcs(attr->value()); attr_map.insert(std::make_pair(attr->name(), buf)); } return TRUE; } -*/ + std::wstring WINAPI to_mbcs(std::string str) { std::wstring dest; if (g_encoding == XML_TEXT_ENCODING::SHIFT_JIS) { diff --git a/ml_xml.hpp b/ml_xml.hpp index acc832c..a944956 100644 --- a/ml_xml.hpp +++ b/ml_xml.hpp @@ -14,6 +14,9 @@ typedef std::map AttributeMap; using namespace rapidxml; +std::wstring WINAPI multi_to_wide(std::string const& src); +std::wstring WINAPI utf8_to_wide(std::string const& src); +std::string WINAPI utf16_to_utf8(std::u16string const& src); BOOL WINAPI StrToBOOL(LPCTSTR lpstr); std::wstring WINAPI WrappedExpandEnvironmentStrings(const std::wstring& str); BOOL WINAPI AppendMenuItem(HMENU hMenu, LPCTSTR lpStr, HBITMAP hBitmap, HMENU hSubmenu, UINT wID); @@ -24,4 +27,5 @@ BOOL WINAPI LoadMenuItems(xml_node<>* node, HMENU hMenu, MLMenu& mlm); BOOL WINAPI LoadMenu(xml_node<>* node, MLMenu& mlm); BOOL WINAPI LoadXML(LPCTSTR szFileName, MLMenu& mlm); BOOL WINAPI GetAttributes(xml_node<>* node, AttributeMap& attr); +std::wstring WINAPI to_mbcs(std::string str); BOOL WINAPI LoadSettings(xml_node<>* node, MLMenu& mlm);