Skip to content

Commit dc348d8

Browse files
authored
Command line tools updated to support feedback (#619)
1 parent 051924a commit dc348d8

3 files changed

Lines changed: 52 additions & 19 deletions

File tree

MakeSpriteFont/CommandLineParser.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class CommandLineParser
2727
List<string> requiredUsageHelp = new List<string>();
2828
List<string> optionalUsageHelp = new List<string>();
2929

30+
private const string feedbackURL = "https://github.com/microsoft/DirectXTK/issues";
3031

3132
// Constructor.
3233
public CommandLineParser(object optionsObject)
@@ -127,6 +128,11 @@ bool ParseArgument(string arg)
127128

128129
return SetOption(field, value);
129130
}
131+
else if (arg.Equals("feedback", StringComparison.OrdinalIgnoreCase))
132+
{
133+
System.Diagnostics.Process.Start(feedbackURL);
134+
return false;
135+
}
130136
else
131137
{
132138
// Parse a required argument.

XWBTool/CmdLineHelpers.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace Helpers
5858
};
5959

6060
template<typename T>
61-
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray)
61+
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray) noexcept
6262
{
6363
while (pArray->name)
6464
{
@@ -72,7 +72,7 @@ namespace Helpers
7272
}
7373

7474
template<typename T>
75-
const wchar_t* LookupByValue(T value, const SValue<T> *pArray)
75+
const wchar_t* LookupByValue(T value, const SValue<T> *pArray) noexcept
7676
{
7777
while (pArray->name)
7878
{
@@ -85,7 +85,7 @@ namespace Helpers
8585
return L"";
8686
}
8787

88-
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList)
88+
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList) noexcept
8989
{
9090
for (auto pFormat = pFormatList; pFormat->name; pFormat++)
9191
{
@@ -99,7 +99,7 @@ namespace Helpers
9999
wprintf(L"*UNKNOWN*");
100100
}
101101

102-
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2)
102+
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2) noexcept
103103
{
104104
for (auto pFormat = pFormatList1; pFormat->name; pFormat++)
105105
{
@@ -123,7 +123,7 @@ namespace Helpers
123123
}
124124

125125
template<typename T>
126-
void PrintList(size_t cch, const SValue<T> *pValue)
126+
void PrintList(size_t cch, const SValue<T> *pValue) noexcept
127127
{
128128
while (pValue->name)
129129
{
@@ -143,7 +143,7 @@ namespace Helpers
143143
wprintf(L"\n");
144144
}
145145

146-
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc)
146+
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc) noexcept
147147
{
148148
wchar_t version[32] = {};
149149

@@ -336,7 +336,7 @@ namespace Helpers
336336
}
337337
}
338338

339-
const wchar_t* GetErrorDesc(HRESULT hr)
339+
const wchar_t* GetErrorDesc(HRESULT hr) noexcept
340340
{
341341
static wchar_t desc[1024] = {};
342342

XWBTool/xwbtool.cpp

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858

5959
#include "WAVFileReader.h"
6060

61+
#include <shellapi.h>
62+
6163
#define TOOL_VERSION 0
6264
#include "CmdLineHelpers.h"
6365

@@ -270,14 +272,14 @@ namespace
270272
static_assert(sizeof(ENTRYCOMPACT) == 4, "Mismatch with xact3wb.h");
271273
static_assert(sizeof(BANKDATA) == 96, "Mismatch with xact3wb.h");
272274

273-
template <typename T> WORD ChannelsSpecifiedInMask(T x)
275+
template <typename T> WORD ChannelsSpecifiedInMask(T x) noexcept
274276
{
275277
WORD bitCount = 0;
276278
while (x) { ++bitCount; x &= (x - 1); }
277279
return bitCount;
278280
}
279281

280-
WORD AdpcmBlockSizeFromPcmFrames(WORD nPcmFrames, WORD nChannels)
282+
WORD AdpcmBlockSizeFromPcmFrames(WORD nPcmFrames, WORD nChannels) noexcept
281283
{
282284
// The full calculation is as follows:
283285
// UINT uHeaderBytes = MSADPCM_HEADER_LENGTH * nChannels;
@@ -305,7 +307,7 @@ namespace
305307
}
306308
}
307309

