From 1a280f1f34547f526685ff0d536a2988dab2ada3 Mon Sep 17 00:00:00 2001 From: SlashNephy Date: Sun, 26 Jun 2022 00:35:40 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E9=A0=85=E7=9B=AE=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=20(v2.5.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 番組名、番組内容を details, state に サービス名を large_image_text に --- TvTestRPC/Activity.h | 101 ++++++++++++++++++++++--------------------- TvTestRPC/Version.h | 2 +- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/TvTestRPC/Activity.h b/TvTestRPC/Activity.h index 43dd399..1d12948 100644 --- a/TvTestRPC/Activity.h +++ b/TvTestRPC/Activity.h @@ -59,53 +59,81 @@ static DiscordActivity CreatePresence( } } - // サービスデータがあるならサービス名を付与する - if (Service.has_value()) - { - // const wchar_t* → wchar_t* - // const auto rawServiceName = const_cast(Service.value().szServiceName); - wchar_t serviceName[ServiceNameLength] = {}; + // サービス名を assets.large_text に設定 + if (Config.ShowChannelLogo) { + if (Service.has_value()) + { + // const wchar_t* → wchar_t* + // const auto rawServiceName = const_cast(Service.value().szServiceName); + wchar_t serviceName[ServiceNameLength] = {}; + + if (const auto rawServiceName = Service.value().szServiceName; !IsBlank(rawServiceName, ServiceNameLength)) + { + wcsncpy_s(serviceName, rawServiceName, ServiceNameLength); + + // 半角変換 + if (Config.ConvertToHalfWidth) + { + Full2Half(serviceName); + } + + wcstombs_s(nullptr, Activity.assets.large_text, serviceName, ServiceNameLength - 1); + } + } - if (const auto rawServiceName = Service.value().szServiceName; !IsBlank(rawServiceName, ServiceNameLength)) + if (Channel.has_value() && strlen(Activity.assets.large_text) == 0) { - wcsncpy_s(serviceName, rawServiceName, ServiceNameLength); + wchar_t channelName[ChannelNameLength] = {}; + const auto rawChannelName = Channel.value().szChannelName; + wcsncpy_s(channelName, !IsBlank(rawChannelName, ChannelNameLength) ? rawChannelName : L"取得中…", ChannelNameLength); // 半角変換 if (Config.ConvertToHalfWidth) { - Full2Half(serviceName); + Full2Half(channelName); } - wcstombs_s(nullptr, Activity.details, serviceName, ServiceNameLength - 1); + wcstombs_s(nullptr, Activity.assets.large_text, channelName, ChannelNameLength - 1); } } - if (Channel.has_value() && strlen(Activity.details) == 0) - { - wchar_t channelName[ChannelNameLength] = {}; - const auto rawChannelName = Channel.value().szChannelName; - wcsncpy_s(channelName, !IsBlank(rawChannelName, ChannelNameLength) ? rawChannelName : L"取得中…", ChannelNameLength); - // 半角変換 - if (Config.ConvertToHalfWidth) + // 番組名を details に設定 + if (Program.has_value()) + { + if (const auto rawEventName = Program.value().pszEventName; !IsBlank(rawEventName, MaxStateLength)) { - Full2Half(channelName); - } + // 半角変換 + if (Config.ConvertToHalfWidth) + { + Full2Half(rawEventName); + } - wcstombs_s(nullptr, Activity.details, channelName, ChannelNameLength - 1); + wcstombs_s(nullptr, Activity.details, rawEventName, MaxStateLength - 1); + } } - // 番組データがあるなら番組名を付与する + // 番組説明を state に設定 if (Program.has_value()) { - if (const auto rawEventName = Program.value().pszEventName; !IsBlank(rawEventName, MaxStateLength)) + if (const auto rawEventText = Program.value().pszEventText; rawEventText != nullptr && !IsBlank(rawEventText, MaxImageTextLength)) { // 半角変換 if (Config.ConvertToHalfWidth) { - Full2Half(rawEventName); + Full2Half(rawEventText); } - wcstombs_s(nullptr, Activity.state, rawEventName, MaxStateLength - 1); + wcstombs_s(nullptr, Activity.state, rawEventText, MaxImageTextLength - 1); + } + else if (const auto rawEventExtText = Program.value().pszEventExtText; rawEventExtText != nullptr && !IsBlank(rawEventExtText, MaxImageTextLength)) + { + // 半角変換 + if (Config.ConvertToHalfWidth) + { + Full2Half(rawEventExtText); + } + + wcstombs_s(nullptr, Activity.state, rawEventExtText, MaxImageTextLength - 1); } } @@ -126,31 +154,6 @@ static DiscordActivity CreatePresence( const auto logoKey = Config.Logos.count(serviceId) > 0 ? Config.Logos[serviceId].c_str() : GetServiceLogoKey(TuningSpace, serviceId, serviceName); strcpy_s(Activity.assets.large_image, logoKey); - - // 番組データがあるなら番組説明を付与する - if (Program.has_value()) - { - if (const auto rawEventText = Program.value().pszEventText; rawEventText != nullptr && !IsBlank(rawEventText, MaxImageTextLength)) - { - // 半角変換 - if (Config.ConvertToHalfWidth) - { - Full2Half(rawEventText); - } - - wcstombs_s(nullptr, Activity.assets.large_text, rawEventText, MaxImageTextLength - 1); - } - else if (const auto rawEventExtText = Program.value().pszEventExtText; rawEventExtText != nullptr && !IsBlank(rawEventExtText, MaxImageTextLength)) - { - // 半角変換 - if (Config.ConvertToHalfWidth) - { - Full2Half(rawEventExtText); - } - - wcstombs_s(nullptr, Activity.assets.large_text, rawEventExtText, MaxImageTextLength - 1); - } - } } // バージョン情報を付与する diff --git a/TvTestRPC/Version.h b/TvTestRPC/Version.h index b4e4a3e..8fefd5c 100644 --- a/TvTestRPC/Version.h +++ b/TvTestRPC/Version.h @@ -1,3 +1,3 @@ #pragma once -constexpr auto TvTestRPCVersion = "2.4.1"; +constexpr auto TvTestRPCVersion = "2.5.0";