diff --git a/TVTComment/Model/IPC/IPCMessage/ChatIPCMessage.cs b/TVTComment/Model/IPC/IPCMessage/ChatIPCMessage.cs index 3a1906a..60ab7bc 100644 --- a/TVTComment/Model/IPC/IPCMessage/ChatIPCMessage.cs +++ b/TVTComment/Model/IPC/IPCMessage/ChatIPCMessage.cs @@ -17,7 +17,7 @@ public void Decode(IEnumerable content) public IEnumerable Encode() { string[] ret = new string[5]; - ret[0] = Chat.Text; + ret[0] = Chat.Text.Replace('\u001E', '〓').Replace('\u001F', '〓'); switch (Chat.Position) { case Chat.PositionType.Normal: diff --git a/Viewer/TVTComment/IPC/RawIPCMessage.cpp b/Viewer/TVTComment/IPC/RawIPCMessage.cpp index 000d059..c6d8738 100644 --- a/Viewer/TVTComment/IPC/RawIPCMessage.cpp +++ b/Viewer/TVTComment/IPC/RawIPCMessage.cpp @@ -5,10 +5,9 @@ namespace TVTComment { std::string RawIPCMessage::ToString() const { - std::string ret; + std::string ret = this->MessageName; for (const std::string &content : this->Contents) - ret += content+" "; - ret.pop_back(); - return this->MessageName + ret; + ret += " " + content; + return ret; } } \ No newline at end of file diff --git a/Viewer/TVTComment/TVTComment.cpp b/Viewer/TVTComment/TVTComment.cpp index bcae33b..1aa0d57 100644 --- a/Viewer/TVTComment/TVTComment.cpp +++ b/Viewer/TVTComment/TVTComment.cpp @@ -48,6 +48,8 @@ namespace TVTComment if (CreateProcessW(NULL, &(this->collectExePath + L" " + receivePipeName.substr(9) + L" " + sendPipeName.substr(9))[0], NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi) == 0) throw std::system_error(std::system_error(GetLastError(), std::system_category())); pid = pi.dwProcessId; + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); this->ipcTunnel->Connect(); } @@ -135,7 +137,11 @@ namespace TVTComment } else if (auto message = dynamic_cast(&msg)) { - this->tvtest->SetChannel(message->SpaceIndex, message->ChannelIndex,message->ServiceId); + //タイムアウトつきでウィンドウスレッドにチャンネル変更を指示する + this->channelSelectSpaceIndex = message->SpaceIndex; + this->channelSelectChannelIndex = message->ChannelIndex; + this->channelSelectServiceId = message->ServiceId; + SendMessageTimeout(this->dialog, WM_CHANNELSELECT, 0, 0, SMTO_NORMAL, CHANNELSELECT_TIMEOUT, nullptr); } else if (auto message = dynamic_cast(&msg)) { @@ -146,7 +152,6 @@ namespace TVTComment else if (auto message = dynamic_cast(&msg)) { lastOpacity = (WPARAM)message->Opacity; - this->tvtest->SetPluginCommandState(static_cast(Command::HideComment), 0); PostMessage(this->dialog, WM_SETCHATOPACITY, (WPARAM)message->Opacity, 0); } #pragma warning(pop) @@ -276,6 +281,10 @@ namespace TVTComment case WM_ONCHANNELSELECTIONCHANGE: this->OnChannelSelectionChange(); break; + + case WM_CHANNELSELECT: + this->tvtest->SetChannel(this->channelSelectSpaceIndex, this->channelSelectChannelIndex, this->channelSelectServiceId); + break; } return FALSE; @@ -400,12 +409,10 @@ namespace TVTComment case Command::HideComment: if (this->commentWindow->GetOpacity() != 0) { lastOpacity = this->commentWindow->GetOpacity(); - PostMessage(this->dialog, WM_SETCHATOPACITY, 0, 0); - this->tvtest->SetPluginCommandState(static_cast(Command::HideComment), TVTest::COMMAND_ICON_STATE_CHECKED); + PostMessage(this->dialog, WM_SETCHATOPACITY, 0, 1); } else { PostMessage(this->dialog, WM_SETCHATOPACITY, lastOpacity, 0); - this->tvtest->SetPluginCommandState(static_cast(Command::HideComment), 0); } break; } diff --git a/Viewer/TVTComment/TVTComment.h b/Viewer/TVTComment/TVTComment.h index 9c44a4b..35689fa 100644 --- a/Viewer/TVTComment/TVTComment.h +++ b/Viewer/TVTComment/TVTComment.h @@ -53,6 +53,11 @@ namespace TVTComment std::wstring collectExePath;//起動するEXEのパス + int channelSelectSpaceIndex;//WM_CHANNELSELECTをタイムアウトつきで呼び出すときの引数 + int channelSelectChannelIndex; + uint16_t channelSelectServiceId; + static constexpr int CHANNELSELECT_TIMEOUT = 5000;//WM_CHANNELSELECTの完了を待つタイムアウト(ミリ秒) + static std::wstring_convert, wchar_t> utf8_utf16_conv; private: @@ -69,7 +74,8 @@ namespace TVTComment static constexpr int WM_DISABLEPLUGIN = WM_APP + 1002;//プラグインを無効化する(別スレッドから無効化するときに使う) static constexpr int WM_ONCHANNELLISTCHANGE = WM_APP + 1003;//メンバ関数OnChannelListChangeを呼ぶ(別スレッドから送るときに使う) static constexpr int WM_ONCHANNELSELECTIONCHANGE = WM_APP + 1004;//メンバ関数OnChannelSelectionChangeを呼ぶ(別スレッドから送るときに使う) - static constexpr int WM_SETCHATOPACITY = WM_APP + 1005;//コメント透過度を設定する wParamに透過度を渡す(0~255) + static constexpr int WM_SETCHATOPACITY = WM_APP + 1005;//コメント透過度を設定する wParamに透過度(0~255)、lParamに表示状態(非0で非表示)を渡す + static constexpr int WM_CHANNELSELECT = WM_APP + 1006;//チャンネル変更する enum class UserInteractionRequestType{ConnectSucceed,ConnectFail,InvalidMessage,ReceiveError,SendError, FetalErrorInTask}; diff --git a/Viewer/Viewer.cpp b/Viewer/Viewer.cpp index 5dcaf78..c07ff0f 100644 --- a/Viewer/Viewer.cpp +++ b/Viewer/Viewer.cpp @@ -541,6 +541,8 @@ LRESULT CViewer::ForceWindowProcMain(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM commentWindow_.Destroy(); } commentWindow_.SetOpacity(newOpacity); + bool hideState = lParam != 0; + m_pApp->SetPluginCommandState(static_cast(TVTComment::Command::HideComment), hideState ? TVTest::COMMAND_ICON_STATE_CHECKED : 0); break; } #pragma endregion