308-
DWORD EncodeWMABlockAlign(DWORD dwBlockAlign, DWORD dwAvgBytesPerSec)
310+
DWORD EncodeWMABlockAlign(DWORD dwBlockAlign, DWORD dwAvgBytesPerSec) noexcept
309311
{
310312
static const uint32_t aWMABlockAlign[17] =
311313
{
@@ -354,7 +356,7 @@ namespace
354356
return DWORD(blockAlignIndex | (bytesPerSecIndex << 5));
355357
}
356358

357-
bool ConvertToMiniFormat(const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt)
359+
bool ConvertToMiniFormat(const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt) noexcept
358360
{
359361
if (!wfx)
360362
return false;
@@ -787,6 +789,7 @@ namespace
787789

788790
const wchar_t* g_ToolName = L"xwbtool";
789791
const wchar_t* g_Description = L"Microsoft (R) XACT-style Wave Bank Tool [DirectXTK]";
792+
const wchar_t* g_FeedbackURL = L"https://github.com/microsoft/DirectXTK/issues";
790793

791794
enum OPTIONS : uint32_t
792795
{
@@ -828,7 +831,7 @@ namespace
828831
WaveFile(WaveFile&&) = default;
829832
};
830833

831-
void FileNameToIdentifier(_Inout_updates_all_(count) wchar_t* str, size_t count)
834+
void FileNameToIdentifier(_Inout_updates_all_(count) wchar_t* str, size_t count) noexcept
832835
{
833836
size_t j = 0;
834837
for (wchar_t* c = str; j < count && *c != 0; ++c, ++j)
@@ -880,13 +883,14 @@ namespace
880883
//////////////////////////////////////////////////////////////////////////////
881884
//////////////////////////////////////////////////////////////////////////////
882885

883-
void PrintUsage()
886+
void PrintUsage(bool full = false) noexcept
884887
{
885888
PrintLogo(false, g_ToolName, g_Description);
886889

887890
static const wchar_t* const s_usage =
888-
L"Usage: xwbtool <options> [--] <wav-files>\n"
889-
L"\n"
891+
L"Usage: xwbtool <options> [--] <wav-files>\n\n";
892+
893+
static const wchar_t* const s_fullUsage =
890894
L" -r wildcard filename search is recursive\n"
891895
L" -flist <filename>, --file-list <filename>\n"
892896
L" use text file with a list of input files (one per line)\n"
@@ -909,9 +913,14 @@ namespace
909913
L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n";
910914

911915
wprintf(L"%ls", s_usage);
916+
917+
if (!full)
918+
return;
919+
920+
wprintf(L"%ls", s_fullUsage);
912921
}
913922

914-
const char* GetFormatTagName(WORD wFormatTag)
923+
const char* GetFormatTagName(WORD wFormatTag) noexcept
915924
{
916925
switch (wFormatTag)
917926
{
@@ -930,7 +939,7 @@ namespace
930939
}
931940
}
932941

933-
const char *ChannelDesc(DWORD dwChannelMask)
942+
const char *ChannelDesc(DWORD dwChannelMask) noexcept
934943
{
935944
switch (dwChannelMask)
936945
{
@@ -948,7 +957,7 @@ namespace
948957
}
949958
}
950959

951-
void PrintInfo(const WaveFile& wave)
960+
void PrintInfo(const WaveFile& wave) noexcept
952961
{
953962
if (wave.data.wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE
954963
&& (wave.data.wfx->cbSize >= (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))))
@@ -985,6 +994,24 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
985994
std::locale::global(std::locale(""));
986995

987996
// Process command line
997+
if (argc < 2)
998+
{
999+
PrintUsage();
1000+
return 0;
1001+
}
1002+
1003+
// check for these first
1004+
if (!_wcsicmp(argv[1], L"help") || !_wcsicmp(argv[1], L"/?"))
1005+
{
1006+
PrintUsage(true);
1007+
return 0;
1008+
}
1009+
else if (!_wcsicmp(argv[1], L"feedback"))
1010+
{
1011+
std::ignore = ShellExecuteW(nullptr, L"open", g_FeedbackURL, nullptr, nullptr, SW_SHOW);
1012+
return 0;
1013+
}
1014+
9881015
uint32_t dwOptions = 0;
9891016
std::list<SConversion> conversion;
9901017
bool allowOpts = true;
@@ -1056,7 +1083,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
10561083
return 0;
10571084

10581085
case OPT_HELP:
1059-
PrintUsage();
1086+
PrintUsage(true);
10601087
return 0;
10611088

10621089
default:

0 commit comments

Comments
 (0)