Skip to content

Commit

Permalink
表示項目を変更 (v2.5.0)
Browse files Browse the repository at this point in the history
番組名、番組内容を details, state に
サービス名を large_image_text に
  • Loading branch information
SlashNephy committed Jun 25, 2022
1 parent 082cc99 commit 1a280f1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 50 deletions.
101 changes: 52 additions & 49 deletions TvTestRPC/Activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,53 +59,81 @@ static DiscordActivity CreatePresence(
}
}

// サービスデータがあるならサービス名を付与する
if (Service.has_value())
{
// const wchar_t* → wchar_t*
// const auto rawServiceName = const_cast<LPWSTR>(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<LPWSTR>(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);
}
}

Expand All @@ -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);
}
}
}

// バージョン情報を付与する
Expand Down
2 changes: 1 addition & 1 deletion TvTestRPC/Version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

constexpr auto TvTestRPCVersion = "2.4.1";
constexpr auto TvTestRPCVersion = "2.5.0";

0 comments on commit 1a280f1

Please sign in to comment.