Skip to content

Commit 1a280f1

Browse files
committed
表示項目を変更 (v2.5.0)
番組名、番組内容を details, state に サービス名を large_image_text に
1 parent 082cc99 commit 1a280f1

File tree

2 files changed

+53
-50
lines changed

2 files changed

+53
-50
lines changed

TvTestRPC/Activity.h

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -59,53 +59,81 @@ static DiscordActivity CreatePresence(
5959
}
6060
}
6161

62-
// サービスデータがあるならサービス名を付与する
63-
if (Service.has_value())
64-
{
65-
// const wchar_t* → wchar_t*
66-
// const auto rawServiceName = const_cast<LPWSTR>(Service.value().szServiceName);
67-
wchar_t serviceName[ServiceNameLength] = {};
62+
// サービス名を assets.large_text に設定
63+
if (Config.ShowChannelLogo) {
64+
if (Service.has_value())
65+
{
66+
// const wchar_t* → wchar_t*
67+
// const auto rawServiceName = const_cast<LPWSTR>(Service.value().szServiceName);
68+
wchar_t serviceName[ServiceNameLength] = {};
69+
70+
if (const auto rawServiceName = Service.value().szServiceName; !IsBlank(rawServiceName, ServiceNameLength))
71+
{
72+
wcsncpy_s(serviceName, rawServiceName, ServiceNameLength);
73+
74+
// 半角変換
75+
if (Config.ConvertToHalfWidth)
76+
{
77+
Full2Half(serviceName);
78+
}
79+
80+
wcstombs_s(nullptr, Activity.assets.large_text, serviceName, ServiceNameLength - 1);
81+
}
82+
}
6883

69-
if (const auto rawServiceName = Service.value().szServiceName; !IsBlank(rawServiceName, ServiceNameLength))
84+
if (Channel.has_value() && strlen(Activity.assets.large_text) == 0)
7085
{
71-
wcsncpy_s(serviceName, rawServiceName, ServiceNameLength);
86+
wchar_t channelName[ChannelNameLength] = {};
87+
const auto rawChannelName = Channel.value().szChannelName;
88+
wcsncpy_s(channelName, !IsBlank(rawChannelName, ChannelNameLength) ? rawChannelName : L"取得中…", ChannelNameLength);
7289

7390
// 半角変換
7491
if (Config.ConvertToHalfWidth)
7592
{
76-
Full2Half(serviceName);
93+
Full2Half(channelName);
7794
}
7895

79-
wcstombs_s(nullptr, Activity.details, serviceName, ServiceNameLength - 1);
96+
wcstombs_s(nullptr, Activity.assets.large_text, channelName, ChannelNameLength - 1);
8097
}
8198
}
82-
if (Channel.has_value() && strlen(Activity.details) == 0)
83-
{
84-
wchar_t channelName[ChannelNameLength] = {};
85-
const auto rawChannelName = Channel.value().szChannelName;
86-
wcsncpy_s(channelName, !IsBlank(rawChannelName, ChannelNameLength) ? rawChannelName : L"取得中…", ChannelNameLength);
8799

88-
// 半角変換
89-
if (Config.ConvertToHalfWidth)
100+
// 番組名を details に設定
101+
if (Program.has_value())
102+
{
103+
if (const auto rawEventName = Program.value().pszEventName; !IsBlank(rawEventName, MaxStateLength))
90104
{
91-
Full2Half(channelName);
92-
}
105+
// 半角変換
106+
if (Config.ConvertToHalfWidth)
107+
{
108+
Full2Half(rawEventName);
109+
}
93110

94-
wcstombs_s(nullptr, Activity.details, channelName, ChannelNameLength - 1);
111+
wcstombs_s(nullptr, Activity.details, rawEventName, MaxStateLength - 1);
112+
}
95113
}
96114

97-
// 番組データがあるなら番組名を付与する
115+
// 番組説明を state に設定
98116
if (Program.has_value())
99117
{
100-
if (const auto rawEventName = Program.value().pszEventName; !IsBlank(rawEventName, MaxStateLength))
118+
if (const auto rawEventText = Program.value().pszEventText; rawEventText != nullptr && !IsBlank(rawEventText, MaxImageTextLength))
101119
{
102120
// 半角変換
103121
if (Config.ConvertToHalfWidth)
104122
{
105-
Full2Half(rawEventName);
123+
Full2Half(rawEventText);
106124
}
107125

108-
wcstombs_s(nullptr, Activity.state, rawEventName, MaxStateLength - 1);
126+
wcstombs_s(nullptr, Activity.state, rawEventText, MaxImageTextLength - 1);
127+
}
128+
else if (const auto rawEventExtText = Program.value().pszEventExtText; rawEventExtText != nullptr && !IsBlank(rawEventExtText, MaxImageTextLength))
129+
{
130+
// 半角変換
131+
if (Config.ConvertToHalfWidth)
132+
{
133+
Full2Half(rawEventExtText);
134+
}
135+
136+
wcstombs_s(nullptr, Activity.state, rawEventExtText, MaxImageTextLength - 1);
109137
}
110138
}
111139

@@ -126,31 +154,6 @@ static DiscordActivity CreatePresence(
126154

127155
const auto logoKey = Config.Logos.count(serviceId) > 0 ? Config.Logos[serviceId].c_str() : GetServiceLogoKey(TuningSpace, serviceId, serviceName);
128156
strcpy_s(Activity.assets.large_image, logoKey);
129-
130-
// 番組データがあるなら番組説明を付与する
131-
if (Program.has_value())
132-
{
133-
if (const auto rawEventText = Program.value().pszEventText; rawEventText != nullptr && !IsBlank(rawEventText, MaxImageTextLength))
134-
{
135-
// 半角変換
136-
if (Config.ConvertToHalfWidth)
137-
{
138-
Full2Half(rawEventText);
139-
}
140-
141-
wcstombs_s(nullptr, Activity.assets.large_text, rawEventText, MaxImageTextLength - 1);
142-
}
143-
else if (const auto rawEventExtText = Program.value().pszEventExtText; rawEventExtText != nullptr && !IsBlank(rawEventExtText, MaxImageTextLength))
144-
{
145-
// 半角変換
146-
if (Config.ConvertToHalfWidth)
147-
{
148-
Full2Half(rawEventExtText);
149-
}
150-
151-
wcstombs_s(nullptr, Activity.assets.large_text, rawEventExtText, MaxImageTextLength - 1);
152-
}
153-
}
154157
}
155158

156159
// バージョン情報を付与する

TvTestRPC/Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#pragma once
22

3-
constexpr auto TvTestRPCVersion = "2.4.1";
3+
constexpr auto TvTestRPCVersion = "2.5.0";

0 commit comments

Comments
 (0)